[
  {
    "path": ".gitignore",
    "content": "doc/html\n"
  },
  {
    "path": "CMakeLists.txt",
    "content": "PROJECT(sisl)\n\nCMAKE_MINIMUM_REQUIRED(VERSION 2.8)\n\n# Organize the project in folders (VS only?)\nSET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON)\n\n# Include directories\n\nINCLUDE_DIRECTORIES(\n  ${sisl_SOURCE_DIR}/include\n  )\n\n\n# Make the sisl library\n\nFILE(GLOB sisl_SRCS src/*.c include/*.h)\nADD_LIBRARY(sisl ${sisl_SRCS})\nIF(CMAKE_COMPILER_IS_GNUCC)\n    TARGET_LINK_LIBRARIES(sisl m)\nENDIF(CMAKE_COMPILER_IS_GNUCC)\nSET_PROPERTY(TARGET sisl\n  PROPERTY FOLDER \"sisl/Libs\")\n\n# This line may be needed only on AMD 64 bit...\n#IF(NOT WIN32)\n#  SET_TARGET_PROPERTIES(sisl PROPERTIES COMPILE_FLAGS \"-fPIC\")\n#ENDIF(NOT WIN32)\n\n\n# Set various compiler flags\nIF(CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\")\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -Wall -Wno-unused-but-set-variable -fPIC\")\n  SET(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} -Wall -Wno-unused-but-set-variable -fPIC\")\nENDIF(CMAKE_CXX_COMPILER_ID STREQUAL \"GNU\")\nIF(WIN32)\n  SET(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} /MP8 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS\")\n  SET(CMAKE_C_FLAGS \"${CMAKE_C_FLAGS} /MP8 -D_SCL_SECURE_NO_WARNINGS -D_CRT_SECURE_NO_WARNINGS\")\nENDIF(WIN32)\n\n\n# Apps, examples, tests, ...?\n\noption(sisl_COMPILE_APPS \"Compile apps?\" OFF)\n\noption(sisl_COMPILE_EXAMPLES \"Compile examples?\" OFF)\n\noption(sisl_COMPILE_VIEWER \"Compile viewer?\" OFF)\n\nIF(sisl_COMPILE_APPS)\n  FILE(GLOB sisl_APPS app/*.[cC])\n  FOREACH(app ${sisl_APPS})\n    GET_FILENAME_COMPONENT(appname ${app} NAME_WE)\n    ADD_EXECUTABLE(${appname} ${app})\n    TARGET_LINK_LIBRARIES(${appname} sisl sisl_streaming)\n    SET_TARGET_PROPERTIES(${appname}\n      PROPERTIES RUNTIME_OUTPUT_DIRECTORY app)\n  ENDFOREACH(app)\nENDIF()\n\nIF(sisl_COMPILE_EXAMPLES OR sisl_COMPILE_VIEWER OR sisl_COMPILE_APPS)\n  INCLUDE_DIRECTORIES(\n    ${sisl_SOURCE_DIR}/streaming/include\n    )\n\n  FILE(GLOB sisl_go_SRCS streaming/src/*.cpp streaming/include/*.h)\n  ADD_LIBRARY(sisl_streaming ${sisl_go_SRCS})\n  # IF(CMAKE_COMPILER_IS_GNUCC)\n  #     TARGET_LINK_LIBRARIES(sisl_go m)\n  # ENDIF(CMAKE_COMPILER_IS_GNUCC)\nENDIF()\n\nIF(sisl_COMPILE_EXAMPLES)\n  FILE(GLOB sisl_APPS2 examples/*.cpp)\n  FOREACH(app ${sisl_APPS2})\n    GET_FILENAME_COMPONENT(appname ${app} NAME_WE)\n    ADD_EXECUTABLE(${appname} ${app})\n    TARGET_LINK_LIBRARIES(${appname} sisl sisl_streaming)\n    SET_TARGET_PROPERTIES(${appname}\n      PROPERTIES RUNTIME_OUTPUT_DIRECTORY examples)\n  ENDFOREACH(app)\nENDIF()\n\nIF(sisl_COMPILE_VIEWER)\n\n  find_package(OpenGL REQUIRED)\n\n  find_path(OPENGL_INCLUDE_DIR\n            gl.h\n            PATH_PREFIXES GL\n            PATHS\n            /usr/local/include\n            /usr/include\n            \"$ENV{HOME}\\\\Install\\\\include\" # For some reason HOME is not found in VS 2019.\n            \"C:\\\\Users\\\\$ENV{USERNAME}\\\\Install\\\\include\"\n\t    \"C:\\\\local\\\\include\"\n            )\n\n  if(WIN32)\n\n    find_path(GLUT_INCLUDE_DIR\n              glut.h\n              PATH_PREFIXES GL\n              PATHS\n              \"$ENV{PROGRAMW6432}/Microsoft SDKs/Windows/v6.0A/Include\"\n              \"$ENV{HOME}\\\\Install\\\\include\" # For some reason HOME is not found in VS 2019.\n              \"C:\\\\Users\\\\$ENV{USERNAME}\\\\Install\\\\include\"\n\t      \"C:\\\\local\\\\include\"\n              )\n    if(${MSVC_VERSION} EQUAL 1900)\n      set(MSVC_NAME \"msvc2015_\")\n      # MESSAGE(\"Visual Studio 2015!\")\n    elseif((${MSVC_VERSION} GREATER_EQUAL 1920) AND (${MSVC_VERSION} LESS 1930))\n      # MESSAGE(\"Visual Studio 2019!\")\n      set(MSVC_NAME \"msvc2019_\")\n    elseif((${MSVC_VERSION} GREATER_EQUAL 1930) AND (${MSVC_VERSION} LESS 1950))\n      set(MSVC_NAME \"msvc2022_\")\n    else()\n      message(\"MSVC version not supported or not installed!\")\n    endif()\n    if(CMAKE_CL_64)\n      set(WIN_LIB_TYPE \"64\")\n    else()\n      set(WIN_LIB_TYPE \"32\")\n    endif()\n\n    find_library( GLUT_LIBRARY_RELEASE NAMES freeglut\n    \t\t  PATHS\n  \t\t  \"~/Install/${MSVC_NAME}lib${WIN_LIB_TYPE}/Release\"\n  \t\t  \"C:/local/${MSVC_NAME}lib${WIN_LIB_TYPE}/Release\"\n                  ${GLUT_ROOT_PATH}/Release\n                  #\"~/Install/${MSVC_NAME}lib${WIN_LIB_TYPE}/Release\"\n                 )\n\n    find_library( GLUT_LIBRARY_DEBUG NAMES freeglutd\n    \t\t  PATHS\n                  ${GLUT_ROOT_PATH}/Debug\n\t\t  \"~/Install/${MSVC_NAME}lib${WIN_LIB_TYPE}/Debug\"\n\t\t  \"C:/local/${MSVC_NAME}lib${WIN_LIB_TYPE}/Debug\"\n                  #\"~/Install/${MSVC_NAME}lib${WIN_LIB_TYPE}/Debug\"\n                 )\n    # message(\"GLUT_LIBRARY_RELEASE: ${GLUT_LIBRARY_RELEASE}\")\n    # message(\"GLUT_LIBRARY_DEBUG: ${GLUT_LIBRARY_DEBUG}\")\n    \n    set(GLUT_glut_LIBRARY \"\")\n    # message(\"GLUT_glut_LIBRARY: ${GLUT_glut_LIBRARY}\")\n    if(GLUT_LIBRARY_DEBUG)\n      set(GLUT_glut_LIBRARY ${GLUT_glut_LIBRARY} debug ${GLUT_LIBRARY_DEBUG})\n    endif()\n    if(GLUT_LIBRARY_RELEASE)\n      set(GLUT_glut_LIBRARY ${GLUT_glut_LIBRARY} optimized ${GLUT_LIBRARY_RELEASE})\n    endif()\n    # message(\"GLUT_glut_LIBRARY: ${GLUT_glut_LIBRARY}\")\n  else()\n    find_package(GLUT REQUIRED)  \n  endif()\n\n  INCLUDE_DIRECTORIES(\n    ${sisl_SOURCE_DIR}/viewer/include\n    ${OPENGL_INCLUDE_DIR}\n    ${GLUT_INCLUDE_DIR}\n    )\n\n  # message(\"GLUT_INCLUDE_DIR: ${GLUT_INCLUDE_DIR}\")\n  # message(\"GLUT_INCLUDE_PATH: ${GLUT_INCLUDE_PATH}\")\n  # message(\"GLUT_glut_LIBRARY_RELEASE: ${GLUT_glut_LIBRARY_RELEASE}\")\n  # message(\"GLUT_glut_LIBRARY_DEBUG: ${GLUT_glut_LIBRARY_DEBUG}\")\n  # message(\"GLUT_glut_LIBRARY: ${GLUT_glut_LIBRARY}\")\n  # message(\"OPENGL_LIBRARIES: ${OPENGL_LIBRARIES}\")\n  # message(\"MSVC_NAME lib WIN_LIB_TYPE: ${MSVC_NAME}lib${WIN_LIB_TYPE}\")\n\n  FILE(GLOB sisl_viewer_SRCS viewer/src/*.cpp viewer/include/*.h)\n  ADD_LIBRARY(sisl_viewer ${sisl_viewer_SRCS})\n  IF(CMAKE_COMPILER_IS_GNUCC)\n    TARGET_LINK_LIBRARIES(sisl_streaming sisl)\n  ENDIF(CMAKE_COMPILER_IS_GNUCC)\n\n  FILE(GLOB sisl_APPS3 viewer/*.cpp)\n  FOREACH(app ${sisl_APPS3})\n    GET_FILENAME_COMPONENT(appname ${app} NAME_WE)\n    ADD_EXECUTABLE(${appname} ${app})\n    TARGET_LINK_LIBRARIES(${appname} sisl sisl_streaming sisl_viewer ${OPENGL_LIBRARIES} ${GLUT_glut_LIBRARY})\n    SET_TARGET_PROPERTIES(${appname}\n      PROPERTIES RUNTIME_OUTPUT_DIRECTORY viewer)\n  ENDFOREACH(app)\nENDIF()\n\n\n# 'install' target\n\n# Set the installation prefix based on platform\nIF(WIN32)\n  SET(sisl_INSTALL_PREFIX \"$ENV{PROGRAMFILES}/SINTEF/sisl\" CACHE PATH \"Path to install sisl\")\nELSE()\n  SET(sisl_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\" CACHE PATH \"Path to install sisl\")\nENDIF()\n\n# === Install Targets and Export CMake Package ===\ninclude(CMakePackageConfigHelpers)\n\ntarget_include_directories(sisl INTERFACE\n  $<BUILD_INTERFACE:${sisl_SOURCE_DIR}/include>\n)\n\nexport(TARGETS sisl FILE sislTargets.cmake)\n\n# Install the sisl target with export\ninstall(TARGETS sisl\n    EXPORT sislTargets\n    ARCHIVE DESTINATION ${sisl_INSTALL_PREFIX}/lib\n    LIBRARY DESTINATION ${sisl_INSTALL_PREFIX}/lib\n    RUNTIME DESTINATION ${sisl_INSTALL_PREFIX}/bin\n    INCLUDES DESTINATION ${sisl_INSTALL_PREFIX}/include\n)\n\n# Install header files\ninstall(DIRECTORY include/\n    DESTINATION ${sisl_INSTALL_PREFIX}/include\n    FILES_MATCHING PATTERN \"*.h\"\n)\n\n# Export target info to a file\ninstall(EXPORT sislTargets\n    FILE sislTargets.cmake\n    #NAMESPACE sisl::             # Allow target_link_libraries(MyApp sisl::sisl)\n    DESTINATION ${sisl_INSTALL_PREFIX}/lib/cmake/sisl\n)\n\n# Generate and install version/config files\nwrite_basic_package_version_file(\n    \"${CMAKE_CURRENT_BINARY_DIR}/sislConfigVersion.cmake\"\n    VERSION 4.6.0\n    COMPATIBILITY SameMajorVersion\n)\n\nconfigure_package_config_file(\n    \"${CMAKE_CURRENT_SOURCE_DIR}/cmake/sislConfig.cmake.in\"\n    \"${CMAKE_CURRENT_BINARY_DIR}/sislConfig.cmake\"\n    INSTALL_DESTINATION ${sisl_INSTALL_PREFIX}/lib/cmake/sisl\n)\n\ninstall(FILES\n    \"${CMAKE_CURRENT_BINARY_DIR}/sislConfig.cmake\"\n    \"${CMAKE_CURRENT_BINARY_DIR}/sislConfigVersion.cmake\"\n    DESTINATION ${sisl_INSTALL_PREFIX}/lib/cmake/sisl\n)\n\n# CPack setup for packaging if needed\nIF(NOT GoTools_ALL_COMPILE)\n  SET(CPACK_SOURCE_PACKAGE_FILE_NAME \"sisl-4.6.0\")\n  SET(CPACK_SOURCE_IGNORE_FILES \"/CVS/;/\\\\.svn/;\\\\.swp$;\\\\.#;/#;.*~\")\n  INCLUDE(CPack)\nENDIF()\n\nSET(CPACK_STRIP_FILES ${CPACK_STRIP_FILES} libsisl.so)\n"
  },
  {
    "path": "COPYING",
    "content": "                    GNU AFFERO GENERAL PUBLIC LICENSE\n                       Version 3, 19 November 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU Affero General Public License is a free, copyleft license for\nsoftware and other kinds of works, specifically designed to ensure\ncooperation with the community in the case of network server software.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nour General Public Licenses are intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  Developers that use our General Public Licenses protect your rights\nwith two steps: (1) assert copyright on the software, and (2) offer\nyou this License which gives you legal permission to copy, distribute\nand/or modify the software.\n\n  A secondary benefit of defending all users' freedom is that\nimprovements made in alternate versions of the program, if they\nreceive widespread use, become available for other developers to\nincorporate.  Many developers of free software are heartened and\nencouraged by the resulting cooperation.  However, in the case of\nsoftware used on network servers, this result may fail to come about.\nThe GNU General Public License permits making a modified version and\nletting the public access it on a server without ever releasing its\nsource code to the public.\n\n  The GNU Affero General Public License is designed specifically to\nensure that, in such cases, the modified source code becomes available\nto the community.  It requires the operator of a network server to\nprovide the source code of the modified version running there to the\nusers of that server.  Therefore, public use of a modified version, on\na publicly accessible server, gives the public access to the source\ncode of the modified version.\n\n  An older license, called the Affero General Public License and\npublished by Affero, was designed to accomplish similar goals.  This is\na different license, not a version of the Affero GPL, but Affero has\nreleased a new version of the Affero GPL which permits relicensing under\nthis license.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU Affero General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Remote Network Interaction; Use with the GNU General Public License.\n\n  Notwithstanding any other provision of this License, if you modify the\nProgram, your modified version must prominently offer all users\ninteracting with it remotely through a computer network (if your version\nsupports such interaction) an opportunity to receive the Corresponding\nSource of your version by providing access to the Corresponding Source\nfrom a network server at no charge, through some standard or customary\nmeans of facilitating copying of software.  This Corresponding Source\nshall include the Corresponding Source for any work covered by version 3\nof the GNU General Public License that is incorporated pursuant to the\nfollowing paragraph.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the work with which it is combined will remain governed by version\n3 of the GNU General Public License.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU Affero General Public License from time to time.  Such new versions\nwill be similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU Affero General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU Affero General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU Affero General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Affero General Public License as published by\n    the Free Software Foundation, either version 3 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 Affero General Public License for more details.\n\n    You should have received a copy of the GNU Affero General Public License\n    along with this program.  If not, see <http://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If your software can interact with users remotely through a computer\nnetwork, you should also make sure that it provides a way for users to\nget its source.  For example, if your program is a web application, its\ninterface could display a \"Source\" link that leads users to an archive\nof the code.  There are many ways you could offer source, and different\nsolutions will be better for different programs; see section 13 for the\nspecific requirements.\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU AGPL, see\n<http://www.gnu.org/licenses/>.\n"
  },
  {
    "path": "ChangeLog",
    "content": "2021-03-16\tVibeke Skytt \t<Vibeke.Skytt@sintef.no>\n\t* Released version 4.7 of SISL. The main updates are related to\n\tdocumentation.\n\t\n2013-06-06\tJan Thomassen\t<jan.b.thomassen@sintef.no>\n\t* Released version 4.6.0 of SISL.\n\t* Updated license to dual license: GNU Affero  GPL 3 or\n\tcommercial\n\t* Fixed a number of bugs.\n\n16.9.2010\tJan Thomassen\t<jan.b.thomassen@sintef.no>\n\t* Released version 4.5.0 of SISL. This is a minor update from the\n\tprevious version.\n\t* Changed building system to CMake.\n\t* Fixed a number of bugs.\n\n3.2.2005\n\t* Released version 4.4 of SISL.\n"
  },
  {
    "path": "INSTALL",
    "content": "Installation Instructions\n*************************\n\nThis package uses CMake to generate a Makefile (on Linux) or\nMS Visual Studio project file (on Windows).\n\nFor information on using CMake, see www.cmake.org.\n\nA more extensive guide on how to compile and link the SISL library and \napplications build upon it can be found in the reference manual.\n\n--------------------------------------------------------------------------------\n\nLINUX\n\nAs a Quick Start Guide, on Linux, make a build directory inside the source\ndirectory\n$ cd <path_to_source_code>\n$ mkdir build\n$ cd build\n\nRun the cmake program to setup the build process, selecting Debug or Release\nas build type, optionally selecting a local install folder:\n$ cmake .. -DCMAKE_BUILD_TYPE=Release (-DCMAKE_INSTALL_PREFIX=$HOME/install)\n\nFor a gui-like cmake interface use ccmake (from cmake-ncurses-gui).\n\nBuild the library:\n$ make\n\nInstall the library to a local folder (requires the use of\n-DCMAKE_INSTALL_PREFIX with a local folder in the previous step):\n$ make install\n\nIf the -DCMAKE_INSTALL_PREFIX in the cmake step was omitted or was set to a\nsystem folder (like /usr/local) the user needs elevated privileges to install\nthe library:\n$ sudo make install\n\n--------------------------------------------------------------------------------\n\nWINDOWS\n\nOn Windows, add a new build folder somewhere. Start the CMake\nexecutable and fill in the paths to the source and build folders. When\nyou run CMake, a Visual Studio project solution file will be generated\nin the build folder.\n"
  },
  {
    "path": "README",
    "content": "SISL is a comprehensive NURBS library for the modeling and\ninterrogation of curves and surfaces. It is implemented in C.\n\nThis software was written by the Geometry Group at SINTEF Digital,\nDepartment of Mathematics and Cybernethics.\n\nRequirements:\n* CMake\n  www.cmake.org\n\nFor information on installation, see the INSTALL file.\n\nGood luck!\n\n\n "
  },
  {
    "path": "app/prog1.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl.h\"\n#include <stdlib.h>\n#include <stdio.h>\nint main()\n{\n  SISLCurve *pc=NULL;\n  double aepsco,aepsge,top[3],axispt[3],conept[3];\n  double st[100],stcoef[100],*spar=NULL;\n  int kstat;\n  int cone_exists=0;\n  int kk,kn,kdim,ki;\n  int kpt,kcrv;\n  SISLIntcurve **qrcrv=NULL;\n  char ksvar[100];\n  kdim=3;\n  aepsge=0.001; /* geometric tolerance */\n  aepsco=0.000001; /* computational tolerance This parameter is included from historical reasons\n                      and no longer used  */\n\n  ksvar[0] = '0';  /* arbitrary character */\n  while (ksvar[0] != 'q')\n    {\n      printf(\"\\n cu - define a new B-spline curve\");\n      printf(\"\\n co - define a new cone\");\n      printf(\"\\n i - intersect the B-spline curve with the cone\");\n      printf(\"\\n q - quit\");\n      printf(\"\\n> \");\n      scanf(\"%s\",ksvar);\n\n      if (ksvar[0] == 'c' && ksvar[1] == 'u')\n\t{\n\t  printf(\"\\n Give number of vertices, order of curve: \");\n\t  scanf(\"%d %d\", &kn, &kk);\n\t  printf(\"Give knots values in ascending order: \\n\");\n\t  for (ki=0;ki<kn+kk;ki++)\n\t    {\n\t      scanf(\"%lf\",&st[ki]);\n\t    }\n\t  printf(\"Give vertices \\n\");\n\t  for (ki=0;ki<kn*kdim;ki++)\n\t    {\n\t      scanf(\"%lf\",&stcoef[ki]);\n\t    }\n\t  if(pc) freeCurve(pc);\n\t  pc = newCurve(kn,kk,st,stcoef,1,kdim,1);\n\t}\n      else if (ksvar[0] == 'c' && ksvar[1] == 'o')\n\t{\n\t  printf(\"\\n Give top point: \");\n\t  scanf(\"%lf %lf %lf\",&top[0],&top[1],&top[2]);\n\t  printf(\"\\n Give a point on the axis: \");\n\t  scanf(\"%lf %lf %lf\",&axispt[0],&axispt[1],&axispt[2]);\n\t  printf(\"\\n Give a point on the cone surface: \");\n\t  scanf(\"%lf %lf %lf\",&conept[0],&conept[1],&conept[2]);\n\t  cone_exists=1;\n\t}\n      else if (ksvar[0] == 'i' && cone_exists && pc)\n\t{\n\t  s1373(pc,top,axispt,conept,kdim,aepsco,aepsge,\n\t\t&kpt,&spar,&kcrv,&qrcrv,&kstat);\n\t  printf(\"\\n kstat %d\",kstat);\n\t  printf(\"\\n kpt %d\",kpt);\n\t  printf(\"\\n kcrv %d\",kcrv);\n\t  for (ki=0;ki<kpt;ki++)\n\t    {\n\t      printf(\"\\nIntersection point %lf\",spar[ki]);\n\t    }\n\t  if (spar)\n\t    {\n\t      free (spar);\n\t      spar=NULL;\n\t    }\n\t  if (qrcrv)\n\t    {\n\t      freeIntcrvlist(qrcrv,kcrv);\n\t      qrcrv=NULL;\n\t    }\n\t}\n    }\n  return 0;\n}\n"
  },
  {
    "path": "app/s1013prob.C",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl.h\"\n#include <iostream>\n\n\nusing namespace std;\n\n\nint main()\n{\n    int dim = 2;\n    int kind = 1;\n    double coefs[] = { -1, 1, 0, 0, 1, 0, 1, 1 };\n    double knots[] = { 0, 0, 0, 0, 1, 1, 1, 1 };\n    int num = 4;\n    int order = 4;\n    SISLCurve* sc = newCurve(num, order, knots, coefs, kind, dim, 1);\n\n    double itpar;\n    int stat;\n    s1013(sc, 1.0, 0.01, 0.3, &itpar, &stat);\n    double pt[4];\n    int kleft;\n    s1221(sc, 1, itpar, &kleft, pt, &stat);\n\n    cout << itpar << ' ' << pt[2] << ' ' << pt[3] << endl;\n}\n"
  },
  {
    "path": "app/s1320prob.C",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl.h\"\n#include <cmath>\n#include <stdlib.h>\n#include <iostream>\n \n\nusing namespace std;\n\n\nint main()\n{\n  // unsigned n;\n  const unsigned dim = 2;\n  const unsigned NoPoints = 3;\n  const unsigned Order = 3;\n  int state, NoIntPoints, NoIntCurves;\n  double* IntPointsOnCurve;\n  double* IntPointsOnLine;\n  SISLIntcurve** IntCurves;\n  SISLCurve* Line = NULL;\n  SISLCurve* Curve = NULL;\n  double endPar;\n  double knots[NoPoints+Order];\n  double coef[(dim+1)*NoPoints];\n  // define line\n  double a[] = { 0.0, 4.0};\n  double b[] = { 4.0, 4.0};\n \n  // generate control polygon\n\n   \n  coef[ 0] =  0.0;\n  coef[ 1] =  0.0;\n  coef[ 2] =  1.0;\n \n  coef[ 3] =  2.0 * sqrt(2.0)/2.0;\n  coef[ 4] =  2.0 * sqrt(2.0)/2.0;\n  coef[ 5] =  1.0 * sqrt(2.0)/2.0;\n \n  coef[ 6] =  4.0;\n  coef[ 7] =  0.0;\n  coef[ 8] =  1.0;\n\n\n  /*\n  coef[ 0] =  0.0;\n  coef[ 1] =  0.0;\n  coef[ 2] =  0.0;\n  coef[ 3] =  1.0;\n \n  coef[ 4] =  2.0 * sqrt(2.0)/2.0;\n  coef[ 5] =  2.0 * sqrt(2.0)/2.0;\n  coef[ 6] =  0.0;\n  coef[ 7] =  1.0 * sqrt(2.0)/2.0;\n \n  coef[ 8] =  4.0;\n  coef[ 9] =  0.0;\n  coef[ 10] =  0.0;\n coef[ 11] =  1.0;\n  */\n\n  /*\n  coef[0] = 0.0;\n  coef[1] =  0.0;\n  coef[2] =  2.0;\n  coef[3] =  2.0;\n  coef[4] =  4.0;\n  coef[5] =  0.0;\n  */\n\n  // generate knots\n  knots[0] = 0.0;\n  knots[1] = 0.0;\n  knots[2] = 0.0;\n  knots[3] = 1.0;\n  knots[4] = 1.0;\n  knots[5] = 1.0;\n \n  // ask SISL for a curve.\n  Curve = newCurve(NoPoints, Order, knots, coef, 4, dim, 1);\n \n  // ask SISL for a line.\n  s1602(a, b, Order, dim, 0.0, &endPar, &Line, &state);\n \n  if (state!=0)\n    return 1;\n \n  // least distance between lines\n  // Denne linja krasjer\n  s1955(Curve, Line, 1E-3, 1E-3, &NoIntPoints, &IntPointsOnCurve,\n        &IntPointsOnLine, &NoIntCurves, &IntCurves, &state);\n \n  cout << NoIntPoints << ' ' << IntPointsOnCurve[0] << ' ' \n       << IntPointsOnLine[0] << endl;\n\n  // cleanup\n  freeCurve(Curve);\n  freeCurve(Line);\n  free(IntPointsOnCurve);\n  free(IntPointsOnLine);\n  freeIntcrvlist(IntCurves, NoIntCurves);\n}\n\n\n\n\n\n\n\n"
  },
  {
    "path": "app/s1606prob.C",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl.h\"\n#include <iostream>\n\n\nusing namespace std;\n\n\nint main()\n{\n    double knots[4]\n\t= {0.0, 0.0, 1.0, 1.0};\n    double c0[6]\n\t= { 0.000002, 0.000150, 0.000000, 0.000000, 0.000000, 0.000000 };\n    double c1[6]\n\t= { 0.000000, 0.001768, -0.001768, 0.000000, 0.001914, -0.001914 };\n//      double c0[6]\n//  \t= { 0, 0, 0, 1, 0, 0 };\n//      double c1[6]\n//  \t= { 2, 1, 1, 2, 2, 1 };\n\n    SISLCurve* cv[3];\n    cv[0] = newCurve(2, 2, knots, c0, 1, 3, 0);\n    cv[1] = newCurve(2, 2, knots, c1, 1, 3, 0);\n    cv[2] = 0;\n    double epsge = 1e-6;\n    double point0[3] = {0.000000, 0.001768, -0.001768};\n    double point1[3] = {0.000002, 0.000150,  0.000000};\n//      double point0[3] = { 1, 0, 0 };\n//      double point1[3] = { 2, 1, 1 };\n    int blendtype = 2;\n    int dim = 3;\n    int order = 4;\n    int stat;\n//      double epoint[12] = { 0.000002, 0.000150, 0.000000,\n//  \t\t\t  0.013332148306149432, 0.99991112296120743, 0,\n//  \t\t\t  0, 0.001768, -0.001768,\n//  \t\t\t  0, 0.70710678118654746, -0.70710678118654746 };\n    // double epoint[12] = { 0, 0, 0,\n    // \t\t\t  1, 0, 0,\n    // \t\t\t  0, 0, 1,\n    // \t\t\t  0.000000001, 1, 0 };\n    // double eptyp[4] = { 1, 4, 1, 4 };\n    s1606(cv[0], cv[1], epsge, point0, point1,\n  \t  blendtype, dim, order, &cv[2], &stat);\n    // double astpar = 0.0;\n    // double cendpar;\n    // double aepsge = 1e-6;\n    //    s1611(epoint, 4, 3, eptyp, 1, 4, astpar, aepsge, &cendpar, &cv[2], &stat);\n    int n = cv[2]->in;\n    int k = cv[2]->ik;\n    // int t = cv[2]->ikind;\n    int d = cv[2]->idim;\n    cout.precision(15);\n    cout << \"GoNurbsCurve3D\\ndimension 3\\nbounding_box 0\\n\"\n\t << \"attribute_list_length 0\\nparameters \"\n\t << cv[2]->et[k-1] << ' ' << cv[2]->et[n] << '\\n'\n\t << \"periodic 0\\nbspline_basis\\nnum_coeffs \"\n\t << n << \"\\norder \" << k << \"\\nknot_vector\\n\";\n    for (int i = 0; i < n + k; ++i) {\n  \tcout << cv[2]->et[i] << ' ';\n    }\n    cout << \"\\nkind 1\\ndim 3\\ncoefficients\\n\";\n    for (int i = 0; i < n; ++i) {\n\tfor (int j = 0; j < d; ++j) {\n\t    cout << cv[2]->ecoef[i*d + j] << ' ';\n\t}\n\tcout << '\\n';\n    }\n    cout << \"closedness -1\" << endl;\n}\n"
  },
  {
    "path": "app/surf_surf_int.C",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <stdexcept>\n#include <cstdlib>\n\n#include \"sisl.h\"\n#include \"GoReadWrite.h\"\n\nusing namespace std;\n\n\n\n//===========================================================================\nint main(int avnum, char** vararg)\n//===========================================================================\n{\n  ifstream is_sf1(vararg[1]);\n  ifstream is_sf2(vararg[2]);\n  double eps = atof(vararg[3]);\n  ofstream os(vararg[4]);\n\n  try {\n\n\n    // reading surfaces\n    SISLSurf* surf_1 = readGoSurface(is_sf1);\n    SISLSurf* surf_2 = readGoSurface(is_sf2);\n\n    // detecting (but not tracing out) intersection curves\n    double epsco = 1.0e-15; // computational epsilon\n    double epsge = 1.0e-5; // geometric tolerance\n    int num_int_points = 0; // number of detected intersection points\n    double* intpar_surf_1  = 0; // parameter values for the surface in the intersections\n    double* intpar_surf_2 = 0; // parameter values for the curve in the intersections\n    int num_int_curves = 0;   // number of intersection curves\n    SISLIntcurve** intcurve = 0; // pointer to array of detected intersection curves\n    int jstat = 0; // status variable\n\n    // calculating topology of intersections\n    s1859(surf_1,          // the first surface\n\t  surf_2,          // the second surface\n\t  epsco,           // computational resolution\n\t  eps,           // geometry resolution\n\t  &num_int_points, // number of single intersection points\n\t  &intpar_surf_1,  // pointer to array of parameter values for surface 1\n\t  &intpar_surf_2,  //               -\"-                    for surface 2\n\t  &num_int_curves, // number of detected intersection curves\n\t  &intcurve,       // pointer to array of detected intersection curves.\n\t  &jstat);         // status variable\n\t\n    if (jstat < 0) {\n      throw runtime_error(\"Error occured inside call to SISL routine s1859.\");\n    } else if (jstat > 0) {\n      cerr << \"WARNING: warning occured inside call to SISL routine s1859. \\n\" \n\t   << endl;\n    }\n\n    // In this example, we expect to detect two intersection curves, but no isolated\n    // intersection points.\n\n    cout << \"Number of intersection points detected: \" << num_int_points << endl;\n    for (int i=0; i<num_int_points; ++i)\n      cout << intpar_surf_1[2*i] << \" \" << intpar_surf_1[2*i+1] << \" \" << intpar_surf_2[2*i] << \" \" << intpar_surf_2[2*i+1] << endl;\n    cout << \"Number of intersection curves detected: \" << num_int_curves << endl;\n    for (int i=0; i<num_int_curves; ++i)\n      {\n\tint npt = intcurve[i]->ipoint;\n\tcout << intcurve[i]->epar1[0] << \" \" << intcurve[i]->epar1[1] << \" \" ;\n\tcout << intcurve[i]->epar2[0] << \" \" << intcurve[i]->epar2[1] << \" \" ;\n\t// evaluating (tracing out) intersection curves and writing them to file\n\tcout << intcurve[i]->epar1[2*(npt-1)] << \" \" << intcurve[i]->epar1[2*npt-1] << \" \" ;\n\tcout << intcurve[i]->epar2[2*(npt-1)] << \" \" << intcurve[i]->epar2[2*npt-1] << endl;\n      }\n    for (int i = 0; i < num_int_curves; ++i) {\n      s1310(surf_1,          // the first surface\n\t    surf_2,          // the second surface\n\t    intcurve[i],     // pointer to the intersection curve object \n\t    epsge,           // geometric tolerance\n\t    double(0),       // maximum step size (ignored if <= 0)\n\t    1,               // make only 3D curve (no 2D curve in parametric domain)\n\t    0,               // don't draw the curve\n\t    &jstat);\n      if (jstat < 0) {\n\tthrow runtime_error(\"Error occured inside call to SISL routine s1310.\");\n      } else if (jstat == 3) {\n\tthrow runtime_error(\"Iteration stopped due to singular point or degenerate \"\n\t\t\t    \"surface.\");\n      }\n      writeGoCurve(intcurve[i]->pgeom, os);\n    }\n\n    // cleaning up\n    if (surf_1) freeSurf(surf_1);\n    if (surf_2) freeSurf(surf_2);\n    is_sf1.close();\n    is_sf2.close();\n    os.close();\n    if (intpar_surf_1) free(intpar_surf_1);\n    if (intpar_surf_2) free(intpar_surf_2);\n    if (num_int_curves > 0)\n      freeIntcrvlist(intcurve, num_int_curves);\n\n  } catch (exception& e) {\n    cerr << \"Exception thrown: \" << e.what() << endl;\n    return 0;\n  }\n\n  return 1;\n};\n"
  },
  {
    "path": "cmake/sislConfig.cmake.in",
    "content": "@PACKAGE_INIT@\n\ninclude(\"${CMAKE_CURRENT_LIST_DIR}/sislTargets.cmake\")\n\n# Legacy compatibility\nset(sisl_LIBRARIES sisl)\n\n# Optional: make include dir available\nset(sisl_INCLUDE_DIRS \"@CMAKE_INSTALL_PREFIX@/include\")\n"
  },
  {
    "path": "doc/manual/chap_curve_analysis.ilg",
    "content": "This is makeindex, version 2.14 [02-Oct-2002] (kpathsea + Thai support).\nScanning input file chap_curve_analysis.tex...\n!! Input index error (file = chap_curve_analysis.tex, line = 1):\n   -- Unknown index keyword \\chapter.\n!! Input index error (file = chap_curve_analysis.tex, line = 2):\n   -- Unknown index keyword \\label.\n!! Input index error (file = chap_curve_analysis.tex, line = 4):\n   -- Missing arguments -- need two (premature LFD).\n!! Input index error (file = chap_curve_analysis.tex, line = 6):\n   -- Unknown index keyword \\section.\n!! Input index error (file = chap_curve_analysis.tex, line = 7):\n   -- Unknown index keyword \\input.\n!! Input index error (file = chap_curve_analysis.tex, line = 8):\n   -- Missing arguments -- need two (premature LFD).\n!! Input index error (file = chap_curve_analysis.tex, line = 9):\n   -- Unknown index keyword \\input.\n!! Input index error (file = chap_curve_analysis.tex, line = 10):\n   -- Missing arguments -- need two (premature LFD).\n!! Input index error (file = chap_curve_analysis.tex, line = 11):\n   -- Unknown index keyword \\input.\n!! Input index error (file = chap_curve_analysis.tex, line = 12):\n   -- Missing arguments -- need two (premature LFD).\n!! Input index error (file = chap_curve_analysis.tex, line = 13):\n   -- Unknown index keyword \\input.\n!! Input index error (file = chap_curve_analysis.tex, line = 14):\n   -- Missing arguments -- need two (premature LFD).\n!! Input index error (file = chap_curve_analysis.tex, line = 15):\n   -- Unknown index keyword \\input.\n!! Input index error (file = chap_curve_analysis.tex, line = 16):\n   -- Missing arguments -- need two (premature LFD).\ndone (0 entries accepted, 14 rejected).\nNothing written in chap_curve_analysis.ind.\nTranscript written in chap_curve_analysis.ilg.\n"
  },
  {
    "path": "doc/manual/chap_curve_analysis.ind",
    "content": ""
  },
  {
    "path": "doc/manual/chap_curve_analysis.tex",
    "content": "\\chapter{Curve Analysis}\n\\label{curveanalysis}\n\nThis chapter describes the Curve Analysis part.\n\n\\section{Curvature Evaluation}\n\\input{func/s2550}\n\\pgsbreak\n\\input{func/s2553}\n\\pgsbreak\n\\input{func/s2556}\n\\pgsbreak\n\\input{func/s2559}\n\\pgsbreak\n\\input{func/s2562}\n\\pgsbreak\n"
  },
  {
    "path": "doc/manual/chap_curve_definition.tex",
    "content": "\\chapter{Curve Definition}\n\\label{curvedefinition}\n\nThis chapter describes all functions in the Curve Definition module.\n\\section{Interpolation}\nIn this section we treat different kinds of interpolation of\npoints or points and derivatives (Hermite). In addition to the general\nfunctions there are functions to find fillet curves\n(a curve between two other curves),\nand blending curves (a curve between the end points of two other curves).\n\\input{func/s1602}\n\\pgsbreak\n\\input{func/s1356}\n\\pgsbreak\n\\input{func/s1357}\n\\pgsbreak\n\\input{func/s1380}\n\\pgsbreak\n\\input{func/s1379}\n\\pgsbreak\n\\input{func/s1607}\n\\pgsbreak\n\\input{func/s1608}\n\\pgsbreak\n\\input{func/s1609}\n\\pgsbreak\n\\input{func/s1014}\n\\pgsbreak\n\\input{func/s1015}\n\\pgsbreak\n\\input{func/s1016}\n\\pgsbreak\n\\input{func/s1606}\n\\pgsbreak\n\\section{Approximation}\nTwo kinds of curves are treated in this section.\nThe first is approximations of special shapes like\ncircles and conic segments.\nThe second is approximation of a point set, or offsets to curves.\n\nExcept for the point set approximation function, all functions\nrequire a tolerance for the approximation.\nNote that there is a close relationship\nbetween the size of the tolerance and the amount of data\nfor the curve.\n\\input{func/s1303}\n\\pgsbreak\n\\input{func/s1611}\n\\pgsbreak\n\\input{func/s1630}\n\\pgsbreak\n\\input{func/s1360}\n\\pgsbreak\n\\input{func/s1613}\n\\pgsbreak\n\\input{func/s1600}\n\\pgsbreak\n\\section{Conversion}\n\\input{func/s1389}\n\\pgsbreak\n\\input{func/s1730}\n\\pgsbreak\n\\input{func/s1732}\n\\pgsbreak\n\\input{func/s1750}\n\\pgsbreak\n\\input{func/s1720}\n\\pgsbreak\n\\input{func/s1522}\n\\pgsbreak\n\\input{func/s1011}\n\\pgsbreak\n\\input{func/s1012}\n"
  },
  {
    "path": "doc/manual/chap_curve_interrogation.tex",
    "content": "\\chapter{Curve Interrogation}\n\\label{curveinterrogation}\nThis chapter describes the functions in the Curve Interrogation module.\n\\section{Intersections}\n\n\\input{func/s1871}\n\\pgsbreak\n\\input{func/s1850}\n\\pgsbreak\n\\input{func/s1327}\n\\pgsbreak\n\\input{func/s1371}\n\\pgsbreak\n\\input{func/s1374}\n\\pgsbreak\n\\input{func/s1857}\n\\pgsbreak\n\\input{func/s1240}\n\\pgsbreak\n\\input{func/s1364}\n\\pgsbreak\n\\input{func/s1451}\n\\pgsbreak\n\\input{func/s1363}\n\\pgsbreak\n\\section{Closest Points}\n\\input{func/s1953}\n\\pgsbreak\n\\input{func/s1957}\n\\pgsbreak\n\\input{func/s1774}\n\\pgsbreak\n\\input{func/s1955}\n\\pgsbreak\n\\input{func/s1013}\n\\pgsbreak\n\\input{func/s1920}\n\\pgsbreak\n\\section{Area between Curve and Point}\n\\input{func/s1241}\n\\pgsbreak\n\\input{func/s1243}\n\\pgsbreak\n\\section{Bounding Box}\nBoth curves and surfaces have bounding boxes. These are boxes surrounding an object not only parallel to the main axis, but also rotated 45 degrees around each main axis. These bounding boxes are used by the intersection functions to decide if an intersection is possible or not. They might also be used to find the position of objects under other circumstances.\n\\input{sec_box_object}\n\\pgsbreak\n\\input{func/s1988}\n\\pgsbreak\n\\section {Normal Cone}\nBoth curves and surfaces have normal cones. These are the cones that are convex hull of all normalized tangents of a curve and all normalized normals of a surface.\n\nThese normal cones are used by the intersection functions to decide if only one intersection is possible. They might also be used to find directions of objects for other reasons.\n\\input{sec_cone_object}\n\\pgsbreak\n\\input{func/s1986}\n"
  },
  {
    "path": "doc/manual/chap_curve_utilities.tex",
    "content": "\\chapter{Curve Utilities}\n\\label{curveutilities}\nThis chapter describes the Curve Utilities.\nThese are common to both the Curve Definition and Curve Interrogation modules.\n\\input{sec_curve_object}\n\n\\pgsbreak\n\\section{Evaluation}\n\\input{func/s1227}\n\\pgsbreak\n\\input{func/s1221}\n\\pgsbreak\n\\input{func/s1225}\n\\pgsbreak\n\\input{func/s1226}\n\\pgsbreak\n\\input{func/s1542}\n\n\\section {Subdivision}\n\\input{func/s1710}\n\\pgsbreak\n\\input{func/s1017}\n\\pgsbreak\n\\input{func/s1018}\n\\pgsbreak\n\\input{func/s1714}\n\\pgsbreak\n\\input{func/s1712}\n\\pgsbreak\n\\input{func/s1713}\n\\pgsbreak\n\\section{Joining}\n\\input{func/s1715}\n\\pgsbreak\n\\input{func/s1716}\n\\pgsbreak\n\\input{func/s1706}\n\\pgsbreak\n\\input{func/s1233}\n\n"
  },
  {
    "path": "doc/manual/chap_data_reduction.tex",
    "content": "\\chapter{Data Reduction}\n\\label{datareduction}\n\\section{Curves}\n\\input{func/s1940}\n\\pgsbreak\n\\input{func/s1961}\n\\pgsbreak\n\\input{func/s1962}\n\\pgsbreak\n\\input{func/s1963}\n\\pgsbreak\n\\section{Surfaces}\n\\input{func/s1965}\n\\pgsbreak\n\\input{func/s1966}\n\\pgsbreak\n\\input{func/s1967}\n\\pgsbreak\n\\input{func/s1968}\n"
  },
  {
    "path": "doc/manual/chap_error_codes.tex",
    "content": "\\chapter{Appendix: Error Codes}\n\\label{errorcodes}\nFor reference, here is a list of the error codes used in SISL.\nThey can be useful for diagnosing problems encountered\nwhen calling SISL routines.\nHowever please note that a small number of SISL routines\nuse their own convention.\n\n\\begin{verbatim}\nLabel Value  Description\n--------------------------------------------------------------------------------\nerr101 -101  Error in memory allocation.\n\nerr102 -102  Error in input. Dimension less than 1.\n\nerr103 -103  Error in input. Dimension less than 2.\n\nerr104 -104  Error in input. Dimension not equal 3.\n\nerr105 -105  Error in input. Dimension not equal 2 or 3.\n\nerr106 -106  Error in input. Conflicting dimensions.\n\nerr107 -107  \t\t\t\n\nerr108 -108  Error in input. Dimension not equal 2.\n\nerr109 -109  Error in input. Order less than 2.\n\nerr110 -110  Error in Curve description. Order less than 1.\n\nerr111 -111  Error in Curve description. Number of vertices less than order.\n\nerr112 -112  Error in Curve description. Error in knot vector.\n\nerr113 -113  Error in Curve description. Unknown kind of Curve.\n\nerr114 -114  Error in Curve description. Open Curve when expecting closed.\n\nerr115 -115  Error in Surf description. Order less than 1.\n\nerr116 -116  Error in Surf description. Number of vertices less than order.\n\nerr117 -117  Error in Surf description. Error in knot vector.\n\nerr118 -118  Error in Surf description. Unknown kind of Surf.\n\nerr119 -119\n\nerr120 -120  Error in input. Negative relative tolerance.\n\nerr121 -121  Error in input. Unknown kind of Object.\n\nerr122 -122  Error in input. Unexpected kind of Object found.\n\nerr123 -123  Error in input. Parameter direction does not exist.\n\nerr124 -124  Error in input. Zero length parameter interval.\n\nerr125 -125\n\nerr126 -126\n\nerr127 -127  Error in input. The whole curve lies on axis.\n\nerr128 -128\n\nerr129 -129\n\nerr130 -130  Error in input. Parameter value is outside parameter area.\n\nerr131 -131\n\nerr132 -132\n\nerr133 -133\n\nerr134 -134\n\nerr135 -135  Error in data structure.\n             Intersection point exists when it should not.\n\nerr136 -136  Error in data structure.\n             Intersection list exists when it should not.\n\nerr137 -137  Error in data structure.\n             Expected intersection point not found.\n\nerr138 -138  Error in data structure.\n             Wrong number of intersections on edges/endpoints.\n\nerr139 -139  Error in data structure.\n             Edge intersection does not lie on edge/endpoint.\n\nerr140 -140  Error in data structure. Intersection interval crosses\n             subdivision line when not expected to.\n   \t\t\t\t\t\t\nerr141 -141  Error in input. Illegal edge point requested.\n\nerr142 -142  \n\nerr143 -143\n\nerr144 -144  Unknown kind of intersection curve.\n\nerr145 -145  Unknown kind of intersection list (internal format).\n\nerr146 -146  Unknown kind of intersection type.\n\nerr147 -147\n\nerr148 -147\n\nerr149 -149\n\nerr150 -150  Error in input. NULL pointer was given.\n\nerr151 -151  Error in input. One or more illegal input values.\n\nerr152 -152  Too many knots to insert.\n\nerr153 -153  Lower level routine reported error. SHOULD use label \"error\".\n\nerr154 -154\n\nerr155 -155\n\nerr156 -156  Illegal derivative requested. Change this label to err178.\n\nerr157 -157\n\nerr158 -158  Intersection point outside Curve.\n\nerr159 -159  No of vertices less than 1. SHOULD USE err111 or err116.\n\nerr160 -160  Error in dimension of interpolation problem.\n\nerr161 -161  Error in interpolation problem.\n\nerr162 -162  Matrix may be noninvertible.\n\nerr163 -163  Matrix part contains diagonal elements.\n\nerr164 -164  No point conditions specified in interpolation problem.\n\nerr165 -165  Error in interpolation problem.\n\nerr166 -166\n\nerr167 -167\n\nerr168 -168\n\nerr169 -169\n\nerr170 -170  Internal error: Error in moving knot values.\n\nerr171 -171  Memory allocation failure: Could not create curve or surface.\n\nerr172 -172  Input error, inarr < 1 || inarr > 3.\n\nerr173 -173  Direction vector zero length.\n\nerr174 -174  Degenerate condition.\n\nerr175 -175  Unknown degree/type of implicit surface.\n\nerr176 -176  Unexpected iteration situation.\n\nerr177 -177  Error in input. Negative step length requested.\n\nerr178 -178  Illegal derivative requested.\n\nerr179 -179  No. of Curves < 2.\n\nerr180 -180  Error in torus description.\n\nerr181 -181  Too few points as input.\n\nerr182 -182\n\nerr183 -183  Order(s) specified to low.\n\nerr184 -184  Negative tolerance given.\n\nerr185 -185  Only degenerate or singular guide points.\n\nerr186 -186  Special error in traversal of curves.\n\nerr187 -187  Error in description of input curves.\n\nerr188 -188\n\nerr189 -189\n\nerr190 -190  Too small array for storing Curve segments.\n\nerr191 -191  Error in inserted parameter number.\n\nerr192 -192\n\nerr193 -193\n\nerr194 -194\n\nerr195 -195\n\nerr196 -196\n\nerr197 -197\n\nerr198 -198\n\nerr199 -199  Error in vectors?\n\\end{verbatim}\n"
  },
  {
    "path": "doc/manual/chap_intro_abridged.tex",
    "content": "\\chapter{General Introduction}\n\\label{introduction}\nSISL is a geometric toolkit to model with curves and surfaces. It is a\nlibrary of C functions to perform operations such as the definition,\nintersection and evaluation of NURBS (Non-Uniform Rational B-spline)\ngeometries. Since many applications use implicit geometric\nrepresentation such as planes, cylinders, tori etc., SISL can also\nhandle the interaction between such geometries and NURBS.\n\n\\medskip\nThroughout this manual, a distinction is made between NURBS (the\ndefault) and B-splines. The term B-splines is used for non-uniform\nnon-rational (or polynomial) B-splines. B-splines are used only where it\ndoes not make sense to employ NURBS (such as the approximation of a\ncircle by a B-spline) or in cases where the research\ncommunity has yet to develop stable technology for treating NURBS.\nA NURBS require more memory space than a B-spline, even when the\nextra degrees of freedom in a NURBS are not used. Therefore the routines\nare specified to give B-spline output whenever the extra degrees of\nfreedom are not required.\n\nTransferring a B-spline into NURBS format is done by constructing a new\ncoefficient vector using the original B-spline coefficients and setting\nall the rational weights equal to one (1).\nThis new coefficient vector is then given as input to the routine for\ncreating a new curve/surface object while specifying that the object to\nbe created should be of the NURBS (rational B-spline) type.\n\nTo approximate a NURBS by a B-spline, use the offset calculation\nroutines with an offset of zero.\n\nThe routines in SISL are designed to function on curves and surfaces\nwhich are at least continuously differentiable. However many routines\nwill also handle continuous curves and surfaces, including piecewise\nlinear ones.\n\n\\medskip\nAll arrays in SISL are 1-dimensional. In an array with points or vertices\nare the points stored consecutively. In a raster are points or vertices\nstored consecutively while points in the first parameter direction have\nthe shortest stride (stored right after each other). There is a special\nrule for vertices given as input to a rational curve or surface, see the\nSections~\\ref{sec:newCurve} and~\\ref{sec:newSurf}.\n\nThe three important data structures used by SISL are SISLCurve,\nSISLSurf, and SISLIntcurve. These are defined in the Curve Utilities,\nSurface Utilities, and Surface Interrogation modules respectively. Other\nstructures are SISLBox and SISLCone, which represents a bounding box and\na normal cone, respectively. It is\nimportant to remember to always free these structures and also to free\ninternally allocated structures and arrays used to pass results to the application,\notherwise strange errors might result.\n\nIn the construction of NURBS curves and surfaces is information on the order of the curve or\nsurface frequently required. The order is equal to the polynomial degree plus one.\n\nThe various functions are equipped with a status variable, typically\nplaced as the last entity in the parameter list. It returns information\nabout whether or not the function succeeded in its purpose. A negative\nvalue means failure, the result zero means success while a positive\nnumber is a warning. Section~\\ref{errorcodes} provides a list over\npossible error messages where most occurances are explained. \n\n\\medskip\nSISL is divided into seven modules, partly in order to provide a logical\nstructure, but also to enable users with a specific application to use\nsubsets of SISL. There are three modules dealing with curves, three with\nsurfaces, and one module to perform data reduction on curves and\nsurfaces. The modules for\ncurves and surfaces focus on functions for creation and definition,\nintersection and interrogation, and general utilities.\n\nThe chapters 3 to 11 in this manual contain information concerning the top\nlevel functions of each module. Lower level functions not usually\nrequired by an application are not included. Each top level function is\ndocumented by describing the purpose, the input and output arguments and\nan example of use. Input parameters specified in the examples are suggestions, the\nactual values must be set dependent on context. The geometric tolerance tells when\ntwo points are regarded as equal. This implies that a large tolerance leads to\nhigher data size in approximaation type functionality such as s1360, offset curve.\nIn surface-surface intersections, on the other hand, will a large tolerance imply\nthat there is a large area around an intersection curve where the two surfaces are\ncloser than the tolerance, which may lead to unstability in tangential situations.\nIn the examples is the suggested tolerance stricter for intersection functionality\nthan in other cases. However, the intersection tolerance must reflect the accuracy\nin which the associated geometry entities are constructed.\nTo get you started, this chapter contains an Example Program.\n\n%\\vfill\n%\\newpage\n\n\\section{\\label{syntax}C Syntax Used in Manual}\nThis manual uses the K\\&R style C syntax for historic reasons, but both\nthe ISO/ANSI and the K\\&R C standards are supported by the library and\nthe include files.\n\n\\section{\\label{dynamic}Dynamic Allocation in SISL}\nIn the description of all the functions in this manual, a\nconvention exists on when to declare or allocate arrays/objects outside a\nfunction and when an array is allocated internally.\n{\\em NB! When memory for output arrays/objects are allocated inside a function you\nmust remember to free the allocated memory when it is not in use any\nmore.}\n\nThe convention is the following:\n\\begin{itemize}\n\\item If $[\\,]$ is used in the synopsis and in the example it means\nthat the array has to be declared or allocated outside the function.\n\\item If $*$ is used it means that the function requires a\npointer and that the allocation will be done outside the function if necessary.\n\\item When either an array or an array of pointers or an object is to be\nallocated in a function, two or three stars are used in the\nsynopsis.\nTo use the function you declare the parameter with one star less and use  \\&\nin the argument list.\n\\item For all output variables except arrays or objects\nthat are declared or allocated  outside the function you have to use \\&\nin the argument list.\n\\end{itemize}\n\n\n\\vfill\n\\newpage\n\\vfill\n\\newpage\n\\section{Creating the library}\n\nIn order to access SISL from your program you need one library inclusion, namely\nthe header file sisl.h. The statement\n\\begin{verbatim}\n#include \"sisl.h\"\n\\end{verbatim}\nmust be written at the top of your main program.\nIn this header file all types\nare defined.\nIt also contains all the\nSISL top level function declarations.\nMemory management and input/output require two more includes to avoid compiler warnings,\nsee Section~\\ref{sec:exampleprog}.\n\nSISL is prepared for makefile generation with CMake and equipped with a CMakeLists.txt file.\nFor information on using CMake, see www.cmake.org. The building procedure depends on whether your platform is\nLinux or Windows.\n\n\\medskip\n    {\\noindent \\bf LINUX}\n\nStart by creating a build directory:\n\\begin{verbatim}\n$ cd <path_to_source_code>\n$ mkdir build\n$ cd build\n\\end{verbatim}\n\nRun the cmake program to setup the build process, selecting Debug or Release\nas build type, optionally selecting a local install folder:\n\\begin{verbatim}\n$ cmake .. -DCMAKE_BUILD_TYPE=Release (-DCMAKE_INSTALL_PREFIX=$HOME/install)\n\\end{verbatim}\n\nFor a gui-like cmake interface use ccmake (from cmake-ncurses-gui) or cmake-gui (from cmake.org).\n\nBuild the library:\n\\begin{verbatim}\n$ make\n\\end{verbatim}\nThis will install the library in the build folder. Compilation and build of one particular\nexample program is done by a specific make statement:\n\\begin{verbatim}\n$ make example01\n\\end{verbatim}\nThis option requires compilation of examples to be set in the Makefile.\n\nInstall the library to a local folder (requires the use of\n-DCMAKE\\_INSTALL\\_PREFIX with a local folder in the previous step):\n\\begin{verbatim}\n$ make install\n\\end{verbatim}\n\nIf the -DCMAKE\\_INSTALL\\_PREFIX in the cmake step was omitted or was set to a\nsystem folder (like /usr/local) the user needs elevated privileges to install\nthe library:\n\\begin{verbatim}\n$ sudo make install\n\\end{verbatim}\n\n\\medskip\n{\\noindent \\bf Windows}\n\nAdd a new build folder somewhere. Start the CMake\nexecutable and fill in the paths to the source and build folders. When\nyou run CMake, a Visual Studio project solution file will be generated\nin the build folder.\n\n\n\n\\newpage\n\\section{An Example Program} \\label{sec:exampleprog}\n\nTo clarify the previous section here is an example program designed to\ntest the SISL algorithm for intersecting a cone with\na B-spline curve. The program calls the SISL routines newCurve() documented in\nSection ~\\ref{sec:newCurve}, freeCurve() documented in~\\ref{sec:freeCurve},\ns1373() found in Section~\\ref{sec:s1373} and freeIntcrvlist() in~\\ref{sec:freeIntcrvlist}.\n\n\\begin{verbatim}\n#include \"sisl.h\"\n#include <stdlib.h>  \n#include <stdio.h>\n\nint main()\n{\n  SISLCurve *pc=0;                    /* Pointer to spline curve */\n  double aepsco,aepsge;               /* Tolerances */\n  double top[3],axispt[3],conept[3];  /* Representating the cone */\n  double st[100],scoef[100];          /* Knot vector and coefficients of spline curve */\n  double *spar;                       /* Parameter values of intersection points */\n  int kstat;                          /* Return status from function calls */\n  int cone_exists=0;\n  int kk,kn,kdim;                     /* Order (polynomial degree+1), number of \n                                         coefficients and spatial dimension */\n  int ki;                             /* Counter */\n  int kpt,kcrv;                       /* Number of intersection points and curves */\n  SISLIntcurve **qrcrv;               /* Array of pointer to intersection curves  */\n  char ksvar[100];                    \n  kdim=3;\n  aepsge=0.001; /* Geometric tolerance */\n  aepsco=0.000001; /* Computational tolerance. This parameter is included from \n                      historical reasons and no longer used */\n\n  ksvar[0] = '0';  /* Arbitrary character */\n  while (ksvar[0] != 'q')\n    {\n      printf(\"\\n cu - define a new B-spline curve\");\n      printf(\"\\n co - define a new cone\");\n      printf(\"\\n i - intersect the B-spline curve with the cone\");\n      printf(\"\\n q - quit\");\n      printf(\"\\n> \");\n      scanf(\"%s\",ksvar);\n\n      if (ksvar[0] == 'c' && ksvar[1] == 'u')\n        {\n          /* Define spline curve */\n          printf(\"\\n Give number of vertices, order of curve: \");\n          scanf(\"%d %d\", &kn, &kk);\n          printf(\"Give knots values in ascending order: \\n\");\n          for (ki=0; ki<kn+kk; ki++)\n            {\n               scanf(\"%lf\",&st[ki]);\n            }\n          printf(\"Give vertices \\n\");\n          for (ki=0; ki<kn*kdim; ki++)\n            {\n              scanf(\"%lf\",&scoef[ki]);\n            }\n         if(pc) freeCurve(pc);\n\n          /* Create curve */\n          pc = newCurve(kn,kk,st,scoef,1,kdim,1);\n        }\n      else if (ksvar[0] == 'c' && ksvar[1] == 'o')\n       {\n         printf(\"\\n Give top point: \");\n         scanf(\"%lf %lf %lf\",&top[0],&top[1],&top[2]);\n         printf(\"\\n Give a point on the axis: \");\n         scanf(\"%lf %lf %lf\",&axispt[0],&axispt[1],&axispt[2]);\n         printf(\"\\n Give a point on the cone surface: \");\n         scanf(\"%lf %lf %lf\",&conept[0],&conept[1],&conept[2]);\n         cone_exists=1;\n       }\n      else if (ksvar[0] == 'i' && cone_exists && pc)\n       {\n         /* Intersect spline curve with cone */\n         s1373(pc,top,axispt,conept,kdim,aepsco,aepsge,\n               &kpt,&spar,&kcrv,&qrcrv,&kstat);\n         printf(\"\\n kstat %d\",kstat);\n         printf(\"\\n kpt %d\",kpt);\n         printf(\"\\n kcrv %d\",kcrv);\n         for (ki=0;ki<kpt;ki++)\n          {\n            printf(\"\\nIntersection point %lf\",spar[ki]);\n          }\n        if (spar)\n          {\n            /* The array containing parameter values of the intersection points between\n               the curve and the cone is allocated inside s1373 and must be freed */\n            free (spar);\n            spar=0;\n          }\n        if (qrcrv)\n         {\n           /* The array containing pointers to intersection points curves between\n              the curve and the cone is allocated inside s1373 and must be freed.\n              This is done in a special function taking care of the intersection\n              curves themselves */\n          freeIntcrvlist(qrcrv,kcrv);\n          qrcrv=0;\n        }\n      }\n    }\n  return 0;\n}\n\n\\end{verbatim}\nNote that sisl.h is included. stdlib.h is included to declare free, which\nreleases memory allocated in the function s1373. stdio.h declares printf and\nscanf.\n\n\\bigskip\n\nThe program was compiled and built using the command:\n\\begin{verbatim}\n$ make prog1\n\\end{verbatim}\nNote that the program must be placed in the app folder and sisl\\_COMPILE\\_APPS must be set to true.\n\nA sample run of prog1 went as follows:\n\\begin{verbatim}\n$ prog1\n\n     cu - define a new B-spline curve\n     co - define a new cone\n     i  - intersect the B-spline curve with the cone\n     q  - quit\n> cu\n\n Give number of vertices, order of curve: 2 2\nGive knots values in ascending order:\n0 0 1 1\nGive vertices\n1 0 0.5\n-1 0 0.5\n\n     cu - define a new B-spline curve\n     co - define a new cone\n     i  - intersect the B-spline curve with the cone\n     q  - quit\n> co\n\n Give top point: 0 0 1\n\n Give a point on the axis: 0 0 0\n\n Give a point on the cone surface: 1 0 0\n\n     cu - define a new B-spline curve\n     co - define a new cone\n     i  - intersect the B-spline curve with the cone\n     q  - quit\n> i\n\n kstat 0\n kpt   2\n kcrv  0\nIntersection point 0.250000\nIntersection point 0.750000\n     cu - define a new B-spline curve\n     co - define a new cone\n     i  - intersect the B-spline curve with the cone\n     q  - quit\n> q\n$\n\\end{verbatim}\nSISL found two intersection points given by the parameters\n$0.25$ and $0.75$. These parameters correspond to the 3D points\n$(-0.5,0,0.5)$ and $(0.5,0,0.5)$ (which could be found by calling\nthe evaluation routine s1221()). They lie on both\nthe B-spline curve and the cone --- as expected!\n\n\\input{sec_spline_curve}\n\\input{sec_spline_surface}\n\n\\vfill\n\\newpage\n%\\mbox{}\n%\\newpage\n"
  },
  {
    "path": "doc/manual/chap_introduction.tex",
    "content": "\\chapter{Introduction}\n\\label{introduction}\nSISL is a geometric toolkit to model with curves and surfaces. It is a\nlibrary of C functions to perform operations such as the definition,\nintersection and evaluation of NURBS (Non-Uniform Rational B-spline)\ngeometries. Since many applications use implicit geometric\nrepresentation such as planes, cylinders, tori etc., SISL can also\nhandle the interaction between such geometries and NURBS.\n\n\\medskip\nThroughout this manual, a distinction is made between NURBS (the\ndefault) and B-splines. The term B-splines is used for non-uniform\nnon-rational (or polynomial) B-splines. B-splines are used only where it\ndoes not make sense to employ NURBS (such as the approximation of a\ncircle by a B-spline) or in cases where the research\ncommunity has yet to develop stable technology for treating NURBS.\nA NURBS require more memory space than a B-spline, even when the\nextra degrees of freedom in a NURBS are not used. Therefore the routines\nare specified to give B-spline output whenever the extra degrees of\nfreedom are not required.\n\nTransferring a B-spline into NURBS format is done by constructing a new\ncoefficient vector using the original B-spline coefficients and setting\nall the rational weights equal to one (1).\nThis new coefficient vector is then given as input to the routine for\ncreating a new curve/surface object while specifying that the object to\nbe created should be of the NURBS (rational B-spline) type.\n\nTo approximate a NURBS by a B-spline, use the offset calculation\nroutines with an offset of zero.\n\nThe routines in SISL are designed to function on curves and surfaces\nwhich are at least continuously differentiable. However many routines\nwill also handle continuous curves and surfaces, including piecewise\nlinear ones.\n\n\\medskip\nAll arrays in SISL are 1-dimensional. In an array with points or vertices\nare the points stored consecutively. In a raster are points or vertices\nstored consecutively while points in the first parameter direction have\nthe shortest stride (stored right after each other). There is a special\nrule for vertices given as input to a rational curve or surface, see the\nSections~\\ref{sec:newCurve} and~\\ref{sec:newSurf}.\n\nThe three important data structures used by SISL are SISLCurve,\nSISLSurf, and SISLIntcurve. These are defined in the Curve Utilities,\nSurface Utilities, and Surface Interrogation modules respectively. Other\nstructures are SISLBox and SISLCone, which represents a bounding box and\na normal cone, respectively. It is\nimportant to remember to always free these structures and also to free\ninternally allocated structures used to pass results to the application,\notherwise strange errors might result.\n\nThe various functions are equipped with a status variable, typically\nplaced as the last entity in the parameter list. It returns information\nabout whether or not the function succeeded in its purpose. A negative\nvalue means failure, the result zero means success while a positive\nnumber is a warning. Section~\\ref{errorcodes} provides a list over\npossible error messages where most occurances are explained. \n\n\\medskip\nSISL is divided into seven modules, partly in order to provide a logical\nstructure, but also to enable users with a specific application to use\nsubsets of SISL. There are three modules dealing with curves, three with\nsurfaces, and one module to perform data reduction on curves and\nsurfaces. The modules for\ncurves and surfaces focus on functions for creation and definition,\nintersection and interrogation, and general utilities.\n\nThe chapters in this manual contains information concerning the top\nlevel functions of each module. Lower level functions not usually\nrequired by an application are not included. Each top level function is\ndocumented by describing the purpose, the input and output arguments and\nan example of use. To get you started, this chapter contains an Example\nProgram.\n\n\\medskip\nSISL is a mature library that is no longer subject to the introduction of new functionality.\nThis version of the library differ from the previous one by bug fixing and\nan update of the documentation. SINTEF Mathematics and Cybernetics provide, in\naddition to SISL, GoTools. This is a collection of geometry libraries written\nin C++ that complements SISL. New geometry software development is integrated\ninto GoTools. Corresponding geometry entities like NURBS curves and surfaces\nhave different representations in SISL and GoTools, but conversion\nfunctionality exist and is placed in GoTools as well as a viewer of a set of geometry\nentities including NURBS curves and surfaces. An overview of the interplay\nbetween SISL and GoTools will be provided in the end of this document.\n\n\n%\\vfill\n%\\newpage\n\n\\section{\\label{syntax}C Syntax Used in Manual}\nThis manual uses the K\\&R style C syntax for historic reasons, but both\nthe ISO/ANSI and the K\\&R C standards are supported by the library and\nthe include files.\n\n\\section{\\label{dynamic}Dynamic Allocation in SISL}\nIn the description of all the functions in this manual, a\nconvention exists on when to declare or allocate arrays/objects outside a\nfunction and when an array is allocated internally.\n{\\em NB! When memory for output arrays/objects are allocated inside a function you\nmust remember to free the allocated memory when it is not in use any\nmore.}\n\nThe convention is the following:\n\\begin{itemize}\n\\item If $[\\,]$ is used in the synopsis and in the example it means\nthat the array has to be declared or allocated outside the function.\n\\item If $*$ is used it means that the function requires a\npointer and that the allocation will be done outside the function if necessary.\n\\item When either an array or an array of pointers or an object is to be\nallocated in a function, two or three stars are used in the\nsynopsis.\nTo use the function you declare the parameter with one star less and use  \\&\nin the argument list.\n\\item For all output variables except arrays or objects\nthat are declared or allocated  outside the function you have to use \\&\nin the argument list.\n\\end{itemize}\n\n\n\\vfill\n\\newpage\n\\section{Creating the library}\n\nIn order to access SISL from your program you need one library inclusion, namely\nthe header file sisl.h. The statement\n\\begin{verbatim}\n#include \"sisl.h\"\n\\end{verbatim}\nmust be written at the top of your main program.\nIn this header file all types\nare defined.\nIt also contains all the\nSISL top level function declarations.\nMemory management and input/output require two more includes to avoid compiler warnings,\nsee Section~\\ref{sec:exampleprog}.\n\nSISL is prepared for makefile generation with CMake and equipped with a CMakeLists.txt file.\nFor information on using CMake, see www.cmake.org. The building procedure depends on whether your platform is\nLinux or Windows.\n\n\\medskip\n    {\\noindent \\bf LINUX}\n\nStart by creating a build directory:\n\\begin{verbatim}\n$ cd <path_to_source_code>\n$ mkdir build\n$ cd build\n\\end{verbatim}\n\nRun the cmake program to setup the build process, selecting Debug or Release\nas build type, optionally selecting a local install folder:\n\\begin{verbatim}\n$ cmake .. -DCMAKE_BUILD_TYPE=Release (-DCMAKE_INSTALL_PREFIX=$HOME/install)\n\\end{verbatim}\n\nFor a gui-like cmake interface use ccmake (from cmake-ncurses-gui) or cmake-gui (from cmake.org).\n\nBuild the library:\n\\begin{verbatim}\n$ make\n\\end{verbatim}\nThis will install the library in the build folder. Compilation and build of one particular\nexample program is done by a specific make statement:\n\\begin{verbatim}\n$ make example01\n\\end{verbatim}\nThis option requires compilation of examples to be set in the Makefile.\n\nInstall the library to a local folder (requires the use of\n-DCMAKE\\_INSTALL\\_PREFIX with a local folder in the previous step):\n\\begin{verbatim}\n$ make install\n\\end{verbatim}\n\nIf the -DCMAKE\\_INSTALL\\_PREFIX in the cmake step was omitted or was set to a\nsystem folder (like /usr/local) the user needs elevated privileges to install\nthe library:\n\\begin{verbatim}\n$ sudo make install\n\\end{verbatim}\n\n\\medskip\n{\\noindent \\bf Windows}\n\nAdd a new build folder somewhere. Start the CMake\nexecutable and fill in the paths to the source and build folders. When\nyou run CMake, a Visual Studio project solution file will be generated\nin the build folder.\n\n\n\n\\newpage\n\\section{An Example Program} \\label{sec:exampleprog}\n\nTo clarify the previous section here is an example program designed to\ntest the SISL algorithm for intersecting a cone with\na B-spline curve. The program calls the SISL routines newCurve() documented in\nSection ~\\ref{sec:newCurve}, freeCurve() documented in~\\ref{sec:freeCurve},\ns1373() found in Section~\\ref{sec:s1373} and freeIntcrvlist() in~\\ref{sec:freeIntcrvlist}.\n\n\\begin{verbatim}\n#include \"sisl.h\"\n#include <stdlib.h>  \n#include <stdio.h>\n\nint main()\n{\n  SISLCurve *pc=NULL;                 /* Pointer to spline curve */\n  double aepsco,aepsge;               /* Tolerances */\n  double top[3],axispt[3],conept[3];  /* Representating the cone */\n  double st[100],scoef[100];          /* Knot vector and coefficients of spline curve */\n  double *spar=NULL;                  /* Parameter values of intersection points */\n  int kstat;                          /* Return status from function calls */\n  int cone_exists=0;\n  int kk,kn,kdim;                     /* Order (polynomial degree+1), number of \n                                         coefficients and spatial dimension */\n  int ki;                             /* Counter */\n  int kpt,kcrv;                       /* Number of intersection points and curves */\n  SISLIntcurve **qrcrv=NULL;          /* Array of pointer to intersection curves  */\n  char ksvar[100];                    \n  kdim=3;\n  aepsge=0.001; /* Geometric tolerance */\n  aepsco=0.000001; /* Computational tolerance. This parameter is included from \n                      historical reasons and no longer used */\n\n  ksvar[0] = '0';  /* Arbitrary character */\n  while (ksvar[0] != 'q')\n    {\n      printf(\"\\n cu - define a new B-spline curve\");\n      printf(\"\\n co - define a new cone\");\n      printf(\"\\n i - intersect the B-spline curve with the cone\");\n      printf(\"\\n q - quit\");\n      printf(\"\\n> \");\n      scanf(\"%s\",ksvar);\n\n      if (ksvar[0] == 'c' && ksvar[1] == 'u')\n        {\n          /* Define spline curve */\n          printf(\"\\n Give number of vertices, order of curve: \");\n          scanf(\"%d %d\", &kn, &kk);\n          printf(\"Give knots values in ascending order: \\n\");\n          for (ki=0; ki<kn+kk; ki++)\n            {\n               scanf(\"%lf\",&st[ki]);\n            }\n          printf(\"Give vertices \\n\");\n          for (ki=0; ki<kn*kdim; ki++)\n            {\n              scanf(\"%lf\",&scoef[ki]);\n            }\n         if(pc) freeCurve(pc);\n\n          /* Create curve */\n          pc = newCurve(kn,kk,st,scoef,1,kdim,1);\n        }\n      else if (ksvar[0] == 'c' && ksvar[1] == 'o')\n       {\n         printf(\"\\n Give top point: \");\n         scanf(\"%lf %lf %lf\",&top[0],&top[1],&top[2]);\n         printf(\"\\n Give a point on the axis: \");\n         scanf(\"%lf %lf %lf\",&axispt[0],&axispt[1],&axispt[2]);\n         printf(\"\\n Give a point on the cone surface: \");\n         scanf(\"%lf %lf %lf\",&conept[0],&conept[1],&conept[2]);\n         cone_exists=1;\n       }\n      else if (ksvar[0] == 'i' && cone_exists && pc)\n       {\n         /* Intersect spline curve with cone */\n         s1373(pc,top,axispt,conept,kdim,aepsco,aepsge,\n               &kpt,&spar,&kcrv,&qrcrv,&kstat);\n         printf(\"\\n kstat %d\",kstat);\n         printf(\"\\n kpt %d\",kpt);\n         printf(\"\\n kcrv %d\",kcrv);\n         for (ki=0;ki<kpt;ki++)\n          {\n            printf(\"\\nIntersection point %lf\",spar[ki]);\n          }\n        if (spar)\n          {\n            /* The array containing parameter values of the intersection points between\n               the curve and the cone is allocated inside s1373 and must be freed */\n            free (spar);\n            spar=NULL;\n          }\n        if (qrcrv)\n         {\n           /* The array containing pointers to intersection points curves between\n              the curve and the cone is allocated inside s1373 and must be freed.\n              This is done in a special function taking care of the intersection\n              curves themselves */\n          freeIntcrvlist(qrcrv,kcrv);\n          qrcrv=NULL;\n        }\n      }\n    }\n  return 0;\n}\n\n\\end{verbatim}\nNote that sisl.h is included. stdlib.h is included to declare free, which\nreleases memory allocated in the function s1373. stdio.h declares printf and\nscanf.\n\n\\bigskip\n\nThe program was compiled and built using the command:\n\\begin{verbatim}\n$ make prog1\n\\end{verbatim}\nNote that the program must be placed in the app folder and sisl\\_COMPILE\\_APPS must be set to true.\n\nA sample run of prog1 went as follows:\n\\begin{verbatim}\n$ prog1\n\n     cu - define a new B-spline curve\n     co - define a new cone\n     i  - intersect the B-spline curve with the cone\n     q  - quit\n> cu\n\n Give number of vertices, order of curve: 2 2\nGive knots values in ascending order:\n0 0 1 1\nGive vertices\n1 0 0.5\n-1 0 0.5\n\n     cu - define a new B-spline curve\n     co - define a new cone\n     i  - intersect the B-spline curve with the cone\n     q  - quit\n> co\n\n Give top point: 0 0 1\n\n Give a point on the axis: 0 0 0\n\n Give a point on the cone surface: 1 0 0\n\n     cu - define a new B-spline curve\n     co - define a new cone\n     i  - intersect the B-spline curve with the cone\n     q  - quit\n> i\n\n kstat 0\n kpt   2\n kcrv  0\nIntersection point 0.250000\nIntersection point 0.750000\n     cu - define a new B-spline curve\n     co - define a new cone\n     i  - intersect the B-spline curve with the cone\n     q  - quit\n> q\n$\n\\end{verbatim}\nSISL found two intersection points given by the parameters\n$0.25$ and $0.75$. These parameters correspond to the 3D points\n$(-0.5,0,0.5)$ and $(0.5,0,0.5)$ (which could be found by calling\nthe evaluation routine s1221()). They lie on both\nthe B-spline curve and the cone --- as expected!\n\n\\input{sec_spline_curve}\n\\input{sec_spline_surface}\n\n\\vfill\n\\newpage\n%\\mbox{}\n%\\newpage\n"
  },
  {
    "path": "doc/manual/chap_surface_analysis.tex",
    "content": "\\chapter{Surface Analysis}\n\\label{surfaceanalysis}\nThis chapter describes the Surface Analysis part.\n\\section{Curvature Evaluation}\n\\input{func/s2500}\n\\pgsbreak\n\\input{func/s2502}\n\\pgsbreak\n\\input{func/s2504}\n\\pgsbreak\n\\input{func/s2506}\n\\pgsbreak\n\\input{func/s2508}\n\\pgsbreak\n\\input{func/s2510}\n\\pgsbreak\n\\input{func/s2532}\n\\pgsbreak\n\\input{func/s2536}\n\\pgsbreak\n\\input{func/s2540}\n\\pgsbreak\n\\input{func/s2542}\n\\pgsbreak\n\\input{func/s2544}\n\\pgsbreak\n\\input{func/s2545}\n\\pgsbreak\n"
  },
  {
    "path": "doc/manual/chap_surface_definition.tex",
    "content": "\\chapter{Surface Definition}\n\\label{surfacedefinition}\n\\section{Interpolation}\n\\input{func/s1536}\n\\pgsbreak\n\\input{func/s1537}\n\\pgsbreak\n\\input{func/s1534}\n\\pgsbreak\n\\input{func/s1535}\n\\pgsbreak\n\\input{func/s1529}\n\\pgsbreak\n\\input{func/s1530}\n\\pgsbreak\n\\input{func/s1538}\n\\pgsbreak\n\\input{func/s1539}\n\\pgsbreak\n\\input{func/s1508}\n\\pgsbreak\n\\input{func/s1390}\n\\pgsbreak\n\\input{func/s1391}\n\\pgsbreak\n\\input{func/s1401}\n\\pgsbreak\n\\section{Approximation}\nTwo kinds of surfaces are treated in this section. The first is\napproximation of special shape properties like rotation or sweeping. The\nsecond is offsets to surfaces.\n\nAll functions require a tolerance for use in the approximation. It is\nuseful to note that there is a close relation between the size of the\ntolerance and the amount of data for the surface.\n\\input{func/s1620}\n\\pgsbreak\n\\input{func/s1332}\n\\pgsbreak\n\\input{func/s1302}\n\\pgsbreak\n\\input{func/s1365}\n\\pgsbreak\n%\\section{Mirror a Surface} Moved into func/s1601.tex\n\\input{func/s1601}\n\\pgsbreak\n\\section{Conversion}\n\\input{func/s1388}\n\\pgsbreak\n\\input{func/s1731}\n\\pgsbreak\n\\input{func/s1733}\n\\pgsbreak\n\\input{func/s1387}\n\\pgsbreak\n\\input{func/s1386}\n\\pgsbreak\n\\input{func/s1023}\n\\pgsbreak\n\\input{func/s1021}\n\\pgsbreak\n\\input{func/s1024}\n\\pgsbreak\n\\input{func/s1022}\n\\vfill\n\\newpage\n"
  },
  {
    "path": "doc/manual/chap_surface_interrogation.tex",
    "content": "\\chapter{Surface Interrogation}\n\\label{surfaceinterrogation}\nThis chapter describes the functions in the Surface Interrogation module.\n\n\\input{sec_intcurve_object}\n\\pgsbreak\n\n\\section{Find the Intersections}\nIntersection functionality where at least one of the input geometry entities is or can be a surface.\n\\input{func/s1850}\n\\pgsbreak\n\\input{func/s1371}\n\\pgsbreak\n\\input{func/s1372}\n\\pgsbreak\n\\input{func/s1373}\n\\pgsbreak\n\\input{func/s1502}\n\\pgsbreak\n\\input{func/s1375}\n\\pgsbreak\n\\input{func/s1870}\n\\pgsbreak\n\\input{func/s1856}\n\\pgsbreak\n\\input{func/s1518}\n\\pgsbreak\n\\input{func/s1328}\n\\pgsbreak\n\\input{func/s1855}\n\\pgsbreak\n\\input{func/s1858}\n\\pgsbreak\n\\section{Find the Topology of the Intersection}\n\\input{func/s1851}\n\\pgsbreak\n\\input{func/s1852}\n\\pgsbreak\n\\input{func/s1853}\n\\pgsbreak\n\\input{func/s1854}\n\\pgsbreak\n\\input{func/s1503}\n\\pgsbreak\n\\input{func/s1369}\n\\pgsbreak\n\\input{func/s1859}\n\\pgsbreak\n\\section{Find the Topology of a Silhouette}\n\\input{func/s1860}\n\\pgsbreak\n\\input{func/s1510}\n\\pgsbreak\n\\input{func/s1511}\n\\pgsbreak\n\\section{Marching}\n\\input{func/s1314}\n\\pgsbreak\n\\input{func/s1315}\n\\pgsbreak\n\\input{func/s1316}\n\\pgsbreak\n\\input{func/s1317}\n\\pgsbreak\n\\input{func/s1501}\n\\pgsbreak\n\\input{func/s1318}\n\\pgsbreak\n\\input{func/s1310}\n\\pgsbreak\n\\section{Marching of Silhouettes}\n\\input{func/s1319}\n\\pgsbreak\n\\input{func/s1514}\n\\pgsbreak\n\\input{func/s1515}\n\\pgsbreak\n% \\section{Closed or Degenerate Edges} %, moved into s1450.tex\n\\input{func/s1450}\n\\pgsbreak\n\\input{func/s1603}\n\\pgsbreak\n\\section{Closest Points}\n\\input{func/s1954}\n\\pgsbreak\n\\input{func/s1958}\n\\pgsbreak\n\\input{func/s1775}\n\\pgsbreak\n% \\section{Calculation of Absolute Extremals on a NURBS Surface} %,\n% moved into s1921.tex\n\\input{func/s1921}\n\\pgsbreak\n\\section{Bounding Box}\nBoth curves and surfaces have bounding boxes. These are boxes surrounding an object not only parallel to the main axis, but also rotated 45 degrees around each main axis. These bounding boxes are used by the intersection functions to decide if an intersection is possible or not. They might also be used to find the position of objects under other circumstances. The bounding box object and corresponding initialization functionality ar described in Section~\\ref{sec:bbox} at pages \\pageref{SISLBox} and \\pageref{newbox}.\n\\input{func/s1989}\n\\pgsbreak\n\\section{Normal Cone}\nBoth curves and surfaces have normal cones. These are the cones that are convex hull of all normalized tangents of a curve and all normalized normals of a surface.\n\nThese normal cones are used by the intersection functions to decide if only one intersection is possible. They might also be used to find directions of objects for other reasons. The direction cone object and corresponding initialization functionality ar described in Section~\\ref{sec:dcone} at pages \\pageref{SISLDir} and \\pageref{newdir}.\n\\input{func/s1987}\n"
  },
  {
    "path": "doc/manual/chap_surface_utilities.tex",
    "content": "\\chapter{Surface Utilities}\n\\label{surfaceutilities}\nThis chapter describes the Surface Utilities. These are common to both\nthe Surface Definition and Surface Interrogation modules.\n\n\\input{sec_surface_object}\n\\pgsbreak\n\\section{Evaluation}\n\\input{func/s1421}\n\\pgsbreak\n\\input{func/s1424}\n\\pgsbreak\n\\input{func/s1422}\n\\pgsbreak\n\\input{func/s1425}\n\\pgsbreak\n\\input{func/s1506}\n\\pgsbreak\n\\section{Subdivision}\n\\input{func/s1711}\n\\pgsbreak\n\\input{func/s1025}\n\\pgsbreak\n\\section{Picking Curves from a Surface}\n\\input{func/s1439}\n\\pgsbreak\n\\input{func/s1383}\n\\pgsbreak\n\\input{func/s1001}\n\\pgsbreak\n\\input{func/s1440}\n"
  },
  {
    "path": "doc/manual/foreword.tex",
    "content": "\\chapter{Preface}\nWelcome to the SISL 4.7 user's manual.  SISL stands for\n\\emph{\\textbf{Si}ntef \\textbf{S}pline \\textbf{L}ibrary}, and has been gradually \ndeveloped and enhanced for more than three decades by the geometry group at SINTEF in Oslo.\nAlthough it is very comprehensive, its organisation is simple.  There are but a \nfew structures, and its nearly four hundred main functions can usually be employed\ndirectly and individually. This manual organises and explains the main routines.  However, much of this\ninformation can also be found directly in the code in the form of commentaries.\n\nThe complete software package you have in your hands should contain the following:\n\\begin{itemize}\n\\item The SISL 4.7 distribution and reference guide (the document you are reading now)\n\\item Supplementary routines for writing SISL objects to streams (including file \nstreams) in a simple ASCII format called \\textbf{\\Verb/Go/}.\n\\item A selection of \\emph{sample programs}, designed to demonstrate functionalities\nand use of SISL.\n\\item Source code for a simple \\emph{viewer} that can be used to view geometric objects stored\nin the \\Verb/Go/-format.  This allows visual inspection of SISL-generated curves\nand surfaces, as well as points.\n\\end{itemize}\n\n\\section{The structure of this document}\n\\textbf{Chapter 2} is a general introduction to SISL and its programming style. A simple example program\nincluding instructions in how to compile and link the program and the expected output is provided.\nSince it is strongly recommended that the user has some general knowledge of splines, this \nchapter also contains a couple of sections introducing the subject of spline curves and\nsurfaces. \\\\\n\\\\\n\\textbf{Chapter 3 to 11} presents the main SISL routines.  \\\\\n\\\\\n\\textbf{Chapter 12} goes through the provided sample programs and explain what these do,\nand what the user can expect to learn from them.  There are a total of 15 sample \nprograms, ranging from very basic to intermediate complexity.\\\\\n\\\\\nThe goal of \\textbf{Chapter 13} is to explain the use of the \\emph{viewer program}, \nwhich is a small but handy tool for visually inspecting results from SISL routines.\\\\\n\\\\\n\\textbf{Chapter 14} is an appendix presenting an explanation of the error codes used in SISL.\\\\\n\\\\\nFinally there is an \\textbf{annex}, citing the text of the General Public License.\n\n\\section{The structure of the software package}\\label{compile}\nThere are seven directories:\n\\begin{itemize}\n\\item \\textbf{\\Verb-include/-} - the inlude files related to the 4.7 release of SISL.\n\\item \\textbf{\\Verb-src/-} - the source code of the 4.7 release of SISL.\n\\item \\textbf{\\Verb-doc/-} - the basis for this document. \n\\item \\textbf{\\Verb-streaming/-} - source code for the routines that can read and write\nSISL objects to a stream.\n\\item \\textbf{\\Verb-examples/-} - sample programs making use of the SISL 4.7 source code.\n\\item \\textbf{\\Verb-viewer/-} - source code for a viewer that can be used to view SISL \n  objects saved in the \\verb/Go/-format.\n\\item \\textbf{\\Verb-app/-} - the expected directory for test programs and applications. A\n  couple of applications are provided including the example program described in Chapter 2.\n\\end{itemize}\nFurthermore is the file CMakeLists.txt provided to facilitate building the library.\n\n\\section{Licensing information}\nSISL is distributed under the \\emph{GNU Affero General Public License} (aGPL).  The license text \nis given in its entirety as an annex to this document.  Commercial licenses are also\navailable from SINTEF.  You can contact Tor Dokken (tor.dokken@sintef.no) for more\ninformation.\n\n%% *what is included in this distibution\n%% *explain chapters\n%% *the manual\n%% *licensing information\n%% *compilation\n%% *the object viewer\n"
  },
  {
    "path": "doc/manual/func/copyCurve.tex",
    "content": "\\subsection{Make a copy of a curve.}\n\\funclabel{copyCurve}\n\\begin{minipg1}\nMake a copy of a curve.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>SISLCurve *copyCurve(\\begin{minipg3}\n          {\\fov pcurve})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLCurve \\> *{\\fov pcurve};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov pcurve}    \\> - \\> Curve to be copied.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov copyCurve} \\> - \\> The new curve.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve \\> *{\\fov curvecopy} = NULL;\\\\\n        \\>\\>    SISLCurve \\> *{\\fov curve} = NULL;\\\\\n        \\>\\>    int       \\> {\\fov number} = 10;\\\\\n        \\>\\>    int       \\> {\\fov order} = 4;\\\\\n        \\>\\>    double    \\> {\\fov knots}[14]; \\,/* Must be defined */\\\\\n        \\>\\>    double    \\> {\\fov coef}[30]; \\, /* Must be defined */\\\\\n        \\>\\>    int       \\> {\\fov kind} = 1; /* Non-rational */ \\\\\n        \\>\\>    int       \\> {\\fov dim} = 3;\\\\\n        \\>\\>    int       \\> {\\fov copy} = 1;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>curve = newCurve(\\begin{minipg4}\n          {\\fov number}, {\\fov order}, {\\fov knots}, {\\fov coef}, {\\fov kind}, {\\fov dim}, {\\fov copy});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>curvecopy = copyCurve(\\begin{minipg4}\n          {\\fov curve});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/copySurface.tex",
    "content": "\\subsection{Make a copy of a surface object.}\n\\funclabel{copySurface}\n\\begin{minipg1}\n  Make a copy of a SISLSurface object.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>SISLSurf *copySurface(\\begin{minipg3}\n          {\\fov psurf})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf *{\\fov psurf};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov psurf}\\> - \\>  \\begin{minipg2}\n                      Surface to be copied.\n                               \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov copySurface}\\> - \\>  \\begin{minipg2}\n                     The new surface.\n                               \\end{minipg2}\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf\\>      {\\fov *surfcopy} = NULL;\\\\\n        \\>\\>    SISLSurf\\>      {\\fov *surf} = NULL;\\\\\n        \\>\\>    int    \\>       {\\fov number1} = 5;\\\\\n        \\>\\>    int    \\>       {\\fov number2} = 4;\\\\\n        \\>\\>    int    \\>       {\\fov order1} = 4;\\\\\n        \\>\\>    int    \\>       {\\fov order2} = 3;\\\\\n        \\>\\>    double \\>       {\\fov knot1}[9];\\\\\n        \\>\\>    double \\>       {\\fov knot2}[7];\\\\\n        \\>\\>    double \\>       {\\fov coef}[60];\\\\\n        \\>\\>    int    \\>       {\\fov kind} = 1;\\\\\n        \\>\\>    int    \\>       {\\fov dim} = 3;\\\\\n        \\>\\>    int    \\>       {\\fov copy} = 1;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>{\\fov surf} = newSurf(\\begin{minipg4}\n          {\\fov number}1, {\\fov number}2, {\\fov order}1, {\\fov order}2, {\\fov knot}1, {\\fov knot}2,\\\\ {\\fov coef}, {\\fov kind}, {\\fov dim}, {\\fov copy});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>surfcopy = copySurface(\\begin{minipg4}\n          {\\fov surf});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/freeCurve.tex",
    "content": "\\subsection{Delete a curve object.} \\label{sec:freeCurve}\n\\funclabel{freeCurve}\n\\begin{minipg1}\nFree the space occupied by the curve. Before using freeCurve, make sure the curve object exists.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void freeCurve(\\begin{minipg3}\n          {\\fov curve})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLCurve    \\> *{\\fov curve};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to the curve to delete.\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve    \\> *{\\fov curve} = NULL;\\\\\n        \\>\\>    int    \\>       {\\fov number} = 10;\\\\\n        \\>\\>    int    \\>       {\\fov order} = 4;\\\\\n        \\>\\>    double \\>       {\\fov knots}[14];\\\\\n        \\>\\>    double \\>       {\\fov coef}[30];\\\\\n        \\>\\>    int    \\>       {\\fov kind} = 1;\\\\\n        \\>\\>    int    \\>       {\\fov dim} = 3;\\\\\n        \\>\\>    int    \\>       {\\fov copy} = 1;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>curve = newCurve(\\begin{minipg4}\n          {\\fov number}, {\\fov order}, {\\fov knots}, {\\fov coef}, {\\fov kind}, {\\fov dim}, {\\fov copy});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>if (curve) freeCurve(\\begin{minipg4}\n          {\\fov curve});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/freeIntcrvlist.tex",
    "content": "\\subsection{Free a list of intersection curves.}\\label{sec:freeIntcrvlist}\n\\funclabel{freeIntcrvlist}\n\\begin{minipg1}\n      Free a list of SISLIntcurve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void freeIntcrvlist(\\begin{minipg3}\n            {\\fov vilist}, {\\fov icrv})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLIntcurve **{\\fov vilist};\\\\\n                \\>\\>    int    \\>  {\\fov icrv};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov vilist}\\> - \\>  \\begin{minipg2}\n                     Array of pointers to pointers to instance\n                           of Intcurve.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov icrv}\\> - \\>  \\begin{minipg2}\n                     number of SISLIntcurves in the list.\n                               \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov None}\\> - \\>  \\begin{minipg2}\n                None.\n                               \\end{minipg2}\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n\n                \\>\\>    SISLIntcurve **{\\fov vilist} = NULL;\\\\\n                \\>\\>    int    \\>  {\\fov icrv} = 0;\\\\                \\>\\>    \\ldots \\\\\n                \\>\\> /* SISLIntcurve instances are generated for instance in surface--surface \\\\\n                \\>\\> intersection */ \\\\\n                \\>\\> \\ldots \\\\\n        \\>\\>if (vilist) freeIntcrvlist(\\begin{minipg4}\n            {\\fov vilist}, {\\fov icrv});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/freeIntcurve.tex",
    "content": "\\subsection{Delete an intersection curve object.}\n\\funclabel{freeIntcurve}\n\\begin{minipg1}\n  Free the space occupied by a SISLIntcurve.\\\\\n  Note that the arrays {\\fov guidepar1} and {\\fov guidepar2} will be freed as well.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void freeIntcurve(\\begin{minipg3}\n        intcurve)\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLIntcurve \\> *{\\fov intcurve};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov intcurve} \\> - \\> Pointer to the SISLIntcurve to delete.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLIntcurve    \\>      *{\\fov intcurve} = NULL;\\\\\n                \\>\\>    int    \\>       {\\fov numgdpt} = 2;\\\\\n                \\>\\>    int    \\>       {\\fov numpar1} = 2;\\\\\n                \\>\\>    int    \\>       {\\fov numpar2} = 2;\\\\\n                \\>\\>    double \\>       {\\fov guidepar1}[4];\\\\\n                \\>\\>    double \\>       {\\fov guidepar2}[4];\\\\\n                \\>\\>    int    \\>       {\\fov type} = 4;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>{\\fov intcurve} = newIntcurve(\\begin{minipg4}\n                {\\fov numgdpt}, {\\fov numpar1}, {\\fov numpar2}, {\\fov guidepar1},\\\\ {\\fov guidepar2}, {\\fov type});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>if (intcurve) freeIntcurve(\\begin{minipg4}\n                {\\fov intcurve});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/freeSurf.tex",
    "content": "\\subsection{Delete a surface object.}\n\\funclabel{freeSurf}\n\\begin{minipg1}\n  Free the space occupied by the surface. Before using freeSurf, make\n  sure that the surface object exists.\n\\end{minipg1} \\\\\nSYNOPSIS\\\\\n        \\>void freeSurf(\\begin{minipg3}\n          {\\fov surf})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf    \\>  *{\\fov surf};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}     \\> - \\> Pointer to the surface to\n        delete.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf\\>      *{\\fov surf} = NULL;\\\\\n        \\>\\>    int    \\>       {\\fov number1} = 5;\\\\\n        \\>\\>    int    \\>       {\\fov number2} = 4;\\\\\n        \\>\\>    int    \\>       {\\fov order1} = 4;\\\\\n        \\>\\>    int    \\>       {\\fov order2} = 3;\\\\\n        \\>\\>    double \\>       {\\fov knot1}[9];\\\\\n        \\>\\>    double \\>       {\\fov knot2}[7];\\\\\n        \\>\\>    double \\>       {\\fov coef}[60];\\\\\n        \\>\\>    int    \\>       {\\fov kind} = 1;\\\\\n        \\>\\>    int    \\>       {\\fov dim} = 3;\\\\\n        \\>\\>    int    \\>       {\\fov copy} = 1;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>{\\fov surf}$=$newSurf(\\begin{minipg4}\n          {\\fov number1}, {\\fov number2}, {\\fov order1}, {\\fov order2}, {\\fov knot1}, {\\fov knot2},\\\\ {\\fov coef}, {\\fov kind}, {\\fov dim}, {\\fov copy});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>{\\fov if (surf) freeSurf}(\\begin{minipg4}\n          {\\fov surf});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/newCurve.tex",
    "content": "\\subsection{Create new curve object.} \\label{sec:newCurve}\n\\funclabel{newCurve}\n\\begin{minipg1}\n  Create and initialize a SISLCurve-instance. Note that the vertex input to a\n  rational curve is unstandard. Given the curve\n  $$\n{\\bf c}(t) = {\\sum_{i=1}^{n} w_i {\\bf p}_{i} B_{i,k,{\\bf t}}(t)\n                 \\over\n                 \\sum_{i=1}^{n} w_i B_{i,k,{\\bf t}}(t)},\n$$\nmust the vertices be given as\n${w_1  {\\bf p}_1, w_1, w_2  {\\bf p}_2, w_2, \\ldots,\n  w_n  {\\bf p}_n, w_n}$ when invoking this function. Thus the vertices are multiplied with the\nassociated weight.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>SISLCurve *newCurve(\\begin{minipg3}\n        {\\fov number}, {\\fov order}, {\\fov knots}, {\\fov coef}, {\\fov kind}, {\\fov dim}, {\\fov copy})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    int    \\>       {\\fov number};\\\\\n                \\>\\>    int    \\>       {\\fov order};\\\\\n                \\>\\>    double \\>       {\\fov knots}[\\,];\\\\\n                \\>\\>    double \\>       {\\fov coef}[\\,];\\\\\n                \\>\\>    int    \\>       {\\fov kind};\\\\\n                \\>\\>    int    \\>       {\\fov dim};\\\\\n                \\>\\>    int    \\>       {\\fov copy};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov number}   \\> - \\> Number of vertices in the new curve.\\\\\n        \\>\\>    {\\fov order} \\> - \\> Order of curve.\\\\\n        \\>\\>    {\\fov knots} \\> - \\> Knot vector of curve.\\\\\n        \\>\\>    {\\fov coef}  \\> - \\> \\begin{minipg2}\n                      Vertices of curve. These can either be the $dim$\n                      \\mbox{dimensional}\n                      non-rational vertices, or the $(dim+1)$ dimensional rational\n                      vertices.\n                                     \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov kind} \\> - \\> Type of curve.\\\\\n        \\>\\>\\>\\>\\>       $= 1$ :\\> Polynomial B-spline curve.\\\\\n        \\>\\>\\>\\>\\>       $= 2$ :\\> Rational B-spline (nurbs) curve.\\\\\n        \\>\\>\\>\\>\\>       $= 3$ :\\> Polynomial Bezier curve.\\\\\n        \\>\\>\\>\\>\\>       $= 4$ :\\> Rational Bezier curve.\\\\\n        \\>\\>    {\\fov dim} \\> - \\> Dimension of the space in which the\n                                   curve lies.\\\\\n        \\>\\>    {\\fov copy} \\> - \\> Flag \\\\\n        \\>\\>\\>\\>\\>       $= 0$ :\\> Set pointer to input arrays.\\\\\n        \\>\\>\\>\\>\\>       $= 1$ :\\> Copy input arrays.\\\\\n        \\>\\>\\>\\>\\>       $= 2$ :\\> Set pointer and remember to free arrays.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newCurve} \\> - \\> \\begin{minipg2}\n                                 Pointer to the new curve. If it is impossible\n                                 to allocate space for the curve, newCurve\n                                 returns NULL.\n                                \\end{minipg2}\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve    \\> *{\\fov curve} = NULL;\\\\\n        \\>\\>    int    \\>       {\\fov number} = 10;\\\\\n        \\>\\>    int    \\>       {\\fov order} = 4;\\\\\n        \\>\\>    double \\>       {\\fov knots}[14]; \\,/* Must be defined */\\\\\n        \\>\\>    double \\>       {\\fov coef}[30]; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\>       {\\fov kind} = 1; /* Non-rational */ \\\\\n        \\>\\>    int    \\>       {\\fov dim} = 3;\\\\\n        \\>\\>    int    \\>       {\\fov copy} = 1;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>{\\fov curve} = newCurve(\\begin{minipg4}\n          {\\fov number}, {\\fov order}, {\\fov knots}, {\\fov coef}, {\\fov kind},\n          {\\fov dim}, {\\fov copy});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/newIntcurve.tex",
    "content": "\\subsection{Create a new intersection curve object.}\n\\funclabel{newIntcurve}\n\\begin{minipg1}\nCreate and initialize a SISLIntcurve-instance. Note that the arrays\n{\\fov guidepar1} and {\\fov guidepar2} will be freed by freeIntcurve. In most cases the SISLIntcurve objects will be generated internally in the SISL intersection routines.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>SISLIntcurve *newIntcurve(\\begin{minipg3}\n        {\\fov numgdpt}, {\\fov numpar1}, {\\fov numpar2}, {\\fov guidepar1},\\\\ {\\fov guidepar2}, type)\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    int    \\>       {\\fov numgdpt};\\\\\n                \\>\\>    int    \\>       {\\fov numpar1};\\\\\n                \\>\\>    int    \\>       {\\fov numpar2};\\\\\n                \\>\\>    double \\>       {\\fov guidepar1}[\\,];\\\\\n                \\>\\>    double \\>       {\\fov guidepar2}[\\,];\\\\\n                \\>\\>    int    \\>       {\\fov type};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov numgdpt}  \\> - \\> \\begin{minipg2}\n                                Number of guide points that describe the curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov numpar1} \\> - \\> \\begin{minipg2}\n                                Number of parameter directions of first object\n                                involved in the intersection.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numpar2}  \\> - \\> \\begin{minipg2}\n                                Number of parameter directions of second object\n                                involved in the intersection.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov guidepar1}\\> - \\> \\begin{minipg2}\n                                Parameter values of the guide points in the parameter\n                                area of the first object.\n                                NB! The epar1 pointer is set to point to this\n                                array. The values are not copied.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov guidepar2}\\> - \\> \\begin{minipg2}\n                                Parameter values of the guide points in the parameter\n                                area of the second object.\n                                NB! The epar2 pointer is set to point to this\n                                array. The values are not copied.\n                                \\end{minipg2}\\\\[0.3ex].\n        \\>\\>    {\\fov type} \\> - \\> \\begin{minipg2}\n                                Kind of curve, see type SISLIntcurve on\n                                page \\pageref{SISLIntcurve}\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newIntcurve} \\> \\> \\begin{minipg2}\n                                 Pointer to new SISLIntcurve. If it is impossible\n                                 to allocate space for the SISLIntcurve, newIntcurve\n                                 returns NULL.\n                                \\end{minipg2}\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLIntcurve    \\>      *{\\fov intcurve = NULL};\\\\\n                \\>\\>    int    \\>       {\\fov numgdpt} = 2;\\\\\n                \\>\\>    int    \\>       {\\fov numpar1} = 2;\\\\\n                \\>\\>    int    \\>       {\\fov numpar2} = 2;\\\\\n                \\>\\>    double \\>       {\\fov guidepar1}[4]; \\, /* Must be defined */\\\\\n                \\>\\>    double \\>       {\\fov guidepar2}[4]; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>       {\\fov type} = 4;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>{\\fov intcurve} = newIntcurve(\\begin{minipg4}\n                {\\fov numgdpt}, {\\fov numpar1}, {\\fov numpar2}, {\\fov guidepar1},\\\\ {\\fov guidepar2}, type);\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/newSurf.tex",
    "content": "\\subsection{Create a new surface object.}\\label{sec:newSurf}\n\\funclabel{newSurf}\n\\begin{minipg1}\nCreate and initialize a surface object instance. Note that the vertex input to a\n  rational surface is unstandard. Given the surface\n  $$\n{\\bf s}(u,v) = {\\sum_{i=1}^{n_1}\\sum_{j=1}^{n_2} w_{i,j} {\\bf p}_{i,j} \n\t    B_{i,k_1,{\\bf u}}(u) B_{j,k_2,{\\bf v}}(v)  \\over\n             \\sum_{i=1}^{n_1}\\sum_{j=1}^{n_2} w_{i,j}\n\t         B_{i,k_1,{\\bf u}}(u) B_{j,k_2,{\\bf v}}(v)},\n$$\nmust the vertices be given as\n${w_{1,1}  {\\bf p}_{1,1}, w_{1,1}, w_{1,2}  {\\bf p}_{1,2}, w_{1,2},  \\ldots,\n  w_{n_1,n_2}  {\\bf p}_{n_1,n_2}, w_{n_1,n_2}}$ when invoking this function. Thus the vertices are multiplied with the\nassociated weight.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>SISLSurf *newSurf(\\begin{minipg3}\n        {\\fov number}1, {\\fov number}2, {\\fov order}1, {\\fov order}2, {\\fov knot}1, {\\fov knot}2, {\\fov coef},\\\\ {\\fov kind}, {\\fov dim}, {\\fov copy})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    int    \\>       {\\fov number}1;\\\\\n                \\>\\>    int    \\>       {\\fov number}2;\\\\\n                \\>\\>    int    \\>       {\\fov order}1;\\\\\n                \\>\\>    int    \\>       {\\fov order}2;\\\\\n                \\>\\>    double \\>       {\\fov knot1}[\\,];\\\\\n                \\>\\>    double \\>       {\\fov knot2}[\\,];\\\\\n                \\>\\>    double \\>       {\\fov coef}[\\,];\\\\\n                \\>\\>    int    \\>       {\\fov kind};\\\\\n                \\>\\>    int    \\>       {\\fov dim};\\\\\n                \\>\\>    int    \\>       {\\fov copy};\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov number}1  \\> - \\> \\begin{minipg2}\n                        Number of vertices in the first parameter direction\n                        of new surface.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov number}2  \\> - \\> \\begin{minipg2}\n                        Number of vertices in the second parameter direction\n                        of new surface.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov order1     } \\> - \\>\\begin{minipg2}\n                        Order of surface in first parameter direction.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov order2     } \\> - \\> \\begin{minipg2}\n                        Order of surface in second parameter direction.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov knot1    } \\> - \\> \\begin{minipg2}\n                        Knot vector of surface in first parameter direction.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov knot2    } \\> - \\> \\begin{minipg2}\n                        Knot vector of surface in second parameter direction.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov coef }    \\> - \\> \\begin{minipg2}\nVertices of surface. These may either be the {\\fov dim} dimensional non-rational vertices or the {\\fov (dim+1)} dimensional rational vertices.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov kind  } \\> - \\> Type of surface.\\\\\n        \\>\\>\\>\\>\\>       $= 1$ :\\> Polynomial B-spline surface.\\\\\n        \\>\\>\\>\\>\\>       $= 2$ :\\> Rational B-spline (nurbs) surface.\\\\\n        \\>\\>\\>\\>\\>       $= 3$ :\\> Polynomial Bezier surface.\\\\\n        \\>\\>\\>\\>\\>       $= 4$ :\\> Rational Bezier surface.\\\\\n        \\>\\>    {\\fov dim   } \\> - \\> Dimension of the space in which the surface lies.\\\\\n        \\>\\>    {\\fov copy  } \\> - \\> Flag \\\\\n        \\>\\>\\>\\>\\>       $= 0$ :\\> Set pointer to input arrays.\\\\\n        \\>\\>\\>\\>\\>       $= 1$ :\\> Copy input arrays.\\\\\n        \\>\\>\\>\\>\\>       $= 2$ :\\> Set pointer and remember to free arrays.\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newSurf} \\> - \\> \\begin{minipg2}\n                                 Pointer to new surface. If it is impossible\n                                 to allocate space for the surface, newSurface\n                                 returns NULL.\n                                \\end{minipg2}\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf\\>      *{\\fov surf} = NULL;\\\\\n        \\>\\>    int    \\>       {\\fov number1} = 5;\\\\\n        \\>\\>    int    \\>       {\\fov number2} = 4;\\\\\n        \\>\\>    int    \\>       {\\fov order1} = 4; /* Polynomial degree 3 */\\\\\n        \\>\\>    int    \\>       {\\fov order2} = 3; /* Polynomial degree 2 */\\\\\n        \\>\\>    double \\>       {\\fov knot1}[9];  \\, /* Must be defined */ \\\\\n        \\>\\>    double \\>       {\\fov knot2}[7]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\>       {\\fov coef}[60];  \\, /* Must be defined */\\\\ \n        \\>\\>    int    \\>       {\\fov kind} = 1;\\\\\n        \\>\\>    int    \\>       {\\fov dim} = 3;\\\\\n        \\>\\>    int    \\>       {\\fov copy} = 1;\\\\\n        \\>\\> /* Knots and vertices must be defined prior to the function call. \\\\\n        \\>\\>    The vertices are given in a 1-dimensional array */ \\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>{\\fov surf} = newSurf(\\begin{minipg4}\n          {\\fov number}1, {\\fov number}2, {\\fov order}1, {\\fov order}2, {\\fov knot}1, {\\fov knot}2,\\\\ {\\fov coef}, {\\fov kind}, {\\fov dim}, {\\fov copy});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/newbox.tex",
    "content": "\\subsection{Create and initialize a curve/surface bounding box instance.}\n\\funclabel{newbox}\n\\begin{minipg1}\nCreate and initialize a curve/surface bounding box instance.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>SISLbox *newbox(\\begin{minipg3}\n          {\\fov idim})\n        \\end{minipg3}\\\\\n        \\>\\>    int \\> {\\fov idim};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov idim}\\> - \\>\n        \\begin{minipg2}\n          Dimension of geometry space.\n        \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newbox}\\> - \\>\n        \\begin{minipg2}\n          Pointer to new SISLbox structure. If it is\n          impossible to allocate space for the structure,\n          newbox will return a NULL value.\n        \\end{minipg2}\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>int   \\> {\\fov idim} = 3;\\\\\n        \\>\\>SISLbox *{\\fov box} = NULL;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>{\\fov box} = newbox(\\begin{minipg4}\n          {\\fov idim});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/newdir.tex",
    "content": "\\subsection{Create and initialize a curve/surface direction instance.}\n\\funclabel{newdir}\n\\begin{minipg1}\nCreate and initialize a curve/surface direction instance.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>SISLdir *newdir(\\begin{minipg3}\n          {\\fov idim})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    int \\> {\\fov idim};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov idim}\\> - \\>\n        \\begin{minipg2}\n          Dimension of the space in which the object lies.\n        \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newdir}\\> - \\>\n        \\begin{minipg2}\n          Pointer to new direction structure. If it is\n          impossible to allocate space for the structure,\n          newdir will return a NULL value.\n        \\end{minipg2}\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>int     \\> {\\fov idim} = 3;\\\\\n        \\>\\>SISLdir \\> *{\\fov dir} = NULL;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>{\\fov dir} = newdir(\\begin{minipg4}\n          {\\fov idim});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1001.tex",
    "content": "\\section{Pick a Part of a Surface.}\n\\funclabel{s1001}\n\\begin{minipg1}\n  To pick a part of a surface.\n  The surface produced will always be k-regular, i.e.\\ with\n  k-tupple start/end knots.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1001(\\begin{minipg3}\n          {\\fov ps},  {\\fov min1},  {\\fov min2},  {\\fov max1},  {\\fov max2},  {\\fov rsnew},  {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf \\> *{\\fov ps};\\\\\n        \\>\\>    double   \\> {\\fov min1};\\\\\n        \\>\\>    double   \\> {\\fov min2};\\\\\n        \\>\\>    double   \\> {\\fov max1};\\\\\n        \\>\\>    double   \\> {\\fov max2};\\\\\n        \\>\\>    SISLSurf \\> **{\\fov rsnew};\\\\\n        \\>\\>    int      \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov ps}\\> - \\>  \\begin{minipg2}\n                     Surface to pick a part of.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov min1}\\> - \\>  \\begin{minipg2}\n                     Minimum value in first parameter direction.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov min2}\\> - \\>  \\begin{minipg2}\n                     Minimum value in second parameter direction.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov max1}\\> - \\>  \\begin{minipg2}\n                     Maximum value in first parameter direction.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov max2}\\> - \\>  \\begin{minipg2}\n                     Maximum value second parameter direction.\n                               \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rsnew}\\> - \\>  \\begin{minipg2}\n                     The new, picked surface.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>           $> 0$ \\> : Warning.\\\\\n                \\>\\>\\>\\>\\>           $= 0$ \\> : Ok.\\\\\n                \\>\\>\\>\\>\\>           $< 0$ \\> : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf \\> *{\\fov ps}; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> {\\fov min1}; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> {\\fov min2}; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> {\\fov max1}; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> {\\fov max2}; \\, /* Must be defined */\\\\\n        \\>\\>    SISLSurf \\> *{\\fov rsnew} = NULL;\\\\\n        \\>\\>    int      \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1001(\\begin{minipg4}\n          {\\fov ps},  {\\fov min1},  {\\fov min2},  {\\fov max1},  {\\fov max2}, \\&{\\fov rsnew},  \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1011.tex",
    "content": "\\subsection{Express a conic arc as a curve.}\n\\funclabel{s1011}\n\\begin{minipg1}\n  Convert an analytic conic arc to a curve.\n  The curve will be geometrically exact.\n  The arc is given by position at start, shoulder point and end, and a\n  shape factor.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1011(\\begin{minipg3}\n          {\\fov start\\_pos},  {\\fov top\\_pos},  {\\fov end\\_pos},  {\\fov shape},  {\\fov dim},  {\\fov arc\\_seg},  {\\fov stat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    double \\> {\\fov start\\_pos}[\\,];\\\\\n        \\>\\>    double \\> {\\fov top\\_pos}[\\,];\\\\\n        \\>\\>    double \\> {\\fov end\\_pos}[\\,];\\\\\n        \\>\\>    double \\> {\\fov shape};\\\\\n        \\>\\>    int    \\> {\\fov dim};\\\\\n        \\>\\>    SISLCurve \\> **{\\fov arc\\_seg};\\\\\n        \\>\\>    int    \\> *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov start\\_pos} \\> - \\> Start point of segment.\\\\\n        \\>\\>    {\\fov top\\_pos}   \\> - \\> \\begin{minipg2}\n                                            Shoulder point of\n                                            segment. This is the\n                                            intersection point of the\n                                            tangents in {\\fov start\\_pos} and\n                                            {\\fov end\\_pos}.\n                                          \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov end\\_pos}   \\> - \\> End point of segment.\\\\\n        \\>\\>    {\\fov shape}      \\> - \\> Shape factor, must be $\\geq 0$.\\\\\n                \\>\\>\\>\\>\\> $< 0.5$, an ellipse,\\\\\n                \\>\\>\\>\\>\\> $= 0.5$, a parabola,\\\\\n                \\>\\>\\>\\>\\> $> 0.5$, a hyperbola,\\\\\n                \\>\\>\\>\\>\\> $\\geq 1$,\n                           \\begin{minipg5}\n                             the start and end points lies on different branches of\n                             the hyperbola.  We want a single arc\n                             segment, therefore if $shape\\geq 1$, shape\n                             is set to $0.999999$.\n                           \\end{minipg5}\\\\[0.8ex]\n        \\>\\>    {\\fov dim}        \\> - \\> The spatial dimension of the curve to\n                                          be produced.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n        \\>\\>    {\\fov arc\\_seg} \\> - \\> Pointer to the curve produced.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    double \\> {\\fov start\\_pos}[3]; \\,/* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov top\\_pos}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov end\\_pos}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov shape} = 0.3;\\\\\n        \\>\\>    int    \\> {\\fov dim} = 3;\\\\\n        \\>\\>    SISLCurve \\> *{\\fov arc\\_seg} = NULL;\\\\\n        \\>\\>    int    \\> {\\fov stat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1011(\\begin{minipg4}\n        {\\fov start\\_pos},  {\\fov top\\_pos},  {\\fov end\\_pos},  {\\fov shape},  {\\fov dim},  \\&{\\fov arc\\_seg},  \\&{\\fov stat});\n      \\end{minipg4}\\\\\n      \\>\\>    \\ldots \\\\\n      \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1012.tex",
    "content": "\\subsection{Express a truncated helix as a curve.}\n\\funclabel{s1012}\n\\begin{minipg1}\n  Convert an analytical truncated helix to a curve.\n  The curve will be geometrically exact.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1012(\\begin{minipg3}\n          {\\fov start\\_pos}, {\\fov axis\\_pos}, {\\fov axis\\_dir}, {\\fov frequency}, {\\fov numb\\_quad},\n          {\\fov counter\\_clock}, {\\fov helix}, {\\fov stat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    double \\> {\\fov start\\_pos}[\\,];\\\\\n        \\>\\>    double \\> {\\fov axis\\_pos}[\\,];\\\\\n        \\>\\>    double \\> {\\fov axis\\_dir}[\\,];\\\\\n        \\>\\>    double \\> {\\fov frequency};\\\\\n        \\>\\>    int    \\> {\\fov numb\\_quad};\\\\\n        \\>\\>    int    \\> {\\fov counter\\_clock};\\\\\n        \\>\\>    SISLCurve \\> **{\\fov helix};\\\\\n        \\>\\>    int    \\> *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov start\\_pos} \\> - \\> Start position on the helix.\\\\\n        \\>\\>    {\\fov axis\\_pos}  \\> - \\> Point on the helix axis.\\\\\n        \\>\\>    {\\fov axis\\_dir}  \\> - \\> Direction of the helix axis.\\\\\n        \\>\\>    {\\fov frequency}  \\> - \\> \\begin{minipg2}\n                                            The length along the helix\n                                            axis for one period of revolution.\n                                          \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numb\\_quad} \\> - \\> Number of quadrants in the helix.\\\\\n        \\>\\>    {\\fov counter\\_clock} \\> - \\> Flag for direction of revolution:\\\\\n                \\>\\>\\>\\>\\> $= 0$ : clockwise,\\\\\n                \\>\\>\\>\\>\\> $= 1$ : counter\\_clockwise.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n        \\>\\>    {\\fov helix} \\> - \\> Pointer to the helix curve produced.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    double \\> {\\fov start\\_pos}[3]; \\,/* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov axis\\_pos}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov axis\\_dir}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov frequency}; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\> {\\fov numb\\_quad} = 5;\\\\\n        \\>\\>    int    \\> {\\fov counter\\_clock} = 1;\\\\\n        \\>\\>    SISLCurve \\> *{\\fov helix} = NULL;\\\\\n        \\>\\>    int    \\> {\\fov stat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1012(\\begin{minipg4}\n          {\\fov start\\_pos}, {\\fov axis\\_pos}, {\\fov axis\\_dir}, {\\fov frequency}, {\\fov numb\\_quad},\n          {\\fov counter\\_clock}, \\&{\\fov helix}, \\&{\\fov stat})\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1013.tex",
    "content": "\\subsection{Find a point on a 2D curve along a given direction.}\n\\funclabel{s1013}\n\\begin{minipg1}\n  Find a point on a 2D curve along a given direction.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1013(\\begin{minipg3}\n        {\\fov pcurve}, {\\fov ang}, {\\fov ang\\_tol}, {\\fov guess\\_par}, {\\fov iter\\_par}, {\\fov jstat})\n      \\end{minipg3}\\\\[0.3ex]\n      \\>\\>      SISLCurve \\>  *{\\fov pcurve};\\\\\n      \\>\\>      double    \\>   {\\fov ang};\\\\\n      \\>\\>      double    \\>   {\\fov ang\\_tol};\\\\\n      \\>\\>      double    \\>   {\\fov guess\\_par};\\\\\n      \\>\\>      double    \\>  *{\\fov iter\\_par};\\\\\n      \\>\\>      int       \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov pcurve}    \\> - \\> Pointer to the curve.\\\\\n        \\>\\>    {\\fov ang}       \\> - \\> \\begin{minipg2}\n                                           The angle (in radians)\n                                           describing the wanted\n                                           \\mbox{direction}.\n                                         \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ang\\_tol}  \\> - \\> The angular tolerance (in radians).\\\\\n        \\>\\>    {\\fov guess\\_par}\\> - \\> Start parameter value on the curve.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov iter\\_par} \\> - \\> The parameter value found on the curve.\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $= 2$   : A minimum distance found.\\\\\n                \\>\\>\\>\\>\\>              $= 1$   : Intersection found.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve \\>  *{\\fov pcurve}; \\, /* Must be defined */\\\\\n        \\>\\>    double    \\>  {\\fov ang}; \\, /* Must be defined */\\\\\n        \\>\\>    double    \\>  {\\fov ang\\_tol} = 0.01;\\\\\n        \\>\\>    double    \\>  {\\fov guess\\_par}; \\, /* Must be defined */\\\\\n        \\>\\>    double    \\>  {\\fov iter\\_par};\\\\\n        \\>\\>    int       \\>  {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1013(\\begin{minipg4}\n        {\\fov pcurve}, {\\fov ang}, {\\fov ang\\_tol}, {\\fov guess\\_par}, \\&{\\fov iter\\_par}, \\&{\\fov jstat});\n      \\end{minipg4}\\\\\n      \\>\\>    \\ldots \\\\\n      \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1014.tex",
    "content": "\\subsection{Compute a circular fillet between a 2D curve and a circle.}\n\\funclabel{s1014}\n\\begin{minipg1}\n  Compute the fillet by iterating to the start and end points of a\n  fillet between a 2D curve and a circle. The centre of the circular\n  fillet is also calculated.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1014(\\begin{minipg3}\n        {\\fov pc1}, {\\fov circ\\_cen}, {\\fov circ\\_rad}, {\\fov aepsge}, {\\fov eps1}, {\\fov eps2}, {\\fov aradius},\n        {\\fov parpt1}, {\\fov parpt2}, {\\fov centre}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLCurve \\> *{\\fov pc1};\\\\\n        \\>\\>    double    \\> {\\fov circ\\_cen}[\\,];\\\\\n        \\>\\>    double    \\> {\\fov circ\\_rad};\\\\\n        \\>\\>    double    \\> {\\fov aepsge};\\\\\n        \\>\\>    double    \\> {\\fov eps1}[\\,];\\\\\n        \\>\\>    double    \\> {\\fov eps2}[\\,];\\\\\n        \\>\\>    double    \\> {\\fov aradius};\\\\\n        \\>\\>    double    \\> *{\\fov parpt1};\\\\\n        \\>\\>    double    \\> *{\\fov parpt2};\\\\\n        \\>\\>    double    \\> {\\fov centre}[\\,];\\\\\n        \\>\\>    int       \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov pc1}    \\> - \\> The first input curve.\\\\\n        \\>\\>    {\\fov circ\\_cen}   \\> - \\> 2D centre of the circle.\\\\\n        \\>\\>    {\\fov circ\\_rad}   \\> - \\> Radius of the circle.\\\\\n        \\>\\>    {\\fov aepsge} \\> - \\> Geometry resolution.\\\\\n        \\>\\>    {\\fov eps1}   \\> - \\> \\begin{minipg2}\n                                        2D point telling that the fillet\n                                        should be put on the side of\n                                        curve 1 where {\\fov eps1} is situated.\n                                      \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov eps2}   \\> - \\> \\begin{minipg2}\n                                        2D point telling that the fillet\n                                        should be put on the side of the\n                                        input circle where {\\fov eps2} is\n                                        situated.\n                                      \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov aradius} \\> - \\> The radius to be used on the fillet.\\\\\n\\\\\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov parpt1} \\> - \\> \\begin{minipg2}\n                                        Parameter value of the point on\n                                        curve 1 where the fillet\n                                        starts. Input is a guess value\n                                        for the iteration.\n                                      \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov parpt2} \\> - \\> \\begin{minipg2}\n                                        Parameter value of the point on\n                                        the input circle where the\n                                        fillet ends. Input is a guess\n                                        value for the iteration.\n                                      \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov centre} \\> - \\> \\begin{minipg2}\n                                        2D centre of the circular\n                                        fillet.  Space must be allocated\n                                        outside the function.\n                                      \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $= 1$      : Converged,\\\\\n                \\>\\>\\>\\>\\> $= 2$      : Diverged,\\\\\n                \\>\\>\\>\\>\\> $< 0$      : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve \\> *{\\fov pc1}; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov circ\\_cen}[2]; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov circ\\_rad}; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov aepsge} = 0.00001;\\\\\n        \\>\\>    double    \\> {\\fov eps1}[2]; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov eps2}[2]; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov aradius}; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov parpt1};\\\\\n        \\>\\>    double    \\> {\\fov parpt2};\\\\\n        \\>\\>    double    \\> {\\fov centre}[2];\\\\\n        \\>\\>    int       \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1014(\\begin{minipg4}\n        {\\fov pc1}, {\\fov circ\\_cen}, {\\fov circ\\_rad}, {\\fov aepsge}, {\\fov eps1}, {\\fov eps2}, {\\fov aradius},\n        \\&{\\fov parpt1}, \\&{\\fov parpt2}, {\\fov centre}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1015.tex",
    "content": "\\subsection{Compute a circular fillet between two 2D curves.}\n\\funclabel{s1015}\n\\begin{minipg1}\n  Compute the fillet by iterating to the start and end points of a\n  fillet between two 2D curves. The centre of the circular fillet is\n  also calculated.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1015(\\begin{minipg3}\n          {\\fov pc1}, {\\fov pc2}, {\\fov aepsge}, {\\fov eps1}, {\\fov eps2}, {\\fov aradius}, {\\fov parpt1}, {\\fov parpt2},\n          {\\fov centre}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve  \\>  *{\\fov pc1};\\\\\n                \\>\\>    SISLCurve  \\>  *{\\fov pc2};\\\\\n                \\>\\>    double     \\>  {\\fov aepsge};\\\\\n                \\>\\>    double     \\>  {\\fov eps1}[\\,];\\\\\n                \\>\\>    double     \\>  {\\fov eps2}[\\,];\\\\\n                \\>\\>    double     \\>  {\\fov aradius};\\\\\n                \\>\\>    double     \\>  *{\\fov parpt1};\\\\\n                \\>\\>    double     \\>  *{\\fov parpt2};\\\\\n                \\>\\>    double     \\>  {\\fov centre}[\\,];\\\\\n                \\>\\>    int        \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov pc1}     \\> - \\> The first 2D input curve.\\\\\n        \\>\\>    {\\fov pc2}     \\> - \\> The second 2D input curve.\\\\\n        \\>\\>    {\\fov aepsge}  \\> - \\> Geometry resolution.\\\\\n        \\>\\>    {\\fov eps1}    \\> - \\>\n        \\begin{minipg2}\n          2D point telling that the fillet should be put on\n          the side of curve 1 where {\\fov eps1} is situated.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov eps2}    \\> - \\>\n        \\begin{minipg2}\n          2D point telling that the fillet should be put on the\n          side of curve 2 where {\\fov eps2} is situated.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov aradius} \\> - \\> The radius to be used on the fillet.\\\\\n\\\\\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov parpt1}  \\> - \\>\n        \\begin{minipg2}\n          Parameter value of the point on curve 1 where the\n          fillet starts. Input is a guess value for the iteration.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov parpt2}  \\> - \\>\n        \\begin{minipg2}\n          Parameter value of the point on curve 2 where the\n          fillet ends. Input is a guess value for the iteration.\n        \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov centre}  \\> - \\>\n        \\begin{minipg2}\n          2D centre of the circular fillet.  Space must be\n          allocated outside the function.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $= 1$      : Converged,\\\\\n                \\>\\>\\>\\>\\> $= 2$      : Diverged,\\\\\n                \\>\\>\\>\\>\\> $< 0$      : Error.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve \\> *{\\fov pc1}; \\,/* Must be defined */ \\\\\n        \\>\\>    SISLCurve \\> *{\\fov pc2}; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov aepsge} = 0.00001;\\\\\n        \\>\\>    double    \\> {\\fov eps1}[2]; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov eps2}[2]; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov aradius}; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov parpt1}; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov parpt2}; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov centre}[2];\\\\\n        \\>\\>    int       \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1015(\\begin{minipg4}\n          {\\fov pc1}, {\\fov pc2}, {\\fov aepsge}, {\\fov eps1}, {\\fov eps2}, {\\fov aradius}, \\&{\\fov parpt1}, \\&{\\fov parpt2},\n          {\\fov centre}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1016.tex",
    "content": "\\subsection{Compute a circular fillet between a 2D curve and a 2D line.}\n\\funclabel{s1016}\n\\begin{minipg1}\n  Compute the fillet by iterating to the start and end points of a\n  fillet between a 2D curve and a 2D line. The centre of the circular\n  fillet is also calculated.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1016(\\begin{minipg3}\n          {\\fov pc1}, {\\fov point}, {\\fov normal}, {\\fov aepsge}, {\\fov eps1}, {\\fov eps2}, {\\fov aradius},\n          {\\fov parpt1}, {\\fov parpt2}, {\\fov centre}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve \\> *{\\fov pc1};\\\\\n                \\>\\>    double    \\> {\\fov point}[\\,];\\\\\n                \\>\\>    double    \\> {\\fov normal}[\\,];\\\\\n                \\>\\>    double    \\> {\\fov aepsge};\\\\\n                \\>\\>    double    \\> {\\fov eps1}[\\,];\\\\\n                \\>\\>    double    \\> {\\fov eps2}[\\,];\\\\\n                \\>\\>    double    \\> {\\fov aradius};\\\\\n                \\>\\>    double    \\> *{\\fov parpt1};\\\\\n                \\>\\>    double    \\> *{\\fov parpt2};\\\\\n                \\>\\>    double    \\> {\\fov centre}[\\,];\\\\\n                \\>\\>    int       \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov pc1}     \\> - \\> The 2D input curve.\\\\\n        \\>\\>    {\\fov point}   \\> - \\> 2D point on the line.\\\\\n        \\>\\>    {\\fov normal}  \\> - \\> 2D normal to the line.\\\\\n        \\>\\>    {\\fov aepsge}  \\> - \\> Geometry resolution.\\\\\n        \\>\\>    {\\fov eps1}    \\> - \\>\n        \\begin{minipg2}\n          2D point telling that the fillet should be put on\n          the side of curve 1 where {\\fov eps1} is situated.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov eps2}    \\> - \\>\n        \\begin{minipg2}\n          2D point telling that the fillet should be put on the\n          side of curve 2 where {\\fov eps2} is situated.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov aradius} \\> - \\> The radius to be used on the fillet.\\\\\n\\\\\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov parpt1}  \\> - \\>\n        \\begin{minipg2}\n          Parameter value of the point on curve 1 where the\n          fillet starts. Input is a guess value for the iteration.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov parpt2}  \\> - \\>\n        \\begin{minipg2}\n          Parameter value of the point on the line where the\n          fillet ends. Input is a guess value for the iteration.\n        \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov centre}  \\> - \\>\n        \\begin{minipg2}\n          2D centre of the (circular) fillet.  Space must be\n          allocated outside the function.\n        \\end{minipg2}\\\\[0.8ex]\n\\newpagetabs\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $= 1$      : Converged,\\\\\n                \\>\\>\\>\\>\\> $= 2$      : Diverged,\\\\\n                \\>\\>\\>\\>\\> $< 0$      : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve \\> *{\\fov pc1}; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov point}[2]; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov normal}[2]; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov aepsge} = 0.00001;\\\\\n        \\>\\>    double    \\> {\\fov eps1}[2]; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov eps2}[2]; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov aradius}; \\,/* Must be defined */ \\\\\n        \\>\\>    double    \\> {\\fov parpt1};\\\\\n        \\>\\>    double    \\> {\\fov parpt2};\\\\\n        \\>\\>    double    \\> {\\fov centre}[2];\\\\\n        \\>\\>    int       \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1016(\\begin{minipg4}\n          {\\fov pc1}, {\\fov point}, {\\fov normal}, {\\fov aepsge}, {\\fov eps1}, {\\fov eps2}, {\\fov aradius},\n          \\&{\\fov parpt1}, \\&{\\fov parpt2}, {\\fov centre}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1017.tex",
    "content": "\\subsection{Insert a given knot into the description of a curve.}\n\\funclabel{s1017}\n\\begin{minipg1}\n  Insert a given knot into the description of a curve.\\\\\n  NOTE       : When the curve is periodic (i.e.\\ the curve flag\n  $cuopen=-1$), the input parameter value must lie in the half-open\n  $[et[kk-1], et[kn)$ interval, the function will automatically update\n  the extra knots and  coeffisients. {\\fov rcnew}{\\tt ->}{\\fov in} is\n  still equal to  $pc${\\tt ->}$in + 1$!\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1017(\\begin{minipg3}\n          {\\fov pc},  {\\fov rc},  {\\fov apar},  {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLCurve \\> *{\\fov pc};\\\\\n        \\>\\>    SISLCurve \\> **{\\fov rc};\\\\\n        \\>\\>    double    \\> {\\fov apar};\\\\\n        \\>\\>    int       \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov pc}   \\> - \\> The curve to be refined.\\\\\n        \\>\\>    {\\fov apar} \\> - \\> Parameter value of the knot to be inserted.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rc}    \\> - \\> The new, refined curve.\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                      \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                      \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve \\> *{\\fov pc}; \\, /* Must be defined */\\\\\n        \\>\\>    double    \\> {\\fov apar}; \\, /* Must be defined */\\\\\n        \\>\\>    SISLCurve \\> *{\\fov rc} = NULL;\\\\\n        \\>\\>    int       \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1017(\\begin{minipg4}\n          {\\fov pc},  \\&{\\fov rc},  {\\fov apar}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1018.tex",
    "content": "\\subsection{Insert a given set of knots into the description of a curve.}\n\\funclabel{s1018}\n\\begin{minipg1}\n  Insert a given set of knots into the description of a curve.\\\\\n  NOTE       : When the curve is periodic (i.e.\\ when the curve flag\n  $cuopen=-1$), the input parameter values must lie in the half-open\n  $[et[kk-1], et[kn)$, the function will automatically update the extra\n  knots and coeffisients.\n  The {\\fov rcnew}{\\tt ->}{\\fov in} will still be equal to $pc${\\tt ->}$in + inpar$.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1018(\\begin{minipg3}\n          {\\fov pc},  {\\fov epar},  {\\fov inpar},  {\\fov rcnew},  {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLCurve \\> *{\\fov pc};\\\\\n        \\>\\>    double    \\> {\\fov epar}[\\,];\\\\\n        \\>\\>    int       \\> {\\fov inpar};\\\\\n        \\>\\>    SISLCurve \\> **{\\fov rcnew};\\\\\n        \\>\\>    int       \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov pc}   \\> - \\> The curve to be refined.\\\\\n        \\>\\>    {\\fov epar} \\> - \\>\n        \\begin{minipg2}\n          Knots to be inserted. The values are stored in increasing\n          order and may be multiple.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov inpar} \\> - \\> Number of knots in {\\fov epar}.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rcnew} \\> - \\> The new, refined curve.\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                      \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                      \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve \\> *{\\fov pc}; \\, /* Must be defined */\\\\\n        \\>\\>    double    \\> {\\fov epar}[5]; \\,/* Must be defined */\\\\\n        \\>\\>    int       \\> {\\fov inpar} = 5;\\\\\n        \\>\\>    SISLCurve \\> *{\\fov rcnew} = NULL;\\\\\n        \\>\\>    int       \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1018(\\begin{minipg4}\n          {\\fov pc},  {\\fov epar},  {\\fov inpar}, \\&{\\fov rcnew}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1021.tex",
    "content": "\\subsection{Express a truncated cylinder as a surface.}\n\\funclabel{s1021}\n\\begin{minipg1}\n  To express a truncated cylinder as a surface. The cylinder can be\n  elliptic.\n  The cylinder will be geometrically exact.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1021(\\begin{minipg3}\n        {\\fov bottom\\_pos}, {\\fov bottom\\_axis}, {\\fov ellipse\\_ratio}, {\\fov axis\\_dir},\n        {\\fov height}, {\\fov cyl}, {\\fov stat})\n      \\end{minipg3}\\\\[0.3ex]\n      \\>\\>    double \\> {\\fov bottom\\_pos}[\\,];\\\\\n      \\>\\>    double \\> {\\fov bottom\\_axis}[\\,];\\\\\n      \\>\\>    double \\> {\\fov ellipse\\_ratio};\\\\\n      \\>\\>    double \\> {\\fov axis\\_dir}[\\,];\\\\\n      \\>\\>    double \\> {\\fov height};\\\\\n      \\>\\>    SISLSurf \\> **{\\fov cyl};\\\\\n      \\>\\>    int    \\> *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov bottom\\_pos}  \\> - \\> Center point of the bottom.\\\\\n        \\>\\>    {\\fov bottom\\_axis} \\> - \\> One of the bottom axis\n                                            (major or minor).\\\\\n        \\>\\>    {\\fov ellipse\\_ratio} \\> - \\> Ratio between the other\n                                              axis and bottom\\_axis.\\\\\n        \\>\\>    {\\fov axis\\_dir}    \\> - \\> Direction of the cylinder axis.\\\\\n        \\>\\>    {\\fov height}       \\> - \\> Height of the cone, can be negative.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov cyl}  \\> - \\> Pointer to the cylinder produced.\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : Warning.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Ok.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    double \\> {\\fov bottom\\_pos}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov bottom\\_axis}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov ellipse\\_ratio} = 1.0; /* Circular cylinder */\\\\\n        \\>\\>    double \\> {\\fov axis\\_dir}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov height}; \\, /* Must be defined */\\\\\n        \\>\\>    SISLSurf \\> *{\\fov cyl} = NULL;\\\\\n        \\>\\>    int    \\> {\\fov stat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1021(\\begin{minipg4}\n        {\\fov bottom\\_pos}, {\\fov bottom\\_axis}, {\\fov ellipse\\_ratio}, {\\fov axis\\_dir},\n        {\\fov height}, \\&{\\fov cyl}, \\&{\\fov stat})\n      \\end{minipg4}\\\\\n      \\>\\>    \\ldots \\\\\n      \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1022.tex",
    "content": "\\subsection{Express a truncated cone as a surface.}\n\\funclabel{s1022}\n\\begin{minipg1}\n  To express a truncated cone as a surface. The cone can be elliptic.\n  The cone will be geometrically exact.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1022(\\begin{minipg3}\n        {\\fov bottom\\_pos}, {\\fov bottom\\_axis}, {\\fov ellipse\\_ratio}, {\\fov axis\\_dir},\n        {\\fov cone\\_angle}, {\\fov height}, {\\fov cone}, {\\fov stat})\n      \\end{minipg3}\\\\[0.3ex]\n      \\>\\>    double \\> {\\fov bottom\\_pos}[\\,];\\\\\n      \\>\\>    double \\> {\\fov bottom\\_axis}[\\,];\\\\\n      \\>\\>    double \\> {\\fov ellipse\\_ratio};\\\\\n      \\>\\>    double \\> {\\fov axis\\_dir}[\\,];\\\\\n      \\>\\>    double \\> {\\fov cone\\_angle};\\\\\n      \\>\\>    double \\> {\\fov height};\\\\\n      \\>\\>    SISLSurf \\> **{\\fov cone};\\\\\n      \\>\\>    int    \\> *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov bottom\\_pos}  \\> - \\> Center point of the bottom.\\\\\n        \\>\\>    {\\fov bottom\\_axis} \\> - \\> One of the bottom axis (major or minor).\\\\\n        \\>\\>    {\\fov ellipse\\_ratio} \\> - \\> Ratio between the other axis and bottom\\_axis.\\\\\n        \\>\\>    {\\fov axis\\_dir}    \\> - \\> Direction of the cone axis.\\\\\n        \\>\\>    {\\fov cone\\_angle}  \\> - \\> \\begin{minipg2}\n                                              Angle between axis\\_dir\n                                              and the cone at the end of\n                                              bottom\\_axis, positive if\n                                              the cone is sloping\n                                              inwards.\n                                            \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov height}       \\> - \\> Height of the cone, can be negative.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov cone} \\> - \\> Pointer to the cone produced.\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : Warning.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Ok.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    double \\> {\\fov bottom\\_pos}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov bottom\\_axis}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov ellipse\\_ratio} =0.5;  /* Elliptic cone */\\\\\n        \\>\\>    double \\> {\\fov axis\\_dir}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov cone\\_angle}; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov height}; \\, /* Must be defined */\\\\\n        \\>\\>    SISLSurf \\> *{\\fov cone} = NULL;\\\\\n        \\>\\>    int    \\> {\\fov stat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1022(\\begin{minipg4}\n          {\\fov bottom\\_pos}, {\\fov bottom\\_axis}, {\\fov ellipse\\_ratio}, {\\fov axis\\_dir},\n          {\\fov cone\\_angle}, {\\fov height}, \\&{\\fov cone}, \\&{\\fov stat})\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1023.tex",
    "content": "\\subsection{Express the octants of a sphere as a surface.}\n\\funclabel{s1023}\n\\begin{minipg1}\n  To express the octants of a sphere as a surface. This can also\n  be used to describe the complete sphere.\n  The sphere/the octants of the sphere will be geometrically exact.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1023(\\begin{minipg3}\n          {\\fov centre},  {\\fov axis},  {\\fov equator},  {\\fov latitude},  {\\fov longitude},  {\\fov sphere},  {\\fov stat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    double \\> {\\fov centre}[\\,];\\\\\n        \\>\\>    double \\> {\\fov axis}[\\,];\\\\\n        \\>\\>    double \\> {\\fov equator}[\\,];\\\\\n        \\>\\>    int    \\> {\\fov latitude};\\\\\n        \\>\\>    int    \\> {\\fov longitude};\\\\\n        \\>\\>    SISLSurf \\> **{\\fov sphere};\\\\\n        \\>\\>    int    \\> *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov centre}\\> - \\> Centre point of the sphere.\\\\\n        \\>\\>    {\\fov axis}\\> - \\> Axis of the sphere (towards the north pole).\\\\\n        \\>\\>    {\\fov equator}\\> - \\> Vector from centre to start point\n                                      on the equator.\\\\\n        \\>\\>    {\\fov latitude} \\> - \\>\n        \\begin{minipg2}\n          Flag indicating number of\n          octants in north/south direction:\n        \\end{minipg2}\\\\[0.3ex]\n          \\>\\>\\>\\>\\> $= 1$ : Octants in the northern hemisphere.\\\\\n          \\>\\>\\>\\>\\> $= 2$ : Octants in both hemispheres.\\\\\n        \\>\\>    {\\fov longitude} \\> - \\>\n        \\begin{minipg2}\n          Flag indicating number of octants along the equator.\n          This is counted counterclockwise from equator.\n        \\end{minipg2}\\\\[0.3ex]\n          \\>\\>\\>\\>\\> $= 1$ : Octants in 1.\\ quadrant.\\\\\n          \\>\\>\\>\\>\\> $= 2$ : Octants in 1.\\ and 2.\\ quadrant.\\\\\n          \\>\\>\\>\\>\\> $= 3$ : Octants in 1., 2.\\ and 3.\\ quadrant.\\\\\n          \\>\\>\\>\\>\\> $= 4$ : Octants in all quadrants.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov sphere} \\> - \\> The sphere produced.\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    double \\> {\\fov centre}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov axis}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov equator}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\> {\\fov latitude} = 1;\\\\\n        \\>\\>    int    \\> {\\fov longitude} = 2;\\\\\n        \\>\\>    SISLSurf \\> *{\\fov sphere} = NULL;\\\\\n        \\>\\>    int    \\> {\\fov stat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1023(\\begin{minipg4}\n          {\\fov centre},  {\\fov axis},  {\\fov equator},  {\\fov latitude},  {\\fov longitude},  \\&{\\fov sphere},  \\&{\\fov stat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1024.tex",
    "content": "\\subsection{Express the octants of a torus as a surface.}\n\\funclabel{s1024}\n\\begin{minipg1}\n  To express the octants of a torus as a surface. This can also be used\n  to describe the complete torus.\n  The torus/the octants of the torus will be geometrically exact.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1024(\\begin{minipg3}\n          {\\fov centre}, {\\fov axis}, {\\fov equator}, {\\fov minor\\_radius}, {\\fov start\\_minor}, {\\fov end\\_minor},\n          {\\fov numb\\_major}, {\\fov torus}, {\\fov stat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    double \\> {\\fov centre}[\\,];\\\\\n        \\>\\>    double \\> {\\fov axis}[\\,];\\\\\n        \\>\\>    double \\> {\\fov equator}[\\,];\\\\\n        \\>\\>    double \\> {\\fov minor\\_radius};\\\\\n        \\>\\>    int    \\> {\\fov start\\_minor};\\\\\n        \\>\\>    int    \\> {\\fov end\\_minor};\\\\\n        \\>\\>    int    \\> {\\fov numb\\_major};\\\\\n        \\>\\>    SISLSurf \\> **{\\fov torus};\\\\\n        \\>\\>    int    \\> *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov centre} \\> - \\> Centre point of the torus.\\\\\n        \\>\\>    {\\fov axis}   \\> - \\> Normal to the torus plane.\\\\\n        \\>\\>    {\\fov equator}\\> - \\> \\begin{minipg2}\n                                        Vector from centre to start point\n                                        on the major circle.\n                                      \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov minor\\_radius} \\> - \\> Radius of the minor circle.\\\\\n        \\>\\>    {\\fov start\\_minor}  \\> - \\> \\begin{minipg2}\n                                               Start quadrant on the\n                                               minor circle (1,2,3 or 4).\n                                               This is counted clockwise\n                                               from the extremum in the\n                                               direction of axis.\n                                             \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov end\\_minor}    \\> - \\> \\begin{minipg2}\n                                               End quadrant on the minor\n                                               circle (1,2,3 or 4). This\n                                               is counted clockwise from\n                                               the extremum in the\n                                               direction of axis.\n                                             \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numb\\_major}   \\> - \\> \\begin{minipg2}\n                                               Number of quadrants on\n                                               the major circle (1,2,3\n                                               or 4). This is counted\n                                               counterclockwise from\n                                               equator.\n                                             \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov torus} \\> - \\> Pointer to the torus produced.\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : Warning.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Ok.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    double \\> {\\fov centre}[3]; \\,/* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov axis}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov equator}[3]; \\,/* Must be defined. Length gives major radius */\\\\\n        \\>\\>    double \\> {\\fov minor\\_radius}; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\> {\\fov start\\_minor} = 1;\\\\\n        \\>\\>    int    \\> {\\fov end\\_minor} = 4;  /* start\\_minor and end\\_minor defines full circle */\\\\\n        \\>\\>    int    \\> {\\fov numb\\_major} = 2;\\\\\n        \\>\\>    SISLSurf \\> *{\\fov torus} = NULL;\\\\\n        \\>\\>    int    \\> {\\fov stat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1024(\\begin{minipg4}\n          {\\fov centre}, {\\fov axis}, {\\fov equator}, {\\fov minor\\_radius}, {\\fov start\\_minor}, {\\fov end\\_minor},\n          {\\fov numb\\_major}, \\&{\\fov torus}, \\&{\\fov stat})\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1025.tex",
    "content": "\\subsection{Insert a given set of knots, in each parameter direction, into the description of a surface.}\n\\funclabel{s1025}\n\\begin{minipg1}\n  Insert a given set of knots in each parameter direction\n  into the description of a surface.\\\\\n  NOTE       : When the surface is periodic in one direction, the input\n               parameter values in this direction\n               must lie in the half-open interval $[et[kk-1], et[kn)$, the function\n               will automatically update the extra knots and\n               coeffisients.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1025(\\begin{minipg3}\n          {\\fov ps},  {\\fov epar1},  {\\fov inpar1},  {\\fov epar2},  {\\fov inpar2},  {\\fov rsnew},  {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf \\> *{\\fov ps};\\\\\n        \\>\\>    double   \\> {\\fov epar1}[\\,];\\\\\n        \\>\\>    int      \\> {\\fov inpar1};\\\\\n        \\>\\>    double   \\> {\\fov epar2}[\\,];\\\\\n        \\>\\>    int      \\> {\\fov inpar2};\\\\\n        \\>\\>    SISLSurf \\> **{\\fov rsnew};\\\\\n        \\>\\>    int      \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov ps}\\> - \\>  \\begin{minipg2}\n                     Surface to be refined.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov epar1}\\> - \\>  \\begin{minipg2}\n                     Knots to insert in first parameter direction.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov inpar1}\\> - \\>  \\begin{minipg2}\n                     Number of new knots in first parameter direction.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov epar2}\\> - \\>  \\begin{minipg2}\n                     Knots to insert in second parameter direction.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov inpar2}\\> - \\>  \\begin{minipg2}\n                     Number of new knots in second parameter direction.\n                               \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rsnew}\\> - \\>  \\begin{minipg2}\n                     The new, refined surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>      $> 0$ : \\>      Warning.\\\\\n                \\>\\>\\>\\>\\>      $= 0$ : \\>      Ok.\\\\\n                \\>\\>\\>\\>\\>      $< 0$ : \\>      Error.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf \\> *{\\fov ps}; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> {\\fov epar1}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    int      \\> {\\fov inpar1} = 3;\\\\\n        \\>\\>    double   \\> {\\fov epar2}[4]; \\, /* Must be defined */\\\\\n        \\>\\>    int      \\> {\\fov inpar2} = 4;\\\\\n        \\>\\>    SISLSurf \\> *{\\fov rsnew} = NULL;\\\\\n        \\>\\>    int      \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1025(\\begin{minipg4}\n          {\\fov ps},  {\\fov epar1},  {\\fov inpar1},  {\\fov epar2},  {\\fov inpar2},  \\&{\\fov rsnew},  \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1221.tex",
    "content": "\\subsection{Compute the position and the right-hand derivatives of a\ncurve at a given parameter value.}\n\\funclabel{s1221}\n\\begin{minipg1}\n  To compute the positione and the first derivatives of a curve at\n  a given parameter value.\n  Evaluation from the right hand side.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1221(\\begin{minipg3}\n        {\\fov curve}, {\\fov der}, {\\fov parvalue}, {\\fov leftknot},\n        {\\fov derive}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    int     \\>      {\\fov der};\\\\\n                \\>\\>    double  \\>      {\\fov parvalue};\\\\\n                \\>\\>    int     \\>      *{\\fov leftknot};\\\\\n                \\>\\>    double  \\>      {\\fov derive}[\\,];\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> \\begin{minipg2}\n                                Pointer to the curve for which position and\n                                derivatives are to be computed.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov der}      \\> - \\> The number (order) of derivatives to compute.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Compute position.\\\\\n                \\>\\>\\>\\>\\>              $= 1$   : Compute position and derivative.\\\\\n                \\>\\>\\>\\>\\>              etc.\\\\\n        \\>\\>    {\\fov parvalue}\\> - \\>  \\begin{minipg2}\n                                The parameter value at which to compute position\n                                and derivatives.\n                                \\end{minipg2}\\\\[0.3ex]\n\\\\\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov leftknot}\\> - \\>  \\begin{minipg2}\n                                Pointer to the interval in the knot\n                                vector where {\\fov parvalue}\n                                is located. If $et[\\,]$ is the knot vector, the relation:\\\\\n                                \\[ et[leftknot] \\leq parvalue < et[leftknot+1] \\]\n                                should hold. (If $parvalue\\geq et[in]$)\n                                then {\\fov leftknot} should be\n                                ``in-1''. Here ``in'' is the number of coefficients.)\n                                If leftknot does not have the right value when entering\n                                the routine, its value will be changed to the value\n                                satisfying the above condition.\n                                \\end{minipg2}\\\\\n\\newpagetabs\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov derive}   \\> - \\> \\begin{minipg2}\n                                        Double array of dimension $(der+1)\\times dim$\n                                        containing the position and derivative vectors.\n                                        ({\\fov dim} is\n                                         the dimension of the Euclidean\n                                        space in which the curve lies.) These vectors are\n                                        stored in the following order: first the dim\n                                        components of the position vector, then the dim\n                                        components of the tangent vector, then the dim\n                                        components of the second derivative vector, and so\n                                        on. (The C declaration of derive as a two dimensional\n                                        array would therefore be\n                                        $derive[der+1][dim]$.)\n\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov der} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov parvalue}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov leftknot} = 0; /* Define initially as zero. For consequtive evaluations \\\\\n                \\>\\>\\>\\>\\>\\> leave leftknot as returned from s1221 */\\\\\n                \\>\\>    double  \\>      {\\fov derive}[12]; /* Curve dimension times (der+1) */\\\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1221(\\begin{minipg4}\n                {\\fov curve}, {\\fov der}, {\\fov parvalue}, \\&{\\fov leftknot},\n                {\\fov derive}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1225.tex",
    "content": "\\subsection{Evaluate position, first derivative, curvature and radius of curvature of a curve at a given parameter value, from the left hand side.}\n\\funclabel{s1225}\n\\begin{minipg1}\nEvaluate position, derivatives, curvature and radius of\n               curvature of a curve at a given parameter value, from the\n               left hand side.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1225(\\begin{minipg3}\n            {\\fov curve}, {\\fov der}, {\\fov parvalue}, {\\fov leftknot}, {\\fov derive}, {\\fov curvature},\n\t   radius\\_of\\_{\\fov curvature}, {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLCurve    \\>  *{\\fov curve};\\\\\n                \\>\\>    int    \\>  {\\fov der};\\\\\n                \\>\\>    double \\> parvalue;\\\\\n                \\>\\>    int    \\>  *{\\fov leftknot};\\\\\n                \\>\\>    double \\> derive[\\,];\\\\\n                \\>\\>    double \\> curvature[\\,];\\\\\n                \\>\\>    double \\> *{\\fov radius}\\_of\\_curvature;\\\\\n                \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}\\> - \\>  \\begin{minipg2}\n                     Pointer to the curve for which position\n                       and derivatives are to be computed.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov der}\\> - \\> The number of derivatives to compute. \\\\\n\t            \\>\\>\\>\\>\\>          $ < 0$ : Error. \\\\\n\t\t    \\>\\>\\>\\>\\>          $ = 0$ : Compute position.\\\\\n\t\t    \\>\\>\\>\\>\\>          $ = 1$ : Compute position and first derivative.\\\\\n\t\t    \\>\\>\\>\\>\\>          etc. \\\\\n        \\>\\>    {\\fov parvalue}\\> - \\>  \\begin{minipg2}\n                     The parameter value at which to compute\n                       position and derivatives.\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov leftknot}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector\n                        where ax is located. If et is the knot vector,\n                        the relation\n                          $$et[ileft] < parvalue <= et[ileft+1]$$\n                        should hold. (If parvalue = et[ik-1] then ileft\n                        should be ik-1. Here in is the number of B-spline\n                        coefficients.)\n                        If ileft does not have the right value upon\n                        entry to the routine, its value will be changed\n                        to the value satisfying the above condition.\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov derive}\\> - \\>  \\begin{minipg2}\n                     Double array of dimension $[(ider+1)*idim]$\n                       containing the position and derivative vectors.\n                       (idim is the number of components of each B-spline\n                       coefficient, i.e. the dimension of the Euclidean\n                       space in which the curve lies.)\n                       These vectors are stored in the following order:\n                       First the idim components of the position vector,\n                       then the idim components of the tangent vector,\n                       then the idim components of the second derivative\n                       vector, and so on.\n                       (The C declaration of eder as a two dimensional array\n                       would therefore be eder[ider+1,idim].)\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov curvature}\\> - \\>  \\begin{minipg2}\n                     Array of dimension idim\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov radius}\\> - \\>  \\begin{minipg2}\n                    1, indicates\n                       that the radius of curvature is infinit.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat}\\> - \\> Status messages \\\\\n                    \\>\\>\\>\\>\\>          $ > 0$      : Warning. \\\\\n                    \\>\\>\\>\\>\\>          $ = 0$      : Ok. \\\\\n                    \\>\\>\\>\\>\\>          $ < 0$      : Error. \\\\\n\t\t\t\t\t \n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLCurve    \\>  *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov der} = 1;\\\\\n                \\>\\>    double \\> parvalue; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov leftknot} = 0; /* Define initially as zero. For consequtive evaluations \\\\\n                \\>\\>\\>\\>\\>\\> leave leftknot as returned from s1225 */\\\\\n                \\>\\>    double \\> derive[6]; /* Curve dimension times (der + 1) */\\\\\n                \\>\\>    double \\> curvature[3]; /* Curve dimension */\\\\\n                \\>\\>    double \\> {\\fov radius}\\_of\\_curvature = 0;\\\\\n                \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1225(\\begin{minipg4}\n            {\\fov curve}, {\\fov der}, {\\fov parvalue}, {\\fov leftknot}, {\\fov derive}, {\\fov curvature},\n\t   \\&radius\\_of\\_{\\fov curvature}, \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1226.tex",
    "content": "\\subsection{Evaluate position, first derivative, curvature and radius of\n               curvature of a curve at a given parameter value, from the\n               right hand side.}\n\\funclabel{s1226}\n\\begin{minipg1}\nEvaluate position, derivatives, curvature and radius of\n               curvature of a curve at a given parameter value, from the\n               right hand side.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1226(\\begin{minipg3}\n            {\\fov curve}, {\\fov der}, {\\fov parvalue}, {\\fov leftknot}, {\\fov derive}, {\\fov curvature},\n\t   radius\\_of\\_{\\fov curvature}, {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLCurve    \\>  *{\\fov curve};\\\\\n                \\>\\>    int    \\>  {\\fov der};\\\\\n                \\>\\>    double \\> parvalue;\\\\\n                \\>\\>    int    \\>  *{\\fov leftknot};\\\\\n                \\>\\>    double \\> derive[\\,];\\\\\n                \\>\\>    double \\> curvature[\\,];\\\\\n                \\>\\>    double \\>*{\\fov radius}\\_of\\_curvature;\\\\\n                \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}\\> - \\>  \\begin{minipg2}\n                     Pointer to the curve for which position\n                       and derivatives are to be computed.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov der}\\> - \\> The number of derivatives to compute.\\\\\n\t            \\>\\>\\>\\>\\>       $< 0$ : Error.\\\\\n\t\t    \\>\\>\\>\\>\\>       $= 0$ : Compute position.\\\\\n\t\t    \\>\\>\\>\\>\\>       $= 1$ : Compute position and first derivative.\\\\\n\t\t    \\>\\>\\>\\>\\>       etc.\\\\\n        \\>\\>    {\\fov parvalue}\\> - \\>  \\begin{minipg2}\n                     The parameter value at which to compute\n                       position and derivatives.\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov leftknot}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector\n                        where ax is located. If et is the knot vector,\n                        the relation\n                          $$et[ileft] < parvalue <= et[ileft+1]$$\n                        should hold. (If parvalue = et[ik-1] then ileft\n                        should be ik-1. Here in is the number of B-spline\n                        coefficients.)\n                        If ileft does not have the right value upon\n                        entry to the routine, its value will be changed\n                        to the value satisfying the above condition.\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov derive}\\> - \\>  \\begin{minipg2}\n                     Double array of dimension [(ider+1)*idim]\n                       containing the position and derivative vectors.\n                       (idim is the number of components of each B-spline\n                       coefficient, i.e. the dimension of the Euclidean\n                       space in which the curve lies.)\n                       These vectors are stored in the following order:\n                       First the idim components of the position vector,\n                       then the idim components of the tangent vector,\n                       then the idim components of the second derivative\n                       vector, and so on.\n                       (The C declaration of eder as a two dimensional array\n                       would therefore be eder[ider+1,idim].)\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov curvature}\\> - \\>  \\begin{minipg2}\n                     Array of dimension idim\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov radius}\\> - \\>  \\begin{minipg2}\n                    1, indicates\n                       that the radius of curvature is infinit.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat}\\> - \\> Status messages\\\\ \n                         \\>\\>\\>\\>\\>      $> 0$      : Warning.\\\\\n                         \\>\\>\\>\\>\\>      $= 0$      : Ok.\\\\\n                         \\>\\>\\>\\>\\>      $< 0$      : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLCurve    \\>  *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov der} = 1;\\\\\n                \\>\\>    double \\> parvalue; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov leftknot} = 0; /* Define initially as zero. For consequtive evaluations \\\\\n                \\>\\>\\>\\>\\>\\> leave leftknot as returned from s1226 */\\\\\n                \\>\\>    double \\>derive[6]; /* Geometry space dimension times (der + 1) */\\\\\n                \\>\\>    double \\>curvature[3]; /* Geometry space dimension */\\\\\n                \\>\\>    double \\> {\\fov radius}\\_of\\_curvature = 0;\\\\\n                \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1226(\\begin{minipg4}\n            {\\fov curve}, {\\fov der}, {\\fov parvalue}, {\\fov leftknot}, {\\fov derive}, {\\fov curvature},\n\t   \\&radius\\_of\\_{\\fov curvature}, \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1227.tex",
    "content": "\\subsection{Compute the position and the left-hand derivatives of a\ncurve at a given parameter value.}\n\\funclabel{s1227}\n\\begin{minipg1}\n  To compute the position and the first derivatives of the curve at a\n  given parameter value\n  Evaluation from the left hand side.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1227(\\begin{minipg3}\n        {\\fov curve}, {\\fov der}, {\\fov parvalue}, {\\fov leftknot},\n        {\\fov derive}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    int     \\>      {\\fov der};\\\\\n                \\>\\>    double  \\>      {\\fov parvalue};\\\\\n                \\>\\>    int     \\>      *{\\fov leftknot};\\\\\n                \\>\\>    double  \\>      {\\fov derive}[\\,];\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> \\begin{minipg2}\n                                Pointer to the curve for which position and\n                                derivatives are to be computed.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov der}      \\> - \\> The number of derivatives to compute.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Compute position.\\\\\n                \\>\\>\\>\\>\\>              $= 1$   : Compute position and derivative.\\\\\n                \\>\\>\\>\\>\\>              etc.\\\\\n        \\>\\>    {\\fov parvalue}\\> - \\>  \\begin{minipg2}\n                                The parameter value at which to compute position\n                                and derivatives.\n                                \\end{minipg2}\\\\[0.3ex]\n\\\\\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov leftknot}\\> - \\>  \\begin{minipg2}\n                                Pointer to the interval in the knot\n                                vector where {\\fov parvalue}\n                                is located. If $et[\\,]$ is the knot vector, the relation:\\\\\n                                \\[ et[\\mbox{leftknot}] < parvalue \\leq et[\\mbox{leftknot}+1] \\]\n                                should hold. (If $parvalue\\leq\n                                et[ik-1]$) then {\\fov leftknot} should be\n                                ``ik-1''. Here ``ik'' is the order of the curve.)\n                                If leftknot does not have the right value when entering\n                                the routine, its value will be changed to the value\n                                satisfying the above condition.\n                                \\end{minipg2}\\\\[0.3ex]\n\\\\\n\\newpagetabs\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov derive}   \\> - \\> \\begin{minipg2}\n                                        Double array of dimension $(der+1)\\times dim$\n                                        containing the position and derivative vectors.\n                                        ({\\fov dim} is\n                                         the dimension of the Euclidean\n                                        space in which the curve lies.) These vectors are\n                                        stored in the following order: first the\n                                        components of the position vector, then the dim\n                                        components of the tangent vector, then the dim\n                                        components of the second derivative vector, and so\n                                        on. (The C declaration of derive as a two dimensional\n                                        array would therefore be\n                                        $derive[der+1][dim]$.)\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov der} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov parvalue}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov leftknot} = 0; /* Define initially as zero. For consequtive evaluations \\\\\n                \\>\\>\\>\\>\\>\\> leave leftknot as returned from s1227 */\\\\\n                \\>\\>    double  \\>      {\\fov derive}[12]; /* Curve dimension times (der+1) */\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1227(\\begin{minipg4}\n                {\\fov curve}, {\\fov der}, {\\fov parvalue}, \\&{\\fov leftknot},\n                {\\fov derive}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1231.tex",
    "content": "\\subsection{Subdivide a NURBS curve at a specified internal parameter value.}\n\\funclabel{s1231}\n\\begin{minipg1}\nSubdivide a NURBS curve at a given {\\bf internal} parameter-value. If the subdivision parameter is at an end of the parameter interval, an error message is given.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1231(\\begin{minipg3}\n\t{\\fov curve}, {\\fov parval}, {\\fov newcurve1}, {\\fov newcurve2}, {\\fov stat})\n\t\t\\end{minipg3}\\\\[0.3ex]\n\t\t\\>\\>\tSISLCurve \t\\>\t*{\\fov curve};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov parval};\\\\\n\t\t\\>\\>\tSISLCurve \t\\>\t**{\\fov newcurve1};\\\\\n\t\t\\>\\>\tSISLCurve \t\\>\t**{\\fov newcurve2};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov curve}\t\\> - \\>\tSISLCurve to subdivide.\\\\\n\t\\>\\>\t{\\fov parval}\t\\> - \\>\t\\begin{minipg2}\n\t\t\t\tParameter value at which to subdivide.\n\t\t\t\t\\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov newcurve1}\\> - \\>\\begin{minipg2}\n\t\t\t\tFirst part of the subdivided curve.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov newcurve2}\\> - \\>\\begin{minipg2}\n\t\t\t\tSecond part of the subdivided curve. \n\t\t\t\t\\end{minipg2}\\\\[0.3ex]\n\t\\>\\>\t{\\fov stat}\t\\> - \\>\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n\t\t\\>\\>\tSISLCurve \t\\>\t*{\\fov curve};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov parval};\\\\\n\t\t\\>\\>\tSISLCurve \t\\>\t*{\\fov newcurve1};\\\\\n\t\t\\>\\>\tSISLCurve \t\\>\t*{\\fov newcurve2};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov stat};\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1231(\\begin{minipg4}\n\t\t{\\fov curve}, {\\fov parval}, \\&{\\fov newcurve1}, \\&{\\fov newcurve2}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1233.tex",
    "content": "\\section{Extend a B-spline Curve.}\n\\funclabel{s1233}\n\\begin{minipg1}\n  To extend a B-spline curve (i.e.\\ NOT rationals) at the start and/or\n  the end of the curve by continuing the polynomial behaviour of the\n  curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1233(\\begin{minipg3}\n          {\\fov pc}, {\\fov afak1}, {\\fov afak2}, {\\fov rc}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLCurve \\>  *{\\fov pc};\\\\\n        \\>\\>    double    \\>  {\\fov afak1};\\\\\n        \\>\\>    double    \\>  {\\fov afak2};\\\\\n        \\>\\>    SISLCurve \\>  **{\\fov rc};\\\\\n        \\>\\>    int       \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov pc}    \\> - \\>\n        \\begin{minipg2}\n          Pointer to the B-spline curve to be extended.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov afak1} \\> - \\>\n        \\begin{minipg2}\n          How much the curve is to be stretched at the\n          start of the curve. The length of the stretched\n          curve will be equal to $(1+afak1)$ times the\n          input curve. $afak1\\geq 0$ and will be set to 0 if\n          negative.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov afak2} \\> - \\>\n        \\begin{minipg2}\n          How much the curve is to be stretched at the\n          end of the curve. The length of the stretched\n          curve will be equal to $(1+afak2)$ times the\n          input curve. $afak2\\geq 0$ and will be set to 0 if\n          negative.\n        \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rc}    \\> - \\> Pointer to the extended B-spline curve.\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $= 1$ : \\begin{minipg5}\n                                     Stretching factors less than 0\n                                     -- read: adjusted factor(s)\n                                     have been used.\n                                   \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve \\>  *{\\fov pc}; \\, /* Must be defined */\\\\\n        \\>\\>    double    \\>  {\\fov afak1} = 0.1;\\\\\n        \\>\\>    double    \\>  {\\fov afak2} = 0.1;\\\\\n        \\>\\>    SISLCurve \\>  *{\\fov rc} = NULL;\\\\\n        \\>\\>    int       \\>  {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1233(\\begin{minipg4}\n          {\\fov pc}, {\\fov afak1}, {\\fov afak2}, \\&{\\fov rc}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1237.tex",
    "content": "\\subsection{Draw constant parameter lines in a surface\nusing piecewise straight lines.}\n\\funclabel{s1237}\n\\begin{minipg1}\n  Draw constant parameter lines in a surface.\n  The distance between the surface and the\n  straight lines is less than a tolerance epsge. Also see NOTE!\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1237(\\begin{minipg3}\n                                {\\fov surf}, {\\fov numline1}, {\\fov numline2}, {\\fov epsge}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    int     \\>      {\\fov numline1};\\\\\n                \\>\\>    int     \\>      {\\fov numline2};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov numline1}\\> - \\>  \\begin{minipg2}\n                                Number of constant parameter lines to be drawn in the first\n                                parameter direction.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov numline2}\\> - \\>  \\begin{minipg2}\n                                Number of constant parameter lines to be drawn in the\n                                second parameter direction.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                The maximal distance allowed between the drawn curves\n                                and the surface.\n                                \\end{minipg2} \\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nNOTE\\\\\n\\>\\begin{minipg6}\nThis function calls s6drawseq() which\nis device dependent. Before using the function make sure\nyou have a version of s6drawseq()\ninterfaced to your graphic package.\nMore about s6drawseq() on page~\\pageref{s6drawseq}.\n\\end{minipg6}\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    int     \\>      {\\fov numline1};\\\\\n                \\>\\>    int     \\>      {\\fov numline2};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      {\\fov stat};\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1237(\\begin{minipg4}\n                        {\\fov surf}, {\\fov numline1}, {\\fov numline2}, {\\fov epsge}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1238.tex",
    "content": "\\subsection{Draw constant parameter lines in a\nsurface bounded by a closed curve in the parameter plane of the surface.}\n\\funclabel{s1238}\n\\begin{minipg1}\n  Draw constant parameter lines in a surface. The lines are limited by a closed\n  curve lying in the parameter plane of the surface, i.e.\\ a 2D curve.\n  All lines are drawn as piecewise straight lines. Also see NOTE!\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1238(\\begin{minipg3}\n                {\\fov surf}, {\\fov curve}, {\\fov numline1}, {\\fov numline2}, {\\fov epsco}, {\\fov epsge}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    int     \\>      {\\fov numline1};\\\\\n                \\>\\>    int     \\>      {\\fov numline2};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov curve}\\> - \\>     \\begin{minipg2}\n                                The 2D curve, in the parameter plane of\n                                the surface, bounding the part of the\n                                surface that is to be drawn.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numline1}\\> - \\>  \\begin{minipg2}\n                                Number of constant parameter lines to be drawn in the first\n                                parameter direction.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov numline2}\\> - \\>  \\begin{minipg2}\n                                Number of constant parameter lines to be drawn in the\n                                second parameter direction.\n                                \\end{minipg2} \\\\[0.3ex]\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Not in use!\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                The maximal distance allowed between the drawn curves\n                                and the surface.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov sta}t     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nNOTE\\\\\n\\>\\begin{minipg6}\nThis function calls s6drawseq() which\nis device dependent. Before using the function make sure\nyou have a version of s6drawseq()\ninterfaced to your graphic package.\nMore about s6drawseq() on page~\\pageref{s6drawseq}.\n\\end{minipg6}\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    int     \\>      {\\fov numline1};\\\\\n                \\>\\>    int     \\>      {\\fov numline2};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      {\\fov stat};\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1238(\\begin{minipg4}\n                        {\\fov surf}, {\\fov curve}, {\\fov numline1}, {\\fov numline2}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1240.tex",
    "content": "\\section{Compute the Length of a Curve}\n\\funclabel{s1240}\n\\begin{minipg1}\n  Compute the length of a curve. The length calculated will not deviate\n  more than {\\fov epsge} divided by the calculated length, from the real\n  length of the curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1240(\\begin{minipg3}\n        {\\fov curve}, {\\fov epsge}, {\\fov length}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      *{\\fov length};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> The curve.\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> Geometry resolution.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov length}   \\> - \\> The length of the curve.\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : Warning.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Ok.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nNOTE\\\\\n\\>\\begin{minipg6}\n        The algorithm is based on recursive\n        subdivision and will thus for small values\n        of {\\fov epsge} require long computation time.\n\\end{minipg6} \\\\ \\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 0.001;\\\\\n                \\>\\>    double  \\>      {\\fov length};\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1240(\\begin{minipg4}\n                {\\fov curve}, {\\fov epsge}, \\&{\\fov length}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1241.tex",
    "content": "\\subsection{Calculate the area between a 2D curve and a 2D point.}\n\\funclabel{s1241}\n\\begin{minipg1}\nTo calculate the area between a 2D curve and a 2D point.\n               When the curve is rotating counter-clockwise around the\n               point, the area contribution is positive.\n               When the curve is rotating clockwise around the point,\n               the area contribution is negative.\n               If the curve is closed or periodic, the area calculated\n               is independent of where the point is situated.\n               The area is calculated exactly for B-spline curves, for\n               NURBS the result is an approximation.\n               This routine will only perform if the order of the curve is\n               less than 7 (can easily be extended).\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1241(\\begin{minipg3}\n            {\\fov pcurve},  {\\fov point},  {\\fov dim},  {\\fov epsge},  {\\fov area},  {\\fov stat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLCurve    \\>  *{\\fov pcurve};\\\\\n                \\>\\>    double    \\>  {\\fov point}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov dim};\\\\\n                \\>\\>    double    \\>  {\\fov epsge};\\\\\n                \\>\\>    double    \\>  *{\\fov area};\\\\\n                \\>\\>    int    \\>  *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov pcurve}\\> - \\>  \\begin{minipg2}\n                     The 2D curve.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov point}\\> - \\>  \\begin{minipg2}\n                     The reference point.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}\\> - \\>  \\begin{minipg2}\n                     Dimension of geometry (must be 2).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>  \\begin{minipg2}\n                     Absolute geometrical tolerance.\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov area}\\> - \\>  \\begin{minipg2}\n                     Calculated area.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : Warning.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Ok.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLCurve    \\>  *{\\fov pcurve}; \\, /* Must be defined */\\\\\n                \\>\\>    double    \\>  {\\fov point}[2]; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov dim} = 2; /* Must be equal to 2 */\\\\\n                \\>\\>    double    \\>  {\\fov epsge} = 0.001;\\\\\n                \\>\\>    double    \\>  {\\fov area};\\\\\n                \\>\\>    int    \\>  {\\fov stat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1241(\\begin{minipg4}\n            {\\fov pcurve},  {\\fov point},  {\\fov dim},  {\\fov epsge},  \\&{\\fov area},  \\&{\\fov stat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1242.tex",
    "content": "\\subsection{Calculate area, moment of inertia and weightpoint of area limited by 2-D curve.}\n\\funclabel{s1242}\n\\begin{minipg1}\nCompute the area surrounded by a 2D-curve and the straight lines from a reference\npoint to the end points of the curve. The area might have a negative value\ndependent on the direction of the curve relative to the reference point. When\nused on a closed curve, the routine gives as output the area surrounded by the curve.\nThe difference between the area calculated and the real area will be less than\n(aepsco/the area calculated). The weight point of the surface and the rotational\nmomentum in accordance with a given axis are also computed.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1242(\\begin{minipg3}\n        {\\fov curve}, {\\fov point}, {\\fov dim}, {\\fov epsco}, {\\fov weight}, {\\fov area}, {\\fov moment}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov point}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov weight}[\\,];\\\\\n                \\>\\>    double  \\>      *{\\fov area};\\\\\n                \\>\\>    double  \\>      *{\\fov moment};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> B-spline curve.\\\\\n        \\>\\>    {\\fov point}    \\> - \\>\\begin{minipg2}\n                                Reference point in the area computation / axis vertical\n                                to a plane (given as point in 2D).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}\\> - \\>\\begin{minipg2}\n                                Dimension of the space in which epoint lies. The\n                                dimension is supposed to be equal to 2.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov epsco} \\> - \\>\\begin{minipg2}\n                                Resolution.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov weight}   \\> - \\>\\begin{minipg2}\n                                Weight point.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov area}     \\> - \\>\\begin{minipg2}\n                                The area calculated.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov moment}   \\> - \\>\\begin{minipg2}\n                                Rotational momentum.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nNOTE\\\\\n\\>\\begin{minipg6}\n        The algorithm is based on recursive\n        subdivision and will thus for small values\n        of epsco require long computation time.\n\\end{minipg6} \\\\ \\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov point[2]};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov weight[2]};\\\\\n                \\>\\>    double  \\>      {\\fov area};\\\\\n                \\>\\>    double  \\>      {\\fov moment};\\\\\n                \\>\\>    int     \\>      {\\fov stat};\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1242(\\begin{minipg4}\n                {\\fov curve}, {\\fov point}, {\\fov dim}, {\\fov epsco}, {\\fov weight}, \\&{\\fov area}, \\&{\\fov moment}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1243.tex",
    "content": "\\subsection{Calculate the weight point and rotational momentum of\n               an area between a 2D curve and a 2D point.}\n\\funclabel{s1243}\n\\begin{minipg1}\nTo calculate the weight point and rotational momentum of\n               an area between a 2D curve and a 2D point. The area is\n               also calculated.\n               When the curve is rotating counter-clockwise around the\n               point, the area contribution is positive.\n               When the curve is rotating clockwise around the point,\n               the area contribution is negative.\n               OBSERVE: FOR CALCULATION OF AREA ONLY, USE s1241().\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1243(\\begin{minipg3}\n            {\\fov pcurve},  {\\fov point},  {\\fov dim},  {\\fov epsge},  {\\fov weight},  {\\fov area},  {\\fov moment},  {\\fov stat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLCurve    \\>  *{\\fov pcurve};\\\\\n                \\>\\>    double    \\>  {\\fov point}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov dim};\\\\\n                \\>\\>    double    \\>  {\\fov epsge};\\\\\n                \\>\\>    double    \\>  {\\fov weight}[\\,];\\\\\n                \\>\\>    double    \\>  *{\\fov area};\\\\\n                \\>\\>    double    \\>  *{\\fov moment};\\\\\n                \\>\\>    int    \\>  *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov pcurve}\\> - \\>  \\begin{minipg2}\n                     The 2D curve.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov point}\\> - \\>  \\begin{minipg2}\n                     The reference point.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}\\> - \\>  \\begin{minipg2}\n                     Dimension of geometry (must be 2).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>  \\begin{minipg2}\n                     Absolute geometrical tolerance.\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov weight}\\> - \\>  \\begin{minipg2}\n                     Weight point.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov area}\\> - \\>  \\begin{minipg2}\n                     Area.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov moment}\\> - \\>  \\begin{minipg2}\n                     Rotational momentum.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLCurve    \\>  *{\\fov pcurve}; \\, /* Must be defined */\\\\\n                \\>\\>    double    \\>  {\\fov point}[2]; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov dim} = 2; /* Dimension 2 is required */\\\\\n                \\>\\>    double    \\>  {\\fov epsge} = 0.01;\\\\\n                \\>\\>    double    \\>  {\\fov weight}[2];\\\\\n                \\>\\>    double    \\>  {\\fov area} = 0.0;\\\\\n                \\>\\>    double    \\>  {\\fov moment} = 0.0;\\\\\n                \\>\\>    int    \\>  {\\fov stat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1243(\\begin{minipg4}\n            {\\fov pcurve},  {\\fov point},  {\\fov dim},  {\\fov epsge},  {\\fov weight},  \\&{\\fov area},  \\&{\\fov moment},  \\&{\\fov stat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1302.tex",
    "content": "\\subsection{Compute a rotational swept surface.}\n\\funclabel{s1302}\n\\begin{minipg1}\n  To create a rotational swept surface by rotating a curve\n  a given angle around the axis defined by {\\fov point}[\\,] and\n  {\\fov axis}[\\,].\n  The maximal deviation allowed between the true rotational surface and the\n  generated surface, is {\\fov epsge}.\n  If {\\fov epsge} is set to 0, a NURBS surface is generated and if\n  $epsge >0$, a B-spline surface is generated.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1302(\\begin{minipg3}\n                        {\\fov curve}, {\\fov epsge}, {\\fov angle}, {\\fov point}, {\\fov axis}, {\\fov surf}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      {\\fov angle};\\\\\n                \\>\\>    double  \\>      {\\fov point}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov axis}[\\,];\\\\\n                \\>\\>    SISLSurf        \\>      **{\\fov surf};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> \\begin{minipg2}\n                                Pointer to the curve that is to be rotated.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> \\begin{minipg2}\n                                Maximal deviation allowed between the true rotational\n                                surface and the generated surface.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov angle}    \\> - \\> \\begin{minipg2}\n                        The rotational angle. The angle is counterclockwise around axis. If the absolute\n                        value of the angle is greater than $2\\pi$ then a rotational surface that is\n                        closed in the rotation direction is made.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov point}    \\> - \\> \\begin{minipg2}\n                                Point on the rotational axis.\n                                \\end{minipg2} \\\\\n        \\>\\>    {\\fov axis}     \\> - \\> \\begin{minipg2}\n                                Direction of rotational axis.\n                                \\end{minipg2} \\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov surf}     \\> - \\> \\begin{minipg2}\n                                        Pointer to the produced surface.\n                                        This will be a NURBS (i.e.\\\n                                        rational) surface if $epsge=0$\n                                        and a \\mbox{B-spline} (i.e.\\\n                                        non-rational) surface if $epsge>0$.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $>0$    : warning\\\\\n                \\>\\>\\>\\>\\>              $=0$    : ok\\\\\n                \\>\\>\\>\\>\\>              $<0$    : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 0.0;\\\\\n                \\>\\>    double  \\>      {\\fov angle}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov point}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov axis}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>    s1302(\\begin{minipg4}\n                        {\\fov curve}, {\\fov epsge}, {\\fov angle}, {\\fov point}, {\\fov axis}, \\&{\\fov surf}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots\\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1303.tex",
    "content": "\\subsection{Approximate a circular arc with a curve.}\n\\funclabel{s1303}\n\\begin{minipg1}\n  To create a curve approximating a circular arc around\n  the axis defined by the centre point, an axis vector,\n  a start point and a rotational angle.\n  The maximal deviation between the true circular arc and the\n  approximation to the arc is controlled by the geometric\n  tolerance (epsge).\n  The output will be represented as a B-spline curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1303(\\begin{minipg3}\n                {\\fov startpt}, {\\fov epsge}, {\\fov angle}, {\\fov centrept}, {\\fov axis}, {\\fov dim},\n                {\\fov curve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    double  \\>      {\\fov startpt}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      {\\fov angle};\\\\\n                \\>\\>    double  \\>      {\\fov centrept}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov axis}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov curve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov startpt}  \\> - \\> Start point of the circular arc\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> \\begin{minipg2}\n                                Maximal deviation allowed between the true\n                                circle and the circle approximation.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov angle}    \\> - \\> \\begin{minipg2}\n                                The rotational angle. Counterclockwise around\n                                axis. If the rotational angle\n                                is outside $<-2\\pi,+2\\pi>$\n                                then a closed curve is produced.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov centrept}\\> - \\>  Point on the axis of the circle.\\\\\n        \\>\\>    {\\fov axis}     \\> - \\> \\begin{minipg2}\n                                Normal vector to plane in which the circle lies.\n                                Used if dim = 3.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                The dimension of the space in which the\n                                circular arc lies (2 or 3).\n                                \\end{minipg2}\\\\[0.3ex]\n\\\\\n\\newpagetabs\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to the B-spline curve.\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    double  \\>      {\\fov startpt}[3]; \\, /* Must be defined */ \\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 0.001;\\\\\n                \\>\\>    double  \\>      {\\fov angle}; \\, \\, /* Must be defined */ \\\\\n                \\>\\>    double  \\>      {\\fov centrept}[3]; \\,/* Must be defined */ \\\\\n                \\>\\>    double  \\>      {\\fov axis}[3]; \\, \\, /* Must be defined */ \\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1303(\\begin{minipg4}\n                        {\\fov startpt}, {\\fov epsge}, {\\fov angle}, {\\fov centrept},\n                        {\\fov axis}, {\\fov dim}, \\&{\\fov curve}, \\&{\\fov stat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1310.tex",
    "content": "\\subsection{March an intersection curve between two spline surfaces.}\n\\funclabel{s1310}\n\\begin{minipg1}\n  To march an intersection curve between two surfaces.\n  The intersection curve is described by guide parameter pairs stored in\n  an intersection curve object.\n  The guide points are expected to be found by s1859() described on\n  page \\pageref{s1859}.\n  The generated geometric curves are represented as B-spline curves.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1310(\\begin{minipg3}\n                        {\\fov surf1}, {\\fov surf2}, {\\fov intcurve}, {\\fov epsge}, {\\fov maxstep}, {\\fov makecurv}, {\\fov graphic}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n\n                \\>\\>    SISLSurf        \\>      *{\\fov surf1};\\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf2};\\\\\n                \\>\\>    SISLIntcurve\\>  *{\\fov intcurve};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      {\\fov maxstep};\\\\\n                \\>\\>    int     \\>      {\\fov makecurv};\\\\\n                \\>\\>    int     \\>      {\\fov graphic};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf1}\\> - \\>     \\begin{minipg2}\n                                Pointer to the first surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov surf2}\\> - \\>     \\begin{minipg2}\n                                Pointer to the second surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2} \\\\\n        \\>\\>    {\\fov maxstep}\\> - \\>   \\begin{minipg2}\n                                Maximum step length. If maxstep$\\leq$0, maxstep is ignored.\n                                maxstep = 0.0 is recommended.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov makecurv}\\> - \\>  \\begin{minipg2}\n                                Indicator specifying if a geometric curve is to be made:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 -     \\>Do not make curves at all\\\\\n                \\>\\>\\>\\>\\>      1 -     \\>Make only a geometric curve.\\\\\n                \\>\\>\\>\\>\\>      2 -     \\>\\begin{minipg5}\n                                        Make geometric curve and curves in the parameter\n                                        planes\n                                        \\end{minipg5} \\\\[0.3ex]\n        \\>\\>    {\\fov graphic}\\> - \\>   \\begin{minipg2}\n                                Indicator specifying if the function\n                                should draw the geometric curve:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 -     \\>Don't draw the curve\\\\\n                \\>\\>\\>\\>\\>      1 -     \\>\\begin{minipg5}\n                                        Draw the geometric curve. This option is\n                                        outdated, if used see NOTE!\n                                        \\end{minipg5} \\\\[0.8ex]\n\\\\ %\\newpagetabs\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                                Pointer to the intersection curve.\n                                As input only\n                                guide points (points in parameter space)\n                                exist. These guide points\n                                are used for guiding the marching.\n                                The routine adds\n                                intersection curve and curves in the parameter\n                                planes to the SISLIntcurve object, according to the value\n                                of makecurv.\n                                \\end{minipg2}\\\\\n\\newpagetabs\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $= 3$ : \\>      \\begin{minipg5}\n                                                        Iteration stopped due to singular\n                                                        point or degenerate surface. A part of an\n                                                        intersection curve may have been\n                                                        traced out. If no curve is traced out,\n                                                        the curve pointers in the SISLIntcurve\n                                                        object point to NULL.\n                                                        \\end{minipg5} \\\\[0.3ex]\n                \\>\\>\\>\\>\\>              $= 0$ : \\>       ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$ : \\>       error\\\\\n\\\\\nNOTE\\\\\n\\>      \\begin{minipg6}\nIf the draw option is used the empty dummy functions s6move() and\ns6line() are called.\nThus if the draw option is used, make sure\nyou have versions of functions s6move() and s6line() interfaced to your graphic package.\n\\end{minipg6}\\\\ \\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf1}; \\, /* Must be defined */\\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf2}; \\, /* Must be defined */\\\\\n                \\>\\>    SISLIntcurve \\> *{\\fov intcurve}; /* The intersection curve instance is defined in s1859 */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-5;\\\\\n                \\>\\>    double  \\>      {\\fov maxstep} = 0.0;\\\\\n                \\>\\>    int     \\>      {\\fov makecurv} = 2;\\\\\n                \\>\\>    int     \\>      {\\fov graphic} = 0;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1310(\\begin{minipg4}\n                {\\fov surf1}, {\\fov surf2}, {\\fov intcurve}, {\\fov epsge}, {\\fov maxstep}, {\\fov makecurv}, {\\fov graphic}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1314.tex",
    "content": "\\subsection{March an intersection curve between a spline surface and a plane.}\n\\funclabel{s1314}\n\\begin{minipg1}\n  To march an intersection curve described by parameter pairs in an intersection\n  curve object, a surface and a plane.\n  The guide points are expected to be found by s1851(), described on\n  page \\pageref{s1851}.\n  The generated geometric curves are represented as B-spline curves.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1314(\\begin{minipg3}\n                {\\fov surf}, {\\fov point}, {\\fov normal}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov maxstep}, {\\fov intcurve}, \\linebreak\n                {\\fov makecurv}, {\\fov graphic}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov point}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov normal}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      {\\fov maxstep};\\\\\n                \\>\\>    SISLIntcurve\\>  *{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      {\\fov makecurv};\\\\\n                \\>\\>    int     \\>      {\\fov graphic};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}     \\> - \\> \\begin{minipg2}\n                                Pointer to the surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov point}    \\> - \\> \\begin{minipg2}\n                                Point in the plane.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov normal}   \\> - \\> \\begin{minipg2}\n                                Normal to the plane.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                Dimension of the space in which the plane lies.\n                                Should be 3.\n                                \\end{minipg2} \\\\[0.8ex]\n        \\>\\>    {\\fov epsco}    \\> - \\> \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov maxstep}  \\> - \\> \\begin{minipg2}\n                                Maximum step length allowed.\n                                If maxstep $\\leq$ epsge maxstep is\n                                neglected. maxstep = 0.0 is recommended.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov makecurv}\\> - \\>  \\begin{minipg2}\n                                Indicator telling if a geometric curve is to be made:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 -     \\>Do not make curves at all.\\\\\n                \\>\\>\\>\\>\\>      1 -     \\>Make only one geometric curve.\\\\\n                \\>\\>\\>\\>\\>      2 -     \\>\\begin{minipg5}\n                                        Make geometric curve and curve in the parameter\n                                        plane.\n                                        \\end{minipg5} \\\\[0.3ex]\n        \\>\\>    {\\fov graphic}\\> - \\>   \\begin{minipg2}\n                                Indicator telling if the function\n                                should draw the curve:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 -     \\>Don't draw the curve.\\\\\n                \\>\\>\\>\\>\\>      1 -     \\>\\begin{minipg5}\n                                        Draw the geometric curve. This option is\n                                        outdated, if used see NOTE!\n                                        \\end{minipg5} \\\\[0.8ex]\n\\newpagetabs\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                                Pointer to the intersection curve.\n                                As input, only\n                                guide points (points in parameter space)\n                                exist. These guide points\n                                are used to guide the marching.\n                                The routine adds\n                                intersection curve and curve in the parameter\n                                plane to the SISLIntcurve object, according to the value\n                                of makecurv.\n                                \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>      $= 3$ : \\>      \\begin{minipg5}\n                                                Iteration stopped due to singular\n                                                point or degenerate surface. A part of an\n                                                intersection curve may have been\n                                                traced out. If no curve is traced out\n                                                the curve pointers in the SISLIntcurve\n                                                object point to NULL.\n                                                \\end{minipg5} \\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 0$   :\\> ok\\\\\n                \\>\\>\\>\\>\\>      $< 0$   :\\> error\\\\\n\\\\\nNOTE\\\\\n\\>      \\begin{minipg6}\nIf the draw option is used the empty dummy functions s6move() and\ns6line() are called.\nThus if the draw option is used, make sure\nyou have versions of functions s6move() and s6line() interfaced to your graphic package.\n\n\\end{minipg6}\\\\\n\\\\ %\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov point}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov normal}[3]; \\,/* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-5;\\\\\n                \\>\\>    double  \\>      {\\fov maxstep} = 0.0;\\\\\n                \\>\\>    SISLIntcurve\\>  *{\\fov intcurve}; /* The intersection curve instance is defined in s1851 */\\\\\n                \\>\\>    int     \\>      {\\fov makecurv} = 2; \\\\\n                \\>\\>    int     \\>      {\\fov graphic} = 0;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1314(\\begin{minipg4}\n                {\\fov surf}, {\\fov point}, {\\fov normal}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov maxstep}, {\\fov intcurve}, \\linebreak\n                {\\fov makecurv}, {\\fov graphic}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1315.tex",
    "content": "\\subsection{March an intersection curve between a spline surface and a sphere.}\n\\funclabel{s1315}\n\\begin{minipg1}\n  To march an intersection curve described by parameter pairs in an intersection\n  curve object, a surface and a sphere.\n  The guide points are expected to be found by s1852(), described on\n  page \\pageref{s1852}.\n  The generated geometric curves are represented as B-spline curves.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1315(\\begin{minipg3}\n                {\\fov surf}, {\\fov centre}, {\\fov radius}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov maxstep}, {\\fov intcurve},\n                makecurv, graphic, stat)\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov centre}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov radius};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      {\\fov maxstep};\\\\\n                \\>\\>    SISLIntcurve\\>  *{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      {\\fov makecurv};\\\\\n                \\>\\>    int     \\>      {\\fov graphic};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}     \\> - \\> \\begin{minipg2}\n                                Pointer to the surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov centre}   \\> - \\> \\begin{minipg2}\n                                Center of the sphere.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov radius}   \\> - \\> \\begin{minipg2}\n                                Radius of sphere\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                Dimension of the space in which the sphere lies.\n                                Should be 3.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epsco}    \\> - \\> \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov maxstep}  \\> - \\> \\begin{minipg2}\n                                Maximum step length allowed.\n                                If maxstep $\\leq$ epsge maxstep is\n                                neglected. maxstep = 0.0 is recommended.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov makecurv}\\> - \\>  \\begin{minipg2}\n                                Indicator specifying if a geometric curve is to be made:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 -     \\>Do not make curves at all.\\\\\n                \\>\\>\\>\\>\\>      1 -     \\>Make only a geometric curve.\\\\\n                \\>\\>\\>\\>\\>      2 -     \\>\\begin{minipg5}\n                                        Make geometric curve and curve in parameter\n                                        plane.\n                                        \\end{minipg5} \\\\[0.3ex]\n        \\>\\>    {\\fov graphic}\\> - \\>   \\begin{minipg2}\n                                Indicator specifying if the function\n                                should draw the curve:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 -     \\>Don't draw the curve.\\\\\n                \\>\\>\\>\\>\\>      1 -     \\>\\begin{minipg5}\n                                        Draw the geometric curve. This option is\n                                        outdated, if used see NOTE!\n                                        \\end{minipg5} \\\\[0.8ex]\n\\newpagetabs\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                                Pointer to the intersection curve.\n                                As input only\n                                guide points (points in parameter space)\n                                exist. These guide points\n                                are used to guide the marching.\n                                The routine adds\n                                intersection curve and curve in the parameter\n                                plane to the SISLIntcurve object according to the value\n                                of makecurv.\n                                \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>      $= 3$ : \\>      \\begin{minipg5}\n                                                Iteration stopped due to singular\n                                                point or degenerate surface. A part of an\n                                                intersection curve may have been\n                                                traced out. If no curve is traced out,\n                                                the curve pointers in the SISLIntcurve\n                                                object point to NULL.\n                                                \\end{minipg5} \\\\[0.3ex]\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nNOTE\\\\\n\\>      \\begin{minipg6}\nIf the draw option is used the empty dummy functions s6move() and\ns6line() are called.\nThus if the draw option is used, make sure\nyou have versions of functions s6move() and s6line() interfaced to your graphic package.\n\\end{minipg6}\\\\\n\\\\ %\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov centre}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov radius}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-5;\\\\\n                \\>\\>    double  \\>      {\\fov maxstep} = 0;\\\\\n                \\>\\>    SISLIntcurve\\>  *{\\fov intcurve}; /* The intersection curve instance is defined in s1852 */\\\\\n                \\>\\>    int     \\>      {\\fov makecurv} = 2;\\\\\n                \\>\\>    int     \\>      {\\fov graphic} = 0;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1315(\\begin{minipg4}\n                {\\fov surf}, {\\fov centre}, {\\fov radius}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov maxstep}, {\\fov intcurve},\n                {\\fov makecurv}, {\\fov graphic}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1316.tex",
    "content": "\\subsection{March an intersection curve between a spline surface and a \\mbox{cylinder}.}\n\\funclabel{s1316}\n\\begin{minipg1}\n  To march an intersection curve described by parameter pairs in an intersection\n  curve object, a surface and a cylinder.\n  The guide points are expected to be found by s1853() described on\n  page \\pageref{s1853}.\n  The generated geometric curves are represented as B-spline curves.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1316(\\begin{minipg3}\n                {\\fov surf}, {\\fov point}, {\\fov cyldir}, {\\fov radius}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov maxstep},\n                {\\fov intcurve}, {\\fov makecurv}, {\\fov graphic}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov point}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov cyldir}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov radius};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      {\\fov maxstep};\\\\\n                \\>\\>    SISLIntcurve\\>  *{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      {\\fov makecurv};\\\\\n                \\>\\>    int     \\>      {\\fov graphic};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov point}\\> - \\>     \\begin{minipg2}\n                                Point on the axis of the cylinder.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov cyldir}\\> - \\>    \\begin{minipg2}\n                                The direction vector of the axis of the cylinder.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov radius}\\> - \\>    \\begin{minipg2}\n                                Radius of the cylinder.\n                                \\end{minipg2} \\\\\n        \\>\\>    {\\fov dim}\\> - \\>       \\begin{minipg2}\n                                Dimension of the space in which the cylinder lies.\n                                Should be 3.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov maxstep}\\> - \\>   \\begin{minipg2}\n                                Maximum step length allowed.\n                                If maxstep $\\leq$ epsge maxstep is\n                                neglected. maxstep = 0.0 is recommended.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov makecurv}\\> - \\>  \\begin{minipg2}\n                                Indicator specifying if a geometric curve is to be made:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 -     \\>Do not make curves at all.\\\\\n                \\>\\>\\>\\>\\>      1 -     \\>Make only a geometric curve.\\\\\n                \\>\\>\\>\\>\\>      2 -     \\>\\begin{minipg5}\n                                        Make geometric curve and curve in the parameter\n                                        plane.\n                                        \\end{minipg5} \\\\[0.3ex]\n        \\>\\>    {\\fov graphic}\\> - \\>   \\begin{minipg2}\n                                Indicator specifying if the function\n                                should draw the curve:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 -     \\>Don't draw the curve.\\\\\n                \\>\\>\\>\\>\\>      1 -     \\>\\begin{minipg5}\n                                        Draw the geometric curve. This option is\n                                        outdated, if used see NOTE!\n                                        \\end{minipg5} \\\\[0.8ex]\n\\\\\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                                Pointer to the intersection curve.\n                                As input only\n                                guide points (points in parameter space)\n                                exist. These guide points\n                                are used to guide the marching.\n                                The routine adds\n                                intersection curve and curve in the parameter\n                                plane to the SISLIntcurve object according to the value\n                                of makecurv.\n                                \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>      $= 3$ : \\>      \\begin{minipg5}\n                                                Iteration stopped due to singular\n                                                point or degenerate surface. A part of\n                                                an intersection curve may have been\n                                                traced out. If no curve is traced out,\n                                                the curve pointers in the SISLIntcurve\n                                                object point to NULL.\n                                                \\end{minipg5} \\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 0$   :\\> ok\\\\\n                \\>\\>\\>\\>\\>      $< 0$   :\\> error\\\\\n\\\\\nNOTE\\\\\n\\>      \\begin{minipg6}\nIf the draw option is used the empty dummy functions s6move() and\ns6line() are called.\nThus if the draw option is used, make sure\nyou have versions of functions s6move() and s6line() interfaced to your graphic package.\n\\end{minipg6}\\\\\n\\\\ %\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov point}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov cyldir}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov radius}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-5;\\\\\n                \\>\\>    double  \\>      {\\fov maxstep} = 0.0;\\\\\n                \\>\\>    SISLIntcurve\\>  *{\\fov intcurve}; /* The intersection curve instance is defined in s1853 */\\\\\n                \\>\\>    int     \\>      {\\fov makecurv};\\\\\n                \\>\\>    int     \\>      {\\fov graphic};\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1316(\\begin{minipg4}\n                {\\fov surf}, {\\fov point}, {\\fov cyldir}, {\\fov radius}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov maxstep},\n                {\\fov intcurve}, {\\fov makecurv}, {\\fov graphic}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1317.tex",
    "content": "\\subsection{March an intersection curve between a spline surface and a cone.}\n\\funclabel{s1317}\n\\begin{minipg1}\n  To march an intersection curve described by parameter pairs in an intersection\n  curve object, a surface and a cone.\n  The guide points are expected to be found by s1854() described on\n  page \\pageref{s1854}.\n  The generated geometric curves are represented as B-spline curves.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1317(\\begin{minipg3}\n        {\\fov surf}, {\\fov toppt}, {\\fov axispt}, {\\fov conept},\n        {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov maxstep},\n        {\\fov intcurve}, {\\fov makecurv}, {\\fov graphic}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov toppt}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov axispt}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov conept}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      {\\fov maxstep};\\\\\n                \\>\\>    SISLIntcurve\\>  *{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      {\\fov makecurv};\\\\\n                \\>\\>    int     \\>      {\\fov graphic};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov toppt}\\> - \\>     \\begin{minipg2}\n                                The top point of the cone.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov axispt}\\> - \\>    \\begin{minipg2}\n                                Point on the axis of the cone; axispt must be different from toppt.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov conept}\\> - \\>    \\begin{minipg2}\n                                A point on the cone surface that is not the top\n                                point.\n                                \\end{minipg2} \\\\[0.3ex]\n        \\>\\>    {\\fov dim}\\> - \\>       \\begin{minipg2}\n                                Dimension of the space in which the cone lies.\n                                Should be 3.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov maxstep}\\> - \\>   \\begin{minipg2}\n                                Maximum step length allowed. If maxstep $\\leq$ epsge,\n                                maxstep is neglected. maxstep = 0.0 is recommended.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov makecurv}\\> - \\>          \\begin{minipg2}\n                                Indicator specifying if a geometric curve is to be made:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 -     \\>Do not make curves at all.\\\\\n                \\>\\>\\>\\>\\>      1 -     \\>Make only a geometric curve.\\\\\n                \\>\\>\\>\\>\\>      2 -     \\>\\begin{minipg5}\n                                        Make geometric curve and curve in the parameter\n                                        plane\n                                        \\end{minipg5} \\\\[0.3ex]\n        \\>\\>    {\\fov graphic}\\> - \\>   \\begin{minipg2}\n                                Indicator specifying if the function\n                                should draw the curve:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 -     \\>Don't draw the curve.\\\\\n                \\>\\>\\>\\>\\>      1 -     \\>\\begin{minipg5}\n                                        Draw the geometric curve. This option is\n                                        outdated, if used see NOTE!\n                                        \\end{minipg5} \\\\[0.8ex]\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                                Pointer to the intersection curve.\n                                As input only\n                                guide points (points in parameter space)\n                                exist. These guide points\n                                are used for guiding the marching.\n                                The routine adds the\n                                intersection curve and curve in the parameter\n                                plane to the SISLIntcurve object according to the value\n                                of makecurv.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>      $= 3$ : \\>      \\begin{minipg5}\n                                                Iteration stopped due to singular\n                                                point or degenerate surface. A part of\n                                                an intersection curve may have been\n                                                traced out. If no curve is traced out,\n                                                the curve pointers in the SISLIntcurve\n                                                object point to NULL.\n                                                \\end{minipg5} \\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 0$   :\\> ok\\\\\n                \\>\\>\\>\\>\\>      $< 0$   :\\> error\\\\\n\\\\\nNOTE\\\\\n\\>      \\begin{minipg6}\nIf the draw option is used the empty dummy functions s6move() and\ns6line() are called.\nThus if the draw option is used, make sure\nyou have versions of functions s6move() and s6line() interfaced to your graphic package.\n\\end{minipg6}\\\\\n\\\\ %\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov toppt}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov axispt}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov conept}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-5;\\\\\n                \\>\\>    double  \\>      {\\fov maxstep} = 0.0;\\\\\n                \\>\\>    SISLIntcurve\\>  *{\\fov intcurve}; /* The intersection curve instance is defined in s1854 */\\\\\n                \\>\\>    int     \\>      {\\fov makecurv} = 2;\\\\\n                \\>\\>    int     \\>      {\\fov graphic} = 0;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1317(\\begin{minipg4}\n                {\\fov surf}, {\\fov toppt}, {\\fov axispt}, {\\fov conept}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov maxstep},\n                {\\fov intcurve}, {\\fov makecurv}, {\\fov graphic}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1318.tex",
    "content": "\\subsection{March an intersection curve between a spline surface and a torus.}\n\\funclabel{s1318}\n\\begin{minipg1}\n  To march an intersection curve described by parameter pairs in an intersection\n  curve object, a surface and a torus.\n  The guide points are expected to be found by s1369(), described on\n  page \\pageref{s1369}.\n  The generated geometric curves are represented as B-spline curves.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1318(\\begin{minipg3}\n                        {\\fov surf}, {\\fov centre}, {\\fov normal}, {\\fov cendist}, {\\fov radius}, {\\fov dim}, {\\fov epsco}, {\\fov epsge},\n                        {\\fov maxstep}, {\\fov intcurve}, {\\fov makecurv}, {\\fov graphic}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov centre}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov normal}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov cendist};\\\\\n                \\>\\>    double  \\>      {\\fov radius};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      {\\fov maxstep};\\\\\n                \\>\\>    SISLIntcurve\\>  *{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      {\\fov makecurv};\\\\\n                \\>\\>    int     \\>      {\\fov graphic};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov centre}\\> - \\>    \\begin{minipg2}\n                                The centre of the torus (lying in the symmetry\n                                plane)\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov normal}\\> - \\>    \\begin{minipg2}\n                                Normal to the symmetry plane.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov cendist}\\> - \\>   \\begin{minipg2}\n                                Distance from centre to the centre circle of torus.\n                                \\end{minipg2} \\\\\n        \\>\\>    {\\fov radius}\\> - \\>    \\begin{minipg2}\n                                The radius of the torus surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}\\> - \\>       \\begin{minipg2}\n                                Dimension of the space in which the torus lies.\n                                Should be 3.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov maxstep}\\> - \\>   \\begin{minipg2}\n                                Maximum step length allowed.\n                                If maxstep $\\leq$ epsge maxstep is\n                                neglected. maxstep = 0.0 is recommended.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov makecurv}\\> - \\>  \\begin{minipg2}\n                                Indicator specifying if a geometric curve is to be made:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 -     \\>Do not make curves at all.\\\\\n                \\>\\>\\>\\>\\>      1 -     \\>Make only a geometric curve.\\\\\n                \\>\\>\\>\\>\\>      2 -     \\>\\begin{minipg5}\n                                        Make geometric curve and curve in the parameter\n                                        plane\n                                        \\end{minipg5} \\\\[0.3ex]\n\\newpagetabs\n        \\>\\>    {\\fov graphic}\\> - \\>   \\begin{minipg2}\n                                Indicator specifying if the function\n                                should draw the curve:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 -     \\>Don't draw the curve.\\\\\n                \\>\\>\\>\\>\\>      1 -     \\>\\begin{minipg5}\n                                        Draw the geometric curve. This option is\n                                        outdated, if used see NOTE!\n                                        \\end{minipg5} \\\\[0.8ex]\n\\\\\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                                Pointer to the intersection curve.\n                                As input only\n                                guide points (points in parameter space)\n                                exist. These guide points\n                                are used for guiding the marching.\n                                The routine adds the\n                                intersection curve and curve in the parameter\n                                plane to the SISLIntcurve object according to the value\n                                of makecurv.\n                                \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>      $= 3$ : \\>      \\begin{minipg5}\n                                                Iteration stopped due to singular\n                                                point or degenerate surface. A part of\n                                                an intersection curve may have been\n                                                traced out. If no curve is traced out\n                                                the curve pointers in the SISLIntcurve\n                                                object point to NULL.\n                                                \\end{minipg5} \\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 0$   :\\> ok\\\\\n                \\>\\>\\>\\>\\>      $< 0$   :\\> error\\\\\n\\\\\nNOTE\\\\\n\\>      \\begin{minipg6}\nIf the draw option is used the empty dummy functions s6move() and\ns6line() are called.\nThus if the draw option is used, make sure\nyou have versions of functions s6move() and s6line() interfaced to your graphic package.\n\\end{minipg6}\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov centre}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov normal}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov cendist}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov radius}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-5;\\\\\n                \\>\\>    double  \\>      {\\fov maxstep} = 0.0;\\\\\n                \\>\\>    SISLIntcurve\\>  *{\\fov intcurve}; /* The intersection curve instance is defined in s1369 */\\\\\n                \\>\\>    int     \\>      {\\fov makecurv} = 2;\\\\\n                \\>\\>    int     \\>      {\\fov graphic} = 0;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1318(\\begin{minipg4}\n                {\\fov surf}, {\\fov centre}, {\\fov normal}, {\\fov cendist}, {\\fov radius}, {\\fov dim}, {\\fov epsco}, {\\fov epsge},\n                {\\fov maxstep}, {\\fov intcurve}, {\\fov makecurv}, {\\fov graphic}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1319.tex",
    "content": "\\subsection{\\sloppy March a silhouette curve of a surface, using parallel \\mbox{projection}.}\n\\funclabel{s1319}\n\\begin{minipg1}\n  To march the silhouette curve described by an intersection curve object, a\n  surface and a view direction (i.e.\\ parallel projection).\n  The guide points are expected to be found by s1860(), described on\n  page \\pageref{s1860}.\n  The generated geometric curves are represented as B-spline curves.\n\\end{minipg1} \\\\ \\\\\nNOTE\\\\\n\\>     \\begin{minipg6}\nThe silhouette curves are defined as curves on the surface where the inner product of the surface normal and the direction vector of the viewing is 0. This definition will include surface points where the normal is zero.\n\\end{minipg6} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1319(\\begin{minipg3}\n                        {\\fov surf}, {\\fov viewdir}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov maxstep}, {\\fov intcurve}, {\\fov makecurv},\n                        {\\fov graphic}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov viewdir}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      {\\fov maxstep};\\\\\n                \\>\\>    SISLIntcurve\\>  *{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      {\\fov makecurv};\\\\\n                \\>\\>    int     \\>      {\\fov graphic};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>              \\begin{minipg2}\n                                Pointer to the surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov viewdir}\\> - \\>   \\begin{minipg2}\n                                View direction.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}\\> - \\>       \\begin{minipg2}\n                                Dimension of the space in which vector describing the view\n                                direction lies. Should be 3.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov maxstep}\\> - \\>   \\begin{minipg2}\n                                Maximum step length allowed.\n                                If maxstep $\\leq$ epsge maxstep is\n                                neglected. maxstep = 0.0 is recommended.\n                                \\end{minipg2}\\\\\n\\newpagetabs\n        \\>\\>    {\\fov makecurv}\\> - \\>  \\begin{minipg2}\n                                Indicator specifying if a geometric curve is to be made:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 -     \\>Do not make curves at all.\\\\\n                \\>\\>\\>\\>\\>      1 -     \\>Make only a geometric curve.\\\\\n                \\>\\>\\>\\>\\>      2 -     \\>\\begin{minipg5}\n                                        Make geometric curve and curve in the parameter\n                                        plane.\n                                        \\end{minipg5} \\\\[0.3ex]\n        \\>\\>    {\\fov graphic}\\> - \\>   \\begin{minipg2}\n                                Indicator specifying if the function\n                                should draw the geometric curve:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 -     \\>Don't draw the curve.\\\\\n                \\>\\>\\>\\>\\>      1 -     \\>\\begin{minipg5}\n                                        Draw the geometric curve.  This option is\n                                        outdated, if used see NOTE!\n                                        \\end{minipg5} \\\\[0.8ex]\n\\\\\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                                Pointer to the intersection curve.\n                                As input, only\n                                guide points (points in parameter space)\n                                exist. These guide points\n                                are used for guiding the marching.\n                                The routine adds\n                                intersection curve and curve in the parameter\n                                plane to the SISLIntcurve object according to the value\n                                of makecurv.\n                                \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>      $= 3$ : \\>      \\begin{minipg5}\n                                                Iteration stopped due to singular\n                                                point or degenerate surface. A part of\n                                                an intersection curve may have been\n                                                traced out. If no curve is traced out\n                                                the curve pointers in the SISLIntcurve\n                                                object point to NULL.\n                                                \\end{minipg5} \\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 0$   :\\> ok\\\\\n                \\>\\>\\>\\>\\>      $< 0$   :\\> error\\\\\n\\\\\nNOTE\\\\\n\\>      \\begin{minipg6}\nIf the draw option is used the empty dummy functions s6move() and\ns6line() are called.\nThus if the draw option is used, make sure\nyou have versions of functions s6move() and s6line() interfaced to your graphic package.\n\\end{minipg6}\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov viewdir}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-5;\\\\\n                \\>\\>    double  \\>      {\\fov maxstep} = 0.0;\\\\\n                \\>\\>    SISLIntcurve\\>  *{\\fov intcurve}; /* The silhouette curve instance is defined in s1860 */\\\\\n                \\>\\>    int     \\>      {\\fov makecurv} = 2;\\\\\n                \\>\\>    int     \\>      {\\fov graphic} = 0;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1319(\\begin{minipg4}\n                {\\fov surf}, {\\fov viewdir}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov maxstep}, {\\fov intcurve}, {\\fov makecurv},\n                graphic, \\&stat);\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1327.tex",
    "content": "\\subsection{Convert a curve/line intersection into a two-dimensional curve/origo intersection}\n\n\\funclabel{s1327}\n\\begin{minipg1}\nPut the equation of the curve pointed at by pcold\n               into two planes given by the point epoint and the normals\n               enorm1 and enorm2. The result is an equation where the\n               new two-dimensional curve rcnew is to be equal to origo.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1327(\\begin{minipg3}\n            {\\fov pcold}, {\\fov epoint}, {\\fov enorm1}, {\\fov enorm2}, {\\fov idim}, {\\fov rcnew}, {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLCurve    \\>  *{\\fov pcold};\\\\\n                \\>\\>    double       \\> epoint[\\,];\\\\\n                \\>\\>    double       \\> enorm1[\\,];\\\\\n                \\>\\>    double       \\> enorm2[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov idim};\\\\\n                \\>\\>    SISLCurve    \\>  **{\\fov rcnew};\\\\\n                \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov pcold}\\> - \\>  \\begin{minipg2}\n                     Pointer to input curve.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov epoint}\\> - \\>  \\begin{minipg2}\n                     SISLPoint in the planes.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov enorm1}\\> - \\>  \\begin{minipg2}\n                     Normal to the first plane.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov enorm2}\\> - \\>  \\begin{minipg2}\n                     Normal to the second plane.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov idim}\\> - \\>  \\begin{minipg2}\n                     Dimension of the space in which the planes lie.\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov rcnew}\\> - \\>  \\begin{minipg2}\n                    2-dimensional curve.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat}\\> - \\> status messages \\\\\n\t                   \\>\\>\\>\\>\\>   $ > 0 $     : warning \\\\\n                           \\>\\>\\>\\>\\>   $ = 0 $     : ok \\\\\n\t\t\t   \\>\\>\\>\\>\\>   $ < 0 $     : error \\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLCurve    \\>  *{\\fov pcold}; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> epoint[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> enorm1[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> enorm2[3]; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov idim} = 3; /* Equal to curve dimension */ \\\\\n                \\>\\>    SISLCurve    \\>  **{\\fov rcnew} = NULL;\\\\\n                \\>\\>    int    \\>  *{\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1327(\\begin{minipg4}\n            {\\fov pcold}, {\\fov epoint}, {\\fov enorm1}, {\\fov enorm2}, {\\fov idim}, {\\fov rcnew}, {\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1328.tex",
    "content": "\\subsection{Convert a surface/line intersection into a two-dimensional surface/origo intersection}\n\\funclabel{s1328}\n\\begin{minipg1}\nPut the equation of the surface pointed at by psold\n               into two planes given by the point epoint and the normals\n               enorm1 and enorm2. The result is an equation where the \n               new two-dimensional surface rsnew is to be equal to origo.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1328(\\begin{minipg3}\n            {\\fov psold}, {\\fov epoint}, {\\fov enorm1}, {\\fov enorm2}, {\\fov idim}, {\\fov rsnew}, {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf    \\>  *{\\fov psold};\\\\\n                \\>\\>    double \\> epoint[\\,];\\\\\n                \\>\\>    double \\> enorm1[\\,];\\\\\n                \\>\\>    double \\> enorm2[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov idim};\\\\\n                \\>\\>    SISLSurf    \\>  **{\\fov rsnew};\\\\\n                \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov psold}\\> - \\>  \\begin{minipg2}\n                     Pointer to input surface.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov epoint}\\> - \\>  \\begin{minipg2}\n                     SISLPoint in the planes.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov enorm1}\\> - \\>  \\begin{minipg2}\n                     Normal to the first plane.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov enorm2}\\> - \\>  \\begin{minipg2}\n                     Normal to the second plane.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov idim}\\> - \\>  \\begin{minipg2}\n                     Dimension of the space in which the planes lie.\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov rsnew}\\> - \\>  \\begin{minipg2}\n                    dimensional surface.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat}\\> - \\> status messages  \\\\\n\t            \\>\\>\\>\\>\\>          $ > 0 $      : warning\\\\\n\t\t    \\>\\>\\>\\>\\>          $ = 0 $      : ok \\\\\n\t\t    \\>\\>\\>\\>\\>          $ < 0 $      : error \\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLSurf    \\>  *{\\fov psold}; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> epoint[3]; \\, /* Must be defined */\\\\\\\n                \\>\\>    double \\> enorm1[3]; \\,/* Must be defined */\\\\\\\n                \\>\\>    double \\> enorm2[3]; \\,/* Must be defined */\\\\\\\n                \\>\\>    int    \\>  {\\fov idim} = 3;\\\\\n                \\>\\>    SISLSurf    \\>  **{\\fov rsnew} = NULL;\\\\\n                \\>\\>    int    \\>  *{\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1328(\\begin{minipg4}\n            {\\fov psold}, {\\fov epoint}, {\\fov enorm1}, {\\fov enorm2}, {\\fov idim}, \\&{\\fov rsnew}, \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1332.tex",
    "content": "\\subsection{Compute a linear swept surface.}\n\\funclabel{s1332}\n\\begin{minipg1}\n  To create a linear swept surface by making the tensor-product of two curves.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1332(\\begin{minipg3}\n                                {\\fov curve1}, {\\fov curve2}, {\\fov epsge}, {\\fov point}, {\\fov surf}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve1};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve2};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      {\\fov point}[\\,];\\\\\n                \\>\\>    SISLSurf        \\>      **{\\fov surf};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve1}   \\> - \\> \\begin{minipg2}\n                                Pointer to curve 1.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov curve2}   \\> - \\> \\begin{minipg2}\n                                Pointer to curve 2.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Maximal deviation allowed between the true swept\n                                surface and the generated surface.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov point}    \\> - \\> \\begin{minipg2}\n                Point near the curve to sweep along. The vertices of the new surface are made by adding the vector from point to each of the vertices on the sweep curve, to each of the vertices on the other curve.\n                                \\end{minipg2} \\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov surf}     \\> - \\> \\begin{minipg2}\n                                Pointer to the surface produced.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $>0$    : warning\\\\\n                \\>\\>\\>\\>\\>              $=0$    : ok\\\\\n                \\>\\>\\>\\>\\>              $<0$    : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    curve   \\>      *{\\fov curve1}; \\, /* Must be defined */\\\\\n                \\>\\>    curve   \\>       *{\\fov curve2}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 0.001 ;\\\\\n                \\>\\>    double  \\>      {\\fov point}[3]; \\, /* Dimension as for curve coefficients. Must be defined */\\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1332(\\begin{minipg4}\n                {\\fov curve1}, {\\fov curve2}, {\\fov epsge}, {\\fov point}, \\&{\\fov surf}, \\&{\\fov stat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1333.tex",
    "content": "\\subsection{Lofted surface.}\n\\funclabel{s1333}\n\\begin{minipg1}\nTo create a spline lofted surface from a set of input curves.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1333(\\begin{minipg3}\n\t\t\t{\\fov numcurve}, {\\fov curves}, {\\fov typecur}, {\\fov startpar}, {\\fov open}, {\\fov order2},\n\t\t\t{\\fov flag}, {\\fov surf}, {\\fov parval}, {\\fov stat})\n\t\t\\end{minipg3}\\\\[0.3ex]\n\t\t\\>\\>\tint\t\\> \t{\\fov numcurve};\\\\\n\t\t\\>\\>\tSISLCurve\t\\>\t*{\\fov curves}[\\,];\\\\\n\t\t\\>\\>\tint\t\\>\t{\\fov typecur}[\\,];\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov startpar};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov open};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov order2};\\\\\n\t\t\\>\\>\tint\t\\>\t{\\fov flag};\\\\\n\t\t\\>\\>\tSISLSurf\t\\>\t**{\\fov surf};\\\\\n\t\t\\>\\>\tdouble \t\\>\t**{\\fov parval};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov numcurve}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tNumber of curves in the curve-set.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov curves}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tArray (length numcurve) of pointers to the curves in the \n\t\t\t\tcurve-set.\n\t\t\t\t\\end{minipg2}\\\\[0.8ex]\n\t\\>\\>\t{\\fov typecur}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tArray (length numcurve) containing the types of the curves\t\n\t\t\t\tin the curve-set.\n\t\t\t\t\\end{minipg2}\\\\[0.8ex]\n\t\t\\>\\>\\>\\>\\>\t 1 : \\>\tOrdinary curve.\\\\\n\t\t\\>\\>\\>\\>\\>\t 3 : \\>\tTangent to next curve.\\\\\n\t\t\\>\\>\\>\\>\\>\t 4 : \\>\tTangent to prior curve.\\\\\n\t\t\\>\\>\\>\\>\\>\t13 : \\>\t\\begin{minipg5}\n\t\t\t\t\tSISLCurve giving start of the tangent to next curve.\n\t\t\t\t\t\\end{minipg5}\\\\[0.8ex]\n\t\t\\>\\>\\>\\>\\>\t14 : \\>\t\\begin{minipg5}\n\t\t\t\t\tSISLCurve giving end of the tangent to prior curve.\n\t\t\t\t\t\\end{minipg5}\\\\[0.8ex]\n\t\\>\\>\t{\\fov startpar}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tStart parameter of the parameter interval in the spline lofting direction.\t\n\t\t\t\t\\end{minipg2} \\\\[0.3ex]\n\t\\>\\>\t{\\fov open}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tFlag specifying if the resulting surface from the lofting should be closed \n\t\t\t\t\t\tor open.\n\t\t\t\t\\end{minipg2} \\\\[0.8ex]\n\t\t\\>\\>\\>\\>\\>\t$=0$ : \\>\tThe surface should be closed.\\\\\n\t\t\\>\\>\\>\\>\\>\t$=1$ : \\>\tThe surface should be open.\\\\\n{\\fov \t}\\>\\>\torder2\t\\> - \\> \\begin{minipg2}\n\t\t\t\tMaximal order of the B-spline basis in the lofting \t\n\t\t\t\tdirection.\n\t\t\t\t\\end{minipg2}\\\\[0.8ex]\n\t\\>\\>\t{\\fov flag}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tFlag specifying if the length of the\n\t\t\t\ttangents in the derivative curves \n\t\t\t\tshould be adjusted or not.\n\t\t\t\t\\end{minipg2}\\\\[0.3ex]\n\t\t\\>\\>\\>\\>\\>\t$=0$ : \\>\tDo not adjust tangent-lengths.\\\\\n\t\t\\>\\>\\>\\>\\>\t$=1$ : \\>\tAdjust tangent-lengths\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov surf}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tPointer to the produced surface .\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov parval}\\> - \\>\t\\begin{minipg2}\n\t\t\tThe input curves are constant parameter lines in the parameter\n\t\t\tplane of the produced surface.\n\t\t\t\t\\end{minipg2}\\\\[0.3ex]\n\t\t\\>\\>\\>\\>\\>\t[i]: \\>\t\\begin{minipg5}\n\t\t\t\t\tcontains the (constant) parameter value of input curve no. i.\n\t\t\t\t\t\\end{minipg5}\\\\[0.3ex]\n\t\\>\\>\t{\\fov stat}\\> - \\>\t\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\t\t\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n\t\t\\>\\>\tint\t\\> \t{\\fov numcurve = 4};\\\\\n\t\t\\>\\>\tSISLCurve\t\\>\t*{\\fov curves[4]};\\\\\n\t\t\\>\\>\tint\t\\>\t{\\fov typecur[4]};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov startpar};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov open};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov order2};\\\\\n\t\t\\>\\>\tint\t\\>\t{\\fov flag};\\\\\n\t\t\\>\\>\tSISLSurf\t\\>\t*{\\fov surf};\\\\\n\t\t\\>\\>\tdouble \t\\>\t*{\\fov parval};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov stat};\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1333(\\begin{minipg4}\n\t\t{\\fov numcurve}, {\\fov curves}, {\\fov typecur}, {\\fov startpar}, {\\fov open}, {\\fov order2}, {\\fov flag}, \\&{\\fov surf},\t\n\t\t\\&{\\fov parval}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots\\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1334.tex",
    "content": "\\subsection{Spline interpolation automatic paramete\\-risation.}\n\\funclabel{s1334}\n\\begin{minipg1}\nTo calculate a B-spline curve interpolating a set of points. Each\npoint can be assigned a tangent (derivative). The curve can be closed\nor open. If end-conditions are conflicting, the condition closed curve\nrules out other end conditions.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1334(\\begin{minipg3}\n\t\t{\\fov point}, {\\fov numpt}, {\\fov dim}, {\\fov typept}, {\\fov startcon}, {\\fov endcon},\n\t\t{\\fov open}, {\\fov order},\\\\ {\\fov startpar}, {\\fov endpar}, {\\fov curve}, {\\fov pointpar},\n\t\t{\\fov numptpar},{\\fov stat})\n\t\t\\end{minipg3}\\\\[0.3ex]\n\t\t\\>\\>\tdouble\t\\> \t{\\fov point}[\\,];\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov numpt};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov dim};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov typept}[\\,];\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov startcon};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov endcon};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov open};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov order};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov startpar};\\\\\n\t\t\\>\\>\tdouble \t\\>\t*{\\fov endpar};\\\\\t\t\n\t\t\\>\\>\tSISLCurve \t\\>\t**{\\fov curve};\\\\\n\t\t\\>\\>\tdouble \t\\>\t**{\\fov pointpar};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov numptpar};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov point}\t\\> - \\>\t\\begin{minipg2}\n\t\t\t\tArray (length dim*numpt) containing the\n\t\t\t\tpoints/derivatives to be interpolated.\n\t\t\t\t\\end{minipg2}\\\\[0.3ex]\n\t\\>\\>\t{\\fov numpt}\t\\> - \\>\t\n\t\t\t\tNo. of points/derivatives in the\n\t\t\t\tpoint array.\n\t\t\t\t\\\\\n\t\\>\\>\t{\\fov dim}\t\\> - \\>\t\\begin{minipg2}\n\t\t\t\tThe dimension of the space in which\n\t\t\t\tthe points lie.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov typept}\t\\> - \\>\t\\begin{minipg2}\n\t\t\t\tArray (length numpt) containing type\n\t\t\t\tindicator for points/derivatives:\n\t\t\t\t\\end{minipg2} \\\\[0.3ex]\n\t\t\\>\\>\\>\\>\\>\t1 : Ordinary point.\\\\\n\t\t\\>\\>\\>\\>\\>\t3 : Derivative to next point.\\\\\n\t\t\\>\\>\\>\\>\\>\t4 : Derivative to prior point.\\\\\n\t\t\\>\\>\\>\\>\\>\t13 : Start-point of tangent to next point.\\\\\n\t\t\\>\\>\\>\\>\\>\t14 : End-point of tangent to prior point.\\\\\n\\newpagetabs\n\t\\>\\>\t{\\fov startcon}\t\\> - \\>\t\\begin{minipg2}\n\t\t\t\tAdditional condition at the start\n\t\t\t\tof the curve:\n\t\t\t\t\\end{minipg2}\\\\\n\t\t\\>\\>\\>\\>\\>\t0 : \tNo additional condition.\\\\\n\t\t\\>\\>\\>\\>\\>\t1 : \tZero curvature at start.\\\\\n\t\\>\\>\t{\\fov endcon}\t\\> - \\>\t\\begin{minipg2}\n\t\t\t\tAdditional condition at the end\n\t\t\t\tof the curve:\n\t\t\t\t\\end{minipg2}\\\\\n\t\t\\>\\>\\>\\>\\>\t0 : \tNo additional condition.\\\\\n\t\t\\>\\>\\>\\>\\>\t1 : \tZero curvature at end.\\\\\n\t\\>\\>\t{\\fov open}\t\\> - \\>\tOpen or closed curve:\\\\\n\t\t\\>\\>\\>\\>\\>\t0 : \tClosed curve.\\\\\n\t\t\\>\\>\\>\\>\\>\t1 : \tOpen curve.\\\\\n\t\\>\\>\t{\\fov order}\t\\> - \\> \\begin{minipg2}\n\t\t\t\tThe order of the B-spline curve\n\t\t\t\tto be produced.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov startpar}\t\\> - \\>\t\\begin{minipg2}\n\t\t\t\tParameter-value to be used at the\n\t\t\t\tstart of the curve.\n\t\t\t\t\\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov endpar}\t\\> - \\>\t\\begin{minipg2}\n\t\t\t\tParameter-value used at the end\n\t\t\t\tof the curve.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov curve}\t\\> - \\>\tPointer to output-curve\\\\\n\t\\>\\>\t{\\fov pointpar}\t\\> - \\>\t\\begin{minipg2}\n\t\t\t\tPointer to the parameter values of\n\t\t\t\tthe interpolation conditions. Represented only once, although\n\t\t\t\tderivative conditions \n\t\t\t\twill have the same \t\n\t\t\t\tparameter-value as the point.\n\t\t\t\t\\end{minipg2} \\\\[0.3ex]\n\t\\>\\>\t{\\fov numptpar}\t\\> - \\>\t\\begin{minipg2}\n\t\t\t\tNo. of different parameter-values.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov stat}\t\\> - \\>\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n\t\t\\>\\>\tdouble\t\\> \t{\\fov point}[30];\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov numpt} = 10;\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov dim} = 3;\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov typept}[10];\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov startcon};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov endcon};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov open};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov order};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov startpar};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov endpar};\\\\\t\t\n\t\t\\>\\>\tSISLCurve \t\\>\t*{\\fov curve};\\\\\n\t\t\\>\\>\tdouble \t\\>\t*{\\fov pointpar};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov numptpar};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov stat};\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1334(\\begin{minipg4}\n\t\t\t{\\fov point}, {\\fov numpt}, {\\fov dim}, {\\fov typept},\n\t\t\t{\\fov startcon}, {\\fov endcon}, {\\fov open}, {\\fov order},\\\\ {\\fov startpar},\n\t\t\t\\&{\\fov endpar}, \\&{\\fov curve}, \\&{\\fov pointpar}, \\&{\\fov numptpar}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1340.tex",
    "content": "\\subsection{Data reduction: B-spline curve as input.}\n\\funclabel{s1340}\n\\begin{minipg1}\n  To remove knots from a B-spline (i.e.\\ NOT rational) curve, and\n  calculate an approximation to the original spline from the reduced\n  spline space.\n  The output is represented as a B-spline curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1340(\\begin{minipg3}\n                {\\fov oldcurve}, {\\fov eps}, {\\fov startfix}, {\\fov endfix}, {\\fov epsco}, {\\fov itmax},\n                {\\fov newcurve}, {\\fov maxerr}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov oldcurve};\\\\\n                \\>\\>    double  \\>      {\\fov eps}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov startfix};\\\\\n                \\>\\>    int     \\>      {\\fov endfix};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    int     \\>      {\\fov itmax};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve};\\\\\n                \\>\\>    double  \\>      {\\fov maxerr}[\\,];\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov oldcurve}\\> - \\>  Pointer to the original B-spline\n                                        curve.\\\\\n        \\>\\>    {\\fov eps}      \\> - \\> \\begin{minipg2}\n                                Array (length dim) giving the desired accuracy of\n                                the spline-approximation in each component.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov startfix}\\> - \\>  \\begin{minipg2}\n                                The no. of derivatives that are not allowed to\n                                change at the left end of the curve. The (0 -\n                                (startfix-1)) derivatives will be kept fixed. If startfix\n                                $<$0, this routine will set it to 0. If startfix$>$the curve order, this\n                                routine will set it to the curve order.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov endfix}   \\> - \\> \\begin{minipg2}\n                                The number of derivatives that are not allowed to\n                                change at the right end of the curve. All the derivatives up to order endfix-1 will be kept fixed. If endfix\n                                $<$0, this routine will set it to 0. If endfix$>$the curve order, this\n                                routine will set it to the curve order.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epsco}    \\> - \\> \\begin{minipg2}\n                                Two numbers differing by a relative amount\n                                $<$epsco, will in some cases be considered equal. A\n                                suitable value is just above the unit roundoff of the\n                                machine. The computations are not guaranteed to\n                                have relative accuracy less than\n                                epsco. Not used anymore.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov itmax}    \\> - \\> Max. no. of iterations.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newcurve}\\> - \\>  Pointer to the new B-spline curve.\\\\\n        \\>\\>    {\\fov maxerr}   \\> - \\> \\begin{minipg2}\n                                Array (length dim)\n                                contains an upper bound\n                                for the  maximum\n                                pointwise error in each of the components\n                                of the spline approximation. E.g.\n                                for dim$=$3 $(x_{max},y_{max},z_{max})$.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov oldcurve};\\\\\n                \\>\\>    double  \\>      {\\fov eps}[3];\\\\\n                \\>\\>    int     \\>      {\\fov startfix};\\\\\n                \\>\\>    int     \\>      {\\fov endfix};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    int     \\>      {\\fov itmax};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve};\\\\\n                \\>\\>    double  \\>      {\\fov maxerr}[3];\\\\\n                \\>\\>    int     \\>      {\\fov stat};\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1340(\\begin{minipg4}\n                {\\fov oldcurve}, {\\fov eps}, {\\fov startfix}, {\\fov endfix}, {\\fov epsco}, {\\fov itmax},\n                \\&{\\fov newcurve},\\\\ {\\fov maxerr}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1341.tex",
    "content": "\\subsection{Data reduction: Point data as input.}\n\\funclabel{s1341}\n\\begin{minipg1}\n  To compute a spline approximation to the data given by  points, and\n  represent it as a B-spline curve. The approximation is determined by\n  first forming the piecewise\n  linear interpolant to the data, and then performing knot removal on\n  this initial approximation.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1341(\\begin{minipg3}\n        {\\fov points}, {\\fov numpt}, {\\fov dim}, {\\fov typepar}, {\\fov par}, {\\fov eps}, {\\fov startfix}, {\\fov endfix}, {\\fov tolshare}, {\\fov epsco},\n        {\\fov itmax}, {\\fov order}, {\\fov curve}, {\\fov maxerr}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    double  \\>      {\\fov points}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov numpt};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    int     \\>      {\\fov typepar};\\\\\n                \\>\\>    double  \\>      {\\fov par}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov eps}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov startfix};\\\\\n                \\>\\>    int     \\>      {\\fov endfix};\\\\\n                \\>\\>    double  \\>      {\\fov tolshare};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    int     \\>      {\\fov itmax};\\\\\n                \\>\\>    int     \\>      {\\fov order};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov curve};\\\\\n                \\>\\>    double  \\>      *{\\fov maxerr};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov points}   \\> - \\> \\begin{minipg2}\n                                Array (length dim *numpt) containing the points to be\n                                approximated.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov numpt}    \\> - \\> \\begin{minipg2}\n                                The number of data points.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                The dimension of the Euclidean space in which the\n                                data points lie, i.e. the number of components of\n                                each data point.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov typepar}  \\> - \\> \\begin{minipg2}\n                                Flag indicating the type of parameterization to be\n                                        used:\n                                \\end{minipg2}\\\\[0.8ex]\n                \\>\\>\\>\\>\\>      $=1$ :\\>\\begin{minipg5}\n                                        Parameterize by accumulated cord length.\n                                        (Arc length parameterization for the\n                                        piecewise linear interpolant.)\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $=2$ :\\>Uniform parameterization.\\\\\n                \\>\\>\\>\\>\\>      $=3$ :\\>\\begin{minipg5}\n                                        Parameterization given by {\\fov par}.\\\\\n                                        If typepar$<$1 or typepar$>$3, it\n                                        will be set to 1.\n                                        \\end{minipg5}\\\\[0.8ex]\n        \\>\\>    {\\fov par}      \\> - \\> \\begin{minipg2}\n                                Array (length numpt) containing a\n                                parameterization of the given data.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov eps}      \\> - \\> \\begin{minipg2}\n                                Array (length dim) containing the tolerance to be\n                                used during the data reduction phase. The final\n                                approximation to the data will deviate less than\n                                eps from the piecewise linear interpolant in each\n                                of the dim components.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov startfix}\\> - \\>  \\begin{minipg2}\n                                The number of derivatives that are not allowed to\n                                change at the left end of the curve.\n                                The $(0 - (startfix -1))$\n                                derivatives will be kept fixed. If startfix$<$0, this\n                                routine will set it to 0. If startfix$>$order,\n                                this routine will set it to order.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov endfix}   \\> - \\> \\begin{minipg2}\n                                The number of derivatives that are not allowed to\n                                change at the right end of the curve.\n                                The $(0 - (endfix-1))$ derivatives will\n                                be kept fixed.\n                                If endfix$<$0, this routine will set it to 0.\n                                If endfix$>$order, this routine will\n                                set it to order.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov tolshare}\\> - \\>  \\begin{minipg2}\n                                Number indicating how the tolerance is to be\n                                shared between the two data reduction stages. For\n                                the linear reduction, a tolerance of tolshare*eps will\n                                be used, while a tolerance of\n                                $(1-tolshare)\\times eps$ will be\n                                used during the final data reduction.\n                                Use $0\\leq tolshare\\leq 1$, a general\n                                advice is to use a {\\fov tolshare} value\n                                closer to zero than one.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov epsco}    \\> - \\> \\begin{minipg2}\n                                Two numbers differing by a relative amount less\n                                than epsco will in some cases be\n                                considered equal.\n                                Not used anymore.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov itmax}    \\> - \\> \\begin{minipg2}\n                                Max. number of iterations in the data-reduction routine.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov order}    \\> - \\> The polynomial order of the approximation.\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to the B-spline curve.\\\\\n        \\>\\>    {\\fov maxerr}   \\> - \\> \\begin{minipg2}\n                                Array (length dim)\n                                containing for each component an upper\n                                bound on the max. deviation of the final\n                                approximation from the initial piecewise linear\n                                interpolant.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    double  \\>      {\\fov points}[30];\\\\\n                \\>\\>    int     \\>      {\\fov numpt} = 10;\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    int     \\>      {\\fov typepar};\\\\\n                \\>\\>    double  \\>      {\\fov par}[10];\\\\\n                \\>\\>    double  \\>      {\\fov eps}[3];\\\\\n                \\>\\>    int     \\>      {\\fov startfix};\\\\\n                \\>\\>    int     \\>      {\\fov endfix};\\\\\n                \\>\\>    double  \\>      {\\fov tolshare};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    int     \\>      {\\fov itmax} = 6;\\\\\n                \\>\\>    int     \\>      {\\fov order};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov maxerr}[3];\\\\\n                \\>\\>    int     \\>      {\\fov stat};\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1341(\\begin{minipg4}\n        {\\fov points}, {\\fov numpt}, {\\fov dim}, {\\fov typepar}, {\\fov par}, {\\fov eps}, {\\fov startfix}, {\\fov endfix}, {\\fov tolshare}, {\\fov epsco},\n        {\\fov itmax}, {\\fov order}, \\&{\\fov curve}, {\\fov maxerr}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1342.tex",
    "content": "\\subsection{Data reduction: Points and tangents as input.}\n\\funclabel{s1342}\n\\begin{minipg1}\n  To compute the approximation to the data given by points and the\n  derivatives (tangents), and represent it as a B-spline curve with\n  parameterization determined by the parameter par. The approximation is\n  determined by first forming the cubic Hermite interpolant to the data, and then\n  performing knot removal on this initial approximation.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1342(\\begin{minipg3}\n        {\\fov points}, {\\fov derives}, {\\fov numpt}, {\\fov dim}, {\\fov typepar}, {\\fov par}, {\\fov eps}, {\\fov startfix}, {\\fov endfix}, {\\fov epsco},\n        {\\fov itmax}, {\\fov curve}, {\\fov maxerr}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    double  \\>      {\\fov points}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov derives}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov numpt};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    int     \\>      {\\fov typepar};\\\\\n                \\>\\>    double  \\>      {\\fov par}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov eps}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov startfix};\\\\\n                \\>\\>    int     \\>      {\\fov endfix};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    int     \\>      {\\fov itmax};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov curve};\\\\\n                \\>\\>    double  \\>      *{\\fov maxerr};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov points}   \\> - \\> \\begin{minipg2}\n                                Array (length dim *numpt) containing the points to be\n                                approximated.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov derives}  \\> - \\> \\begin{minipg2}\n                                Array (length dim *numpt) containing\n                                the derivatives\n                                of the points to be\n                                approximated.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov numpt}    \\> - \\> \\begin{minipg2}\n                                The number of data points.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                The dimension of the Euclidean space in which the\n                                data points lie, i.e. the number of components of\n                                each data point.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov typepar}  \\> - \\> \\begin{minipg2}\n                                Flag indicating the type of parameterization to be\n                                        used:\n                                \\end{minipg2}\\\\[0.8ex]\n                \\>\\>\\>\\>\\>      $=1$ :\\> \\begin{minipg5}\n                                        Parameterize by accumulated cord length.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $=2$ :\\> Uniform parameterization.\\\\\n                \\>\\>\\>\\>\\>      $=3$ :\\> \\begin{minipg5}\n                                        Parameterization given by {\\fov par}.\\\\\n                                        If typepar$<$1 or typepar$>$3, it\n                                        will be set to 1.\n                                        \\end{minipg5}\\\\[0.8ex]\n        \\>\\>    {\\fov par}      \\> - \\> \\begin{minipg2}\n                                Array (length numpt) containing a\n                                parameterization of the given data.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov eps}      \\> - \\> \\begin{minipg2}\n                                Array (length dim) containing the tolerance to be\n                                used during the data reduction phase. The final\n                                approximation to the data will deviate less than\n                                eps from the cubic Hermite interpolant in each\n                                of the dim components.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov startfix}\\> - \\>  \\begin{minipg2}\n                                The number of derivatives that are not allowed to\n                                change at the left end of the curve.\n                                The $(0 - (startfix -1))$\n                                derivatives will be kept fixed. If startfix$<$0, this\n                                routine will set it to 0. If startfix$>$order,\n                                this routine will set it to order.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov endfix}   \\> - \\> \\begin{minipg2}\n                                The number of derivatives that are not allowed to\n                                change at the right end of the curve.\n                                The $(0 - (endfix-1))$ derivatives will\n                                be kept fixed.\n                                If endfix$<$0, this routine will set it to 0.\n                                If endfix$>$order, this routine will\n                                set it to order.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epsco}    \\> - \\> \\begin{minipg2}\n                                Two numbers differing by a relative amount less\n                                than epsco will in some cases be\n                                considered equal.\n                                Not used anymore.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov itmax}    \\> - \\> \\begin{minipg2}\n                                Max. number of iterations in the data-reduction routine.\n                                \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to the B-spline curve.\\\\\n        \\>\\>    {\\fov maxerr}   \\> - \\> \\begin{minipg2}\n                                Array (length dim)\n                                containing for each component an upper\n                                bound on the max. deviation of the final\n                                approximation from the initial cubic Hermite\n                                interpolant.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    double  \\>      {\\fov points}[30];\\\\\n                \\>\\>    double  \\>      {\\fov derives}[30];\\\\\n                \\>\\>    int     \\>      {\\fov numpt} = 10;\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    int     \\>      {\\fov typepar};\\\\\n                \\>\\>    double  \\>      {\\fov par}[10];\\\\\n                \\>\\>    double  \\>      {\\fov eps}[3];\\\\\n                \\>\\>    int     \\>      {\\fov startfix};\\\\\n                \\>\\>    int     \\>      {\\fov endfix};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    int     \\>      {\\fov itmax} = 6;\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov maxerr}[3];\\\\\n                \\>\\>    int     \\>      {\\fov stat};\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1342(\\begin{minipg4}\n        {\\fov points}, {\\fov derives}, {\\fov numpt}, {\\fov dim}, {\\fov typepar}, {\\fov par}, {\\fov eps}, {\\fov startfix}, {\\fov endfix}, {\\fov epsco},\n        {\\fov itmax}, \\&{\\fov curve}, {\\fov maxerr}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1343.tex",
    "content": "\\subsection{Degree reduction: B-spline curve as input.}\n\\funclabel{s1343}\n\\begin{minipg1}\n  To approximate the input B-spline (i.e.\\ NOT rational) curve by a\n  cubic B-spline curve with error less than {\\fov eps} in each of the\n  {\\fov kdim} components.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1343(\\begin{minipg3}\n        {\\fov oldcurve}, {\\fov eps}, {\\fov startfix}, {\\fov endfix}, {\\fov epsco},\n        {\\fov itmax}, {\\fov newcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov oldcurve};\\\\\n                \\>\\>    double  \\>      {\\fov eps}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov startfix};\\\\\n                \\>\\>    int     \\>      {\\fov endfix};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    int     \\>      {\\fov itmax};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov oldcurve}\\> - \\> Pointer to the old B-spline curve.\\\\\n        \\>\\>    {\\fov eps}      \\> - \\> \\begin{minipg2}\n                        Array (length kdim) giving the desired accuracy of\n                                the spline-approximation in each component.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov startfix}\\> - \\>  \\begin{minipg2}\n                        The no. of derivatives that are not allowed to\n                        change at the left end of the curve.\n                        The $(0 - (startfix-1))$ derivatives\n                        will be kept fixed. If startfix$<$0, this\n                        routine will set it to 0. If startfix$>$order,\n                        this routine will set it to order.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov endfix}   \\> - \\> \\begin{minipg2}\n                        The no. of derivatives that are not allowed to\n                        change at the right end of the curve. The\n                        $(0 - (endfix-1))$ derivatives will be kept fixed.\n                        If endfix$<$0, this routine will set it to 0.\n                        If endfix$>$order, this routine will set it to order.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epsco}    \\> - \\> \\begin{minipg2}\n                        Two numbers differing by a relative amount\n                        $<$epsco, will in some cases be considered equal. A\n                        suitable value is just above the unit roundoff in the\n                        machine.  The computations are not guaranteed to\n                        have relative accuracy less than aepsco.\n                        Not used anymore.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov itmax}    \\> - \\> \\begin{minipg2}\n                                Max. no. of iterations in the data-reduction routine.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newcurve}\\> - \\> Pointer to the new B-spline curve.\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov oldcurve};\\\\\n                \\>\\>    double  \\>      {\\fov eps}[3];\\\\\n                \\>\\>    int     \\>      {\\fov startfix};\\\\\n                \\>\\>    int     \\>      {\\fov endfix};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    int     \\>      {\\fov itmax};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve};\\\\\n                \\>\\>    int     \\>      {\\fov stat};\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1343(\\begin{minipg4}\n        {\\fov oldcurve}, {\\fov eps}, {\\fov startfix}, {\\fov endfix}, {\\fov epsco},\n        {\\fov itmax}, \\&{\\fov newcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1345.tex",
    "content": "\\subsection{Data reduction: B-spline surface as input.}\n\\funclabel{s1345}\n\\begin{minipg1}\n  To remove knots from a tensor-product B-spline (i.e.\\ NOT rational)\n  surface and calculate an approximation to the original surface on the\n  reduced knot vectors.\n  The output is represented as a B-spline surface.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1345(\\begin{minipg3}\n                        {\\fov surf}, {\\fov eps}, {\\fov edgefix}, {\\fov edgeps}, {\\fov epsco}, {\\fov optim}, {\\fov itmax}, {\\fov newsurf},\n                        {\\fov maxerr}, {\\fov stat})\n                        \\end{minipg3}\\\\[0.3ex]\n\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov eps}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov edgefix}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov edgeps}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    int     \\>      {\\fov optim};\\\\\n                \\>\\>    int     \\>      {\\fov itmax};\\\\\n                \\>\\>    SISLSurf        \\>      **{\\fov newsurf};\\\\\n                \\>\\>    double  \\>      {\\fov maxerr}[\\,];\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the original B-spline surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov eps}\\> - \\>       \\begin{minipg2}\n                                Array with length dim (dim=geometrical dimension)\n                                containing the\n                                maximum deviation which is\n                                acceptable in each of the dim\n                                components of the surface (except\n                                possibly along the edges).\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov edgefix}\\> - \\>   \\begin{minipg2}\n                                Array (length 4) containing the no. of derivatives to be\n                                kept \"fixed\" along each edge of the surface. The\n                                numbering of the edges is the same as for edgeps\n                                below. All the derivatives of\n                                $order<\\mbox{edgefix}[i]-1$ will\n                                be kept \"fixed\" along edge no. $i$.\n                                Hence $\\mbox{edgefix}[i]=0$\n                                indicates that nothing is to be kept fixed along edge\n                                no. $i$. To be kept fixed means to have error of approximation less\n                                than edges. In general, it is impossible to remove any\n                                knots and keep an edge completely fixed.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov edgeps}\\> - \\>    \\begin{minipg2}\n                                Array with length dim*4\n                                (dim=geometrical dimension)  containing the max.\n                                deviation which is acceptable along the edges of\n                                the surfaces.\n                                \\end{minipg2}\\\\[0.3ex]\n                \\>\\>\\>\\>        \\begin{minipg2}\n                                $edgeps[dim*i],\\ldots,edgeps[(dim*(i+1)-1]$\n                                gives the\n                                tolerance along the edge nr. $i$ corresponding to the\n                                following:\n                                \\end{minipg2}\\\\[0.3ex]\n                \\>\\>\\>\\>        \\begin{minipg2}\n                                \\begin{center}\n                                        \\begin{picture}(180,110)(0,0)\n                                        \\put(50,15){\\framebox(80,80)}\n                                        \\put(40,55){\\makebox(0,0){0}}\n                                        \\put(140,55){\\makebox(0,0){1}}\n                                        \\put(90,5){\\makebox(0,0){2}}\n                                        \\put(90,105){\\makebox(0,0){3}}\n\n                                        \\put(60,20){\\vector(1,0){40}}\n                                        \\put(85,28){\\makebox(0,0){$(i)$}}\n                                        \\put(55,25){\\vector(0,1){40}}\n                                        \\put(65,50){\\makebox(0,0){$(ii)$}}\n                                        \\end{picture}\\\\\n                                        $(i) \\; \\; \\;$ first parameter direction of surface.\\\\\n                                        $(ii)$   second parameter direction of surface.\\\\\n                                \\end{center}\n                                $edgeps[dim*i],\\ldots,edgeps[(dim*(i+1)-1]$\n                                will only have any significance if $\\mbox{edgefix}[i]>0$.\n                                \\end{minipg2} \\\\[0.3ex]\n        \\>\\>    {\\fov epsco}\\> - \\>             \\begin{minipg2}\n                                Two numbers differing by a relative amount less than\n                                epsco will in some cases be considered equal. A suitable\n                                value is just above the unit roundoff of the machine.\n                                A reasonable choice might be $10^{-15}$. The\n                                computations are not guaranteed to have relative\n                                accuracy less than epsco.\n                                Not used anymore.\n                                \\end{minipg2} \\\\[0.3ex]\n        \\>\\>    {\\fov optim}\\> - \\>             \\begin{minipg2}\n                                Flag indicating the order in which the data\n                                reduction is to be performed.\n                                \\end{minipg2}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 1$ :\\>\\begin{minipg5}\n                                Remove knots in parameter-direction 1 only.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 2$ : \\>\\begin{minipg5}\n                                Remove knots in parameter-direction 2 only.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 3$ : \\>\\begin{minipg5}\n                                        Remove knots in parameter-direction 1\n                                                and then in parameter-direction 2.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 4$ : \\>\\begin{minipg5}\n                                        Remove knots in parameter-direction 2\n                                                and then in parameter-direction 1.\n                                \\end{minipg5}\\\\[0.3ex]\n        \\>\\>    {\\fov itmax}\\> - \\>     \\begin{minipg2}\n                                Max. no. of iterations.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newsurf}\\> - \\>   \\begin{minipg2}\n                                Pointer to the produced B-spline surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov maxerr}\\> - \\>    \\begin{minipg2}\n                                Array with length dim (dim=geometrical dimension)\n                                allocated outside this routine and\n                                containing an upper bound for the pointwise error in\n                                each of the components of the spline-approximation.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    stat    \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov eps}[3];\\\\\n                \\>\\>    int     \\>      {\\fov edgefix}[4];\\\\\n                \\>\\>    double  \\>      {\\fov edgeps}[12];\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    int     \\>      {\\fov optim};\\\\\n                \\>\\>    int     \\>      {\\fov itmax};\\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov newsurf};\\\\\n                \\>\\>    double  \\>      {\\fov maxerr}[3];\\\\\n                \\>\\>    int     \\>      {\\fov stat};\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1345(\\begin{minipg4}\n                        {\\fov surf}, {\\fov eps}, {\\fov edgefix}, {\\fov edgeps}, {\\fov epsco}, {\\fov optim},\n                        {\\fov itmax}, \\&{\\fov newsurf}, {\\fov maxerr}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1346.tex",
    "content": "\\subsection{Data reduction: Point data as input.}\n\\funclabel{s1346}\n\\begin{minipg1}\n  To compute a tensor-product B-spline approximation of order $(order1,\n  order2)$ to the rectangular array of {\\fov dim}-dimensional points given by\n  points.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1346(\\begin{minipg3}\n                {\\fov points}, {\\fov numpt1}, {\\fov numpt2}, {\\fov dim}, {\\fov typepar}, {\\fov par1}, {\\fov par2}, {\\fov eps}, {\\fov edgefix}, {\\fov edgeps},\n                {\\fov tolshare}, {\\fov epsco}, {\\fov optim}, {\\fov itmax}, {\\fov order1}, {\\fov order2},\n                {\\fov newsurf}, {\\fov maxerr}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n\n                \\>\\>    double  \\>      {\\fov points}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov numpt1};\\\\\n                \\>\\>    int     \\>      {\\fov numpt2};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    int     \\>      {\\fov typepar};\\\\\n                \\>\\>    double  \\>      {\\fov par1}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov par2}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov eps}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov edgefix}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov edgeps}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov tolshare};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    int     \\>      {\\fov optim};\\\\\n                \\>\\>    int     \\>      {\\fov itmax};\\\\\n                \\>\\>    int     \\>      {\\fov order1};\\\\\n                \\>\\>    int     \\>      {\\fov order2};\\\\\n                \\>\\>    SISLSurf        \\>      **{\\fov newsurf};\\\\\n                \\>\\>    double  \\>      {\\fov maxerr}[\\,];\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov points}\\> - \\>    \\begin{minipg2}\n                                Array (length dim*numpt1*numpt2) containing the points\n                                to be approximated.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov numpt1}\\> - \\>    \\begin{minipg2}\n                                The no. of points in first parameter-direction.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov numpt2}\\> - \\>    \\begin{minipg2}\n                                The no. of points in second parameter-direction.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                The no. of components of each input-point. The\n                                approximation will be a parametric surface situated in\n                                the {\\fov dim}-dimensional Euclidean\n                                space (usually 3).\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov typepar}\\> - \\>   \\begin{minipg2}\n                                Flag determining the para\\-meterization of the data\n                                points:\n                                \\end{minipg2} \\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 1$ :\\>       \\begin{minipg5}\n                                                Means accumulated cord-length\n                                                  para\\-meterization.\n                                        \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>\\>      $= 2$ : \\>Uniform parameterization.\\\\\n                \\>\\>\\>\\>\\>      $= 3$ : \\>Parameterization given by par1 and par2.\\\\\n        \\>\\>    {\\fov par1}\\> - \\>      \\begin{minipg2}\n                                Array (length numptl) containing a parameterization in\n                                the first parameter-direction. (Will only be used if\n                                typepar=3).\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov par2}\\> - \\>      \\begin{minipg2}\n                                Array (length numpt2) containing a parameterization in\n                                the second parameter-direction. (Will only be used if\n                                typepar=3).\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov eps}\\> - \\>       \\begin{minipg2}\n                                Array (length dim) containing the max. permissible\n                                deviation of the approximation from the given data\n                                points, in each of the components. More specifically, the\n                                approximation will not deviate more than eps(dim)\n                                from the bilinear\n                                approximation to the data in component no. dim.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov edgefix}\\> - \\>   \\begin{minipg2}\n                                Array (length 4) giving the no. of derivatives to be\n                                kept fixed along each edge of the bilinear interpolant.\n                                The numbering of the edges is the same as for edgeps\n                                below. All the derivatives of\n                                $\\mbox{order}<(\\mbox{edgefix}(i)-1)$ will be\n                                kept fixed along the edge i.\n                                Hence $\\mbox{edgefix}(i)=0$ indicates\n                                that nothing is to be kept fixed along edge $i$. (Used by the\n                                data reduction routine.)\n                                To be kept fixed here means to have error less than\n                                edgeps. In general, it is impossible to remove any knots\n                                and keep an edge completely fixed.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov edgeps}\\> - \\>    \\begin{minipg2}\n                                Array (length dim*4) containing the max. deviation\n                                from the bilinear interpolant which is acceptable along\n                                the edges of the surface.\n                                \\end{minipg2}\\\\[0.3ex]\n                \\>\\>\\>\\>        \\begin{minipg2}\n                                $edgeps[dim*i],\\ldots,edgeps[(dim*(i+1)-1]$\n                                gives the\n                                tolerance along the edge nr. $i$.\n                                $edgeps[dim*i],\\ldots,edgeps[(dim*(i+1)-1]$\n                                will only have any significance if\n                                $\\mbox{edgefix}[i]>0$.\n                                The edge numbers correspond to the\n                                following:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>        \\begin{minipg2}\n                                \\begin{center}\n                                        \\begin{picture}(180,110)(0,0)\n                                        \\put(50,15){\\framebox(80,80)}\n                                        \\put(40,55){\\makebox(0,0){0}}\n                                        \\put(140,55){\\makebox(0,0){1}}\n                                        \\put(90,5){\\makebox(0,0){2}}\n                                        \\put(90,105){\\makebox(0,0){3}}\n\n                                        \\put(60,20){\\vector(1,0){40}}\n                                        \\put(85,28){\\makebox(0,0){$(i)$}}\n                                        \\put(55,25){\\vector(0,1){40}}\n                                        \\put(65,50){\\makebox(0,0){$(ii)$}}\n                                        \\end{picture}\\\\\n                                        $(i) \\; \\; \\;$ first parameter direction of surface.\\\\\n                                        $(ii)$   second parameter direction of surface.\\\\\n                                \\end{center}\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov tolshare}\\> - \\>  \\begin{minipg2}\n                                $0.0 \\leq \\mbox{tolshare} \\leq 1.0$.\n                                Tolshare indicates how the tolerance is to be shared\n                                between the two data-reduction stages. For the linear\n                                reduction, a tolerance of tolshare*eps will be used, while\n                                a tolerance of ($1.0-$tolshare)*eps will be used during the\n                                final data reduction (similarly for\n                                edgeps.)\n                                Use $0\\leq tolshare\\leq 1$, a general\n                                advice is to use a {\\fov tolshare} value\n                                closer to zero than one.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Two numbers differing by a relative amount less\n                                than epsco, will in some cases be considered equal.\n                                A suitable value is just above the unit roundoff of\n                                the computer. The computations are not guaranteed\n                                to have relative accuracy less than\n                                epsco.\n                                Not used anymore.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov optim}\\> - \\>     \\begin{minipg2}\n                                Flag indicating the order in which the data-\n                                reduction is to be performed:\n                                \\end{minipg2}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 1$ :\\>\\begin{minipg5}\n                                Remove knots in parameter-direction 1 only.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 2$ : \\>\\begin{minipg5}\n                                Remove knots in parameter-direction 2 only.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 3$ : \\>\\begin{minipg5}\n                                        Remove knots in parameter-direction 1\n                                                and then in parameter-direction 2.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 4$ : \\>\\begin{minipg5}\n                                        Remove knots in parameter-direction 2\n                                                and then in parameter-direction 1.\n                                \\end{minipg5}\\\\[0.3ex]\n        \\>\\>    {\\fov itmax}\\> - \\>     \\begin{minipg2}\n                                Max. no. of iterations in the data-reduction.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov order1}\\> - \\>    \\begin{minipg2}\n                                The order of the approximation in the first parameter-\n                                direction.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov order2}\\> - \\>    \\begin{minipg2}\n                                The order of the approximation in the second parameter-\n                                direction.\n                                \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newsurf}\\> - \\>           \\begin{minipg2}\n                                Pointer to the B-spline surface produced.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov maxerr}\\> - \\>    \\begin{minipg2}\n                                Array (length dim)\n                                containing the error in the approximation to the data.\n                                This is a guaranteed upper bound on the max. deviation\n                                in each component, between the final approximation\n                                and the bilinear spline-approximation to the original\n                                data.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    double  \\>      {\\fov points}[90];\\\\\n                \\>\\>    int     \\>      {\\fov numpt1} = 5;\\\\\n                \\>\\>    int     \\>      {\\fov numpt2} = 6;\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    int     \\>      {\\fov typepar};\\\\\n                \\>\\>    double  \\>      {\\fov par1}[5];\\\\\n                \\>\\>    double  \\>      {\\fov par2}[6];\\\\\n                \\>\\>    double  \\>      {\\fov eps}[3];\\\\\n                \\>\\>    int     \\>      {\\fov edgefix}[4];\\\\\n                \\>\\>    double  \\>      {\\fov edgeps}[12];\\\\\n                \\>\\>    double  \\>      {\\fov tolshare};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    int     \\>      {\\fov optim};\\\\\n                \\>\\>    int     \\>      {\\fov itmax};\\\\\n                \\>\\>    int     \\>      {\\fov order1};\\\\\n                \\>\\>    int     \\>      {\\fov order2};\\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov newsurf};\\\\\n                \\>\\>    double  \\>      {\\fov maxerr}[3];\\\\\n                \\>\\>    int     \\>      {\\fov stat};\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1346(\\begin{minipg4}\n                {\\fov points}, {\\fov numpt1}, {\\fov numpt2}, {\\fov dim}, {\\fov typepar}, {\\fov par1}, {\\fov par2}, {\\fov eps}, {\\fov edgefix}, {\\fov edgeps},\n                {\\fov tolshare}, {\\fov epsco}, {\\fov optim}, {\\fov itmax}, {\\fov order1}, {\\fov order2},\n                \\linebreak \\&{\\fov newsurf}, {\\fov maxerr}, \\&{\\fov stat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1347.tex",
    "content": "\\subsection{Data reduction: Points and tangents as input.}\n\\funclabel{s1347}\n\\begin{minipg1}\n  To compute a bicubic hermite B-spline approximation to the position and\n  derivative data given by points, tangent1, tangent2 and derive.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1347(\\begin{minipg3}\n        {\\fov points}, {\\fov tangent1}, {\\fov tangent2}, {\\fov derive}, {\\fov numpt1}, {\\fov numpt2}, {\\fov dim},\\linebreak {\\fov typepar}, {\\fov par1},\n        {\\fov par2}, {\\fov eps}, {\\fov edgefix}, {\\fov edgeps}, {\\fov epsco}, {\\fov optim}, {\\fov itmax}, {\\fov newsurf}, {\\fov maxerr},\n                                stat)\n                \\end{minipg3}\\\\[0.3ex]\n\n                \\>\\>    double  \\>      {\\fov points}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov tangent1}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov tangent2}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov derive}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov numpt1};\\\\\n                \\>\\>    int     \\>      {\\fov numpt2};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    int     \\>      {\\fov typepar};\\\\\n                \\>\\>    double  \\>      {\\fov par1}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov par2}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov eps}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov edgefix}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov edgeps}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    int     \\>      {\\fov optim};\\\\\n                \\>\\>    int     \\>      {\\fov itmax};\\\\\n                \\>\\>    SISLSurf        \\>      **{\\fov newsurf};\\\\\n                \\>\\>    double  \\>      {\\fov maxerr}[\\,];\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov points}   \\> - \\> \\begin{minipg2}\n                                Array (length dim*numpt1*numpt2) containing the points to be\n                                approximated.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov tangent1}\\> - \\>  \\begin{minipg2}\n                                Array (length dim*numpt1*numpt2) containing the\n                                derivatives (tangents) at the data-points in the first parameter-\n                                direction.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov tangent2}\\> - \\>  \\begin{minipg2}\n                                Array (length dim*numpt1*numpt2) containing the\n                                derivatives (tangents) at the data-points in the second parameter-\n                                direction.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov derive}\\> - \\>    \\begin{minipg2}\n                                Array (length dim*numpt1*numpt2) containing the cross\n                                (twist) derivatives at the data-points.\n                                \\end{minipg2} \\\\[0.3ex]\n        \\>\\>    {\\fov numpt1}\\> - \\> \\begin{minipg2}\n                                The no. of points in the first parameter-direction.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov numpt2}   \\> - \\> \\begin{minipg2}\n                                The no. of points in the second parameter-direction.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                The no. of components of each input-point. The\n                                approximation will be a parametric surface situated in\n                                the {\\fov dim}-dimensional Euclidean\n                                space (usually 3).\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov typepar}\\> - \\> \\begin{minipg2}\n                                Flag determining the parameterization of the data-\n                                points.\n                                \\end{minipg2} \\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 1$ :\\>       \\begin{minipg5}\n                                                Means accumulated cord-length\n                                                  para\\-meterization.\n                                        \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>\\>      $= 2$ : \\>Uniform parameterization.\\\\\n                \\>\\>\\>\\>\\>      $= 3$ : \\>Parameterization given by par1 and par2.\\\\\n        \\>\\>    {\\fov par1}\\> - \\>      \\begin{minipg2}\n                                Array (length numpt1) containing the parameterization in\n                                the first parameter-direction. (Will only be used if\n                                typepar=3.)\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov par2}\\> - \\>      \\begin{minipg2}\n                                Array (length numpt2) containing the parameterization in the\n                                second parameter direction.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov eps}\\> - \\>               \\begin{minipg2}\n                                Array (length dim) containing the maximum\n                                deviation which is acceptable in each of the dim\n                                components of the surface (except possibly along the\n                                ends).\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov edgefix}\\> - \\>   \\begin{minipg2}\n                                Array (length 4) containing the no. of derivatives to\n                                be kept fixed along each edge of the surface. The\n                                numbering of the edges is the same as for edgeps\n                                below. All the derivatives of\n                                $\\mbox{order}<(\\mbox{edgefix}(i)-1)$ will\n                                be kept fixed along edge no. i.\n                                Hence $\\mbox{edgefix}(i)=0$\n                                indicates that nothing is to be kept fixed along edge\n                                no. $i$. To be kept fixed here means to have error less\n                                than edgeps. In general, it is impossible to  remove\n                                any knots and keep an edge completely fixed.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov edgeps}\\> - \\>    \\begin{minipg2}\n                                Array (length dim*4) containing the max.\n                                deviation which is acceptable along the edges of\n                                the surfaces.\n                                \\end{minipg2}\\\\[0.3ex]\n                \\>\\>\\>\\>        \\begin{minipg2}\n                                $edgeps[dim*i],\\ldots,edgeps[(dim*(i+1)-1]$\n                                gives the\n                                tolerance along the edge nr. $i$.\n                                $edgeps[dim*i],\\ldots,edgeps[(dim*(i+1)-1]$\n                                will only have any significance if\n                                $\\mbox{edgefix}[i]>0$.\n                                The edge numbers correspond to the\n                                following:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>        \\begin{minipg2}\n                                \\begin{center}\n                                        \\begin{picture}(180,110)(0,0)\n                                        \\put(50,15){\\framebox(80,80)}\n                                        \\put(40,55){\\makebox(0,0){0}}\n                                        \\put(140,55){\\makebox(0,0){1}}\n                                        \\put(90,5){\\makebox(0,0){2}}\n                                        \\put(90,105){\\makebox(0,0){3}}\n\n                                        \\put(60,20){\\vector(1,0){40}}\n                                        \\put(85,28){\\makebox(0,0){$(i)$}}\n                                        \\put(55,25){\\vector(0,1){40}}\n                                        \\put(65,50){\\makebox(0,0){$(ii)$}}\n                                        \\end{picture}\\\\\n                                        $(i) \\; \\; \\;$ first parameter direction of surface.\\\\\n                                        $(ii)$   second parameter direction of surface.\\\\\n                                \\end{center}\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Two numbers differing by a relative amount less\n                                than epsco will in some cases be considered equal.\n                                A suitable value is just above the unit roundoff of\n                                the machine.\n                                A reasonable choice might be $10^{-15}$.\n                                The computations are not guaranteed to\n                                have relative accuracy less than epsco.\n                                Not used anymore.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov optim}\\> - \\>     \\begin{minipg2}\n                                Flag indicating the order in which the data-\n                                reduction is to be performed:\n                                \\end{minipg2}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 1$ :\\>\\begin{minipg5}\n                                Remove knots in parameter-direction 1 only.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 2$ : \\>\\begin{minipg5}\n                                Remove knots in parameter-direction 2 only.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 3$ : \\>\\begin{minipg5}\n                                        Remove knots in parameter-direction 1\n                                                and then in parameter-direction 2.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 4$ : \\>\\begin{minipg5}\n                                        Remove knots in parameter-direction 2\n                                                and then in parameter-direction 1.\n                                \\end{minipg5}\\\\[0.3ex]\n        \\>\\>    {\\fov itmax}\\> - \\>     \\begin{minipg2}\n                                Max. no. of iterations.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newsurf}\\> - \\>   \\begin{minipg2}\n                                Pointer to the produced B-spline surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov maxerr}\\> - \\>    \\begin{minipg2}\n                                Array (length dim)\n                                containing the error in the approximation to the data.\n                                This is a guaranteed upper bound on the max. deviation\n                                in each component, between the final approximation\n                                and the bicubic Hermite spline-approximation to the original data.\n\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    double  \\>      {\\fov points}[90];\\\\\n                \\>\\>    double  \\>      {\\fov tangent1}[90];\\\\\n                \\>\\>    double  \\>      {\\fov tangent2}[90];\\\\\n                \\>\\>    double  \\>      {\\fov derive}[90];\\\\\n                \\>\\>    int     \\>      {\\fov numpt1} = 5;\\\\\n                \\>\\>    int     \\>      {\\fov numpt2} = 6;\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    int     \\>      {\\fov typepar};\\\\\n                \\>\\>    double  \\>      {\\fov par1}[5];\\\\\n                \\>\\>    double  \\>      {\\fov par2}[6];\\\\\n                \\>\\>    double  \\>      {\\fov eps}[3];\\\\\n                \\>\\>    int     \\>      {\\fov edgefix}[4];\\\\\n                \\>\\>    double  \\>      {\\fov edgeps}[12];\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    int     \\>      {\\fov optim};\\\\\n                \\>\\>    int     \\>      {\\fov itmax};\\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov newsurf};\\\\\n                \\>\\>    double  \\>      {\\fov maxerr}[3];\\\\\n                \\>\\>    int     \\>      {\\fov stat};\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1347(\\begin{minipg4}\n                {\\fov points}, {\\fov tangent1}, {\\fov tangent2}, {\\fov derive}, {\\fov numpt1}, {\\fov numpt2}, {\\fov dim},\n                \\linebreak {\\fov typepar}, {\\fov par1},\n                {\\fov par2}, {\\fov eps}, {\\fov edgefix}, {\\fov edgeps}, {\\fov epsco}, {\\fov optim}, {\\fov itmax}, \\&{\\fov newsurf}, {\\fov maxerr},\n                        \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1348.tex",
    "content": "\\subsection{Degree reduction: B-spline surface as input}\n\\funclabel{s1348}\n\\begin{minipg1}\n  To compute a cubic tensor-product B-spline approximation to a given tensor\n  product B-spline (i.e.\\ NOT rational) surface of arbitrary order, with\n  error less than {\\fov eps}[i], $i=0,1,2$ in each of the {\\fov dim} components.\n  The output is represented as a B-spline surface.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1348(\\begin{minipg3}\n                {\\fov surf}, {\\fov eps}, {\\fov edgefix}, {\\fov edgeps}, {\\fov epsco}, {\\fov optim}, {\\fov itmax}, {\\fov newsurf}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov eps}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov edgefix}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov edgeps}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    int     \\>      {\\fov optim};\\\\\n                \\>\\>    int     \\>      {\\fov itmax};\\\\\n                \\>\\>    SISLSurf        \\>      **{\\fov newsurf};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the original B-spline surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov eps}\\> - \\>       \\begin{minipg2}\n                                Array (length {\\fov dim}) containing the maximum\n                                deviation which is acceptable in each of the dim\n                                components of the surface (except possibly along the\n                                edges).\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov edgefix}\\> - \\>   \\begin{minipg2}\n                                Array (length 4) containing the no. of derivatives to\n                                be kept fixed along each edge of the surface. The\n                                numbering of the edges is the same as for edgeps\n                                below. All the derivatives of\n                                $\\mbox{order} < \\mbox{edgefix}(i)-1$ will\n                                be kept \"fixed\" along edge no. $i$.\n                                Hence $\\mbox{edgefix}(i)=0$\n                                indicates that nothing is to be kept \"fixed\" along edge\n                                no. $i$. To be kept \"fixed\" here means to have error less\n                                than edgeps. In general, it is impossible to  remove\n                                any knots and keep an edge completely fixed.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov edgeps}\\> - \\>    \\begin{minipg2}\n                                Array (length dim*4) containing the max.\n                                deviation which is acceptable along the edges of\n                                the surfaces.\n                                \\end{minipg2} \\\\[0.3ex]\n                \\>\\>\\>\\>        \\begin{minipg2}\n                                $edgeps[dim*i],\\ldots,edgeps[(dim*(i+1)-1]$\n                                gives the\n                                tolerance along the edge nr. $i$.\n                                $edgeps[dim*i],\\ldots,edgeps[(dim*(i+1)-1]$\n                                will only have any significance if\n                                $\\mbox{edgefix}[i]>0$.\n                                The edge numbers correspond to the\n                                following:\n                                \\end{minipg2}\\\\\n\\newpagetabs\n                \\>\\>\\>\\>        \\begin{minipg2}\n                                \\begin{center}\n                                        \\begin{picture}(180,110)(0,0)\n                                        \\put(50,15){\\framebox(80,80)}\n                                        \\put(40,55){\\makebox(0,0){0}}\n                                        \\put(140,55){\\makebox(0,0){1}}\n                                        \\put(90,5){\\makebox(0,0){2}}\n                                        \\put(90,105){\\makebox(0,0){3}}\n\n                                        \\put(60,20){\\vector(1,0){40}}\n                                        \\put(85,28){\\makebox(0,0){$(i)$}}\n                                        \\put(55,25){\\vector(0,1){40}}\n                                        \\put(65,50){\\makebox(0,0){$(ii)$}}\n                                        \\end{picture}\\\\\n                                        $(i) \\; \\; \\;$ first parameter direction of surface.\\\\\n                                        $(ii)$   second parameter direction of surface.\\\\\n                                \\end{center}\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov epsco}\\> - \\>      \\begin{minipg2}\n                                Two numbers differing by a relative amount less\n                                than epsco will in some cases be considered equal.\n                                A suitable value is just above the unit roundoff of\n                                the machine.\n                                A reasonable choice might be $10^{-15}$. The\n                                computations are not guaranteed to have relative\n                                accuracy less than epsco.\n                                Not used anymore.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov optim}\\> - \\>             \\begin{minipg2}\n                                Flag indicating the order in which the data-\n                                reduction is to be performed.\n                                \\end{minipg2}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 1$ :\\>\\begin{minipg5}\n                                Remove knots in parameter-direction 1 only.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 2$ : \\>\\begin{minipg5}\n                                Remove knots in parameter-direction 2 only.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 3$ : \\>\\begin{minipg5}\n                                        Remove knots in parameter-direction 1\n                                                and then in parameter-direction 2.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 4$ : \\>\\begin{minipg5}\n                                        Remove knots in parameter-direction 2\n                                                and then in parameter-direction 1.\n                                \\end{minipg5}\\\\[0.3ex]\n        \\>\\>    {\\fov itmax}\\> - \\>     \\begin{minipg2}\n                                Max. no. of iterations.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newsurf}\\> - \\>   \\begin{minipg2}\n                                Pointer to the produced B-spline surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov eps}[3];\\\\\n                \\>\\>    int     \\>      {\\fov edgefix}[4];\\\\\n                \\>\\>    double  \\>      {\\fov edgeps}[12];\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    int     \\>      {\\fov optim};\\\\\n                \\>\\>    int     \\>      {\\fov itmax};\\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov newsurf};\\\\\n                \\>\\>    int     \\>      {\\fov stat};\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1348(\\begin{minipg4}\n                {\\fov surf}, {\\fov eps}, {\\fov edgefix}, {\\fov edgeps}, {\\fov epsco}, {\\fov optim}, {\\fov itmax}, \\&{\\fov newsurf}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1356.tex",
    "content": "\\subsection{Compute a curve interpolating a set of points,\n\\mbox{automatic} parameterization.}\n\\funclabel{s1356}\n\\begin{minipg1}\nCompute a curve interpolating a set of points.  The points\ncan be assigned a tangent (derivative).  The parameterization of the\ncurve will be generated and the curve can be open, closed non-periodic\nor periodic.  If end-conditions are conflicting, the condition closed\ncurve rules out other end conditions.\nThe output will be represented as a B-spline curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1356(\\begin{minipg3}\n          {\\fov epoint}, {\\fov inbpnt}, {\\fov idim}, {\\fov nptyp}, {\\fov icnsta}, {\\fov icnend}, {\\fov iopen}, {\\fov ik}, {\\fov astpar},\n          {\\fov cendpar}, {\\fov rc}, {\\fov gpar}, {\\fov jnbpar}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    double \\>  {\\fov epoint}[\\,];\\\\\n        \\>\\>    int    \\>  {\\fov inbpnt};\\\\\n        \\>\\>    int    \\>  {\\fov idim};\\\\\n        \\>\\>    int    \\>  {\\fov nptyp}[\\,];\\\\\n        \\>\\>    int    \\>  {\\fov icnsta};\\\\\n        \\>\\>    int    \\>  {\\fov icnend};\\\\\n        \\>\\>    int    \\>  {\\fov iopen};\\\\\n        \\>\\>    int    \\>  {\\fov ik};\\\\\n        \\>\\>    double \\>  {\\fov astpar};\\\\\n        \\>\\>    double \\>  *{\\fov cendpar};\\\\\n        \\>\\>    SISLCurve \\> **{\\fov rc};\\\\\n        \\>\\>    double \\>  **{\\fov gpar};\\\\\n        \\>\\>    int    \\>  *{\\fov jnbpar};\\\\\n        \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov epoint}\\> - \\>\n        \\begin{minipg2}\n          Array (of length $idim\\times inbpnt$) containing the\n          points/\\-derivatives to be interpolated.\n        \\end{minipg2}\\\\\n        \\>\\>    {\\fov inbpnt}\\> - \\>\n        \\begin{minipg2}\n          No. of points/\\-derivatives in the {\\fov epoint} array.\n        \\end{minipg2}\\\\\n        \\>\\>    {\\fov idim}\\> - \\>\n        The dimension of the space in which the points lie.\\\\\n        \\>\\>    {\\fov nptyp}\\> - \\> \\begin{minipg2}\n                  Array (length {\\fov inbpnt}) containing type indicator for\n                  points/\\-derivatives/\\-second-derivatives:\n                \\end{minipg2}\\\\\n                \\>\\>\\>\\> $=1$\\>: Ordinary point.\\\\\n                \\>\\>\\>\\> $=2$\\>:\n                \\begin{minipg5}\n                  Knuckle point.  (Is treated as an ordinary point.)\n                \\end{minipg5}\\\\\n                \\>\\>\\>\\> $=3$\\>: Derivative to next point.\\\\\n                \\>\\>\\>\\> $=4$\\>: Derivative to prior point.\\\\\n                \\>\\>\\>\\> ($=5$\\>: Second-derivative to next point.)\\\\\n                \\>\\>\\>\\> ($=6$\\>: Second derivative to prior point.)\\\\\n                \\>\\>\\>\\> $=13$\\>: Point of tangent to next point.\\\\\n                \\>\\>\\>\\> $=14$\\>: Point of tangent to prior  point.\\\\\n\\newpagetabs\n        \\>\\>    {\\fov icnsta}\\> - \\>\n                Additional condition at the start of the curve:\\\\\n                  \\>\\>\\>\\> $=0$\\>: No additional condition.\\\\\n                  \\>\\>\\>\\> $=1$\\>: Zero curvature at start.\\\\\n        \\>\\>    {\\fov icnend}\\> - \\>\n                Additional condition at the end of the curve:\\\\\n                  \\>\\>\\>\\> $=0$\\>: No additional condition.\\\\\n                  \\>\\>\\>\\> $=1$\\>: Zero curvature at end.\\\\\n        \\>\\>    {\\fov iopen}\\> - \\>\n                Flag telling if the curve should be open or closed:\\\\\n                  \\>\\>\\>\\> $=1$\\>: Open curve.\\\\\n                  \\>\\>\\>\\> $=0$\\>: Closed, non-periodic curve.\\\\\n                  \\>\\>\\>\\> $=-1$\\>: Periodic (and closed) curve.\\\\\n        \\>\\>    {\\fov ik}\\> - \\> The order of the spline curve to be produced.\\\\\n        \\>\\>    {\\fov astpar}\\> - \\>\n        \\begin{minipg2}\n          Parameter value to be used at the start of the curve.\n        \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov cendpar}\\> - \\>\n        \\begin{minipg2}\n          Parameter value used at the end of the curve.\n        \\end{minipg2}\\\\\n        \\>\\>    {\\fov rc}\\> - \\> Pointer to output B-spline curve.\\\\\n        \\>\\>    {\\fov gpar}\\> - \\>\n        \\begin{minipg2}\n          Pointer to the parameter values of the points in the\n          curve. Represented only once, although derivatives and\n          second-derivatives will have the same parameter value as the\n          points.\n        \\end{minipg2}\\\\\n        \\>\\>    {\\fov jnbpar}\\> - \\> No. of unique parameter values.\\\\\n        \\>\\>    {\\fov jstat}\\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n\\\\ %\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    double \\>  {\\fov epoint}[30];\\\\\n        \\>\\>    int    \\>  {\\fov inbpnt} = 10;\\\\\n        \\>\\>    int    \\>  {\\fov idim} = 3;\\\\\n        \\>\\>    int    \\>  {\\fov nptyp}[10];\\\\\n        \\>\\>    int    \\>  {\\fov icnsta} = 0;\\\\\n        \\>\\>    int    \\>  {\\fov icnend} = 0;\\\\\n        \\>\\>    int    \\>  {\\fov iopen} = 1;\\\\\n        \\>\\>    int    \\>  {\\fov ik} = 4;\\\\\n        \\>\\>    double \\>  {\\fov astpar} = 0.0;\\\\\n        \\>\\>    double \\>  {\\fov cendpar} = 0.0;\\\\\n        \\>\\>    SISLCurve \\> *{\\fov rc} = NULL;\\\\\n        \\>\\>    double \\>  *{\\fov gpar} = NULL;\\\\\n        \\>\\>    int    \\>  {\\fov jnbpar} = 0;\\\\\n        \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1356(\\begin{minipg4}\n          {\\fov epoint}, {\\fov inbpnt}, {\\fov idim}, {\\fov nptyp}, {\\fov icnsta}, {\\fov icnend}, {\\fov iopen}, {\\fov ik}, {\\fov astpar},\n          \\&{\\fov cendpar}, \\&{\\fov rc}, \\&{\\fov gpar}, \\&{\\fov jnbpar}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1357.tex",
    "content": "\\subsection{Compute a curve interpolating a set of points,\nparameter\\-ization as input.}\n\\funclabel{s1357}\n\\begin{minipg1}\nCompute a curve interpolating a set of points.  The points\ncan be assigned a tangent (derivative).  The curve can be open, closed\nor periodic. If end-conditions are conflicting, the condition closed\ncurve rules out other end conditions. The parameterization is given by\nthe array {\\fov epar}.\nThe output will be represented as a B-spline curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1357(\\begin{minipg3}\n        {\\fov epoint}, {\\fov inbpnt}, {\\fov idim}, {\\fov ntype}, {\\fov epar}, {\\fov icnsta}, {\\fov icnend}, {\\fov iopen}, {\\fov ik}, {\\fov astpar},\n        {\\fov cendpar}, {\\fov rc}, {\\fov gpar}, {\\fov jnbpar}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    double \\>  {\\fov epoint}[\\,];\\\\\n        \\>\\>    int    \\>  {\\fov inbpnt};\\\\\n        \\>\\>    int    \\>  {\\fov idim};\\\\\n        \\>\\>    int    \\>  {\\fov ntype}[\\,];\\\\\n        \\>\\>    double \\>  {\\fov epar}[\\,];\\\\\n        \\>\\>    int    \\>  {\\fov icnsta};\\\\\n        \\>\\>    int    \\>  {\\fov icnend};\\\\\n        \\>\\>    int    \\>  {\\fov iopen};\\\\\n        \\>\\>    int    \\>  {\\fov ik};\\\\\n        \\>\\>    double \\>  {\\fov astpar};\\\\\n        \\>\\>    double \\>  *{\\fov cendpar};\\\\\n        \\>\\>    SISLCurve \\> **{\\fov rc};\\\\\n        \\>\\>    double \\>  **{\\fov gpar};\\\\\n        \\>\\>    int    \\>  *{\\fov jnbpar};\\\\\n        \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov epoint}\\> - \\>\n        \\begin{minipg2}\n          Array (length $idim\\times inbpnt$) containing the\n          points/\\-derivatives to be interpolated.\n        \\end{minipg2}\\\\\n        \\>\\>    {\\fov inbpnt}\\> - \\>\n        \\begin{minipg2}\n          No. of points/\\-derivatives in the {\\fov epoint} array.\n        \\end{minipg2}\\\\\n        \\>\\>    {\\fov idim}\\> - \\>\n        The dimension of the space in which the points lie.\\\\\n        \\>\\>    {\\fov ntype}\\> - \\> \\begin{minipg2}\n                  Array (length {\\fov inbpnt}) containing type indicator for\n                  points/\\-derivatives/\\-second-derivatives:\n                \\end{minipg2}\\\\\n                \\>\\>\\>\\> $=1$\\>: Ordinary point.\\\\\n                \\>\\>\\>\\> $=2$\\>:\n                \\begin{minipg5}\n                  Knuckle point.  (Is treated as an ordinary point.)\n                \\end{minipg5}\\\\\n                \\>\\>\\>\\> $=3$\\>: Derivative to next point.\\\\\n                \\>\\>\\>\\> $=4$\\>: Derivative to prior point.\\\\\n                \\>\\>\\>\\> ($=5$\\>: Second-derivative to next point.)\\\\\n                \\>\\>\\>\\> ($=6$\\>: Second derivative to prior point.)\\\\\n                \\>\\>\\>\\> $=13$\\>: Point of tangent to next point.\\\\\n                \\>\\>\\>\\> $=14$\\>: Point of tangent to prior  point.\\\\\n        \\>\\>    {\\fov epar}\\> - \\>\n        \\begin{minipg2}\n          Array containing the wanted parameterization. Only parameter\n          values corresponding to position points are given.\n          For closed curves, one additional parameter value\n          must be specified. The last entry contains\n          the parametrization of the repeated start point.\n          (if the end point is equal to the start point of\n          the interpolation the length of the array should\n          be equal to inpt1 also in the closed case).\n        \\end{minipg2}\\\\\n        \\>\\>    {\\fov icnsta}\\> - \\>\n                Additional condition at the start of the curve:\\\\\n                  \\>\\>\\>\\> $=0$\\>: No additional condition.\\\\\n                  \\>\\>\\>\\> $=1$\\>: Zero curvature at start.\\\\\n        \\>\\>    {\\fov icnend}\\> - \\>\n                Additional condition at the end of the curve:\\\\\n                  \\>\\>\\>\\> $=0$\\>: No additional condition.\\\\\n                  \\>\\>\\>\\> $=1$\\>: Zero curvature at end.\\\\\n        \\>\\>    {\\fov iopen}\\> - \\>\n                Flag telling if the curve should be open or closed:\\\\\n                  \\>\\>\\>\\> $=1$\\>: The curve should be open.\\\\\n                  \\>\\>\\>\\> $=0$\\>: The curve should be closed.\\\\\n                  \\>\\>\\>\\> $=-1$\\>: The curve should be closed and periodic.\\\\\n        \\>\\>    {\\fov ik}\\> - \\> The order of the spline curve to be produced.\\\\\n        \\>\\>    {\\fov astpar}\\> - \\>\n        \\begin{minipg2}\n          Parameter value to be used at the start of the curve.\n        \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov cendpar}\\> - \\>\n        \\begin{minipg2}\n          Parameter value used at the end of the curve.\n        \\end{minipg2}\\\\\n        \\>\\>    {\\fov rc}\\> - \\> Pointer to the output B-spline curve.\\\\\n        \\>\\>    {\\fov gpar}\\> - \\>\n        \\begin{minipg2}\n          Pointer to the parameter values of the points in the\n          curve. Represented only once, although derivatives and\n          second-derivatives will have the same parameter value as the\n          points.\n        \\end{minipg2}\\\\\n        \\>\\>    {\\fov jnbpar}\\> - \\>  No, of unique parameter values.\\\\\n        \\>\\>    {\\fov jstat}\\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    double \\>  {\\fov epoint}[30];\\\\\n        \\>\\>    int    \\>  {\\fov inbpnt} = 10;\\\\\n        \\>\\>    int    \\>  {\\fov idim} = 3;\\\\\n        \\>\\>    int    \\>  {\\fov ntype}[10];\\\\\n        \\>\\>    double \\>  {\\fov epar}[10];\\\\\n        \\>\\>    int    \\>  {\\fov icnsta} = 0;\\\\\n        \\>\\>    int    \\>  {\\fov icnend} = 0;\\\\\n        \\>\\>    int    \\>  {\\fov iopen} = 0;\\\\\n        \\>\\>    int    \\>  {\\fov ik} = 4;\\\\\n        \\>\\>    double \\>  {\\fov astpar} = 0.0;\\\\\n        \\>\\>    double \\>  {\\fov cendpar};\\\\\n        \\>\\>    SISLCurve \\> *{\\fov rc} = NULL;\\\\\n        \\>\\>    double \\>  *{\\fov gpar} = NULL;\\\\\n        \\>\\>    int    \\>  {\\fov jnbpar};\\\\\n        \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1357(\\begin{minipg4}\n          {\\fov epoint}, {\\fov inbpnt}, {\\fov idim}, {\\fov ntype}, {\\fov epar}, {\\fov icnsta}, {\\fov icnend}, {\\fov iopen}, {\\fov ik}, {\\fov astpar},\n          \\&{\\fov cendpar}, \\&{\\fov rc}, \\&{\\fov gpar}, \\&{\\fov jnbpar}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1358.tex",
    "content": "\\subsection{Spline interpolation, parameterization as input.}\n\\funclabel{s1358}\n\\begin{minipg1}\nTo calculate a B-spline curve interpolating a set of points. The\npoints can be assigned a tangent (derivative). The curve can be\nclosed or open. If end-conditions are conflicting, the condition\nclosed curve rules out other end conditions. The parameterization\nis given by the array par.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1358(\\begin{minipg3}\n        {\\fov point}, {\\fov numpt}, {\\fov dim}, {\\fov typept}, {\\fov par}, {\\fov startcon}, {\\fov endcon}, {\\fov open},\n        {\\fov order}, {\\fov startpar}, {\\fov endpar}, {\\fov curve}, {\\fov pointpar}, {\\fov numptpar}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    double  \\>      {\\fov point}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov numpt};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov typept}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov par}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov startcon};\\\\\n                \\>\\>    int     \\>      {\\fov endcon};\\\\\n                \\>\\>    int     \\>      {\\fov open};\\\\\n                \\>\\>    int     \\>      {\\fov order};\\\\\n                \\>\\>    double  \\>      {\\fov startpar};\\\\\n                \\>\\>    double  \\>      *{\\fov endpar};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov curve};\\\\\n                \\>\\>    double  \\>      **{\\fov pointpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numptpar};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov point}    \\> - \\> \\begin{minipg2}\n                                Array (length dim*numpt) containing the\n                                points/derivatives to be interpolated.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov numpt}    \\> - \\>\n                                No. of points/derivatives in the\n                                point array.\n                                \\\\\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                The dimension of the space in which\n                                the points lie.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov typept}   \\> - \\> \\begin{minipg2}\n                                Array (length numpt) containing type\n                                indicator for points/derivatives:\n                                \\end{minipg2} \\\\[0.3ex]\n                \\>\\>\\>\\>\\>      1 : Ordinary point.\\\\\n                \\>\\>\\>\\>\\>      3 : Derivative to next point.\\\\\n                \\>\\>\\>\\>\\>      4 : Derivative to prior point.\\\\\n                \\>\\>\\>\\>\\>      13 : Start-point of tangent to next point.\\\\\n                \\>\\>\\>\\>\\>      14 : End-point of tangent to prior point.\\\\\n        \\>\\>    {\\fov par}      \\> - \\> \\begin{minipg2}\n                                Array containing the wanted parameterization. Only points will be given a value.\n\\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov startcon} \\> - \\> \\begin{minipg2}\n                                Additional condition at the start\n                                of the curve:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 :     No additional condition.\\\\\n                \\>\\>\\>\\>\\>      1 :     Zero curvature at start.\\\\\n        \\>\\>    {\\fov endcon}   \\> - \\> \\begin{minipg2}\n                                Additional condition at the end\n                                of the curve:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 :     No additional condition.\\\\\n                \\>\\>\\>\\>\\>      1 :     Zero curvature at end.\\\\\n        \\>\\>    {\\fov open}     \\> - \\> Open or closed curve:\\\\\n                \\>\\>\\>\\>\\>      0 :     Closed curve.\\\\\n                \\>\\>\\>\\>\\>      1 :     Open curve.\\\\\n        \\>\\>    {\\fov order}    \\> - \\> \\begin{minipg2}\n                                The order of the B-spline curve\n                                to be produced.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov startpar} \\> - \\>\n                                Not used\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov endpar}   \\> - \\> \\begin{minipg2}\n                                Parameter-value used at the end\n                                of the curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to output-curve\\\\\n        \\>\\>    {\\fov pointpar} \\> - \\> \\begin{minipg2}\n                                Pointer to the parameter-values of\n                                the interpolation conditions. Represented only once, although\n                                derivatives\n                                will have the same\n                                parameter-value as the points.\n                                \\end{minipg2} \\\\[0.3ex]\n        \\>\\>    {\\fov numptpar} \\> - \\> \\begin{minipg2}\n                                No. of different parameter-values.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    double  \\>      {\\fov point}[30];\\\\\n                \\>\\>    int     \\>      {\\fov numpt} = 10;\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov typept}[10];\\\\\n                \\>\\>    double  \\>      {\\fov par}[10];\\\\\n                \\>\\>    int     \\>      {\\fov startcon};\\\\\n                \\>\\>    int     \\>      {\\fov endcon};\\\\\n                \\>\\>    int     \\>      {\\fov open};\\\\\n                \\>\\>    int     \\>      {\\fov order};\\\\\n                \\>\\>    double  \\>      {\\fov startpar};\\\\\n                \\>\\>    double  \\>      {\\fov endpar};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      *{\\fov pointpar};\\\\\n                \\>\\>    int     \\>      {\\fov numptpar};\\\\\n                \\>\\>    int     \\>      {\\fov stat};\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1358(\\begin{minipg4}point, numpt, dim, typept,\n                        {\\fov par}, {\\fov startcon}, {\\fov endcon}, {\\fov open}, {\\fov order}, {\\fov startpar},\n                        \\&{\\fov endpar}, \\&{\\fov curve}, \\&{\\fov pointpar}, \\&{\\fov numptpar}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1360.tex",
    "content": "\\subsection{Approximate the offset of a curve with a curve.}\n\\funclabel{s1360}\n\\begin{minipg1}\n  To create a approximation of the offset to a curve within a\n  tolerance.\n  The output will be represented as a B-spline curve.\\\\\n  With an offset of zero, this routine can be used to approximate any\n  NURBS curve, within a tolerance, with a (non-rational) B-spline curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1360(\\begin{minipg3}\n        {\\fov oldcurve}, {\\fov offset}, {\\fov epsge}, {\\fov norm}, {\\fov max}, {\\fov dim}, {\\fov newcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov oldcurve};\\\\\n                \\>\\>    double  \\>      {\\fov offset};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      {\\fov norm}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov max};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov oldcurve}\\> - \\> The input curve.\\\\\n        \\>\\>    {\\fov offset}   \\> - \\> \\begin{minipg2}\n                        The offset distance. If dim=2, a positive sign on\n                        this value put the offset on the side of the positive\n                        normal vector, and a negative sign puts the offset on\n                        the negative normal vector. If dim=3, the offset direction is\n                        determined by the cross product of the tangent\n                        vector and the normal vector. The offset distance is\n                        multiplied by this cross product.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epsge}    \\> - \\> \\begin{minipg2}\n                        Maximal deviation allowed between the true offset\n                        curve and the approximated offset curve.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov norm}     \\> - \\> Vector used in 3D calculations.\\\\\n        \\>\\>    {\\fov max}      \\> - \\> \\begin{minipg2}\n                        Maximal step length. It is neglected if\n                        max$\\leq$epsge. If max=0.0, then a maximal step\n                        equal to the longest box side of the curve is used.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov dim}      \\> - \\>The dimension of the space must be 2 or 3.\\\\\n\\\\\nNOTE\\\\\n\\>\\begin{minipg6}\n  If the vector norm and the curve tangent are parallel at some point,\n  then the curve produced will not be an offset at this point, and it\n  will probably move from one side of the input curve to the other side.\n\\end{minipg6}\\\\\n\\newpagetabs\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newcurve}\\> - \\> \\begin{minipg2}\n                        Pointer to the B-spline curve\n                        approximating the offset curve.\n                                       \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages.\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : Warning.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Ok.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov oldcurve}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov offset}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov epsge}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov norm}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov max} = 0.0;\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1360(\\begin{minipg4}\n        {\\fov oldcurve}, {\\fov offset}, {\\fov epsge}, {\\fov norm}, {\\fov max}, {\\fov dim}, \\&{\\fov newcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1363.tex",
    "content": "\\section{Pick the Parameter Range of a Curve}\n\\funclabel{s1363}\n\\begin{minipg1}\n  To pick the parameter range of a curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1363(\\begin{minipg3}\n        {\\fov curve}, {\\fov startpar}, {\\fov endpar}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      *{\\fov startpar};\\\\\n                \\>\\>    double  \\>      *{\\fov endpar};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> The curve.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov startpar}\\> - \\>  Start of the parameter interval of the curve.\\\\\n        \\>\\>    {\\fov endpar}   \\> - \\> End of the parameter interval of the curve.\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $= 1$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov startpar};\\\\\n                \\>\\>    double  \\>      {\\fov endpar};\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1363(\\begin{minipg4}\n                {\\fov curve}, \\&{\\fov startpar}, \\&{\\fov endpar}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1364.tex",
    "content": "\\section{Check if a Curve is Closed}\n\\funclabel{s1364}\n\\begin{minipg1}\n  To check if a curve is closed, i.e.\\ test if the distance between the\n  end points of the curve is less than a given tolerance.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1364(\\begin{minipg3}\n        {\\fov curve}, {\\fov epsge}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> The curve.\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> Geometric tolerance.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $= 2$   : Curve is closed and periodic.\\\\\n                \\>\\>\\>\\>\\>              $= 1$   : Curve is closed.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Curve is open.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1364(\\begin{minipg4}\n                {\\fov curve}, {\\fov epsge}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1365.tex",
    "content": "\\subsection{Compute a surface approximating the offset of a surface.}\n\\funclabel{s1365}\n\\begin{minipg1}\n  Create a surface approximating the offset of a surface.\n  The output is represented as a B-spline surface.\\\\\n  With an offset of zero, this routine can be used to approximate any\n  NURBS (rational) surface with a B-spline (non-rational) surface.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1365(\\begin{minipg3}\n          {\\fov ps}, {\\fov aoffset}, {\\fov aepsge}, {\\fov amax}, {\\fov idim}, {\\fov rs}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf \\> *{\\fov ps};\\\\\n        \\>\\>    double   \\> {\\fov aoffset};\\\\\n        \\>\\>    double   \\> {\\fov aepsge};\\\\\n        \\>\\>    double   \\> {\\fov amax};\\\\\n        \\>\\>    int      \\> {\\fov idim};\\\\\n        \\>\\>    SISLSurf \\> **{\\fov rs};\\\\\n        \\>\\>    int      \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov ps} \\> - \\> The input surface.\\\\\n        \\>\\>    {\\fov aoffset} \\> - \\>\n        \\begin{minipg2}\n          The offset distance.\n          The offset direction is determined by the normalized cross\n          product of the tangent vector and the anorm vector.\n          The offset distance is multiplied by this vector.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov aepsge} \\> - \\>\n        \\begin{minipg2}\n          Maximal deviation allowed between true offset surface\n          and the approximated offset surface.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov amax} \\> - \\>\n        \\begin{minipg2}\n          Maximal stepping length. Is negleceted if $amax\\leq aepsge$.\n          If $amax=0$ then a maximal step length of the longest box side\n          is used.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov idim} \\> - \\> The dimension of the space (idim = 3 is required).\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rs} \\> - \\>\n        \\begin{minipg2}\n          The approximated offset represented as\n          a \\mbox{B-spline} surface.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf \\> *{\\fov ps}; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> {\\fov aoffset}; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> {\\fov aepsge} = 0.001;\\\\\n        \\>\\>    double   \\> {\\fov amax} = 0;\\\\\n        \\>\\>    int      \\> {\\fov idim} = 3;\\\\\n        \\>\\>    SISLSurf \\> *{\\fov rs} = NULL;\\\\\n        \\>\\>    int      \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1365(\\begin{minipg4}\n          {\\fov ps}, {\\fov aoffset}, {\\fov aepsge}, {\\fov amax}, {\\fov idim}, \\&{\\fov rs}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1369.tex",
    "content": "\\subsection{Find the topology for the intersections between a spline surface and a \\mbox{torus}.}\n\\funclabel{s1369}\n\\begin{minipg1}\n  Find all intersections between a surface and a torus.\n  Intersection curves are described by guide points.\n  To produce the intersection curves use s1318() described on page \\pageref{s1318}.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1369(\\begin{minipg3}\n                {\\fov surf}, {\\fov centre}, {\\fov normal}, {\\fov cendist}, {\\fov radius}, {\\fov dim}, {\\fov epsco},\n                {\\fov epsge}, {\\fov \\linebreak}\n                {\\fov numintpt}, {\\fov pointpar}, {\\fov numintcr}, {\\fov intcurves}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov centre}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov normal}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov cendist};\\\\\n                \\>\\>    double  \\>      {\\fov radius};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov pointpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcr};\\\\\n                \\>\\>    SISLIntcurve\\>  ***{\\fov intcurves};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov centre}\\> - \\>    \\begin{minipg2}\n                                The centre of the torus (lying in the symmetry\n                                plane)\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov normal}\\> - \\>    \\begin{minipg2}\n                                Normal to the symmetry plane.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov cendist}\\> - \\>   \\begin{minipg2}\n                                Distance from centre to centre circle of the torus.\n                                \\end{minipg2} \\\\\n        \\>\\>    {\\fov radius}\\> - \\>    \\begin{minipg2}\n                                The radius of the torus surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov di}m      \\> - \\> \\begin{minipg2}\n                                Dimension of the space in which the torus lies. dim\n                                should be equal to two or three.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2}\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  \\begin{minipg2}\n                                Number of single intersection points.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov pointpar}\\> - \\>  \\begin{minipg2}\n                                Array containing the parameter values of the single\n                                intersection points in the parameter plane of the\n                                surface. The points lie in sequence. Intersection curves\n                                are stored in intcurves.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcr}\\> - \\>  \\begin{minipg2}\n                                Number of intersection curves.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov intcurves}\\> - \\>\\begin{minipg2}\n                                Array containing the description of the intersection\n                                curves. The curves are only described by\n                                start points and end points (guide points) in\n                                the parameter planes.\n                                The curve pointers point\n                                to nothing.\n                                \\end{minipg2}\\\\[0.3ex]\n%\\newpagetabs\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov centre}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov normal}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov cendist}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov radius}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov pointpar} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcr} = 0;\\\\\n                \\>\\>    SISLIntcurve\\>  **{\\fov intcurves} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1369(\\begin{minipg4}\n                {\\fov surf}, {\\fov centre}, {\\fov normal}, {\\fov cendist}, {\\fov radius}, {\\fov dim}, {\\fov epsco},\n                {\\fov epsge}, \\linebreak \\&{\\fov numintpt},\n                \\&{\\fov pointpar}, \\&{\\fov numintcr}, \\&{\\fov intcurves}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1371.tex",
    "content": "\\subsection{Intersection between a spline curve and a 2D circle or a sphere.}\n\\funclabel{s1371}\n\\begin{minipg1}\n  Find all the intersections between a curve and a sphere\n  (if curve dimension and $dim=3$), or a curve and a circle\n  (if curve dimension and $dim=2$).\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1371(\\begin{minipg3}\n        {\\fov curve}, {\\fov centre}, {\\fov radius}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov numintpt}, {\\fov intpar},\\\\\n                        {\\fov numintcu}, {\\fov intcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov centre}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov radius};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov intpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcu};\\\\\n                \\>\\>    SISLIntcurve \\> ***{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to the curve.\\\\\n        \\>\\>    {\\fov centre}   \\> - \\> Centre of the circle/sphere.\\\\\n        \\>\\>    {\\fov radius}   \\> - \\> Radius of circle or sphere.\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                Dimension of the space in which the\n                                curve and the circle/sphere lies, {\\fov dim}\n                                should be equal to two or three.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov epsco}    \\> - \\> Computational resolution (not used).\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> Geometry resolution.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  Number of single intersection points.\\\\\n        \\>\\>    {\\fov intpar}   \\> - \\> \\begin{minipg2}\n                        Array containing the parameter values of the\n                        single intersection points in the parameter\n                        interval of the curve. The points lie in sequence.\n                        Intersection curves are stored in intcurve.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcu}\\> - \\>Number of intersection curves.\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                        Array of pointers to SISLIntcurve objects\n                        containing descriptions of the intersection\n                        curves. The curves are only described by start\n                        points and end points in\n                        the parameter interval of the curve. The curve\n                        pointers point to nothing.\n                                \\end{minipg2}\\\\[0.8ex]\n\\newpagetabs\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov centre}[3]; \\,/* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov radius}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} =  1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov intpar} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcu} = 0;\\\\\n                \\>\\>    SISLIntcurve \\> **{\\fov intcurve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1371(\\begin{minipg4}\n        {\\fov curve}, {\\fov centre}, {\\fov radius}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov numintpt},\n                \\&{\\fov intpar}, \\&{\\fov numintcu}, \\&{\\fov intcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1372.tex",
    "content": "\\subsection{Intersection between a spline curve and a cylinder.}\n\\funclabel{s1372}\n\\begin{minipg1}\n  Find all the intersections between a spline curve and a cylinder.\n\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1372(\\begin{minipg3}\n        {\\fov curve}, {\\fov point}, {\\fov dir}, {\\fov radius}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov numintpt}, {\\fov intpar},\n                        {\\fov numintcu}, {\\fov intcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov point}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov dir}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov radius};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov intpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcu};\\\\\n                \\>\\>    SISLIntcurve \\> ***{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to the curve.\\\\\n        \\>\\>    {\\fov point}    \\> - \\> Point on the cylinder axis.\\\\\n        \\>\\>    {\\fov dir}      \\> - \\> Direction of the cylinder axis.\\\\\n        \\>\\>    {\\fov radius}   \\> - \\> Radius of the cylinder.\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                Dimension of the space in which the\n                                cylinder and the curve\n                                lie, dim should be equal to three.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov epsco}    \\> - \\> Computational resolution (not used).\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> Geometry resolution.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  Number of single intersection points.\\\\\n        \\>\\>    {\\fov intpar}   \\> - \\> \\begin{minipg2}\n                        Array containing the parameter values of the\n                        single intersection points in the parameter\n                        interval of the curve. The points lie in sequence.\n                        Intersection curves are stored in intcurve.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcu}\\> - \\>Number of intersection curves.\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                        Array of pointers to the SISLIntcurve objects\n                        containing descriptions of the intersection\n                        curves. The curves are only described by start\n                        points and end points in\n                        the parameter interval of the curve. The curve\n                        pointers point to nothing.\n                                \\end{minipg2}\\\\[0.8ex]\n\\newpagetabs\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov point}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov dir}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov radius}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9 /* Not used */;\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov intpar} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcu} = 0;\\\\\n                \\>\\>    SISLIntcurve \\> **{\\fov intcurve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1372(\\begin{minipg4}\n        {\\fov curve}, {\\fov point}, {\\fov dir}, {\\fov radius}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov numintpt},\\\\\n                \\&{\\fov intpar}, \\&{\\fov numintcu}, \\&{\\fov intcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1373.tex",
    "content": "\\subsection{Intersection between a spline curve and a cone.} \\label{sec:s1373}\n\\funclabel{s1373}\n\\begin{minipg1}\n  Find all the intersections between a curve and a cone.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1373(\\begin{minipg3}\n         {\\fov curve}, {\\fov top}, {\\fov dir}, {\\fov conept}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov numintpt}, {\\fov intpar},\n                        {\\fov numintcu}, {\\fov intcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov top}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov axispt}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov conept}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov intpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcu};\\\\\n                \\>\\>    SISLIntcurve \\> ***{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to the curve.\\\\\n        \\>\\>    {\\fov top}      \\> - \\> Top point of the cone.\\\\\n        \\>\\>    {\\fov axispt}   \\> - \\> Point on the cone axis.\\\\\n        \\>\\>    {\\fov conept}   \\> - \\> Point on the cone surface, other than the top point.\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                Dimension of the space in which the\n                                cone and the curve\n                                lie, dim should be equal to three.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov epsco}    \\> - \\> Computational resolution (not used).\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> Geometry resolution.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  Number of single intersection points.\\\\\n        \\>\\>    {\\fov intpar}   \\> - \\> \\begin{minipg2}\n                        Array containing the parameter values of the\n                        single intersection points in the parameter\n                        interval of the curve. The points lie in sequence.\n                        Intersection curves are stored in intcurve.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcu}\\> - \\>Number of intersection curves.\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                        Array of pointers to the SISLIntcurve object\n                        containing descriptions of the intersection\n                        curves. The curves are only described by start\n                        points and end points in the parameter interval\n                        of the curve. The curve pointers point\n                        to nothing.\n                                \\end{minipg2}\\\\[0.8ex]\n\\newpagetabs\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /*Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov top}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov dir}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov conept}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */ \\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov intpar} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcu} = 0;\\\\\n                \\>\\>    SISLIntcurve \\> **{\\fov intcurve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1373(\\begin{minipg4}\n        {\\fov curve}, {\\fov top}, {\\fov dir}, {\\fov conept}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov numintpt},\n                \\&{\\fov intpar}, \\&{\\fov numintcu}, \\&{\\fov intcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1374.tex",
    "content": "\\subsection{Intersection between a curve and a quadric curve.}\n\\funclabel{s1374}\n\\begin{minipg1}\n  Find all the intersections between a curve and a quadric\n  curve, (if curve dimension and $dim=2$), or a curve and a\n  quadric surface, (if curve dimension and $dim=3$).\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1374(\\begin{minipg3}\n        {\\fov curve}, {\\fov conarray}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov numintpt}, {\\fov intpar},\n                        {\\fov numintcu}, {\\fov intcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov conarray}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov intpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcu};\\\\\n                \\>\\>    SISLIntcurve \\> ***{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to the curve.\\\\\n        \\>\\>    {\\fov conarray}\\> - \\>  \\begin{minipg2}\n                                Matrix of dimension $(dim+1)\\times(dim+1)$ describing\n                                the conic curve or surface with homogeneous coordinates. For dim=2\n                                the implicit equation of the curve is that the following is equal to zero:\n                                \\[ \\left( \\begin{array}{ccc} x & y & 1\n                                \\end{array} \\right)\n                                \\left( \\begin{array}{ccc} c_{0} & c_{1} & c_{2}\\\\\n                                c_{3} & c_{4} & c_{5}\\\\ c_{6} & c_{7} & c_{8}\n                                \\end{array} \\right)\n                                \\left( \\begin{array}{c} x\\\\ y\\\\ 1\n                                \\end{array} \\right) \\]\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                Dimension of the space in which the\n                                cone and the curve\n                                lie, {\\fov dim} should be equal to two or three.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov epsco}    \\> - \\> Computational resolution (not used).\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> Geometry resolution.\\\\\n\\newpagetabs\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  Number of single intersection points.\\\\\n        \\>\\>    {\\fov intpar}   \\> - \\> \\begin{minipg2}\n                        Array containing the parameter values of the\n                        single intersection points in the parameter\n                        interval of the curve. The points lie in sequence.\n                        Intersection curves are stored in intcurve.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcu}\\> - \\>Number of intersection curves.\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                        Array of pointers to SISLIntcurve objects\n                        containing descriptions of the intersection\n                        curves. The curves are only described by start\n                        points and end points in\n                        the parameter interval of the curve. The curve\n                        pointers point to nothing.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : Warning.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Ok.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov conarray}[16]; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov intpar} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcu} = 0;\\\\\n                \\>\\>    SISLIntcurve \\> **{\\fov intcurve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1374(\\begin{minipg4}\n        {\\fov curve}, {\\fov conarray}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov numintpt},\n                \\&{\\fov intpar}, {\\fov \\linebreak} \\&{\\fov numintcu}, \\&{\\fov intcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1375.tex",
    "content": "\\subsection{Intersection between a curve and a torus.}\n\\funclabel{s1375}\n\\begin{minipg1}\n  Find all the intersections between a spline curve and a torus.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1375(\\begin{minipg3}\n        {\\fov curve}, {\\fov centre}, {\\fov normal}, {\\fov centdist}, {\\fov rad}, {\\fov dim}, {\\fov epsco}, {\\fov epsge},\\\\ {\\fov numintpt}, {\\fov intpar},\n                        {\\fov numintcu}, {\\fov intcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov centre[\\,]};\\\\\n                \\>\\>    double  \\>      {\\fov normal}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov centdist};\\\\\n                \\>\\>    double  \\>      {\\fov rad};\\\\\n                \\>\\>    int             \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov intpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcu};\\\\\n                \\>\\>    SISLIntcurve \\> ***{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to the curve.\\\\\n        \\>\\>    {\\fov centre}   \\> - \\> \\begin{minipg2}\n                                The centre of the torus (lying in the symmetry plane)\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov normal}   \\> - \\> Normal of symmetry plane.\\\\\n        \\>\\>    {\\fov centdist}\\> - \\>  \\begin{minipg2}\n                                Distance from the centre of the cone to the centre circle of the torus.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov rad}      \\> - \\> The radius of the torus surface.\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                Dimension of the space in which the\n                                torus and the curve\n                                lie, dim should be equal to  three.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov epsco}    \\> - \\> Computational resolution (not used).\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> Geometry resolution.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  Number of single intersection points.\\\\\n        \\>\\>    {\\fov intpar}   \\> - \\> \\begin{minipg2}\n                        Array containing the parameter values of the\n                        single intersection points in the parameter\n                        interval of the curve. The points lie in sequence.\n                        Intersection curves are stored in intcurve.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcu}\\> - \\>Number of intersection curves.\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                        Array of pointers to the SISLIntcurve objects\n                        containing descriptions of the intersection\n                        curves. The curves are only described by start\n                        points and end points in\n                        the parameter interval of the curve. The curve\n                        pointers point to nothing.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov centre}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov normal}[3]; \\,/* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov centdist}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov rad}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov intpar} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcu} = 0;\\\\\n                \\>\\>    SISLIntcurve \\> **{\\fov intcurve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    {\\fov \\ldots} \\\\\n        \\>\\>s1375(\\begin{minipg4}\n        {\\fov curve}, {\\fov centre}, {\\fov normal}, {\\fov centdist}, {\\fov rad}, {\\fov dim}, {\\fov epsco}, {\\fov epsge},\\\\ \\&{\\fov numintpt},\n                \\&{\\fov intpar}, \\&{\\fov numintcu}, \\&{\\fov intcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1379.tex",
    "content": "\\subsection{Compute a curve by Hermite interpolation,\nparameter\\-ization as input.}\n\\funclabel{s1379}\n\\begin{minipg1}\nTo compute the cubic Hermite interpolant to the data given by the points\npoint and the derivatives derivate and the parameterization par.\nThe output is represented as a B-spline curve.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1379(\\begin{minipg3}\n                {\\fov point}, {\\fov derivate}, {\\fov par}, {\\fov numpt}, {\\fov dim}, {\\fov curve}, {\\fov stat})\n                \\end{minipg3}\\\\\n                \\>\\>    double  \\>      {\\fov point}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov derivate}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov par}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov numpt};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov curve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov point}    \\> - \\> \\begin{minipg2}\n                                Array (length dim*numpt) containing the\n                                points to be interpolated in the sequence is\n                                $(x_{0},y_{0},x_{1},y_{1},\\ldots)$\n                                .\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov derivate}\\> - \\>  \\begin{minipg2}\n                                Array (length dim*numpt) containing the\n                                derivatives to be interpolated in the sequence is\n                                \\[\n                                (\\frac{dx_{0}}{dt},\\frac{dy_{0}}{dt},\n                                \\frac{dx_{1}}{dt},\\frac{dy_{1}}{dt},\\ldots).\n                                \\]\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov par}      \\> - \\> \\begin{minipg2}\n                                Parameterization array,\n                                $(t_{0},t_{1},\\ldots)$. The array should\n                                be increasing in value.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov numpt}    \\> - \\> \\begin{minipg2}\n                                No. of points/derivatives in the\n                                point and derivative arrays.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                The dimension of the space in which\n                                the points lie.\n                                \\end{minipg2}\\\\[0.3ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to output B-spline curve\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    double  \\>      {\\fov point}[10];\\\\\n                \\>\\>    double  \\>      {\\fov derivate}[10];\\\\\n                \\>\\>    double  \\>      {\\fov par}[5];\\\\\n                \\>\\>    int     \\>      {\\fov numpt} = 5;\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 2;\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1379(\\begin{minipg4}\n                {\\fov point}, {\\fov derivate}, {\\fov par}, {\\fov numpt}, {\\fov dim}, \\&{\\fov curve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1380.tex",
    "content": "\\subsection{\\sloppy Compute a curve by Hermite interpolation, automatic parameteriza\\-tion.}\n\\funclabel{s1380}\n\\begin{minipg1}\n  To compute the cubic Hermite interpolant to the data given by the points\n  point and the derivatives derivate.\n The output is represented as a B-spline curve.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1380(\\begin{minipg3}\n                {\\fov point}, {\\fov derivate}, {\\fov numpt}, {\\fov dim}, {\\fov typepar}, {\\fov curve}, {\\fov stat})\n                \\end{minipg3}\\\\\n                \\>\\>    double  \\>      {\\fov point}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov derivate}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov numpt};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    int     \\>      {\\fov typepar};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov curve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov point}    \\> - \\> \\begin{minipg2}\n                                Array (length dim*numpt) containing the\n                                points in sequence\n                                $(x_{0},y_{0},x_{1},y_{1},\\ldots)$\n                                to be interpolated.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov derivate}\\> - \\>  \\begin{minipg2}\n                                Array (length dim*numpt) containing the\n                                derivate in sequence\n                                $(\\frac{dx_{0}}{dt},\\frac{dy_{0}}{dt},\n                                \\frac{dx_{1}}{dt},\\frac{dy_{1}}{dt},\\ldots)$\n                                to be interpolated.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov numpt}    \\> - \\> \\begin{minipg2}\n                                No. of points/derivatives in the\n                                point and derivative arrays.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                The dimension of the space in which\n                                the points lie.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov typepar}  \\> - \\>\n                                Type of parameterization:\\\\\n                \\>\\>\\>\\>\\>      $=1$ : \\>  \\begin{minipg5}\n                                Parameterization using cord length\\\\\n                                between the points.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $\\neq 1$ :\\>  Uniform parameterization.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to the output B-spline curve\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    double  \\>      {\\fov point}[10];\\\\\n                \\>\\>    double  \\>      {\\fov derivate}[10];\\\\\n                \\>\\>    int     \\>      {\\fov numpt} = 5;\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 2;\\\\\n                \\>\\>    int     \\>      {\\fov typepar} = 1;\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1380(\\begin{minipg4}\n                {\\fov point}, {\\fov derivate}, {\\fov numpt}, {\\fov dim}, {\\fov typepar}, \\&{\\fov curve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1383.tex",
    "content": "\\subsection{Pick the curve lying in a surface, described by a curve in the parameter plane of\nthe surface.}\n\\funclabel{s1383}\n\\begin{minipg1}\n  To create a 3D approximation to the curve in a surface, traced out by\n  a curve in the parameter plane.\n  The output is represented as a B-spline curve.\n\\end{minipg1} \\\\\nSYNOPSIS\\\\\n        \\>void s1383(\\begin{minipg3}\n                        {\\fov surf}, {\\fov curve}, {\\fov epsge}, {\\fov maxstep}, {\\fov der}, {\\fov newcurve1}, {\\fov newcurve2}, {\\fov newcurve3},\n                        stat)\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      {\\fov maxstep};\\\\\n                \\>\\>    int     \\>      {\\fov der};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve1};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve2};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve3};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                The surface object\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov curve}\\> - \\>     \\begin{minipg2}\n                                The input curve in the parameter plane.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Maximal deviation allowed between true 3D curve lying in the surface,\n                                and the approximated 3D curve.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov maxstep}\\> - \\>   \\begin{minipg2}\n                                Maximum step length. Is neglected if\n                                $maxstep \\leq epsge$ If\n                                $maxstep \\leq 0.0$ the 3D box of the\n                                surface is used to estimate the maximum step length.\n                                \\end{minipg2} \\\\[0.3ex]\n        \\>\\>    {\\fov der}      \\> - \\>         \\begin{minipg2}\n                                Derivative indicator\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      $= 0$ : Calculate only position curve.\\\\\n                \\>\\>\\>\\>\\>      $= 1$ : Calculate position + derivative curves.\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newcurve1}\\> - \\> \\begin{minipg2}\n                                Pointer to the B-spline curve\n                                approximating the position curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov newcurve2}\\> - \\> \\begin{minipg2}\n                                Pointer to the B-spline curve\n                                approximating the derivative curve along\n                                the position curve in the first\n                                parameter direction of the surface.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov newcurve3}\\> - \\> \\begin{minipg2}\n                                Pointer to the B-spline curve\n                                approximating derivative curve in\n                                the second parameter direction of the\n                                surface, along the position curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov epsge}  = 0.0001;\\\\\n                \\>\\>    double  \\>      {\\fov maxstep} = 0.0;\\\\\n                \\>\\>    int     \\>      {\\fov der} = 1;\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve1} = NULL;\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve2} = NULL;\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve3} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1383(\\begin{minipg4}\n                {\\fov surf}, {\\fov curve}, {\\fov epsge}, {\\fov maxstep}, {\\fov der}, \\&{\\fov newcurve1}, \\&{\\fov newcurve2}, \\&{\\fov newcurve3},\n                \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1386.tex",
    "content": "\\subsection{Express the ``i,j''-th derivative of an open surface as a \\mbox{surface}.}\n\\funclabel{s1386}\n\\begin{minipg1}\n  To express the $(der1, der2)$-th derivative of an open surface as a surface.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1386(\\begin{minipg3}\n          {\\fov surf}, {\\fov der1}, {\\fov der2}, {\\fov newsurf}, {\\fov stat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n        \\>\\>    int     \\>      {\\fov der1};\\\\\n        \\>\\>    int     \\>      {\\fov der2};\\\\\n        \\>\\>    SISLSurf        \\>      **{\\fov newsurf};\\\\\n        \\>\\>    int     \\>      *{\\fov stat};\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}     \\> - \\> \\begin{minipg2}\n                                Surface to differentiate.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov der1}     \\> - \\> \\begin{minipg2}\n                                The derivative to be produced in the first\n                                parameter direction: $0\\leq der1$\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov der2}     \\> - \\> \\begin{minipg2}\n                                The derivative to be produced in the second\n                                parameter direction: $0\\leq der2$\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newsurf}  \\> - \\> \\begin{minipg2}\n                                The result of the (der1, der2) differentiation of surf.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\[1.0ex]\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov der1} = 1;\\\\\n                \\>\\>    int     \\>      {\\fov der2} = 0;\\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov newsurf} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1386(\\begin{minipg4}\n                {\\fov surf}, {\\fov der1}, {\\fov der2}, \\&{\\fov newsurf}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1387.tex",
    "content": "\\subsection{Express a surface using a higher order basis.}\n\\funclabel{s1387}\n\\begin{minipg1}\n  To express a surface as a surface of higher order.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1387(\\begin{minipg3}\n                                {\\fov surf}, {\\fov order1}, {\\fov order2}, {\\fov newsurf}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    int     \\>      {\\fov order1};\\\\\n                \\>\\>    int     \\>      {\\fov order2};\\\\\n                \\>\\>    SISLSurf        \\>      **{\\fov newsurf};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>              \\begin{minipg2}\n                                Surface to raise the order of.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov order1}\\> - \\>            \\begin{minipg2}\n                                New order in the first parameter direction.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov order2}\\> - \\>            \\begin{minipg2}\n                                New order in the second parameter direction.\n                                \\end{minipg2}\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newsurf}\\> - \\>   \\begin{minipg2}\n                                The resulting order elevated surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>      $= 1$   : \\> \\begin{minipg5}\n                                                Input order equal to\n                                                order of surface.\n                                                Pointer set to input.\n                                        \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>\\>      $= 0$   : \\>Ok.\\\\\n                \\>\\>\\>\\>\\>      $< 0$   : \\>Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov order1}; \\, /* Must be defined. Larger than or equal to surf--$>$ik1 */\\\\\n                \\>\\>    int     \\>      {\\fov order2}; \\, /* Must be defined. Larger than or equal to surf--$>$ik2 */\\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov newsurf} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1387(\\begin{minipg4}\n                                {\\fov surf}, {\\fov order1}, {\\fov order2}, \\&{\\fov newsurf}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1388.tex",
    "content": "\\subsection{Convert a surface of order up to four to a mesh of Coons\npatches.}\n\\funclabel{s1388}\n\\begin{minipg1}\n  To convert a surface of order less than or equal to 4 in both\n  directions to a mesh of Coons patches with uniform parameterization.\n  The function assumes that the surface is $C^1$ continuous.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1388(\\begin{minipg3}\n                        {\\fov surf}, {\\fov coons}, {\\fov numcoons1}, {\\fov numcoons2}, {\\fov dim}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      **{\\fov coons};\\\\\n                \\>\\>    int     \\>      *{\\fov numcoons1};\\\\\n                \\>\\>    int     \\>      *{\\fov numcoons2};\\\\\n                \\>\\>    int     \\>      *{\\fov dim}\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}     \\> - \\> \\begin{minipg2}\n                                Pointer to the surface that is to be converted\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov coons}    \\> - \\> \\begin{minipg2}\n                                Array containing the (sequence of) Coons patches.\n                                The total number of patches is\n                                $numcoons1\\times numcoons2$. The patches\n                                are stored in sequence with $dim\\times\n                                16$ values for each patch. For each\n                                corner of the patch we store in\n                                sequence, positions, derivative in first\n                                direction, derivative in second\n                                direction, and twists.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov numcoons1}\\> - \\> \\begin{minipg2}\n                                Number of Coons patches in first\n                                parameter direction.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov numcoons2}\\> - \\> \\begin{minipg2}\n                                Number of Coons patches in second\n                                parameter direction.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                The dimension of the geometric space.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>      $= 1$   :\\>\\begin{minipg5}\n                                        Order too high, surface interpolated.\n                                        \\end{minipg5}\\\\\n                \\>\\>\\>\\>\\>      $= 0$   :\\> Ok.\\\\\n                \\>\\>\\>\\>\\>      $< 0$   :\\> Error.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      *{\\fov coons} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numcoons1} = 0;\\\\\n                \\>\\>    int     \\>      {\\fov numcoons2} = 0;\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1388(\\begin{minipg4}\n                {\\fov surf}, \\&{\\fov coons}, \\&{\\fov numcoons1}, \\&{\\fov numcoons2}, \\&{\\fov dim}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1389.tex",
    "content": "\\subsection{Convert a curve of order up to four, to a sequence of cubic polynomials.}\n\\funclabel{s1389}\n\\begin{minipg1}\n  Convert a curve of order up to 4 to a sequence of non-rational cubic\n  segments with uniform parameterization.\n\\end{minipg1} \\\\\nSYNOPSIS\\\\\n        \\>void s1389(\\begin{minipg3}\n                                {\\fov curve}, {\\fov cubic}, {\\fov numcubic}, {\\fov dim}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      **{\\fov cubic};\\\\\n                \\>\\>    int     \\>      *{\\fov numcubic};\\\\\n                \\>\\>    int     \\>      *{\\fov dim};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> \\begin{minipg2}\n                                Pointer to the curve that is to be converted\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov cubic}    \\> - \\> \\begin{minipg2}\n                                Array containing the sequence of cubic segments.\n                                Each segment is represented by the start point,\n                                followed by the start tangent, end point and end\n                                tangent. Each segment needs 4*dim doubles for storage.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov numcubic}\\> - \\>  \\begin{minipg2}\n                                Number of elements of length\n                                (4*dim) in the array cubic\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                The dimension of the geometric space.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>      $> 0$   :\\>\\begin{minipg5}\n                                                warning\n                                        \\end{minipg5}\\\\\n                \\>\\>\\>\\>\\>      $= 0$   :\\> ok\\\\\n                \\>\\>\\>\\>\\>      $< 0$   :\\> error\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      *{\\fov cubic} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numcubic};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1389(\\begin{minipg4}\n                {\\fov curve}, \\&{\\fov cubic}, \\&{\\fov numcubic}, \\&{\\fov dim},\n                 \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1390.tex",
    "content": "\\subsection{Compute a rectangular blending surface from a set of\n\\mbox{B-spline} input curves.}\n\\funclabel{s1390}\n\\begin{minipg1}\n  Make a 4-edged blending surface between 4 B-spline (i.e.\\ NOT\n  rational) curves where each curve is associated with a number of\n  cross-derivative B-spline (i.e.\\ NOT rational) curves.\n  The output is represented as a B-spline surface.\n  The input curves are numbered successively around the blending\n  parameter, and the directions of the curves are expected to be as\n  follows when this routine is entered:\n\\begin{center}\n\\begin{picture}(180,110)(0,0)\n        \\put(50,15){\\framebox(80,80)}\n        \\put(40,55){\\vector(0,1){20}}\n        \\put(140,55){\\vector(0,1){20}}\n        \\put(90,5){\\vector(1,0){20}}\n        \\put(90,105){\\vector(1,0){20}}\n        \\put(40,45){\\makebox(0,0){4}}\n        \\put(140,45){\\makebox(0,0){2}}\n        \\put(80,5){\\makebox(0,0){1}}\n        \\put(80,105){\\makebox(0,0){3}}\n\n        \\put(60,20){\\vector(1,0){40}}\n        \\put(85,28){\\makebox(0,0){$(i)$}}\n        \\put(55,25){\\vector(0,1){40}}\n        \\put(65,50){\\makebox(0,0){$(ii)$}}\n\\end{picture}\\\\\n$(i) \\; \\; \\;$ first parameter direction of the surface.\\\\\n$(ii)$   second parameter direction of the surface.\\\\\n\\end{center}\n        NB!     The cross-derivatives are always pointing into the patch, and note the\n                directions in the above diagram.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1390(\\begin{minipg3}\n                {\\fov curves}, {\\fov surf}, {\\fov numder}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curves}[\\,];\\\\\n                \\>\\>    SISLSurf        \\>      **{\\fov surf};\\\\\n                \\>\\>    int     \\>      {\\fov numder}[\\,];\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curves}   \\> - \\>\n        \\begin{minipg2}\n          Pointers to the boundary B-spline curves:\\\\\n          $curves[i], i=0,\\ldots,numder[0]-1,$\n          are pointers to position and cross-derivatives along the first edge.\n        \\end{minipg2}\\\\[0.3ex]\n        \\>\\>\\>\\>\n        \\begin{minipg2}\n          $curves[i],$\\\\\n          $i=numder[0],\\ldots,numder[0]+numder[1]-1,$\n          are pointers to position  and cross-derivatives\n          along the second edge.\n        \\end{minipg2}\\\\[0.3ex]\n        \\>\\>\\>\\>\n        \\begin{minipg2}\n          $curves[i], i=numder[0]+numder[1],\\ldots,$\\\\\n          $numder[0]+numder[1]+numder[2]-1,$\n          are pointers to position and cross-derivatives\n          along the third edge.\n        \\end{minipg2}\\\\[0.3ex]\n\\newpagetabs\n        \\>\\>\\>\\>\n        \\begin{minipg2}\n          $curves[i],$\\\\\n          $i=numder[0]+numder[1]+numder[2],\\ldots,$\\\\\n          $numder[0]+numder[1]+numder[2]+numder[3]-1,$\n          are  pointers to position\n          and cross-derivatives along the fourth edge.\n        \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov numder}   \\> - \\> \\begin{minipg2}\n                                Array of length 4, numder[i] gives the\n                                 number of curves on edge number $i+1$.\n                                \\end{minipg2}\\\\[0.3ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the blending B-spline surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curves}[8]; \\, /* Must be defined */\\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numder}[4]; /* Each entry is equal to 2 in this case */\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1390(\\begin{minipg4}\n                {\\fov curves}, \\&{\\fov surf}, {\\fov numder}, \\&{\\fov stat})\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1391.tex",
    "content": "\\subsection{Compute a first derivative continuous blending surface set,\nover a 3-, 4-, 5- or 6-sided region in space, from a set of B-spline\ninput curves.}\n\\funclabel{s1391}\n\\begin{minipg1}\n  To create a first derivative continuous blending surface set over a\n  3-, 4-, 5- and 6-sided region in space. The boundary of the\n  region are B-spline (i.e.\\ NOT rational) curves and the cross boundary\n  derivatives  are given as B-spline (i.e.\\ NOT rational) curves.\n  This function automatically\n  preprocesses the input cross tangent curves in order to\n  make them suitable for the blending. Thus, the cross tangent\n  curves should be taken as the cross tangents of the\n  surrounding surface. It is not necessary and not advisable\n  to match tangents etc. in the corners.\n  The output is represented as a set of B-spline surfaces.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1391(\\begin{minipg3}\n          {\\fov pc}, {\\fov ws}, {\\fov icurv}, {\\fov nder}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLCurve \\> **{\\fov pc};\\\\\n        \\>\\>    SISLSurf  \\> ***{\\fov ws};\\\\\n        \\>\\>    int       \\>  {\\fov icurv};\\\\\n        \\>\\>    int       \\>  {\\fov nder}[\\,];\\\\\n        \\>\\>    int       \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov pc} \\> - \\>\n        \\begin{minipg2}\n          Pointers to boundary B-spline curves. All curves must\n          have same parameter direction around the patch,\n          either clockwise or counterclockwise.\n          $pc1[i], i=0,\\dots nder[0]-1$ are pointers to position\n          and cross-derivatives along first edge.\n          $pc1[i], i=nder[0],\\dots nder[1]-1$ are pointers\n          to position and cross-derivatives along second edge.\\\\\n          \\hspace*{4em}$\\vdots$\\\\\n          \\[\n            pc1[i], i=nder[0]+\\dots+nder[icurv-2],\\dots, nder[icurv-1]-1\n          \\]\n          are pointers to position and cross-derivatives along fourth edge.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov icurv} \\> - \\> Number of boundary curves (3, 5, 4 or 6).\\\\\n        \\>\\>    {\\fov nder} \\> - \\>\n        \\begin{minipg2}\n          {\\fov nder[i]} gives number of curves on edge number\n          $i+1$. These numbers has to be equal to 2.\n          The vector is of length {\\fov icurv}.\n        \\end{minipg2}\\\\[0.8ex]\n\\\\\n\\newpagetabs\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov ws} \\> - \\>\n        \\begin{minipg2}\n          These are pointers to the blending B-spline surfaces. The vector is of\n          length {\\fov icurv}.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve \\> *{\\fov pc}[10];  /* Position and derivative curves. Must be defined */\\\\\n        \\>\\>    SISLSurf  \\> **{\\fov ws} = NULL; /* In this case 5 surfaces will be constructed \\\\\n        \\>\\>    int       \\> {\\fov icurv} = 5;\\\\\n        \\>\\>    int       \\> {\\fov nder}[5]; /* Each entry must be equal to 2 */ \\\\\n        \\>\\>    int       \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1391(\\begin{minipg4}\n          {\\fov pc}, \\&{\\fov ws}, {\\fov icurv}, {\\fov nder}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1401.tex",
    "content": "\\subsection{Compute a surface, representing a Gordon patch, from a set\nof B-spline input curves.}\n\\funclabel{s1401}\n\\begin{minipg1}\n  Compute a Gordon patch, given position and cross tangent conditions as\n  B-spline (i.e.\\ NOT rational) curves at the boundary of a squared\n  region and the twist vector in the corners.\n  The output is represented as a B-spline surface.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1401(\\begin{minipg3}\n          {\\fov vcurve}, {\\fov etwist}, {\\fov rsurf}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    double    \\> {\\fov etwist}[\\,];\\\\\n        \\>\\>    SISLCurve \\> *{\\fov vcurve}[\\,];\\\\\n        \\>\\>    int       \\> *{\\fov jstat};\\\\\n        \\>\\>    SISLSurf  \\> **{\\fov rsurf};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov vcurve} \\> - \\>\n        \\begin{minipg2}\n          Position and cross-tangent B-spline curves around the square\n          region. For each edge of the region position and cross-tangent\n          curves are given. The dimension of the array is 8.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>\\>\\>\\begin{minipg2}\n                  The orientation is as follows:\\\\\n                  \\begin{center}\n                    \\begin{picture}(180,110)(0,0)\n                      \\put(50,15){\\framebox(80,80)}\n                      \\put(40,55){\\vector(0,1){20}}\n                      \\put(140,55){\\vector(0,1){20}}\n                      \\put(90,5){\\vector(1,0){20}}\n                      \\put(90,105){\\vector(1,0){20}}\n                      \\put(40,45){\\makebox(0,0){4}}\n                      \\put(140,45){\\makebox(0,0){2}}\n                      \\put(80,5){\\makebox(0,0){1}}\n                      \\put(80,105){\\makebox(0,0){3}}\n\n                      \\put(60,20){\\vector(1,0){40}}\n                      \\put(85,28){\\makebox(0,0){$(i)$}}\n                      \\put(55,25){\\vector(0,1){40}}\n                      \\put(65,50){\\makebox(0,0){$(ii)$}}\n                    \\end{picture}\\\\\n                    $(i) \\; \\; \\;$ first parameter direction of the surface.\\\\\n                    $(ii)$   second parameter direction of the surface.\\\\\n                  \\end{center}\n                \\end{minipg2}\\\\ \\\\\n        \\>\\>    {\\fov etwist} \\> - \\>\n        \\begin{minipg2}\n          Twist-vectors of the corners of the vertex region. The first\n          element of the array is the twist in the corner before the\n          first edge, etc. The dimension of the array is 4 times the\n          spatial dimension of the input curves (currently only 3D).\n        \\end{minipg2}\\\\[0.8ex]\n\\newpagetabs\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rsurf} \\> - \\> Gordons-patch represented as a\n                                     B-spline surface.\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    int       \\> {\\fov idim} = 3;\\\\\n        \\>\\>    double    \\> {\\fov etwist}[12]; /* 4*idim. Must be defined */\\\\\n        \\>\\>    SISLCurve \\> *{\\fov vcurve}[8]; /* Position and derivative curves. Must be defined */\\\\\n        \\>\\>    int       \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    SISLSurf  \\> *{\\fov rsurf} = NULL;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1401(\\begin{minipg4}\n          {\\fov vcurve}, {\\fov etwist}, \\&{\\fov rsurf}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1421.tex",
    "content": "\\subsection{Compute the position, the derivatives and the normal of a\nsurface at a given parameter value pair.}\n\\funclabel{s1421}\n\\begin{minipg1}\n  Evaluate the surface at a given parameter value pair.\n  Compute {\\fov der} derivatives and the normal if $der \\geq 1$.\n  See also s1424() on page \\pageref{s1424}.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1421(\\begin{minipg3}\n          {\\fov surf}, {\\fov der}, {\\fov parvalue}, {\\fov leftknot1}, {\\fov leftknot2}, {\\fov derive}, {\\fov normal}, {\\fov stat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n        \\>\\>    int     \\>      {\\fov der};\\\\\n        \\>\\>    double  \\>      {\\fov parvalue}[\\,];\\\\\n        \\>\\>    int     \\>      *{\\fov leftknot1};\\\\\n        \\>\\>    int     \\>      *{\\fov leftknot2};\\\\\n        \\>\\>    double  \\>      {\\fov derive}[\\,];\\\\\n        \\>\\>    double  \\>      {\\fov normal}[\\,];\\\\\n        \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>              \\begin{minipg2}\n                                Pointer to the surface to evaluate.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov der}\\> - \\>               \\begin{minipg2}\n                                Number (order) of derivatives to evaluate.\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      $< 0$ \\> : No derivatives evaluated.\\\\\n                \\>\\>\\>\\>\\>      $= 0$ \\> : Position evaluated.\\\\\n                \\>\\>\\>\\>\\>      $> 0$ \\> : \\begin{minipg5}\n                                              Position and derivatives\n                                              evaluated.\n                                            \\end{minipg5}\\\\\n        \\>\\>    {\\fov parvalue}\\> - \\>          \\begin{minipg2}\n                                Parameter value at which to evaluate. Dimension\n                                of parvalue is 2.\n                                \\end{minipg2}\\\\[0.3ex]\n\\\\\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov leftknot1}\\> - \\>\n                \\begin{minipg2}\n                  Pointer to the interval in the knot\n                  vector in first\n                  parameter direction where $parvalue[0]$ is\n                  found. The relation\n                  \\[\n                  etl[leftknot1]\\leq parvalue[0]<etl[leftknot1+1],\n                  \\]\n                  where {\\fov etl} is the knot\n                  vector, should hold. {\\fov leftknot1} should be set\n                  equal to zero at the first call to the routine. Do not\n                  change {\\fov leftknot} during a section of calls to\n                  s1421().\n                \\end{minipg2} \\\\[0.8ex]\n        \\>\\>    {\\fov leftknot2}\\> - \\> \\begin{minipg2}\n                                Corresponding to {\\fov leftknot1}\n                                in the second parameter\n                                direction.\n                                \\end{minipg2}\\\\[0.8ex]\n\\newpagetabs\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov derive}\\> - \\>    \\begin{minipg2}\n                                Array where the derivatives of the surface in parvalue are\n                                placed. The sequence is position, first derivative in\n                                first parameter direction, first derivative in second\n                                parameter direction, (2,0) derivative, (1,1)\n                                derivative, (0,2) derivative, etc. The expresion\n                                \\[\n                                dim*(1+2+\\ldots+(der+1))=dim*(der+1)(der+2)/2\n                                \\]\n                                gives the dimension of the {\\fov derive} array.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov normal}\\> - \\>    \\begin{minipg2}\n                                Normal of surface. Is evaluated if\n                                $der \\geq 1$.\n                                Dimension is dim. The normal is not normalised.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>      $= 2$ \\> :\n                                \\begin{minipg5}\n                                  Surface is degenerate at the point,\n                                  normal has zero length.\n                                \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>\\>      $= 1$ \\> :\n                                \\begin{minipg5}\n                                  Surface is close to degenerate at the\n                                  point. Angle between tangents is less\n                                  than the angular tolerance.\n                                \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>\\>      $= 0$ \\> : Ok.\\\\\n                \\>\\>\\>\\>\\>      $< 0$ \\> : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n        \\>\\>    int     \\>      {\\fov der} = 2;\\\\\n        \\>\\>    double  \\>      {\\fov parvalue}[2]; \\, /* Must be defined */\\\\\n        \\>\\>    int     \\>      {\\fov leftknot1} = 0; /* Define initially as zero. For consequtive evaluations \\\\\n                \\>\\>\\>\\>\\>\\> leave leftknot1 as returned from s1421 */ \\\\\n        \\>\\>    int     \\>      {\\fov leftknot2} = 0; /* As for leftknot1 */ \\\\\n        \\>\\>    double  \\>      {\\fov derive}[18]; /* Length is spatial dimension times total number of entities */ \\\\\n        \\>\\>    double  \\>      {\\fov normal}[3]; /* Length is spatial dimension */ \\\\\n        \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1421(\\begin{minipg4}\n          {\\fov surf}, {\\fov der}, {\\fov parvalue}, \\&{\\fov leftknot1}, \\&{\\fov leftknot2}, {\\fov derive}, {\\fov normal}, \\&{\\fov stat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1422.tex",
    "content": "\\subsection{Compute the position and the left- or right-hand derivatives of\na surface at a given parameter value pair.}\n\\funclabel{s1422}\n\\begin{minipg1}\n  Evaluate and compute the left- or right-hand derivatives of\n  a surface at a given parameter position.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1422(\\begin{minipg3}\n          {\\fov ps1}, {\\fov ider}, {\\fov iside1}, {\\fov iside2}, {\\fov epar}, {\\fov ilfs}, {\\fov ilft}, {\\fov eder}, {\\fov enorm}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf    \\>  *{\\fov ps1};\\\\\n        \\>\\>    int    \\>  {\\fov ider};\\\\\n        \\>\\>    int    \\>  {\\fov iside1};\\\\\n        \\>\\>    int    \\>  {\\fov iside2};\\\\\n        \\>\\>    double \\>  {\\fov epar}[\\,];\\\\\n        \\>\\>    int    \\>  *{\\fov ilfs};\\\\\n        \\>\\>    int    \\>  *{\\fov ilft};\\\\\n        \\>\\>    double \\>  {\\fov eder}[\\,];\\\\\n        \\>\\>    double \\>  {\\fov enorm}[\\,];\\\\\n        \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov ps1}\\> - \\>  \\begin{minipg2}\n                     Pointer to the surface to evaluate.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov ider}\\> - \\>  \\begin{minipg2}\n                     Number of derivatives to calculate.\n                     \\end{minipg2}\\\\\n                     \\>\\>\\>\\> $<0$ \\> : No derivative calculated.\\\\\n                     \\>\\>\\>\\> $=0$ \\> : Position calculated.\\\\\n                     \\>\\>\\>\\> $=1$ \\> : Position and first derivative calculated.\\\\\n                     \\>\\>\\>\\>      \\>   etc.\\\\\n        \\>\\>    {\\fov iside1}\\> - \\>  \\begin{minipg2}\n                        Indicator telling if the derivatives in the first\n                        parameter direction is to be calculated from the\n                        left or from the right:\n                      \\end{minipg2}\\\\[0.3ex]\n                      \\>\\>\\>\\> $<0$ \\> :\n                      \\begin{minipg5}\n                        Calculate derivative from the left hand side.\n                      \\end{minipg5}\\\\[0.8ex]\n                      \\>\\>\\>\\> $\\geq 0$ \\> :\n                      \\begin{minipg5}\n                        Calculate derivative from the right hand side.\n                      \\end{minipg5}\\\\[0.8ex]\n        \\>\\>    {\\fov iside2}\\> - \\>  \\begin{minipg2}\n                     Indicator telling if the derivatives in the second\n                        parameter direction is to be calculated from the\n                        left or from the right:\n                               \\end{minipg2}\\\\[0.3ex]\n                      \\>\\>\\>\\> $<0$ \\> :\n                      \\begin{minipg5}\n                        Calculate derivative from the left hand side.\n                      \\end{minipg5}\\\\[0.8ex]\n                      \\>\\>\\>\\> $\\geq 0$ \\> :\n                      \\begin{minipg5}\n                        Calculate derivative from the right hand side.\n                      \\end{minipg5}\\\\[0.8ex]\n        \\>\\>    {\\fov epar}\\> - \\>  \\begin{minipg2}\n                    Parameter value at which to calculate. Dimension\n                       of {\\fov epar} is 2.\n                               \\end{minipg2}\\\\[0.8ex]\n\\newpagetabs\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov ilfs}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knotvector\n                        in first parameter direction where {\\fov epar}[0]\n                        is found. The relation\n                        \\[\n                          et1[ilfs]\\leq epar[0] < et1[ilfs+1],\n                        \\]\n                        where {\\fov et1} is the knotvektor, should hold.\n                        {\\fov ilfs} is set equal to zero at the first call\n                        to the routine.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ilft}\\> - \\>  \\begin{minipg2}\n                     Corresponding to {\\fov ilfs} in the second parameter\n                        direction.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov eder}\\> - \\>  \\begin{minipg2}\n                     Array where the derivative of the curve in\n                       {\\fov apar} is placed. The sequence is position,\n                       first derivative in first parameter direction,\n                       first derivative in second parameter direction,\n                       (2,0) derivative, (1,1) derivative, (0,2)\n                       derivative, etc. The expression\n                       \\[\n                       idim*(1+2+...+(ider+1))\n                       \\]\n                       gives the dimension of the {\\fov eder} array.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov enorm}\\> - \\>  \\begin{minipg2}\n                     Normal of surface. Is calculated if $ider\\geq 1$.\n                       Dimension is {\\fov idim}. The normal is not normalized.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>      $= 2$ : \\>\n                                \\begin{minipg5}\n                                  Surface is degenerate at the point,\n                                  normal has zero length.\n                                \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>\\>      $= 1$ : \\>\n                                \\begin{minipg5}\n                                  Surface is close to degenerate at the\n                                  point. Angle between tangents is less\n                                  than the angular tolerance.\n                                \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>\\>      $= 0$ : \\>      Ok.\\\\\n                \\>\\>\\>\\>\\>      $< 0$ : \\>      Error.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf    \\>  *{\\fov ps1}; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\>  {\\fov ider} = 1;\\\\\n        \\>\\>    int    \\>  {\\fov iside1} = 0;\\\\\n        \\>\\>    int    \\>  {\\fov iside2} = 1;\\\\\n        \\>\\>    double \\>  {\\fov epar}[2]; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\>  {\\fov ilfs} = 0; /* Define initially as zero. For consequtive evaluations \\\\\n                \\>\\>\\>\\>\\> leave ilfs as returned from s1422 */\\\\\n        \\>\\>    int    \\>  {\\fov ilft} = 0; /* As for ilfs */\\\\\n        \\>\\>    double \\>  {\\fov eder}[9]; /* Length is spatial dimension times total number of entities */\\\\\n        \\>\\>    double \\>  {\\fov enorm}[3]; /* Length is spatial dimension */ \\\\\n        \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1422(\\begin{minipg4}\n          {\\fov ps1}, {\\fov ider}, {\\fov iside1}, {\\fov iside2}, {\\fov epar}, \\&{\\fov ilfs}, \\&{\\fov ilft}, {\\fov eder}, {\\fov enorm}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1424.tex",
    "content": "\\subsection{Compute the position and derivatives of a surface at a given\nparameter value pair.}\n\\funclabel{s1424}\n\\begin{minipg1}\n  Evaluate the surface the parameter value ({\\fov parvalue}[0],\n  {\\fov parvalue}[1]).\n  Compute the $der1\\times der2$ first derivatives.\n  The derivatives that will be computed are $D^{i,j}$,\n  $i=0,1,\\ldots,der1$, $j=0,1,...,der2$.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1424(\\begin{minipg3}\n          {\\fov surf}, {\\fov der1}, {\\fov der2}, {\\fov parvalue}, {\\fov leftknot1}, {\\fov leftknot2}, {\\fov derive}, {\\fov stat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n        \\>\\>    int     \\>      {\\fov der1};\\\\\n        \\>\\>    int     \\>      {\\fov der2};\\\\\n        \\>\\>    double  \\>      {\\fov parvalue}[\\,];\\\\\n        \\>\\>    int     \\>      *{\\fov leftknot1};\\\\\n        \\>\\>    int     \\>      *{\\fov leftknot2};\\\\\n        \\>\\>    double  \\>      {\\fov derive}[\\,];\\\\\n        \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the surface to evaluate.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov der1}\\> - \\>      \\begin{minipg2}\n                                Number (order) of derivatives to be\n                                evaluated in\n                                first parameter direction, where $0\\leq der1$.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov der2}\\> - \\>              \\begin{minipg2}\n                                Number (order) of derivatives to be\n                                evaluated in\n                                second parameter direction, where $0\\leq\n                                der2$.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov parvalue}\\> - \\>          \\begin{minipg2}\n                                Parameter-value at which to evaluate. The dimension\n                                of {\\fov parvalue} is 2.\n                                \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov leftknot1}\\> - \\> \\begin{minipg2}\n                                Pointer to the interval in the knot vector in first\n                                parameter direction where {\\fov parvalue}[0] is\n                                found. The relation\n                                \\[\n                                etl[leftknot1]\\leq parvalue[0]<etl[leftknot1+1],\n                                \\]\n                                where {\\fov etl} is the knot vector, should\n                                hold. {\\fov leftknot1}  should be set\n                                equal to zero at the first call to the\n                                routine.\n                                Do not change the value of {\\fov leftknot1}\n                                between calls to the routine.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov leftknot2}\\> - \\> \\begin{minipg2}\n                                Corresponding to {\\fov leftknot1} in the\n                                second parameter direction.\n                                \\end{minipg2}\\\\[0.8ex]\n\\newpagetabs\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov derive}\\> - \\>    \\begin{minipg2}\n                                Array of size $d(der1+1)(der2+1)$\n                                where the position and the derivative\n                                vectors of the surface in\n                                ({\\fov parvalue}[0], {\\fov parvalue}[1]) is placed.\n                                $d=surf\\rightarrow dim$ is the number of\n                                elements in each vector and is equal to\n                                the geometrical dimension.\n                       The vectors are stored in the following order:\n                       First the $d$ components of the position vector,\n                       then the $d$ components of the $D^{1,0}$ vector,\n                       and so on up to the $d$ components of the $D^{der1,0}$\n                       vector,\n                       then the $d$ components of the $D^{0,1}$ vector etc.\n                       If derive is considered to be a\n                       three dimensional array, then its declaration in C\n                       would be $derive[der2+1][der1+1][d]$.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>      $> 0$ : \\>      Warning.\\\\\n                \\>\\>\\>\\>\\>      $= 0$ : \\>      Ok.\\\\\n                \\>\\>\\>\\>\\>      $< 0$ : \\>      Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov der1} = 2;\\\\\n                \\>\\>    int     \\>      {\\fov der2} = 1;\\\\\n                \\>\\>    double  \\>      {\\fov parvalue}[2]; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov leftknot1} = 0; /* Define initially as zero. For consequtive evaluations \\\\\n                \\>\\>\\>\\>\\>\\> leave leftknot1 as returned from s1424 */\\\\\n                \\>\\>    int     \\>      {\\fov leftknot2} = 0;; /* As for leftknot1 */ \\\\\n                \\>\\>    double  \\>      {\\fov derive}[18]; /* Length is spatial dimension times total number of entities */ \\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1424(\\begin{minipg4}\n                {\\fov surf}, {\\fov der1}, {\\fov der2}, {\\fov parvalue}, \\&{\\fov leftknot1}, \\&{\\fov leftknot2}, {\\fov derive}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1425.tex",
    "content": "\\subsection{Compute the position and the derivatives of a surface at a\ngiven parameter value pair.}\n\\funclabel{s1425}\n\\begin{minipg1}\n  To compute the value and $ider1\\times ider2$ first derivatives\n  of a tensor product surface at the point with parameter value\n  ({\\fov epar}[0], {\\fov epar}[1]).\n  The derivatives that will be computed are $D(i,j)$,\n  $i=0,1,\\dots,ider1$, $j=0,1,\\dots,ider2$. The calculations are\n  from the right hand or left hand side.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1425(\\begin{minipg3}\n          {\\fov ps1}, {\\fov ider1}, {\\fov ider2}, {\\fov iside1}, {\\fov iside2}, {\\fov epar}, {\\fov ileft1}, {\\fov ileft2}, {\\fov eder}, {\\fov jstat})\n        \\end{minipg3}\\\\\n        \\>\\>    SISLSurf    \\>  *{\\fov ps1};\\\\\n        \\>\\>    int    \\>  {\\fov ider1};\\\\\n        \\>\\>    int    \\>  {\\fov ider2};\\\\\n        \\>\\>    int    \\>  {\\fov iside1};\\\\\n        \\>\\>    int    \\>  {\\fov iside2};\\\\\n        \\>\\>    double \\>  {\\ epar}[\\,];\\\\\n        \\>\\>    int    \\>  *{\\fov ileft1};\\\\\n        \\>\\>    int    \\>  *{\\fov ileft2};\\\\\n        \\>\\>    double \\>  {\\fov eder}[\\,];\\\\\n        \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov ps1}\\> - \\>  \\begin{minipg2}\n                     Pointer to the surface for which position\n                       and derivatives are to be computed.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ider1}\\> - \\>\n        \\begin{minipg2}\n          The number of derivatives to be computed with respect\n          to the first parameter direction.\n        \\end{minipg2}\\\\[0.8ex]\n                     \\>\\>\\>\\> $<0$ \\> \\> : Error, no derivative calculated.\\\\\n                     \\>\\>\\>\\> $=0$ \\> \\> :\n                     \\begin{minipg5}\n                       No derivatives with respect to the first\n                       parameter direction will be computed.\n                       (Only derivatives of the type\n                       $D(0,0),D(0,1),\\dots,D(0,ider2)$).\n                     \\end{minipg5}\\\\[0.8ex]\n                     \\>\\>\\>\\> $=1$ \\> :\n                     \\begin{minipg5}\n                       Derivatives up to first order with respect to\n                       the first parameter direction will be\n                       computed.\n                     \\end{minipg5}\\\\[0.8ex]\n                     \\>\\>\\>\\>      \\>   etc.\\\\\n\\newpagetabs\n        \\>\\>    {\\fov ider2}\\> - \\>  \\begin{minipg2}\n                     The number of derivatives to be computed with respect\n                       to the second parameter direction.\n        \\end{minipg2}\\\\[0.8ex]\n                     \\>\\>\\>\\> $<0$ \\> \\> : Error, no derivative calculated.\\\\\n                     \\>\\>\\>\\> $=0$ \\> \\> :\n                     \\begin{minipg5}\n                       No derivatives with respect to the second\n                       parameter direction will be computed.\n                       (Only derivatives of the type\n                       $D(0,0),D(1,0),\\dots,D(ider1,0)$).\n                     \\end{minipg5}\\\\[0.8ex]\n                     \\>\\>\\>\\> $=1$ \\> :\n                     \\begin{minipg5}\n                       Derivatives up to first order with respect to\n                       the second parameter direction will be computed.\n                     \\end{minipg5}\\\\[0.8ex]\n                     \\>\\>\\>\\>      \\>   etc.\\\\\n        \\>\\>    {\\fov iside1}\\> - \\>\n        \\begin{minipg2}\n          Indicator telling if the derivatives in the first\n          parameter direction is to be calculated from the\n          left or from the right:\n        \\end{minipg2}\\\\[0.3ex]\n                      \\>\\>\\>\\> $<0$ \\> :\n                      \\begin{minipg5}\n                        Calculate derivative from the left hand side.\n                      \\end{minipg5}\\\\[0.8ex]\n                      \\>\\>\\>\\> $\\geq 0$ \\> :\n                      \\begin{minipg5}\n                        Calculate derivative from the right hand side.\n                      \\end{minipg5}\\\\[0.8ex]\n        \\>\\> {\\fov iside2}\\> - \\>\n        \\begin{minipg2}\n          Indicator telling if the derivatives in the second\n          parameter direction is to be calculated from the\n          left or from the right:\n        \\end{minipg2}\\\\[0.3ex]\n                      \\>\\>\\>\\> $<0$ \\> :\n                      \\begin{minipg5}\n                        Calculate derivative from the left hand side.\n                      \\end{minipg5}\\\\[0.8ex]\n                      \\>\\>\\>\\> $\\geq 0$ \\> :\n                      \\begin{minipg5}\n                        Calculate derivative from the right hand side.\n                      \\end{minipg5}\\\\[0.8ex]\n        \\>\\>    {\\fov epar}\\> - \\>\n        \\begin{minipg2}\n          Array of dimension 2 containing the\n          parameter values of the point at which the position\n          and derivatives are to be computed.\n        \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov ileft1}\\> - \\>\n        \\begin{minipg2}\n          Pointer to the interval in the knot vector\n          in the first parameter direction where {\\fov epar}[0]\n          is located. If {\\fov et1} is the knot vector in the first\n          parameter direction, the relation\n          \\[\n          et1[ileft]\\leq epar[0] < et1[ileft+1],\n          \\]\n          should hold. (If $epar[0]=et1[in1]$ then {\\fov ileft} should\n          be $in1-1$. Here {\\fov in1} is the number of B-spline\n          coefficients associated with {\\fov et1}.)\n          If {\\fov ileft1} does not have the right value upon\n          entry to the routine, its value will be changed\n          to the value satisfying the above condition.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ileft2}\\> - \\>\n        \\begin{minipg2}\n          Pointer to the interval in the knot vector\n          in the second parameter direction where {\\fov epar}[1]\n          is located. If {\\fov et2} is the knot vector in the second\n          parameter direction, the relation\n          \\[\n          et2[ileft]\\leq epar[1] < et2[ileft+1],\n          \\]\n          should hold. (If $epar[1]=et2[in2]$ then {\\fov ileft} should\n          be $in2-1$. Here {\\fov in2} is the number of B-spline\n          coefficients associated with {\\fov et2}.)\n          If {\\fov ileft2} does not have the right value upon\n          entry to the routine, its value will be changed\n          to the value satisfying the above condition.\n        \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov eder}\\> - \\>\n        \\begin{minipg2}\n          Array of dimension $(ider2+1)*(ider1+1)*idim$\n          containing the position and the derivative vectors\n          of the surface at the point with parameter value\n          ({\\fov epar}[0], {\\fov epar}[1]).\n          ({\\fov idim} is the number of components of each B-spline\n          coefficient, i.e. the dimension of the Euclidean\n          space in which the surface lies.)\n          These vectors are stored in the following order:\n          First the {\\fov idim} components of the position vector,\n          then the {\\fov idim} components of the $D(1,0)$ vector,\n          and so on up to the {\\fov idim} components of the $D(ider1,0)$\n          vector,\n          then the {\\fov idim} components of the $D(1,1)$ vector etc.\n          Equivalently, if {\\fov eder} is considered to be a\n          three dimensional array, then its declaration in C\n          would be $eder[ider2+1,ider1+1,idim]$.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>      $> 0$ : \\>      Warning.\\\\\n                \\>\\>\\>\\>\\>      $= 0$ : \\>      Ok.\\\\\n                \\>\\>\\>\\>\\>      $< 0$ : \\>      Error.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf    \\>  *{\\fov ps1}; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\>  {\\fov ider1} = 1;\\\\\n        \\>\\>    int    \\>  {\\fov ider2} = 1;\\\\\n        \\>\\>    int    \\>  {\\fov iside1} = 0;\\\\\n        \\>\\>    int    \\>  {\\fov iside2} = -1;\\\\\n        \\>\\>    double \\>  {\\fov epar}[2]; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\>  {\\fov ileft1} = 0; /* Define initially as zero. For consequtive evaluations \\\\\n                \\>\\>\\>\\>\\> leave ileft1 as returned from s1425 */\\\\\n        \\>\\>    int    \\>  {\\fov ileft2} = 0; /* As for ileft1 */\\\\\n        \\>\\>    double \\>  {\\fov eder}[12]; /* Length is spatial dimension times total number of entities */\\\\\n        \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1425(\\begin{minipg4}\n          {\\fov ps1}, {\\fov ider1}, {\\fov ider2}, {\\fov iside1}, {\\fov iside2}, {\\fov epar}, \\&{\\fov ileft1}, \\&{\\fov ileft2}, {\\fov eder}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1436.tex",
    "content": "\\subsection{Pick a curve lying in surface, with constant second parameter value.}\n\\funclabel{s1436}\n\\begin{minipg1}\nMake constant parameter curve in the surface. The constant parameter value \nused is parvalue and is in the second parameter direction. \n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1436(\\begin{minipg3}\n\t\t\t{\\fov surf}, {\\fov parvalue}, {\\fov curve}, {\\fov stat})\n\t\t\\end{minipg3}\\\\[0.3ex]\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov parvalue};\\\\\n\t\t\\>\\>\tSISLCurve\t\\>\t**{\\fov curve};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov surf}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tSurface to pick the curve from.\n\t\t\t\t\\end{minipg2}\\\\[0.3ex]\n\t\\>\\>\t{\\fov parvalue}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tParameter value in the second parameter direction used when picking \n\t\t\t\tthe curve.\n\t\t\t\t\\end{minipg2}\\\\[0.3ex]\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov curve}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tSISLCurve at constant parameter value.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov stat}\t\\> - \\>\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov parvalue};\\\\\n\t\t\\>\\>\tSISLCurve\t\\>\t*{\\fov curve};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov stat};\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1436(\\begin{minipg4}\n\t\t{\\fov surf}, {\\fov parvalue}, \\&{\\fov curve}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1437.tex",
    "content": "\\subsection{Pick a curve lying in a surface, with constant first parameter value.}\n\\funclabel{s1437}\n\\begin{minipg1}\nMake constant parameter curve in the surface. The constant parameter value \nused is parvalue and is in the first parameter direction.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1436(\\begin{minipg3}\n\t\t\t{\\fov surf}, {\\fov parvalue}, {\\fov curve}, {\\fov stat})\n\t\t\\end{minipg3}\\\\[0.3ex]\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov parvalue};\\\\\n\t\t\\>\\>\tSISLCurve\t\\>\t**{\\fov curve};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov surf}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tSurface to pick curve from.\n\t\t\t\t\\end{minipg2}\\\\[0.3ex]\n\t\\>\\>\t{\\fov parvalue}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tParameter value used when picking \n\t\t\t\tthe curve at a constant \t\n\t\t\t\tparameter curve in first parameter direction.\n\t\t\t\t\\end{minipg2}\\\\[0.3ex]\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov curve}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tSISLCurve at constant parameter value.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov stat}\t\\> - \\>\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov parvalue};\\\\\n\t\t\\>\\>\tSISLCurve\t\\>\t*{\\fov curve};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov stat};\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1437(\\begin{minipg4}\n\t\t{\\fov surf}, {\\fov parvalue}, \\&{\\fov curve}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1439.tex",
    "content": "\\subsection{Pick a curve along a constant parameter line in a surface.}\n\\funclabel{s1439}\n\\begin{minipg1}\n  Make a constant parameter curve along a given parameter direction in a surface.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1439(\\begin{minipg3}\n          {\\fov ps1}, {\\fov apar}, {\\fov idirec}, {\\fov rcurve}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf \\> *{\\fov ps1};\\\\\n        \\>\\>    double   \\> {\\fov apar};\\\\\n        \\>\\>    int      \\> {\\fov idirec};\\\\\n        \\>\\>    SISLCurve \\> **{\\fov rcurve};\\\\\n        \\>\\>    int      \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov ps1}\\> - \\>  \\begin{minipg2}\n                     Pointer to the surface.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov apar}\\> - \\>  \\begin{minipg2}\n                     Parameter value to use when picking out constant\n                       parameter curve.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov idirec}\\> - \\>\n                     Parameter direction in which to pick (must be 1 or 2).\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rcurve}\\> - \\>  \\begin{minipg2}\n                     Constant parameter curve.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>           $> 0$ \\> : Warning.\\\\\n                \\>\\>\\>\\>\\>           $= 0$ \\> : Ok.\\\\\n                \\>\\>\\>\\>\\>           $< 0$ \\> : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf \\> *{\\fov ps1}; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> {\\fov apar}; \\, /* Must be defined */\\\\\n        \\>\\>    int      \\> {\\fov idirec} = 1;\\\\\n        \\>\\>    SISLCurve \\> *{\\fov rcurve} = NULL;\\\\\n        \\>\\>    int      \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1439(\\begin{minipg4}\n          {\\fov ps1}, {\\fov apar}, {\\fov idirec}, \\&{\\fov rcurve}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1440.tex",
    "content": "\\section{Turn the Direction of the Surface Normal Vector.}\n\\funclabel{s1440}\n\\begin{minipg1}\n  Interchange the two parameter directions used in the mathematical\n  description of a surface and thereby change the direction of the\n  normal vector of the surface.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1440(\\begin{minipg3}\n                                {\\fov surf}, {\\fov newsurf}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    SISLSurf        \\>      **{\\fov newsurf};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the original surface.\n                                \\end{minipg2}\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newsurf}\\> - \\>   \\begin{minipg2}\n                                Pointer to the surface where the parameter\n                                directions are interchanged.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov newsurf} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1440(\\begin{minipg4}\n                {\\fov surf}, \\&{\\fov newsurf}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1441.tex",
    "content": "\\subsection{Compute volume between a B-spline surface and a point.}\n\\funclabel{s1441}\n\\begin{minipg1}\nCompute the volume of the object surrounded by the input surface and the \nsurface defined by the reference point and the boundary of the input surface. The \nvolume might have a negative value dependent on the \"direction\" of the surface \nrelative to the reference point. When used on a closed surface, the routine \ngives as output the volume of the object surrounded by the surface. The \ndifference between the volume calculated and the real volume will be less than \n(epssurf/the volume calculated).\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1441\t(\\begin{minipg3}\n\t\t\t\t{\\fov surf}, {\\fov point}, {\\fov dim}, {\\fov epssurf}, {\\fov epsge}, {\\fov volume}, {\\fov stat})\n\t\t\\end{minipg3}\\\\[0.3ex]\n\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov point}[\\,];\\\\\n\t\t\\>\\>\tint\t\\>\t{\\fov dim};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov epssurf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epsge};\\\\\n\t\t\\>\\>\tdouble\t\\>\t*{\\fov volume};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov surf}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tPointer to the surface.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov point}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tReference point in the volume computation.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov dim}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tDimension of the space in which the point and surface lie.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov epssurf}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tRelative resolution used on surfaces.\n\t\t\t\t\\end{minipg2} \\\\\n\t\\>\\>\t{\\fov epsge}\\> - \\> \\begin{minipg2}\n\t\t\t\tGeometry resolution.\n\t\t\t\t\\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov volume}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tThe volume calculated\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov stat}\t\\> - \\>\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov point[3]};\\\\\n\t\t\\>\\>\tint\t\\>\t{\\fov dim = 3};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov epssurf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epsge};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov volume};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov stat};\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1441\t(\\begin{minipg4}\n\t\t{\\fov surf}, {\\fov point}, {\\fov dim}, {\\fov epssurf}, {\\fov epsge}, \\&{\\fov volume}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1442.tex",
    "content": "\\subsection{Compute area, weight point and moment of inertia of a B-spline patch.}\n\\funclabel{s1442}\n\\begin{minipg1}\nCompute the area and the weight point of a surface by using recursive \nsubdivision. The rotational momentum relative to  a given axis is also \ncalculated. The difference between the area computed and the real area of the \nsurface is less than (epssurf/area computed).\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1442(\\begin{minipg3}\n\t\t\t{\\fov surf}, {\\fov point}, {\\fov dir}, {\\fov dim}, {\\fov epssurf}, {\\fov epsge}, {\\fov weight}, {\\fov area}, \t\n\t\t\t{\\fov moment}, {\\fov stat})\n\t\t\\end{minipg3}\\\\[0.3ex]\n\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov point}[\\,];\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov dir}[\\,];\\\\\n\t\t\\>\\>\tint\t\\>\t{\\fov dim};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epssurf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epsge};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov weight}[\\,];\\\\\n\t\t\\>\\>\tdouble \t\\>\t*{\\fov area};\\\\\n\t\t\\>\\>\tdouble \t\\>\t*{\\fov moment};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov surf}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tPointer to the surface.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov point}\\> - \\>\t\\begin{minipg2}\n\t\t\t\t(Reference) point on the rotational axis.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov dir}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tDirection of the rotational axis.\t\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov dim}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tDimension of the space in which point and dir lie.\n\t\t\t\t\\end{minipg2} \\\\\n\t\\>\\>\t{\\fov epssurf}\\> - \\> \t\\begin{minipg2}\n\t\t\t\tRelative resolution used on surfaces.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov epsge}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tGeometry resolution.\n\t\t\t\t\\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov weight}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tArea weight point.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov area}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tThe area calculated.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov moment}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tRotational weight moment.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov stat}\t\\> - \\>\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n\t\t\\>\\>\tSISLSurf\t\\> \t*surf;\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov point}[3];\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov dir}[3];\\\\\n\t\t\\>\\>\tint\t\\>\t{\\fov dim} = 3;\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epssurf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epsge};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov weight}[3];\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov area};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov moment};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov stat};\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1442(\\begin{minipg4}\n\t\t{\\fov surf}, {\\fov point}, {\\fov dir}, {\\fov dim}, {\\fov epssurf}, {\\fov epsge}, {\\fov weight}, \\&{\\fov area}, \t\t\n\t\t\\&{\\fov moment}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1443.tex",
    "content": "\\subsection{Compute volume, weight point and moment of inertia of an object defined by a B-spline \npatch and a point.}\n\\funclabel{s1443}\n\\begin{minipg1}\nCompute the volume and the weight point of the object surrounded (by the \ninput \nsurface and the surface defined by the reference point) and boundary of the input surface, by using recursive subdivision. The \nrotational momentum relative to a given axis is also calculated. The \ndifference between the volume computed and the real volume of the object \nis \nless than (epssurf/volume computed).\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1443(\\begin{minipg3}\n\t\t\t{\\fov surf}, {\\fov refpoint}, {\\fov axpoint}, {\\fov dir}, {\\fov dim}, {\\fov epssurf}, {\\fov epsge}, {\\fov weight}, \t\n\t\t\t{\\fov volume}, {\\fov moment}, {\\fov stat}))\n\t\t\\end{minipg3}\\\\[0.3ex]\n\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov refpoint}[\\,];\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov axpoint}[\\,];\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov dir}[\\,];\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov dim};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epssurf};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov epsge};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov weight}[\\,];\\\\\n\t\t\\>\\>\tdouble \t\\>\t*{\\fov volume};\\\\\n\t\t\\>\\>\tdouble\t\\>\t*{\\fov moment};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov surf}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tPointer to the surface.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov refpoint}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tReference point in volume computation.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov axpoint}\\> - \\>\t\t\\begin{minipg2}\n\t\t\t\tPoint on the rotational axis.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov dir}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tDirection of the rotational axis\n\t\t\t\t\\end{minipg2} \\\\\n\t\\>\\>\t{\\fov dim}\\> - \\> \t\\begin{minipg2}\n\t\t\t\tDimension of the space in which point, axpoint and dir \n\t\t\t\tlie.\n\t\t\t\t\\end{minipg2}\\\\[0.8ex]\n\t\\>\\>\t{\\fov epssurf}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tRelative resolution used on surfaces.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov epsge}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tGeometry resolutions.\n\t\t\t\t\\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov weight}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tWeight point of object.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov volume}\\> - \\>\t\t\\begin{minipg2}\n\t\t\t\tThe volume calculated.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov moment}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tRotational weight moment.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov stat}\t\\> - \\>\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov refpoint[3]};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov axpoint[3]};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov dir[3]};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov dim = 3};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epssurf};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov epsge};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov weight[3]};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov volume};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov moment};\\\\\n\t\t\\>\\>\tint \t\\>\tstat;\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1443(\\begin{minipg4}\n\t\t{\\fov surf}, {\\fov refpoint}, {\\fov axpoint}, {\\fov dir}, {\\fov dim}, {\\fov epssurf}, {\\fov epsge}, {\\fov weight},\\linebreak\n\t\t\\&{\\fov volume},\\&{\\fov moment}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1450.tex",
    "content": "\\section{Check if a Surface is Closed or has Degenerate Edges.}\n\\funclabel{s1450}\n\\begin{minipg1}\n  To check if a surface is closed or has degenerate boundaries.\n  The edge numbers correspond to the  following:\n\\begin{center}\n        \\begin{picture}(180,110)(0,0)\n                \\put(50,15){\\framebox(80,80)}\n                \\put(40,55){\\makebox(0,0){4}}\n                \\put(140,55){\\makebox(0,0){2}}\n                \\put(90,5){\\makebox(0,0){1}}\n                \\put(90,105){\\makebox(0,0){3}}\n\n                \\put(60,20){\\vector(1,0){40}}\n                \\put(85,28){\\makebox(0,0){$(i)$}}\n                \\put(55,25){\\vector(0,1){40}}\n                \\put(65,50){\\makebox(0,0){$(ii)$}}\n        \\end{picture}\\\\\n        $(i) \\; \\; \\;$ first parameter direction of surface.\\\\\n        $(ii)$   second parameter direction of surface.\\\\\n\\end{center}\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1450(\\begin{minipg3}\n                {\\fov surf}, {\\fov epsge}, {\\fov close1}, {\\fov close2}, {\\fov degen1}, {\\fov degen2}, {\\fov degen3}, {\\fov degen4},\n                {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov close1};\\\\\n                \\>\\>    int     \\>      *{\\fov close2};\\\\\n                \\>\\>    int     \\>      *{\\fov degen1};\\\\\n                \\>\\>    int     \\>      *{\\fov degen2};\\\\\n                \\>\\>    int     \\>      *{\\fov degen3};\\\\\n                \\>\\>    int     \\>      *{\\fov degen4};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>              \\begin{minipg2}\n                                Pointer to the surface that is to be checked.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Tolerance used during testing.\n                                \\end{minipg2}\\\\\n\\newpagetabs\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov close1}\\> - \\>    \\begin{minipg2}\n                                Closed indicator in the first parameter direction.\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      $=0$ :\\>\\begin{minipg5}\n                                Surface open in first direction\n                                \\end{minipg5}\\\\\n                \\>\\>\\>\\>\\>      $=1$ :\\>\\begin{minipg5}\n                                Surface closed in first direction\n                                \\end{minipg5}\\\\\n        \\>\\>    {\\fov close2}\\> - \\>    \\begin{minipg2}\n                                Closed indicator in second direction\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      $=0$ :\\>\\begin{minipg5}\n                                Surface open in second direction\n                                \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>\\>      $=1$ :\\>\\begin{minipg5}\n                                Surface closed in second direction\n                                \\end{minipg5}\\\\[0.8ex]\n        \\>\\>    {\\fov degen1}\\> - \\>    \\begin{minipg2}\n                                Degenerate indicator along standard edge 1\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      $=0$ :\\>        Edge is not degenerate\\\\\n                \\>\\>\\>\\>\\>      $=1$ :\\>        Edge is degenerate\\\\\n        \\>\\>    {\\fov degen2}\\> - \\>    \\begin{minipg2}\n                                Degenerate indicator along standard edge 2\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      $=0$ :\\>        Edge is not degenerate\\\\\n                \\>\\>\\>\\>\\>      $=1$ :\\>        Edge is degenerate\\\\\n        \\>\\>    {\\fov degen3}\\> - \\>    \\begin{minipg2}\n                                Degenerate indicator along standard edge 3\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      $=0$ :\\>        Edge is not degenerate\\\\\n                \\>\\>\\>\\>\\>      $=1$ :\\>        Edge is degenerate\\\\\n        \\>\\>    {\\fov degen4}\\> - \\>    \\begin{minipg2}\n                                Degenerate indicator along standard edge 4\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      $=0$ :\\>        Edge is not degenerate\\\\\n                \\>\\>\\>\\>\\>      $=1$ :\\>        Edge is degenerate\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 0.000001;\\\\\n                \\>\\>    int     \\>      {\\fov close1} = 0;\\\\\n                \\>\\>    int     \\>      {\\fov close2} = 0;\\\\\n                \\>\\>    int     \\>      {\\fov degen1} = 0;\\\\\n                \\>\\>    int     \\>      {\\fov degen2} = 0;\\\\\n                \\>\\>    int     \\>      {\\fov degen3} = 0;\\\\\n                \\>\\>    int     \\>      {\\fov degen4} = 0;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1450(\\begin{minipg4}\n                {\\fov surf}, {\\fov epsge}, \\&{\\fov close1}, \\&{\\fov close2}, \\&{\\fov degen1}, \\&{\\fov degen2}, \\&{\\fov degen3}, \\&{\\fov degen4},\n                \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1451.tex",
    "content": "\\section{Check if a Curve is Degenerated.}\n\\funclabel{s1451}\n\\begin{minipg1}\n  To check if a curve is degenerated.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1451(\\begin{minipg3}\n          {\\fov pc1}, {\\fov aepsge}, {\\fov jdgen}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLCurve \\> *{\\fov pc1};\\\\\n        \\>\\>    double    \\> {\\fov aepsge};\\\\\n        \\>\\>    int       \\> *{\\fov jdgen};\\\\\n        \\>\\>    int       \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov pc1}    \\> - \\> Pointer to the curve to be tested.\\\\\n        \\>\\>    {\\fov aepsge} \\> - \\>\n        \\begin{minipg2}\n          The curve is degenerate if all vertices lie\n          within the distance aepsge from each other\n        \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov jdgen}  \\> - \\> Degenerate indicator\\\\\n                \\>\\>\\>\\>\\> $= 0$ : The curve is not degenerate.\\\\\n                \\>\\>\\>\\>\\> $= 1$ : The curve is degenerate.\\\\\n        \\>\\>    {\\fov jstat}  \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve    \\>  *{\\fov pc1}; \\, /* Must be defined */\\\\\n        \\>\\>    double \\>  {\\fov aepsge} = 1.0e-5;\\\\\n        \\>\\>    int    \\>  *{\\fov jdgen} = 0;\\\\\n        \\>\\>    int    \\>  *{\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1451(\\begin{minipg4}\n          {\\fov pc1}, {\\fov aepsge}, {\\fov jdgen}, {\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1452.tex",
    "content": "\\subsection{Offset surface.}\n\\funclabel{s1452}\n\\begin{minipg1}\nTo make a B-spline surface approximating an offset surface using a given distance from the input surface.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1452(\\begin{minipg3}\n\t\t\t\t{\\fov surf}, {\\fov epsge}, {\\fov offdist}, {\\fov newsurf}, {\\fov stat})\n\t\t\\end{minipg3}\\\\[0.3ex]\n\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epsge};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov offdist};\\\\\n\t\t\\>\\>\tSISLSurf\t\\>\t**{\\fov newsurf};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov surf}\\> - \\>\t\\begin{minipg2}\n\t\t\tPointer to the surface from which the offset surface is to be made.\n\t\t\t\t\\end{minipg2}\\\\[0.8ex]\n\t\\>\\>\t{\\fov epsge}\\> - \\>\t\\begin{minipg2}\n\t\t\tAccepted deviation between the true offset surface and the approximated \n\t\t\toffset surface. If a small tolerance is \n\t\t\tgiven, the execution time will be long.\n\t\t\t\t\\end{minipg2}\\\\[0.3ex]\n\t\\>\\>\t{\\fov offdist}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tThe offset distance. If offdist is \n\t\t\t\tpositive the offset will be along the \n\t\t\t\tpositive direction of the normal vector, \n\t\t\t\telse along the negative \n\t\t\t\tdirection.\t\n\t\t\t\t\\end{minipg2}\\\\[0.3ex]\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov newsurf}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tThe produced offset surface.\t\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov stat}\t\\> - \\>\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epsge};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov offdist};\\\\\n\t\t\\>\\>\tSISLSurf\t\\>\t*{\\fov newsurf};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov stat};\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1452(\\begin{minipg4}\n\t\t{\\fov surf}, {\\fov epsge}, {\\fov offdist},\\&{\\fov newsurf}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1501.tex",
    "content": "\\subsection{March an intersection curve between a surface and an\n\\mbox{elliptic} cone.}\n\\funclabel{s1501}\n\\begin{minipg1}\n  To march an intersection curve described by parameter pairs in an intersection\n  curve object, a surface and an elliptic cone.\n  The guide points are expected to be found by s1503() described on\n  page \\pageref{s1503}.\n  The generated geometric curves are represented as B-spline curves.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1501(\\begin{minipg3}\n        {\\fov surf}, {\\fov basept}, {\\fov normdir}, {\\fov ellipaxis},\n        {\\fov alpha}, {\\fov ratio}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov maxstep},\n        {\\fov intcurve}, {\\fov makecurv}, {\\fov graphic}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov basept}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov normdir}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov ellipaxis}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov alpha};\\\\\n                \\>\\>    double  \\>      {\\fov ratio};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      {\\fov maxstep};\\\\\n                \\>\\>    SISLIntcurve\\>  *{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      {\\fov makecurv};\\\\\n                \\>\\>    int     \\>      {\\fov graphic};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov basept}\\> - \\>    \\begin{minipg2}\n                                Base point of the cone, centre of elliptic base.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov normdir}\\> - \\>   \\begin{minipg2}\n                                Direction of the cone axis, normal to the elliptic base. The default is pointing from the base point to the top point.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov ellipaxis}\\> - \\> \\begin{minipg2}\n                                One of the axes of the ellipse (major or\n                                minor).\n                                The other axis will be calculated as\n                                $normdir\\times ellipaxis$ scaled with\n                                {\\fov ratio}.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov alpha}\\> - \\>     \\begin{minipg2}\n                                The opening angle in radians of the cone at the ellipaxis.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov ratio}\\> - \\>     \\begin{minipg2}\n                                The ratio of the major and minor\n                                axes = ellipaxis/otheraxis.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov dim}\\> - \\>       \\begin{minipg2}\n                                Dimension of the space in which the cone lies.\n                                Should be 3.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov maxstep}\\> - \\>   \\begin{minipg2}\n                                Maximum step length allowed. If maxstep $\\leq$ epsge,\n                                maxstep is neglected. maxstep = 0.0 is recommended.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov makecurv}\\> - \\>          \\begin{minipg2}\n                                Indicator specifying if a geometric curve is to be made:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 -     \\>Do not make curves at all.\\\\\n                \\>\\>\\>\\>\\>      1 -     \\>Make only a geometric curve.\\\\\n                \\>\\>\\>\\>\\>      2 -     \\>\\begin{minipg5}\n                                        Make geometric curve and curve in the parameter\n                                        plane\n                                        \\end{minipg5} \\\\[0.3ex]\n        \\>\\>    {\\fov graphic}\\> - \\>   \\begin{minipg2}\n                                Indicator specifying if the function\n                                should draw the curve:\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      0 -     \\>Don't draw the curve.\\\\\n                \\>\\>\\>\\>\\>      1 -     \\>\\begin{minipg5}\n                                        Draw the geometric curve. This option is\n                                        outdated, if used see NOTE!\n                                        \\end{minipg5} \\\\[0.8ex]\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                                Pointer to the intersection curve.\n                                As input only\n                                guide points (points in parameter space)\n                                exist. These guide points\n                                are used for guiding the marching.\n                                The routine adds the\n                                intersection curve and curve in the parameter\n                                plane to the SISLIntcurve object according to the value\n                                of makecurv.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>      $= 3$ : \\>      \\begin{minipg5}\n                                                Iteration stopped due to singular\n                                                point or degenerate surface. A part of\n                                                an intersection curve may have been\n                                                traced out. If no curve is traced out,\n                                                the curve pointers in the SISLIntcurve\n                                                object point to NULL.\n                                                \\end{minipg5} \\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 0$   :\\> ok\\\\\n                \\>\\>\\>\\>\\>      $< 0$   :\\> error\\\\\n\\\\\nNOTE\\\\\n\\>      \\begin{minipg6}\nIf the draw option is used the empty dummy functions s6move() and\ns6line() are called.\nThus if the draw option is used, make sure\nyou have versions of functions s6move() and s6line() interfaced to your graphic package.\n\\end{minipg6}\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov basept}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov normdir}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov ellipaxis}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov alpha}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov ratio}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    double  \\>      {\\fov maxstep} = 0.0;\\\\\n                \\>\\>    SISLIntcurve\\>  *{\\fov intcurve}; /* The intersection curve instance is defined in s1853 */\\\\\n                \\>\\>    int     \\>      {\\fov makecurv} = 2;\\\\\n                \\>\\>    int     \\>      {\\fov graphic} = 0;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1501(\\begin{minipg4}\n                {\\fov surf}, {\\fov basept}, {\\fov normdir}, {\\fov ellipaxis}, {\\fov alpha}, {\\fov ratio}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov maxstep},\n                {\\fov intcurve}, {\\fov makecurv}, {\\fov graphic}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1502.tex",
    "content": "\\subsection{Intersection between a spline curve and an elliptic cone.}\n\\funclabel{s1502}\n\\begin{minipg1}\n  Find all the intersections between a curve and an elliptic cone.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1502(\\begin{minipg3}\n         {\\fov curve}, {\\fov basept}, {\\fov normdir}, {\\fov ellipaxis}, {\\fov alpha}, {\\fov ratio}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov numintpt}, {\\fov intpar},\n                        {\\fov numintcu}, {\\fov intcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov basept}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov normdir}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov ellipaxis}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov alpha};\\\\\n                \\>\\>    double  \\>      {\\fov ratio};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov intpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcu};\\\\\n                \\>\\>    SISLIntcurve \\> ***{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to the curve.\\\\\n        \\>\\>    {\\fov basept}\\> - \\>    \\begin{minipg2}\n                                Base point of the cone, centre of elliptic base.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov normdir}\\> - \\>   \\begin{minipg2}\n                                Direction of the cone axis, normal to the elliptic base. The default is pointing from the base point to the top point of the cone.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov ellipaxis}\\> - \\> \\begin{minipg2}\n                                One of the axes of the ellipse (major or minor).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov alpha}\\> - \\>     \\begin{minipg2}\n                                The opening angle of the cone at the ellipaxis.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov ratio}\\> - \\>     \\begin{minipg2}\n                                The ratio of the major and minor\n                                axes = ellipaxis/otheraxis.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                Dimension of the space in which the\n                                cone and the curve\n                                lie, dim should be equal to three.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov epsco}    \\> - \\> Computational resolution (not used).\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> Geometry resolution.\\\\\n\\newpagetabs\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  Number of single intersection points.\\\\\n        \\>\\>    {\\fov intpar}   \\> - \\> \\begin{minipg2}\n                        Array containing the parameter values of the\n                        single intersection points in the parameter\n                        interval of the curve. The points lie in sequence.\n                        Intersection curves are stored in intcurve.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcu}\\> - \\>Number of intersection curves.\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                        Array of pointers to the SISLIntcurve object\n                        containing descriptions of the intersection\n                        curves. The curves are only described by start\n                        points and end points in\n                        the parameter interval of the curve. The curve\n                        pointers point to nothing.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov basept}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov normdir}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov ellipaxis}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov alpha}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov ratio} = 1.5;\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov intpar} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcu} = 0;\\\\\n                \\>\\>    SISLIntcurve \\> **{\\fov intcurve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1502(\\begin{minipg4}\n        {\\fov curve}, {\\fov basept}, {\\fov normdir}, {\\fov ellipaxis}, {\\fov alpha}, {\\fov ratio}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov numintpt},\n                \\&{\\fov intpar}, \\&{\\fov numintcu}, \\&{\\fov intcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1503.tex",
    "content": "\\subsection{Find the topology for the intersections between a spline surface and an\n\\mbox{elliptic} cone.}\n\\funclabel{s1503}\n\\begin{minipg1}\n  Find all intersections between a tensor-product surface and an elliptic cone.\n  Intersection curves are described by guide points.\n  To produce the intersection curves use s1501() described on page \\pageref{s1501}.\n\\end{minipg1} \\\\\nSYNOPSIS\\\\\n        \\>void s1503(\\begin{minipg3}\n                        {\\fov surf}, {\\fov basept}, {\\fov normdir}, {\\fov ellipaxis}, {\\fov alpha}, {\\fov ratio}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov numintpt}, {\\fov pointpar},\n                        {\\fov numintcr}, {\\fov intcurves}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov basept}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov normdir}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov ellipaxis}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov alpha};\\\\\n                \\>\\>    double  \\>      {\\fov ratio};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov pointpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcr};\\\\\n                \\>\\>    SISLIntcurve\\>  ***{\\fov intcurves};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the surface\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov basept}\\> - \\>    \\begin{minipg2}\n                                Base point of the cone, centre of elliptic base.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov normdir}\\> - \\>   \\begin{minipg2}\n                                Direction of the cone axis, normal to the elliptic base. The default is pointing from the base point to the top point.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ellipaxis}\\> - \\> \\begin{minipg2}\n                                One of the axes of the ellipse (major or\n                                minor).\n                                The other axis will be calculated as\n                                $normdir\\times ellipaxis$ scaled with\n                                {\\fov ratio}.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov alpha}\\> - \\>     \\begin{minipg2}\n                                The opening angle in radians of the cone at the ellipaxis.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ratio}\\> - \\>     \\begin{minipg2}\n                                The ratio of the major and minor\n                                axes = ellipaxis/otheraxis.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov dim}\\> - \\>       \\begin{minipg2}\n                                Dimension of the space in which the cone lies.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2}\n\\newpagetabs\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  \\begin{minipg2}\n                                Number of single intersection points.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov pointpar}\\> - \\>  \\begin{minipg2}\n                                Array containing the parameter values of the single\n                                intersection points in the parameter plane of the\n                                surface. The points lie in sequence. Intersection curves\n                                are stored in intcurves.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcr}\\> - \\>  \\begin{minipg2}\n                                Number of intersection curves.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov intcurves}\\> - \\> \\begin{minipg2}\n                                Array containing the description of the intersection\n                                curves. The curves are only described by\n                                start points and end points (guide points) in\n                                the parameter plane. The curve pointers point to\n                                nothing.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov basept}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov normdir}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov ellipaxis}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov alpha}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov ratio}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov pointpar} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcr} = 0;\\\\\n                \\>\\>    SISLIntcurve\\>  **{\\fov intcurves} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1503(\\begin{minipg4}\n                {\\fov surf}, {\\fov basept}, {\\fov normdir}, {\\fov ellipaxis}, {\\fov alpha}, {\\fov ratio}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov numintpt}, \\&{\\fov pointpar},\n                \\&numintcr, \\&intcurves, \\&stat);\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1506.tex",
    "content": "\\subsection{Evaluate the surface pointed at by ps1 over an m1 * m2 grid\n               of points (x[i],y[j]). Compute ider derivatives and normals\n               if suitable.}\n\\funclabel{s1506}\n\\begin{minipg1}\nEvaluate the surface pointed at by ps1 over an m1 * m2 grid\n               of points (x[i],y[j]). Compute ider derivatives and normals\n               if suitable.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1506(\\begin{minipg3}\n            {\\fov ps1}, {\\fov ider}, {\\fov m1}, {\\fov x}, {\\fov m2}, {\\fov y}, {\\fov eder}, {\\fov norm}, {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf \\>*{\\fov ps1};\\\\\n                \\>\\>    int    \\>  {\\fov ider};\\\\\n                \\>\\>    int    \\>  {\\fov m1};\\\\\n                \\>\\>    double    \\>  *{\\fov x};\\\\\n                \\>\\>    int    \\>  {\\fov m2};\\\\\n                \\>\\>    double    \\>  *{\\fov y};\\\\\n                \\>\\>    double    \\>  {\\fov eder}[\\,];\\\\\n                \\>\\>    double    \\>  {\\fov norm}[\\,];\\\\\n                \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov ps1}\\> - \\>  \\begin{minipg2}\n                     Pointer to the surface to evaluate.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov ider}\\> - \\> Number of derivatives to calculate.\\\\\n                 \\>\\>\\>\\>\\>      $< 0$ : No derivative calculated.\\\\\n\t\t \\>\\>\\>\\>\\>      $= 0$ : Position calculated.\\\\\n\t\t \\>\\>\\>\\>\\>      $= 1$ : Position and first derivative calculated.\\\\\n\t\t \\>\\>\\>\\>\\>      etc.\\\\\t \n        \\>\\>    {\\fov m1}\\> - \\>  \\begin{minipg2}\n                     Number of grid points in first direction.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov x}\\> - \\>  \\begin{minipg2}\n                     Array of x values of the grid.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov m2}\\> - \\>  \\begin{minipg2}\n                     Number of grid points in first direction.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov y}\\> - \\>  \\begin{minipg2}\n                     Array of y values of the grid.\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov eder}\\> - \\>  \\begin{minipg2}\n                     Array where the derivatives of the surface\n                       are placed, dimension\n                         idim * ((ider+1)(ider+2) / 2) * m1 * m2.\n                       The sequence is position,\n                       first derivative in first parameter direction,\n                       first derivative in second parameter direction,\n                       (2,0) derivative, (1,1) derivative, (0,2)\n                       derivative, etc. at point (x[0],y[0]),\n                       followed by the same information at (x[1],y[0]),\n                       etc.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov norm}\\> - \\>  \\begin{minipg2}\n                     Normals of surface. Is calculated if ider $\\ge$ 1.\n                       Dimension is idim*m1*m2.\n                       The normals are not normalized.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat}\\> - \\> status messages \\\\\n\t       \\>\\>\\>\\>\\>       $ = 2 $     : Surface is degenerate at some point, \\\\\n\t       \\>\\>\\>\\>\\>\\> normal has zero length.\\\\\n\t       \\>\\>\\>\\>\\>       $ = 1 $     : Surface is close to degenerate at some point. \\\\\n\t       \\>\\>\\>\\>\\>\\> Angle between tangents, less than angular tolerance.\\\\\n\t       \\>\\>\\>\\>\\>       $ = 0 $     : Ok.\\\\\n\t       \\>\\>\\>\\>\\>       $ < 0 $     : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLSurf \\> *{\\fov ps1}; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov ider} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov m1} = 10;\\\\\n                \\>\\>    double    \\>  {\\fov x}[10]; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov m2} = 8;\\\\\n                \\>\\>    double    \\>  {\\fov y}[8]; \\, /* Must be defined */\\\\\n                \\>\\>    double    \\>  {\\fov eder}[720]; /* Length: spatial dimension times number of \\\\\n                \\>\\>\\>\\>\\> entities times number of grid points */\\\\\n                \\>\\>    double    \\>  {\\fov norm}[240]; /* Length: spatial dimension times number of grid points */\\\\\n                \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1506(\\begin{minipg4}\n            {\\fov ps1}, {\\fov ider}, {\\fov m1}, {\\fov x}, {\\fov m2}, {\\fov y}, {\\fov eder}, {\\fov norm}, \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1508.tex",
    "content": "\\subsection{Create a rational lofted surface from a set of rational input-curves}\n\\funclabel{s1508}\n\\begin{minipg1}\n  To create a rational lofted surface from a set of rational input-curves. The surface will\n  be $C^1$ cubic in the lofting direction.\n\\end{minipg1} \\\\ \\\\ \nSYNOPSIS\\\\\n      \\> void s1508(\\begin{minipg3}\n\t   {\\fov inbcrv}, {\\fov vpcurv}, {\\fov par\\_arr}, {\\fov rsurf}, {\\fov jstat})\n\t       \\end{minipg3}\\\\\n               \\>\\> int \\> {\\fov inbcrv};\\\\\n\t       \\>\\> SISLCurve \\> *{\\fov vpcurv[\\,]};\\\\\n\t       \\>\\> double \\> {\\fov par\\_arr[\\,]};\\\\\n\t       \\>\\> SISLSurf \\> **{\\fov rsurf};\\\\\n\t       \\>\\> int \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n      \\> Input Arguments:\\\\\n      \\>\\> {\\fov inbcrv} \\> - \\> \\begin{minipg2}\n\t           Number of NURBS-curves in the curve set.\n\t\t                 \\end{minipg2}\\\\\n      \\>\\> {\\fov vpcurv} \\> - \\> \\begin{minipg2}\n\t           Array (length {\\fov inbcrv}) of pointers to the curves in the curve-set.\n\t\t                 \\end{minipg2}\\\\\n      \\>\\> {\\fov par\\_arr} \\> - \\> \\begin{minipg2}\n\t           The required parametrization, must be strictly increasing, \n\t\t   length {\\fov inbcrv}.\n\t\t                 \\end{minipg2}\\\\\n\n      \\> Output Arguments: \\\\\n      \\>\\> {\\fov rsurf} \\> - \\> \\begin{minipg2}\n\t           Pointer to the NURBS surface produced.\n\t\t                \\end{minipg2}\\\\\n      \\>\\> {\\fov jstat} \\> - \\> status message \\\\\n                 \\>\\>\\>\\>\\>   $ < 0 $ : Error.\\\\\n\t\t \\>\\>\\>\\>\\>   $ = 0 $ : Ok. \\\\\n\t\t \\>\\>\\>\\>\\>   $ > 0 $ : Warning.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n               \\>      \\{ \\\\\n\t       \n\t       \\>\\>    int \\> {\\fov inbcrv} = 3;\\\\\n\t       \\>\\>    SISLCurve \\> *{\\fov vpcurv[3]}; \\, /* Must be defined */\\\\\n\t       \\>\\>    double \\> {\\fov par\\_arr[3]}; \\, /* Must be defined */\\\\\n\t       \\>\\>    SISLSurf  \\> *{\\fov rsurf} = NULL;\\\\\n\t       \\>\\>    int \\> {\\fov jstat} = 0;\\\\\n\t       \\>\\>    \\ldots \\\\\n\t       \\>\\>    s1508({\\fov inbcrv}, {\\fov vpcurv}, {\\fov par\\_arr}, \\&{\\fov rsurf}, \\&{\\fov jstat}); \\\\\n\t       \\>\\>    \\ldots \\\\\n\t       \\>      \\}\n\n\n\\end{tabbing}\n      \n"
  },
  {
    "path": "doc/manual/func/s1510.tex",
    "content": "\\subsection{Find the topology of the silhouette curves of a spline surface,\n using perspective projection.}\n\\funclabel{s1510}\n\\begin{minipg1}\n  Find the silhouette curves and points of a surface when\n  the surface is viewed perspectively from a specific eye point.\n  In addition to the points and curves found by this routine,\n  break curves and edge-curves might be silhouette curves.\n  To march out the silhouette curves, use s1514() on page~\\pageref{s1514}.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1510(\\begin{minipg3}\n          {\\fov ps}, {\\fov eyepoint}, {\\fov idim},  {\\fov aepsco},  {\\fov aepsge},  {\\fov jpt},  {\\fov gpar},  {\\fov jcrv},  {\\fov wcurve},  {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf \\> *{\\fov ps};\\\\\n        \\>\\>    double   \\> {\\fov eyepoint}[\\,];\\\\\n        \\>\\>    int      \\> {\\fov idim};\\\\\n        \\>\\>    double   \\> {\\fov aepsco};\\\\\n        \\>\\>    double   \\> {\\fov aepsge};\\\\\n        \\>\\>    int      \\> *{\\fov jpt};\\\\\n        \\>\\>    double   \\> **{\\fov gpar};\\\\\n        \\>\\>    int      \\> *{\\fov jcrv};\\\\\n        \\>\\>    SISLIntcurve \\> ***{\\fov wcurve};\\\\\n        \\>\\>    int      \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov ps}\\> - \\>  \\begin{minipg2}\n                           Pointer to the surface.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov eyepoint}\\> - \\>  \\begin{minipg2}\n                      The eye point vector.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov idim}\\> - \\>  \\begin{minipg2}\n                        Dimension of the space in which eyepoint lies.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov aepsco}\\> - \\>  \\begin{minipg2}\n                        Computational resolution (not used).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov aepsge}\\> - \\>  \\begin{minipg2}\n                        Geometry resolution.\n                               \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov jpt}\\> - \\>  \\begin{minipg2}\n                     Number of single silhouette points.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov gpar}\\> - \\>  \\begin{minipg2}\n                     Array containing the parameter values of the\n                       single silhouette points in the parameter\n                       plane of the surface. The points lie continuous.\n                       Silhouette curves are stored in wcurve.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jcrv}\\> - \\>  \\begin{minipg2}\n                     Number of silhouette curves.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov wcurve}\\> - \\>  \\begin{minipg2}\n                     Array containing descriptions of the silhouette\n                       curves. The curves are only described by points\n                       in the parameter plane. The curve-pointers points\n                       to nothing.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf \\> *{\\fov ps}; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> {\\fov eyepoint}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    int      \\> {\\fov idim} = 3;\\\\\n        \\>\\>    double   \\> {\\fov aepsco} = 1.0e-9; /* Not used */\\\\\n        \\>\\>    double   \\> {\\fov aepsge} = 1.0e-6;\\\\\n        \\>\\>    int      \\> {\\fov jpt} = 0;\\\\\n        \\>\\>    double   \\> *{\\fov gpar} = NULL;\\\\\n        \\>\\>    int      \\> {\\fov jcrv} = 0;\\\\\n        \\>\\>    SISLIntcurve \\> **{\\fov wcurve} = NULL;\\\\\n        \\>\\>    int      \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1510(\\begin{minipg4}\n          {\\fov ps}, {\\fov eyepoint}, {\\fov idim},  {\\fov aepsco},  {\\fov aepsge}, \\&{\\fov jpt}, \\&{\\fov gpar}, \\&{\\fov jcrv}, \\&{\\fov wcurve}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1511.tex",
    "content": "\\subsection{Find the topology of the circular silhouette curves of a spline\n\\mbox{surface}.}\n\\funclabel{s1511}\n\\begin{minipg1}\n  Find the circular silhouette curves and points of a surface.\n  In addition to the points and curves found by this routine,\n  break curves and edge-curves might be silhouette curves.\n  To march out the silhouette curves use s1515() on page~\\pageref{s1515}.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1511(\\begin{minipg3}\n          {\\fov ps}, {\\fov qpoint}, {\\fov bvec}, {\\fov idim}, {\\fov aepsco}, {\\fov aepsge}, {\\fov jpt},  {\\fov gpar},  {\\fov jcrv},  {\\fov wcurve},  {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf \\> *{\\fov ps};\\\\\n        \\>\\>    double   \\> {\\fov qpoint}[\\,];\\\\\n        \\>\\>    double   \\> {\\fov bvec}[\\,];\\\\\n        \\>\\>    int      \\> {\\fov idim};\\\\\n        \\>\\>    double   \\> {\\fov aepsco};\\\\\n        \\>\\>    double   \\> {\\fov aepsge};\\\\\n        \\>\\>    int      \\> *{\\fov jpt};\\\\\n        \\>\\>    double   \\> **{\\fov gpar};\\\\\n        \\>\\>    int      \\> *{\\fov jcrv};\\\\\n        \\>\\>    SISLIntcurve \\> ***{\\fov wcurve};\\\\\n        \\>\\>    int      \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov ps}\\> - \\>  \\begin{minipg2}\n                          Pointer to the surface.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov qpoint}\\> - \\>  \\begin{minipg2}\n                       A point on the spin axis.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov bvec}\\> - \\>  \\begin{minipg2}\n                        The circular silhouette axis direction.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov idim}\\> - \\>  \\begin{minipg2}\n                       Dimension of the space in which axis lies.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov aepsco}\\> - \\>  \\begin{minipg2}\n                       Computational resolution (not used).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov aepsge}\\> - \\>  \\begin{minipg2}\n                       Geometry resolution.\n                               \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov jpt}\\> - \\>  \\begin{minipg2}\n                     Number of single silhouette points.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov gpar}\\> - \\>  \\begin{minipg2}\n                     Array containing the parameter values of the\n                       single silhouette points in the parameter\n                       plane of the surface. The points lie continuous.\n                       Silhouette curves are stored in wcurve.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jcrv}\\> - \\>  \\begin{minipg2}\n                     Number of silhouette curves.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov wcurve}\\> - \\>  \\begin{minipg2}\n                     Array containing descriptions of the silhouette\n                     curves. The curves are only described by points\n                     in the parameter plane. The curve-pointers points\n                     to nothing.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf \\> *{\\fov ps}; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> {\\fov qpoint}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> {\\fov bvec}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    int      \\> {\\fov idim} = 3;\\\\\n        \\>\\>    double   \\> {\\fov aepsco} =1.0e-9; /* Not used */\\\\\n        \\>\\>    double   \\> {\\fov aepsge} = 1.0e-6;\\\\\n        \\>\\>    int      \\> {\\fov jpt} = 0;\\\\\n        \\>\\>    double   \\> *{\\fov gpar} = NULL;\\\\\n        \\>\\>    int      \\> {\\fov jcrv} = 0;\\\\\n        \\>\\>    SISLIntcurve \\> **{\\fov wcurve} = NULL;\\\\\n        \\>\\>    int      \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1511(\\begin{minipg4}\n          {\\fov ps}, {\\fov qpoint}, {\\fov bvec}, {\\fov idim}, {\\fov aepsco}, {\\fov aepsge}, \\&{\\fov jpt}, \\&{\\fov gpar}, \\&{\\fov jcrv}, \\&{\\fov wcurve}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1514.tex",
    "content": "\\subsection{\\sloppy March a silhouette curve of a surface, using\nperspective \\mbox{projection}.}\n\\funclabel{s1514}\n\\begin{minipg1}\n  To march the perspective silhouette curve described by an intersection\n  curve object, a surface and an eye point.\n  The guide points are expected to be found by s1510() described on\n  page \\pageref{s1510}.\n  The generated geometric curves are represented as B-spline curves.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1514(\\begin{minipg3}\n          {\\fov ps1},  {\\fov eyepoint},  {\\fov idim},  {\\fov aepsco},  {\\fov aepsge},  {\\fov amax},  {\\fov pintcr},  {\\fov icur},  {\\fov igraph},  {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf \\> *{\\fov ps1};\\\\\n        \\>\\>    double   \\> {\\fov eyepoint}[\\,]\\\\\n        \\>\\>    int      \\> {\\fov idim};\\\\\n        \\>\\>    double   \\> {\\fov aepsco};\\\\\n        \\>\\>    double   \\> {\\fov aepsge};\\\\\n        \\>\\>    double   \\> {\\fov amax};\\\\\n        \\>\\>    SISLIntcurve \\> *{\\fov pintcr};\\\\\n        \\>\\>    int      \\> {\\fov icur};\\\\\n        \\>\\>    int      \\> {\\fov igraph};\\\\\n        \\>\\>    int      \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov ps1}\\> - \\>  \\begin{minipg2}\n                     Pointer to surface.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov eyepoint}\\> - \\>  \\begin{minipg2}\n                     Eye point for perspective view\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov idim}\\> - \\>  \\begin{minipg2}\n                     Dimension of the space in which the {\\fov eyepoint}\n                       lies.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov aepsco}\\> - \\>  \\begin{minipg2}\n                     Computational resolution (not used).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov aepsge}\\> - \\>  \\begin{minipg2}\n                     Geometry resolution.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov amax}\\> - \\>  \\begin{minipg2}\n                     Maximal allowed step length.\\\\ If $amax\\leq aepsge$\n                       {\\fov amax} is neglected.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov icur}\\> - \\>  \\begin{minipg2}\n                    Indicator telling if a 3D curve is to be made.\n                               \\end{minipg2}\\\\\n                    \\>\\>\\>\\>\\> $= 0$ \\> : Don't make 3D curve.\\\\\n                    \\>\\>\\>\\>\\> $= 1$ \\> : Make 3D curve.\\\\\n                    \\>\\>\\>\\>\\> $= 2$ \\> : \\begin{minipg5}\n                                            Make 3D curve and curves in\n                                            the parameter plane.\n                                          \\end{minipg5}\\\\[0.8ex]\n        \\>\\>    {\\fov igraph}\\> - \\>  \\begin{minipg2}\n                     Indicator telling if the curve is to be output\n                       through function calls:\\\\\n                               \\end{minipg2}\\\\\n                    \\>\\>\\>\\>\\> $= 0$ \\> : \\begin{minipg5}\n                                            Don't output curve through\n                                            function call.\n                                          \\end{minipg5}\\\\[0.3ex]\n                    \\>\\>\\>\\>\\> $= 0$ \\> : \\begin{minipg5}\n                                             Output as straight line\n                                             segments. This option is\n                                             outdated, if used see NOTE!\n                                          \\end{minipg5}\\\\[0.8ex]\n\\newpagetabs\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov pintcr}\\> - \\>  \\begin{minipg2}\n                     The intersection curve. When coming in as input\n                       only parameter values in the parameter plane\n                       exist. When coming as output the 3D geometry\n                       and possibly the curve in the parameter plane\n                       of the surface is added.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n        \\>\\>\\>\\> $= 3$ \\> :\n                \\begin{minipg5}\n                  Iteration stopped due to singular\n                  point or degenerate surface. A part\n                  of intersection curve may have been\n                  traced out. If no curve is traced out\n                  the curve pointers in the Intcurve\n                  object point to NULL.\n                \\end{minipg5}\\\\[0.8ex]\n        \\>\\>\\>\\> $> 0$ \\>\\> : Warning.\\\\\n        \\>\\>\\>\\> $= 0$ \\>\\> : Ok.\\\\\n        \\>\\>\\>\\> $< 0$ \\>\\> : Error.\\\\\n        \\>\\>\\>\\> $= -185$ \\>\\> :\n        \\begin{minipg5}\n          No points produced on intersection curve.\n        \\end{minipg5}\\\\[0.8ex]\n\\\\\nNOTE\\\\\n\\>      \\begin{minipg6}\nIf the draw option is used the empty dummy functions s6move() and\ns6line() are called.\nThus if the draw option is used, make sure\nyou have versions of functions s6move() and s6line() interfaced to your graphic package.\n\\end{minipg6}\\\\\n\\\\ %\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf \\> *{\\fov ps1}; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> {\\fov eyepoint}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    int      \\> {\\fov idim} = 3;\\\\\n        \\>\\>    double   \\> {\\fov aepsco} = 1.0e-9; /* Not used */\\\\\n        \\>\\>    double   \\> {\\fov aepsge} = 1.0e-5;\\\\\n        \\>\\>    double   \\> {\\fov amax} = 0.0;\\\\\n        \\>\\>    SISLIntcurve \\> *{\\fov pintcr}; /* The silhouette curve instance is defined in s1510 */\\\\\n        \\>\\>    int      \\> {\\fov icur};\\\\\n        \\>\\>    int      \\> {\\fov igraph};\\\\\n        \\>\\>    int      \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1514(\\begin{minipg4}\n          {\\fov ps1},  {\\fov eyepoint},  {\\fov idim},  {\\fov aepsco},  {\\fov aepsge},  {\\fov amax},  {\\fov pintcr},  {\\fov icur},  {\\fov igraph},  \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1515.tex",
    "content": "\\subsection{March a circular silhouette curve of a surface.}\n\\funclabel{s1515}\n\\begin{minipg1}\n  To march the circular silhouette curve described by an intersection\n  curve object, a surface, point Q and direction B\n  i.e.\\ solution of  $f(u,v)=N(u,v)\\times (P(u,v)-Q)\\cdot B$.\\\\\n  The guide points are expected to be found by s1511() described on\n  page \\pageref{s1511}.\n  The generated geometric curves are represented as B-spline curves.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1515(\\begin{minipg3}\n          {\\fov ps1},  {\\fov qpoint},  {\\fov bvec},  {\\fov idim},  {\\fov aepsco},  {\\fov aepsge},  {\\fov amax},  {\\fov pintcr},  {\\fov icur},  {\\fov igraph},  {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf \\> *{\\fov ps1};\\\\\n        \\>\\>    double   \\> {\\fov qpoint}[\\,];\\\\\n        \\>\\>    double   \\> {\\fov bvec}[\\,];\\\\\n        \\>\\>    int      \\> {\\fov idim};\\\\\n        \\>\\>    double   \\> {\\fov aepsco};\\\\\n        \\>\\>    double   \\> {\\fov aepsge};\\\\\n        \\>\\>    double   \\> {\\fov amax};\\\\\n        \\>\\>    SISLIntcurve \\> *{\\fov pintcr};\\\\\n        \\>\\>    int      \\> {\\fov icur};\\\\\n        \\>\\>    int      \\> {\\fov igraph};\\\\\n        \\>\\>    int      \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov ps1}\\> - \\>  \\begin{minipg2}\n                     Pointer to surface.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov qpoint}\\> - \\>  \\begin{minipg2}\n                     Point Q for circular silhouette.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov bvec}\\> - \\>  \\begin{minipg2}\n                     Direction B for circular silhouette.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov idim}\\> - \\>  \\begin{minipg2}\n                     Dimension of the space in which Q lies.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov aepsco}\\> - \\>  \\begin{minipg2}\n                     Computational resolution (not used).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov aepsge}\\> - \\>  \\begin{minipg2}\n                     Geometry resolution.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov amax}\\> - \\>  \\begin{minipg2}\n                     Maximal allowed step length. If $amax\\leq aepsge$\n                       {\\fov amax} is neglected.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov icur}\\> - \\>  \\begin{minipg2}\n                    Indicator telling if a 3D curve is to be made.\n                               \\end{minipg2}\\\\\n                    \\>\\>\\>\\>\\> $= 0$ \\> : Don't make 3D curve.\\\\\n                    \\>\\>\\>\\>\\> $= 1$ \\> : Make 3D curve.\\\\\n                    \\>\\>\\>\\>\\> $= 2$ \\> : \\begin{minipg5}\n                                            Make 3D curve and curves in\n                                            the parameter plane.\n                                          \\end{minipg5}\\\\[0.8ex]\n        \\>\\>    {\\fov igraph}\\> - \\>  \\begin{minipg2}\n                     Indicator telling if the curve is to be output\n                       through function calls:\\\\\n                               \\end{minipg2}\\\\\n                    \\>\\>\\>\\>\\> $= 0$ \\> : \\begin{minipg5}\n                                            Don't output curve through\n                                            function call.\n                                          \\end{minipg5}\\\\[0.3ex]\n                    \\>\\>\\>\\>\\> $= 0$ \\> : \\begin{minipg5}\n                                             Output as straight line\n                                             segments . This option is\n                                             outdated, if used see NOTE!\n                                          \\end{minipg5}\\\\[0.8ex]\n\\newpagetabs\n        \\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov pintcr}\\> - \\>\n        \\begin{minipg2}\n          The intersection curve. When coming in as input\n          only parameter values in the parameter plane\n          exist. When coming as output the 3-D geometry\n          and possibly the curve in the parameter plane\n          of the surface is added.\n        \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n        \\>\\>\\>\\> $= 3$ \\>\\> :\n                \\begin{minipg5}\n                  Iteration stopped due to singular\n                  point or degenerate surface. A part\n                  of intersection curve may have been\n                  traced out. If no curve is traced out\n                  the curve pointers in the Intcurve\n                  object point to NULL.\n                \\end{minipg5}\\\\[0.8ex]\n        \\>\\>\\>\\> $> 0$ \\>\\> : Warning.\\\\\n        \\>\\>\\>\\> $= 0$ \\>\\> : Ok.\\\\\n        \\>\\>\\>\\> $< 0$ \\>\\> : Error.\\\\\n        \\>\\>\\>\\> $= -185$ \\>\\> :\n        \\begin{minipg5}\n          No points produced on intersection curve.\n        \\end{minipg5}\\\\[0.8ex]\n\\\\\nNOTE\\\\\n\\>      \\begin{minipg6}\nIf the draw option is used the empty dummy functions s6move() and\ns6line() are called.\nThus if the draw option is used, make sure\nyou have versions of functions s6move() and s6line() interfaced to your graphic package.\n\\end{minipg6}\\\\\n\\\\ %\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf \\> *{\\fov ps1}; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> {\\fov qpoint}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> {\\fov bvec}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    int      \\> {\\fov idim} = 3;\\\\\n        \\>\\>    double   \\> {\\fov aepsco} = 1.0e-9; /* Not used */\\\\\n        \\>\\>    double   \\> {\\fov aepsge} = 1.0e-6;\\\\\n        \\>\\>    double   \\> {\\fov amax} = 0.0;\\\\\n        \\>\\>    SISLIntcurve \\> *{\\fov pintcr}; /* The silhouette curve instance is defined in s1511 */\\\\\n        \\>\\>    int      \\> {\\fov icur} = 2;\\\\\n        \\>\\>    int      \\> {\\fov igraph} = 0;\\\\\n        \\>\\>    int      \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\> s1515(\\begin{minipg4}\n          {\\fov ps1},  {\\fov qpoint},  {\\fov bvec},  {\\fov idim},  {\\fov aepsco},  {\\fov aepsge},  {\\fov amax},  {\\fov pintcr},  {\\fov icur},  {\\fov igraph}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1518.tex",
    "content": "\\subsection{Newton iteration on the intersection between a 3D NURBS surface and a line.}\n\\funclabel{s1518}\n\\begin{minipg1}\nNewton iteration on the intersection between\n               a 3D NURBS surface and a line.\n               If a good initial guess is given, the intersection will\n               be found quickly. However if a bad initial guess is given,\n               the iteration might not converge.\n               We only search in the rectangular subdomain specified\n               by \"start\" and \"end\". This can be the whole domain if desired.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>     void s1518(\\begin{minipg3}\n            {\\fov surf},  {\\fov point},  {\\fov dir},  {\\fov epsge},  {\\fov start},  {\\fov end},  {\\fov parin},  {\\fov parout},  {\\fov stat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf    \\>  *{\\fov surf};\\\\\n                \\>\\>    double \\> point[\\,];\\\\\n                \\>\\>    double \\> dir[\\,];\\\\\n                \\>\\>    double \\> epsge;\\\\\n                \\>\\>    double \\> start[\\,];\\\\\n                \\>\\>    double \\> end[\\,];\\\\\n                \\>\\>    double \\> parin[\\,];\\\\\n                \\>\\>    double \\> parout[\\,];\\\\\n                \\>\\>    int    \\>  *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>  \\begin{minipg2}\n                     The NURBS surface.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov point}\\> - \\>  \\begin{minipg2}\n                     A point on the line.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov dir}\\> - \\>  \\begin{minipg2}\n                     The vector direction of the line\n                        (not necessarily normalized).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>  \\begin{minipg2}\n                     Geometric resolution.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov start}\\> - \\>  \\begin{minipg2}\n                     Lower limits of search rectangle (umin, vmin).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov end}\\> - \\>  \\begin{minipg2}\n                     Upper limits of search rectangle (umax, vmax).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov parin}\\> - \\>  \\begin{minipg2}\n                     Initial guess (u0,v0) for parameter point of\n                        intersection (which should be inside the\n                        search rectangle).\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov parout}\\> - \\>  \\begin{minipg2}\n                     Parameter point (u,v) of intersection.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat}\\> - \\>  \\begin{minipg2}\n                     status messages  \n                                = 1   : Intersection found.\n                                < 0   : error.\n                               \\end{minipg2}\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLSurf    \\>  *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> point[3]; \\,/* Must be defined */\\\\\n                \\>\\>    double \\> dir[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> epsge = 1.0e-6;\\\\\n                \\>\\>    double \\> start[2]; \\,/* Must be defined */\\\\\n                \\>\\>    double \\> end[2]; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> parin[2]; \\, /* Guess parameter. Must be defined */\\\\\n                \\>\\>    double \\> parout[2];\\\\\n                \\>\\>    int    \\>  {\\fov stat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>    \\>s1518(\\begin{minipg4}\n            {\\fov surf},  {\\fov point},  {\\fov dir},  {\\fov epsge},  {\\fov start},  {\\fov end},  {\\fov parin},  {\\fov parout},  \\&{\\fov stat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1520.tex",
    "content": "\\subsection{Create a NURBS rotational surface by rotating\na curve around an axis over a given angle.}\n\\funclabel{s1520}\n\\begin{minipg1}\n  To create a NURBS rotational surface by rotating\n  a curve around an axis over a given angle.\n  This will be an exact representation.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1520(\\begin{minipg3}\n          {\\fov pc},  {\\fov angle},  {\\fov ep},  {\\fov eaxis},  {\\fov rs},  {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLCurve \\> *{\\fov pc};\\\\\n        \\>\\>    double    \\> {\\fov angle};\\\\\n        \\>\\>    double    \\> {\\fov ep}[\\,];\\\\\n        \\>\\>    double    \\> {\\fov eaxis}[\\,];\\\\\n        \\>\\>    SISLSurf  \\> **{\\fov rs};\\\\\n        \\>\\>    int       \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov pc}   \\> - \\> The curve to be rotated (NURBS or B-spline).\\\\\n        \\>\\>    {\\fov angle}\\> - \\>\n        \\begin{minipg2}\n          The rotational angle. Counter clockwise around axis.\n          If the absolute value of the angle is greater than\n          $2\\pi$ then a rotational surface closed in the\n          rotation direction is made.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ep} \\> - \\> A point on the rotational axis.\\\\\n        \\>\\>    {\\fov eaxis}\\> - \\> Direction of the rotational axis.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rs}\\> - \\> The surface produced (NURBS or B-spline).\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve \\> *{\\fov pc};\\\\\n        \\>\\>    double    \\> {\\fov angle};\\\\\n        \\>\\>    double    \\> {\\fov ep}[3];\\\\\n        \\>\\>    double    \\> {\\fov eaxis}[3];\\\\\n        \\>\\>    SISLSurf  \\> *{\\fov rs} = NULL;\\\\\n        \\>\\>    int       \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>s1520(\\begin{minipg4}\n          {\\fov pc}, {\\fov angle}, {\\fov ep}, {\\fov eaxis}, \\&{\\fov rs}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1522.tex",
    "content": "\\subsection{Express a 2D or 3D ellipse as a curve.}\n\\funclabel{s1522}\n\\begin{minipg1}\n  Convert a 2D or 3D analytical ellipse to a curve.\n  The curve will be geometrically exact.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1522(\\begin{minipg3}\n            {\\fov normal},  {\\fov centre},  {\\fov ellipaxis},  {\\fov ratio},  {\\fov dim},  {\\fov ellipse},  {\\fov jstat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    double \\> {\\fov normal}[\\,];\\\\\n                \\>\\>    double \\> {\\fov centre}[\\,];\\\\\n                \\>\\>    double \\> {\\fov ellipaxis}[\\,];\\\\\n                \\>\\>    double \\> {\\fov ratio};\\\\\n                \\>\\>    int    \\> {\\fov dim};\\\\\n                \\>\\>    SISLCurve \\> **{\\fov ellipse};\\\\\n                \\>\\>    int    \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov normal} \\> - \\>\n        \\begin{minipg2}\n          3D normal to ellipse plane (not necessarily normalized).  Used\n          if $dim=3$.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov centre} \\> - \\>\n        \\begin{minipg2}\n          Centre of ellipse (2D if $dim=2$ and 3D if $dim=3$).\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ellipaxis} \\> - \\>\n        \\begin{minipg2}\n          This will be used as starting point\n          for the ellipse curve (2D if $dim=2$ and 3D if $dim=3$).\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ratio} \\> - \\>\n        \\begin{minipg2}\n          The ratio between the length of the given ellipaxis and the\n          length of the other axis, i.e. $|ellipaxis| / |other axis|$\n          (a compact representation format).\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov dim}\\> - \\>\n        \\begin{minipg2}\n          Dimension of the space in which the elliptic nurbs curve lies (2 or 3).\n        \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov ellipse} \\> - \\>\n        \\begin{minipg2}\n          Ellipse curve (2D if $dim=2$ and 3D if $dim=3$).\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    double \\> {\\fov normal}[3]; \\,/* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov centre}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov ellipaxis}[3]; \\,/* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov ratio}; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\> {\\fov dim} = 3;\\\\\n        \\>\\>    SISLCurve \\> *{\\fov ellipse} = NULL;\\\\\n        \\>\\>    int    \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1522(\\begin{minipg4}\n          {\\fov normal},  {\\fov centre},  {\\fov ellipaxis},  {\\fov ratio},  {\\fov dim},  \\&{\\fov ellipse},  \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1529.tex",
    "content": "\\subsection{\\sloppy Compute a surface by Hermite interpolation, automatic parameter\\-ization.}\n\\funclabel{s1529}\n\\begin{minipg1}\n  Compute the cubic Hermite surface interpolant to the data given.\n  More specifically, given positions, (u',v), (u,v'), and (u',v')\n  derivatives at points of a rectangular grid,\n  the routine\n  computes a cubic tensor-product B-spline interpolant to\n  the given data with double knots at each data (the first\n  knot vector will have double knots at all interior points\n  in epar1, quadruple knots at the first and last points,\n  and similarly for the second knot vector).\n  The output is represented as a B-spline surface.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1529(\\begin{minipg3}\n          {\\fov ep}, {\\fov eder10}, {\\fov eder01}, {\\fov eder11},\n          {\\fov im1}, {\\fov im2}, {\\fov idim}, {\\fov ipar}, {\\fov rsurf}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    double \\>  {\\fov ep}[\\,];\\\\\n        \\>\\>    double \\>  {\\fov eder10}[\\,];\\\\\n        \\>\\>    double \\>  {\\fov eder01}[\\,];\\\\\n        \\>\\>    double \\>  {\\fov eder11}[\\,];\\\\\n        \\>\\>    int    \\>  {\\fov im1};\\\\\n        \\>\\>    int    \\>  {\\fov im2};\\\\\n        \\>\\>    int    \\>  {\\fov idim};\\\\\n        \\>\\>    int    \\>  {\\fov ipar};\\\\\n        \\>\\>    SISLSurf \\>  **{\\fov rsurf};\\\\\n        \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov ep}     \\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing the\n          positions of the nodes (using the same ordering as ecoef in\n          the SISLSurf structure).\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov eder10} \\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing the\n          first derivative in the first parameter direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov eder01} \\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing the\n          first derivative in the second parameter direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov eder11} \\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing the\n          cross derivative (twist vector).\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ipar}   \\> - \\>\n          Flag showing the desired parametrization to be used:\\\\\n          \\>\\>\\>\\>$= 1$\\>:\n          \\begin{minipg5}\n            Mean accumulated cord-length para\\-meter\\-ization.\n          \\end{minipg5}\\\\[0.8ex]\n          \\>\\>\\>\\>$= 2$\\>: Uniform parametrization.\\\\\n        \\>\\>    {\\fov im1}    \\> - \\>\n        \\begin{minipg2}\n          The number of interpolation points in the first parameter\n          direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov im2}    \\> - \\>\n        \\begin{minipg2}\n          The number of interpolation points in the second parameter\n          direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov idim}   \\> - \\> Spatial dimension.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rsurf}  \\> - \\> Pointer to the B-spline surface produced.\\\\\n        \\>\\>    {\\fov jstat}  \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n\\\\ %\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    double \\>  {\\fov ep}[300]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\>  {\\fov eder10}[300]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\>  {\\fov eder01}[300]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\>  {\\fov eder11}[300]; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\>  {\\fov im1} = 10;\\\\\n        \\>\\>    int    \\>  {\\fov im2} = 10;\\\\\n        \\>\\>    int    \\>  {\\fov idim} = 3;\\\\\n        \\>\\>    int    \\>  {\\fov ipar} = 1;\\\\\n        \\>\\>    SISLSurf \\> *{\\fov rsurf} = NULL;\\\\\n        \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1529(\n        \\begin{minipg4}\n          {\\fov ep}, {\\fov eder10}, {\\fov eder01}, {\\fov eder11},\n          {\\fov im1}, {\\fov im2}, {\\fov idim}, {\\fov ipar}, \\&{\\fov rsurf}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1530.tex",
    "content": "\\subsection{Compute a surface by Hermite interpolation, parameter\\-ization as input.}\n\\funclabel{s1530}\n\\begin{minipg1}\n  To compute the cubic Hermite interpolant to the data given.\n  More specifically, given positions, 10, 01, and 11\n  derivatives at points of a rectangular grid, the routine\n  computes a cubic tensor-product B-spline interpolant to\n  the given data with double knots at each data point (the first\n  knot vector will have double knots at all interior points\n  in epar1, quadruple knots at the first and last points,\n  and similarly for the second knot vector).\n  The output is represented as a B-spline surface.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1530(\\begin{minipg3}\n          {\\fov ep}, {\\fov eder10}, {\\fov eder01}, {\\fov eder11}, {\\fov epar1}, {\\fov epar2},\n          {\\fov im1}, {\\fov im2}, {\\fov idim}, {\\fov rsurf}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    double \\> {\\fov ep}[\\,];\\\\\n        \\>\\>    double \\> {\\fov eder10}[\\,];\\\\\n        \\>\\>    double \\> {\\fov eder01}[\\,];\\\\\n        \\>\\>    double \\> {\\fov eder11}[\\,];\\\\\n        \\>\\>    double \\> {\\fov epar1}[\\,];\\\\\n        \\>\\>    double \\> {\\fov epar2}[\\,];\\\\\n        \\>\\>    int    \\> {\\fov im1};\\\\\n        \\>\\>    int    \\> {\\fov im2};\\\\\n        \\>\\>    int    \\> {\\fov idim};\\\\\n        \\>\\>    SISLSurf \\> **{\\fov rsurf};\\\\\n        \\>\\>    int    \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov ep} \\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing\n          the positions of the nodes (using the same ordering\n          as {\\fov ecoef} in the SISLSurf structure).\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov eder10} \\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing the\n          first derivative in the first parameter direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov eder01} \\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing the\n          first derivative in the second parameter direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov eder11} \\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing\n          the cross derivative (twist vector).\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epar1} \\> - \\>\n        \\begin{minipg2}\n          Array of size {\\fov im1} containing the\n          parametrization in the first direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epar2} \\> - \\>\n        \\begin{minipg2}\n          Array of size {\\fov im2} containing the\n          parametrization in the first direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov im1} \\> - \\>\n          The number of interpolation points in the 1st param. dir.\\\\\n        \\>\\>    {\\fov im2} \\> - \\>\n          The number of interpolation points in the 2nd param. dir.\\\\\n        \\>\\>    {\\fov idim} \\> - \\> Dimension of the space we are working in.\\\\\n\\\\\n\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rsurf} \\> - \\> Pointer to the B-spline surface produced.\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    double \\> {\\fov ep}[30]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov eder10}[30]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov eder01}[30]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov eder11}[30]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov epar1}[2]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov epar2}[5]; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\> {\\fov im1 = 2};\\\\\n        \\>\\>    int    \\> {\\fov im2 = 5};\\\\\n        \\>\\>    int    \\> {\\fov idim = 3};\\\\\n        \\>\\>    SISLSurf \\>  *{\\fov rsurf} = NULL;\\\\\n        \\>\\>    int    \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1530(\\begin{minipg4}\n          {\\fov ep}, {\\fov eder10}, {\\fov eder01}, {\\fov eder11}, {\\fov epar1}, {\\fov epar2},\n          {\\fov im1}, {\\fov im2}, {\\fov idim}, \\&{\\fov rsurf}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1534.tex",
    "content": "\\subsection{Compute a surface interpolating a set of points,\nderivatives as input.}\n\\funclabel{s1534}\n\\begin{minipg1}\n  To compute a surface interpolating a set of points, derivatives\n  as input.\n  The output is represented as a B-spline surface.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n      \\>void s1534(\\begin{minipg3}\n        {\\fov points}, {\\fov der10}, {\\fov der01}, {\\fov der11}, {\\fov im1}, {\\fov im2}, {\\fov idim}, {\\fov ipar}, {\\fov con1}, {\\fov con2}, {\\fov con3},\n        {\\fov con4}, {\\fov order1},  {\\fov order2}, {\\fov rsurf}, {\\fov jstat})\n      \\end{minipg3}\\\\[0.3ex]\n      \\>\\>    double \\> {\\fov points}[\\,];\\\\\n      \\>\\>    double \\> {\\fov der10}[\\,];\\\\\n      \\>\\>    double \\> {\\fov der01}[\\,];\\\\\n      \\>\\>    double \\> {\\fov der11}[\\,];\\\\\n      \\>\\>    int    \\> {\\fov im1};\\\\\n      \\>\\>    int    \\> {\\fov im2};\\\\\n      \\>\\>    int    \\> {\\fov idim};\\\\\n      \\>\\>    int    \\> {\\fov ipar};\\\\\n      \\>\\>    int    \\> {\\fov con1};\\\\\n      \\>\\>    int    \\> {\\fov con2};\\\\\n      \\>\\>    int    \\> {\\fov con3};\\\\\n      \\>\\>    int    \\> {\\fov con4};\\\\\n      \\>\\>    int    \\> {\\fov order1};\\\\\n      \\>\\>    int    \\> {\\fov order2};\\\\\n      \\>\\>    SISLSurf \\> **{\\fov rsurf};\\\\\n      \\>\\>    int    \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov points} \\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing the\n          positions of the nodes (using the same ordering as ecoef in\n          the SISLSurf structure).\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov der10}  \\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing\n          the first derivatives in the first parameter direction.\n        \\end{minipg2}\\\\\n        \\>\\>    {\\fov der01}  \\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing the\n          first derivatives in the second parameter direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov der11}  \\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing the\n          cross derivatives (the twists).\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov im1}  \\> - \\>\n        \\begin{minipg2}\n          The number of interpolation points in the first parameter\n          direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov im2}  \\> - \\>\n        \\begin{minipg2}\n          The number of interpolation points in the second parameter\n          direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov idim} \\> - \\> Dimension of the space we are working in.\\\\\n        \\>\\>    {\\fov ipar} \\> - \\> Flag showing the desired\n                                    parametrization to be used:\\\\\n                 \\>\\>\\>\\>\\> $= 1$ : \\begin{minipg5}\n                                      Mean accumulated cord-length\n                                      parameterization.\n                                    \\end{minipg5}\\\\[0.3ex]\n                 \\>\\>\\>\\>\\> $= 2$ : Uniform parametrization.\\\\\n%\\newpagetabs\n        \\>\\>\\>\\>\\begin{minipg2}\n                Numbering of surface edges:\\\\\n                \\begin{center}\n                  \\begin{picture}(180,110)(0,0)\n                    \\put(50,15){\\framebox(80,80)}\n                    \\put(40,55){\\makebox(0,0){3}}\n                    \\put(140,55){\\makebox(0,0){4}}\n                    \\put(90,5){\\makebox(0,0){1}}\n                    \\put(90,105){\\makebox(0,0){2}}\n\n                    \\put(60,20){\\vector(1,0){40}}\n                    \\put(85,28){\\makebox(0,0){$(i)$}}\n                    \\put(55,25){\\vector(0,1){40}}\n                    \\put(65,50){\\makebox(0,0){$(ii)$}}\n                  \\end{picture}\\\\\n                  $(i) \\; \\; \\;$ first parameter direction of surface.\\\\\n                  $(ii)$   second parameter direction of surface.\\\\\n                \\end{center}\n              \\end{minipg2}\\\\ \\\\\n        \\>\\>    {\\fov con1} \\> - \\> Additional condition along edge 1:\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : No additional condition.\\\\\n                      \\>\\>\\>\\>\\> $= 1$ : Zero curvature.\\\\\n        \\>\\>    {\\fov con2} \\> - \\> Additional condition along edge 2:\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : No additional condition.\\\\\n                      \\>\\>\\>\\>\\> $= 1$ : Zero curvature.\\\\\n        \\>\\>    {\\fov con3} \\> - \\> Additional condition along edge 3:\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : No additional condition.\\\\\n                      \\>\\>\\>\\>\\> $= 1$ : Zero curvature.\\\\\n        \\>\\>    {\\fov con4} \\> - \\> Additional condition along edge 4:\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : No additional condition.\\\\\n                      \\>\\>\\>\\>\\> $= 1$ : Zero curvature.\\\\\n        \\>\\>    {\\fov order1} \\> - \\> Order of surface in first\n                                      parameter direction.\\\\\n        \\>\\>    {\\fov order2} \\> - \\> Order of surface in second\n                                      parameter direction.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rsurf}  \\> - \\> Pointer to the B-spline surface produced.\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    double \\> {\\fov points}[300]; \\,/* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov der10}[300]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov der01}[300]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov der11}[300]; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\> {\\fov im1} = 10;\\\\\n        \\>\\>    int    \\> {\\fov im2} = 10;\\\\\n        \\>\\>    int    \\> {\\fov idim} = 3;\\\\\n        \\>\\>    int    \\> {\\fov ipar} = 1;\\\\\n        \\>\\>    int    \\> {\\fov con1} = 0;\\\\\n        \\>\\>    int    \\> {\\fov con2} = 0;\\\\\n        \\>\\>    int    \\> {\\fov con3} = 0;\\\\\n        \\>\\>    int    \\> {\\fov con4} = 0;\\\\\n        \\>\\>    int    \\> {\\fov order1} = 4; /* Cubic */\\\\\n        \\>\\>    int    \\> {\\fov order2} = 4;\\\\\n        \\>\\>    SISLSurf \\> *{\\fov rsurf} = NULL;\\\\\n        \\>\\>    int    \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1534(\\begin{minipg4}\n          {\\fov points}, {\\fov der10}, {\\fov der01}, {\\fov der11}, {\\fov im1}, {\\fov im2}, {\\fov idim}, {\\fov ipar}, {\\fov con1}, {\\fov con2}, {\\fov con3},\n          {\\fov con4}, {\\fov order1},  {\\fov order2}, \\&{\\fov rsurf}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1535.tex",
    "content": "\\subsection{Compute a surface interpolating a set of points,\nderivatives and parameterization as input.}\n\\funclabel{s1535}\n\\begin{minipg1}\n  Compute a surface interpolating a set of points, derivatives\n  and parameterization as input.\n  The output is represented as a B-spline surface.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n      \\>void s1535(\\begin{minipg3}\n        {\\fov points}, {\\fov der10}, {\\fov der01}, {\\fov der11}, {\\fov im1}, {\\fov im2}, {\\fov idim}, {\\fov par1},  {\\fov par2},\n        {\\fov con1}, {\\fov con2}, {\\fov con3}, {\\fov con4}, {\\fov order1},  {\\fov order2}, {\\fov rsurf}, {\\fov jstat})\n      \\end{minipg3}\\\\[0.3ex]\n      \\>\\>    double \\> {\\fov points}[\\,];\\\\\n      \\>\\>    double \\> {\\fov der10}[\\,];\\\\\n      \\>\\>    double \\> {\\fov der01}[\\,];\\\\\n      \\>\\>    double \\> {\\fov der11}[\\,];\\\\\n      \\>\\>    int    \\> {\\fov im1};\\\\\n      \\>\\>    int    \\> {\\fov m2};\\\\\n      \\>\\>    int    \\> {\\fov idim};\\\\\n      \\>\\>    double \\> {\\fov par1}[\\,];\\\\\n      \\>\\>    double \\> {\\fov par2}[\\,];\\\\\n      \\>\\>    int    \\> {\\fov con1};\\\\\n      \\>\\>    int    \\> {\\fov con2};\\\\\n      \\>\\>    int    \\> {\\fov con3};\\\\\n      \\>\\>    int    \\> {\\fov con4};\\\\\n      \\>\\>    int    \\> {\\fov order1};\\\\\n      \\>\\>    int    \\> {\\fov order2};\\\\\n      \\>\\>    SISLSurf \\> **{\\fov rsurf};\\\\\n      \\>\\>    int    \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov points} \\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing\n          the positions of the nodes (using the same ordering\n          as {\\fov ecoef} in the SISLSurf structure).\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov der10} \\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing the\n          first derivatives in the first parameter direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov der01} \\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing the\n          first derivatives in the second parameter direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov der11} \\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing the\n          cross derivatives (the twists).\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov im1} \\> - \\>\n        \\begin{minipg2}\n          The number of interpolation points in the\n          first parameter direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov im2} \\> - \\>\n        \\begin{minipg2}\n          The number of interpolation points in the\n          second parameter direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov idim} \\> - \\> Dimension of the space we are working in.\\\\\n        \\>\\>    {\\fov par1} \\> - \\> Parametrization in first parameter direction.\\\\\n        \\>\\>    {\\fov par2} \\> - \\> Parametrization in second parameter direction.\\\\\n        \\>\\>\\>\\>\\begin{minipg2}\n                Numbering of surface edges:\\\\\n                \\begin{center}\n                  \\begin{picture}(180,110)(0,0)\n                    \\put(50,15){\\framebox(80,80)}\n                    \\put(40,55){\\makebox(0,0){3}}\n                    \\put(140,55){\\makebox(0,0){4}}\n                    \\put(90,5){\\makebox(0,0){1}}\n                    \\put(90,105){\\makebox(0,0){2}}\n\n                    \\put(60,20){\\vector(1,0){40}}\n                    \\put(85,28){\\makebox(0,0){$(i)$}}\n                    \\put(55,25){\\vector(0,1){40}}\n                    \\put(65,50){\\makebox(0,0){$(ii)$}}\n                  \\end{picture}\\\\\n                  $(i) \\; \\; \\;$ first parameter direction of surface.\\\\\n                  $(ii)$   second parameter direction of surface.\\\\\n                \\end{center}\n              \\end{minipg2}\\\\ \\\\\n        \\>\\>    {\\fov con1} \\> - \\> Additional condition along edge 1:\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : No additional condition.\\\\\n                      \\>\\>\\>\\>\\> $= 1$ : Zero curvature.\\\\\n        \\>\\>    {\\fov con2} \\> - \\> Additional condition along edge 2:\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : No additional condition.\\\\\n                      \\>\\>\\>\\>\\> $= 1$ : Zero curvature.\\\\\n        \\>\\>    {\\fov con3} \\> - \\> Additional condition along edge 3:\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : No additional condition.\\\\\n                      \\>\\>\\>\\>\\> $= 1$ : Zero curvature.\\\\\n        \\>\\>    {\\fov con4} \\> - \\> Additional condition along edge 4:\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : No additional condition.\\\\\n                      \\>\\>\\>\\>\\> $= 1$ : Zero curvature.\\\\\n        \\>\\>    {\\fov order1} \\> - \\> Order of surface in first\n                                      parameter direction.\\\\\n        \\>\\>    {\\fov order2} \\> - \\> Order of surface in second\n                                      parameter direction.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rsurf} \\> - \\> Pointer to the B-spline surface produced.\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    double \\> {\\fov points}[300]; \\,/* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov der10}[300]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov der01}[300]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov der11}[300]; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\> {\\fov im1} = 10;\\\\\n        \\>\\>    int    \\> {\\fov im2} = 10;\\\\\n        \\>\\>    int    \\> {\\fov idim} = 3;\\\\\n        \\>\\>    double \\> {\\fov par1}[10]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov par2}[10]; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\> {\\fov con1} = 0;\\\\\n        \\>\\>    int    \\> {\\fov con2} = 0;\\\\\n        \\>\\>    int    \\> {\\fov con3} = 0;\\\\\n        \\>\\>    int    \\> {\\fov con4} = 0;\\\\\n        \\>\\>    int    \\> {\\fov order1} = 4; /* Cubic */\\\\\n        \\>\\>    int    \\> {\\fov order2} = 4;\\\\\n        \\>\\>    SISLSurf \\> *{\\fov rsurf} = NULL;\\\\\n        \\>\\>    int    \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1535(\\begin{minipg4}\n          {\\fov points}, {\\fov der10}, {\\fov der01}, {\\fov der11}, {\\fov im1}, {\\fov im2}, {\\fov idim}, {\\fov par1},  {\\fov par2},\n          {\\fov con1}, {\\fov con2}, {\\fov con3}, {\\fov con4}, {\\fov order1},  {\\fov order2}, \\&{\\fov rsurf}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1536.tex",
    "content": "\\subsection{Compute a surface interpolating a set of points,\nautomatic parameterization.}\n\\funclabel{s1536}\n\\begin{minipg1}\n  To compute a tensor surface interpolating a set of points,\n  automatic parameterization.\n  The output is represented as a B-spline surface.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1536(\\begin{minipg3}\n          {\\fov points}, {\\fov im1}, {\\fov im2}, {\\fov idim}, {\\fov ipar}, {\\fov con1}, {\\fov con2}, {\\fov con3},\n          {\\fov con4}, {\\fov order1},  {\\fov order2},  {\\fov iopen1}, {\\fov iopen2}, {\\fov rsurf}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    double \\> {\\fov points}[\\,];\\\\\n        \\>\\>    int \\> {\\fov im1};\\\\\n        \\>\\>    int \\> {\\fov im2};\\\\\n        \\>\\>    int \\> {\\fov idim};\\\\\n        \\>\\>    int \\> {\\fov ipar};\\\\\n        \\>\\>    int \\> {\\fov con1};\\\\\n        \\>\\>    int \\> {\\fov con2};\\\\\n        \\>\\>    int \\> {\\fov con3};\\\\\n        \\>\\>    int \\> {\\fov con4};\\\\\n        \\>\\>    int \\> {\\fov order1};\\\\\n        \\>\\>    int \\> {\\fov order2};\\\\\n        \\>\\>    int \\> {\\fov iopen1};\\\\\n        \\>\\>    int \\> {\\fov iopen2};\\\\\n        \\>\\>    SISLSurf \\> **{\\fov rsurf};\\\\\n        \\>\\>    int \\> *{\\fov jstat};\\\\\n\\newpagetabs\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov points}\\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing\n          the positions of the nodes (using the same ordering\n          as ecoef in the SISLSurf structure).\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov im1}\\> - \\>\n        \\begin{minipg2}\n          The number of interpolation points in the\n          first parameter direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov im2}\\> - \\>\n        \\begin{minipg2}\n          The number of interpolation points in the\n          second parameter direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov idim} \\> - \\> Dimension of the space we are working in.\\\\\n        \\>\\>    {\\fov ipar} \\> - \\> Flag showing the desired\n                                    parametrization to be used:\\\\\n                \\>\\>\\>\\>\\> $= 1$ : \\begin{minipg5}\n                                     Mean accumulated cord-length\n                                     parameterization.\n                                   \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\> $= 2$ : Uniform parametrization.\\\\\n        \\>\\>\\>\\>\\begin{minipg2}\n                Numbering of surface edges:\\\\\n                \\begin{center}\n                  \\begin{picture}(180,110)(0,0)\n                    \\put(50,15){\\framebox(80,80)}\n                    \\put(40,55){\\makebox(0,0){3}}\n                    \\put(140,55){\\makebox(0,0){4}}\n                    \\put(90,5){\\makebox(0,0){1}}\n                    \\put(90,105){\\makebox(0,0){2}}\n\n                    \\put(60,20){\\vector(1,0){40}}\n                    \\put(85,28){\\makebox(0,0){$(i)$}}\n                    \\put(55,25){\\vector(0,1){40}}\n                    \\put(65,50){\\makebox(0,0){$(ii)$}}\n                  \\end{picture}\\\\\n                  $(i) \\; \\; \\;$ first parameter direction of surface.\\\\\n                  $(ii)$   second parameter direction of surface.\\\\\n                \\end{center}\n              \\end{minipg2}\\\\ \\\\\n        \\>\\>    {\\fov con1} \\> - \\> Additional condition along edge 1:\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : No additional condition.\\\\\n                      \\>\\>\\>\\>\\> $= 1$ : Zero curvature.\\\\\n        \\>\\>    {\\fov con2} \\> - \\> Additional condition along edge 2:\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : No additional condition.\\\\\n                      \\>\\>\\>\\>\\> $= 1$ : Zero curvature.\\\\\n        \\>\\>    {\\fov con3} \\> - \\> Additional condition along edge 3:\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : No additional condition.\\\\\n                      \\>\\>\\>\\>\\> $= 1$ : Zero curvature.\\\\\n        \\>\\>    {\\fov con4} \\> - \\> Additional condition along edge 4:\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : No additional condition.\\\\\n                      \\>\\>\\>\\>\\> $= 1$ : Zero curvature.\\\\\n        \\>\\>    {\\fov order1}\\> - \\> Order of surface in first parameter\n                                     direction.\\\\\n        \\>\\>    {\\fov order2}\\> - \\> Order of surface in second\\\\\n        \\>\\>    {\\fov iopen1}\\> - \\>\n                     \\begin{minipg2}\n                       Open/closed/periodic in first parameter direction.\n                     \\end{minipg2}\\\\\n                      \\>\\>\\>\\> $= 1$ \\> : Open surface.\\\\\n                      \\>\\>\\>\\> $= 0$ \\> : Closed surface.\\\\\n                      \\>\\>\\>\\> $= -1$ \\> : Closed and periodic\n                      surface.\\\\\n\\newpagetabs\n        \\>\\>    {\\fov iopen2}\\> - \\>\n                     \\begin{minipg2}\n                       Open/closed/periodic in second parameter direction.\n                     \\end{minipg2}\\\\\n                      \\>\\>\\>\\> $= 1$ \\> : Open surface.\\\\\n                      \\>\\>\\>\\> $= 0$ \\> : Closed surface.\\\\\n                      \\>\\>\\>\\> $= -1$ \\> : Closed and periodic surface.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rsurf}\\> - \\> Pointer to the B-spline surface produced.\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    double \\> {\\fov points}[300]; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\> {\\fov im1} = 10;\\\\\n        \\>\\>    int    \\> {\\fov im2} = 10;\\\\\n        \\>\\>    int    \\> {\\fov idim} = 3;\\\\\n        \\>\\>    int    \\> {\\fov ipar} = 1;\\\\\n        \\>\\>    int    \\> {\\fov con1} = 0;\\\\\n        \\>\\>    int    \\> {\\fov con2} = 0;\\\\\n        \\>\\>    int    \\> {\\fov con3} = 0;\\\\\n        \\>\\>    int    \\> {\\fov con4}= 0;\\\\\n        \\>\\>    int    \\> {\\fov order1} = 4; /* Cubic */\\\\\n        \\>\\>    int    \\> {\\fov order2} = 4;\\\\\n        \\>\\>    int    \\> {\\fov iopen1} = 1;\\\\\n        \\>\\>    int    \\> {\\fov iopen2} = 0;\\\\\n        \\>\\>    SISLSurf \\> *{\\fov rsurf} = NULL;\\\\\n        \\>\\>    int    \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1536(\\begin{minipg4}\n          {\\fov points}, {\\fov im1}, {\\fov im2}, {\\fov idim}, {\\fov ipar}, {\\fov con1}, {\\fov con2}, {\\fov con3},\n          {\\fov con4}, {\\fov order1},  {\\fov order2},  {\\fov iopen1},  {\\fov iopen2}, \\&{\\fov rsurf}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1537.tex",
    "content": "\\subsection{Compute a surface interpolating a set of points,\nparameterization as input.}\n\\funclabel{s1537}\n\\begin{minipg1}\n  Compute a tensor surface interpolating a set of points,\n  parameterization as input.\n  The output is represented as a B-spline surface.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1537(\\begin{minipg3}\n          {\\fov points}, {\\fov im1}, {\\fov im2}, {\\fov idim}, {\\fov par1},  {\\fov par2}, {\\fov con1}, {\\fov con2}, {\\fov con3},\n          {\\fov con4}, {\\fov order1},  {\\fov order2}, {\\fov iopen1},\n          {\\fov iopen2}, {\\fov rsurf}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    double \\> {\\fov points}[\\,];\\\\\n        \\>\\>    int    \\> {\\fov im1};\\\\\n        \\>\\>    int    \\> {\\fov im2};\\\\\n        \\>\\>    int    \\> {\\fov idim};\\\\\n        \\>\\>    double \\> {\\fov par1}[\\,];\\\\\n        \\>\\>    double \\> {\\fov par2}[\\,];\\\\\n        \\>\\>    int    \\> {\\fov con1};\\\\\n        \\>\\>    int    \\> {\\fov con2};\\\\\n        \\>\\>    int    \\> {\\fov con3};\\\\\n        \\>\\>    int    \\> {\\fov con4};\\\\\n        \\>\\>    int    \\> {\\fov order1};\\\\\n        \\>\\>    int    \\> {\\fov order2};\\\\\n        \\>\\>    int    \\> {\\fov iopen1};\\\\\n        \\>\\>    int    \\> {\\fov iopen2};\\\\\n        \\>\\>    SISLSurf \\> **{\\fov rsurf};\\\\\n        \\>\\>    int    \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov points}\\> - \\>\n        \\begin{minipg2}\n          Array of dimension $idim\\times im1\\times im2$ containing\n          the positions of the nodes (using the same ordering\n          as ecoef in the SISLSurf structure).\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov im1} \\> - \\>\n        \\begin{minipg2}\n          The number of interpolation points in the\n          first parameter direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov im2} \\> - \\>\n        \\begin{minipg2}\n          The number of interpolation points in the\n          second parameter direction.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov idim}\\> - \\> Dimension of the space we are working in.\\\\\n        \\>\\>    {\\fov par1}\\> - \\> Parametrization in first parameter direction.\\\\\n        \\>\\>    {\\fov par2}\\> - \\> Parametrization in second parameter\n                                   direction.\\\\\n\\newpagetabs\n        \\>\\>\\>\\>\\begin{minipg2}\n                Numbering of surface edges:\\\\\n                \\begin{center}\n                  \\begin{picture}(180,110)(0,0)\n                    \\put(50,15){\\framebox(80,80)}\n                    \\put(40,55){\\makebox(0,0){3}}\n                    \\put(140,55){\\makebox(0,0){4}}\n                    \\put(90,5){\\makebox(0,0){1}}\n                    \\put(90,105){\\makebox(0,0){2}}\n\n                    \\put(60,20){\\vector(1,0){40}}\n                    \\put(85,28){\\makebox(0,0){$(i)$}}\n                    \\put(55,25){\\vector(0,1){40}}\n                    \\put(65,50){\\makebox(0,0){$(ii)$}}\n                  \\end{picture}\\\\\n                  $(i) \\; \\; \\;$ first parameter direction of surface.\\\\\n                  $(ii)$   second parameter direction of surface.\\\\\n                \\end{center}\n              \\end{minipg2}\\\\ \\\\\n        \\>\\>    {\\fov con1} \\> - \\> Additional condition along edge 1:\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : No additional condition.\\\\\n                      \\>\\>\\>\\>\\> $= 1$ : Zero curvature.\\\\\n        \\>\\>    {\\fov con2} \\> - \\> Additional condition along edge 2:\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : No additional condition.\\\\\n                      \\>\\>\\>\\>\\> $= 1$ : Zero curvature.\\\\\n        \\>\\>    {\\fov con3} \\> - \\> Additional condition along edge 3:\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : No additional condition.\\\\\n                      \\>\\>\\>\\>\\> $= 1$ : Zero curvature.\\\\\n        \\>\\>    {\\fov con4} \\> - \\> Additional condition along edge 4:\\\\\n                      \\>\\>\\>\\>\\> $= 0$ : No additional condition.\\\\\n                      \\>\\>\\>\\>\\> $= 1$ : Zero curvature.\\\\\n        \\>\\>    {\\fov order1}\\> - \\> Order of surface in first parameter\n                                     direction.\\\\\n        \\>\\>    {\\fov order2}\\> - \\> Order of surface in second\n                                     parameter direction.\\\\\n        \\>\\>    {\\fov iopen1}\\> - \\>\n                     \\begin{minipg2}\n                       Open/closed/periodic in first parameter direction.\n                     \\end{minipg2}\\\\\n                      \\>\\>\\>\\>\\> $= 1$ \\> : Open surface.\\\\\n                      \\>\\>\\>\\>\\> $= 0$ \\> : Closed surface.\\\\\n                      \\>\\>\\>\\>\\> $= -1$ \\> : Closed and periodic\n                      surface.\\\\\n        \\>\\>    {\\fov iopen2}\\> - \\>\n                     \\begin{minipg2}\n                       Open/closed/periodic in second parameter direction.\n                     \\end{minipg2}\\\\\n                      \\>\\>\\>\\>\\> $= 1$ \\> : Open surface.\\\\\n                      \\>\\>\\>\\>\\> $= 0$ \\> : Closed surface.\\\\\n                      \\>\\>\\>\\>\\> $= -1$ \\> : Closed and periodic surface.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rsurf}\\> - \\> Pointer to the B-spline surface produced.\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    double \\> {\\fov points}[300]; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\> {\\fov im1} = 10;\\\\\n        \\>\\>    int    \\> {\\fov im2} = 10;\\\\\n        \\>\\>    int    \\> {\\fov idim} = 3;\\\\\n        \\>\\>    double \\> {\\fov par1}[10]; \\, /* Must be defined */\\\\\n        \\>\\>    double \\> {\\fov par2}[10]; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\> {\\fov con1} = 0;\\\\\n        \\>\\>    int    \\> {\\fov con2} = 0;\\\\\n        \\>\\>    int    \\> {\\fov con3} = 0;\\\\\n        \\>\\>    int    \\> {\\fov con4} = 0;\\\\\n        \\>\\>    int    \\> {\\fov order1} = 4; /* Cubic */\\\\\n        \\>\\>    int    \\> {\\fov order2} = 4;\\\\\n        \\>\\>    int    \\> {\\fov iopen1} = 1;\\\\\n        \\>\\>    int    \\> {\\fov iopen2} = 0;\\\\\n        \\>\\>    SISLSurf \\> *{\\fov rsurf} = NULL;\\\\\n        \\>\\>    int    \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1537(\\begin{minipg4}\n          {\\fov points}, {\\fov im1}, {\\fov im2}, {\\fov idim}, {\\fov par1},  {\\fov par2}, {\\fov con1}, {\\fov con2}, {\\fov con3},\n          {\\fov con4}, {\\fov order1},  {\\fov order2}, {\\fov iopen1},\n          {\\fov iopen2}, \\&{\\fov rsurf}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1538.tex",
    "content": "\\subsection{Create a lofted surface from a set of B-spline\ninput curves.}\n\\funclabel{s1538}\n\\begin{minipg1}\n  To create a lofted surface from a set of B-spline (i.e.\\ NOT rational)\n  input curves.\n  The output is represented as a B-spline surface.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1538(\\begin{minipg3}\n          {\\fov inbcrv}, {\\fov vpcurv}, {\\fov nctyp}, {\\fov astpar}, {\\fov iopen}, {\\fov iord2},\n          {\\fov iflag}, {\\fov rsurf}, {\\fov gpar}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    int       \\> {\\fov inbcrv};\\\\\n        \\>\\>    SISLCurve \\> *{\\fov vpcurv}[\\,];\\\\\n        \\>\\>    int       \\> {\\fov nctyp}[\\,];\\\\\n        \\>\\>    double    \\> {\\fov astpar};\\\\\n        \\>\\>    int       \\> {\\fov iopen};\\\\\n        \\>\\>    int       \\> {\\fov iord2};\\\\\n        \\>\\>    int       \\> {\\fov iflag};\\\\\n        \\>\\>    SISLSurf  \\> **{\\fov rsurf};\\\\\n        \\>\\>    double    \\> **{\\fov gpar};\\\\\n        \\>\\>    int       \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov inbcrv} \\> - \\> Number of B-spline curves in the curve set.\\\\\n        \\>\\>    {\\fov vpcurv} \\> - \\>\n        \\begin{minipg2}\n          Array (length {\\fov inbcrv}) of pointers to the\n          curves in the curve-set.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov nctyp}  \\> - \\>\n        \\begin{minipg2}\n          Array (length {\\fov inbcrv}) containing the types\n          of curves in the curve-set.\n        \\end{minipg2}\\\\[0.8ex]\n                \\>\\>\\>\\> $=1$ \\> : Ordinary curve.\\\\\n                \\>\\>\\>\\> $=2$ \\> : Knuckle curve. Treated as an ordinary curve.\\\\\n                \\>\\>\\>\\> $=3$ \\> : Tangent to next curve.\\\\\n                \\>\\>\\>\\> $=4$ \\> : Tangent to prior curve.\\\\\n                \\>\\>\\>\\> ($=5$ \\> : Second derivative to prior curve.)\\\\\n                \\>\\>\\>\\> ($=6$ \\> : Second derivative to next curve.)\\\\\n                \\>\\>\\>\\> $=13$ \\> : Curve giving start of tangent to next curve.\\\\\n                \\>\\>\\>\\> $=14$ \\> : Curve giving end of tangent to prior curve.\\\\\n        \\>\\>    {\\fov astpar} \\> - \\> Start parameter for spline lofting\n                                      direction.\\\\\n        \\>\\>    {\\fov iopen} \\> - \\>\n        \\begin{minipg2}\n          Flag telling if the resulting surface should be open, closed\n          or periodic in the lofting direction (i.e.\\ not the curve direction).\n        \\end{minipg2}\\\\[0.3ex]\n        \\>\\>\\>\\>  $= 1$ \\> : Open.\\\\\n        \\>\\>\\>\\>  $= 0$ \\> : Closed.\\\\\n        \\>\\>\\>\\>  $= -1$ \\> : Closed and periodic.\\\\\n        \\>\\>    {\\fov iord2} \\> - \\>\n        \\begin{minipg2}\n          Maximal order of the surface in the lofting direction.\n        \\end{minipg2}\\\\[0.8ex]\n\\newpagetabs\n        \\>\\>    {\\fov iflag} \\> - \\>\n        \\begin{minipg2}\n          Flag telling if the size of the tangents in the\n          derivative curves should be adjusted or not.\n        \\end{minipg2}\\\\[0.3ex]\n                      \\>\\>\\>\\> $= 0$ \\> : Do not adjust tangent sizes.\\\\\n                      \\>\\>\\>\\> $= 1$ \\> : Adjust tangent sizes.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rsurf} \\> - \\> Pointer to the B-spline surface produced.\\\\\n        \\>\\>    {\\fov gpar}  \\> - \\>\n        \\begin{minipg2}\n          The input curves are constant parameter lines\n          in the parameter-plane of the produced surface.\n          The $i$-th element in this array contains the (constant) value\n          of this parameter of the $i$-th. input curve.\n        \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\> $< 0$ \\> : Error.\\\\\n                \\>\\>\\>\\> $= 0$ \\> : Ok.\\\\\n                \\>\\>\\>\\> $> 0$ \\> : Warning.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    int       \\> {\\fov inbcrv} = 3;\\\\\n        \\>\\>    SISLCurve \\> *{\\fov vpcurv}[3]; \\,/* Must be defined */\\\\\n        \\>\\>    int       \\> {\\fov nctyp}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double    \\> {\\fov astpar} = 0.0;\\\\\n        \\>\\>    int       \\> {\\fov iopen} = 1;\\\\\n        \\>\\>    int       \\> {\\fov iord2} = 4; /* Cubic */ \\\\\n        \\>\\>    int       \\> {\\fov iflag} = 1;\\\\\n        \\>\\>    SISLSurf  \\> *{\\fov rsurf} = NULL;\\\\\n        \\>\\>    double    \\> *{\\fov gpar} = NULL;\\\\\n        \\>\\>    int       \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1538(\\begin{minipg4}\n          {\\fov inbcrv}, {\\fov vpcurv}, {\\fov nctyp}, {\\fov astpar}, {\\fov iopen}, {\\fov iord2},\n          {\\fov iflag}, \\&{\\fov rsurf}, \\&{\\fov gpar}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1539.tex",
    "content": "\\subsection{Create a lofted surface\n               from a set of B-spline input curves and parametrization.}\n\\funclabel{s1539}\n\\begin{minipg1}\nTo create a spline lofted surface\n               from a set of input curves. The parametrization\n               of the position curves is given in epar.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1539(\\begin{minipg3}\n            {\\fov inbcrv}, {\\fov vpcurv}, {\\fov nctyp}, {\\fov epar}, {\\fov astpar}, {\\fov iopen}, {\\fov iord2},\n            {\\fov iflag}, {\\fov rsurf}, {\\fov gpar}, {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    int    \\>  \t{\\fov inbcrv};\\\\\n                \\>\\>    SISLCurve    \\>  *{\\fov vpcurv}[\\,];\\\\\n                \\>\\>    int    \\>  \t{\\fov nctyp}[\\,];\\\\\n                \\>\\>    double    \\>  {\\fov epar}[\\,];\\\\\n                \\>\\>    double\t\\> {\\fov astpar};\\\\\n                \\>\\>    int    \\>  \t{\\fov iopen};\\\\\n                \\>\\>    int    \\>  \t{\\fov iord2};\\\\\n                \\>\\>    int    \\>  \t{\\fov iflag};\\\\\n                \\>\\>    SISLSurf    \\>  **{\\fov rsurf};\\\\\n                \\>\\>    double \t\\> **{\\fov gpar};\\\\\n                \\>\\>    int    \\>  \t*{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov inbcrv}\\> - \\>  \\begin{minipg2}\n                    set.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov vpcurv}\\> - \\>  \\begin{minipg2}\n                     Array (length inbcrv) of pointers to the\n                       curves in the curve-set.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov nctyp}\\> - \\>  \\begin{minipg2}\n                     Array (length inbcrv) containing the types\n                       of curves in the curve-set.\n                               \\end{minipg2}\\\\[0.8ex]\n                \\>\\>\\>\\> $=1$ \\> : Ordinary curve.\\\\\n                \\>\\>\\>\\> $=2$ \\> : Knuckle curve. Treated as an ordinary curve.\\\\\n                \\>\\>\\>\\> $=3$ \\> : Tangent to next curve.\\\\\n                \\>\\>\\>\\> $=4$ \\> : Tangent to previous curve.\\\\\n                \\>\\>\\>\\> ($=5$ \\> : Second derivative to previous curve.)\\\\\n                \\>\\>\\>\\> ($=6$ \\> : Second derivative to next curve.)\\\\\n                \\>\\>\\>\\> $=13$ \\> : Curve giving start of tangent to next curve.\\\\\n                \\>\\>\\>\\> $=14$ \\> : Curve giving end of tangent to previous curve.\\\\\n        \\>\\>    {\\fov epar}\\> - \\>  \\begin{minipg2}\n                     Array containing the wanted parametrization. Only\n                       parametervalues corresponding to position\n                       curves are given. For closed curves, one additional\n                       parameter value must be spesified. The last entry\n                       contains the parametrization of the repeated start\n                       curve. (if the endpoint is equal to the startpoint\n                       of the interpolation the lenght of the array should\n                       be equal to inpt1 also in the closed case). The\n                       number of entries in the array is thus equal to\n                       the number of position curves (number plus one\n                       if the curve is closed).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov astpar}\\> - \\>  \\begin{minipg2}\n                    parameter for spline lofting direction.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov iopen}\\> - \\>  \\begin{minipg2}\n                     Flag saying whether the resulting surface should\n                       be closed or open.\n                               \\end{minipg2}\\\\\n        \\>\\>\\>\\>  $= 1$ \\> : Open.\\\\\n        \\>\\>\\>\\>  $= 0$ \\> : Closed.\\\\\n        \\>\\>\\>\\>  $= -1$ \\> : Closed and periodic.\\\\\n        \\>\\>    {\\fov iord2}\\> - \\>  \\begin{minipg2}\n                    spline basis in the\n                       lofting direction.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov iflag}\\> - \\>  \\begin{minipg2}\n                     Flag saying whether the size of the tangents in the\n                       derivative curves should be adjusted or not.\n                               \\end{minipg2}\\\\\n                      \\>\\>\\>\\> $= 0$ \\> : Do not adjust tangent sizes.\\\\\n                      \\>\\>\\>\\> $= 1$ \\> : Adjust tangent sizes.\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov rsurf}\\> - \\>  \\begin{minipg2}\n                     Pointer to the surface produced.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov gpar}  \\> - \\>\n        \\begin{minipg2}\n          The input curves are constant parameter lines\n          in the parameter-plane of the produced surface.\n          The $i$-th element in this array contains the (constant) value\n          of this parameter of the $i$-th. input curve.\n        \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\> $< 0$ \\> : Error.\\\\\n                \\>\\>\\>\\> $= 0$ \\> : Ok.\\\\\n                \\>\\>\\>\\> $> 0$ \\> : Warning.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    int    \\>  \t{\\fov inbcrv} = 4;\\\\\n                \\>\\>    SISLCurve    \\>  *{\\fov vpcurv}[4]; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  \t{\\fov nctyp}[4]; \\, /* Must be defined */\\\\\n                \\>\\>    double    \\>  {\\fov epar}[5]; \\, /* Must be defined. The length corresponds to only\\\\\n                \\>\\>\\>\\>\\> positional curves and no duplication of first curve */\\\\\n                \\>\\>    double\t\\> {\\fov astpar} = 0.0;\\\\\n                \\>\\>    int    \\>  \t{\\fov iopen} = 0;\\\\\n                \\>\\>    int    \\>  \t{\\fov iord2} = 4; /* Cubic */ \\\\\n                \\>\\>    int    \\>  \t{\\fov iflag} = 0;\\\\\n                \\>\\>    SISLSurf    \\>  *{\\fov rsurf} = NULL;\\\\\n                \\>\\>    double \t\\> *{\\fov gpar} = NULL;\\\\\n                \\>\\>    int    \\>  \t{\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1539(\\begin{minipg4}\n            {\\fov inbcrv}, {\\fov vpcurv}, {\\fov nctyp}, {\\fov epar}, {\\fov astpar}, {\\fov iopen}, {\\fov iord2},\n            {\\fov iflag}, \\&{\\fov rsurf}, \\&{\\fov gpar}, \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1542.tex",
    "content": "\\subsection{Evaluate the curve over a grid of m points.  Only positions are evaluated.}\n\\funclabel{s1542}\n\\begin{minipg1}\nEvaluate the curve pointed at by pc1 over a m grid\n               of points (x[i]). Only positions are evaluated.\n               Do not apply in the rational case.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1542(\\begin{minipg3}\n            {\\fov pc1}, {\\fov m}, {\\fov x}, {\\fov eder}, {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLCurve \\> *{\\fov pc1};\\\\\n                \\>\\>    int    \\>  {\\fov m};\\\\\n                \\>\\>    double    \\>  {\\fov x}[\\,];\\\\\n                \\>\\>    double    \\>  {\\fov eder}[\\,];\\\\\n                \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov pc1}\\> - \\>  \\begin{minipg2}\n                     Pointer to the curve to evaluate.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov m}\\> - \\>  \\begin{minipg2}\n                     Number of grid points.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov x}\\> - \\>  \\begin{minipg2}\n                     Array of parameter values of the grid.\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov eder}\\> - \\>  \\begin{minipg2}\n                     Array where the positions of the curve\n                       are placed, dimension\n                         idim * m.\n                       The sequence is position at point x[0],\n                       followed by the same information at x[1],\n                       etc.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat}\\> - \\>  status messages \\\\\n\t              \\>\\>\\>\\>\\>   $ = 0 $  : Ok.\\\\\n\t\t      \\>\\>\\>\\>\\>   $ < 0 $  : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLCurve \\> *{\\fov pc1}; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov m} = 25;\\\\\n                \\>\\>    double    \\>  {\\fov x}[25];\\\\\n                \\>\\>    double    \\>  {\\fov eder}[75]; /* Geometry space dimension times m */\\\\\n                \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1542(\\begin{minipg4}\n            {\\fov pc1}, {\\fov m}, {\\fov x}, {\\fov eder}, \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1600.tex",
    "content": "\\section{Mirror a Curve}\n\\funclabel{s1600}\n\\begin{minipg1}\n  To mirror a curve around a plane.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1600(\\begin{minipg3}\n                {\\fov oldcurve}, {\\fov point}, {\\fov normal}, {\\fov dim}, {\\fov newcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov oldcurve};\\\\\n                \\>\\>    double  \\>      {\\fov point}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov normal}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov oldcurve}\\> - \\>  Pointer to original curve.\\\\\n        \\>\\>    {\\fov point}    \\> - \\> A point in the plane.\\\\\n        \\>\\>    {\\fov normal}   \\> - \\> Normal vector to the plane.\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> The dimension of the space.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newcurve}\\> - \\>  Pointer to the mirrored curve.\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov oldcurve}; \\,/* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov point}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov normal}[3]; \\,/* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve} =NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1600(\\begin{minipg4}\n                {\\fov oldcurve}, {\\fov point}, {\\fov normal}, {\\fov dim}, \\&{\\fov newcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1601.tex",
    "content": "\\section{Mirror a Surface}\n\\funclabel{s1601}\n\\begin{minipg1}\n  Mirror a surface about a plane.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1601(\\begin{minipg3}\n          {\\fov psurf}, {\\fov epoint}, {\\fov enorm}, {\\fov idim}, {\\fov rsurf}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf \\> *{\\fov psurf};\\\\\n        \\>\\>    double   \\> {\\fov epoint}[\\,];\\\\\n        \\>\\>    double   \\> {\\fov enorm}[\\,];\\\\\n        \\>\\>    int      \\> {\\fov idim};\\\\\n        \\>\\>    SISLSurf \\> **{\\fov rsurf};\\\\\n        \\>\\>    int      \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov psurf} \\> - \\> The input surface.\\\\\n        \\>\\>    {\\fov epoint}\\> - \\> A point in the plane.\\\\\n        \\>\\>    {\\fov enorm} \\> - \\> The normal vector to the plane.\\\\\n        \\>\\>    {\\fov idim}  \\> - \\>\n        \\begin{minipg2}\n          The dimension of the space, must be the same as the surface.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rsurf} \\> - \\> Pointer to the mirrored surface.\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf \\> *{\\fov psurf}; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> {\\fov epoint}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> {\\fov enorm}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    int      \\> {\\fov idim} = 3;\\\\\n        \\>\\>    SISLSurf \\> *{\\fov rsurf} = NULL;\\\\\n        \\>\\>    int      \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1601(\\begin{minipg4}\n          {\\fov psurf}, {\\fov epoint}, {\\fov enorm}, {\\fov idim}, \\&{\\fov rsurf}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1602.tex",
    "content": "\\subsection{Compute a curve interpolating a straight line between two points.}\n\\funclabel{s1602}\n\\begin{minipg1}\nTo make a straight line represented as a B-spline curve between two points.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1602(\\begin{minipg3}\n                {\\fov startpt}, {\\fov endpt}, {\\fov order}, {\\fov dim}, {\\fov startpar}, {\\fov endpar},\n                {\\fov curve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    double  \\>      {\\fov startpt}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov endpt}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov order};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov startpar};\\\\\n                \\>\\>    double  \\>      *{\\fov endpar};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov curve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\newpagetabs\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov startpt}  \\> - \\> Start point of the straight line\\\\\n        \\>\\>    {\\fov endpt}    \\> - \\> End point of the straight line\\\\\n        \\>\\>    {\\fov order}    \\> - \\> The order of the curve to be made.\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> The dimension of the geometric space\\\\\n        \\>\\>    {\\fov startpar} \\> - \\> Start value of the parameterization of the curve\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov endpar }\\> - \\>   Parameter value used at the end of the curve\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to the B-spline curve\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    double          \\>{\\fov startpt}[2];\\\\\n                \\>\\>    double          \\>{\\fov endpt}[2];\\\\\n                \\>\\>    int             \\>{\\fov order}=2;  /* If a higher order is requested will a degree \\\\\n                \\>\\>\\>\\>\\> one curve be constructed and degree raising \\\\\n                \\>\\>\\>\\>\\> performed to reach the requested order */ \\\\\n                \\>\\>    int             \\>{\\fov dim}=2; /* Corresponds to the number of parameters \\\\\n                \\>\\>\\>\\>\\> in startpt and endpt */\\\\\n                \\>\\>    double          \\>{\\fov startpar}=0.0;\\\\\n                \\>\\>    double          \\>{\\fov endpar};\\\\\n                \\>\\>    SISLCurve               \\>*{\\fov curve}=NULL;\\\\\n                \\>\\>    int             \\>{\\fov stat}=0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1602(\\begin{minipg4}\n                {\\fov startpt}, {\\fov endpt}, {\\fov order}, {\\fov dim},\n        {\\fov startpar}, \\&{\\fov endpar}, \\&{\\fov curve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1603.tex",
    "content": "\\section{Pick the Parameter Ranges of a Surface}\n\\funclabel{s1603}\n\\begin{minipg1}\n  To pick the parameter ranges of a surface.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1603(\\begin{minipg3}\n                                {\\fov surf}, {\\fov min1}, {\\fov min2}, {\\fov max1}, {\\fov max2}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      *{\\fov min1};\\\\\n                \\>\\>    double  \\>      *{\\fov min2};\\\\\n                \\>\\>    double  \\>      *{\\fov max1};\\\\\n                \\>\\>    double  \\>      *{\\fov max2};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                The surface.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov min1}\\> - \\>      \\begin{minipg2}\n                                Start parameter in the first parameter direction.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov min2}\\> - \\>      \\begin{minipg2}\n                                Start parameter in the second parameter direction.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov max1}\\> - \\>      \\begin{minipg2}\n                                End parameter in the first parameter direction.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov max2}\\> - \\>      \\begin{minipg2}\n                                End parameter in the second parameter direction.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov min1};\\\\\n                \\>\\>    double  \\>      {\\fov min2};\\\\\n                \\>\\>    double  \\>      {\\fov max1};\\\\\n                \\>\\>    double  \\>      {\\fov max2};\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1603(\\begin{minipg4}\n                {\\fov surf}, \\&{\\fov min1}, \\&{\\fov min2}, \\&{\\fov max1}, \\&{\\fov max2}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1604.tex",
    "content": "\\subsection{B-spline approximation.}\n\\funclabel{s1604}\n\\begin{minipg1}\n        To make a B-spline curve using the input points as control vertices. The\n        distances between the points are used to make the parameterization.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1604(\\begin{minipg3}\n                {\\fov points}, {\\fov numpt}, {\\fov startpar}, {\\fov open}, {\\fov dim}, {\\fov order}, {\\fov curve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    double  \\>      {\\fov points}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov numpt};\\\\\n                \\>\\>    double  \\>      {\\fov startpar};\\\\\n                \\>\\>    int     \\>      {\\fov open};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    int     \\>      {\\fov order};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov curve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov points}   \\> - \\> \\begin{minipg2}\n                                The array containing the points to be used as\n                                control vertices of the B-spline curve.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov numpt}    \\> - \\> Number of points in points.\\\\\n        \\>\\>    {\\fov startpar}\\> - \\>  \\begin{minipg2}\n                                Parameter-value to be used at the\n                                start of the curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov open}     \\> - \\> Open or closed curve:\\\\\n                \\>\\>\\>\\>\\>      0 :     Closed curve.\\\\\n                \\>\\>\\>\\>\\>      1 :     Open curve.\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                The dimension of the space in which\n                                the points lie.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov order}    \\> - \\> \\begin{minipg2}\n                                The order of the NURBS curve\n                                to be produced.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to output curve\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    double  \\>      {\\fov points[30]};\\\\\n                \\>\\>    int     \\>      {\\fov numpt} = 10;\\\\\n                \\>\\>    double  \\>      {\\fov startpar};\\\\\n                \\>\\>    int     \\>      {\\fov open} = 1;\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    int     \\>      {\\fov order};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    int     \\>      {\\fov stat};\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1604(\\begin{minipg4}\n                {\\fov points}, {\\fov numpt}, {\\fov startpar}, {\\fov open}, {\\fov dim}, {\\fov order}, \\&{\\fov curve}, \\&{\\fov stat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1606.tex",
    "content": "\\subsection{Compute a blending curve between two curves.}\n\\funclabel{s1606}\n\\begin{minipg1}\n  To compute a blending curve between two curves.\n  Two points indicate between which\n  ends the blend is to be produced.\n  The blending curve is either a circle or\n  an approximated conic section if this is\n  possible, otherwise it is a quadratic polynomial spline curve.\n  The output is represented as a B-spline curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1606(\\begin{minipg3}\n        {\\fov curve1}, {\\fov curve2}, {\\fov epsge}, {\\fov point1}, {\\fov point2},\n        {\\fov blendtype}, {\\fov dim}, {\\fov order}, {\\fov newcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve1};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve2};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      {\\fov point1}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov point2}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov blendtype};\\\\\n                \\>\\>    int     \\>      {\\fov dim;}\\\\\n                \\>\\>    int     \\>      {\\fov order};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve1}   \\> - \\> The first input curve.\\\\\n        \\>\\>    {\\fov curve2}   \\> - \\> The second input curve.\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> Geometry resolution.\\\\\n        \\>\\>    {\\fov point1}   \\> - \\> \\begin{minipg2}\n                        Point near the end of curve 1 where the blend starts.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov point2}   \\> - \\> \\begin{minipg2}\n                        Point near the end of curve 2 where the blend starts.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov blendtype}\\> - \\> Indicator of type of blending.\\\\\n                \\>\\>\\>\\>\\>      $=1$ : \\>\\begin{minipg5}\n                                Circle, interpolating tangent on first\n                                curve, not on curve 2, if possible.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $=2$ : \\>\\begin{minipg5}\n                                Conic if possible,\n                                \\end{minipg5}\\\\\n                \\>\\>\\>\\>\\>      else : \\>\\begin{minipg5}\n                                polynomial segment.\n                                \\end{minipg5}\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> Dimension of the geometry space.\\\\\n        \\>\\>    {\\fov order}    \\> - \\> Order of the blending curve.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newcurve}\\> - \\> Pointer to the B-spline blending curve.\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve1}; \\,/* Must be defined */ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve2}; \\,/* Must be defined */ \\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 0.00001;\\\\\n                \\>\\>    double  \\>      {\\fov point1}[3]; \\,/* Must be defined */ \\\\\n                \\>\\>    double  \\>      {\\fov point2}[3]; \\,/* Must be defined */ \\\\\n                \\>\\>    int     \\>      {\\fov blendtype} = 1;\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3; \\, /* Must be consistent with curve1 and curve2 /*\\\\\n                \\>\\>    int     \\>      {\\fov order} = 3; \\,/* If not given by blendtype */\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve};\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1606(\\begin{minipg4}\n        {\\fov curve1}, {\\fov curve2}, {\\fov epsge}, {\\fov point1}, {\\fov point2},\n        {\\fov blendtype}, {\\fov dim}, {\\fov order}, \\&{\\fov newcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1607.tex",
    "content": "\\subsection{Compute a fillet curve based on parameter value.}\n\\funclabel{s1607}\n\\begin{minipg1}\n  To calculate a fillet curve between two curves. The start and end point\n  for the fillet is given as one parameter value for each of the\n  curves.\n  The output is represented as a B-spline curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1607(\\begin{minipg3}\n        {\\fov curve1}, {\\fov curve2}, {\\fov epsge}, {\\fov end1}, {\\fov fillpar1}, {\\fov end2}, {\\fov fillpar2},\n        {\\fov filltype}, {\\fov dim}, {\\fov order}, {\\fov newcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve1};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve2};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      {\\fov end1};\\\\\n                \\>\\>    double  \\>      {\\fov fillpar1};\\\\\n                \\>\\>    double  \\>      {\\fov end2};\\\\\n                \\>\\>    double  \\>      {\\fov fillpar2};\\\\\n                \\>\\>    int     \\>      {\\fov filltype};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    int     \\>      {\\fov order};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve1}   \\> - \\> The first input curve.\\\\\n        \\>\\>    {\\fov curve2}   \\> - \\> The second input curve.\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> Geometry resolution.\\\\\n        \\>\\>    {\\fov end1}     \\> - \\> \\begin{minipg2}\n                        Parameter value on the first curve. The parameter fillpar1 divides the first curve in two pieces. End1 is used to select which of these pieces the fillet should extend.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov fillpar1}\\> - \\>  \\begin{minipg2}\n                        Parameter value of the start point of the fillet\n                                on the first curve.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov end2}     \\> - \\> \\begin{minipg2}\n                        Parameter value on the second curve indicating that\n                        the part of the curve lying on this side of fillpar2\n                                shall not be replaced by the fillet.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov fillpar2}\\> - \\>  \\begin{minipg2}\n                        Parameter value of the start point of the fillet\n                                on the second curve.\n                                \\end{minipg2}\\\\\n\\newpagetabs\n        \\>\\>    {\\fov filltype}\\> - \\>  Indicator of the type of fillet.\\\\\n                \\>\\>\\>\\>\\>      $=1$ : \\>\\begin{minipg5}\n                                Circle approximation, interpolating tangent on first\n                                curve, not on curve 2.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $=2$ : \\>\\begin{minipg5}\n                                Conic approximation if possible,\n                                \\end{minipg5}\\\\\n                \\>\\>\\>\\>\\>      else : \\>\\begin{minipg5}\n                                polynomial segment.\n                                \\end{minipg5}\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> Dimension of space.\\\\\n        \\>\\>    {\\fov order}    \\> - \\> Order of the fillet curve, which is not always used.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newcurve}\\> - \\> Pointer to the B-spline fillet curve.\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve1};  /* Must be defined */\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve2};  /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 0.0001;\\\\\n                \\>\\>    double  \\>      {\\fov end1};     \\,\\,\\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov fillpar1};  /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov end2};    \\,\\,\\,   /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov fillpar2};  /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov filltype} = 2;\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    int     \\>      {\\fov order} = 4;\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1607(\\begin{minipg4}\n        {\\fov curve1}, {\\fov curve2}, {\\fov epsge}, {\\fov end1}, {\\fov fillpar1}, {\\fov end2}, {\\fov fillpar2},\n        {\\fov filltype}, {\\fov dim}, {\\fov order}, \\&{\\fov newcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1608.tex",
    "content": "\\subsection{Compute a fillet curve based on points.}\n\\funclabel{s1608}\n\\begin{minipg1}\n  To calculate a fillet curve between two curves. Points indicate\n  between which points on the input curve the fillet is to be produced.\n  The output is represented as a B-spline curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1608(\\begin{minipg3}\n        {\\fov curve1}, {\\fov curve2}, {\\fov epsge}, {\\fov point1}, {\\fov startpt1}, {\\fov point2}, {\\fov endpt2},\n        {\\fov filltype}, {\\fov dim}, {\\fov order}, {\\fov newcurve}, {\\fov parpt1}, {\\fov parspt1}, {\\fov parpt2},\n        {\\fov parept2}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve1};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve2}; \\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      {\\fov point1}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov startpt1}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov point2}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov endpt2}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov filltype};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    int     \\>      {\\fov order};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve};\\\\\n                \\>\\>    double  \\>      *{\\fov parpt1};\\\\\n                \\>\\>    double  \\>      *{\\fov parspt1};\\\\\n                \\>\\>    double  \\>      *{\\fov parpt2};\\\\\n                \\>\\>    double  \\>      *{\\fov parept2};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve1}   \\> - \\> The first input curve.\\\\\n        \\>\\>    {\\fov curve2}   \\> - \\> The second input curve.\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> Geometry resolution.\\\\\n        \\>\\>    {\\fov point1}   \\> - \\> \\begin{minipg2}\n                        Point close to curve 1 indicating that the part of the\n                        curve lying on this side of startpt1 is\n                        not to be replaced by the fillet.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov startpt1}\\> - \\>  \\begin{minipg2}\n                        Point close to curve 1, indicating where the fillet is\n                        to start. The tangent at the start of the fillet will\n                        have the same orientation as the curve\n                        from point1 to startpt1.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov point2}   \\> - \\> \\begin{minipg2}\n                        Point close to curve 2 indicating that the part of the\n                        curve lying on this side of endpt2 is not\n                        to be replaced by the fillet.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov endpt2}   \\> - \\> \\begin{minipg2}\n                        Point close to curve two, indicating where the fillet\n                        is to end. The tangent at the end of the fillet will\n                        have the same orientation as the curve\n                        from endpt2 to point2.\n                                \\end{minipg2}\\\\[0.3ex]\n\\newpagetabs\n        \\>\\>    {\\fov filltype}\\> - \\>  Indicator of type of fillet.\\\\\n                \\>\\>\\>\\>\\>      $=1$ : \\>\\begin{minipg5}\n                                Circle, interpolating tangent on first\n                                curve, not on curve 2.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $=2$ : \\>\\begin{minipg5}\n                                Conic if possible,\n                                \\end{minipg5}\\\\\n                \\>\\>\\>\\>\\>      else : \\>\\begin{minipg5}\n                                polynomial segment.\n                                \\end{minipg5}\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> Dimension of space.\\\\\n        \\>\\>    {\\fov order}    \\> - \\> Order of fillet curve, which is not always used.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newcurve}\\> - \\> Pointer to the B-spline fillet curve.\\\\\n        \\>\\>    {\\fov parpt1}   \\> - \\> \\begin{minipg2}\n                        Parameter value of point {\\fov point1} on curve 1.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov parspt1}  \\> - \\> \\begin{minipg2}\n                        Parameter value of point {\\fov startpt1} on curve 1.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov parpt2}   \\> - \\> \\begin{minipg2}\n                        Parameter value of point {\\fov point2} on curve 2.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov parept2}  \\> - \\> \\begin{minipg2}\n                        Parameter value of point {\\fov endpt2} on curve 2.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve1};  /* Must be defined */\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve2}; /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 0.0001;\\\\\n                \\>\\>    double  \\>      {\\fov point1}[3]; \\,\\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov startpt1}[3];  /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov point2}[3]; \\,\\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov endpt2}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov filltype} = 3;\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    int     \\>      {\\fov order} = 4;\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve} = NULL;\\\\\n                \\>\\>    double  \\>      {\\fov parpt1};\\\\\n                \\>\\>    double  \\>      {\\fov parspt1};\\\\\n                \\>\\>    double  \\>      {\\fov parpt2};\\\\\n                \\>\\>    double  \\>      {\\fov parept2};\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1608(\\begin{minipg4}\n        {\\fov curve1}, {\\fov curve2}, {\\fov epsge}, {\\fov point1}, {\\fov startpt1}, {\\fov point2}, {\\fov endpt2},\\linebreak[4]\n        {\\fov filltype}, {\\fov dim}, {\\fov order}, \\&{\\fov newcurve}, \\&{\\fov parpt1}, \\&{\\fov parspt1},\n        \\linebreak[4] \\&{\\fov parpt2}, \\&{\\fov parept2}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1609.tex",
    "content": "\\subsection{Compute a fillet curve based on radius.}\n\\funclabel{s1609}\n\\begin{minipg1}\n  To calculate a constant radius fillet curve between two curves\n  if possible.\n  The output is represented as a B-spline curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1609(\\begin{minipg3}\n        {\\fov curve1}, {\\fov curve2}, {\\fov epsge}, {\\fov point1}, {\\fov pointf}, {\\fov point2}, {\\fov radius}, {\\fov normal},\\linebreak\n        {\\fov filltype}, {\\fov dim}, {\\fov order}, {\\fov newcurve}, {\\fov parend1}, {\\fov parspt1}, {\\fov parend2},\\linebreak\n        {\\fov parept2}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve1};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve2};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      {\\fov point1}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov pointf}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov point2}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov radius};\\\\\n                \\>\\>    double  \\>      {\\fov normal}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov filltype};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    int     \\>      {\\fov order};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve};\\\\\n                \\>\\>    double  \\>      *{\\fov parend1};\\\\\n                \\>\\>    double  \\>      *{\\fov parspt1};\\\\\n                \\>\\>    double  \\>      *{\\fov parend2};\\\\\n                \\>\\>    double  \\>      *{\\fov parept2};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve1}   \\> - \\> The first input curve.\\\\\n        \\>\\>    {\\fov curve2}   \\> - \\> The second input curve.\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> Geometry resolution.\\\\\n        \\>\\>    {\\fov point1}   \\> - \\> \\begin{minipg2}\n                        Point indicating that the fillet should be put on the\n                        side of {\\fov curve1} where {\\fov point1} is situated.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov pointf}\\> - \\>    \\begin{minipg2}\n                        Point indicating where the fillet curve should go.\n                        {\\fov point1} together with {\\fov pointf}\n                        indicates the direction of the start tangent of\n                        the curve, while pointf together with {\\fov point2}\n                        indicates the direction of the end tangent of\n                        the curve.  If more than one position of the fillet\n                        curve is possible, the closest curve to {\\fov pointf}\n                        is chosen.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov point2}   \\> - \\> \\begin{minipg2}\n                        Point indicating that the fillet should be put on the\n                        side of {\\fov curve2} where {\\fov point2} is situated.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov radius}   \\> - \\> \\begin{minipg2}\n                The radius to be used on the fillet if a circular fillet is\n                possible, otherwise a conic or a quadratic polynomial\n                curve is used, approximating the circular fillet.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov normal}   \\> - \\> \\begin{minipg2}\n                        Normal to the plane the fillet curve\n                        should lie close to. This is only used in 3D\n                        fillet calculations, and the fillet centre will\n                        be in the direction of the cross product of the\n                        curve tangents and the normal.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov filltype}\\> - \\>  Indicator of type of fillet.\\\\\n                \\>\\>\\>\\>\\>      $=1$ : \\>\\begin{minipg5}\n                                Circle, interpolating tangent on first\n                                curve, not on curve 2.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $=2$ : \\>\\begin{minipg5}\n                                Conic if possible,\n                                \\end{minipg5}\\\\\n                \\>\\>\\>\\>\\>      else : \\>\\begin{minipg5}\n                                polynomial segment.\n                                \\end{minipg5}\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> Dimension of space.\\\\\n        \\>\\>    {\\fov order}    \\> - \\> Order of fillet curve, which is not always used.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newcurve}\\> - \\> Pointer to the B-spline fillet curve.\\\\\n        \\>\\>    {\\fov parend1}  \\> - \\> \\begin{minipg2}\n                        Parameter value of the end of curve 1 not affected\n                        by the fillet.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov parspt1}  \\> - \\> \\begin{minipg2}\n                        Parameter value of the point on curve 1 where the\n                        fillet starts.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov parend2}  \\> - \\> \\begin{minipg2}\n                        Parameter value of the end of curve 2 not affected\n                        by the fillet.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov parept2}  \\> - \\> \\begin{minipg2}\n                        Parameter value of the point on curve 2 where the\n                        fillet ends.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve1}; \\,/* Must be defined */ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve2}; \\,/* Must be defined */ \\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 0.00001;\\\\\n                \\>\\>    double  \\>      {\\fov point1}[3];  \\, /* Must be defined */ \\\\\n                \\>\\>    double  \\>      {\\fov pointf}[3];  \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov point2}[3];  \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov radius};  \\, \\, \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov normal}[3];  \\,/* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov filltype} = 2;\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    int     \\>      {\\fov order} = 4; \\,/* If not given by filltype */\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve} = NULL;\\\\\n                \\>\\>    double  \\>      {\\fov parend1};\\\\\n                \\>\\>    double  \\>      {\\fov parspt1};\\\\\n                \\>\\>    double  \\>      {\\fov parend2};\\\\\n                \\>\\>    double  \\>      {\\fov parept2};\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1609(\\begin{minipg4}\n        {\\fov curve1}, {\\fov curve2}, {\\fov epsge}, {\\fov point1}, {\\fov pointf}, {\\fov point2}, {\\fov radius},\\\\ {\\fov normal},\n        {\\fov filltype}, {\\fov dim}, {\\fov order}, \\&{\\fov newcurve}, \\&{\\fov parend1}, \\&{\\fov parspt1},\\\\ \\&{\\fov parend2},\n        \\&{\\fov parept2}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1610.tex",
    "content": "\\subsection{Draw ``polygons'' in a surface using a recursive algorithm testing for \nplanarity of the subdivided parts.}\n\\funclabel{s1610}\n\\begin{minipg1}\nTo draw a surface using recursive subdivision.\nThis drawing function is slower than the one drawing constant parameter\nlines, s1237() (page~\\pageref{s1237}). But the recursive algorithm\nwill guarantee that all variations in the surface greater\nthan the surface resolution will be drawn.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1610(\\begin{minipg3}\n\t\t{\\fov surf}, {\\fov epscur}, {\\fov epssur}, {\\fov stat})\n\t\t\\end{minipg3}\\\\[0.3ex]\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epscur};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epssur};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov surf}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tThe NURBS surface to be drawn.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov epscur}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tGeometry resolution for curve.\n\t\t\t\tThe maximal distance allowed between\n\t\t\t\tthe curves \n\t\t\t\tdrawn and the surface.\n\t\t\t\t\\end{minipg2}\\\\[0.8ex]\n\t\\>\\>\t{\\fov epssur}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tGeometry resolution for surface.\n\t\t\t\t\\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov stat}\t\\> - \\>\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\n\\\\\nNOTE\\\\\n\\>\\begin{minipg6}\nThis function calls s6drawseq() which\nis device dependent. Before using the function make sure \nyou have a version of s6drawseq() \ninterfaced to your graphic package.\nMore about s6drawseq() on page~\\pageref{s6drawseq}.\n\\end{minipg6}\n\\\\ \n\\newpagetabs\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epscur};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epssur};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov stat};\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1610(\\begin{minipg4}\n\t\t{\\fov surf}, {\\fov epscur}, {\\fov epssur}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1611.tex",
    "content": "\\subsection{Approximate a conic arc with a curve.}\n\\funclabel{s1611}\n\\begin{minipg1}\n  To approximate a conic arc with a curve in two or three\n  dimensional space. If two points are given, a straight line is\n  produced, if three an approximation of a circular arc, and if four or\n  five a conic arc.\n  The output will be represented as a B-spline curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1611(\\begin{minipg3}\n                {\\fov point}, {\\fov numpt}, {\\fov dim}, {\\fov typept}, {\\fov open}, {\\fov order},\n                {\\fov startpar}, {\\fov epsge}, {\\fov endpar}, {\\fov curve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    double  \\>      {\\fov point}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov numpt};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov typept}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov open};\\\\\n                \\>\\>    int     \\>      {\\fov order};\\\\\n                \\>\\>    double  \\>      {\\fov startpar};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      *{\\fov endpar};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov curve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov point}    \\> - \\>\n                \\begin{minipg2}\n                  Array of length $dim\\times numpt$ containing the\n                  points/ derivatives to be interpolated.\n                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov numpt}    \\> - \\>\n                                No. of points/derivatives in the\n                                point array.\n                                \\\\\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                The dimension of the space in which\n                                the points lie.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov typept}   \\> - \\> \\begin{minipg2}\n                                Array (length numpt) containing type\n                                indicator for points/derivatives/\n                                second-derivatives:\n                                \\end{minipg2} \\\\[0.3ex]\n                \\>\\>\\>\\>\\>      1 : Ordinary point.\\\\\n                \\>\\>\\>\\>\\>      3 : Derivative to next point.\\\\\n                \\>\\>\\>\\>\\>      4 : Derivative to prior point.\\\\\n        \\>\\>    {\\fov open}     \\> - \\> Open or closed curve:\\\\\n                \\>\\>\\>\\>\\>      0 :     Closed curve, not implemented.\\\\\n                \\>\\>\\>\\>\\>      1 :     Open curve.\\\\\n        \\>\\>    {\\fov order}    \\> - \\> \\begin{minipg2}\n                                The order of the B-spline curve\n                                to be produced.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov startpar}\\> - \\>  \\begin{minipg2}\n                                Parameter-value to be used at the\n                                start of the curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> The geometry resolution.\\\\\n\\\\\n\\newpagetabs\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov endpar}   \\> - \\> \\begin{minipg2}\n                                Parameter-value used at the end\n                                of the curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to the output B-spline curve.\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nNOTE\\\\\n\\>\\begin{minipg6}\nWhen four points/tangents are given as input, the xy term of the\nimplicit equation is set to zero. Thus the points might end on two\nbranches of a hyperbola and a straight line is produced. When\nfour or five points/tangents are given only three of these should\nactually be points.\n\\end{minipg6}\n\\\\ \\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    double  \\>      {\\fov point}[30]; \\, /* Must be defined */ \\\\\n                \\>\\>    int     \\>      {\\fov numpt} = 10;\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov typept}[10]; \\, /* Must be defined */ \\\\\n                \\>\\>    int     \\>      {\\fov open} = 1;\\\\\n                \\>\\>    int     \\>      {\\fov order} = 4;\\\\\n                \\>\\>    double  \\>      {\\fov startpar} = 0.0;\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 0.0001;\\\\\n                \\>\\>    double  \\>      {\\fov endpar};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1611(\\begin{minipg4}\n                {\\fov point}, {\\fov numpt}, {\\fov dim}, {\\fov typept}, {\\fov open}, {\\fov order}, {\\fov startpar}, {\\fov epsge},\\linebreak\n                \\&{\\fov endpar}, \\&{\\fov curve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1613.tex",
    "content": "\\subsection{Approximate a curve with a sequence of straight lines.}\n\\funclabel{s1613}\n\\begin{minipg1}\n  To calculate a set of points on a curve. The straight lines between the\n  points will not deviate more than {\\fov epsge} from the curve at any\n  point.  The generated points will have the same spatial dimension as\n  the input curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1613(\\begin{minipg3}\n        {\\fov curve}, {\\fov epsge}, {\\fov points}, {\\fov numpoints}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    double  \\>      **{\\fov points};\\\\\n                \\>\\>    int     \\>      *{\\fov numpoints};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> \\begin{minipg2}\n                                The input curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution, maximum distance allowed\n                                between the curve and the straight lines that are to be\n                                calculated.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov points}   \\> - \\> \\begin{minipg2}\n                                Calculated points,\\\\\n                                (a vector of\n                                $numpoints\\times curve${\\tt ->}$idim$ elements).\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov numpoints}\\> - \\>\\begin{minipg2}\n                                Number of calculated points.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\,/* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov epsge}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      *{\\fov points} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numpoints} = 0;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1613(\\begin{minipg4}\n                {\\fov curve}, {\\fov epsge}, \\&{\\fov points}, \\&{\\fov numpoints}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1620.tex",
    "content": "\\subsection{Compute a surface using the input points as\ncontrol vertices, automatic parameterization.}\n\\funclabel{s1620}\n\\begin{minipg1}\n  To calculate a surface using the input points as\n  control vertices. The parametrization is calculated\n  according to {\\fov ipar}.\n  The output is represented as a B-spline surface.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1620(\\begin{minipg3}\n          {\\fov epoint}, {\\fov inbpnt1}, {\\fov inbpnt2}, {\\fov ipar},\n          {\\fov iopen1}, {\\fov iopen2}, {\\fov ik1}, {\\fov ik2}, {\\fov idim}, {\\fov rs}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    double \\> {\\fov epoint}[\\,];\\\\\n        \\>\\>    int    \\> {\\fov inbpnt1};\\\\\n        \\>\\>    int    \\> {\\fov inbpnt2};\\\\\n        \\>\\>    int    \\> {\\fov ipar};\\\\\n        \\>\\>    int    \\> {\\fov iopen1};\\\\\n        \\>\\>    int    \\> {\\fov iopen2};\\\\\n        \\>\\>    int    \\> {\\fov ik1};\\\\\n        \\>\\>    int    \\> {\\fov ik2};\\\\\n        \\>\\>    int    \\> {\\fov idim};\\\\\n        \\>\\>    SISLSurf \\> **{\\fov rs};\\\\\n        \\>\\>    int    \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov epoint} \\> - \\>\n        \\begin{minipg2}\n          The array containing the points to be used as\n          controlling vertices of the B-spline surface.\n        \\end{minipg2}\\\\\n        \\>\\>    {\\fov inbpnt1} \\> - \\> The number of points in first\n                                       parameter direction.\\\\\n        \\>\\>    {\\fov inbpnt2} \\> - \\> The number of points in second\n                                       parameter direction.\\\\\n        \\>\\>    {\\fov ipar} \\> - \\> Flag showing the desired\n                                    parametrization to be used:\\\\\n                 \\>\\>\\>\\> $= 1$ \\>:\n                 \\begin{minipg5}\n                   Mean accumulated cord-length\n                   parameterization.\n                 \\end{minipg5}\\\\[0.8ex]\n                 \\>\\>\\>\\> $= 2$ \\>: Uniform parametrization.\\\\\n        \\>\\>    {\\fov iopen1} \\> - \\>\n          Open/close condition in the first parameter direction:\\\\\n          \\>\\>\\>\\> $=1$ \\>: Open.\\\\\n          \\>\\>\\>\\> $=0$ \\>: Closed. \\\\\n          \\>\\>\\>\\> $=-1$ \\>: Closed and periodic.\\\\\n\\newpagetabs\n        \\>\\>    {\\fov iopen2} \\> - \\>\n          Open/close condition in the second parameter direction:\\\\\n          \\>\\>\\>\\> $=1$ \\>: Open.\\\\\n          \\>\\>\\>\\> $=0$ \\>: Closed. \\\\\n          \\>\\>\\>\\> $=-1$ \\>: Closed and periodic.\\\\\n        \\>\\>    {\\fov ik1} \\> - \\> The order of the surface in first direction.\\\\\n        \\>\\>    {\\fov ik2} \\> - \\> The order of the surface in second direction.\\\\\n        \\>\\>    {\\fov idim} \\> - \\> The dimension of the space.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rs} \\> - \\> Pointer to the B-spline surface.\\\\\n         \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\> $< 0$ \\>: Error.\\\\\n                \\>\\>\\>\\> $= 0$ \\>: Ok.\\\\\n                \\>\\>\\>\\> $> 0$ \\>: Warning.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    double \\> {\\fov epoint}[300]; \\, /* Must be defined */\\\\\n        \\>\\>    int    \\> {\\fov inbpnt1} = 10;\\\\\n        \\>\\>    int    \\> {\\fov inbpnt2} = 10;\\\\\n        \\>\\>    int    \\> {\\fov ipar} = 1;\\\\\n        \\>\\>    int    \\> {\\fov iopen1} = 1;\\\\\n        \\>\\>    int    \\> {\\fov iopen2} = 1;\\\\\n        \\>\\>    int    \\> {\\fov ik1} = 4; /* Cubic */\\\\\n        \\>\\>    int    \\> {\\fov ik2} = 4;\\\\\n        \\>\\>    int    \\> {\\fov idim} = 3;\\\\\n        \\>\\>    SISLSurf \\> *{\\fov rs} = NULL;\\\\\n        \\>\\>    int    \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1620(\\begin{minipg4}\n          {\\fov epoint}, {\\fov inbpnt1}, {\\fov inbpnt2}, {\\fov ipar},\n          {\\fov iopen1}, {\\fov iopen2}, {\\fov ik1}, {\\fov ik2}, {\\fov idim}, \\&{\\fov rs}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1630.tex",
    "content": "\\subsection{Compute a curve using the input points as\ncontrolling \\mbox{vertices}, automatic parameterization.}\n\\funclabel{s1630}\n\\begin{minipg1}\n  To compute a curve using the input points as controlling\n  vertices. The distances between the points are used as\n  parametrization.\n  The output will be represented as a B-spline curve.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1630(\\begin{minipg3}\n          {\\fov epoint}, {\\fov inbpnt}, {\\fov astpar}, {\\fov iopen}, {\\fov idim}, {\\fov ik}, {\\fov rc}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\> double \\>  {\\fov epoint}[\\,];\\\\\n        \\>\\> int    \\>  {\\fov inbpnt};\\\\\n        \\>\\> double \\>  {\\fov astpar};\\\\\n        \\>\\> int    \\>  {\\fov iopen};\\\\\n        \\>\\> int    \\>  {\\fov idim};\\\\\n        \\>\\> int    \\>  {\\fov ik};\\\\\n        \\>\\> SISLCurve \\> **{\\fov rc};\\\\\n        \\>\\> int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov epoint} \\> - \\>\n        \\begin{minipg2}\n          The array containing the points to be used as\n          controlling vertices of the B-spline curve.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov inbpnt} \\> - \\> No. of points in epoint.\\\\\n        \\>\\>    {\\fov astpar} \\> - \\>\n        \\begin{minipg2}\n          Parameter value to be used at the start of the curve.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov iopen} \\> - \\>\n        \\begin{minipg2}\n          Open/closed/periodic condition.\n        \\end{minipg2}\\\\[0.8ex]\n            \\>\\>\\>\\> $=-1$ \\> : Closed and periodic.\\\\\n            \\>\\>\\>\\> $=0$  \\> : Closed.\\\\\n            \\>\\>\\>\\> $=1$  \\> : Open.\\\\\n        \\>\\>    {\\fov idim} \\> - \\> The dimension of the space.\\\\\n        \\>\\>    {\\fov ik}   \\> - \\> The order of the spline curve to be produced.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rc} \\> - \\> Pointer to the B-spline curve.\\\\\n        \\>\\>    {\\fov jstat}\\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    double \\> {\\fov epoint}[30]; \\, /* Must be defined */ \\\\\n        \\>\\>    int    \\> {\\fov inbpnt} = 10;\\\\\n        \\>\\>    double \\> {\\fov astpar} = 0.0;\\\\\n        \\>\\>    int    \\> {\\fov iopen} = 1;\\\\\n        \\>\\>    int    \\> {\\fov idim} = 3;\\\\\n        \\>\\>    int    \\> {\\fov ik} = 4;\\\\\n        \\>\\>    SISLCurve \\> *{\\fov rc} = NULL;\\\\\n        \\>\\>    int    \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1630(\\begin{minipg4}\n          {\\fov epoint}, {\\fov inbpnt}, {\\fov astpar}, {\\fov iopen}, {\\fov idim}, {\\fov ik}, \\&{\\fov rc}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1706.tex",
    "content": "\\section{Reverse the Orientation of a Curve.}\n\\funclabel{s1706}\n\\begin{minipg1}\n  Turn the direction of a curve by reversing the ordering of the\n  coefficients.\n  The start parameter value of the new curve is the same as the start\n  parameter value of the old curve.\n  This routine turns the direction of the orginal curve.\n  If you want a copy with a turned direction, just make a copy and turn\n  the direction of the copy.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1706(\\begin{minipg3}\n        {\\fov curve})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> The curve to turn.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1706(\\begin{minipg4}\n                {\\fov curve});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1710.tex",
    "content": "\\subsection{Subdivide a curve at a given parameter value.}\n\\funclabel{s1710}\n\\begin{minipg1}\n  Subdivide a curve at a given parameter value.\\\\\n  NOTE: When the curve is periodic (i.e.\\ when the {\\fov cuopen} flag of\n  the curve has value $=-1$), this function will return only ONE curve\n  through {\\fov rcnew1}. This curve is the same geometric curve as {\\fov pc1},\n  but is represented on a closed basis, i.e.\\ with k-tuple start/end\n  knots and coinciding start/end coefficients.\n  The {\\fov cuopen} flag of the curve will then be set to closed ($=0$)\n  and a status value {\\fov jstat} equal to 2 will be returned.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1710(\\begin{minipg3}\n          {\\fov pc1},  {\\fov apar},  {\\fov rcnew1},  {\\fov rcnew2},  {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLCurve \\> *{\\fov pc1};\\\\\n        \\>\\>    double    \\> {\\fov apar};\\\\\n        \\>\\>    SISLCurve \\> **{\\fov rcnew1};\\\\\n        \\>\\>    SISLCurve \\> **{\\fov rcnew2};\\\\\n        \\>\\>    int       \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov pc1}  \\> - \\> The curve to subdivide.\\\\\n        \\>\\>    {\\fov apar} \\> - \\> Parameter value at which to subdivide.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov rcnew1} \\> - \\> First part of the subdivided curve.\\\\\n        \\>\\>    {\\fov rcnew2} \\> - \\>\n        \\begin{minipg2}\n          Second part of the subdivided curve.\n          If the parameter value is at the end of a\n          curve NULL pointers might be returned\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat} \\> - \\> Status messages\\\\\n                      \\>\\>\\>\\>\\> $= 5$      : \\begin{minipg5}\n                                                Parameter value at end of\n                                                curve, $rcnew1$=NULL or\n                                                {\\fov rcnew2}=NULL.\n                                              \\end{minipg5}\\\\[0.8ex]\n                      \\>\\>\\>\\>\\> $= 2$      : {\\fov pc1} periodic,\n                                              {\\fov rcnew2}=NULL.\\\\\n                      \\>\\>\\>\\>\\> $> 0$      : Warning.\\\\\n                      \\>\\>\\>\\>\\> $= 0$      : Ok.\\\\\n                      \\>\\>\\>\\>\\> $< 0$      : Error.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve \\> *{\\fov pc1}; \\, /* Must be defined */\\\\\n        \\>\\>    double    \\> {\\fov apar}; \\, /* Must be defined */\\\\\n        \\>\\>    SISLCurve \\> *{\\fov rcnew1} = NULL;\\\\\n        \\>\\>    SISLCurve \\> *{\\fov rcnew2} = NULL;\\\\\n        \\>\\>    int       \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>s1710(\\begin{minipg4}\n          {\\fov pc1},  {\\fov apar}, \\&{\\fov rcnew1}, \\&{\\fov rcnew2}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1711.tex",
    "content": "\\subsection{Subdivide a surface along a given parameter line.}\n\\funclabel{s1711}\n\\begin{minipg1}\n  Subdivide a surface along a given internal parameter line.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1711(\\begin{minipg3}\n        {\\fov surf}, {\\fov pardir}, {\\fov parval}, {\\fov newsurf1}, {\\fov newsurf2}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    int     \\>      {\\fov pardir};\\\\\n                \\>\\>    double  \\>      {\\fov parval};\\\\\n                \\>\\>    SISLSurf        \\>      **{\\fov newsurf1};\\\\\n                \\>\\>    SISLSurf        \\>      **{\\fov newsurf2};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}     \\> - \\> Surface to subdivide.\\\\\n        \\>\\>    {\\fov pardir}   \\> - \\> \\begin{minipg2}\n                                Value used to indicate in which\n                                parameter direction the subdivision is to take place.\n                                \\end{minipg2}\\\\[0.8ex]\n                \\>\\>\\>\\>\\>      $= 1$\\> : First parameter direction.\\\\\n                \\>\\>\\>\\>\\>      $= 2$\\> : Second parameter direction.\\\\\n        \\>\\>    {\\fov parval}   \\> - \\> \\begin{minipg2}\n                                Parameter value at which to subdivide.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newsurf1}\\> - \\>\\begin{minipg2}\n                                First part of the subdivided surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov newsurf2}\\> - \\>\\begin{minipg2}\n                                Second part of the subdivided surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\ %\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov pardir} = 2;\\\\\n                \\>\\>    double  \\>      {\\fov parval}; \\, /* Must be defined */\\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov newsurf1} = NULL;\\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov newsurf2} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1711(\\begin{minipg4}\n                {\\fov surf}, {\\fov pardir}, {\\fov parval}, \\&{\\fov newsurf1}, \\&{\\fov newsurf2}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1712.tex",
    "content": "\\subsection{Pick a part of a curve.}\n\\funclabel{s1712}\n\\begin{minipg1}\n  To pick one part of a curve and make a new curve of the part. If\n  $endpar<begpar$ the direction of the new curve is turned.\n  Use s1713() to pick a curve part crossing the start/end points of a\n  closed (or periodic) curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1712(\\begin{minipg3}\n        {\\fov curve}, {\\fov begpar}, {\\fov endpar}, {\\fov newcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov begpar};\\\\\n                \\>\\>    double  \\>      {\\fov endpar};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> The curve to pick a part from.\\\\\n        \\>\\>    {\\fov begpar}   \\> - \\> \\begin{minipg2}\n                                Start parameter value of the part curve\n                                to be picked.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov endpar}   \\> - \\> \\begin{minipg2}\n                                End parameter value of the part curve\n                                to be picked.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newcurve}\\> - \\>\\begin{minipg2}\n                                The new curve that is a part of the original curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov begpar}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov endpar}; \\, /* Must be defined */\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve} = NULL;\\\\\n                \\>\\>    int     \\>      stat = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1712(\\begin{minipg4}\n                {\\fov curve}, {\\fov begpar}, {\\fov endpar}, \\&{\\fov newcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1713.tex",
    "content": "\\subsection{Pick a part of a closed curve.}\n\\funclabel{s1713}\n\\begin{minipg1}\n  To pick one part of a closed curve and make a new curve of that\n  part. If the routine is used on an open curve and $endpar\\leq begpar$,\n  the last part of the curve is translated so that the end of the curve\n  joins the start.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1713(\\begin{minipg3}\n        {\\fov curve}, {\\fov begpar}, {\\fov endpar}, {\\fov newcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov begpar};\\\\\n                \\>\\>    double  \\>      {\\fov endpar};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> The curve to pick a part from.\\\\\n        \\>\\>    {\\fov begpar}   \\> - \\> \\begin{minipg2}\n                                Start parameter value of the part of the curve\n                                to be picked.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov endpar}   \\> - \\> \\begin{minipg2}\n                                End parameter value of the part of the curve\n                                to be picked.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newcurve}\\> - \\>\\begin{minipg2}\n                                The new curve that is a part of the original curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov begpar}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov endpar}; \\, /* Must be defined */\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1713(\\begin{minipg4}\n                {\\fov curve}, {\\fov begpar}, {\\fov endpar}, \\&{\\fov newcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1714.tex",
    "content": "\\subsection{Split a curve into two new curves.}\n\\funclabel{s1714}\n\\begin{minipg1}\n  Split a curve in two parts at two specified parameter values. The\n  first curve starts at {\\fov parval1}. If the curve is open, the last\n  part of the curve is translated so that the end of the curve joins the\n  start.\n\\end{minipg1} \\\\\nSYNOPSIS\\\\\n        \\>void s1714(\\begin{minipg3}\n        {\\fov curve}, {\\fov parval1}, {\\fov parval2}, {\\fov newcurve1}, {\\fov newcurve2}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov parval1};\\\\\n                \\>\\>    double  \\>      {\\fov parval2};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve1};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve2};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> The curve to split.\\\\\n        \\>\\>    {\\fov parval1}  \\> - \\> \\begin{minipg2}\n                                Start parameter value of the first new curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov parval2}  \\> - \\> \\begin{minipg2}\n                                Start parameter value of the second new curve.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newcurve1}\\> - \\>\\begin{minipg2}\n                                The first new curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov newcurve2}\\> - \\>\\begin{minipg2}\n                                The second new curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov parval1}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov parval2}; \\, /* Must be defined */\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve1} = NULL;\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve2} = NULL;\\\\\n                \\>\\>    int     \\>      stat = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1714(\\begin{minipg4}\n                {\\fov curve}, {\\fov parval1}, {\\fov parval2}, \\&{\\fov newcurve1}, \\&{\\fov newcurve2}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1715.tex",
    "content": "\\subsection{Join two curves at specified ends.}\n\\funclabel{s1715}\n\\begin{minipg1}\n  To join one end of one curve with one end of another curve by\n  translating the second curve. If {\\fov curve1} is to be joined at the start,\n  the direction of the curve is turned. If {\\fov curve2} is to be joined at the\n  end, the direction of this curve is turned. This means that {\\fov curve1}\n  always makes the first part of the new curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1715(\\begin{minipg3}\n        {\\fov curve1}, {\\fov curve2}, {\\fov end1}, {\\fov end2}, {\\fov newcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve1};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve2};\\\\\n                \\>\\>    int     \\>      {\\fov end1};\\\\\n                \\>\\>    int     \\>      {\\fov end2};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve1}   \\> - \\> First curve to join.\\\\\n        \\>\\>    {\\fov curve2}   \\> - \\> Second curve to join.\\\\\n        \\>\\>    {\\fov end1}     \\> - \\> \\begin{minipg2}\n                                True (1) if the first curve is to be joined at the end,\n                                else false (0).\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov end2}     \\> - \\> \\begin{minipg2}\n                                True (1) if the second curve is to be joined at the end,\n                                else false (0).\n                                \\end{minipg2}\\\\[0.3ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newcurve}\\> - \\>\\begin{minipg2}\n                                The new joined curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve1}; \\, /* Must be defined */\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve2}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov end1} = 1;\\\\\n                \\>\\>    int     \\>      {\\fov end2} = 0;\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat = 0};\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1715(\\begin{minipg4}\n                {\\fov curve1}, {\\fov curve2}, {\\fov end1}, {\\fov end2}, \\&{\\fov newcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1716.tex",
    "content": "\\subsection{Join two curves at closest ends.}\n\\funclabel{s1716}\n\\begin{minipg1}\n  To join two curves at the ends that lie closest to each other, if the\n  distance between the ends is less than the tolerance {\\fov epsge}. If\n  {\\fov curve1} is to be joined at the start, the direction of the curve is turned.\n  If {\\fov curve2} is to be joined at the end, the direction of this\n  curve is turned. This means that {\\fov curve1} always makes up the\n  first part of the new curve. If {\\fov epsge} is positive, but smaller\n  than the smallest distance between the ends of the two curves, a NULL\n  pointer is returned.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1716(\\begin{minipg3}\n        {\\fov curve1}, {\\fov curve2}, {\\fov epsge}, {\\fov newcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve1};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve2};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve1}   \\> - \\> First curve to join.\\\\\n        \\>\\>    {\\fov curve2}   \\> - \\> Second curve to join.\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> \\begin{minipg2}\n                                The curves are to be joined if {\\fov epsge} is\n                                greater than or equal to the distance\n                                between the ends lying closest to each\n                                other. If {\\fov epsge} is negative, the\n                                curves are automatically joined.\n                                \\end{minipg2}\\\\[0.3ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newcurve}\\> - \\>\\begin{minipg2}\n                                The new joined curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\ %\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve1}; \\, /* Must be defined */\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve2}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1716(\\begin{minipg4}\n                {\\fov curve1}, {\\fov curve2}, {\\fov epsge}, \\&{\\fov newcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1720.tex",
    "content": "\\subsection{Express the ``i''-th derivative of an open curve as a curve.}\n\\funclabel{s1720}\n\\begin{minipg1}\nTo express the ``i''-th derivative of an open curve as a curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1720(\\begin{minipg3}\n        {\\fov curve}, {\\fov derive}, {\\fov newcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    int     \\>      {\\fov derive};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Curve to be differentiated.\\\\\n        \\>\\>    {\\fov derive}   \\> - \\> \\begin{minipg2}\n                                The order \"i\" of the derivative, where\n                                $0 \\leq derive $.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newcurve}\\> - \\>\\begin{minipg2}\n                                The \"i\"-th derivative of a curve\n                                represented as a curve.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov derive} = 1;\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1720(\\begin{minipg4}\n                {\\fov curve}, {\\fov derive}, \\&{\\fov newcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1730.tex",
    "content": "\\subsection{Convert a curve to a sequence of Bezier curves.}\n\\funclabel{s1730}\n\\begin{minipg1}\n  To convert a curve to a sequence of Bezier curves. The Bezier\n  curves are stored as one curve with all knots of multiplicity\n  newcurve-$>$ik (order of the curve).\n  If the input curve is rational, the generated Bezier curves will be\n  rational too (i.e.\\ there will be rational weights in the\n  representation of the Bezier curves).\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1730(\\begin{minipg3}\n        {\\fov curve}, {\\fov newcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> The curve to convert.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newcurve}\\> - \\>\\begin{minipg2}\n                                The new curve\n                                containing all\n                                the Bezier curves.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1730(\\begin{minipg4}\n                {\\fov curve}, \\&{\\fov newcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1731.tex",
    "content": "\\subsection{Convert a surface to a mesh of Bezier surfaces.}\n\\funclabel{s1731}\n\\begin{minipg1}\n  To convert a surface to a mesh of Bezier surfaces.\n  The Bezier surfaces are stored in a surface with all knots having\n  multiplicity equal to the order of the surface in the\n  corresponding parameter direction.\n  If the input surface is rational, the generated Bezier surfaces will be\n  rational too (i.e.\\ there will be rational weights in the\n  representation of the Bezier surfaces).\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1731(\\begin{minipg3}\n                                {\\fov surf}, {\\fov newsurf}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    SISLSurf        \\>      **{\\fov newsurf};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Surface to convert.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newsurf}\\> - \\>   \\begin{minipg2}\n                                The new surface\n                                storing the Bezier represented\\\\ surfaces.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov sta}t     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov newsurf} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1731(\\begin{minipg4}\n                {\\fov surf}, \\&{\\fov newsurf}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1732.tex",
    "content": "\\subsection{Pick out the next Bezier curve from a curve.}\n\\funclabel{s1732}\n\\begin{minipg1}\n  To pick out the next Bezier curve from a curve. This function requires a\n  curve represented as the curve that is output from s1730().\n  If the input curve is rational, the generated Bezier curves will be\n  rational too (i.e.\\ there will be rational weights in the\n  representation of the Bezier curves, note the convention for coefficients in the\n  rational case, see Chapter~\\ref{sec:newCurve}).\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1732(\\begin{minipg3}\n        {\\fov curve}, {\\fov number}, {\\fov startpar}, {\\fov endpar}, {\\fov coef}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    int     \\>      {\\fov number};\\\\\n                \\>\\>    double  \\>      *{\\fov startpar};\\\\\n                \\>\\>    double  \\>      *{\\fov endpar};\\\\\n                \\>\\>    double  \\>      {\\fov coef}[\\,];\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> curve to pick from.\\\\\n        \\>\\>    {\\fov number}   \\> - \\>\\begin{minipg2}\n                                The number of the Bezier curve that is\n                                to be picked, where $0\\leq number<in/ik$\n                                (i.e.\\ the number of vertices in the\n                                curve divided by the order of the curve).\n                                \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov startpar}\\> - \\>\\begin{minipg2}\n                                The start parameter value of the Bezier curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov endpar} \\> - \\>\\begin{minipg2}\n                                The end parameter value of the Bezier curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov coef}     \\> - \\>\\begin{minipg2}\n                                The vertices of the Bezier curve.\n                                Space of size $(idim+1)\\times ik$ (i.e.\\\n                                spatial dimension of curve $+1$ times the\n                                order of the curve) must be allocated\n                                outside the function.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov number}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov startpar};\\\\\n                \\>\\>    double  \\>      {\\fov endpar};\\\\\n                \\>\\>    double  \\>      {\\fov coef}[12]; \\, /* Assumes dimension=3, order=4, non-rational */\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1732(\\begin{minipg4}\n                {\\fov curve}, {\\fov number}, \\&{\\fov startpar}, \\&{\\fov endpar}, {\\fov coef}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1733.tex",
    "content": "\\subsection{Pick the next Bezier surface from a surface.}\n\\funclabel{s1733}\n\\begin{minipg1}\n  To pick the next Bezier surface from a surface. This function\n  requires a surface represented as the result of s1731(). See page\n  \\pageref{s1731}.\n  This routine does not check that the surface is correct.\n  If the input surface is rational, the generated Bezier surfaces will be\n  rational too (i.e.\\ there will be rational weights in the\n  representation of the Bezier surfaces).\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1733(\\begin{minipg3}\n                {\\fov surf}, {\\fov number1}, {\\fov number2}, {\\fov startpar1}, {\\fov endpar1}, {\\fov startpar2},\n                 \\linebreak  {\\fov endpar2}, {\\fov coef}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    int     \\>      {\\fov number1};\\\\\n                \\>\\>    int     \\>      {\\fov number2};\\\\\n                \\>\\>    double  \\>      *{\\fov startpar1};\\\\\n                \\>\\>    double  \\>      *{\\fov endpar1};\\\\\n                \\>\\>    double  \\>      *{\\fov startpar2};\\\\\n                \\>\\>    double  \\>      *{\\fov endpar2};\\\\\n                \\>\\>    double  \\>      {\\fov coef}[\\,];\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                The surface to convert.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov number1}\\> - \\>\n        \\begin{minipg2}\n          The number of the Bezier patch to pick in the horizontal\n          direction, where $0\\leq number1<in1/ik1$ of the surface.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov number2}\\> - \\>\n        \\begin{minipg2}\n          The number of the Bezier patch to pick in the vertical\n          direction, , where $0\\leq number2<in2/ik2$ of the surface.\n        \\end{minipg2}\\\\[0.8ex]\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov startpar1}        \\> - \\> \\begin{minipg2}\n                                The start parameter value of the Bezier\n                                patch in the horizontal direction.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov endpar1}  \\> - \\> \\begin{minipg2}\n                                The end parameter value of the Bezier\n                                patch in the horizontal direction.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov startpar2}        \\> - \\> \\begin{minipg2}\n                                The start parameter value of the Bezier patch                           in the vertical direction.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov endpar2}  \\> - \\> \\begin{minipg2}\n                                The end parameter value of the Bezier patch                             in the vertical direction.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov coef}     \\> - \\>\n        \\begin{minipg2}\n          The vertices of the Bezier patch.\n          Space must be allocated with a size of $idim\\times ik1\\times ik2$ or\n          $(idim+1)\\times ik1\\times ik2$ in the rational case.\n          These parameters are given by the surface (this is done for reasons of efficiency).\n        \\end{minipg2}\\\\\n\\newpagetabs\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov number1}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov number2}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov startpar1};\\\\\n                \\>\\>    double  \\>      {\\fov endpar1};\\\\\n                \\>\\>    double  \\>      {\\fov startpar2};\\\\\n                \\>\\>    double  \\>      {\\fov endpar2};\\\\\n                \\>\\>    double  \\>      {\\fov coef}[48]; /* Non-rational, degree 3 in both directions, \\\\\n                \\>\\>\\>\\>\\> geometry space dimension equal to 3 */ \\\\\n                \\>\\>    int     \\>      stat = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1733(\\begin{minipg4}\n                {\\fov surf}, {\\fov number1}, {\\fov number2}, \\&{\\fov startpar1}, \\&{\\fov endpar1},\n                        \\&{\\fov startpar2}, \\&{\\fov endpar2}, {\\fov coef}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1740.tex",
    "content": "\\subsection{Draw piecewise straight lines approximating a B-spline curve.}\n\\funclabel{s1740}\n\\begin{minipg1}\nDraw piecewise straight lines approximating a B-spline curve.\nThe distance between the B-spline curve and the \nstraight lines is less than a tolerance epsge. NB see NOTE!\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1740(\\begin{minipg3}\n\t\t{\\fov curve}, {\\fov epsge}, {\\fov stat})\n\t\t\\end{minipg3}\\\\[0.3ex]\n\t\t\\>\\>\tSISLCurve\t\\> \t*{\\fov curve};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov epsge};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov curve}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tPointer to the curve.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov epsge}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tThe maximal distance allowed between the lines \n\t\t\t\tdrawn and the curve.\n\t\t\t\t\\end{minipg2} \\\\[0.8ex]\n\\\\\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov stat}\t\\> - \\>\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\n\\\\\nNOTE\\\\\n\\>\\begin{minipg6}\nThis function calls s6drawseq() which\nis device dependent. Before using the function you therefore have to be sure \nthat you have a version of s6drawseq() capable for your equipment.\nMore about s6drawseq() on page~\\pageref{s6drawseq}.\n\\end{minipg6}\n\\\\ \\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n\t\t\\>\\>\tSISLCurve\t\\> \t*{\\fov curve};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov epsge};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov stat};\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1740(\\begin{minipg4}\n\t\t\t{\\fov curve}, {\\fov epsge}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\} \\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1744.tex",
    "content": "\\subsection{Draw ``polygons'' in a surface limited by a closed B-spline \ncurve in the parameter plane of the surface\nusing a recursive algorithm testing for \nplanarity of the subdivided parts.}\n\\funclabel{s1744}\n\\begin{minipg1}\nTo draw a surface limited by a closed B-spline \ncurve in the parameter plane of the surface\nusing recursive subdivision.\nThis drawing function is slower than the one drawing constant parameter\nlines, s1238() (page~\\pageref{s1238}). But the recursive algorithm\nwill guarantee that all variations in the surface greater\nthan the surface resolution will be drawn.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1744(\\begin{minipg3}\n\t\t{\\fov surf}, {\\fov curve}, {\\fov epscur}, {\\fov epssur}, {\\fov stat})\n\t\t\\end{minipg3}\\\\[0.3ex]\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tSISLCurve\t\\>\t*{\\fov curve};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epscur};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epssur};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov surf}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tThe B-spline surface to be drawn.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov curve}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tSISLCurve limiting the part of the surface that is to be drawn\n\t\t\t\t\\end{minipg2}\\\\[0.8ex]\n\t\\>\\>\t{\\fov epscur}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tGeometry resolution for curve.\n\t\t\t\tThe maximal distance allowed between\n\t\t\t\tthe curves \n\t\t\t\tdrawn and the surface.\n\t\t\t\t\\end{minipg2}\\\\[0.8ex]\n\t\\>\\>\t{\\fov epssur}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tGeometry resolution for surface.\n\t\t\t\t\\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov stat}\t\\> - \\>\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\n\\\\\nNOTE\\\\\n\\>\\begin{minipg6}\nThis function calls s6drawseq() which\nis device dependent. Before using the function make sure \nto have a version of s6drawseq() \ninterfaced to your graphic package.\nMore about s6drawseq() on page~\\pageref{s6drawseq}.\n\\end{minipg6}\n\\\\ \\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tSISLCurve\t\\>\t*{\\fov curve};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epscur};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epssur};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov stat};\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1744(\\begin{minipg4}\n\t\t{\\fov surf}, {\\fov curve}, {\\fov epscur}, {\\fov epssur}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1745.tex",
    "content": "\\subsection{Shade a surface.}\n\\funclabel{s1745}\n\\begin{minipg1}\nTo shade a surface \nusing a recursive algorithm testing for \nplanarity of the subdivided parts.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1745(\\begin{minipg3}\n\t\t{\\fov surf}, {\\fov epsge}, {\\fov stat})\n\t\t\\end{minipg3}\\\\[0.3ex]\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epsge};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov surf}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tThe B-spline surface to be drawn.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov epsge}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tGeometry resolution for surface.\n\t\t\t\t\\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov stat}\t\\> - \\>\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\n\\\\\nNOTE\\\\\n\\>\\begin{minipg6}\nThis function calls s6shadepol() which\nis device dependent. Before using the function make sure \nto have a version of s6shadepol() \ninterfaced to your graphic package.\nMore about s6shadepol() on page~\\pageref{s6shadepol}.\n\\end{minipg6}\n\\\\ \\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epsge};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov stat};\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1745(\\begin{minipg4}\n\t\t{\\fov surf}, {\\fov epsge}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1746.tex",
    "content": "\\subsection{Shade a surface limited by a closed B-spline \ncurve in the parameter plane of the surface.}\n\\funclabel{s1746}\n\\begin{minipg1}\nTo shade a surface \nlimited by a closed B-spline \ncurve in the parameter plane of the surface, using a recursive algorithm testing for \nplanarity of the subdivided parts\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1746(\\begin{minipg3}\n\t\t{\\fov surf}, {\\fov curve}, {\\fov epsge}, {\\fov stat})\n\t\t\\end{minipg3}\\\\[0.3ex]\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tSISLCurve\t\\>\t*{\\fov curve};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epsge};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov surf}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tThe B-spline surface to be drawn.\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov curve}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tSISLCurve limiting the part of the surface that is to be drawn\n\t\t\t\t\\end{minipg2}\\\\[0.8ex]\n\t\\>\\>\t{\\fov epsge}\\> - \\>\t\\begin{minipg2}\n\t\t\t\tGeometry resolution for surface.\n\t\t\t\t\\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov stat}\t\\> - \\>\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\n\\\\\nNOTE\\\\\n\\>\\begin{minipg6}\nThis function calls s6shadepol() which\nis device dependent. Before using the function make sure \nto have a version of s6shadepol() \ninterfaced to your graphic package.\nMore about s6shadepol() on page~\\pageref{s6shadepol}.\n\\end{minipg6}\n\\\\ \\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n\t\t\\>\\>\tSISLSurf\t\\> \t*{\\fov surf};\\\\\n\t\t\\>\\>\tSISLCurve\t\\>\t*{\\fov curve};\\\\\n\t\t\\>\\>\tdouble\t\\>\t{\\fov epsge};\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov stat};\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1746(\\begin{minipg4}\n\t\t{\\fov surf}, {\\fov curve}, {\\fov epsge}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1750.tex",
    "content": "\\subsection{Express a curve using a higher order basis.}\n\\funclabel{s1750}\n\\begin{minipg1}\n  To describe a curve using a higher order basis.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1750(\\begin{minipg3}\n        {\\fov curve}, {\\fov order}, {\\fov newcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    int     \\>      {\\fov order};\\\\\n                \\>\\>    SISLCurve       \\>      **{\\fov newcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> The input curve.\\\\\n        \\>\\>    {\\fov order}    \\> - \\> \\begin{minipg2}\n                                Order of the new curve.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov newcurve}\\> - \\>\\begin{minipg2}\n                                The new curve of higher order.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\,/* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov order}; \\, /* Must be defined */\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov newcurve} = NULL;\\\\\n                \\>\\>    int     \\>      stat = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1750(\\begin{minipg4}\n                {\\fov curve}, {\\fov order}, \\&{\\fov newcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1774.tex",
    "content": "\\subsection{Local iteration to closest point between point and curve.}\n\\funclabel{s1774}\n\\begin{minipg1}\nNewton iteration on the distance function between\n               a curve and a point, to find a closest point or an\n               intersection point.\n               If a bad choice for the guess parameter is given in, the\n               iteration may end at a local, not global closest point.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1774(\\begin{minipg3}\n            {\\fov crv},  {\\fov point},  {\\fov dim},  {\\fov epsge},  {\\fov start},  {\\fov end},  {\\fov guess},  {\\fov clpar},  {\\fov stat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLCurve \\> *{\\fov crv};\\\\\n                \\>\\>    double \\> {\\fov point}[\\,];\\\\\n                \\>\\>    int \\> {\\fov dim};\\\\\n                \\>\\>    double \\> {\\fov epsge};\\\\\n                \\>\\>    double \\> {\\fov start};\\\\\n                \\>\\>    double \\> {\\fov end};\\\\\n                \\>\\>    double \\> {\\fov guess};\\\\\n                \\>\\>    double \\> *{\\fov clpar};\\\\\n                \\>\\>    int \\> *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov crv}\\> - \\>  \\begin{minipg2}\n                     The curve in the closest point problem.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov point}\\> - \\>  \\begin{minipg2}\n                     The point in the closest point problem.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}\\> - \\>  \\begin{minipg2}\n                     Dimension of the geometry.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>  \\begin{minipg2}\n                     Geometrical resolution.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov start}\\> - \\>  \\begin{minipg2}\n                     Curve parameter giving the start of the search\n                        interval.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov end}\\> - \\>  \\begin{minipg2}\n                     Curve parameter giving the end of the search\n                        interval.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov guess}\\> - \\>  \\begin{minipg2}\n                     Curve guess parameter for the closest point\n                        iteration.\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov clpar}\\> - \\>  \\begin{minipg2}\n                     Resulting curve parameter from the iteration.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : A minimum distance found.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Intersection found.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLCurve \\> *{\\fov crv}; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> {\\fov point}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    int \\> {\\fov dim} = 3;\\\\\n                \\>\\>    double \\> {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    double \\> {\\fov start}; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> {\\fov end}; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> {\\fov guess}; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> {\\fov clpar} = 0;\\\\\n                \\>\\>    int \\> {\\fov stat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1774(\\begin{minipg4}\n            {\\fov crv},  {\\fov point},  {\\fov dim},  {\\fov epsge},  {\\fov start},  {\\fov end},  {\\fov guess},  \\&{\\fov clpar},  \\&{\\fov stat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1775.tex",
    "content": "\\subsection{Local iteration to closest point bewteen point and surface.}\n\\funclabel{s1775}\n\\begin{minipg1}\nNewton iteration on the distance function between\n               a surface and a point, to find a closest point or an\n               intersection point.\n               If a bad choice for the guess parameters is given in, the\n               iteration may end at a local, not global closest point.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1775(\\begin{minipg3}\n            {\\fov surf},  {\\fov point},  {\\fov dim},  {\\fov epsge},  {\\fov start},  {\\fov end},  {\\fov guess},  {\\fov clpar},  {\\fov stat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf \\> *{\\fov surf};\\\\\n                \\>\\>    double \\> {\\fov point}[\\,];\\\\\n                \\>\\>    int \\> {\\fov dim};\\\\\n                \\>\\>    double \\> {\\fov epsge};\\\\\n                \\>\\>    double \\> {\\fov start}[\\,];\\\\\n                \\>\\>    double \\> {\\fov end}[\\,];\\\\\n                \\>\\>    double \\> {\\fov guess}[\\,];\\\\\n                \\>\\>    double \\> {\\fov clpar}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>  \\begin{minipg2}\n                     The surface in the closest point problem.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov point}\\> - \\>  \\begin{minipg2}\n                     The point in the closest point problem.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}\\> - \\>  \\begin{minipg2}\n                     Dimension of the geometry.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>  \\begin{minipg2}\n                     Geometry resolution.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov start}\\> - \\>  \\begin{minipg2}\n                     Surface parameters giving the start of the search\n                        area (umin, vmin).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov end}\\> - \\>  \\begin{minipg2}\n                     Surface parameters giving the end of the search\n                        area (umax, vmax).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov guess}\\> - \\>  \\begin{minipg2}\n                     Surface guess parameters for the closest point\n                        iteration.\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov clpar}\\> - \\>  \\begin{minipg2}\n                     Resulting surface parameters from the iteration.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : A minimum distance found.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Intersection found.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLSurf \\> *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> {\\fov point}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    int \\> {\\fov dim} = 3;\\\\\n                \\>\\>    double \\> {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    double \\> {\\fov start}[2]; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> {\\fov end}[2]; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> {\\fov guess}[2]; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> {\\fov clpar}[2];\\\\\n                \\>\\>    int \\> {\\fov stat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1775(\\begin{minipg4}\n            {\\fov surf},  {\\fov point},  {\\fov dim},  {\\fov epsge},  {\\fov start},  {\\fov end},  {\\fov guess},  {\\fov clpar},  \\&{\\fov stat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1850.tex",
    "content": "\\subsection{\\sloppy Intersection between a spline curve and a straight line or a plane.}\n\\funclabel{s1850}\n\\begin{minipg1}\n        Find all the intersections between a spline curve and a plane (if\n        curve dimension and $dim=3$)\n        or a curve and a line (if curve dimension and $dim=2$).\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1850(\\begin{minipg3}\n        {\\fov curve}, {\\fov point}, {\\fov normal}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov numintpt},\n        {\\fov intpar},\\linebreak {\\fov numintcu}, {\\fov intcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov point}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov normal}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov intpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcu};\\\\\n                \\>\\>    SISLIntcurve \\> ***{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to the curve.\\\\\n        \\>\\>    {\\fov point}    \\> - \\> Point in the plane/line.\\\\\n        \\>\\>    {\\fov normal}   \\> - \\>\n        \\begin{minipg2}\n          Normal to the plane or any normal to the direction of the\n          line.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                Dimension of the space in which the\n                                curve and the plane/line lies, {\\fov\n                                  dim} must be equal to two or three.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epsco}    \\> - \\> Computational resolution (not used).\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> Geometry resolution.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  Number of single intersection points.\\\\\n        \\>\\>    {\\fov intpar}   \\> - \\> \\begin{minipg2}\n                        Array containing the parameter values of the\n                        single intersection points in the parameter\n                        interval of the curve. The points lie in sequence.\n                        Intersection curves are stored in intcurve.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcu}\\> - \\>Number of intersection curves.\\\\\n\\newpagetabs\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                        Array of pointers to SISLIntcurve objects\n                        containing description of the intersection\n                        curves. The curves are only described by start\n                        points and end points in\n                        the parameter interval of the curve. The\n                        curve pointers point\n                        to nothing.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov point}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov normal}[3]; \\,/* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov intpar} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcu} = 0;\\\\\n                \\>\\>    SISLIntcurve \\> **{\\fov intcurve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1850(\\begin{minipg4}\n                {\\fov curve}, {\\fov point}, {\\fov normal}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov numintpt},\n                \\&{\\fov intpar}, \\&{\\fov numintcu}, \\&{\\fov intcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1851.tex",
    "content": "\\subsection{Find the topology for the intersections between a spline surface and a plane.}\n\\funclabel{s1851}\n\\begin{minipg1}\n  Find all intersections between a tensor-product surface and a plane.\n  Intersection curves are described by guide points.\n  To make the intersection curves use s1314() described on page \\pageref{s1314}.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1851(\\begin{minipg3}\n                        {\\fov surf}, {\\fov point}, {\\fov normal},\n                {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov numintpt},\n                {\\fov pointpar}, {\\fov numintcr},\n                        {\\fov intcurves}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov point}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov normal}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov pointpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcr};\\\\\n                \\>\\>    SISLIntcurve\\>  ***{\\fov intcurves};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to surface\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov point}\\> - \\>     \\begin{minipg2}\n                                Point in the plane.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov normal}\\> - \\>    \\begin{minipg2}\n                                Normal to the plane.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}\\> - \\>       \\begin{minipg2}\n                                Dimension of the space in which the plane lies.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  \\begin{minipg2}\n                                Number of single intersection points.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov pointpar}\\> - \\>  \\begin{minipg2}\n                                Array containing the parameter values of the single\n                                intersection points in the parameter plane of the\n                                surface. The points lie in sequence. Intersection curves\n                                are stored in intcurves.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    numintcr\\> - \\> \\begin{minipg2}\n                                Number of intersection curves.\n                                \\end{minipg2}\\\\\n        \\>\\>    intcurves\\> - \\>        \\begin{minipg2}\n                                Array containing descriptions of the intersection\n                                curves. The curves are only described by\n                                start points and end points (guide points) in\n                                the parameter plane. The curve pointers\n                                point to nothing.\n                                \\end{minipg2}\\\\[0.8ex]\n\\newpagetabs\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov point}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov normal}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov pointpar} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcr} = 0;\\\\\n                \\>\\>    SISLIntcurve\\>  **{\\fov intcurves} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1851(\\begin{minipg4}\n                {\\fov surf}, {\\fov point}, {\\fov normal}, {\\fov dim},\n                {\\fov epsco}, {\\fov epsge}, \\&{\\fov numintpt},\n                \\&{\\fov pointpar}, \\&{\\fov numintcr},\n                \\&{\\fov intcurves}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1852.tex",
    "content": "\\subsection{Find the topology for the intersection between a spline surface and a sphere.}\n\\funclabel{s1852}\n\\begin{minipg1}\n  Find all intersections between a tensor-product surface and a sphere.\n  Intersection curves are described by guide points.\n  To produce the intersection curves use s1315() described on page \\pageref{s1315}.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1852(\\begin{minipg3}\n                {\\fov surf}, {\\fov centre}, {\\fov radius}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov numintpt},\n                {\\fov pointpar}, \\linebreak {\\fov numintcr},\n                {\\fov intcurves}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov centre} [];\\\\\n                \\>\\>    double  \\>      {\\fov radius};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov pointpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcr};\\\\\n                \\>\\>    SISLIntcurve\\>  ***{\\fov intcurves};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>              \\begin{minipg2}\n                                Pointer to the surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov centre}\\> - \\>    \\begin{minipg2}\n                                Center of the sphere.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov radius}\\> - \\>    \\begin{minipg2}\n                                Radius of the sphere.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}\\> - \\>       \\begin{minipg2}\n                                Dimension of the space in which the sphere lies.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>\\begin{minipg2}\n                                Number of single intersection points.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov pointpar}\\> - \\>  \\begin{minipg2}\n                                Array containing the parameter values of the single\n                                intersection points in the parameter plane of the\n                                surface. The points lie in sequence. Intersection curves\n                                are stored in intcurves.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcr}\\> - \\>  \\begin{minipg2}\n                                Number of intersection curves.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov intcurves}\\> - \\> \\begin{minipg2}\n                                Array containing description of the intersection\n                                curves. The curves are only described by\n                                start points and end points (guide points) in\n                                the parameter plane. The curve pointers point to\n                                nothing.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n%\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov centre}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov radius}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov pointpar} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcr} = 0;\\\\\n                \\>\\>    SISLIntcurve\\>  **{\\fov intcurves} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1852(\\begin{minipg4}\n                        {\\fov surf}, {\\fov centre}, {\\fov radius}, {\\fov dim}, {\\fov epsco}, {\\fov epsge},\n                        \\&{\\fov numintpt}, \\&{\\fov pointpar}, \\&{\\fov numintcr},\n                        \\&{\\fov intcurves}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1853.tex",
    "content": "\\subsection{Find the topology for the intersections between a spline surface and a cylinder.}\n\\funclabel{s1853}\n\\begin{minipg1}\n  Find all intersections between a tensor-product surface and a cylinder.\n  Intersection curves are described by guide points.\n  To produce the intersection curves use s1316() described on page \\pageref{s1316}.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1853(\\begin{minipg3}\n                        {\\fov surf}, {\\fov point}, {\\fov cyldir}, {\\fov radius}, {\\fov dim}, {\\fov epsco},\n                        {\\fov epsge}, {\\fov numintpt}, \\linebreak\n                        {\\fov pointpar}, {\\fov numintcr}, {\\fov intcurves}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov point}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov cyldir}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov radius};\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov pointpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcr};\\\\\n                \\>\\>    SISLIntcurve\\>  ***{\\fov intcurves};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov point}\\> - \\>     \\begin{minipg2}\n                                Point on the axis of the cylinder.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov cyldir}\\> - \\>    \\begin{minipg2}\n                                The direction vector of the axis of the cylinder.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov radius}\\> - \\>    \\begin{minipg2}\n                                Radius of the cylinder.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}\\> - \\>       \\begin{minipg2}\n                                Dimension of the space in which the cylinder lies.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  \\begin{minipg2}\n                                Number of single intersection points.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov pointpar}\\> - \\>  \\begin{minipg2}\n                                Array containing the parameter values of the single\n                                intersection points in the parameter plane of the\n                                surface. The points lie in sequence. Intersection curves\n                                are stored in intcurves.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcr}\\> - \\>  \\begin{minipg2}\n                                Number of intersection curves.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov intcurves}\\> - \\> \\begin{minipg2}\n                                Array containing description of the intersection\n                                curves. The curves are only described by\n                                start points and end points (guide points) in\n                                the parameter plane. The curve pointers point to\n                                nothing.\n\n                                \\end{minipg2}\\\\[0.3ex]\n\\newpagetabs\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov point}[3]; \\,/* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov cyldir}[3]; \\,/* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov radius}; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov pointpar} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcr} = 0;\\\\\n                \\>\\>    intcurve\\>      **{\\fov intcurves} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1853(\\begin{minipg4}\n                {\\fov surf}, {\\fov point}, {\\fov cyldir}, {\\fov radius}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov numintpt},\n                \\&{\\fov pointpar}, \\&{\\fov numintcr}, \\&{\\fov intcurves}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1854.tex",
    "content": "\\subsection{Find the topology for the intersections between a spline surface and a cone.}\n\\funclabel{s1854}\n\\begin{minipg1}\n  Find all intersections between a tensor-product surface and a cone.\n  Intersection curves are described by guide points.\n  To produce the intersection curves use s1317() described on page \\pageref{s1317}.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1854(\\begin{minipg3}\n                        {\\fov surf}, {\\fov toppt}, {\\fov axispt}, {\\fov conept}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov numintpt}, {\\fov pointpar},\n                        {\\fov numintcr}, {\\fov intcurves}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov toppt}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov axispt}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov conept}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov pointpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcr};\\\\\n                \\>\\>    SISLIntcurve\\>  ***{\\fov intcurves};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the surface\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov toppt}\\> - \\>     \\begin{minipg2}\n                                Top point of the cone.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov axispt}\\> - \\>    \\begin{minipg2}\n                                Point on the axis of the cone, axispt must be different from toppt.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov conept}\\> - \\>    \\begin{minipg2}\n                                Point on the cone surface, conept must be different from toppt.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov dim}\\> - \\>       \\begin{minipg2}\n                                Dimension of the space in which the cone lies.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  \\begin{minipg2}\n                                Number of single intersection points.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov pointpar}\\> - \\>  \\begin{minipg2}\n                                Array containing the parameter values of the single\n                                intersection points in the parameter plane of the\n                                surface. The points lie in sequence. Intersection curves\n                                are stored in intcurves.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcr}\\> - \\>  \\begin{minipg2}\n                                Number of intersection curves.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov intcurves}\\> - \\> \\begin{minipg2}\n                                Array containing the description of the intersection\n                                curves. The curves are only described by\n                                start points and end points (guide points) in\n                                the parameter plane. The curve pointers point to\n                                nothing.\n                                \\end{minipg2}\\\\[0.3ex]\n%\\newpagetabs\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov toppt}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov axispt}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov conept}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov pointpar} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcr} = 0;\\\\\n                \\>\\>    SISLIntcurve\\>  **{\\fov intcurves} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1854(\\begin{minipg4}\n                {\\fov surf}, {\\fov toppt}, {\\fov axispt}, {\\fov conept}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov numintpt}, \\&{\\fov pointpar},\n                \\&numintcr, \\&intcurves, \\&stat);\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1855.tex",
    "content": "\\subsection{Intersection between a spline surface and a circle.}\n\\funclabel{s1855}\n\\begin{minipg1}\n  Find all intersections between a tensor-product surface and a full circle.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1855(\\begin{minipg3}\n                {\\fov surf}, {\\fov centre}, {\\fov radius}, {\\fov normal}, {\\fov dim}, {\\fov epsco}, {\\fov epsge},\n                {\\fov numintpt}, \\linebreak {\\fov pointpar}, {\\fov numintcr}, {\\fov intcurves}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov centre}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov radius};\\\\\n                \\>\\>    double  \\>      {\\fov normal}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov pointpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcr};\\\\\n                \\>\\>    SISLIntcurve\\>  ***{\\fov intcurves};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov centre}\\> - \\>    \\begin{minipg2}\n                                Centre of the circle.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov radius}\\> - \\>    \\begin{minipg2}\n                                Radius of the circle.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov normal}\\> - \\>    \\begin{minipg2}\n                                Normal vector to the plane in which the circle\n                                lies.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>\\begin{minipg2}\n                                Number of single intersection points.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov pointpar}\\> - \\>  \\begin{minipg2}\n                                Array containing the parameter values of the\n                                single intersection points in the parameter plane\n                                of the surface. The points lie in sequence.\n                                Intersection curves are stored in intcurves.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcr}\\> - \\>  \\begin{minipg2}\n                                Number of intersection curves.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov intcurves}\\> - \\> \\begin{minipg2}\n                                Array containing the description of the intersection\n                                curves. The curves are only described by\n                                start points and end points in\n                                the parameter plane. The curve pointers point to\n                                nothing.\n\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov centre}[3]; \\,/* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov radius}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov normal}[3]; \\,/* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov pointpar} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcr} = 0;\\\\\n                \\>\\>    SISLIntcurve\\>  **{\\fov intcurves} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1855(\\begin{minipg4}\n                {\\fov surf}, {\\fov centre}, {\\fov radius}, {\\fov normal}, {\\fov dim}, {\\fov epsco}, {\\fov epsge},\n                        \\&{\\fov numintpt}, \\&{\\fov pointpar}, \\&{\\fov numintcr}, \\&{\\fov intcurves}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1856.tex",
    "content": "\\subsection{Intersection between a spline surface and a straight line.}\n\\funclabel{s1856}\n\\begin{minipg1}\n  Find all intersections between a tensor-product surface and an infinite straight\n  line.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1856(\\begin{minipg3}\n                {\\fov surf}, {\\fov point}, {\\fov linedir}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov numintpt}, {\\fov pointpar},\n                \\linebreak {\\fov numintcr}, {\\fov intcurves}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov point}[\\,];\\\\\n                \\>\\>    double  \\>      {\\fov linedir}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov pointpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcr};\\\\\n                \\>\\>    SISLIntcurve\\>  ***{\\fov intcurves};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}     \\> - \\> \\begin{minipg2}\n                                Pointer to the surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov point}    \\> - \\> \\begin{minipg2}\n                                Point on the line.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov linedir}  \\> - \\> \\begin{minipg2}\n                                Direction vector of the line.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                Dimension of the space in which the line lies.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsco}    \\> - \\> \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt} \\> - \\> \\begin{minipg2}\n                                Number of single intersection points.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov pointpar} \\> - \\> \\begin{minipg2}\n                                Array containing the parameter values of the\n                                single intersection points in the parameter plane\n                                of the surface. The points lie in sequence.\n                                Intersection curves are stored in intcurves.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcr} \\> - \\> \\begin{minipg2}\n                                Number of intersection curves.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov intcurves}        \\> - \\> \\begin{minipg2}\n                                Array containing the description of the intersection\n                                curves. The curves are only described by\n                                start points and end points in\n                                the parameter plane. The curve pointers point to\n                                nothing.\n\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov point}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov linedir}[3]; \\,/* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} =1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov pointpar} =  NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcr} = 0;\\\\\n                \\>\\>    SISLIntcurve\\>  **{\\fov intcurves} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1856(\\begin{minipg4}\n                {\\fov surf}, {\\fov point}, {\\fov linedir}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov numintpt}, \\&{\\fov pointpar},\n                \\&{\\fov numintcr}, \\&{\\fov intcurves}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1857.tex",
    "content": "\\subsection{\\sloppy Intersection between two curves.}\n\\funclabel{s1857}\n\\begin{minipg1}\n  Find all the intersections between two curves.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1857(\\begin{minipg3}\n        {\\fov curve1}, {\\fov curve2}, {\\fov epsco}, {\\fov epsge}, {\\fov numintpt},\n        {\\fov intpar1}, {\\fov intpar2}, {\\fov \\\\numintcu}, {\\fov intcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve1};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve2};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov intpar1};\\\\\n                \\>\\>    double  \\>      **{\\fov intpar2};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcu};\\\\\n                \\>\\>    SISLIntcurve \\> ***{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve1}   \\> - \\> Pointer to the first curve.\\\\\n        \\>\\>    {\\fov curve2}   \\> - \\> Pointer to the second curve.\\\\\n        \\>\\>    {\\fov epsco}    \\> - \\> Computational resolution (not used).\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> Geometry resolution.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  Number of single intersection points.\\\\\n        \\>\\>    {\\fov intpar1}  \\> - \\> \\begin{minipg2}\n                        Array containing the parameter values of the\n                        single intersection points in the parameter\n                        interval of the first curve.\n                        Intersection curves are stored in intcurve.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov intpar2}  \\> - \\> \\begin{minipg2}\n                        Array containing the parameter values of the\n                        single intersection points in the parameter\n                        interval of the second curve.\n                        Intersection curves are stored in intcurve.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcu}\\> - \\>Number of intersection curves.\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                        Array of pointers to the SISLIntcurve objects\n                        containing descriptions of the intersection\n                        curves. The curves are only described by start\n                        points and end points in the parameter interval\n                        of the curve. The curve pointers point\n                        to nothing.\n                        If the curves given as input are\n                        degenerate, an intersection point can be returned as\n                        an intersection curve.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\ %\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve1}; \\, /* Must be defined */\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve2}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov intpar1} = NULL;\\\\\n                \\>\\>    double  \\>      *{\\fov intpar2} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcu} = 0;\\\\\n                \\>\\>    SISLIntcurve \\> **{\\fov intcurve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1857(\\begin{minipg4}\n                {\\fov curve1}, {\\fov curve2}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov numintpt},\n                \\&{\\fov intpar1}, \\&{\\fov intpar2}, \\&{\\fov numintcu}, \\&{\\fov intcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1858.tex",
    "content": "\\subsection{Intersection between a surface and a curve.}\n\\funclabel{s1858}\n\\begin{minipg1}\n  Find all intersections between a surface and a curve.\n  Intersection curves are described by guide points.\n  To pick the intersection curves use s1712() described on page \\pageref{s1712}.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1858(\\begin{minipg3}\n                {\\fov surf}, {\\fov curve}, {\\fov epsco}, {\\fov epsge}, {\\fov numintpt}, {\\fov pointpar1},\n                {\\fov pointpar2}, \\linebreak {\\fov numintcr},\n                {\\fov intcurves}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov pointpar1};\\\\\n                \\>\\>    double  \\>      **{\\fov pointpar2};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcr};\\\\\n                \\>\\>    SISLIntcurve\\>  ***{\\fov intcurves};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov curve}\\> - \\>     \\begin{minipg2}\n                                Pointer to the curve.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2} \\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  \\begin{minipg2}\n                                Number of single intersection points.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov pointpar1}\\> - \\>\\begin{minipg2}\n                                Array containing the parameter values of the\n                                single intersection points in the parameter\n                                plane of the surface. The points lie\n                                in sequence. Intersection curves are stored in\n                                intcurves.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov pointpar2}\\> - \\>\\begin{minipg2}\n                                Array containing the parameter values of the\n                                single intersection points in the parameter\n                                interval of the curve.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcr}\\> - \\>  \\begin{minipg2}\n                                Number of intersection curves.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov intcurves}\\> - \\>\\begin{minipg2}\n                                Array containing the description of the intersection\n                                curves. The curves are only described by\n                                start points and end points (guide points) in\n                                the parameter plane.\n\n                         The curve pointers point to\n                                nothing.\n                                If the curves given as input are\n                                degenerate, an intersection point can be returned\n                                as an intersection curve.\n                                \\end{minipg2}\\\\[0.8ex]\n\\newpagetabs\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\,/* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov pointpar1} = NULL;\\\\\n                \\>\\>    double  \\>      *{\\fov pointpar2} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcr} = 0;\\\\\n                \\>\\>    SISLIntcurve\\>  **{\\fov intcurves} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1858(\\begin{minipg4}\n                {\\fov surf}, {\\fov curve}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov numintpt}, \\&{\\fov pointpar1}, \\&{\\fov pointpar2}, \\&{\\fov numintcr},\n                \\&{\\fov intcurves}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1859.tex",
    "content": "\\subsection{Find the topology for the intersection between two spline surfaces.}\n\\funclabel{s1859}\n\\begin{minipg1}\n  Find all intersections between two surfaces.\n  Intersection curves are described by guide points.\n  To produce the intersection curves use s1310() described on page \\pageref{s1310}.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1859    (\\begin{minipg3}\n                {\\fov surfl}, {\\fov surf2}, {\\fov epsco}, {\\fov epsge}, {\\fov numintpt},\n                {\\fov pointpar1}, {\\fov pointpar2}, \\linebreak {\\fov numintcr}, {\\fov intcurves},\n                {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf1};\\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf2};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov pointpar1};\\\\\n                \\>\\>    double  \\>      **{\\fov pointpar2};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcr};\\\\\n                \\>\\>    SISLIntcurve\\>  ***{\\fov intcurves};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf1}\\> - \\>     \\begin{minipg2}\n                                Pointer to the first surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov surf2}\\> - \\>     \\begin{minipg2}\n                                Pointer to the second surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2} \\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  \\begin{minipg2}\n                                Number of single intersection points.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov pointpar1}\\> - \\>\\begin{minipg2}\n                                Array containing the parameter values of the single\n                                intersection points in the parameter plane of the\n                                first surface. The points lie in sequence. Intersection\n                                curves are stored in intcurves.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov pointpar2}\\> - \\>\\begin{minipg2}\n                                Array containing the parameter values of the single\n                                intersection points in the parameter plane of the\n                                second surface.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcr}\\> - \\>  \\begin{minipg2}\n                                Number of intersection curves.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov intcurves}\\> - \\>\\begin{minipg2}\n                                Array containing description of the intersection\n                                curves. The curves are only described\n                                by start points and end points (guide\n                                points) in\n                                the parameter planes of the surfaces.\n                                The curve pointers point to\n                                nothing.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf1}; \\, /* Must be defined */\\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf2}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov pointpar1} = NULL;\\\\\n                \\>\\>    double  \\>      *{\\fov pointpar2} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcr} = 0;\\\\\n                \\>\\>    SISLIntcurve\\>  **{\\fov intcurves} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1859(\\begin{minipg4}\n                {\\fov surfl}, {\\fov surf2}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov numintpt},\n                \\&{\\fov pointpar1}, \\&{\\fov pointpar2}, \\&{\\fov numintcr}, \\&{\\fov intcurves},\n                \\&{\\fov stat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1860.tex",
    "content": "\\subsection{Find the topology of the silhouette curves of a spline surface,\nusing parallel projection.}\n\\funclabel{s1860}\n\\begin{minipg1}\n  Find the silhouette curves and points of a surface when the surface is viewed\n  from a specific direction (i.e.\\ parallel projection).\n  In addition to the points and curves found by this routine, break\n  curves and edge-curves might be silhouette curves.\n  Silhouette curves are described by guide points.\n  To produce the silhouette curves use s1319() described on page \\pageref{s1319}.\n\\end{minipg1} \\\\ \\\\\nNOTE\\\\\n\\>     \\begin{minipg6}\nThe silhouette curves are defined as curves on the surface where the inner product of the surface normal and the direction vector of the viewing is 0. This definition will include surface points where the normal is zero.\n\\end{minipg6}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1860(\\begin{minipg3}\n                {\\fov surf}, {\\fov viewdir}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov numsilpt}, {\\fov pointpar}, {\\fov numsilcr}, {\\fov silcurves},\n                {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov viewdir}[];\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numsilpt};\\\\\n                \\>\\>    double  \\>      **{\\fov pointpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numsilcr};\\\\\n                \\>\\>    SISLIntcurve\\>  ***{\\fov silcurves};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>              \\begin{minipg2}\n                                Pointer to the surface.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov viewdir}\\> - \\>   \\begin{minipg2}\n                                The direction vector of the viewing.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}\\> - \\>       \\begin{minipg2}\n                                Dimension of the space in which {\\fov viewdir} lies.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numsilpt}\\> - \\>  \\begin{minipg2}\n                                Number of single silhouette points.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov pointpar}\\> - \\>  \\begin{minipg2}\n                                Array containing the parameter values of the\n                                single silhouette points in the parameter plane of\n                                the surface. The points lie in sequence. Silhouette\n                                curves are stored in silcurves.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numsilcr}\\> - \\>  \\begin{minipg2}\n                                Number of silhouette curves.\n                                \\end{minipg2}\\\\\n%\\newpagetabs\n        \\>\\>    {\\fov silcurves}\\> - \\>\\begin{minipg2}\n                                Array containing the description of the silhouette\n                                curves. The curves are only described by\n                                start points and end points (guide points) in\n                                the parameter plane. The curve pointers point to\n                                nothing.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov viewdir}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numsilpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov pointpar} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numsilcr} = 0;\\\\\n                \\>\\>    SISLIntcurve\\>  **{\\fov silcurves} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1860(\\begin{minipg4}\n                {\\fov surf}, {\\fov viewdir}, {\\fov dim}, {\\fov epsco}, {\\fov epsge},\n                \\&{\\fov numsilpt}, \\&{\\fov pointpar}, \\linebreak \\&{\\fov numsilcr}, \\&{\\fov silcurves},\n                \\&{\\fov stat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1870.tex",
    "content": "\\subsection{Intersection between a surface and a point.}\n\\funclabel{s1870}\n\\begin{minipg1}\n  Find all intersections between a spline surface and a point.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1870(\\begin{minipg3}\n        {\\fov ps1}, {\\fov pt1}, {\\fov idim}, {\\fov aepsge}, {\\fov jpt}, {\\fov gpar1}, {\\fov jcrv}, {\\fov wcurve}, {\\fov jstat})\n      \\end{minipg3}\\\\[0.3ex]\n      \\>\\>    SISLSurf    \\>  *{\\fov ps1};\\\\\n      \\>\\>    double      \\>  {\\fov pt1}[\\,];\\\\\n      \\>\\>    int         \\>  {\\fov idim};\\\\\n      \\>\\>    double      \\>  {\\fov aepsge};\\\\\n      \\>\\>    int         \\>  *{\\fov jpt};\\\\\n      \\>\\>    double      \\>  **{\\fov gpar1};\\\\\n      \\>\\>    int         \\>  *{\\fov jcrv};\\\\\n      \\>\\>    SISLIntcurve\\>  ***{\\fov wcurve};\\\\\n      \\>\\>    int         \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov ps1}    \\> - \\> Pointer to the surface.\\\\\n        \\>\\>    {\\fov pt1}    \\> - \\> Coordinates of the point.\\\\\n        \\>\\>    {\\fov idim}   \\> - \\> Number of coordinates in pt1.\\\\\n        \\>\\>    {\\fov aepsge} \\> - \\> Geometry resolution.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov jpt}    \\> - \\> Number of single intersection points.\\\\\n        \\>\\>    {\\fov gpar1}  \\> - \\> \\begin{minipg2}\n                                        Array containing the parameter values of the\n                                        single intersection points in the parameter\n                                        interval of the surface. The points lie\n                                        continuous. Intersection curves\n                                        are stored in wcurve.\n                                      \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jcrv}   \\> - \\> Number of intersection curves.\\\\\n        \\>\\>    {\\fov wcurve} \\> - \\> \\begin{minipg2}\n                                        Array containing descriptions of\n                                        the intersection curves. The\n                                        curves are only described by\n                                        points in the parameter\n                                        plane. The curve-pointers points\n                                        to nothing.\\\\\n                                        If the curves given as input are\n                                        degnenerate an intersection\n                                        point can be returned as an\n                                        intersection curve. Use s1327 to\n                                        decide if an intersection curve\n                                        is a point on one of the\n                                        curves.\n                                      \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : Warning.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Ok.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf    \\>  *{\\fov ps1}; \\, /* Must be defined */\\\\\n        \\>\\>    double      \\>  {\\fov pt1}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    int         \\>  {\\fov idim} = 3;\\\\\n        \\>\\>    double      \\>  {\\fov aepsge} = 1.0e-6;\\\\\n        \\>\\>    int         \\>  {\\fov jpt} = 0;\\\\\n        \\>\\>    double      \\>  *{\\fov gpar1} = NULL;\\\\\n        \\>\\>    int         \\>  {\\fov jcrv} = 0;\\\\\n        \\>\\>    SISLIntcurve\\>  **{\\fov wcurve} = NULL;\\\\\n        \\>\\>    int         \\>  {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1870(\\begin{minipg4}\n        {\\fov ps1}, {\\fov pt1}, {\\fov idim}, {\\fov aepsge}, \\&{\\fov jpt}, \\&{\\fov gpar1}, \\&{\\fov jcrv}, \\&{\\fov wcurve}, \\&{\\fov jstat});\n      \\end{minipg4}\\\\\n      \\>\\>    \\ldots \\\\\n      \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1871.tex",
    "content": "\\subsection{Intersection between a curve and a point.}\n\\funclabel{s1871}\n\\begin{minipg1}\n  Find all the intersections between a curve and a point.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1871(\\begin{minipg3}\n        {\\fov pc1}, {\\fov pt1}, {\\fov idim}, {\\fov aepsge}, {\\fov jpt}, {\\fov gpar1}, {\\fov jcrv},\n        {\\fov wcurve}, {\\fov jstat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve \\>  *{\\fov pc1};\\\\\n                \\>\\>    double    \\>  *{\\fov pt1};\\\\\n                \\>\\>    int       \\>  {\\fov idim};\\\\\n                \\>\\>    double    \\>  {\\fov aepsge};\\\\\n                \\>\\>    int       \\>  *{\\fov jpt};\\\\\n                \\>\\>    double    \\>  **{\\fov gpar1};\\\\\n                \\>\\>    int       \\>  *{\\fov jcrv};\\\\\n                \\>\\>    SISLIntcurve \\> ***{\\fov wcurve};\\\\\n                \\>\\>    int       \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov pc1}    \\> - \\> Pointer to the curve.\\\\\n        \\>\\>    {\\fov pt1}    \\> - \\> coordinates of the point.\\\\\n        \\>\\>    {\\fov idim}   \\> - \\> number of coordinates in {\\fov pt1}.\\\\\n        \\>\\>    {\\fov aepsge} \\> - \\> Geometry resolution.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov jpt}    \\> - \\> Number of single intersection points.\\\\\n        \\>\\>    {\\fov gpar1}  \\> - \\> \\begin{minipg2}\n                                        Array containing the parameter\n                                        values of the single\n                                        intersection points in the\n                                        parameter interval of the\n                                        curve. The points lie\n                                        continuous. Intersection curves\n                                        are stored in {\\fov wcurve}.\n                                      \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jcrv}   \\> - \\> Number of intersection curves.\\\\\n        \\>\\>    {\\fov wcurve} \\> - \\> \\begin{minipg2}\n                                        Array containing descriptions of\n                                        the intersection curves. The\n                                        curves are only described by\n                                        points in the parameter\n                                        plane. The curve-pointers points\n                                        to nothing.\\\\\n                                        If the curves given as input are\n                                        degenerate, an intersection\n                                        point can be returned as an\n                                        intersection curve. Use s1327() to\n                                        decide if an intersection curve\n                                        is a point on one of the\n                                        curves.\n                                      \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat}  \\> - \\> \\begin{minipg2}\n                                        Status messages\\\\\n                                        $> 0$      : Warning.\\\\\n                                        $= 0$      : Ok.\\\\\n                                        $< 0$      : Error.\\\\\n                                      \\end{minipg2}\\\\[0.8ex]\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve \\>  *{\\fov pc1}; \\,/* Must be defined */\\\\\n        \\>\\>    double    \\>  *{\\fov pt1}; \\,/* Must be defined */\\\\\n        \\>\\>    int       \\>  {\\fov idim}; \\, /* Equal to the curve dimension */ \\\\\n        \\>\\>    double    \\>  {\\fov aepsge} = 0.000001 ;\\\\\n        \\>\\>    int       \\>  {\\fov jpt} = 0;\\\\\n        \\>\\>    double    \\>  *{\\fov gpar1} = NULL;\\\\\n        \\>\\>    int       \\>  {\\fov jcrv} = 0;\\\\\n        \\>\\>    SISLIntcurve \\> **{\\fov wcurve} = NULL;\\\\\n        \\>\\>    int       \\>  {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1871(\\begin{minipg4}\n        {\\fov pc1}, {\\fov pt1}, {\\fov idim}, {\\fov aepsge}, \\&{\\fov jpt}, \\&{\\fov gpar1}, \\&{\\fov jcrv}, \\&{\\fov wcurve}, \\&{\\fov jstat});\n      \\end{minipg4}\\\\\n      \\>\\>    \\ldots \\\\\n      \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1920.tex",
    "content": "\\section{Find the Absolute Extremals of a Curve.}\n\\funclabel{s1920}\n\\begin{minipg1}\n  Find the absolute extremal points/intervals of a curve relative to a\n  given direction.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1920(\\begin{minipg3}\n        {\\fov curve}, {\\fov dir}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov numintpt},\n        {\\fov intpar},\\\\ {\\fov numintcu}, {\\fov intcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov dir}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov intpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcu};\\\\\n                \\>\\>    SISLIntcurve \\> ***{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> Pointer to the curve.\\\\\n        \\>\\>    {\\fov dir}      \\> - \\> \\begin{minipg2}\n                                The direction in which the extremal point(s)\n                                and/or interval(s) are to be\n                                calculated. If $dim=1$, a positive value\n                                indicates the maximum of the\n                                function and a negative value the minimum.\n                                If the dimension is greater than 1, the array\n                                contains the coordinates of the direction vector.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                Dimension of the space in which the\n                                curve and {\\fov dir} lie.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov epsco}    \\> - \\> Computational resolution (not used).\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> Geometry resolution.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  Number of single extremal points.\\\\\n        \\>\\>    {\\fov intpar}   \\> - \\> \\begin{minipg2}\n                                Array containing the parameter values of the\n                                single extremal points in the parameter\n                                interval of the curve. The points lie in sequence.\n                                Extremal curves are stored in intcurve.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcu}\\> - \\>  Number of extremal curves.\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                                Array of pointers to the SISLIntcurve objects\n                                containing descriptions of the extremal\n                                curves. The curves are only described by\n                                start points and end points in\n                                the parameter interval of the curve. The\n                                curve pointers point to nothing.\n                                \\end{minipg2}\\\\[0.3ex]\n\\newpagetabs\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : Warning.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Ok.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve}; \\,/* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov dir}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov intpar} =  NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcu} = 0;\\\\\n                \\>\\>    SISLIntcurve \\> **{\\fov intcurve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1920(\\begin{minipg4}\n                {\\fov curve}, {\\fov dir}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov numintpt},\n                \\&{\\fov intpar}, \\&{\\fov numintcu}, \\&{\\fov intcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1921.tex",
    "content": "\\section{Find the Absolute Extremals of a Surface.}\n\\funclabel{s1921}\n\\begin{minipg1}\n  Find the absolute extremal points/curves of a surface along a given direction.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1921(\\begin{minipg3}\n          {\\fov ps1}, {\\fov edir}, {\\fov idim}, {\\fov aepsco}, {\\fov aepsge}, {\\fov jpt}, {\\fov gpar}, {\\fov jcrv}, {\\fov wcurve}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf  \\>  *{\\fov ps1};\\\\\n        \\>\\>    double    \\>  {\\fov edir}[\\,];\\\\\n        \\>\\>    int       \\>  {\\fov idim};\\\\\n        \\>\\>    double    \\>  {\\fov aepsco};\\\\\n        \\>\\>    double    \\>  {\\fov aepsge};\\\\\n        \\>\\>    int       \\>  *{\\fov jpt};\\\\\n        \\>\\>    double    \\>  **{\\fov gpar};\\\\\n        \\>\\>    int       \\>  *{\\fov jcrv};\\\\\n        \\>\\>    SISLIntcurve \\> ***{\\fov wcurve};\\\\\n        \\>\\>    int       \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov ps1}\\> - \\>  \\begin{minipg2}\n                     Pointer to the surface.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov edir}\\> - \\>\n        \\begin{minipg2}\n          The direction in which the extremal point(s)\n          and/or interval(s) are to be calculated. If\n          $idim=1$ a positive value indicates the maximum\n          of the function and a negative value\n          the minimum. If the dimension is greater that\n          1 the array contains the coordinates of the\n          direction vector.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov idim}\\> - \\>  \\begin{minipg2}\n                     Dimension of the space in which the vector {\\fov edir}\n                       lies.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov aepsco}\\> - \\>  \\begin{minipg2}\n                     Computational resolution (not used).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov aepsge}\\> - \\>  \\begin{minipg2}\n                     Geometry resolution.\n                               \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov jpt}\\> - \\>  \\begin{minipg2}\n                     Number of single extremal points.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov gpar}\\> - \\>\n        \\begin{minipg2}\n          Array containing the parameter values of the\n          single extremal points in the parameter\n          area of the surface. The points lie continuous.\n          Extremal curves are stored in {\\fov wcurve}.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jcrv}\\> - \\>  \\begin{minipg2}\n                     Number of extremal curves.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov wcurve}\\> - \\>\n        \\begin{minipg2}\n          Array containing descriptions of the extremal\n          curves. The curves are only described by points\n          in the parameter area. The curve-pointers point\n          to nothing.\n        \\end{minipg2}\\\\[0.8ex]\n\\newpagetabs\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>              $> 0$ \\> : Warning.\\\\\n                \\>\\>\\>\\>              $= 0$ \\> : Ok.\\\\\n                \\>\\>\\>\\>              $< 0$ \\> : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf  \\>  *{\\fov ps1}; \\, /* Must be defined */\\\\\n        \\>\\>    double    \\>  {\\fov edir}[3];\\ \\, /* Must be defined */\\\\\n        \\>\\>    int       \\>  {\\fov idim} = 3;\\\\\n        \\>\\>    double    \\>  {\\fov aepsco} = 1.0e-9; /* Not used */\\\\\n        \\>\\>    double    \\>  {\\fov aepsge} = 1.0e-6;\\\\\n        \\>\\>    int       \\>  {\\fov jpt} = 0;\\\\\n        \\>\\>    double    \\>  *{\\fov gpar} = NULL;\\\\\n        \\>\\>    int       \\>  {\\fov jcrv} = 0;\\\\\n        \\>\\>    SISLIntcurve \\> **{\\fov wcurve} = NULL;\\\\\n        \\>\\>    int       \\>  {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1921(\\begin{minipg4}\n          {\\fov ps1}, {\\fov edir}, {\\fov idim}, {\\fov aepsco}, {\\fov aepsge}, \\&{\\fov jpt}, \\&{\\fov gpar}, \\&{\\fov jcrv}, \\&{\\fov wcurve}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1940.tex",
    "content": "\\subsection{Data reduction: B-spline curve as input.}\n\\funclabel{s1940}\n\\begin{minipg1}\nTo remove as many knots as possible from a spline curve\n \t   without perturbing the curve more than a given\n \t   tolerance.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1940(\\begin{minipg3}\n            {\\fov oldcurve},  {\\fov eps},  {\\fov startfix},  {\\fov endfix},  {\\fov iopen},  {\\fov itmax},  {\\fov newcurve},\n       {\\fov maxerr},  {\\fov stat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLCurve \\> *{\\fov oldcurve};\\\\\n                \\>\\>    double \\> {\\fov eps}[\\,];\\\\\n                \\>\\>    int \\> {\\fov startfix};\\\\\n                \\>\\>    int \\> {\\fov endfix};\\\\\n                \\>\\>    int \\> {\\fov iopen};\\\\\n                \\>\\>    int \\> {\\fov itmax};\\\\\n                \\>\\>    SISLCurve \\> **{\\fov newcurve};\\\\\n                \\>\\>    double \\> {\\fov maxerr}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov oldcurve}\\> - \\>  \\begin{minipg2}\n                     pointer to the original spline curve. \n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov eps}\\> - \\>  \\begin{minipg2}\n                     double array giving the desired absolute accuracy\n                        of the final approximation as compared to oldcurve.\n                        If oldcurve is a spline curve in a space of\n\t\t\t dimension dim, then eps must have length dim.\n                        Note that it is not relative, but absolute accuracy\n                        that is being used. This means that the difference\n                        in component i at any parameter value, between\n                        the given curve and the approximation, is to be\n                        less than eps[i]. Note that in such comparisons\n                        the same parametrization is used for both curves.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov startfix}\\> - \\>  \\begin{minipg2}\n                     the number of derivatives to be kept fixed at\n\t\t\t the beginning of the knot interval.\n                     The $0,\\ldots,(startfix-1)$ derivatives will be kept fixed.\n                        If startfix $<0$, this routine will set it to 0.\n                        If startfix $<$ the order of the curve, this routine\n                        will set it to the order.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov endfix}\\> - \\>  \\begin{minipg2}\n                     the number of derivatives to be kept fixed at\n\t\t         the end of the knot interval.\n                     The $0,\\ldots,(endfix-1)$ derivatives will be kept fixed.\n                        If endfix $<0$, this routine will set it to 0.\n                        If endfix $<$ the order of the curve, this routine\n                        will set it to the order.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov iopen}\\> - \\>  Open/closed parameter\\\\\n            \\>\\>\\>\\>  $= 1$  : Produce open curve.\\\\\n            \\>\\>\\>\\>  $= 0$ : Produce closed, non-periodic curve if possible.\\\\\n            \\>\\>\\>\\>  $= -1$ : Produce closed, periodic curve if possible.\\\\\n        \\>\\>    {\\fov itmax}\\> - \\>  \\begin{minipg2}\n                     maximum number of iterations. The routine will\n                        follow an iterative procedure trying to remove\n                        more and more knots. The process will almost always\n                        stop after less than 10 iterations and it will often\n                        stop after less than 5 iterations. A suitable\n                        value for itmax is therefore usually in the region\n                        3-10.\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov }\\> - \\>  \\begin{minipg2}\n        \n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov newcurve}\\> - \\>  \\begin{minipg2}\n                     the spline approximation on the reduced\n                        knot vector.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov maxerr}\\> - \\>  \\begin{minipg2}\n                     double array containing an upper bound for the\n\t\t\t pointwise error in each of the components of the\n\t\t         spline approximation. The two curves oldcurve and\n\t\t\t newcurve are compared at the same parameter value,\n                        i.e., if oldcurve is f and newcurve is g, then\n\t\t\t               $|f(t)-g(t)| <= eps$\n\t\t\t in each of the components.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : Warning.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Ok.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLCurve \\> *{\\fov oldcurve}; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> {\\fov eps}[3]; /* Spatial dimension.  Must be defined */\\\\\n                \\>\\>    int \\> {\\fov startfix} = 1;\\\\\n                \\>\\>    int \\> {\\fov endfix} = 1;\\\\\n                \\>\\>    int \\> {\\fov iopen} = 1;\\\\\n                \\>\\>    int \\> {\\fov itmax} = 8;\\\\\n                \\>\\>    SISLCurve \\> *{\\fov newcurve} = NULL;\\\\\n                \\>\\>    double \\> {\\fov maxerr}[3]; /* Spatial dimension */\\\\\n                \\>\\>    int \\> {\\fov stat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1940(\\begin{minipg4}\n            {\\fov oldcurve},  {\\fov eps},  {\\fov startfix},  {\\fov endfix},  {\\fov iopen},  {\\fov itmax},  \\&{\\fov newcurve},\n       {\\fov maxerr},  \\&{\\fov stat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1953.tex",
    "content": "\\subsection{Find the closest point between a curve and a point.}\n\\funclabel{s1953}\n\\begin{minipg1}\n  Find the closest points between a curve and a point.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1953(\\begin{minipg3}\n        {\\fov curve}, {\\fov point}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov numintpt},\n        {\\fov intpar},\\linebreak {\\fov numintcu}, {\\fov intcurve}, {\\fov jstat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve};\\\\\n                \\>\\>    double  \\>      {\\fov point}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov intpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcu};\\\\\n                \\>\\>    SISLIntcurve \\> ***{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}    \\> - \\> \\begin{minipg2}\n                                Pointer to the curve in the closest point problem.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov point}    \\> - \\> \\begin{minipg2}\n                                The point in the closest point problem.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}      \\> - \\> \\begin{minipg2}\n                                Dimension of the space in which the\n                                curve and point lie.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epsco}    \\> - \\> Computational resolution (not used).\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> Geometry resolution.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  Number of single closest points.\\\\\n        \\>\\>    {\\fov intpar}   \\> - \\> \\begin{minipg2}\n                                Array containing the parameter values of the\n                                single closest points in the parameter\n                                interval of the curve. The points lie in sequence.\n                                Closest curves are stored in intcurve.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcu}\\> - \\>  Number of closest curves.\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                                Array of pointers to the SISLIntcurve objects\n                                containing descriptions of the closest\n                                curves. The curves are only described by\n                                start points and end points in\n                                the parameter interval of the curve. The\n                                curve pointers point to nothing.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve \\> *{\\fov curve}; \\, /* Must be defined */\\\\\n        \\>\\>    double  \\>   {\\fov point}[3]; \\,/* Must be defined */\\\\\n        \\>\\>    int     \\>   {\\fov dim} = 3;\\\\\n        \\>\\>    double  \\>   {\\fov epsco} = 1.9e-9; /* Not used */\\\\\n        \\>\\>    double  \\>   {\\fov epsge} = 1.0e-6;\\\\\n        \\>\\>    int     \\>   {\\fov numintpt} = 0;\\\\\n        \\>\\>    double  \\>   *{\\fov intpar} = NULLL;\\\\\n        \\>\\>    int     \\>   {\\fov numintcu} = 0;\\\\\n        \\>\\>    SISLIntcurve \\> **{\\fov intcurve} = NULL;\\\\\n        \\>\\>    int     \\>   {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1953(\\begin{minipg4}\n          {\\fov curve}, {\\fov point}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov numintpt},\n          \\&{\\fov intpar},\\linebreak \\&{\\fov numintcu}, \\&{\\fov intcurve}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1954.tex",
    "content": "\\subsection{Find the closest point between a surface and a point.}\n\\funclabel{s1954}\n\\begin{minipg1}\n  Find the points on a surface lying closest to a given point.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1954(\\begin{minipg3}\n                        {\\fov surf}, {\\fov point}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, {\\fov numclopt}, {\\fov pointpar},\n                        {\\fov numclocr}, {\\fov clocurves}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLSurf        \\>      *{\\fov surf};\\\\\n                \\>\\>    double  \\>      {\\fov point}[\\,];\\\\\n                \\>\\>    int     \\>      {\\fov dim};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numclopt};\\\\\n                \\>\\>    double  \\>      **{\\fov pointpar};\\\\\n                \\>\\>    int     \\>      *{\\fov numclocr};\\\\\n                \\>\\>    SISLIntcurve\\>  ***{\\fov clocurves};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>      \\begin{minipg2}\n                                Pointer to the surface in the closest point\n                                problem.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov point}\\> - \\>     \\begin{minipg2}\n                                The point in the closest point problem.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov dim}\\> - \\>       \\begin{minipg2}\n                                Dimension of the space in which the point lies.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsco}\\> - \\>     \\begin{minipg2}\n                                Computational resolution (not used).\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov epsge}\\> - \\>     \\begin{minipg2}\n                                Geometry resolution.\n                                \\end{minipg2}\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numclopt}\\> - \\>  \\begin{minipg2}\n                                Number of single closest points.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov pointpar}\\> - \\>  \\begin{minipg2}\n                                Array containing the parameter values of the\n                                single closest points in the parameter area of\n                                the surface. The points lie in sequence. Closest\n                                curves are stored in clocurves.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numclocr}\\> - \\>  \\begin{minipg2}\n                                Number of closest curves.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov clocurves}\\> - \\> \\begin{minipg2}\n                                Array containing the description of the closest\n                                curves. The curves are only described by points\n                                in the parameter area. The curve pointers\n                                point to nothing.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLSurf        \\>      *{\\fov surf} \\, /* Must be defined */;\\\\\n                \\>\\>    double  \\>      {\\fov point}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    int     \\>      {\\fov dim} = 3;\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */ \\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numclopt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov pointpar} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numclocr} = 0;\\\\\n                \\>\\>    SISLIntcurve\\>  **{\\fov clocurves} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1954(\\begin{minipg4}\n                {\\fov surf}, {\\fov point}, {\\fov dim}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov numclopt}, \\&{\\fov pointpar},\n        \\&{\\fov numclocr}, \\&{\\fov clocurves}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1955.tex",
    "content": "\\subsection{Find the closest points between two curves.}\n\\funclabel{s1955}\n\\begin{minipg1}\n  Find the closest points between two curves.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1955(\\begin{minipg3}\n        {\\fov curve1}, {\\fov curve2}, {\\fov epsco}, {\\fov epsge}, {\\fov numintpt},\n        {\\fov intpar1}, {\\fov intpar2},\\\\ {\\fov numintcu}, {\\fov intcurve}, {\\fov stat})\n                \\end{minipg3}\\\\[0.3ex]\n                \\>\\>    SISLCurve       \\>      *{\\fov curve1};\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve2};\\\\\n                \\>\\>    double  \\>      {\\fov epsco};\\\\\n                \\>\\>    double  \\>      {\\fov epsge};\\\\\n                \\>\\>    int     \\>      *{\\fov numintpt};\\\\\n                \\>\\>    double  \\>      **{\\fov intpar1};\\\\\n                \\>\\>    double  \\>      **{\\fov intpar2};\\\\\n                \\>\\>    int     \\>      *{\\fov numintcu};\\\\\n                \\>\\>    SISLIntcurve \\> ***{\\fov intcurve};\\\\\n                \\>\\>    int     \\>      *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve1}   \\> - \\> \\begin{minipg2}\n                                Pointer to the first curve in the closest point\n                                        problem.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov curve2}   \\> - \\> \\begin{minipg2}\n                                Pointer to the second curve in the closest point\n                                        problem.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epsco}    \\> - \\> Computational resolution (not used).\\\\\n        \\>\\>    {\\fov epsge}    \\> - \\> Geometry resolution.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov numintpt}\\> - \\>  Number of single closest points.\\\\\n        \\>\\>    {\\fov intpar1}  \\> - \\> \\begin{minipg2}\n                        Array containing the parameter values of the\n                        single closest points in the parameter\n                        interval of the first curve. The points lie in sequence.\n                        Closest curves are stored in intcurve.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov intpar2}  \\> - \\> \\begin{minipg2}\n                        Array containing the parameter values of the\n                        single closest points in the parameter\n                        interval of the second curve. The points lie in sequence.\n                        Closest curves are stored in intcurve.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov numintcu}\\> - \\>Number of closest curves.\\\\\n        \\>\\>    {\\fov intcurve}\\> - \\>  \\begin{minipg2}\n                        Array of pointers to the SISLIntcurve objects\n                        containing descriptions of the closest\n                        curves. The curves are only described by\n                        start points and end points in\n                        the parameter interval of the curve. The curve\n                        pointers point to nothing.\n                        If the curves given as input are\n                        degenerate, a closest point may be returned as\n                        a closest curve.\n                                \\end{minipg2}\\\\[0.8ex]\n\\newpagetabs\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : warning\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : ok\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : error\\\\\nEXAMPLE OF USE\\\\\n                \\>      \\{ \\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve1}; \\, /* Must be defined */\\\\\n                \\>\\>    SISLCurve       \\>      *{\\fov curve2}; \\, /* Must be defined */\\\\\n                \\>\\>    double  \\>      {\\fov epsco} = 1.0e-9; /* Not used */\\\\\n                \\>\\>    double  \\>      {\\fov epsge} = 1.0e-6;\\\\\n                \\>\\>    int     \\>      {\\fov numintpt} = 0;\\\\\n                \\>\\>    double  \\>      *{\\fov intpar1} = NULL;\\\\\n                \\>\\>    double  \\>      *{\\fov intpar2} =  NULL;\\\\\n                \\>\\>    int     \\>      {\\fov numintcu} = 0;\\\\\n                \\>\\>    SISLIntcurve \\> **{\\fov intcurve} = NULL;\\\\\n                \\>\\>    int     \\>      {\\fov stat} = 0;\\\\\n                \\>\\>    \\ldots \\\\\n        \\>\\>s1955(\\begin{minipg4}\n                {\\fov curve1}, {\\fov curve2}, {\\fov epsco}, {\\fov epsge}, \\&{\\fov numintpt},\n                \\&{\\fov intpar1}, \\&{\\fov intpar2}, \\&{\\fov numintcu}, \\&{\\fov intcurve}, \\&{\\fov stat});\n                        \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n                \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1957.tex",
    "content": "\\subsection{Find the closest point between a curve and a point. Simple version.}\n\\funclabel{s1957}\n\\begin{minipg1}\n  Find the closest point between a curve and a point.\n  The method is fast and should work well in clear cut cases but does not\n  guarantee finding the right solution. As long as it doesn't fail, it\n  will find exactly one point.  In other cases, use s1953().\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1957(\\begin{minipg3}\n          {\\fov pcurve}, {\\fov epoint}, {\\fov idim}, {\\fov aepsco}, {\\fov aepsge}, {\\fov gpar}, {\\fov dist}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLCurve \\>  *{\\fov pcurve};\\\\\n        \\>\\>    double    \\>  {\\fov epoint}[\\,];\\\\\n        \\>\\>    int       \\>  {\\fov idim};\\\\\n        \\>\\>    double    \\>  {\\fov aepsco};\\\\\n        \\>\\>    double    \\>  {\\fov aepsge};\\\\\n        \\>\\>    double    \\>  *{\\fov gpar};\\\\\n        \\>\\>    double    \\>  *{\\fov dist};\\\\\n        \\>\\>    int       \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov pcurve} \\> - \\>\n        \\begin{minipg2}\n          Pointer to the curve in the closest point problem.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epoint} \\> - \\> The point in the closest point problem.\\\\\n        \\>\\>    {\\fov idim}   \\> - \\> Dimension of the space in which\n                                      {\\fov epoint} lies.\\\\\n        \\>\\>    {\\fov aepsco} \\> - \\> Computational resolution (not used).\\\\\n        \\>\\>    {\\fov aepsge} \\> - \\> Geometry resolution.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov gpar}  \\> - \\>\n        \\begin{minipg2}\n          The parameter value of the closest point in the parameter\n          interval of the curve.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov dist}  \\> - \\> The closest distance between curve and point.\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Point found by iteration.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n                \\>\\>\\>\\>\\> $= 1$ : Point lies at an end.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve \\>  *{\\fov pcurve}; \\, /* Must be defined */\\\\\n        \\>\\>    double    \\>  {\\fov epoint}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    int       \\>  {\\fov idim} = 3;\\\\\n        \\>\\>    double    \\>  {\\fov aepsco} = 1.0e-9;  /* Not used */\\\\\n        \\>\\>    double    \\>  {\\fov aepsge} = 1.0e-6;\\\\\n        \\>\\>    double    \\>  {\\fov gpar} = 0;\\\\\n        \\>\\>    double    \\>  {\\fov dist} = 0;\\\\\n        \\>\\>    int       \\>  {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1957(\\begin{minipg4}\n          {\\fov pcurve}, {\\fov epoint}, {\\fov idim}, {\\fov aepsco}, {\\fov aepsge}, \\&{\\fov gpar}, \\&{\\fov dist}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1958.tex",
    "content": "\\subsection{Find the closest point between a surface and a point.\nSimple version.}\n\\funclabel{s1958}\n\\begin{minipg1}\n  Find the closest point between a surface and a point.\n  The method is fast and should work well in clear cut cases, but there is\n  no guarantee it will find the right solution. As long as it doesn't\n  fail, it will find exactly one point.  In other cases, use s1954() on\n  page~\\pageref{s1954}.\n\\end{minipg1}\\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1958(\\begin{minipg3}\n          {\\fov psurf}, {\\fov epoint}, {\\fov idim}, {\\fov aepsco}, {\\fov aepsge}, {\\fov gpar}, {\\fov dist}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf \\> *{\\fov psurf};\\\\\n        \\>\\>    double   \\> {\\fov epoint}[\\,];\\\\\n        \\>\\>    int      \\> {\\fov idim};\\\\\n        \\>\\>    double   \\> {\\fov aepsco};\\\\\n        \\>\\>    double   \\> {\\fov aepsge};\\\\\n        \\>\\>    double   \\> {\\fov gpar}[\\,];\\\\\n        \\>\\>    double   \\> *{\\fov dist};\\\\\n        \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov psurf}\\> - \\>  \\begin{minipg2}\n                     Pointer to the surface in the closest point problem.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov epoint}\\> - \\>  \\begin{minipg2}\n                     The point in the closest point problem.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov idim}\\> - \\>  \\begin{minipg2}\n                     Dimension of the space in which epoint lies.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov aepsco}\\> - \\>  \\begin{minipg2}\n                     Computational resolution (not used).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov aepsge}\\> - \\>  \\begin{minipg2}\n                     Geometry resolution.\n                               \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov gpar}\\> - \\>  \\begin{minipg2}\n                     2D array containing the parameter values of the\n                       closest point in the parameter space\n                       of the surface.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov dist}\\> - \\>  \\begin{minipg2}\n                     The closest distance between point and the surface.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>              $> 2$ \\> : Warning.\\\\\n                \\>\\>\\>\\>              $= 2$ \\> : Solution at a corner.\\\\\n                \\>\\>\\>\\>              $= 1$ \\> : Solution at an edge.\\\\\n                \\>\\>\\>\\>              $= 0$ \\> : Solution in interior.\\\\\n                \\>\\>\\>\\>              $< 0$ \\> : Error.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf  \\>  *{\\fov psurf}; \\, /* Must be defined */\\\\\n        \\>\\>    double    \\>  {\\fov epoint}[3]; \\, /* Must be defined */\\\\\n        \\>\\>    int       \\>  {\\fov idim} = 3;\\\\\n        \\>\\>    double    \\>  {\\fov aepsco} = 1.0e-9; /* Not used */\\\\\n        \\>\\>    double    \\>  {\\fov aepsge} = 1.0e-6;\\\\\n        \\>\\>    double    \\>  {\\fov gpar}[2];\\\\\n        \\>\\>    double    \\>  {\\fov dist} = 0.0;\\\\\n        \\>\\>    int       \\>  {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1958(\\begin{minipg4}\n          {\\fov psurf}, {\\fov epoint}, {\\fov idim}, {\\fov aepsco}, {\\fov aepsge}, {\\fov gpar}, \\&{\\fov dist}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1961.tex",
    "content": "\\subsection{Data reduction: Point data as input.}\n\\funclabel{s1961}\n\\begin{minipg1}\nTo compute a spline-approximation to the data given by the\n           points ep, and represent it as a B-spline curve with\n           parameterization determined by the parameter ipar.\n           The approximation is determined by first forming the piecewise\n           linear interpolant to the data, and then performing knot\n           removal on this initial approximation.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1961(\\begin{minipg3}\n            {\\fov ep}, {\\fov im}, {\\fov idim}, {\\fov ipar}, {\\fov epar}, {\\fov eeps}, {\\fov ilend}, {\\fov irend}, {\\fov iopen}, {\\fov afctol},\n            {\\fov itmax}, {\\fov ik}, {\\fov rc}, {\\fov emxerr}, {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    double \\> {\\fov ep}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov im};\\\\\n                \\>\\>    int    \\>  {\\fov idim};\\\\\n                \\>\\>    int    \\>  {\\fov ipar};\\\\\n                \\>\\>    double \\> {\\fov epar}[\\,];\\\\\n                \\>\\>    double \\> {\\fov eeps}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov ilend};\\\\\n                \\>\\>    int    \\>  {\\fov irend};\\\\\n                \\>\\>    int    \\>  {\\fov iopen};\\\\\n                \\>\\>    double \\> {\\fov afctol};\\\\\n                \\>\\>    int    \\>  {\\fov itmax};\\\\\n                \\>\\>    int    \\>  {\\fov ik};\\\\\n                \\>\\>    SISLCurve    \\>  **{\\fov rc};\\\\\n                \\>\\>    double \\> {\\fov emxerr}[\\,];\\\\\n                \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov ep}\\> - \\>  \\begin{minipg2}\n                     Array (length $idim*im$) containing the points to\n                 be approximated.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov im}\\> - \\>  \\begin{minipg2}\n                     The no. of data points.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov idim}\\> - \\>  \\begin{minipg2}\n                     The dimension of the euclidean space in which the data\n                 points lie, i.e. the number of components of each data point.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov ipar}\\> - \\> \\begin{minipg2}\n                     Flag indicating the type of parameterization to be used:\n                               \\end{minipg2}\\\\[0.8ex]\n                \\>\\>\\>\\>   $= 1$ : Paramterize by accumulated cord length.\\\\\n                \\>\\>\\>\\>         (Arc length parametrization for the piecewise\\\\\n                \\>\\>\\>\\>         linear interpolant.)\\\\\n                \\>\\>\\>\\>   $= 2$ : Uniform parameterization.\\\\\n                \\>\\>\\>\\>   $= 3$ : Parametrization given by epar.\\\\\n                \\>\\>\\>\\>  If ipar $<1$  or ipar $>3$, it will be set to 1.\\\\\n        \\>\\>    {\\fov epar}\\> - \\>  \\begin{minipg2}\n                     Array (length im) containing a parametrization\n                 of the given data.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov eeps}\\> - \\>  \\begin{minipg2}\n                     Array (length idim) containing the tolerance to be\n                 used during the data reduction stage. The final\n                 approximation to the data will deviate less than eeps\n                 from the piecewise linear interpolant in each of the\n                 idim components.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ilend}\\> - \\>  \\begin{minipg2}\n                     The no. of derivatives that are not allowed to change\n                 at the left end of the curve.\n                 The $0,\\ldots,(ilend-1)$ derivatives will be kept fixed.\n                 If ilend $<0$, this routine will set it to 0.\n                 If ilend $<ik$, this routine will set it to ik.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov irend}\\> - \\>  \\begin{minipg2}\n                     The no. of derivatives that are not allowed to change\n                 at the right end of the curve.\n                 The $0,\\ldots,(irend-1)$ derivatives will be kept fixed.\n                 If irend $<0$, this routine will set it to 0.\n                 If irend $<ik$, this routine will set it to ik.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov iopen}\\> - \\>  Open/closed parameter\\\\\n            \\>\\>\\>\\>  $= 1$  : Produce open curve.\\\\\n            \\>\\>\\>\\>  $= 0$ : Produce closed, non-periodic curve if possible.\\\\\n            \\>\\>\\>\\>  $= -1$ : Produce closed, periodic curve if possible.\\\\\n                 \\>\\>\\>\\>  \\begin{minipg2}\n                 If a closed or periodic curve is to be produced and the\n                 start- and endpoint is more distant than the length of\n                 the tolerance, a new point is added. Note that if the\n                 parametrization is given as input, the parametrization\n                 if the last point will be arbitrary.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov afctol}\\> - \\>  \\begin{minipg2}\n                 Number indicating how the tolerance is to be shared\n                 between the two data reduction stages. For the linear\n                 reduction, a tolerance of $afctol*eeps$ will be used,\n                 while a tolerance of $(1-afctol)*eeps$ will be used\n                 during the final data reduction. (Similarly for edgeps.)\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov itmax}\\> - \\>  \\begin{minipg2}\n                    Max. no. of iterations in the data-reduction routine.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov ik}\\> - \\>  \\begin{minipg2}\n                     The polynomial order of the approximation.\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov rc}\\> - \\>  \\begin{minipg2}\n                     Pointer to curve.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov emxerr}\\> - \\>  \\begin{minipg2}\n                     Array (length idim) (allocated outside this routine.)\n                 containing for each component an upper bound on the\n                 max. deviation of the final approximation from the\n                 initial piecewise linear interpolant.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : Warning.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Ok.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    double \\> {\\fov ep}[300]; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov im} = 100;\\\\\n                \\>\\>    int    \\>  {\\fov idim} = 3;\\\\\n                \\>\\>    int    \\>  {\\fov ipar} = 1;\\\\\n                \\>\\>    double \\> {\\fov epar}[100]; /* Used if ipar = 3 */\\\\\n                \\>\\>    double \\> {\\fov eeps}[3]; \\, /* Spatial dimension. Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov ilend} = 0;\\\\\n                \\>\\>    int    \\>  {\\fov irend} = 0;\\\\\n                \\>\\>    int    \\>  {\\fov iopen} = 1;\\\\\n                \\>\\>    double \\> {\\fov afctol} = 0.5;\\\\\n                \\>\\>    int    \\>  {\\fov itmax} = 6;\\\\\n                \\>\\>    int    \\>  {\\fov ik} = 4;\\\\\n                \\>\\>    SISLCurve    \\>  *{\\fov rc} = NULL;\\\\\n                \\>\\>    double \\> {\\fov emxerr}[3];  \\,/* Spatial dimension */\\\\\n                \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1961(\\begin{minipg4}\n            {\\fov ep}, {\\fov im}, {\\fov idim}, {\\fov ipar}, {\\fov epar}, {\\fov eeps}, {\\fov ilend}, {\\fov irend}, {\\fov iopen}, {\\fov afctol},\n            {\\fov itmax}, {\\fov ik}, \\&{\\fov rc}, {\\fov emxerr}, \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1962.tex",
    "content": "\\subsection{Data reduction: Points and tangents as input.}\n\\funclabel{s1962}\n\\begin{minipg1}\nTo compute the approximation to the data given by the points\n           ep and the derivatives (tangents) ev, and represent it as a\n           B-spline curve with parametrization determined by the parameter\n           ipar. The approximation is determined by first forming the cubic\n           hermite interpolant to the data, and then performing knot\n           removal on this initial approximation.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1962(\\begin{minipg3}\n            {\\fov ep}, {\\fov ev}, {\\fov im}, {\\fov idim}, {\\fov ipar}, {\\fov epar}, {\\fov eeps}, {\\fov ilend}, {\\fov irend}, {\\fov iopen}, {\\fov itmax},\n            {\\fov rc}, {\\fov emxerr}, {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    double \\> {\\fov ep}[\\,];\\\\\n                \\>\\>    double \\> {\\fov ev}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov im};\\\\\n                \\>\\>    int    \\>  {\\fov idim};\\\\\n                \\>\\>    int    \\>  {\\fov ipar};\\\\\n                \\>\\>    double \\> {\\fov epar}[\\,];\\\\\n                \\>\\>    double \\> {\\fov eeps}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov ilend};\\\\\n                \\>\\>    int    \\>  {\\fov irend};\\\\\n                \\>\\>    int    \\>  {\\fov iopen};\\\\\n                \\>\\>    int    \\>  {\\fov itmax};\\\\\n                \\>\\>    SISLCurve    \\>  **{\\fov rc};\\\\\n                \\>\\>    double \\> {\\fov emxerr}[\\,];\\\\\n                \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov ep}\\> - \\>  \\begin{minipg2}\n                     Array (length idim*im) comtaining the points\n                  to be approximated.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ev}\\> - \\>  \\begin{minipg2}\n                     Array (length idim*im) containing the derivatives\n                  of the points to be approximated.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov im}\\> - \\>  \\begin{minipg2}\n                     The no. of data points.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov idim}\\> - \\>  \\begin{minipg2}\n                     The dimension of the euclidean space in which the\n                  curve lies.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ipar}\\> - \\> \\begin{minipg2}\n                     Flag indicating the type of parameterization to be used:\n                               \\end{minipg2}\\\\[0.8ex]\n                \\>\\>\\>\\>   $= 1$ : Paramterize by accumulated cord length.\\\\\n                \\>\\>\\>\\>         (Arc length parametrization for the piecewise\\\\\n                \\>\\>\\>\\>         linear interpolant.)\\\\\n                \\>\\>\\>\\>   $= 2$ : Uniform parameterization.\\\\\n                \\>\\>\\>\\>   $= 3$ : Parametrization given by epar.\\\\\n                \\>\\>\\>\\>  If ipar $<1$  or ipar $>3$, it will be set to 1.\\\\\n        \\>\\>    {\\fov epar}\\> - \\>  \\begin{minipg2}\n                     Array (length im) containing a parameterization\n                  of the given data.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov eeps}\\> - \\>  \\begin{minipg2}\n                     Array (length idim) giving the desired accuracy of\n                  the spline-approximation in each component.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ilend}\\> - \\>  \\begin{minipg2}\n                     The no. of derivatives that are not allowed to change\n                 at the left end of the curve.\n                 The $0,\\ldots,(ilend-1)$ derivatives will be kept fixed.\n                 If ilend $<0$, this routine will set it to 0.\n                 If ilend $<ik$, this routine will set it to ik.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov irend}\\> - \\>  \\begin{minipg2}\n                     The no. of derivatives that are not allowed to change\n                 at the right end of the curve.\n                 The $0,\\ldots,(irend-1)$ derivatives will be kept fixed.\n                 If irend $<0$, this routine will set it to 0.\n                 If irend $<ik$, this routine will set it to ik.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov iopen}\\> - \\>  Open/closed parameter\\\\\n            \\>\\>\\>\\>  $= 1$  : Produce open curve.\\\\\n            \\>\\>\\>\\>  $= 0$ : Produce closed, non-periodic curve if possible.\\\\\n            \\>\\>\\>\\>  $= -1$ : Produce closed, periodic curve if possible.\\\\\n                 \\>\\>\\>\\>  \\begin{minipg2}\n                 If a closed or periodic curve is to be produced and the\n                 start- and endpoint is more distant than the length of\n                 the tolerance, a new point is added. Note that if the\n                 parametrization is given as input, the parametrization\n                 if the last point will be arbitrary.\n                                \\end{minipg2}\\\\\n        \\>\\>    {\\fov itmax}\\> - \\>  \\begin{minipg2}\n                     Max. no. of iteration.\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov rc}\\> - \\>  \\begin{minipg2}\n                     Pointer to curve.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov emxerr}\\> - \\>  \\begin{minipg2}\n                     Array (length idim) (allocated outside this routine.)\n                  containing an upper bound for the pointwise error\n                  in each of the components of the spline-approximation.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : Warning.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Ok.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    double \\> {\\fov ep}[120]; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> {\\fov ev}[120]; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov im} = 40;\\\\\n                \\>\\>    int    \\>  {\\fov idim} = 3;\\\\\n                \\>\\>    int    \\>  {\\fov ipar} = 3;\\\\\n                \\>\\>    double \\> {\\fov epar}[40]; \\, /* Must be defined. Used only if ipar = 3 */\\\\\n                \\>\\>    double \\> {\\fov eeps}[3]; \\, /* Spatial dimension. Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov ilend} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov irend} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov iopen} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov itmax} = 8;\\\\\n                \\>\\>    SISLCurve    \\>  *{\\fov rc} = NULL;\\\\\n                \\>\\>    double \\> {\\fov emxerr}[3]; \\, /* Spatial dimension */\\\\\n                \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1962(\\begin{minipg4}\n            {\\fov ep}, {\\fov ev}, {\\fov im}, {\\fov idim}, {\\fov ipar}, {\\fov epar}, {\\fov eeps}, {\\fov ilend}, {\\fov irend}, {\\fov iopen}, {\\fov itmax},\n            \\&{\\fov rc}, {\\fov emxerr}, \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1963.tex",
    "content": "\\subsection{Degree reduction: B-spline curve as input.}\n\\funclabel{s1963}\n\\begin{minipg1}\nTo approximate the input spline curve by a cubic spline\n           curve with error less than eeps in each of the kdim components.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1963(\\begin{minipg3}\n            {\\fov pc}, {\\fov eeps}, {\\fov ilend}, {\\fov irend}, {\\fov iopen}, {\\fov itmax}, {\\fov rc}, {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLCurve    \\>  *{\\fov pc};\\\\\n                \\>\\>    double \\> {\\fov eeps}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov ilend};\\\\\n                \\>\\>    int    \\>  {\\fov irend};\\\\\n                \\>\\>    int    \\>  {\\fov iopen};\\\\\n                \\>\\>    int    \\>  {\\fov itmax};\\\\\n                \\>\\>    SISLCurve    \\>  **{\\fov rc};\\\\\n                \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov pc}\\> - \\>  \\begin{minipg2}\n                     Pointer to curve.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov eeps}\\> - \\>  \\begin{minipg2}\n                     Array (length kdim) giving the desired accuracy of\n                  the spline-approximation in each component.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ilend}\\> - \\>  \\begin{minipg2}\n                     The no. of derivatives that are not allowed to change\n                 at the left end of the curve.\n                 The $0,\\ldots,(ilend-1)$ derivatives will be kept fixed.\n                 If ilend $<0$, this routine will set it to 0.\n                 If ilend $<ik$, this routine will set it to ik.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov irend}\\> - \\>  \\begin{minipg2}\n                     The no. of derivatives that are not allowed to change\n                 at the right end of the curve.\n                 The $0,\\ldots,(irend-1)$ derivatives will be kept fixed.\n                 If irend $<0$, this routine will set it to 0.\n                 If irend $<ik$, this routine will set it to ik.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov iopen}\\> - \\>  Open/closed parameter\\\\\n            \\>\\>\\>\\>  $= 1$  : Produce open curve.\\\\\n            \\>\\>\\>\\>  $= 0$ : Produce closed, non-periodic curve if possible.\\\\\n            \\>\\>\\>\\>  $= -1$ : Produce closed, periodic curve if possible.\\\\\n        \\>\\>    {\\fov itmax}\\> - \\>  \\begin{minipg2}\n                     Max. no. of iterations.\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov rc}\\> - \\>  \\begin{minipg2}\n                     Pointer to curve.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : Warning.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Ok.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLCurve    \\>  *{\\fov pc}; \\, /* Must be defined */\\\\\n                \\>\\>    double \\> {\\fov eeps}[3]; \\, /* Spatial dimension. Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov ilend} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov irend} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov iopen} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov itmax} = 8;\\\\\n                \\>\\>    SISLCurve    \\>  *{\\fov rc} = NULL;\\\\\n                \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1963(\\begin{minipg4}\n            {\\fov pc}, {\\fov eeps}, {\\fov ilend}, {\\fov irend}, {\\fov iopen}, {\\fov itmax}, \\&{\\fov rc}, \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1965.tex",
    "content": "\\subsection{Data reduction: B-spline surface as input.}\n\\funclabel{s1965}\n\\begin{minipg1}\nTo remove as many knots as possible from a spline surface\n           without perturbing the surface more than the given tolerance.\n           The error in continuity over the start and end of\n           a closed or periodic surface is only guaranteed to be within\n           edgeps.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1965(\\begin{minipg3}\n            {\\fov oldsurf},  {\\fov eps},  {\\fov edgefix},  {\\fov iopen1},  {\\fov iopen2},  {\\fov edgeps},  {\\fov opt}, \n\t     {\\fov itmax},  {\\fov newsurf}, {\\fov maxerr},  {\\fov stat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf \\> \t*{\\fov oldsurf};\\\\\n                \\>\\>    double\t\\> {\\fov eps}[\\,];\\\\\n                \\>\\>    int\t\\> {\\fov edgefix}[{\\fov 4}];\\\\\n                \\>\\>    int    \\>  {\\fov iopen1};\\\\\n                \\>\\>    int    \\>  {\\fov iopen2};\\\\\n                \\>\\>    double\t\\> {\\fov edgeps}[\\,];\\\\\n                \\>\\>    int \t\\> {\\fov opt};\\\\\n                \\>\\>    int\t\\> {\\fov itmax};\\\\\n                \\>\\>    SISLSurf\\> \t**{\\fov newsurf};\\\\\n                \\>\\>    double\t\\> {\\fov maxerr}[\\,];\\\\\n                \\>\\>    int\t\\> *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov oldsurf}\\> - \\>  \\begin{minipg2}\n                     pointer to the original spline surface. Note\n\t\t\t if the polynomial orders of the surface are\n\t\t\t k1 and k2, then the two knot vectors are\n\t\t\t assumed to have knots of multiplicity k1 and\n\t\t\t k2 at the ends.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov eps}\\> - \\>  \\begin{minipg2}\n                     double array of length dim (the number of\n\t\t\t components of the surface, typically three)\n\t\t\t giving the desired accuracy of the\n\t\t\t final approximation compared to oldcurve.\n                        Note that in such comparisons the two\n\t\t\t surfaces are not reparametrized in any way.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov edgefix}\\> - \\>  \\begin{minipg2}\n                     integer array of dimension (4) giving the number\n\t\t\t of derivatives to be kept fixed along each edge\n\t\t\t of the surface. The numbering of the edges is the\n\t\t\t same as for edgeps below. All the derivatives of\n\t\t\t order $< nend(i)-1$ will be kept fixed along\n\t\t\t edge $i$. Hence $nend(i)=0$ indicates that nothing is\n\t\t\t to be kept fixed along edge $i$.\n                NB! TO BE KEPT FIXED HERE MEANS TO HAVE ERROR LESS THAN\n\t\t     EDGEPS. IN GENERAL, IT IS IMPOSSIBLE TO REMOVE KNOTS\n                    AND KEEP AN EDGE COMPLETELY FIXED.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>   {\\fov iopen1}\\> - \\> Open/closed parameter in first direction.\\\\\n          \\>\\>\\>\\>  $= 1$  : Produce open surface.\\\\\n          \\>\\>\\>\\>  $= 0$ : Produce closed, non-periodic surface if possible.\\\\\n          \\>\\>\\>\\>  $= -1$ : Produce closed, periodic surface\\\\\n        \\>\\>   {\\fov iopen2}\\> - \\> Open/closed parameter in second direction.\\\\\n          \\>\\>\\>\\>  $= 1$  : Produce open surface.\\\\\n          \\>\\>\\>\\>  $= 0$ : Produce closed, non-periodic surface if possible.\\\\\n          \\>\\>\\>\\>  $= -1$ : Produce closed, periodic surface\\\\\n        \\>\\>    {\\fov edgeps}\\> - \\>  \\begin{minipg2}\n                     double array of length 4*dim ([4,dim]) (dim is\n                        the number of components of each coefficient)\n\t\t\t containing the maximum deviation which is\n\t\t\t acceptable along the edges of the surface.\n                         $edgeps[0]-edgeps[dim-1]$ gives the tolerance along\n\t\t\t the edge corresponding to x1 (the first parameter)\n \t\t\t having it's minimum value.\n\t\t\t $edgeps[dim]-edgeps[2*dim-1]$ gives the tolerance\n\t\t\t along the edge corresponding to x1 (the first\n\t\t\t parameter) having it's maximum value.\n              \t\t $edgeps[2*dim]-edgeps[3*dim-1]$ gives the tolerance\n\t\t\t along the edge corresponding to x2 (the second\n\t\t\t parameter) having it's minimum value.\n              \t\t $edgeps[3*dim]-edgeps[4*dim-1]$ gives the tolerance\n\t\t\t along the edge corresponding to x2 (the second\n\t\t\t parameter) having its maximum value.\n           \t NB! EDGEPS WILL ONLY HAVE ANY SIGNIFICANCE IF THE\n\t\t     CORRESPONDING ELEMENT OF EDGEFIX IS POSITIVE.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov itmax}\\> - \\>  \\begin{minipg2}\n                     maximum number of iterations. The routine will\n                        follow an iterative procedure trying to remove\n                        more and more knots, one direction at a time.\n                        The process will almost always stop after less\n                        than 10 iterations and it will often stop after\n                        less than 5 iterations. A suitable value for itmax\n                        is therefore usually in the region 3-10.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov opt}\\> - \\>  \\begin{minipg2}\n                     integer indicating the order in which the\n\t       \t         knot removal is to be performed.\n                               \\end{minipg2}\\\\[0.8ex]\n          \\>\\>\\>\\>  1 : remove knots in parameter 1 only.\\\\\n          \\>\\>\\>\\>  2 : remove knots in parameter 2 only.\\\\\n          \\>\\>\\>\\>  3 : remove knots first in parameter 1 and then 2.\\\\\n          \\>\\>\\>\\>  4 : remove knots first in parameter 2 and then 1.\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov newsurf}\\> - \\>  \\begin{minipg2}\n                     the approximating surface on the reduced knot vectors.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov maxerr}\\> - \\>  \\begin{minipg2}\n                     double array of length dim containing an upper\n\t\t         bound for the pointwise error in each of the\n\t\t         components of the spline approximation. The two\n                        surfaces oldsurf and newsurf are compared at the\n                        same parameter vaues, i.e., if oldsurf is f and\n                        newsurf is g then\n                              $|f(u,v)-g(u,v)| <= eps$\n                        in each of the components.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : Warning.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Ok.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLSurf \\> \t*{\\fov oldsurf}; \\, /* Must be defined */\\\\\n                \\>\\>    double\t\\> {\\fov eps}[3]; \\, /* Spatial dimension. Must be defined */\\\\\n                \\>\\>    int\t\\> {\\fov edgefix}[{\\fov 4}]; \\, /* Must be defined */\\\\\\\n                \\>\\>    int    \\>  {\\fov iopen1} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov iopen2} = 1;\\\\\n                \\>\\>    double\t\\> {\\fov edgeps}[12]; \\, /* Spatial dimension times number of edges. \\\\\n                \\>\\>\\>\\>\\>\\> Must be defined */\\\\\n                \\>\\>    int \t\\> {\\fov opt} = 3;\\\\\n                \\>\\>    int\t\\> {\\fov itmax} = 8;\\\\\n                \\>\\>    SISLSurf\t\\> *{\\fov newsurf} = NULL;\\\\\n                \\>\\>    double\t\\> {\\fov maxerr}[3]; \\, /* Spatial dimension */ \\\\\n                \\>\\>    int\t\\> {\\fov stat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1965(\\begin{minipg4}\n            {\\fov oldsurf},  {\\fov eps},  {\\fov edgefix},  {\\fov iopen1},  {\\fov iopen2},  {\\fov edgeps},  {\\fov opt}, \n\t     {\\fov itmax},  \\&{\\fov newsurf}, {\\fov maxerr},  \\&{\\fov stat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1966.tex",
    "content": "\\subsection{Data reduction: Point data as input.}\n\\funclabel{s1966}\n\\begin{minipg1}\nTo compute a tensor-product spline-approximation of order\n           (ik1,ik2) to the rectangular array of idim-dimensional\n           points given by ep.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1966(\\begin{minipg3}\n            {\\fov ep}, {\\fov im1}, {\\fov im2}, {\\fov idim}, {\\fov ipar}, {\\fov epar1}, {\\fov epar2}, {\\fov eeps}, {\\fov nend}, {\\fov iopen1}, {\\fov iopen2},\n            {\\fov edgeps}, {\\fov afctol}, {\\fov iopt}, {\\fov itmax}, {\\fov ik1}, {\\fov ik2},\n            {\\fov rs}, {\\fov emxerr}, {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    double \\> {\\fov ep}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov im1};\\\\\n                \\>\\>    int    \\>  {\\fov im2};\\\\\n                \\>\\>    int    \\>  {\\fov idim};\\\\\n                \\>\\>    int    \\>  {\\fov ipar};\\\\\n                \\>\\>    double \\> {\\fov epar1}[\\,];\\\\\n                \\>\\>    double \\> {\\fov epar2}[\\,];\\\\\n                \\>\\>    double \\> {\\fov eeps}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov nend}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov iopen1};\\\\\n                \\>\\>    int    \\>  {\\fov iopen2};\\\\\n                \\>\\>    double \\> {\\fov edgeps}[\\,];\\\\\n                \\>\\>    double \\> {\\fov afctol};\\\\\n                \\>\\>    int    \\>  {\\fov iopt};\\\\\n                \\>\\>    int    \\>  {\\fov itmax};\\\\\n                \\>\\>    int    \\>  {\\fov ik1};\\\\\n                \\>\\>    int    \\>  {\\fov ik2};\\\\\n                \\>\\>    SISLSurf    \\>  **{\\fov rs};\\\\\n                \\>\\>    double \\> {\\fov emxerr}[\\,];\\\\\n                \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov ep}\\> - \\>  \\begin{minipg2}\n                     Array (length idim*im1*im2) containing the points\n                  to be approximated.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov im1}\\> - \\>  \\begin{minipg2}\n                    The no. of points in the first parameter.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov im2}\\> - \\>  \\begin{minipg2}\n                    The no. of points in the second parameter.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov idim}\\> - \\>  \\begin{minipg2}\n                    The no. of components of each input point.\n                  The approximation will be a parametric surface\n                  situated in idim-dimensional Euclidean space\n                  (usually 3).\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ipar}\\> - \\>  \\begin{minipg2}\n                     Flag determining the parametrization of the data points:\n                               \\end{minipg2}\\\\[0.8ex]\n          \\>\\>\\>\\>  $= 1$  : Mean accumulated cord-length parameterization.\\\\\n          \\>\\>\\>\\>  $= 2$  : Uniform parametrization.\\\\\n          \\>\\>\\>\\>  $= 3$  : Parametrization given by epar1 and epar2.\\\\\n        \\>\\>    {\\fov epar1}\\> - \\>  \\begin{minipg2}\n                     Array (length im1) containing a parametrization\n                  in the first parameter. (Will only\n                  be used if $ipar=3$).\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epar2}\\> - \\>  \\begin{minipg2}\n                     Array (length im2) containing a parametrization\n                  in the second parameter. (Will only\n                  be used if $ipar=3$).\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov eeps}\\> - \\>  \\begin{minipg2}\n                     Array (length idim) containing the max. permissible\n                  deviation of the approximation from the given data\n                  points, in each of the components. More specifically,\n                  the approximation will not deviate more than eeps(kdim)\n                  in component no. kdim, from the bilinear approximation\n                  to the data.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov nend}\\> - \\>  \\begin{minipg2}\n                     Array (length 4) giving the no. of derivatives to be\n                  kept fixed along each edge of the bilinear interpolant.\n                  The numbering of the edges is the same as for edgeps below.\n                  All the derivatives of order $< (nend(i)-1)$ will be kept\n                  fixed along the edge $i$. Hence $nend(i)=0$ indicates that\n                  nothing is to be kept fixed along edge $i$.\n                  To be kept fixed here means to have error less than edgeps.\n                  In general, it is impossible to remove any knots and keep\n                  an edge completely fixed.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>   {\\fov iopen1}\\> - \\> Open/closed parameter in first direction.\\\\\n          \\>\\>\\>\\>  $= 1$  : Produce open surface.\\\\\n          \\>\\>\\>\\>  $= 0$ : Produce closed, non-periodic surface if possible.\\\\\n          \\>\\>\\>\\>  $= -1$ : Produce closed, periodic surface\\\\\n        \\>\\>\\>\\>  \\begin{minipg2}\n                  NB! The surface will be closed/periodic only if the first \n                      and last column of data points are (approximately) equal.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>   {\\fov iopen2}\\> - \\> Open/closed parameter in second direction.\\\\\n          \\>\\>\\>\\>  $= 1$  : Produce open surface.\\\\\n          \\>\\>\\>\\>  $= 0$ : Produce closed, non-periodic surface if possible.\\\\\n          \\>\\>\\>\\>  $= -1$ : Produce closed, periodic surface\\\\\n        \\>\\>\\>\\>  \\begin{minipg2}\n                  NB! The surface will be closed/periodic only if the first \n                      and last row of data points are (approximately) equal.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov edgeps}\\> - \\>  \\begin{minipg2}\n                     Array (length idim*4) containing the max. deviation from\n                  the bilinear interpolant which is acceptable along the\n                  edges of the surface.\n                  edgeps(1,i):edgeps(idim,i) gives the tolerance along\n                  the edge corresponding to the i-th parameter having\n                  one of it`s extremal-values.\n                     \\end{minipg2}\\\\[0.8ex]\n          \\>\\>\\>\\> $i=1$: min value of first parameter.\\\\ \n          \\>\\>\\>\\> $i=2$: max value of first parameter.\\\\\n          \\>\\>\\>\\> $i=3$: min value of second parameter.\\\\\n          \\>\\>\\>\\> $i=4$: max value of second parameter.\\\\\n          \\>\\>\\>\\>  \\begin{minipg2}\n                  edgeps(kp,i) will only have significance if $nend(i)>0$.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov afctol}\\> - \\>  \\begin{minipg2}\n                     $0.0 >= afctol <= 1.0$.\n                  Afctol indicates how the tolerance is to be shared\n                  between the two data-reduction stages. For the linear\n                  reduction, a tolerance of $afctol*eeps$ will be used,\n                  while a tolerance of $(1.0-afctol)*eeps$ will be used\n                  during the final data reduction (similarly for edgeps.)\n                  Default is 0.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov iopt}\\> - \\>  \\begin{minipg2}\n                  Flag indicating the order in which the data-reduction\n                  is to be performed:\n                               \\end{minipg2}\\\\[0.8ex]\n          \\>\\>\\>\\> $=1$: Remove knots in parameter 1 only.\\\\\n          \\>\\>\\>\\> $=2$: Remove knots in parameter 2 only.\\\\\n          \\>\\>\\>\\> $=3$: Remove knots first in parameter 1 and then in 2.\\\\\n          \\>\\>\\>\\> $=4$: Remove knots first in parameter 2 and then in 1.\\\\\n        \\>\\>    {\\fov itmax}\\> - \\>  \\begin{minipg2}\n                    Max. no. of iterations in the data-reduction..\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ik1}\\> - \\>  \\begin{minipg2}\n                     The order of the approximation in the first\n                  parameter.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ik2}\\> - \\>  \\begin{minipg2}\n                     The order of the approximation in the second\n                  parameter.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov rs}\\> - \\>  \\begin{minipg2}\n                     Pointer to surface.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov emxerr}\\> - \\>  \\begin{minipg2}\n                     Array (length idim) (allocated outside this routine.)\n                  containing the error in the approximation to the data.\n                  This is a guaranteed upper bound on the max. deviation\n                  in each component, between the final approximation\n                  and the bilinear spline- pproximation to the original data.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : Warning.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Ok.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    double \\> {\\fov ep}[7500]; \\, /* Spatial dimension times number of points. Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov im1} = 50;\\\\\n                \\>\\>    int    \\>  {\\fov im2} = 50;\\\\\n                \\>\\>    int    \\>  {\\fov idim} = 3;\\\\\n                \\>\\>    int    \\>  {\\fov ipar} = 1;\\\\\n                \\>\\>    double \\> {\\fov epar1}[50]; /* Used if ipar = 3 */\\\\\n                \\>\\>    double \\> {\\fov epar2}[50]; /* Used if ipar = 3 */\\\\\n                \\>\\>    double \\> {\\fov eeps}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov nend}[4]; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov iopen1} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov iopen2} = 1;\\\\\n                \\>\\>    double \\> {\\fov edgeps}[12]; /* Spatial dimension times number of edges. \\\\\n                \\>\\>\\>\\>\\>\\> Must be defined */\\\\\n                \\>\\>    double \\> {\\fov afctol} = 0.5;\\\\\n                \\>\\>    int    \\>  {\\fov iopt} = 4;\\\\\n                \\>\\>    int    \\>  {\\fov itmax} = 8;\\\\\n                \\>\\>    int    \\>  {\\fov ik1} = 4;\\\\\n                \\>\\>    int    \\>  {\\fov ik2} = 4;\\\\\n                \\>\\>    SISLSurf    \\>  *{\\fov rs} = NULL;\\\\\n                \\>\\>    double \\> {\\fov emxerr}[3]; /* Spatial dimension */\\\\\n                \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1966(\\begin{minipg4}\n            {\\fov ep}, {\\fov im1}, {\\fov im2}, {\\fov idim}, {\\fov ipar}, {\\fov epar1}, {\\fov epar2}, {\\fov eeps}, {\\fov nend}, {\\fov iopen1}, {\\fov iopen2},\n            {\\fov edgeps}, {\\fov afctol}, {\\fov iopt}, {\\fov itmax}, {\\fov ik1}, {\\fov ik2},\n            \\&{\\fov rs}, {\\fov emxerr}, \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1967.tex",
    "content": "\\subsection{Data reduction: Points and tangents as input.}\n\\funclabel{s1967}\n\\begin{minipg1}\nTo compute a bicubic hermite spline-approximation to the\n           position and derivative data given by ep,etang1,etang2\n           and eder11.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1967(\\begin{minipg3}\n            {\\fov ep}, {\\fov etang1}, {\\fov etang2}, {\\fov eder11}, {\\fov im1}, {\\fov im2}, {\\fov idim}, {\\fov ipar}, {\\fov epar1}, {\\fov epar2},\n\t    {\\fov eeps}, {\\fov nend}, {\\fov iopen1}, {\\fov iopen2}, {\\fov edgeps}, {\\fov iopt}, {\\fov itmax}, {\\fov rs}, {\\fov emxerr}, {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    double \\> {\\fov ep}[\\,];\\\\\n                \\>\\>    double \\> {\\fov etang1}[\\,];\\\\\n                \\>\\>    double \\> {\\fov etang2}[\\,];\\\\\n                \\>\\>    double \\> {\\fov eder11}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov im1};\\\\\n                \\>\\>    int    \\>  {\\fov im2};\\\\\n                \\>\\>    int    \\>  {\\fov idim};\\\\\n                \\>\\>    int    \\>  {\\fov ipar};\\\\\n                \\>\\>    double \\> {\\fov epar1}[\\,];\\\\\n                \\>\\>    double \\> {\\fov epar2}[\\,];\\\\\n                \\>\\>    double \\> {\\fov eeps}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov nend}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov iopen1};\\\\\n                \\>\\>    int    \\>  {\\fov iopen2};\\\\\n                \\>\\>    double \\> {\\fov edgeps}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov iopt};\\\\\n                \\>\\>    int    \\>  {\\fov itmax};\\\\\n                \\>\\>    SISLSurf    \\>  **{\\fov rs};\\\\\n                \\>\\>    double \\> {\\fov emxerr}[\\,];\\\\\n                \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov ep}\\> - \\>  \\begin{minipg2}\n                     Array (length idim*im1*im2) containing the points\n                  to be approximated.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov etang1}\\> - \\>  \\begin{minipg2}\n                     Array (length idim*im1*im2) containing the derivatives\n                  (tangents) in the first parameter-direction at the\n                  data-points.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov etang2}\\> - \\>  \\begin{minipg2}\n                     Array (length idim*im1*im2) containing the derivatives\n                  (tangents) in the second parameter-direction at the\n                  data-points.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov eder11}\\> - \\>  \\begin{minipg2}\n                     Array (length idim*im1*im2) containing the cross (twist)\n                  derivatives at the data-points.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov im1}\\> - \\>  \\begin{minipg2}\n                    The no. of points in the first parameter.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov im2}\\> - \\>  \\begin{minipg2}\n                    The no. of points in the second parameter.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov idim}\\> - \\>  \\begin{minipg2}\n                    The no. of components of each input point.\n                  The approximation will be a parametric surface\n                  situated in idim-dimensional Euclidean space\n                  (usually 3).\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ipar}\\> - \\>  \\begin{minipg2}\n                     Flag determining the parametrization of the data points:\n                               \\end{minipg2}\\\\[0.8ex]\n          \\>\\>\\>\\>  $= 1$  : Mean accumulated cord-length parameterization.\\\\\n          \\>\\>\\>\\>  $= 2$  : Uniform parametrization.\\\\\n          \\>\\>\\>\\>  $= 3$  : Parametrization given by epar1 and epar2.\\\\\n        \\>\\>    {\\fov epar1}\\> - \\>  \\begin{minipg2}\n                     Array (length im1) containing a parametrization\n                  in the first parameter. (Will only\n                  be used if $ipar=3$).\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov epar2}\\> - \\>  \\begin{minipg2}\n                     Array (length im2) containing a parametrization\n                  in the second parameter. (Will only\n                  be used if $ipar=3$).\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov eeps}\\> - \\>  \\begin{minipg2}\n                     Array (length idim) containing the maximum deviation\n                  which is acceptable in each of the idim components of\n                  the surface (except possibly along the edges).\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov nend}\\> - \\>  \\begin{minipg2}\n                     Array (length 4) giving the no. of derivatives to be\n                  kept fixed along each edge of the bilinear interpolant.\n                  The numbering of the edges is the same as for edgeps below.\n                  All the derivatives of order $< (nend(i)-1)$ will be kept\n                  fixed along the edge $i$. Hence $nend(i)=0$ indicates that\n                  nothing is to be kept fixed along edge $i$.\n                  To be kept fixed here means to have error less than edgeps.\n                  In general, it is impossible to remove any knots and keep\n                  an edge completely fixed.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>   {\\fov iopen1}\\> - \\> Open/closed parameter in first direction.\\\\\n          \\>\\>\\>\\>  $= 1$  : Produce open surface.\\\\\n          \\>\\>\\>\\>  $= 0$ : Produce closed, non-periodic surface if possible.\\\\\n          \\>\\>\\>\\>  $= -1$ : Produce closed, periodic surface\\\\\n        \\>\\>\\>\\>  \\begin{minipg2}\n                  NB! The surface will be closed/periodic only if the first \n                      and last column of data points are (approximately) equal.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>   {\\fov iopen2}\\> - \\> Open/closed parameter in second direction.\\\\\n          \\>\\>\\>\\>  $= 1$  : Produce open surface.\\\\\n          \\>\\>\\>\\>  $= 0$ : Produce closed, non-periodic surface if possible.\\\\\n          \\>\\>\\>\\>  $= -1$ : Produce closed, periodic surface\\\\\n        \\>\\>\\>\\>  \\begin{minipg2}\n                  NB! The surface will be closed/periodic only if the first \n                      and last row of data points are (approximately) equal.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov edgeps}\\> - \\>  \\begin{minipg2}\n                     Array (length idim*4) containing the max. deviation from\n                  the bilinear interpolant which is acceptable along the\n                  edges of the surface.\n                  edgeps(1,i):edgeps(idim,i) gives the tolerance along\n                  the edge corresponding to the i-th parameter having\n                  one of it`s extremal-values.\n                     \\end{minipg2}\\\\[0.8ex]\n          \\>\\>\\>\\> $i=1$: min value of first parameter.\\\\ \n          \\>\\>\\>\\> $i=2$: max value of first parameter.\\\\\n          \\>\\>\\>\\> $i=3$: min value of second parameter.\\\\\n          \\>\\>\\>\\> $i=4$: max value of second parameter.\\\\\n          \\>\\>\\>\\>  \\begin{minipg2}\n                  edgeps(kp,i) will only have significance if $nend(i)>0$.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov iopt}\\> - \\>  \\begin{minipg2}\n                  Flag indicating the order in which the data reduction\n                  is to be performed:\n                               \\end{minipg2}\\\\[0.8ex]\n          \\>\\>\\>\\> $=1$: Remove knots in parameter 1 only.\\\\\n          \\>\\>\\>\\> $=2$: Remove knots in parameter 2 only.\\\\\n          \\>\\>\\>\\> $=3$: Remove knots first in parameter 1 and then in 2.\\\\\n          \\>\\>\\>\\> $=4$: Remove knots first in parameter 2 and then in 1.\\\\\n        \\>\\>    {\\fov itmax}\\> - \\>  \\begin{minipg2}\n                    Max. no. of iterations in the data reduction.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov rs}\\> - \\>  \\begin{minipg2}\n                     Pointer to surface.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov emxerr}\\> - \\>  \\begin{minipg2}\n                     Array (length idim) (allocated outside this routine.)\n                  containing an upper bound for the error comitted in\n                  each component during the data reduction.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : Warning.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Ok.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    double \\> {\\fov ep}[6000];\\, /* Spatial dimension times number of points.\\\\\n                \\>\\>\\>\\>\\>\\> Must be defined */\\\\\n                \\>\\>    double \\> {\\fov etang1}[6000];\\, /* Spatial dimension times number of points.\\\\\n                \\>\\>\\>\\>\\>\\> Must be defined */\\\\\n                \\>\\>    double \\> {\\fov etang2}[6000];\\, /* Spatial dimension times number of points.\\\\\n                \\>\\>\\>\\>\\>\\> Must be defined */\\\\\n                \\>\\>    double \\> {\\fov eder11}[6000];\\, /* Spatial dimension times number of points.\\\\\n                \\>\\>\\>\\>\\>\\> Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov im1} = 100;\\\\\n                \\>\\>    int    \\>  {\\fov im2} = 20;\\\\\n                \\>\\>    int    \\>  {\\fov idim} = 3;\\\\\n                \\>\\>    int    \\>  {\\fov ipar} = 3;\\\\\n                \\>\\>    double \\> {\\fov epar1}[100]; \\, /* Must be defined, used when ipar = 3 */\\\\\n                \\>\\>    double \\> {\\fov epar2}[20]; \\, /* Must be defined, used when ipar = 3 \\\\\n                \\>\\>    double \\> {\\fov eeps}[3]; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov nend}[4]; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov iopen1} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov iopen2} = 1;\\\\\n                \\>\\>    double \\> {\\fov edgeps}[12];/* Spatial dimension times number of edges. \\\\\n                \\>\\>\\>\\>\\>\\> Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov iopt} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov itmax} = 7;\\\\\n                \\>\\>    SISLSurf    \\>  *{\\fov rs} = NULL;\\\\\n                \\>\\>    double \\> {\\fov emxerr}[3]; /* Spatial dimension */\\\\\n                \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1967(\\begin{minipg4}\n            {\\fov ep}, {\\fov etang1}, {\\fov etang2}, {\\fov eder11}, {\\fov im1}, {\\fov im2}, {\\fov idim}, {\\fov ipar}, {\\fov epar1}, {\\fov epar2},\n\t    {\\fov eeps}, {\\fov nend}, {\\fov iopen1}, {\\fov iopen2}, {\\fov edgeps}, {\\fov iopt}, {\\fov itmax}, \\&{\\fov rs}, {\\fov emxerr}, \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1968.tex",
    "content": "\\subsection{Degree reduction: B-spline surface as input.}\n\\funclabel{s1968}\n\\begin{minipg1}\nTo compute a cubic tensor-product spline approximation\n           to a given tensor product spline surface of arbitrary order,\n           with error less than eeps in each of the idim components.\n           The error in continuity over the start and end of\n           a closed or periodic surface is only guaranteed to be within\n           edgeps.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1968(\\begin{minipg3}\n            {\\fov ps}, {\\fov eeps}, {\\fov nend}, {\\fov iopen1}, {\\fov iopen2}, {\\fov edgeps}, {\\fov iopt}, {\\fov itmax}, {\\fov rs}, {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf    \\>  *{\\fov ps};\\\\\n                \\>\\>    double \\> {\\fov eeps}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov nend}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov iopen1};\\\\\n                \\>\\>    int    \\>  {\\fov iopen2};\\\\\n                \\>\\>    double \\> {\\fov edgeps}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov iopt};\\\\\n                \\>\\>    int    \\>  {\\fov itmax};\\\\\n                \\>\\>    SISLSurf    \\>  **{\\fov rs};\\\\\n                \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov ps}\\> - \\>  \\begin{minipg2}\n                     Pointer to surface.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov eeps}\\> - \\>  \\begin{minipg2}\n                     Array (length idim) containing the max. permissible\n                  deviation of the approximation from the given data\n                  points, in each of the components. More specifically,\n                  the approximation will not deviate more than eeps(kdim)\n                  in component no. kdim, from the bilinear approximation\n                  to the data.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov nend}\\> - \\>  \\begin{minipg2}\n                     Array (length 4) giving the no. of derivatives to be\n                  kept fixed along each edge of the bilinear interpolant.\n                  The numbering of the edges is the same as for edgeps below.\n                  All the derivatives of order $< (nend(i)-1)$ will be kept\n                  fixed along the edge $i$. Hence $nend(i)=0$ indicates that\n                  nothing is to be kept fixed along edge $i$.\n                  To be kept fixed here means to have error less than edgeps.\n                  In general, it is impossible to remove any knots and keep\n                  an edge completely fixed.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>   {\\fov iopen1}\\> - \\> Open/closed parameter in first direction.\\\\\n          \\>\\>\\>\\>  $= 1$  : Produce open surface.\\\\\n          \\>\\>\\>\\>  $= 0$ : Produce closed, non-periodic surface if possible.\\\\\n          \\>\\>\\>\\>  $= -1$ : Produce closed, periodic surface\\\\\n        \\>\\>\\>\\>  \\begin{minipg2}\n                  NB! The surface will be closed/periodic only if the first \n                      and last column of data points are (approximately) equal.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>   {\\fov iopen2}\\> - \\> Open/closed parameter in second direction.\\\\\n          \\>\\>\\>\\>  $= 1$  : Produce open surface.\\\\\n          \\>\\>\\>\\>  $= 0$ : Produce closed, non-periodic surface if possible.\\\\\n          \\>\\>\\>\\>  $= -1$ : Produce closed, periodic surface\\\\\n        \\>\\>\\>\\>  \\begin{minipg2}\n                  NB! The surface will be closed/periodic only if the first \n                      and last row of data points are (approximately) equal.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov edgeps}\\> - \\>  \\begin{minipg2}\n                     Array (length idim*4) containing the max. deviation from\n                  the bilinear interpolant which is acceptable along the\n                  edges of the surface.\n                  edgeps(1,i):edgeps(idim,i) gives the tolerance along\n                  the edge corresponding to the i-th parameter having\n                  one of it`s extremal-values.\n                     \\end{minipg2}\\\\[0.8ex]\n          \\>\\>\\>\\> $i=1$: min value of first parameter.\\\\ \n          \\>\\>\\>\\> $i=2$: max value of first parameter.\\\\\n          \\>\\>\\>\\> $i=3$: min value of second parameter.\\\\\n          \\>\\>\\>\\> $i=4$: max value of second parameter.\\\\\n          \\>\\>\\>\\>  \\begin{minipg2}\n                  edgeps(kp,i) will only have significance if $nend(i)>0$.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov iopt}\\> - \\>  \\begin{minipg2}\n                  Flag indicating the order in which the data-reduction\n                  is to be performed:\n                               \\end{minipg2}\\\\[0.8ex]\n          \\>\\>\\>\\> $=1$: Remove knots in parameter 1 only.\\\\\n          \\>\\>\\>\\> $=2$: Remove knots in parameter 2 only.\\\\\n          \\>\\>\\>\\> $=3$: Remove knots first in parameter 1 and then in 2.\\\\\n          \\>\\>\\>\\> $=4$: Remove knots first in parameter 2 and then in 1.\\\\\n        \\>\\>    {\\fov itmax}\\> - \\>  \\begin{minipg2}\n                    Max. no. of iterations in the data-reduction..\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov rs}\\> - \\>  \\begin{minipg2}\n                     Pointer to surface.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>              $> 0$   : Warning.\\\\\n                \\>\\>\\>\\>\\>              $= 0$   : Ok.\\\\\n                \\>\\>\\>\\>\\>              $< 0$   : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLSurf    \\>  *{\\fov ps}; \\, /*Must be defined */\\\\\n                \\>\\>    double \\> {\\fov eeps}[3]; \\, /*Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov nend}[4];\\, /*Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov iopen1} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov iopen2} = -1;\\\\\n                \\>\\>    double \\> {\\fov edgeps}[12];/* Spatial dimension times number of edges. \\\\\n                \\>\\>\\>\\>\\>\\> Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov iopt} = 4;\\\\\n                \\>\\>    int    \\>  {\\fov itmax} = 7;\\\\\n                \\>\\>    SISLSurf    \\>  *{\\fov rs} = NULL;\\\\\n                \\>\\>    int    \\>  *{\\fov *jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s1968(\\begin{minipg4}\n            {\\fov ps}, {\\fov eeps}, {\\fov nend}, {\\fov iopen1}, {\\fov iopen2}, {\\fov edgeps}, {\\fov iopt}, {\\fov itmax}, \\&{\\fov rs}, \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1986.tex",
    "content": "\\subsection{Find the direction cone of a curve.}\n\\funclabel{s1986}\n\\begin{minipg1}\nFind the direction cone of a curve.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1986(\\begin{minipg3}\n          {\\fov pc}, {\\fov aepsge}, {\\fov jgtpi}, {\\fov gaxis}, {\\fov cang}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLCurve \\> *{\\fov pc};\\\\\n        \\>\\>    double    \\> {\\fov aepsge};\\\\\n        \\>\\>    int       \\> *{\\fov jgtpi};\\\\\n        \\>\\>    double    \\> **{\\fov gaxis};\\\\\n        \\>\\>    double    \\> *{\\fov cang};\\\\\n        \\>\\>    int       \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov pc}     \\> - \\> The curve to treat.\\\\\n        \\>\\>    {\\fov aepsge} \\> - \\> Geometry tolerance.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov jgtpi} \\> - \\>\n                \\begin{minipg2}\n                  To mark if the angle of the direction cone is greater than $\\pi$.\n                \\end{minipg2}\\\\[0.3ex]\n                \\>\\>\\>\\>\\> $= 0$ \\begin{minipg5}\n                                   The direction cone of the curve $\\leq\\pi$.\n                                 \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\> $= 1$ \\begin{minipg5}\n                                   The direction cone of the curve $> \\pi$.\n                                 \\end{minipg5}\\\\[0.8ex]\n        \\>\\>    {\\fov gaxis} \\> - \\>\n        \\begin{minipg2}\n          Allocated array containing the coordinates of the\n          centre of the cone. It is only computed if $jgtpi=0$.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov cang} \\> - \\>\n        \\begin{minipg2}\n          The angle from the centre to the boundary of the\n          cone. It is only computed if $jgtpi=0$.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat} \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>           $> 0$ : Warning.\\\\\n                \\>\\>\\>\\>\\>           $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\>           $< 0$ : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve \\> *{\\fov pc}; \\, /* Must be defined */\\\\\n        \\>\\>    double    \\> {\\fov aepsge} = 1.0e-10;\\\\\n        \\>\\>    int       \\> {\\fov jgtpi} = 0;\\\\\n        \\>\\>    double    \\> *{\\fov gaxis} = NULL;\\\\\n        \\>\\>    double    \\> {\\fov cang} = 0.0;\\\\\n        \\>\\>    int       \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1986(\\begin{minipg4}\n          {\\fov pc}, {\\fov aepsge}, \\&{\\fov jgtpi}, \\&{\\fov gaxis}, \\&{\\fov cang}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1987.tex",
    "content": "\\subsection{Find the direction cone of a surface.}\n\\funclabel{s1987}\n\\begin{minipg1}\n  Find the direction cone of a surface.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1987(\\begin{minipg3}\n          {\\fov ps}, {\\fov aepsge}, {\\fov jgtpi}, {\\fov gaxis}, {\\fov cang}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.ex]\n        \\>\\>    SISLSurf \\> *{\\fov ps};\\\\\n        \\>\\>    double   \\> {\\fov aepsge};\\\\\n        \\>\\>    int      \\> *{\\fov jgtpi};\\\\\n        \\>\\>    double   \\> **{\\fov gaxis};\\\\\n        \\>\\>    double   \\> *{\\fov cang};\\\\\n        \\>\\>    int      \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov ps}\\> - \\>  \\begin{minipg2}\n                     Surface to treat.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov aepsge}\\> - \\>  \\begin{minipg2}\n                     Geometry tolerance.\n                               \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov jgtpi}\\> - \\>\n        \\begin{minipg2}\n          To mark if the angle of the direction cone is\n          greater than $\\pi$.\n        \\end{minipg2}\\\\[0.8ex]\n                \\>\\>\\>\\> $=0$ \\> :\n                \\begin{minipg5}\n                  The direction cone of the surface\n                  is not greater than $\\pi$ in any parameter direction.\n                \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\> $=1$ \\> :\n                \\begin{minipg5}\n                  The direction cone of the surface\n                  is greater than $\\pi$ in the first parameter direction.\n                \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\> $=2$ \\> :\n                \\begin{minipg5}\n                  The direction cone of the surface is greater\n                  than $\\pi$ in the second parameter direction.\n                \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\> $=10$ \\> :\n                \\begin{minipg5}\n                  The direction cone of a boundary curve of\n                  the surface is greater than $\\pi$ in the first\n                  parameter direction.\n                \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\> $=20$ \\> :\n                \\begin{minipg5}\n                  The direction cone of a boundary curve of\n                  the surface is greater than $\\pi$ in the second\n                  parameter direction.\n                \\end{minipg5}\\\\[0.8ex]\n        \\>\\>    {\\fov gaxis}\\> - \\>\n        \\begin{minipg2}\n          Allocated array containing the coordinates of the\n          centre of the cone. It is only computed if $jgtpi=0$.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov cang}\\> - \\>\n        \\begin{minipg2}\n          The angle from the centre to the boundary of the\n          cone. It is only computed if $jgtpi=0$.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>              $> 0$ \\> : Warning.\\\\\n                \\>\\>\\>\\>              $= 0$ \\> : Ok.\\\\\n                \\>\\>\\>\\>              $< 0$ \\> : Error.\\\\\n\\newpagetabs\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf \\> *{\\fov ps}; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> {\\fov aepsge} = 1.0e-10;\\\\\n        \\>\\>    int      \\> {\\fov jgtpi} = 0;\\\\\n        \\>\\>    double   \\> *{\\fov gaxis} = NULL;\\\\\n        \\>\\>    double   \\> {\\fov cang} = 0.0;\\\\\n        \\>\\>    int      \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1987(\\begin{minipg4}\n          {\\fov ps}, {\\fov aepsge}, \\&{\\fov jgtpi}, \\&{\\fov gaxis}, \\&{\\fov cang}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1988.tex",
    "content": "\\subsection{Find the bounding box of a curve.}\n\\funclabel{s1988}\n\\begin{minipg1}\nFind the bounding box of a SISLCurve. NB. The geometric\n               bounding box is returned also in the rational case, that\n               is the box in homogenous coordinates is NOT computed.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s1988(\\begin{minipg3}\n          {\\fov pc}, {\\fov emax}, {\\fov emin}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLCurve \\> *{\\fov pc};\\\\\n        \\>\\>    double    \\> **{\\fov emax};\\\\\n        \\>\\>    double    \\> **{\\fov emin};\\\\\n        \\>\\>    int       \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov pc} \\> - \\> The curve to treat.\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov emin} \\> - \\>\n        \\begin{minipg2}\n          Array of dimension {\\fov idim} containing\n          the minimum values of the bounding box,\n          i.e.\\ bottom-left corner of the box.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov emax} \\> - \\>\n        \\begin{minipg2}\n          Array of dimension {\\fov idim} containing\n          the maximum values of the bounding box,\n          i.e.\\ upper-right corner of the box.\n        \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat}  \\> - \\> Status message\\\\\n                \\>\\>\\>\\>\\> $< 0$ : Error.\\\\\n                \\>\\>\\>\\>\\> $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\> $> 0$ : Warning.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLCurve \\> *{\\fov pc}; \\, /* Must be defined */\\\\\n        \\>\\>    double    \\> *{\\fov emax} = NULL;\\\\\n        \\>\\>    double    \\> *{\\fov emin} = NULL;\\\\\n        \\>\\>    int       \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1988(\\begin{minipg4}\n          {\\fov pc}, \\&{\\fov emax}, \\&{\\fov emin}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1989.tex",
    "content": "\\subsection{Find the bounding box of a surface.}\n\\funclabel{s1989}\n\\begin{minipg1}\n  Find the bounding box of a surface.\\\\\n  NOTE: The geometric\n  bounding box is returned also in the rational case, that\n  is the box in homogeneous coordinates is NOT computed.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>void s1989(\\begin{minipg3}\n          {\\fov ps}, {\\fov emax}, {\\fov emin}, {\\fov jstat})\n        \\end{minipg3}\\\\[0.3ex]\n        \\>\\>    SISLSurf \\> *{\\fov ps};\\\\\n        \\>\\>    double   \\> **{\\fov emax};\\\\\n        \\>\\>    double   \\> **{\\fov emin};\\\\\n        \\>\\>    int      \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n        \\>Input Arguments:\\\\\n        \\>\\>    {\\fov ps}\\> - \\>  \\begin{minipg2}\n                     Surface to treat.\n                               \\end{minipg2}\\\\\n\\\\\n        \\>Output Arguments:\\\\\n        \\>\\>    {\\fov emin}\\> - \\>  \\begin{minipg2}\n                     Array of dimension {\\fov idim} containing\n                          the minimum values of the bounding box,\n                          i.e.\\ bottom-left corner of the box.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov emax}\\> - \\>  \\begin{minipg2}\n                     Array of dimension {\\fov idim} containing\n                          the maximum values of the bounding box,\n                          i.e.\\ upper-right corner of the box.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>              $> 0$ \\> : Warning.\\\\\n                \\>\\>\\>\\>              $= 0$ \\> : Ok.\\\\\n                \\>\\>\\>\\>              $< 0$ \\> : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n        \\>      \\{ \\\\\n        \\>\\>    SISLSurf \\> *{\\fov ps}; \\, /* Must be defined */\\\\\n        \\>\\>    double   \\> *{\\fov emax} = NULL;\\\\\n        \\>\\>    double   \\> *{\\fov emin} = NULL;\\\\\n        \\>\\>    int      \\> {\\fov jstat} = 0;\\\\\n        \\>\\>    \\ldots \\\\\n        \\>\\>s1989(\\begin{minipg4}\n          {\\fov ps}, \\&{\\fov emax}, \\&{\\fov emin}, \\&{\\fov jstat});\n        \\end{minipg4}\\\\\n        \\>\\>    \\ldots \\\\\n        \\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1990.tex",
    "content": "\\subsection{Create and compute normal cone of a surface.}\n\\funclabel{s1990}\n\\begin{minipg1}\n\t\tTo create the normal cone on the unit sphere to\n\t       \ta NURBS surface, the surface is represented with\n\t       \ta surrounding cone picked from the unit sphere. The cone centre and cone angle are placed in the SISLdir element pointed to by pdir in the surface object.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1990(\\begin{minipg3}\n\t\tsurf, epsge, stat)\n\t\t\\end{minipg3}\\\\[0.3ex]\n\t\t\\>\\>\tSISLSurf \t\\>\t*{\\fov surf};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov epsge};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov surf}\t\\> - \\>\tInput surface.\\\\\n\t\\>\\>\t{\\fov epsge}\t\\> - \\>\tGeometry resolution.\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov stat}\t\\> - \\>\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n  \t\t\\>\\>\tSISLSurf    \\>\t*{\\fov surf} = NULL;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov number1} = 5;\\\\\n\t\t\\>\\>\tint    \\>\t{\\fov number2} = 4;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov order1} = 4;\\\\\n\t\t\\>\\>\tint    \\>\t{\\fov order2} = 3;\\\\\n  \t\t\\>\\>\tdouble \\>\t{\\fov knot1[9]};\\\\\n\t\t\\>\\>\tdouble \\>\t{\\fov knot2[7]};\\\\\n  \t\t\\>\\>\tdouble \\>\t{\\fov coef[60]};\\\\\n  \t\t\\>\\>\tdouble \\>\t{\\fov epsge} = 1e-10;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov kind} = 1;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov dim} = 3;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov copy} = 0;\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov stat};\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>surf$=$newSurf(\\begin{minipg4}\n\t{\\fov number1}, {\\fov number2}, {\\fov order1}, {\\fov order2}, {\\fov knot1}, {\\fov knot2}, {\\fov coef}, {\\fov kind}, {\\fov dim}, {\\fov copy});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1990(\\begin{minipg4}\n\t\t{\\fov surf}, {\\fov epsge}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1991.tex",
    "content": "\\subsection{Create and compute direction cone to a curve.} \n\\funclabel{s1991}\n\\begin{minipg1}\n\t\tTo make the orientation cone on the unit sphere of\n\t       \ta NURBS curve. The curve is represented with\n\t       \ta surrounding cone picked from the unit sphere. The cone centre and cone angle are placed in the SISLdir element pointed to by pdir in the curve object.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1991(\\begin{minipg3}\n\t\t{\\fov curve}, {\\fov epsge}, {\\fov stat})\n\t\t\\end{minipg3}\\\\[0.3ex]\n\t\t\\>\\>\tSISLCurve \t\\>\t*{\\fov curve};\\\\\n\t\t\\>\\>\tdouble \t\\>\t{\\fov epsge};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov curve}\t\\> - \\>\tInput curve.\\\\\n\t\\>\\>\t{\\fov epsge}\t\\> - \\>\tGeometry resolution.\\\\\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov stat}\t\\> - \\>\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n  \t\t\\>\\>\tSISLCurve    \\>\t*{\\fov curve} = NULL;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov number} = 10;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov order} = 4;\\\\\n  \t\t\\>\\>\tdouble \\>\t{\\fov knots[14]};\\\\\n  \t\t\\>\\>\tdouble \\>\t{\\fov coef[30]};\\\\\n  \t\t\\>\\>\tdouble \\>\t{\\fov epsge} = 1e-10;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov kind} = 1;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov dim} = 3;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov copy} = 0;\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov stat};\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>{\\fov curve}$=$newCurve(\\begin{minipg4}\n\t{\\fov number}, {\\fov order}, {\\fov knots}, {\\fov coef}, {\\fov kind}, {\\fov dim}, {\\fov copy});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1991(\\begin{minipg4}\n\t\t{\\fov curve}, {\\fov epsge}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1992cu.tex",
    "content": "\\subsection{Create and compute bounding box to a curve.}\n\\funclabel{s1992cu}\n\\begin{minipg7}\n\t\tMake a box from the control polygon to the curve given by\n              \tecoef. If dimension is 2, then one box rotated 45 degrees is also made. If the dimension\n\t       \tis 3, then boxes  rotated 45 degrees around each\n\t       \tmain axis are made. The min/max values of the boxes are placed in the SISLbox element pointed to by pbox in the curve object.\n\\end{minipg7} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1992cu(\\begin{minipg3}\n\t\t{\\fov curve}, {\\fov stat})\n\t\t\\end{minipg3}\\\\[0.3ex]\n\t\t\\>\\>\tSISLCurve \t\\>\t*{\\fov curve};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\newpagetabs\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov curve}\t\\> - \\>\tInput curve.\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov stat}\t\\> - \\>\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n  \t\t\\>\\>\tSISLCurve    \\>\t*{\\fov curve = NULL};\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov number} = 10;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov order} = 4;\\\\\n  \t\t\\>\\>\tdouble \\>\t{\\fov knots[14]};\\\\\n  \t\t\\>\\>\tdouble \\>\t{\\fov coef[30]};\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov kind} = 1;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov dim} = 3;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov copy} = 0;\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov stat};\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>curve$=$newCurve(\\begin{minipg4}\n\t{\\fov number}, {\\fov order}, {\\fov knots}, {\\fov coef}, {\\fov kind}, {\\fov dim}, {\\fov copy});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1992cu(\\begin{minipg4}\n\t\t{\\fov curve}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s1992su.tex",
    "content": "\\subsection{Create and compute bounding box to a surface.}\n\\funclabel{s1992su}\n\\begin{minipg7}\n\t\tMake a box from the control polygon of the surface given by\n              \tecoef. If dimension is 2 then one\n\t       \tbox rotated 45 degrees is also made. If dimension\n\t       \tis 3 then boxes rotated 45 degrees around each\n\t       \tmain axis are made. The min/max values of the boxes are placed in the SISLbox element pointed to by pbox in the surface object.\n\\end{minipg7} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s1992su(\\begin{minipg3}\n\t\t{\\fov surf}, {\\fov stat})\n\t\t\\end{minipg3}\\\\[0.3ex]\n\t\t\\>\\>\tSISLSurf \t\\>\t*{\\fov surf};\\\\\n\t\t\\>\\>\tint \t\\>\t*{\\fov stat};\\\\\n\\newpagetabs\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov surf}\t\\> - \\>\tInput surface.\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n\t\\>\\>\t{\\fov stat}\t\\> - \\>\tStatus messages\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$> 0$\t: warning\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$= 0$\t: ok\\\\\n\t\t\\>\\>\\>\\>\\>\t\t$< 0$\t: error\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n  \t\t\\>\\>\tSISLSurf    \\>\t*{\\fov surf} = NULL;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov number}1=5;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov number}2=4;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov order}1=4;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov order}2=3;\\\\\n  \t\t\\>\\>\tdouble \\>\t{\\fov knot1[9]};\\\\\n  \t\t\\>\\>\tdouble \\>\t{\\fov knot2[7]};\\\\\n  \t\t\\>\\>\tdouble \\>\t{\\fov coef[60]};\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov kind} = 1;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov dim} = 3;\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov copy} = 0;\\\\\n\t\t\\>\\>\tint \t\\>\t{\\fov stat};\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>surf$=$newSurf(\\begin{minipg4}\n\t{\\fov number1}, {\\fov number2}, {\\fov order1}, {\\fov order2}, {\\fov knot1}, {\\fov knot2},\\\\ {\\fov coef}, {\\fov kind}, {\\fov dim}, {\\fov copy});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\\>\\>s1992su(\\begin{minipg4}\n\t\t{\\fov surf}, \\&{\\fov stat});\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s2500.tex",
    "content": "\\subsection{Gaussian curvature of a spline surface.}\n\\funclabel{s2500}\n\\begin{minipg1}\n To compute the Gaussian curvature K(u,v) of a spline surface at given\n                   values (u,v) $=$ (parvalue[0],parvalue[1]), where\n                      et1[leftknot1] $<=$ parvalue[0] $<$ et1[leftknot1+1] and\n                      et2[leftknot2] $<=$ parvalue[1] $<$ et2[leftknot2+1].\n                   See also s2501().\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>  void s2500(\\begin{minipg3}\n            {\\fov surf},  {\\fov ider},  {\\fov iside1},  {\\fov iside2},  {\\fov parvalue},  {\\fov leftknot1},  {\\fov leftknot2},  {\\fov gaussian},  {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf \\> *{\\fov surf};\\\\\n                \\>\\>    int    \\>  {\\fov ider};\\\\\n                \\>\\>    int    \\>  {\\fov iside1};\\\\\n                \\>\\>    int    \\>  {\\fov iside2};\\\\\n                \\>\\>    double \\> {\\fov parvalue}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov leftknot1};\\\\\n                \\>\\>    int \\> *{\\fov leftknot2};\\\\\n                \\>\\>    double \\> {\\fov gaussian}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>  \\begin{minipg2}\n                     Pointer to the surface to evaluate.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ider}\\> - \\>  \\begin{minipg2}\n                     Number of derivatives to calculate.\n                     Only implemented for ider=0.\n                               \\end{minipg2}\\\\[0.8ex]\n                \\>\\>\\>\\>  $< 0$ : \\> No derivative calculated.\\\\\n                \\>\\>\\>\\>  $= 0$ : \\> Position calculated.\\\\\n                \\>\\>\\>\\>  $= 1$ : \\> Position and first derivative calculated, etc.\\\\\n        \\>\\>    {\\fov iside1}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the derivatives in the first\n                     parameter direction are to be calculated from the\n                     left or from the right:\n                               \\end{minipg2}\\\\[0.8ex]\n         \\>\\>\\>\\>  $< 0$  : \\> calculate derivative from the left hand side.\\\\\n         \\>\\>\\>\\>  $>= 0$ : \\> calculate derivative from the right hand side.\\\\\n        \\>\\>    {\\fov iside2}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the derivatives in the second\n                     parameter direction are to be calculated from the\n                     left or from the right:\n                               \\end{minipg2}\\\\[0.8ex]\n         \\>\\>\\>\\>  $< 0$  : \\> calculate derivative from the left hand side.\\\\\n         \\>\\>\\>\\>  $>= 0$ : \\> calculate derivative from the right hand side.\\\\\n        \\>\\>    {\\fov parvalue}\\> - \\>  \\begin{minipg2}\n                     Parameter value at which to evaluate. Dimension of\n                     parvalue is 2.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov leftknot1}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector in the\n                     first parameter direction where parvalue[0] is found,\n                     that is:\n                          et1[leftknot1] $<=$ parvalue[0] $<$ et1[leftknot1+1].\n                     leftknot1 should be set equal to zero at the first call\n                     to the routine.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov leftknot2}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector in the\n                     second parameter direction where parvalue[1] is found,\n                     that is:\n                          et2[leftknot2] $<=$ parvalue[1] $<$ et2[leftknot2+1].\n                     leftknot2 should be set equal to zero at the first call\n                     to the routine.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov gaussian}\\> - \\>  \\begin{minipg2}\n                     Gaussian of the surface at (u,v) $=$\n                     (parvalue[0],parvalue[1]).\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\> $= 2$ : \n                       \\> \\begin{minipg5}  \n                               Surface is degenerate at the point, that is,\n                               the surface is not regular at this point.\n                               \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>  $= 1$ :\n                       \\> \\begin{minipg5}  \n                               Surface is close to degenerate at the point.\n                               Angle between tangents is less than the angular\n                               tolerance.\n                               \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\> $= 0$ : \\> Ok.\\\\\n                \\>\\>\\>\\> $< 0$ : \\> Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLSurf \\> *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov ider} = 0;\\\\\n                \\>\\>    int    \\>  {\\fov iside1} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov iside2} = 1;\\\\\n                \\>\\>    double \\> {\\fov parvalue}[2]; /* Must be defined */\\\\\n                \\>\\>    int \\> {\\fov leftknot1} = 0; /* Define initially as zero. For consequtive evaluations \\\\\n                \\>\\>\\>\\>\\>\\> leave leftknot1 as returned from s1500 */\\\\\n                \\>\\>    int \\> {\\fov leftknot2} = 0; /* As for leftknot1 */ \\\\\n                \\>\\>    double \\> {\\fov gaussian}[1]; /* A pre allocated array is expected */\\\\\n                \\>\\>    int \\> {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\> \\>s2500(\\begin{minipg4}\n            {\\fov surf},  {\\fov ider},  {\\fov iside1},  {\\fov iside2},  {\\fov parvalue},  \\&{\\fov leftknot1},  \\&{\\fov leftknot2},  {\\fov gaussian},  \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s2502.tex",
    "content": "\\subsection{Mean curvature of a spline surface.}\n\\funclabel{s2502}\n\\begin{minipg1}\n To compute the mean curvature H(u,v) of a spline surface at given\n                   values (u,v) $=$ (parvalue[0],parvalue[1]), where\n                       etl[leftknot1] $<=$ parvalue[0] $<$ etl[leftknot1+1] and\n                       et2[leftknot2] $<=$ parvalue[1] $<$ et2[leftknot2+1].\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>  void s2502(\\begin{minipg3}\n            {\\fov surf},  {\\fov ider},  {\\fov iside1},  {\\fov iside2},  {\\fov parvalue},  {\\fov leftknot1},  {\\fov leftknot2},\n\t     {\\fov meancurvature},  {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf \\> *{\\fov surf};\\\\\n                \\>\\>    int    \\>  {\\fov ider};\\\\\n                \\>\\>    int    \\>  {\\fov iside1};\\\\\n                \\>\\>    int    \\>  {\\fov iside2};\\\\\n                \\>\\>    double \\> {\\fov parvalue}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov leftknot1};\\\\\n                \\>\\>    int \\> *{\\fov leftknot2};\\\\\n                \\>\\>    double \\> {\\fov meancurvature}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>  \\begin{minipg2}\n                     Pointer to the surface to evaluate.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ider}\\> - \\>  \\begin{minipg2}\n                     Number of derivatives to calculate.\n                     Only implemented for ider=0.\n                               \\end{minipg2}\\\\[0.8ex]\n                \\>\\>\\>\\>  $< 0$ : \\> No derivative calculated.\\\\\n                \\>\\>\\>\\>  $= 0$ : \\> Position calculated.\\\\\n                \\>\\>\\>\\>  $= 1$ : \\> Position and first derivative calculated, etc.\\\\\n        \\>\\>    {\\fov iside1}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the derivatives in the first\n                     parameter direction are to be calculated from the\n                     left or from the right:\n                               \\end{minipg2}\\\\[0.8ex]\n         \\>\\>\\>\\>  $< 0$  : \\> calculate derivative from the left hand side.\\\\\n         \\>\\>\\>\\>  $>= 0$ : \\> calculate derivative from the right hand side.\\\\\n        \\>\\>    {\\fov iside2}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the derivatives in the second\n                     parameter direction are to be calculated from the\n                     left or from the right:\n                               \\end{minipg2}\\\\[0.8ex]\n         \\>\\>\\>\\>  $< 0$  : \\> calculate derivative from the left hand side.\\\\\n         \\>\\>\\>\\>  $>= 0$ : \\> calculate derivative from the right hand side.\\\\\n        \\>\\>    {\\fov parvalue}\\> - \\>  \\begin{minipg2}\n                     Parameter value at which to evaluate. Dimension of\n                     parvalue is 2.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov leftknot1}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector in the\n                     first parameter direction where parvalue[0] is found,\n                     that is:\n                          et1[leftknot1] $<=$ parvalue[0] $<$ et1[leftknot1+1].\n                     leftknot1 should be set equal to zero at the first call\n                     to the routine.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov leftknot2}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector in the\n                     second parameter direction where parvalue[1] is found,\n                     that is:\n                          et2[leftknot2] $<=$ parvalue[1] $<$ et2[leftknot2+1].\n                     leftknot2 should be set equal to zero at the first call\n                     to the routine.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov meancurvature}\\> - \\>  \\begin{minipg2}\n                     Mean curvature of the surface at (u,v) $=$\n                     (parvalue[0],parvalue[1]).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\> $= 2$ : \n                       \\> \\begin{minipg5}  \n                               Surface is degenerate at the point, that is,\n                               the surface is not regular at this point.\n                               \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>  $= 1$ :\n                       \\> \\begin{minipg5}  \n                               Surface is close to degenerate at the point.\n                               Angle between tangents is less than the angular\n                               tolerance.\n                               \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\> $= 0$ : \\> Ok.\\\\\n                \\>\\>\\>\\> $< 0$ : \\> Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLSurf \\> *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov ider} = 0;\\\\\n                \\>\\>    int    \\>  {\\fov iside1} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov iside2} = 1;\\\\\n                \\>\\>    double \\> {\\fov parvalue}[2]; \\, /* Must be defined */\\\\\n                \\>\\>    int \\> {\\fov leftknot1} = 0; /* Define initially as zero. For consequtive evaluations \\\\\n                \\>\\>\\>\\>\\>\\> leave leftknot1 as returned from s1502 */\\\\\n                \\>\\>    int \\> {\\fov leftknot2} = 0; /* As for leftknot1 */ \\\\\n                \\>\\>    double \\> {\\fov meancurvature}[1]; /* A pre allocated array is expected */\\\\\n                \\>\\>    int \\> {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\> \\>s2502(\\begin{minipg4}\n            {\\fov surf},  {\\fov ider},  {\\fov iside1},  {\\fov iside2},  {\\fov parvalue},  {\\fov leftknot1},  {\\fov leftknot2},\n\t     {\\fov meancurvature},  \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s2504.tex",
    "content": "\\subsection{Absolute curvature of a spline surface.}\n\\funclabel{s2504}\n\\begin{minipg1}\n To compute the absolute curvature A(u,v) of a spline surface at\n                   given values (u,v) $=$ (parvalue[0],parvalue[1]), where\n                   et1[leftknot1] $<=$ parvalue[0] $<$ et1[leftknot1+1] and\n                   et2[leftknot2] $<=$ parvalue[1] $<$ et2[leftknot2+1].\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>  void s2504(\\begin{minipg3}\n            {\\fov surf},  {\\fov ider},  {\\fov iside1},  {\\fov iside2},  {\\fov parvalue},  {\\fov leftknot1},  {\\fov leftknot2},\n\t     {\\fov absCurvature},  {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf \\> *{\\fov surf};\\\\\n                \\>\\>    int    \\>  {\\fov ider};\\\\\n                \\>\\>    int    \\>  {\\fov iside1};\\\\\n                \\>\\>    int    \\>  {\\fov iside2};\\\\\n                \\>\\>    double \\> {\\fov parvalue}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov leftknot1};\\\\\n                \\>\\>    int \\> *{\\fov leftknot2};\\\\\n                \\>\\>    double \\> {\\fov absCurvature}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>  \\begin{minipg2}\n                     Pointer to the surface to evaluate.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ider}\\> - \\>  \\begin{minipg2}\n                     Number of derivatives to calculate.\n                     Only implemented for ider=0.\n                               \\end{minipg2}\\\\[0.8ex]\n                \\>\\>\\>\\>  $< 0$ : \\> No derivative calculated.\\\\\n                \\>\\>\\>\\>  $= 0$ : \\> Position calculated.\\\\\n                \\>\\>\\>\\>  $= 1$ : \\> Position and first derivative calculated, etc.\\\\\n        \\>\\>    {\\fov iside1}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the derivatives in the first\n                     parameter direction are to be calculated from the\n                     left or from the right:\n                               \\end{minipg2}\\\\[0.8ex]\n         \\>\\>\\>\\>  $< 0$  : \\> calculate derivative from the left hand side.\\\\\n         \\>\\>\\>\\>  $>= 0$ : \\> calculate derivative from the right hand side.\\\\\n        \\>\\>    {\\fov iside2}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the derivatives in the second\n                     parameter direction are to be calculated from the\n                     left or from the right:\n                               \\end{minipg2}\\\\[0.8ex]\n         \\>\\>\\>\\>  $< 0$  : \\> calculate derivative from the left hand side.\\\\\n         \\>\\>\\>\\>  $>= 0$ : \\> calculate derivative from the right hand side.\\\\\n        \\>\\>    {\\fov parvalue}\\> - \\>  \\begin{minipg2}\n                     Parameter value at which to evaluate. Dimension of\n                     parvalue is 2.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov leftknot1}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector in the\n                     first parameter direction where parvalue[0] is found,\n                     that is:\n                          et1[leftknot1] $<=$ parvalue[0] $<$ et1[leftknot1+1].\n                     leftknot1 should be set equal to zero at the first call\n                     to the routine.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov leftknot2}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector in the\n                     second parameter direction where parvalue[1] is found,\n                     that is:\n                          et2[leftknot2] $<=$ parvalue[1] $<$ et2[leftknot2+1].\n                     leftknot2 should be set equal to zero at the first call\n                     to the routine.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov absCurvature}\\> - \\>  \\begin{minipg2}\n                     Absolute curvature of the surface at (u,v) $=$\n                     (parvalue[0],parvalue[1]).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\> $= 2$ : \n                       \\> \\begin{minipg5}  \n                               Surface is degenerate at the point, that is,\n                               the surface is not regular at this point.\n                               \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>  $= 1$ :\n                       \\> \\begin{minipg5}  \n                               Surface is close to degenerate at the point.\n                               Angle between tangents is less than the angular\n                               tolerance.\n                               \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\> $= 0$ : \\> Ok.\\\\\n                \\>\\>\\>\\> $< 0$ : \\> Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLSurf \\> *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov ider} = 0;\\\\\n                \\>\\>    int    \\>  {\\fov iside1} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov iside2} = 1;\\\\\n                \\>\\>    double \\> {\\fov parvalue}[2]; \\, /* Must be defined */\\\\\n                \\>\\>    int \\> {\\fov leftknot1} = 0; /* Define initially as zero. For consequtive evaluations \\\\\n                \\>\\>\\>\\>\\>\\> leave leftknot1 as returned from s1504 */\\\\\n                \\>\\>    int \\> {\\fov leftknot2} = 0; /* As for leftknot1 */ \\\\\n                \\>\\>    double \\> {\\fov absCurvature}[1]; /* A pre allocated array is expected */\\\\\n                \\>\\>    int \\> {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\> \\>s2504(\\begin{minipg4}\n            {\\fov surf},  {\\fov ider},  {\\fov iside1},  {\\fov iside2},  {\\fov parvalue},  {\\fov leftknot1},  {\\fov leftknot2},\n\t     {\\fov absCurvature},  \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s2506.tex",
    "content": "\\subsection{Total curvature of a spline surface.}\n\\funclabel{s2506}\n\\begin{minipg1}\nTo compute the total curvature T(u,v) of a surface at\n                   given values (u,v) = (parvalue[0],parvalue[1]), where\n                   et1[leftknot1] $<=$ parvalue[0] $<$ et1[leftknot1+1] and\n                   et2[leftknot2] $<=$ parvalue[1] $<$ et2[leftknot2+1].\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>  void s2506(\\begin{minipg3}\n            {\\fov surf},  {\\fov ider},  {\\fov iside1},  {\\fov iside2},  {\\fov parvalue},  {\\fov leftknot1},  {\\fov leftknot2},\n\t     {\\fov totalCurvature},  {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf \\> *{\\fov surf};\\\\\n                \\>\\>    int    \\>  {\\fov ider};\\\\\n                \\>\\>    int    \\>  {\\fov iside1};\\\\\n                \\>\\>    int    \\>  {\\fov iside2};\\\\\n                \\>\\>    double \\> {\\fov parvalue}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov leftknot1};\\\\\n                \\>\\>    int \\> *{\\fov leftknot2};\\\\\n                \\>\\>    double \\> {\\fov totalCurvature}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>  \\begin{minipg2}\n                     Pointer to the surface to evaluate.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ider}\\> - \\>  \\begin{minipg2}\n                     Number of derivatives to calculate.\n                     Only implemented for ider=0.\n                               \\end{minipg2}\\\\[0.8ex]\n                \\>\\>\\>\\>  $< 0$ : \\> No derivative calculated.\\\\\n                \\>\\>\\>\\>  $= 0$ : \\> Position calculated.\\\\\n                \\>\\>\\>\\>  $= 1$ : \\> Position and first derivative calculated, etc.\\\\\n        \\>\\>    {\\fov iside1}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the derivatives in the first\n                     parameter direction are to be calculated from the\n                     left or from the right:\n                               \\end{minipg2}\\\\[0.8ex]\n         \\>\\>\\>\\>  $< 0$  : \\> calculate derivative from the left hand side.\\\\\n         \\>\\>\\>\\>  $>= 0$ : \\> calculate derivative from the right hand side.\\\\\n        \\>\\>    {\\fov iside2}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the derivatives in the second\n                     parameter direction are to be calculated from the\n                     left or from the right:\n                               \\end{minipg2}\\\\[0.8ex]\n         \\>\\>\\>\\>  $< 0$  : \\> calculate derivative from the left hand side.\\\\\n         \\>\\>\\>\\>  $>= 0$ : \\> calculate derivative from the right hand side.\\\\\n        \\>\\>    {\\fov parvalue}\\> - \\>  \\begin{minipg2}\n                     Parameter value at which to evaluate. Dimension of\n                     parvalue is 2.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov leftknot1}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector in the\n                     first parameter direction where parvalue[0] is found,\n                     that is:\n                          et1[leftknot1] $<=$ parvalue[0] $<$ et1[leftknot1+1].\n                     leftknot1 should be set equal to zero at the first call\n                     to the routine.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov leftknot2}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector in the\n                     second parameter direction where parvalue[1] is found,\n                     that is:\n                          et2[leftknot2] $<=$ parvalue[1] $<$ et2[leftknot2+1].\n                     leftknot2 should be set equal to zero at the first call\n                     to the routine.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov totalCurvature}\\> - \\>  \\begin{minipg2}\n                     Total curvature of the surface at (u,v) $=$\n                     (parvalue[0],parvalue[1]).\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\> $= 2$ : \n                       \\> \\begin{minipg5}  \n                               Surface is degenerate at the point, that is,\n                               the surface is not regular at this point.\n                               \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>  $= 1$ :\n                       \\> \\begin{minipg5}  \n                               Surface is close to degenerate at the point.\n                               Angle between tangents is less than the angular\n                               tolerance.\n                               \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\> $= 0$ : \\> Ok.\\\\\n                \\>\\>\\>\\> $< 0$ : \\> Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLSurf \\> *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov ider} = 0;\\\\\n                \\>\\>    int    \\>  {\\fov iside1} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov iside2} = 1;\\\\\n                \\>\\>    double \\> {\\fov parvalue}[2] \\, /* Must be defined */;\\\\\n                \\>\\>    int \\> {\\fov leftknot1} = 0; /* Define initially as zero. For consequtive evaluations\\\\\n                \\>\\>\\>\\>\\>\\> leave leftknot1 as returned from s1506 */\\\\\n                \\>\\>    int \\> {\\fov leftknot2} = 0; /* As for leftknot1 */ \\\\\n                \\>\\>    double \\> {\\fov totalCurvature}[1]; /* A pre allocated array is expected */\\\\\n                \\>\\>    int \\> {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\> \\>s2506(\\begin{minipg4}\n            {\\fov surf},  {\\fov ider},  {\\fov iside1},  {\\fov iside2},  {\\fov parvalue},  {\\fov leftknot1},  {\\fov leftknot2},\n\t     {\\fov totalCurvature},  \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s2508.tex",
    "content": "\\subsection{Second order Mehlum curvature of a spline surface.}\n\\funclabel{s2508}\n\\begin{minipg1}\nTo compute the second order Mehlum curvature M(u,v) of a \n                   surface at given values (u,v) = (parvalue[0],parvalue[1]), \n                   where\n                    et1[leftknot1] $<=$ parvalue[0] $<$ et1[leftknot1+1] and\n                    et2[leftknot2] $<=$ parvalue[1] $<$ et2[leftknot2+1].\n                   See also s2509().\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>  void s2508(\\begin{minipg3}\n            {\\fov surf},  {\\fov ider},  {\\fov iside1},  {\\fov iside2},  {\\fov parvalue},  {\\fov leftknot1},  {\\fov leftknot2},  {\\fov mehlum},  {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf \\> *{\\fov surf};\\\\\n                \\>\\>    int    \\>  {\\fov ider};\\\\\n                \\>\\>    int    \\>  {\\fov iside1};\\\\\n                \\>\\>    int    \\>  {\\fov iside2};\\\\\n                \\>\\>    double \\> {\\fov parvalue}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov leftknot1};\\\\\n                \\>\\>    int \\> *{\\fov leftknot2};\\\\\n                \\>\\>    double \\> {\\fov mehlum}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>  \\begin{minipg2}\n                     Pointer to the surface to evaluate.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ider}\\> - \\>  \\begin{minipg2}\n                     Number of derivatives to calculate.\n                     Only implemented for ider=0.\n                               \\end{minipg2}\\\\[0.8ex]\n                \\>\\>\\>\\>  $< 0$ : \\> No derivative calculated.\\\\\n                \\>\\>\\>\\>  $= 0$ : \\> Position calculated.\\\\\n                \\>\\>\\>\\>  $= 1$ : \\> Position and first derivative calculated, etc.\\\\\n        \\>\\>    {\\fov iside1}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the derivatives in the first\n                     parameter direction are to be calculated from the\n                     left or from the right:\n                               \\end{minipg2}\\\\[0.8ex]\n         \\>\\>\\>\\>  $< 0$  : \\> calculate derivative from the left hand side.\\\\\n         \\>\\>\\>\\>  $>= 0$ : \\> calculate derivative from the right hand side.\\\\\n        \\>\\>    {\\fov iside2}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the derivatives in the second\n                     parameter direction are to be calculated from the\n                     left or from the right:\n                               \\end{minipg2}\\\\[0.8ex]\n         \\>\\>\\>\\>  $< 0$  : \\> calculate derivative from the left hand side.\\\\\n         \\>\\>\\>\\>  $>= 0$ : \\> calculate derivative from the right hand side.\\\\\n        \\>\\>    {\\fov parvalue}\\> - \\>  \\begin{minipg2}\n                     Parameter value at which to evaluate. Dimension of\n                     parvalue is 2.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov leftknot1}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector in the\n                     first parameter direction where parvalue[0] is found,\n                     that is:\n                          et1[leftknot1] $<=$ parvalue[0] $<$ et1[leftknot1+1].\n                     leftknot1 should be set equal to zero at the first call\n                     to the routine.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov leftknot2}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector in the\n                     second parameter direction where parvalue[1] is found,\n                     that is:\n                          et2[leftknot2] $<=$ parvalue[1] $<$ et2[leftknot2+1].\n                     leftknot2 should be set equal to zero at the first call\n                     to the routine.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov mehlum}\\> - \\>  \\begin{minipg2}\n                     The second order Mehlum curvature\n                     of the surface at (u,v) $=$\n                     (parvalue[0],parvalue[1]).\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\> $= 2$ : \n                       \\> \\begin{minipg5}  \n                               Surface is degenerate at the point, that is,\n                               the surface is not regular at this point.\n                               \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>  $= 1$ :\n                       \\> \\begin{minipg5}  \n                               Surface is close to degenerate at the point.\n                               Angle between tangents is less than the angular\n                               tolerance.\n                               \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\> $= 0$ : \\> Ok.\\\\\n                \\>\\>\\>\\> $< 0$ : \\> Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLSurf \\> *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov ider} = 0;\\\\\n                \\>\\>    int    \\>  {\\fov iside1} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov iside2} = 1;\\\\\n                \\>\\>    double \\> {\\fov parvalue}[2]; \\, /* Must be defined */\\\\\n                \\>\\>    int \\> {\\fov leftknot1} = 0; /* Define initially as zero. For consequtive evaluations \\\\\n                \\>\\>\\>\\>\\>\\> leave leftknot1 as returned from s1506 \\\\\n                \\>\\>    int \\> {\\fov leftknot2} = 0; /* As for leftknot1 */\\\\\n                \\>\\>    double \\> {\\fov mehlum}[1]; /* A pre allocated array is expected \\\\\n                \\>\\>    int \\> {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\> \\>s2508(\\begin{minipg4}\n            {\\fov surf},  {\\fov ider},  {\\fov iside1},  {\\fov iside2},  {\\fov parvalue},  {\\fov leftknot1},  {\\fov leftknot2},  {\\fov mehlum},  \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s2510.tex",
    "content": "\\subsection{Third order Mehlum curvature of a spline surface.}\n\\funclabel{s2510}\n\\begin{minipg1}\n To compute the third order Mehlum curvature M(u,v) of a \n                   surface at given values (u,v) $=$ (parvalue[0],parvalue[1]), \n                   where\n                     et1[leftknot1] $<=$ parvalue[0] $<$ et1[leftknot1+1],\n                     et2[leftknot2] $<=$ parvalue[1] $<$ et2[leftknot2+1].\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>  void s2510(\\begin{minipg3}\n            {\\fov surf},  {\\fov ider},  {\\fov iside1},  {\\fov iside2},  {\\fov parvalue},  {\\fov leftknot1},  {\\fov leftknot2},  {\\fov mehlum},  {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf \\> *{\\fov surf};\\\\\n                \\>\\>    int    \\>  {\\fov ider};\\\\\n                \\>\\>    int    \\>  {\\fov iside1};\\\\\n                \\>\\>    int    \\>  {\\fov iside2};\\\\\n                \\>\\>    double \\> {\\fov parvalue}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov leftknot1};\\\\\n                \\>\\>    int \\> *{\\fov leftknot2};\\\\\n                \\>\\>    double \\> {\\fov mehlum}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>  \\begin{minipg2}\n                     Pointer to the surface to evaluate.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ider}\\> - \\>  \\begin{minipg2}\n                     Number of derivatives to calculate.\n                     Only implemented for ider=0.\n                               \\end{minipg2}\\\\[0.8ex]\n                \\>\\>\\>\\>  $< 0$ : \\> No derivative calculated.\\\\\n                \\>\\>\\>\\>  $= 0$ : \\> Position calculated.\\\\\n                \\>\\>\\>\\>  $= 1$ : \\> Position and first derivative calculated, etc.\\\\\n        \\>\\>    {\\fov iside1}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the derivatives in the first\n                     parameter direction are to be calculated from the\n                     left or from the right:\n                               \\end{minipg2}\\\\[0.8ex]\n         \\>\\>\\>\\>  $< 0$  : \\> calculate derivative from the left hand side.\\\\\n         \\>\\>\\>\\>  $>= 0$ : \\> calculate derivative from the right hand side.\\\\\n        \\>\\>    {\\fov iside2}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the derivatives in the second\n                     parameter direction are to be calculated from the\n                     left or from the right:\n                               \\end{minipg2}\\\\[0.8ex]\n         \\>\\>\\>\\>  $< 0$  : \\> calculate derivative from the left hand side.\\\\\n         \\>\\>\\>\\>  $>= 0$ : \\> calculate derivative from the right hand side.\\\\\n        \\>\\>    {\\fov parvalue}\\> - \\>  \\begin{minipg2}\n                     Parameter value at which to evaluate. Dimension of\n                     parvalue is 2.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov leftknot1}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector in the\n                     first parameter direction where parvalue[0] is found,\n                     that is:\n                          et1[leftknot1] $<=$ parvalue[0] $<$ et1[leftknot1+1].\n                     leftknot1 should be set equal to zero at the first call\n                     to the routine.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov leftknot2}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector in the\n                     second parameter direction where parvalue[1] is found,\n                     that is:\n                          et2[leftknot2] $<=$ parvalue[1] $<$ et2[leftknot2+1].\n                     leftknot2 should be set equal to zero at the first call\n                     to the routine.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov mehlum}\\> - \\>  \\begin{minipg2}\n                     Third order Mehlum curvature of the surface at (u,v) $=$\n                     (parvalue[0],parvalue[1]).\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\> $= 2$ : \n                       \\> \\begin{minipg5}  \n                               Surface is degenerate at the point, that is,\n                               the surface is not regular at this point.\n                               \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>  $= 1$ :\n                       \\> \\begin{minipg5}  \n                               Surface is close to degenerate at the point.\n                               Angle between tangents is less than the angular\n                               tolerance.\n                               \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\> $= 0$ : \\> Ok.\\\\\n                \\>\\>\\>\\> $< 0$ : \\> Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLSurf \\> *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov ider} = 0;\\\\\n                \\>\\>    int    \\>  {\\fov iside1} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov iside2} = 1;\\\\\n                \\>\\>    double \\> {\\fov parvalue}[2]; \\, /* Must be defined */\\\\\n                \\>\\>    int \\> {\\fov leftknot1} = 0; /* Define initially as zero. For consequtive evaluations \\\\\n                \\>\\>\\>\\>\\>\\> leave leftknot1 as returned from s1510 */\\\\\n                \\>\\>    int \\> {\\fov leftknot2} = 0; /* As for leftknot1 */\\\\\n                \\>\\>    double \\> {\\fov mehlum}[1]; /* A pre allocated array is expected */\\\\\n                \\>\\>    int \\> {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\> \\>s2510(\\begin{minipg4}\n            {\\fov surf},  {\\fov ider},  {\\fov iside1},  {\\fov iside2},  {\\fov parvalue},  {\\fov leftknot1},  {\\fov leftknot2},  {\\fov mehlum},  \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s2532.tex",
    "content": "\\subsection{Gaussian curvature of a B-spline or NURBS \n            surface as a NURBS surface.}\n\\funclabel{s2532}\n\\begin{minipg1}\nTo interpolate or approximate the Gaussian curvature of a B-spline or NURBS \n            surface by a NURBS surface. \n            The desired continuity of the Gaussian curvature surface is\n            input and this may lead to a patchwork of output surfaces. \n            Interpolation results in a high order surface.\n            If the original surface is a B-spline surface of order $k$,\n            the result is of order $8k -11$, in the NURBS case,\n            order $32k-35$.\n            To avoid instability beacuse of this, a maximum order is\n            applied. This may lead to an approximation rather than\n            an interpolation.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s2532(\\begin{minipg3}\n            {\\fov surf}, {\\fov u\\_continuity}, {\\fov v\\_continuity}, {\\fov u\\_surfnumb}, \n\t    {\\fov v\\_surfnumb}, {\\fov gauss\\_surf}, {\\fov stat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf \\> *{\\fov surf};\\\\\n                \\>\\>    int    \\>  {\\fov u\\_continuity};\\\\\n                \\>\\>    int    \\>  {\\fov v\\_continuity}1;\\\\\n                \\>\\>    int    \\>  *{\\fov u\\_surfnumb};\\\\\n                \\>\\>    int    \\>  *{\\fov v\\_surfnumb};\\\\\n                \\>\\>    SISLSurf \\> ***{\\fov gauss\\_surf};\\\\\n                \\>\\>    int    \\>  *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>  \\begin{minipg2}\n                     The original surface.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov u\\_continuity}\\> - \\>  \\begin{minipg2}\n                     Desired continuity of the Gaussian curvature surfaces\n                          in the u direction: $0$ implies positional continuity,\n                          $1$ implies tangential continuity, and so on.\n                          SISL only accepts surfaces of continuity 0 or higher.\n                          If the surface is to be intersected with another,\n                          the continuity must be 1 or higher to find all the\n                          intersection curves. If the requested continuity is higher than\n                          the minimum continuity of the surface in the first parameter\n                          direction minus 2, an approximation will be performed.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov v\\_continuity}\\> - \\>  \\begin{minipg2}\n                     Desired continuity of the Gaussian curvature surfaces\n                          in the v direction: $0$ implies positional continuity,\n                          $1$ implies tangential continuity, and so on.\n                          SISL only accepts surfaces of continuity 0 or higher.\n                          If the surface is to be intersected with another,\n                          the continuity must be 1 or higher to find all the\n                          intersection curves. If the requested continuity is higher than\n                          the minimum continuity of the surface in the second parameter\n                          direction minus 2, an approximation will be performed.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov u\\_surfnumb}\\> - \\>  \\begin{minipg2}\n                     Number of Gaussian curvature surface patches\n                          in the u direction.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov v\\_surfnumb}\\> - \\>  \\begin{minipg2}\n                     Number of Gaussian curvature surface patches\n                          in the v direction.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov gauss\\_surf}\\> - \\>  \\begin{minipg2}\n                     The Gaussian curvature interpolation surfaces.\n                          This will be a pointer to an array of length\n                          {\\fov u\\_surfnum} * {\\fov v\\_surfnumb} of\n                          SISLSurf pointers, where the indexing runs\n                          fastest in the u direction.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>   $> 0$  \\> : Warning.\\\\\n                \\>\\>\\>\\>   $= 2$  \\> : The surface is degenerate.\\\\\n                \\>\\>\\>\\>   $= 0$  \\> : Ok.\\\\\n                \\>\\>\\>\\>   $< 0$  \\> : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n                \\>\\>    SISLSurf \\> *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov u\\_continuity} = 0; /* Should depend on continuity of input\\\\\n               \\>\\>\\>\\>\\>\\> surface and the use of the result */\\\\\n                 \\>\\>    int    \\>  {\\fov v\\_continuity} = 0;\\\\\n                \\>\\>    int    \\>  {\\fov u\\_surfnumb} = 0;\\\\\n                \\>\\>    int    \\>  {\\fov v\\_surfnumb} = 0;\\\\\n                \\>\\>    SISLSurf \\> **{\\fov gauss\\_surf} = NULL;\\\\\n                \\>\\>    int    \\>  {\\fov stat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s2532(\\begin{minipg4}\n            {\\fov surf},  {\\fov u\\_continuity},  {\\fov v\\_continuity},  \\&{\\fov u\\_surfnumb}, \n\t    \\&{\\fov v\\_surfnumb}, \\&{\\fov gauss\\_surf}, \\&{\\fov stat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s2536.tex",
    "content": "\\subsection{Mehlum curvature of a B-spline or NURBS \n            surface as a NURBS surface.}\n\\funclabel{s2536}\n\\begin{minipg1}\nTo interpolate or approximate the Mehlum curvature of a B-spline or NURBS \n            surface by a NURBS surface. \n            The desired continuity of the Mehlum curvature surface is\n            input and this may lead to a patchwork of output surfaces. \n            Interpolation results in a high order surface.\n            If the original surface is a B-spline surface of order $k$,\n            the result is of order $12k-17$, in the NURBS case,\n            order $48k-53$.\n            To avoid instability beacuse of this, a maximum order is\n            applied. This may lead to an approximation rather than\n            an interpolation.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s2536(\\begin{minipg3}\n            {\\fov surf}, {\\fov u\\_continuity}, {\\fov v\\_continuity}, {\\fov u\\_surfnumb}, \n\t    {\\fov v\\_surfnumb}, {\\fov mehlum\\_surf}, {\\fov stat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf \\> *{\\fov surf};\\\\\n                \\>\\>    int    \\>  {\\fov u\\_continuity};\\\\\n                \\>\\>    int    \\>  {\\fov v\\_continuity};\\\\\n                \\>\\>    int    \\>  *{\\fov u\\_surfnumb};\\\\\n                \\>\\>    int    \\>  *{\\fov v\\_surfnumb};\\\\\n                \\>\\>    SISLSurf \\> ***{\\fov mehlum\\_surf};\\\\\n                \\>\\>    int    \\>  *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>  \\begin{minipg2}\n                     The original surface.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov u\\_continuity}\\> - \\>  \\begin{minipg2}\n                     Desired continuity of the Mehlum curvature surfaces\n                          in the u direction: $0$ implies positional continuity,\n                          $1$ implies tangential continuity, and so on.\n                          SISL only accepts surfaces of continuity 0 or higher.\n                          If the surface is to be intersected with another,\n                          the continuity must be 1 or higher to find all the\n                          intersection curves. If the requested continuity is higher than\n                          the minimum continuity of the surface in the first parameter\n                          direction minus 2, an approximation will be performed.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov v\\_continuity}\\> - \\>  \\begin{minipg2}\n                     Desired continuity of the Mehlum curvature surfaces\n                          in the v direction: $0$ implies positional continuity,\n                          $1$ implies tangential continuity, and so on.\n                          SISL only accepts surfaces of continuity 0 or higher.\n                          If the surface is to be intersected with another,\n                          the continuity must be 1 or higher to find all the\n                          intersection curves. If the requested continuity is higher than\n                          the minimum continuity of the surface in the second parameter\n                          direction minus 2, an approximation will be performed.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov u\\_surfnumb}\\> - \\>  \\begin{minipg2}\n                     Number of Mehlum curvature surface patches\n                          in the u direction.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov v\\_surfnumb}\\> - \\>  \\begin{minipg2}\n                     Number of Mehlum curvature surface patches\n                          in the v direction.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov mehlum\\_surf}\\> - \\>  \\begin{minipg2}\n                     The Mehlum curvature interpolation surfaces.\n                          This will be a pointer to an array of length\n                          {\\fov u\\_surfnum} * {\\fov v\\_surfnumb} of\n                          SISLSurf pointers, where the indexing runs\n                          fastest in the u direction.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>   $> 0$  \\> : Warning.\\\\\n                \\>\\>\\>\\>   $= 2$  \\> : The surface is degenerate.\\\\\n                \\>\\>\\>\\>   $= 0$  \\> : Ok.\\\\\n                \\>\\>\\>\\>   $< 0$  \\> : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLSurf \\> *{\\fov surf} \\, /* Must be defined */;\\\\\n                \\>\\>    int    \\>  {\\fov u\\_continuity} = 0; /* Should depend on continuity of input\\\\\n                \\>\\>\\>\\>\\>\\> surface and the use of the result */\\\\\n                \\>\\>    int    \\>  {\\fov v\\_continuity} = 0;\\\\\n                \\>\\>    int    \\>  {\\fov u\\_surfnumb} = 0;\\\\\n                \\>\\>    int    \\>  {\\fov v\\_surfnumb} = 0;\\\\\n                \\>\\>    SISLSurf \\> **{\\fov mehlum\\_surf} = NULL;\\\\\n                \\>\\>    int    \\>  {\\fov stat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s2536(\\begin{minipg4}\n            {\\fov surf},  {\\fov u\\_continuity},  {\\fov v\\_continuity},  \\&{\\fov u\\_surfnumb}, \n\t    \\&{\\fov v\\_surfnumb}, \\&{\\fov mehlum\\_surf}, \\&{\\fov stat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s2540.tex",
    "content": "\\subsection{Curvature on a uniform grid of a NURBS surface.}\n\\funclabel{s2540}\n\\begin{minipg1}\nTo compute a set of curvature values on a uniform grid \n            in a selected subset of the parameter domain of a NURBS surface.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s2540(\\begin{minipg3}\n            {\\fov surf}, {\\fov curvature\\_type},  {\\fov export\\_par\\_val},  {\\fov pick\\_subpart}, boundary[],  {\\fov n\\_u},  {\\fov n\\_v}, \n       {\\fov garr},  {\\fov stat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf \\> *{\\fov surf};\\\\\n                \\>\\>    int \\> {\\fov curvature\\_type};\\\\\n                \\>\\>    int \\> {\\fov export\\_par\\_val};\\\\\n                \\>\\>    int \\> {\\fov pick\\_subpart};\\\\\n                \\>\\>    double \\> {\\fov boundary}[\\,];\\\\\n                \\>\\>    int \\> {\\fov n\\_u};\\\\\n                \\>\\>    int \\> {\\fov n\\_v};\\\\\n                \\>\\>    double \\> **{\\fov garr};\\\\\n                \\>\\>    int \\> *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>  \\begin{minipg2}\n                     The surface to evaluate.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov curvature}\\> - \\>  \\begin{minipg2}\n                     The type of curvature:\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>\\>\\> $0$  \\> : Gaussian curvature.\\\\\n        \\>\\>\\>\\> $1$  \\> : Mean curvature.\\\\\n        \\>\\>\\>\\> $2$  \\> : Absolute curvature.\\\\\n        \\>\\>\\>\\> $3$  \\> : Total curvature.\\\\\n        \\>\\>\\>\\> $4$  \\> : Second order Mehlum curvature.\\\\\n        \\>\\>\\>\\> $5$  \\> : Third order Mehlum curvature.\\\\\n        \\>\\>    {\\fov export}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the parameter values\n                            of the grid points are to be exported:\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>\\>\\> $0$  \\> : False, do not export parameter values.\\\\\n        \\>\\>\\>\\> $1$  \\> : True, do export parameter values.\\\\\n        \\>\\>    {\\fov pick}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the grid is to be\n                            calculated on a subpart of the surface:\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>\\>\\> $0$  \\> : False, calculate grid on the complete surface.\\\\\n        \\>\\>\\>\\> $1$  \\> : True, calculate grid on a part of the surface.\\\\\n        \\>\\>    {\\fov boundary}\\> - \\>  \\begin{minipg2}\n                     A rectangular subset of the parameter domain.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>\\>\\> $0$  \\> : Minimum value in the first parameter.\\\\\n        \\>\\>\\>\\> $1$  \\> : Minimum value in the second parameter.\\\\\n        \\>\\>\\>\\> $2$  \\> : Maximum value in the first parameter.\\\\\n        \\>\\>\\>\\> $3$  \\> : Maximum value in the second parameter.\\\\\n        \\>\\>\\>\\> \\begin{minipg2}\n                            ONLY USED WHEN {\\fov pick\\_subpart} $= 1$.\n                            If {\\fov pick\\_subpart} $= 0$\n                            the parameter area of surf is returned here.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov n\\_u}\\> - \\>  \\begin{minipg2}\n                     Number of segments in the first parameter.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov n\\_v}\\> - \\>  \\begin{minipg2}\n                     Number of segments in the second parameter.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov garr}\\> - \\>  \\begin{minipg2}\n                     Array containing the computed values on the grid.\n\t\t     The allocation is done internally and the dimension \n\t\t    is  3*(n\\_u+1)*(n\\_v+1) if export\\_par\\_val is true,\n\t\t     and (n\\_u+1)*(n\\_v+1) if export\\_par\\_val is false.\n                     Each gridpoint consists of a triple \n                     $(u_i,v_j,curvature(u_i,v_j))$ or only $curvature(u_,v_j)$.\n\t\t     The sequence runs first in the first parameter.\n                              \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>   $> 0$  \\> : Warning.\\\\\n                \\>\\>\\>\\>   $= 0$  \\> : Ok.\\\\\n                \\>\\>\\>\\>   $< 0$  \\> : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n                \\>\\>    SISLSurf \\> *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    int \\> {\\fov curvature\\_type} = 1;\\\\\n                \\>\\>    int \\> {\\fov export\\_par\\_val} = 1 ;\\\\\n                \\>\\>    int \\> {\\fov pick\\_subpart} = 0;\\\\\n                \\>\\>    double \\> {\\fov boundary}[4]; \\, /* Must be defined if pick\\_subpart = 1 */\\\\\n                \\>\\>    int \\> {\\fov n\\_u} = 10;\\\\\n                \\>\\>    int \\> {\\fov n\\_v} = 10;\\\\\n                \\>\\>    double \\> *{\\fov garr} = NULL;\\\\ \n                \\>\\>    int \\> {\\fov stat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s2540(\\begin{minipg4}\n            {\\fov surf}, {\\fov curvature\\_type}, {\\fov export\\_par\\_val}, {\\fov pick\\_subpart}, {\\fov boundary}[], {\\fov n\\_u}, {\\fov n\\_v}, \n       \\&{\\fov garr}, \\&{\\fov stat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s2542.tex",
    "content": "\\subsection{Principal curvatures of a spline surface.}\n\\funclabel{s2542}\n\\begin{minipg1}\n To compute principal curvatures (k1,k2) with corresponding \n                   principal directions (d1,d2) of a spline surface at\n                   given values (u,v) $=$ (parvalue[0],parvalue[1]), where\n                   etl[leftknot1] $<=$ parvalue[0] $<$ etl[leftknot1+1] and\n                   et2[leftknot2] $<=$ parvalue[1] $<$ et2[leftknot2+1].\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>  void s2542(\\begin{minipg3}\n            {\\fov surf},  {\\fov ider},  {\\fov iside1},  {\\fov iside2},   {\\fov parvalue},  {\\fov leftknot1},  {\\fov leftknot2}, \n\t     {\\fov k1},  {\\fov k2},  {\\fov d1},  {\\fov d2},  {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf \\> *{\\fov surf};\\\\\n                \\>\\>    int    \\>  {\\fov ider};\\\\\n                \\>\\>    int    \\>  {\\fov iside1};\\\\\n                \\>\\>    int    \\>  {\\fov iside2};\\\\\n                \\>\\>    double \\> {\\fov parvalue}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov leftknot1};\\\\\n                \\>\\>    int \\> *{\\fov leftknot2};\\\\\n                \\>\\>    double \\> *{\\fov k1};\\\\\n                \\>\\>    double \\> *{\\fov k2};\\\\\n                \\>\\>    double \\> {\\fov d1}[\\,];\\\\\n                \\>\\>    double \\> {\\fov d2}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>  \\begin{minipg2}\n                     Pointer to the surface to evaluate.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ider}\\> - \\>  \\begin{minipg2}\n                     Number of derivatives to calculate.\n                     Only implemented for ider=0.\n                               \\end{minipg2}\\\\[0.8ex]\n                \\>\\>\\>\\>  $< 0$ : \\> No derivative calculated.\\\\\n                \\>\\>\\>\\>  $= 0$ : \\> Position calculated.\\\\\n                \\>\\>\\>\\>  $= 1$ : \\> Position and first derivative calculated, etc.\\\\\n        \\>\\>    {\\fov iside1}\\> - \\>  \\begin{minipg2}\n                  Flag indicating whether the principal curvature in the first\n                  parameter is to be calculated from the\n                     left or from the right:\n                               \\end{minipg2}\\\\[0.8ex]\n         \\>\\>\\>\\>  $< 0$  : \\> calculate curvature from the left hand side.\\\\\n         \\>\\>\\>\\>  $>= 0$ : \\> calculate curvature from the right hand side.\\\\\n        \\>\\>    {\\fov iside2}\\> - \\>  \\begin{minipg2}\n                  Flag indicating whether the principal curvature in the second\n                  parameter is to be calculated from the\n                     left or from the right:\n                               \\end{minipg2}\\\\[0.8ex]\n         \\>\\>\\>\\>  $< 0$  : \\> calculate curvature from the left hand side.\\\\\n         \\>\\>\\>\\>  $>= 0$ : \\> calculate curvature from the right hand side.\\\\\n        \\>\\>    {\\fov parvalue}\\> - \\>  \\begin{minipg2}\n                     Parameter value at which to evaluate. Dimension of\n                     parvalue is 2.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov leftknot1}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector in the\n                     first parameter direction where parvalue[0] is found,\n                     that is:\n                          et1[leftknot1] $<=$ parvalue[0] $<$ et1[leftknot1+1].\n                     leftknot1 should be set equal to zero at the first call\n                     to the routine.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov leftknot2}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector in the\n                     second parameter direction where parvalue[1] is found,\n                     that is:\n                          et2[leftknot2] $<=$ parvalue[1] $<$ et2[leftknot2+1].\n                     leftknot2 should be set equal to zero at the first call\n                     to the routine.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov k1}\\> - \\>  \\begin{minipg2}\n                     Max. principal curvature.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov k2}\\> - \\>  \\begin{minipg2}\n                     Min. principal curvature.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov d1}\\> - \\>  \\begin{minipg2}\n                     Max. direction of the principal curvature k1, given \n                     in local coordinates (with regard to Xu,Xv).\n                     Dim. $=$ 2.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov d2}\\> - \\>  \\begin{minipg2}\n                     Min. direction of the principal curvature k2, given \n                     in local coordinates (with regard to Xu,Xv).\n                     Dim. $=$ 2.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\> $= 2$ : \n                       \\> \\begin{minipg5}  \n                               Surface is degenerate at the point, that is,\n                               the surface is not regular at this point.\n                               \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>  $= 1$ :\n                       \\> \\begin{minipg5}  \n                               Surface is close to degenerate at the point.\n                               Angle between tangents is less than the angular\n                               tolerance.\n                               \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\> $= 0$ : \\> Ok.\\\\\n                \\>\\>\\>\\> $< 0$ : \\> Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLSurf \\> *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov ider} = 0;\\\\\n                \\>\\>    int    \\>  {\\fov iside1} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov iside2} = 1;\\\\\n                \\>\\>    double \\> {\\fov parvalue}[2]; \\, /* Must be defined */\\\\\n                \\>\\>    int \\> {\\fov leftknot1} = 0; /* Define initially as zero. For consequtive evaluations \\\\\n                \\>\\>\\>\\>\\>\\> leave leftknot1 as returned from s2542 \\\\\n                \\>\\>    int \\> {\\fov leftknot2} = 0; /* As for leftknot1 */\\\\\n                \\>\\>    double \\> {\\fov k1};\\\\\n                \\>\\>    double \\> {\\fov k2};\\\\\n                \\>\\>    double \\> {\\fov d1}[2];\\\\\n                \\>\\>    double \\> {\\fov d2}[2];\\\\\n                \\>\\>    int \\> {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\> \\>s2542(\\begin{minipg4}\n            {\\fov surf},  {\\fov ider},  {\\fov iside1},  {\\fov iside2},   {\\fov parvalue},  \\&{\\fov leftknot1},  \\&{\\fov leftknot2}, \n\t     \\&{\\fov k1},  \\&{\\fov k2},  {\\fov d1},  {\\fov d2},  \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s2544.tex",
    "content": "\\subsection{Normal curvature of a spline surface.}\n\\funclabel{s2544}\n\\begin{minipg1}\n To compute the Normal curvature of a splne surface at given\n                   values (u,v) $=$ (parvalue[0],parvalue[1]) in the\n                   direction (parvalue[2],parvalue[3])\n                   where\n                   et1[leftknot1] $<=$ parvalue[0] $<$ et1[leftknot1+1] and\n                   et2[leftknot2] $<=$ parvalue[1] $<$ et2[leftknot2+1].\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\>  void s2544(\\begin{minipg3}\n            {\\fov surf},  {\\fov ider},  {\\fov iside1},  {\\fov iside2},  {\\fov parvalue},  {\\fov leftknot1},  {\\fov leftknot2},  {\\fov norcurv},\n\t     {\\fov jstat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf \\> *{\\fov surf};\\\\\n                \\>\\>    int    \\>  {\\fov ider};\\\\\n                \\>\\>    int    \\>  {\\fov iside1};\\\\\n                \\>\\>    int    \\>  {\\fov iside2};\\\\\n                \\>\\>    double \\> {\\fov parvalue}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov leftknot1};\\\\\n                \\>\\>    int \\> *{\\fov leftknot2};\\\\\n                \\>\\>    double \\> {\\fov norcurv}[\\,];\\\\\n                \\>\\>    int \\> *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>  \\begin{minipg2}\n                     Pointer to the surface to evaluate.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov ider}\\> - \\>  \\begin{minipg2}\n                     Number of derivatives to calculate.\n                     Only implemented for ider=0.\n                               \\end{minipg2}\\\\[0.8ex]\n                \\>\\>\\>\\>  $< 0$ : \\> No derivative calculated.\\\\\n                \\>\\>\\>\\>  $= 0$ : \\> Position calculated.\\\\\n                \\>\\>\\>\\>  $= 1$ : \\> Position and first derivative calculated, etc.\\\\\n        \\>\\>    {\\fov iside1}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the derivatives in the first\n                     parameter direction are to be calculated from the\n                     left or from the right:\n                               \\end{minipg2}\\\\[0.8ex]\n         \\>\\>\\>\\>  $< 0$  : \\> calculate derivative from the left hand side.\\\\\n         \\>\\>\\>\\>  $>= 0$ : \\> calculate derivative from the right hand side.\\\\\n        \\>\\>    {\\fov iside2}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the derivatives in the second\n                     parameter direction are to be calculated from the\n                     left or from the right:\n                               \\end{minipg2}\\\\[0.8ex]\n         \\>\\>\\>\\>  $< 0$  : \\> calculate derivative from the left hand side.\\\\\n         \\>\\>\\>\\>  $>= 0$ : \\> calculate derivative from the right hand side.\\\\\n        \\>\\>    {\\fov parvalue}\\> - \\>  \\begin{minipg2}\n                     Parameter value at which to evaluate plus the direction.\n                     Dimension of parvalue is 4.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Input/Output Arguments:\\\\\n        \\>\\>    {\\fov leftknot1}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector in the\n                     first parameter direction where parvalue[0] is found,\n                     that is:\n                          et1[leftknot1] $<=$ parvalue[0] $<$ et1[leftknot1+1].\n                     leftknot1 should be set equal to zero at the first call\n                     to the routine.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov leftknot2}\\> - \\>  \\begin{minipg2}\n                     Pointer to the interval in the knot vector in the\n                     second parameter direction where parvalue[1] is found,\n                     that is:\n                          et2[leftknot2] $<=$ parvalue[1] $<$ et2[leftknot2+1].\n                     leftknot2 should be set equal to zero at the first call\n                     to the routine.\n                               \\end{minipg2}\\\\[0.8ex]\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov gaussian}\\> - \\>  \\begin{minipg2}\n                     Normal curvature and derivatives of normal curvature\n                     of the surface at (u,v) $=$ (parvalue[0],parvalue[1])\n                     in the direction (parvalue[2],parvalue[3]).\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov jstat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\> $= 2$ : \n                       \\> \\begin{minipg5}  \n                               Surface is degenerate at the point, that is,\n                               the surface is not regular at this point.\n                               \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>  $= 1$ :\n                       \\> \\begin{minipg5}  \n                               Surface is close to degenerate at the point.\n                               Angle between tangents is less than the angular\n                               tolerance.\n                               \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\> $= 0$ : \\> Ok.\\\\\n                \\>\\>\\>\\> $< 0$ : \\> Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLSurf \\> *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov ider} = 0;\\\\\n                \\>\\>    int    \\>  {\\fov iside1} = 1;\\\\\n                \\>\\>    int    \\>  {\\fov iside2} = 1;\\\\\n                \\>\\>    double \\> {\\fov parvalue}[2]; \\, /* Must be defined */\\\\\n                \\>\\>    int \\> {\\fov leftknot1} = 0;/* Define initially as zero. For consequtive evaluations \\\\\n                \\>\\>\\>\\>\\>\\> leave leftknot1 as returned from s2544 */ \\\\\n                \\>\\>    int \\> {\\fov leftknot2} = 0; /* As for leftknot1 */\\\\\n                \\>\\>    double \\> {\\fov norcurv}[1]; /* An allocated array with length ider is expected */\\\\\n                \\>\\>    int \\> {\\fov jstat};\\\\                \\>\\>    \\ldots \\\\\n        \\> \\>s2544(\\begin{minipg4}\n            {\\fov surf},  {\\fov ider},  {\\fov iside1},  {\\fov iside2},  {\\fov parvalue},  \\&{\\fov leftknot1},  \\&{\\fov leftknot2},  {\\fov norcurv},\n\t     \\&{\\fov jstat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s2545.tex",
    "content": "\\subsection{Focal values on a uniform grid of a NURBS surface.}\n\\funclabel{s2545}\n\\begin{minipg1}\nTo compute a set of focal values on a uniform grid\n            in a selected subset of the parameter domain of a\n            NURBS surface. A focal value is a surface position offset\n            by the surface curvature.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s2545(\\begin{minipg3}\n            {\\fov surf}, {\\fov curvature\\_type},  {\\fov export\\_par\\_val},  {\\fov pick\\_subpart}, boundary,  {\\fov n\\_u},  {\\fov n\\_v}, \n       {\\fov scale}, {\\fov garr},  {\\fov stat})\n                \\end{minipg3}\\\\\n                \\>\\>    SISLSurf \\> *{\\fov surf};\\\\\n                \\>\\>    int \\> {\\fov curvature\\_type};\\\\\n                \\>\\>    int \\> {\\fov export\\_par\\_val};\\\\\n                \\>\\>    int \\> {\\fov pick\\_subpart};\\\\\n                \\>\\>    double \\> {\\fov boundary}[\\,];\\\\\n                \\>\\>    int \\> {\\fov n\\_u};\\\\\n                \\>\\>    int \\> {\\fov n\\_v};\\\\\n                \\>\\>    double \\> {\\fov scale};\\\\\n                \\>\\>    double \\> **{\\fov garr};\\\\\n                \\>\\>    int \\> *{\\fov stat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov surf}\\> - \\>  \\begin{minipg2}\n                     The surface to evaluate.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov curvature}\\> - \\>  \\begin{minipg2}\n                     The type of curvature:\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>\\>\\> $0$  \\> : Gaussian curvature.\\\\\n        \\>\\>\\>\\> $1$  \\> : Mean curvature.\\\\\n        \\>\\>\\>\\> $2$  \\> : Absolute curvature.\\\\\n        \\>\\>\\>\\> $3$  \\> : Total curvature.\\\\\n        \\>\\>\\>\\> $4$  \\> : Second order Mehlum curvature.\\\\\n        \\>\\>\\>\\> $5$  \\> : Third order Mehlum curvature.\\\\\n        \\>\\>    {\\fov export}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the parameter values\n                            of the grid points are to be exported:\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>\\>\\> $0$  \\> : False, do not export parameter values.\\\\\n        \\>\\>\\>\\> $1$  \\> : True, do export parameter values.\\\\\n        \\>\\>    {\\fov pick}\\> - \\>  \\begin{minipg2}\n                     Flag indicating whether the grid is to be\n                            calculated on a subpart of the surface:\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>\\>\\> $0$  \\> : False, calculate grid on the complete surface.\\\\\n        \\>\\>\\>\\> $1$  \\> : True, calculate grid on a part of the surface.\\\\\n        \\>\\>    {\\fov boundary}\\> - \\>  \\begin{minipg2}\n                     A rectangular subset of the parameter domain.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>\\>\\> $0$  \\> : Minmum value in the first parameter.\\\\\n        \\>\\>\\>\\> $1$  \\> : Minmum value in the second parameter.\\\\\n        \\>\\>\\>\\> $2$  \\> : Maximum value in the first parameter.\\\\\n        \\>\\>\\>\\> $3$  \\> : Maximum value in the second parameter.\\\\\n        \\>\\>\\>\\> \\begin{minipg2}\n                            ONLY USED WHEN {\\fov pick\\_subpart} $= 1$.\n                            If {\\fov pick\\_subpart} $= 0$\n                            the parameter area of surf is returned here.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov n\\_u}\\> - \\>  \\begin{minipg2}\n                     Number of segments in the first parameter.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov n\\_v}\\> - \\>  \\begin{minipg2}\n                     Number of segments in the second parameter.\n                               \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov scale}\\> - \\>  \\begin{minipg2}\n                     Scaling factor.\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov garr}\\> - \\>  \\begin{minipg2}\n                     Array containing the computed values on the grid.\n\t\t     The allocation is done internally and the dimension \n\t\t     is  (dim+2)*(n\\_u+1)*(n\\_v+1) if export\\_par\\_val is \n                     true, and dim*(n\\_u+1)*(n\\_v+1) if export\\_par\\_val is\n                     false.\n                     Each gridpoint consists of dim $+$ 2 values\n                     $(u_i,v_j,x(u_i,v_j),...)$ or only the\n                     focal points $(x(u_i,v_j),....)$.\n\t\t     The sequence runs first in the first parameter.\n                              \\end{minipg2}\\\\[0.8ex]\n        \\>\\>    {\\fov stat}     \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>   $> 0$  \\> : Warning.\\\\\n                \\>\\>\\>\\>   $= 0$  \\> : Ok.\\\\\n                \\>\\>\\>\\>   $< 0$  \\> : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n                \\>\\>    SISLSurf \\> *{\\fov surf}; \\, /* Must be defined */\\\\\n                \\>\\>    int \\> {\\fov curvature\\_type} = 0;\\\\\n                \\>\\>    int \\> {\\fov export\\_par\\_val} = 1;\\\\\n                \\>\\>    int \\> {\\fov pick\\_subpart} 0;\\\\\n                \\>\\>    double \\> {\\fov boundary}[4]; \\, /* Must be defined if pick\\_subpart = 1*/\\\\\n                \\>\\>    int \\> {\\fov n\\_u} = 10;\\\\\n                \\>\\>    int \\> {\\fov n\\_v} = 10;\\\\\n                \\>\\>    double \\> {\\fov scale} = 1.0;\\\\\n                \\>\\>    double \\> *{\\fov garr} = NULL;\\\\ \n                \\>\\>    int \\> {\\fov stat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s2545(\\begin{minipg4}\n            {\\fov surf}, {\\fov curvature\\_type}, {\\fov export\\_par\\_val}, {\\fov pick\\_subpart}, {\\fov boundary}[], {\\fov n\\_u}, {\\fov n\\_v}, \n       {\\fov scale}, \\&{\\fov garr}, \\&{\\fov stat});\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s2550.tex",
    "content": "\\subsection{Evaluate the curvature of a curve at given parameter values.}\n\\funclabel{s2550}\n\\begin{minipg1}\nEvaluate the curvature of a curve at given parameter values\n               ax[ 0 ],...,ax[ num\\_ax - 1 ].\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s2550(\\begin{minipg3}\n             {\\fov curve},  {\\fov ax}, num\\_ {\\fov ax},  {\\fov curvature}, jstat )\n                \\end{minipg3}\\\\\n                \\>\\>    SISLCurve    \\>  *{\\fov curve};\\\\\n                \\>\\>    double    \\>  {\\fov ax}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov num}\\_ax;\\\\\n                \\>\\>    double    \\>  {\\fov curvature}[\\,];\\\\\n                \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}\\> - \\>  \\begin{minipg2}\n                     Pointer to the curve.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov ax}\\> - \\>  \\begin{minipg2}\n                     The parameter values\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov num}\\> - \\>  \\begin{minipg2}\n                     No. of parameter values\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov }\\> - \\>  \\begin{minipg2}\n             \n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov curvature}\\> - \\>  \\begin{minipg2}\n                     The \"num\\_ax\" curvature values computed\n                               \\end{minipg2}\\\\\n\n        \\>\\>    {\\fov jstat} \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>           $> 0$ : Warning.\\\\\n                \\>\\>\\>\\>\\>           $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\>           $< 0$ : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLCurve    \\>  *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double    \\>  {\\fov ax}[10]; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov num}\\_ax = 10;\\\\\n                \\>\\>    double    \\>  {\\fov curvature}[10]; /* Size equal to num\\_ax */\\\\\n                \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s2550(\\begin{minipg4}\n             {\\fov curve},  {\\fov ax}, num\\_ {\\fov ax},  {\\fov curvature}, \\&jstat );\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s2553.tex",
    "content": "\\subsection{Evaluate the torsion of a curve at given parameter values.}\n\\funclabel{s2553}\n\\begin{minipg1}\nEvaluate the torsion of a curve at given parameter values\n               ax[ 0 ],...,ax[ num\\_ax - 1 ].\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s2553(\\begin{minipg3}\n             {\\fov curve},  {\\fov ax}, num\\_ {\\fov ax},  {\\fov torsion}, jstat )\n                \\end{minipg3}\\\\\n                \\>\\>    SISLCurve    \\>  *{\\fov curve};\\\\\n                \\>\\>    double    \\>  {\\fov ax}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov num}\\_ax;\\\\\n                \\>\\>    double    \\>  {\\fov torsion}[\\,];\\\\\n                \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}\\> - \\>  \\begin{minipg2}\n                     Pointer to the curve.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov ax}\\> - \\>  \\begin{minipg2}\n                     The parameter values\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov num}\\> - \\>  \\begin{minipg2}\n                     No. of parameter values\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov }\\> - \\>  \\begin{minipg2}\n             \n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov torsion}\\> - \\>  \\begin{minipg2}\n                     The \"num\\_ax\" torsion values computed\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>           $> 0$ : Warning.\\\\\n                \\>\\>\\>\\>\\>           $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\>           $< 0$ : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLCurve    \\>  *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double    \\>  {\\fov ax}[10]; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov num}\\_ax = 10;\\\\\n                \\>\\>    double    \\>  {\\fov torsion}[10]; /* Size equal to num\\_ax */\\\\\n                \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s2553(\\begin{minipg4}\n             {\\fov curve},  {\\fov ax}, num\\_ {\\fov ax},  {\\fov torsion}, \\&jstat );\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s2556.tex",
    "content": "\\subsection{Evaluate the Variation of Curvature (VoC) of a curve at given parameter values.}\n\\funclabel{s2556}\n\\begin{minipg1}\nEvaluate the Variation of Curvature (VoC) of a curve\n               at given parameter values ax[ 0 ],...,ax[ num\\_ax - 1 ].\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s2556(\\begin{minipg3}\n             {\\fov curve},  {\\fov ax}, num\\_ {\\fov ax},  {\\fov VoC}, jstat )\n                \\end{minipg3}\\\\\n                \\>\\>    SISLCurve    \\>  *{\\fov curve};\\\\\n                \\>\\>    double    \\>  {\\fov ax}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov num}\\_ax;\\\\\n                \\>\\>    double    \\>  {\\fov VoC}[\\,];\\\\\n                \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}\\> - \\>  \\begin{minipg2}\n                     Pointer to the curve.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov ax}\\> - \\>  \\begin{minipg2}\n                     The parameter values\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov num}\\> - \\>  \\begin{minipg2}\n                     No. of parameter values\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov }\\> - \\>  \\begin{minipg2}\n             \n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov VoC}\\> - \\>  \\begin{minipg2}\n                     The \"num\\_ax\" Variation of Curvature (VoC) values computed\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>           $> 0$ : Warning.\\\\\n                \\>\\>\\>\\>\\>           $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\>           $< 0$ : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLCurve    \\>  *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double    \\>  {\\fov ax}[10]; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov num}\\_ax = 10;\\\\\n                \\>\\>    double    \\>  {\\fov VoC}[10]; /* Size equal to num\\_ax */\\\\\n                \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s2556(\\begin{minipg4}\n             {\\fov curve},  {\\fov ax}, num\\_ {\\fov ax},  {\\fov VoC}, \\&jstat );\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s2559.tex",
    "content": "\\subsection{Evaluate the Frenet Frame (t,n,b) of a curve at given parameter values.}\n\\funclabel{s2559}\n\\begin{minipg1}\nEvaluate the Frenet Frame (t,n,b) of a curve\n               at given parameter values ax[ 0 ],...,ax[ num\\_ax - 1 ].\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s2559(\\begin{minipg3}\n             {\\fov curve},  {\\fov ax}, num\\_ {\\fov ax},  {\\fov p},  {\\fov t},  {\\fov n},  {\\fov b}, jstat )\n                \\end{minipg3}\\\\\n                \\>\\>    SISLCurve    \\>  *{\\fov curve};\\\\\n                \\>\\>    double    \\>  {\\fov ax}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov num}\\_ax;\\\\\n                \\>\\>    double    \\>  {\\fov p}[\\,];\\\\\n                \\>\\>    double    \\>  {\\fov t}[\\,];\\\\\n                \\>\\>    double    \\>  {\\fov n}[\\,];\\\\\n                \\>\\>    double    \\>  {\\fov b}[\\,];\\\\\n                \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}\\> - \\>  \\begin{minipg2}\n                     Pointer to the curve.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov ax}\\> - \\>  \\begin{minipg2}\n                     The parameter values\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov num}\\> - \\>  \\begin{minipg2}\n                     No. of parameter values\n                               \\end{minipg2}\\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov }\\> - \\>  \\begin{minipg2}\n             \n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov t}\\> - \\>  \\begin{minipg2}\n                     The Frenet Frame (in 3D) computed. Each of the arrays\n                   (t,n,b) are of dim. 3*num\\_ax, and the data are\n                   stored like this: tx(ax[0]), ty(ax[0]), tz(ax[0]),\n                   ...,tx(ax[num\\_ax-1]), ty(ax[num\\_ax-1]), tz(ax[num\\_ax-1]).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov p}\\> - \\>  \\begin{minipg2}\n                     1 ]\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>           $> 0$ : Warning.\\\\\n                \\>\\>\\>\\>\\>           $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\>           $< 0$ : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLCurve    \\>  *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double    \\>  {\\fov ax}[10];\\\\\n                \\>\\>    int    \\>  {\\fov num}\\_ax = 10;\\\\\n                \\>\\>    double    \\>  {\\fov p}[10]; /* Size equal to num\\_ax */ \\\\\n                \\>\\>    double    \\>  {\\fov t}[10]; /* Size equal to num\\_ax */\\\\\n                \\>\\>    double    \\>  {\\fov n}[10]; /* Size equal to num\\_ax */\\\\\n                \\>\\>    double    \\>  {\\fov b}[10]; /* Size equal to num\\_ax */\\\\\n                \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s2559(\\begin{minipg4}\n             {\\fov curve},  {\\fov ax}, num\\_ {\\fov ax},  {\\fov p},  {\\fov t},  {\\fov n},  {\\fov b}, \\&jstat );\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s2562.tex",
    "content": "\\subsection{Evaluate geometric properties at given parameter values.}\n\\funclabel{s2562}\n\\begin{minipg1}\nEvaluate the 3D position, the Frenet Frame (t,n,b) and\n               geometric property (curvature, torsion or variation of\n               curvature) of a curve at given parameter values\n               ax[0],...,ax[num\\_ax-1].\n               These data are needed to produce spike plots (using the\n               Frenet Frame and the geometric property) and circular\n               tube plots (using circular in the normal plane (t,b),\n               where the radius is equal to the geometric property times\n               a scaling factor for visual effects).\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n        \\> void s2562(\\begin{minipg3}\n             {\\fov curve},  {\\fov ax}, num\\_ {\\fov ax}, val\\_ {\\fov flag},  {\\fov p},  {\\fov t},  {\\fov n},  {\\fov b},  {\\fov val}, jstat )\n                \\end{minipg3}\\\\\n                \\>\\>    SISLCurve    \\>  *{\\fov curve};\\\\\n                \\>\\>    double    \\>  {\\fov ax}[\\,];\\\\\n                \\>\\>    int    \\>  {\\fov num}\\_ax;\\\\\n                \\>\\>    int    \\>  {\\fov val}\\_flag;\\\\\n                \\>\\>    double    \\>  {\\fov p}[\\,];\\\\\n                \\>\\>    double    \\>  {\\fov t}[\\,];\\\\\n                \\>\\>    double    \\>  {\\fov n}[\\,];\\\\\n                \\>\\>    double    \\>  {\\fov b}[\\,];\\\\\n                \\>\\>    double    \\>  {\\fov val}[\\,];\\\\\n                \\>\\>    int    \\>  *{\\fov jstat};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n        \\>\\>    {\\fov curve}\\> - \\>  \\begin{minipg2}\n                     Pointer to the curve.\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov ax}\\> - \\>  \\begin{minipg2}\n                     The parameter values\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov num}\\> - \\>  \\begin{minipg2}\n                     No. of parameter values\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov val}\\> - \\> Compute geometric property \\\\\n\t        \\>\\>\\>\\>\\>      = 1  : curvature \\\\\n                \\>\\>\\>\\>\\>      = 2  : torsion \\\\\n\t\t\\>\\>\\>\\>\\>      = 3  : variation of curvature \\\\\n\\\\\n\t\\>Output Arguments:\\\\\n        \\>\\>    {\\fov }\\> - \\>  \\begin{minipg2}\n             \n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov t}\\> - \\>  \\begin{minipg2}\n                     The Frenet Frame (in 3D) computed. Each of the arrays\n                   (t,n,b) are of dim. 3*num\\_ax, and the data are\n                   stored like this: tx(ax[0]), ty(ax[0]), tz(ax[0]),\n                   ...,tx(ax[num\\_ax-1]), ty(ax[num\\_ax-1]), tz(ax[num\\_ax-1]).\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov p}\\> - \\>  \\begin{minipg2}\n                    1]\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov val}\\> - \\>  \\begin{minipg2}\n                      Geometric property (curvature, torsion or\n                  variation of curvature) of a curve at given parameter\n                  values ax[0],...,ax[num\\_ax-1].\n                               \\end{minipg2}\\\\\n        \\>\\>    {\\fov jstat} \\> - \\> Status messages\\\\\n                \\>\\>\\>\\>\\>           $> 0$ : Warning.\\\\\n                \\>\\>\\>\\>\\>           $= 0$ : Ok.\\\\\n                \\>\\>\\>\\>\\>           $< 0$ : Error.\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>      \\{ \\\\\n\n                \\>\\>    SISLCurve    \\>  *{\\fov curve}; \\, /* Must be defined */\\\\\n                \\>\\>    double    \\>  {\\fov ax}[10]; \\, /* Must be defined */\\\\\n                \\>\\>    int    \\>  {\\fov num}\\_ax = 10;\\\\\n                \\>\\>    int    \\>  {\\fov val}\\_flag = 1;\\\\\n                \\>\\>    double    \\>  {\\fov p}[30]; /* Size equal to dimension times num\\_ax */ \\\\\n                \\>\\>    double    \\>  {\\fov t}[30]; /* Size equal to dimension times num\\_ax */ \\\\\n                \\>\\>    double    \\>  {\\fov n}[30]; /* Size equal to dimension times num\\_ax */ \\\\\n                \\>\\>    double    \\>  {\\fov b}[30]; /* Size equal to dimension times num\\_ax */ \\\\\n                \\>\\>    double    \\>  {\\fov val}[10]; /* Size equal to num\\_ax */ \\\\\n                \\>\\>    int    \\>  {\\fov jstat} = 0;\\\\                \\>\\>    \\ldots \\\\\n        \\>\\>s2562(\\begin{minipg4}\n             {\\fov curve},  {\\fov ax}, num\\_ {\\fov ax}, val\\_ {\\fov flag},  {\\fov p},  {\\fov t},  {\\fov n},  {\\fov b},  {\\fov val}, \\&jstat );\n                \\end{minipg4}\\\\\n                \\>\\>    \\ldots \\\\\n\t\t\\>      \\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/s6shadepol.tex",
    "content": "\\subsection{Shade a polygon.}\n\\funclabel{s6shadepol}\n\\begin{minipg1}\n\tShade a polygon using Gouraud shading.\n\tThe polygon is represented by a sequence of points \n\t(vertices) and a normal to each point. \n\tOnly for dimension equal to 3.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s6shadepol(\\begin{minipg3}\n\t\t{\\fov points}, {\\fov numpoints})\n\t\t\\end{minipg3}\\\\[0.3ex]\n  \t\t\\>\\>\tdouble \\>\t{\\fov points}[\\,];\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov numpoints};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov points}\t\\> - \\> \\begin{minipg2}\n\t\t\t\tPoints and normals stored in sequence. \n\t\t\t\tie. $(x_{0},y_{0},z_{0},x^n_{0},y^n_{0},z^n_{0},\n\t\t\t\tx_{1},y_{1},z_{1},x^n_{1},y^n_{1},z^n_{1},\\ldots)$\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov numpoints}\\> - \\> \\begin{minipg2}\n\t\t\t\tNumber of points in the sequence.\n\t\t\t\t\\end{minipg2}\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n  \t\t\\>\\>\tdouble \\>\t{\\fov points[24]};\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov numpoints = 4};\\\\\n\t\t\\>\\> \\ldots \\\\\n\t\\>\\>s6shadepol(\\begin{minipg4}\n\t\t{\\fov points}, {\\fov numpoints})\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/func/secshade.tex",
    "content": "\\subsection{Shade a polygone.}\n\\funclabel{s6shadepol}\n\\begin{minipg1}\n\tShade a polygon using Gouraud shading.\n\tThe polygon is represented by a sequence of points \n\t(vertices) and a normal to each point. \n\tOnly for dimension equal 3.\n\\end{minipg1} \\\\ \\\\\nSYNOPSIS\\\\\n\t\\>void s6shadepol(\\begin{minipg3}\n\t\t{\\fov points}, {\\fov normals}, {\\fov numpoints})\n\t\t\\end{minipg3}\\\\[0.3ex]\n  \t\t\\>\\>\tdouble \\>\t{\\fov points}[\\,];\\\\\n  \t\t\\>\\>\tdouble \\>\t{\\fov normals}[\\,];\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov numpoints};\\\\\n\\\\\nARGUMENTS\\\\\n\t\\>Input Arguments:\\\\\n\t\\>\\>\t{\\fov points}\t\\> - \\> \\begin{minipg2}\n\t\t\t\tPoints in sequence. \n\t\t\t\tie. $(x_{0},y_{0},z_{0},x_{1},y_{1},z_{1},\\ldots)$\n\t\t\t\t\\end{minipg2}\\\\\n        \\>\\>    {\\fov normals }\\> - \\> \\begin{minipg2}\n\t\t\t\tNormals in sequence.\n\t\t\t\tie. $(x^n_{0},y^n_{0},z^n_{0},\n\t\t\t\tx^n_{1},y^n_{1},z^n_{1},\\ldots)$\n\t\t\t\t\\end{minipg2}\\\\\n\t\\>\\>\t{\\fov numpoints}\\> - \\> \\begin{minipg2}\n\t\t\t\tNumber of points in sequence.\n\t\t\t\t\\end{minipg2}\\\\\n\\\\\nEXAMPLE OF USE\\\\\n\t\t\\>\t\\{ \\\\\n  \t\t\\>\\>\tdouble \\>\t{\\fov points[12]};\\\\\n  \t\t\\>\\>\tdouble \\>\t{\\fov normals[12]};\\\\\n  \t\t\\>\\>\tint    \\>\t{\\fov numpoints = 4};\\\\\n\t\t\\>\\> \\ldots \\\\\n\t\\>\\>s6shadepol(\\begin{minipg4}\n\t\t{\\fov points}, {\\fov normals}, {\\fov numpoints})\n\t\t\t\\end{minipg4}\\\\\n\t\t\\>\\>\t\\ldots \\\\\n\t\t\\>\t\\}\n\\end{tabbing}\n\n\n\\subsection{Examples of s6shadepol().}\nIn the following example of s6shadepol() we have used line2()\nand line3() as drawing primitives. Instead of such move and draw\nfunction for simple lines there might be possibilities to use\na polyline() function.\n\n\n\\begin{tabbing}\n******\\=*****\\=*****\\=*****\\=*****\\=*****\\=    \\kill\n\tvoid s6shadepol(\\begin{minipg3}\n\t\t{\\fov points}, {\\fov normals}, {\\fov numpoints})\n\t\t\\end{minipg3}\\\\[0.3ex]\n  \t\t\\>\tdouble \\>\\>\t{\\fov points}[\\,];\\\\\n  \t\t\\>\tdouble \\>\\>\t{\\fov normals}[\\,];\\\\\n  \t\t\\>\tint    \\>\\>\t{\\fov numpoints};\\\\\n\\{ \\\\\n\\>  extern void line2(\\,);\\>\\>\\>\\> /* Local drawing function for dim=2. */\\\\\n\\>  extern void line3(\\,);\\>\\>\\>\\> /* Local drawing function for dim=3. */\\\\\n  \\\\\n\\>  double *pt;\\>\\>\\>\\>  /* Pointer to traverse points. */\\\\\n\\>  double *ptend;\\>\\>\\>\\>  /* Pointer to mark end of points. */\\\\\n  \\\\\n\\> if (dim==2)\\\\\n\\>\\{ \\\\\n\\>\\>  /* Move pen at start of the broken line.  */\\\\\n \\\\ \n\\>\\>  line2(points[0], points[1], 0);\\\\\n  \\\\\n\\>\\>  /* Draw sequence of line-segments.  */\\\\\n  \\\\\n\\>\\>  for (pt=points+2, ptend=points+2*numpoints ; pt$<$ptend; pt+=2)\\\\\n\\>\\>\\>    line2(pt[0], pt[1], 1);\\\\\n\\>\\} \\\\\n\\>  else if (dim==3)\\\\\n\\>\\{ \\\\\n\n\\>\\>  /* Move pen at start of the broken line.  */\\\\\n \\\\ \n\\>\\>  line3(points[0], points[1], points[2], 0);\\\\\n  \\\\\n\\>\\>  /* Draw sequence of line-segments.  */\\\\\n  \\\\\n\\>\\>  for (pt=points+3, ptend=points+3*numpoints ; pt$<$ptend; pt+=3)\\\\\n\\>\\>\\>    line3(pt[0], pt[1], pt[2], 1);\\\\\n\\>\\} \\\\\n  \\\\\n\\>  return; \\\\\n\\}                                   \n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/licensing_information.tex",
    "content": "\\appendix\n\n\n\\chapter{GNU AFFERO GENERAL PUBLIC LICENSE}\n\n\\begin{center}\n{\\parindent 0in\n  Version 3, 19 November 2007\n  \nCopyright \\copyright\\  2007 Free Software Foundation, Inc. \\texttt{https://fsf.org/}\n\n\\bigskip\nEveryone is permitted to copy and distribute verbatim copies of this\n\nlicense document, but changing it is not allowed.}\n\n\\end{center}\n\n\\renewcommand{\\abstractname}{Preamble}\n\\begin{abstract}\nThe GNU Affero General Public License is a free, copyleft license\nfor software and other kinds of works, specifically designed to ensure\ncooperation with the community in the case of network server software.\n\nThe licenses for most software and other practical works are\ndesigned to take away your freedom to share and change the works.  By\ncontrast, our General Public Licenses are intended to guarantee your\nfreedom to share and change all versions of a program--to make sure it\nremains free software for all its users.\n\nWhen we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\nDevelopers that use our General Public Licenses protect your rights\nwith two steps: (1) assert copyright on the software, and (2) offer\nyou this License which gives you legal permission to copy, distribute\nand/or modify the software.\n\nA secondary benefit of defending all users' freedom is that\nimprovements made in alternate versions of the program, if they\nreceive widespread use, become available for other developers to\nincorporate.  Many developers of free software are heartened and\nencouraged by the resulting cooperation.  However, in the case of\nsoftware used on network servers, this result may fail to come about.\nThe GNU General Public License permits making a modified version and\nletting the public access it on a server without ever releasing its\nsource code to the public.\n\nThe GNU Affero General Public License is designed specifically to\nensure that, in such cases, the modified source code becomes available\nto the community.  It requires the operator of a network server to\nprovide the source code of the modified version running there to the\nusers of that server.  Therefore, public use of a modified version, on\na publicly accessible server, gives the public access to the source\ncode of the modified version.\n\nAn older license, called the Affero General Public License and\npublished by Affero, was designed to accomplish similar goals.  This is\na different license, not a version of the Affero GPL, but Affero has\nreleased a new version of the Affero GPL which permits relicensing under\nthis license.\n\nThe precise terms and conditions for copying, distribution and\nmodification follow.\n\\end{abstract}\n\n\\begin{center}\n{\\Large \\sc Terms and Conditions}\n\\end{center}\n\n\n\\begin{enumerate}\n\n\\addtocounter{enumi}{-1}\n\n\\item Definitions.\n\n``This License'' refers to version 3 of the GNU Affero General Public License.\n\n``Copyright'' also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n``The Program'' refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as ``you''.  ``Licensees'' and\n``recipients'' may be individuals or organizations.\n\nTo ``modify'' a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a ``modified version'' of the\nearlier work or a work ``based on'' the earlier work.\n\nA ``covered work'' means either the unmodified Program or a work based\non the Program.\n\nTo ``propagate'' a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\nTo ``convey'' a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\nAn interactive user interface displays ``Appropriate Legal Notices''\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n\\item Source Code.\n\nThe ``source code'' for a work means the preferred form of the work\nfor making modifications to it.  ``Object code'' means any non-source\nform of a work.\n\nA ``Standard Interface'' means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\nThe ``System Libraries'' of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n``Major Component'', in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\nThe ``Corresponding Source'' for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\nThe Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\nThe Corresponding Source for a work in source code form is that\nsame work.\n\n\\item Basic Permissions.\n\nAll rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\nYou may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\nConveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n\\item Protecting Users' Legal Rights From Anti-Circumvention Law.\n\nNo covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\nWhen you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n\\item Conveying Verbatim Copies.\n\nYou may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\nYou may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n\\item Conveying Modified Source Versions.\n\nYou may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n  \\begin{enumerate}\n  \\item The work must carry prominent notices stating that you modified\n  it, and giving a relevant date.\n\n  \\item The work must carry prominent notices stating that it is\n  released under this License and any conditions added under section\n  7.  This requirement modifies the requirement in section 4 to\n  ``keep intact all notices''.\n\n  \\item You must license the entire work, as a whole, under this\n  License to anyone who comes into possession of a copy.  This\n  License will therefore apply, along with any applicable section 7\n  additional terms, to the whole of the work, and all its parts,\n  regardless of how they are packaged.  This License gives no\n  permission to license the work in any other way, but it does not\n  invalidate such permission if you have separately received it.\n\n  \\item If the work has interactive user interfaces, each must display\n  Appropriate Legal Notices; however, if the Program has interactive\n  interfaces that do not display Appropriate Legal Notices, your\n  work need not make them do so.\n\\end{enumerate}\nA compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n``aggregate'' if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n\\item Conveying Non-Source Forms.\n\nYou may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n  \\begin{enumerate}\n  \\item Convey the object code in, or embodied in, a physical product\n  (including a physical distribution medium), accompanied by the\n  Corresponding Source fixed on a durable physical medium\n  customarily used for software interchange.\n\n  \\item Convey the object code in, or embodied in, a physical product\n  (including a physical distribution medium), accompanied by a\n  written offer, valid for at least three years and valid for as\n  long as you offer spare parts or customer support for that product\n  model, to give anyone who possesses the object code either (1) a\n  copy of the Corresponding Source for all the software in the\n  product that is covered by this License, on a durable physical\n  medium customarily used for software interchange, for a price no\n  more than your reasonable cost of physically performing this\n  conveying of source, or (2) access to copy the\n  Corresponding Source from a network server at no charge.\n\n  \\item Convey individual copies of the object code with a copy of the\n  written offer to provide the Corresponding Source.  This\n  alternative is allowed only occasionally and noncommercially, and\n  only if you received the object code with such an offer, in accord\n  with subsection 6b.\n\n  \\item Convey the object code by offering access from a designated\n  place (gratis or for a charge), and offer equivalent access to the\n  Corresponding Source in the same way through the same place at no\n  further charge.  You need not require recipients to copy the\n  Corresponding Source along with the object code.  If the place to\n  copy the object code is a network server, the Corresponding Source\n  may be on a different server (operated by you or a third party)\n  that supports equivalent copying facilities, provided you maintain\n  clear directions next to the object code saying where to find the\n  Corresponding Source.  Regardless of what server hosts the\n  Corresponding Source, you remain obligated to ensure that it is\n  available for as long as needed to satisfy these requirements.\n\n  \\item Convey the object code using peer-to-peer transmission, provided\n  you inform other peers where the object code and Corresponding\n  Source of the work are being offered to the general public at no\n  charge under subsection 6d.\n  \\end{enumerate}\n\nA separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\nA ``User Product'' is either (1) a ``consumer product'', which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, ``normally used'' refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n``Installation Information'' for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\nIf you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\nThe requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\nCorresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n\\item Additional Terms.\n\n``Additional permissions'' are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\nWhen you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\nNotwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n  \\begin{enumerate}\n  \\item Disclaiming warranty or limiting liability differently from the\n  terms of sections 15 and 16 of this License; or\n\n  \\item Requiring preservation of specified reasonable legal notices or\n  author attributions in that material or in the Appropriate Legal\n  Notices displayed by works containing it; or\n\n  \\item Prohibiting misrepresentation of the origin of that material, or\n  requiring that modified versions of such material be marked in\n  reasonable ways as different from the original version; or\n\n  \\item Limiting the use for publicity purposes of names of licensors or\n  authors of the material; or\n\n  \\item Declining to grant rights under trademark law for use of some\n  trade names, trademarks, or service marks; or\n\n  \\item Requiring indemnification of licensors and authors of that\n  material by anyone who conveys the material (or modified versions of\n  it) with contractual assumptions of liability to the recipient, for\n  any liability that these contractual assumptions directly impose on\n  those licensors and authors.\n  \\end{enumerate}\n\nAll other non-permissive additional terms are considered ``further\nrestrictions'' within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\nIf you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\nAdditional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n\\item Termination.\n\nYou may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\nHowever, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\nMoreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\nTermination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n\\item Acceptance Not Required for Having Copies.\n\nYou are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n\\item Automatic Licensing of Downstream Recipients.\n\nEach time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\nAn ``entity transaction'' is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\nYou may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n\\item Patents.\n\nA ``contributor'' is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's ``contributor version''.\n\nA contributor's ``essential patent claims'' are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, ``control'' includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\nEach contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\nIn the following three paragraphs, a ``patent license'' is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To ``grant'' such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\nIf you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  ``Knowingly relying'' means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\nIf, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\nA patent license is ``discriminatory'' if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\nNothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n\\item No Surrender of Others' Freedom.\n\nIf conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n\\item Remote Network Interaction; Use with the GNU General Public License.\n\nNotwithstanding any other provision of this License, if you modify the\nProgram, your modified version must prominently offer all users interacting\nwith it remotely through a computer network (if your version supports such\ninteraction) an opportunity to receive the Corresponding Source of your\nversion by providing access to the Corresponding Source from a network\nserver at no charge, through some standard or customary means of\nfacilitating copying of software.  This Corresponding Source shall include\nthe Corresponding Source for any work covered by version 3 of the GNU\nGeneral Public License that is incorporated pursuant to the following\nparagraph.\n\nNotwithstanding any other provision of this License, you have permission to\nlink or combine any covered work with a work licensed under version 3 of\nthe GNU General Public License into a single combined work, and to convey\nthe resulting work.  The terms of this License will continue to apply to\nthe part which is the covered work, but the work with which it is combined\nwill remain governed by version 3 of the GNU General Public License.\n\n\\item Revised Versions of this License.\n\nThe Free Software Foundation may publish revised and/or new versions of\nthe GNU Affero General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\nEach version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU Affero General\nPublic License ``or any later version'' applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU Affero General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\nIf the Program specifies that a proxy can decide which future\nversions of the GNU Affero General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\nLater license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n\\item Disclaimer of Warranty.\n\n\\begin{sloppypar}\n THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\n APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE\n COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM ``AS IS''\n WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,\n INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\n MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE\n RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.\n SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL\n NECESSARY SERVICING, REPAIR OR CORRECTION.\n\\end{sloppypar}\n\n\\item Limitation of Liability.\n\n IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN\n WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES\n AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR\n DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL\n DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM\n (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED\n INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE\n OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH\n HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH\n DAMAGES.\n\n\\item Interpretation of Sections 15 and 16.\n\nIf the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n\\begin{center}\n{\\Large\\sc End of Terms and Conditions}\n\\end{center}\n\\pagebreak[2]\n\n\\section*{Appendix: How to Apply These Terms to Your New Programs}\n\nIf you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\nTo do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe ``copyright'' line and a pointer to where the full notice is found.\n\n{\\footnotesize\n\\begin{verbatim}\n<one line to give the program's name and a brief idea of what it does.>\n\nCopyright (C) <textyear>  <name of author>\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU Affero General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU Affero General Public License for more details.\n\nYou should have received a copy of the GNU Affero General Public License\nalong with this program.  If not, see <https://www.gnu.org/licenses/>.\n\\end{verbatim}\n}\n\nAlso add information on how to contact you by electronic and paper mail.\n\nIf your software can interact with users remotely through a computer\nnetwork, you should also make sure that it provides a way for users to\nget its source.  For example, if your program is a web application, its\ninterface could display a ``Source'' link that leads users to an archive\nof the code.  There are many ways you could offer source, and different\nsolutions will be better for different programs; see section 13 for the\nspecific requirements.\n\nYou should also get your employer (if you work as a programmer) or\nschool, if any, to sign a ``copyright disclaimer'' for the program, if\nnecessary.  For more information on this, and how to apply and follow\nthe GNU AGPL, see \\texttt{https://www.gnu.org/licenses/}.\n\n\\end{enumerate}\n\n\\end{document}\n\n%%% Local Variables:\n%%% mode: latex\n%%% TeX-master: t\n%%% End:\n\n"
  },
  {
    "path": "doc/manual/manual.aux",
    "content": "\\relax \n\\@writefile{toc}{\\contentsline {chapter}{\\numberline {1}Preface}{1}}\n\\@writefile{lof}{\\addvspace {10\\p@ }}\n\\@writefile{lot}{\\addvspace {10\\p@ }}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {1.1}The structure of this document}{1}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {1.2}The structure of the software package}{2}}\n\\newlabel{compile}{{1.2}{2}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {1.3}Licensing information}{2}}\n\\@writefile{toc}{\\contentsline {chapter}{\\numberline {2}General Introduction}{3}}\n\\@writefile{lof}{\\addvspace {10\\p@ }}\n\\@writefile{lot}{\\addvspace {10\\p@ }}\n\\newlabel{introduction}{{2}{3}}\n\\newlabel{syntax}{{2.1}{4}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {2.1}C Syntax Used in Manual}{4}}\n\\newlabel{dynamic}{{2.2}{4}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {2.2}Dynamic Allocation in SISL}{4}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {2.3}Creating the library}{6}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {2.4}An Example Program}{7}}\n\\newlabel{sec:exampleprog}{{2.4}{7}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {2.5}B-spline Curves}{10}}\n\\@writefile{lof}{\\contentsline {figure}{\\numberline {2.1}{\\ignorespaces A linear B-spline (order 2) defined by three knots.}}{11}}\n\\newlabel{curve1}{{2.1}{11}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {2.5.1}B-splines}{11}}\n\\@writefile{lof}{\\contentsline {figure}{\\numberline {2.2}{\\ignorespaces Linear B-splines of with multiple knots at one end.}}{12}}\n\\newlabel{curve2}{{2.2}{12}}\n\\@writefile{lof}{\\contentsline {figure}{\\numberline {2.3}{\\ignorespaces A B-spline curve of dimension 1 as a linear combination of a sequence of B-splines. Each B-spline (dashed) is scaled by a coefficient.}}{12}}\n\\newlabel{curve3}{{2.3}{12}}\n\\@writefile{lof}{\\contentsline {figure}{\\numberline {2.4}{\\ignorespaces A quadratic B-spline, the two linear B-splines and the corresponding lines (dashed) in the quadratic B-spline definition.}}{12}}\n\\newlabel{curve4}{{2.4}{12}}\n\\@writefile{lof}{\\contentsline {figure}{\\numberline {2.5}{\\ignorespaces Linear, quadratic, and cubic B-spline curves sharing the same control polygon. The control polygon is equal to the linear B-spline curve. The curves are planar, i.e. the space dimension is two.}}{13}}\n\\newlabel{curve5}{{2.5}{13}}\n\\@writefile{lof}{\\contentsline {figure}{\\numberline {2.6}{\\ignorespaces The cubic B-spline curve with a redefined knot vector.}}{13}}\n\\newlabel{curve6}{{2.6}{13}}\n\\newlabel{contrlpoly}{{2.5.2}{13}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {2.5.2}The Control Polygon}{13}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {2.5.3}The Knot Vector}{13}}\n\\@writefile{lof}{\\contentsline {figure}{\\numberline {2.7}{\\ignorespaces Two quadratic B-spline curves with the same control polygon but different knot vectors. The curves and the control polygons are two-dimensional.}}{14}}\n\\newlabel{curve7}{{2.7}{14}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {2.5.4}NURBS Curves}{14}}\n\\@writefile{lof}{\\contentsline {figure}{\\numberline {2.8}{\\ignorespaces A quadratic B-spline curve with two equal internal knots.}}{15}}\n\\newlabel{curve8}{{2.8}{15}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {2.6}B-spline Surfaces}{15}}\n\\@writefile{lof}{\\contentsline {figure}{\\numberline {2.9}{\\ignorespaces  A B-spline surface and its control net. The surface is drawn using isocurves. The dimension is 3.}}{16}}\n\\newlabel{surf1}{{2.9}{16}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {2.6.1}The Basis Functions}{16}}\n\\@writefile{lof}{\\contentsline {figure}{\\numberline {2.10}{\\ignorespaces  A basis function of degree one in both variables.}}{17}}\n\\newlabel{surf2}{{2.10}{17}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {2.6.2}NURBS Surfaces}{17}}\n\\@writefile{toc}{\\contentsline {chapter}{\\numberline {3}Curve Definition}{18}}\n\\@writefile{lof}{\\addvspace {10\\p@ }}\n\\@writefile{lot}{\\addvspace {10\\p@ }}\n\\newlabel{curvedefinition}{{3}{18}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {3.1}Interpolation}{18}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.1.1}Compute a curve interpolating a straight line between two points.}{18}}\n\\newlabel{s1602}{{3.1.1}{18}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.1.2}Compute a curve interpolating a set of points, \\unhbox \\voidb@x \\hbox {automatic} parameterization.}{20}}\n\\newlabel{s1356}{{3.1.2}{20}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.1.3}Compute a curve interpolating a set of points, parameter\\-ization as input.}{22}}\n\\newlabel{s1357}{{3.1.3}{22}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.1.4}\\tolerance 9999\\emergencystretch 3em\\hfuzz .5\\p@ \\vfuzz \\hfuzz Compute a curve by Hermite interpolation, automatic parameteriza\\-tion.}{25}}\n\\newlabel{s1380}{{3.1.4}{25}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.1.5}Compute a curve by Hermite interpolation, parameter\\-ization as input.}{27}}\n\\newlabel{s1379}{{3.1.5}{27}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.1.6}Compute a fillet curve based on parameter value.}{29}}\n\\newlabel{s1607}{{3.1.6}{29}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.1.7}Compute a fillet curve based on points.}{31}}\n\\newlabel{s1608}{{3.1.7}{31}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.1.8}Compute a fillet curve based on radius.}{33}}\n\\newlabel{s1609}{{3.1.8}{33}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.1.9}Compute a circular fillet between a 2D curve and a circle.}{36}}\n\\newlabel{s1014}{{3.1.9}{36}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.1.10}Compute a circular fillet between two 2D curves.}{38}}\n\\newlabel{s1015}{{3.1.10}{38}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.1.11}Compute a circular fillet between a 2D curve and a 2D line.}{40}}\n\\newlabel{s1016}{{3.1.11}{40}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.1.12}Compute a blending curve between two curves.}{42}}\n\\newlabel{s1606}{{3.1.12}{42}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {3.2}Approximation}{44}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.2.1}Approximate a circular arc with a curve.}{44}}\n\\newlabel{s1303}{{3.2.1}{44}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.2.2}Approximate a conic arc with a curve.}{46}}\n\\newlabel{s1611}{{3.2.2}{46}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.2.3}Compute a curve using the input points as controlling \\unhbox \\voidb@x \\hbox {vertices}, automatic parameterization.}{48}}\n\\newlabel{s1630}{{3.2.3}{48}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.2.4}Approximate the offset of a curve with a curve.}{50}}\n\\newlabel{s1360}{{3.2.4}{50}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.2.5}Approximate a curve with a sequence of straight lines.}{52}}\n\\newlabel{s1613}{{3.2.5}{52}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {3.3}Mirror a Curve}{53}}\n\\newlabel{s1600}{{3.3}{53}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {3.4}Conversion}{54}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.4.1}Convert a curve of order up to four, to a sequence of cubic polynomials.}{54}}\n\\newlabel{s1389}{{3.4.1}{54}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.4.2}Convert a curve to a sequence of Bezier curves.}{55}}\n\\newlabel{s1730}{{3.4.2}{55}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.4.3}Pick out the next Bezier curve from a curve.}{56}}\n\\newlabel{s1732}{{3.4.3}{56}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.4.4}Express a curve using a higher order basis.}{58}}\n\\newlabel{s1750}{{3.4.4}{58}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.4.5}Express the ``i''-th derivative of an open curve as a curve.}{59}}\n\\newlabel{s1720}{{3.4.5}{59}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.4.6}Express a 2D or 3D ellipse as a curve.}{60}}\n\\newlabel{s1522}{{3.4.6}{60}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.4.7}Express a conic arc as a curve.}{62}}\n\\newlabel{s1011}{{3.4.7}{62}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {3.4.8}Express a truncated helix as a curve.}{64}}\n\\newlabel{s1012}{{3.4.8}{64}}\n\\@writefile{toc}{\\contentsline {chapter}{\\numberline {4}Curve Interrogation}{66}}\n\\@writefile{lof}{\\addvspace {10\\p@ }}\n\\@writefile{lot}{\\addvspace {10\\p@ }}\n\\newlabel{curveinterrogation}{{4}{66}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {4.1}Intersections}{66}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.1.1}Intersection between a curve and a point.}{66}}\n\\newlabel{s1871}{{4.1.1}{66}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.1.2}\\tolerance 9999\\emergencystretch 3em\\hfuzz .5\\p@ \\vfuzz \\hfuzz Intersection between a spline curve and a straight line or a plane.}{68}}\n\\newlabel{s1850}{{4.1.2}{68}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.1.3}Convert a curve/line intersection into a two-dimensional curve/origo intersection}{70}}\n\\newlabel{s1327}{{4.1.3}{70}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.1.4}Intersection between a spline curve and a 2D circle or a sphere.}{71}}\n\\newlabel{s1371}{{4.1.4}{71}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.1.5}Intersection between a curve and a quadric curve.}{73}}\n\\newlabel{s1374}{{4.1.5}{73}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.1.6}\\tolerance 9999\\emergencystretch 3em\\hfuzz .5\\p@ \\vfuzz \\hfuzz Intersection between two curves.}{75}}\n\\newlabel{s1857}{{4.1.6}{75}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {4.2}Compute the Length of a Curve}{77}}\n\\newlabel{s1240}{{4.2}{77}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {4.3}Check if a Curve is Closed}{78}}\n\\newlabel{s1364}{{4.3}{78}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {4.4}Check if a Curve is Degenerated.}{79}}\n\\newlabel{s1451}{{4.4}{79}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {4.5}Pick the Parameter Range of a Curve}{80}}\n\\newlabel{s1363}{{4.5}{80}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {4.6}Closest Points}{81}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.6.1}Find the closest point between a curve and a point.}{81}}\n\\newlabel{s1953}{{4.6.1}{81}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.6.2}Find the closest point between a curve and a point. Simple version.}{83}}\n\\newlabel{s1957}{{4.6.2}{83}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.6.3}Local iteration to closest point between point and curve.}{85}}\n\\newlabel{s1774}{{4.6.3}{85}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.6.4}Find the closest points between two curves.}{87}}\n\\newlabel{s1955}{{4.6.4}{87}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.6.5}Find a point on a 2D curve along a given direction.}{89}}\n\\newlabel{s1013}{{4.6.5}{89}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {4.7}Find the Absolute Extremals of a Curve.}{90}}\n\\newlabel{s1920}{{4.7}{90}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {4.8}Area between Curve and Point}{92}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.8.1}Calculate the area between a 2D curve and a 2D point.}{92}}\n\\newlabel{s1241}{{4.8.1}{92}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.8.2}Calculate the weight point and rotational momentum of an area between a 2D curve and a 2D point.}{93}}\n\\newlabel{s1243}{{4.8.2}{93}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {4.9}Bounding Box}{95}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.9.1}Bounding box object.}{95}}\n\\newlabel{sec:bbox}{{4.9.1}{95}}\n\\newlabel{SISLBox}{{4.9.1}{95}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.9.2}Create and initialize a curve/surface bounding box instance.}{96}}\n\\newlabel{newbox}{{4.9.2}{96}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.9.3}Find the bounding box of a curve.}{97}}\n\\newlabel{s1988}{{4.9.3}{97}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {4.10}Normal Cone}{98}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.10.1}Normal cone object.}{98}}\n\\newlabel{sec:dcone}{{4.10.1}{98}}\n\\newlabel{SISLDir}{{4.10.1}{98}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.10.2}Create and initialize a curve/surface direction instance.}{99}}\n\\newlabel{newdir}{{4.10.2}{99}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {4.10.3}Find the direction cone of a curve.}{100}}\n\\newlabel{s1986}{{4.10.3}{100}}\n\\@writefile{toc}{\\contentsline {chapter}{\\numberline {5}Curve Analysis}{101}}\n\\@writefile{lof}{\\addvspace {10\\p@ }}\n\\@writefile{lot}{\\addvspace {10\\p@ }}\n\\newlabel{curveanalysis}{{5}{101}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {5.1}Curvature Evaluation}{101}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {5.1.1}Evaluate the curvature of a curve at given parameter values.}{101}}\n\\newlabel{s2550}{{5.1.1}{101}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {5.1.2}Evaluate the torsion of a curve at given parameter values.}{103}}\n\\newlabel{s2553}{{5.1.2}{103}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {5.1.3}Evaluate the Variation of Curvature (VoC) of a curve at given parameter values.}{104}}\n\\newlabel{s2556}{{5.1.3}{104}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {5.1.4}Evaluate the Frenet Frame (t,n,b) of a curve at given parameter values.}{105}}\n\\newlabel{s2559}{{5.1.4}{105}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {5.1.5}Evaluate geometric properties at given parameter values.}{106}}\n\\newlabel{s2562}{{5.1.5}{106}}\n\\@writefile{toc}{\\contentsline {chapter}{\\numberline {6}Curve Utilities}{108}}\n\\@writefile{lof}{\\addvspace {10\\p@ }}\n\\@writefile{lot}{\\addvspace {10\\p@ }}\n\\newlabel{curveutilities}{{6}{108}}\n\\newlabel{curveobject}{{6.1}{108}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {6.1}Curve Object}{108}}\n\\newlabel{SISLCurve}{{6.1}{108}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {6.1.1}Create new curve object.}{110}}\n\\newlabel{sec:newCurve}{{6.1.1}{110}}\n\\newlabel{newCurve}{{6.1.1}{110}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {6.1.2}Make a copy of a curve.}{112}}\n\\newlabel{copyCurve}{{6.1.2}{112}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {6.1.3}Delete a curve object.}{113}}\n\\newlabel{sec:freeCurve}{{6.1.3}{113}}\n\\newlabel{freeCurve}{{6.1.3}{113}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {6.2}Evaluation}{114}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {6.2.1}Compute the position and the left-hand derivatives of a curve at a given parameter value.}{114}}\n\\newlabel{s1227}{{6.2.1}{114}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {6.2.2}Compute the position and the right-hand derivatives of a curve at a given parameter value.}{116}}\n\\newlabel{s1221}{{6.2.2}{116}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {6.2.3}Evaluate position, first derivative, curvature and radius of curvature of a curve at a given parameter value, from the left hand side.}{118}}\n\\newlabel{s1225}{{6.2.3}{118}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {6.2.4}Evaluate position, first derivative, curvature and radius of curvature of a curve at a given parameter value, from the right hand side.}{120}}\n\\newlabel{s1226}{{6.2.4}{120}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {6.2.5}Evaluate the curve over a grid of m points. Only positions are evaluated.}{122}}\n\\newlabel{s1542}{{6.2.5}{122}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {6.3}Subdivision}{122}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {6.3.1}Subdivide a curve at a given parameter value.}{122}}\n\\newlabel{s1710}{{6.3.1}{122}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {6.3.2}Insert a given knot into the description of a curve.}{125}}\n\\newlabel{s1017}{{6.3.2}{125}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {6.3.3}Insert a given set of knots into the description of a curve.}{126}}\n\\newlabel{s1018}{{6.3.3}{126}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {6.3.4}Split a curve into two new curves.}{127}}\n\\newlabel{s1714}{{6.3.4}{127}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {6.3.5}Pick a part of a curve.}{128}}\n\\newlabel{s1712}{{6.3.5}{128}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {6.3.6}Pick a part of a closed curve.}{129}}\n\\newlabel{s1713}{{6.3.6}{129}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {6.4}Joining}{130}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {6.4.1}Join two curves at specified ends.}{130}}\n\\newlabel{s1715}{{6.4.1}{130}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {6.4.2}Join two curves at closest ends.}{132}}\n\\newlabel{s1716}{{6.4.2}{132}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {6.5}Reverse the Orientation of a Curve.}{133}}\n\\newlabel{s1706}{{6.5}{133}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {6.6}Extend a B-spline Curve.}{134}}\n\\newlabel{s1233}{{6.6}{134}}\n\\@writefile{toc}{\\contentsline {chapter}{\\numberline {7}Surface Definition}{136}}\n\\@writefile{lof}{\\addvspace {10\\p@ }}\n\\@writefile{lot}{\\addvspace {10\\p@ }}\n\\newlabel{surfacedefinition}{{7}{136}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {7.1}Interpolation}{136}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.1.1}Compute a surface interpolating a set of points, automatic parameterization.}{136}}\n\\newlabel{s1536}{{7.1.1}{136}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.1.2}Compute a surface interpolating a set of points, parameterization as input.}{139}}\n\\newlabel{s1537}{{7.1.2}{139}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.1.3}Compute a surface interpolating a set of points, derivatives as input.}{142}}\n\\newlabel{s1534}{{7.1.3}{142}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.1.4}Compute a surface interpolating a set of points, derivatives and parameterization as input.}{145}}\n\\newlabel{s1535}{{7.1.4}{145}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.1.5}\\tolerance 9999\\emergencystretch 3em\\hfuzz .5\\p@ \\vfuzz \\hfuzz Compute a surface by Hermite interpolation, automatic parameter\\-ization.}{148}}\n\\newlabel{s1529}{{7.1.5}{148}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.1.6}Compute a surface by Hermite interpolation, parameter\\-ization as input.}{150}}\n\\newlabel{s1530}{{7.1.6}{150}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.1.7}Create a lofted surface from a set of B-spline input curves.}{152}}\n\\newlabel{s1538}{{7.1.7}{152}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.1.8}Create a lofted surface from a set of B-spline input curves and parametrization.}{154}}\n\\newlabel{s1539}{{7.1.8}{154}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.1.9}Create a rational lofted surface from a set of rational input-curves}{156}}\n\\newlabel{s1508}{{7.1.9}{156}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.1.10}Compute a rectangular blending surface from a set of \\unhbox \\voidb@x \\hbox {B-spline} input curves.}{157}}\n\\newlabel{s1390}{{7.1.10}{157}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.1.11}Compute a first derivative continuous blending surface set, over a 3-, 4-, 5- or 6-sided region in space, from a set of B-spline input curves.}{159}}\n\\newlabel{s1391}{{7.1.11}{159}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.1.12}Compute a surface, representing a Gordon patch, from a set of B-spline input curves.}{161}}\n\\newlabel{s1401}{{7.1.12}{161}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {7.2}Approximation}{163}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.2.1}Compute a surface using the input points as control vertices, automatic parameterization.}{163}}\n\\newlabel{s1620}{{7.2.1}{163}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.2.2}Compute a linear swept surface.}{165}}\n\\newlabel{s1332}{{7.2.2}{165}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.2.3}Compute a rotational swept surface.}{166}}\n\\newlabel{s1302}{{7.2.3}{166}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.2.4}Compute a surface approximating the offset of a surface.}{168}}\n\\newlabel{s1365}{{7.2.4}{168}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {7.3}Mirror a Surface}{170}}\n\\newlabel{s1601}{{7.3}{170}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {7.4}Conversion}{171}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.4.1}Convert a surface of order up to four to a mesh of Coons patches.}{171}}\n\\newlabel{s1388}{{7.4.1}{171}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.4.2}Convert a surface to a mesh of Bezier surfaces.}{173}}\n\\newlabel{s1731}{{7.4.2}{173}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.4.3}Pick the next Bezier surface from a surface.}{174}}\n\\newlabel{s1733}{{7.4.3}{174}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.4.4}Express a surface using a higher order basis.}{176}}\n\\newlabel{s1387}{{7.4.4}{176}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.4.5}Express the ``i,j''-th derivative of an open surface as a \\unhbox \\voidb@x \\hbox {surface}.}{177}}\n\\newlabel{s1386}{{7.4.5}{177}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.4.6}Express the octants of a sphere as a surface.}{178}}\n\\newlabel{s1023}{{7.4.6}{178}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.4.7}Express a truncated cylinder as a surface.}{180}}\n\\newlabel{s1021}{{7.4.7}{180}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.4.8}Express the octants of a torus as a surface.}{181}}\n\\newlabel{s1024}{{7.4.8}{181}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {7.4.9}Express a truncated cone as a surface.}{183}}\n\\newlabel{s1022}{{7.4.9}{183}}\n\\@writefile{toc}{\\contentsline {chapter}{\\numberline {8}Surface Interrogation}{185}}\n\\@writefile{lof}{\\addvspace {10\\p@ }}\n\\@writefile{lot}{\\addvspace {10\\p@ }}\n\\newlabel{surfaceinterrogation}{{8}{185}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {8.1}Intersection Curves}{185}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.1.1}Intersection curve object.}{185}}\n\\newlabel{SISLIntcurve}{{8.1.1}{185}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.1.2}Create a new intersection curve object.}{187}}\n\\newlabel{newIntcurve}{{8.1.2}{187}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.1.3}Delete an intersection curve object.}{189}}\n\\newlabel{freeIntcurve}{{8.1.3}{189}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.1.4}Free a list of intersection curves.}{190}}\n\\newlabel{sec:freeIntcrvlist}{{8.1.4}{190}}\n\\newlabel{freeIntcrvlist}{{8.1.4}{190}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {8.2}Find the Intersections}{191}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.2.1}\\tolerance 9999\\emergencystretch 3em\\hfuzz .5\\p@ \\vfuzz \\hfuzz Intersection between a spline curve and a straight line or a plane.}{191}}\n\\newlabel{s1850}{{8.2.1}{191}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.2.2}Intersection between a spline curve and a 2D circle or a sphere.}{193}}\n\\newlabel{s1371}{{8.2.2}{193}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.2.3}Intersection between a spline curve and a cylinder.}{195}}\n\\newlabel{s1372}{{8.2.3}{195}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.2.4}Intersection between a spline curve and a cone.}{197}}\n\\newlabel{sec:s1373}{{8.2.4}{197}}\n\\newlabel{s1373}{{8.2.4}{197}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.2.5}Intersection between a spline curve and an elliptic cone.}{199}}\n\\newlabel{s1502}{{8.2.5}{199}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.2.6}Intersection between a curve and a torus.}{201}}\n\\newlabel{s1375}{{8.2.6}{201}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.2.7}Intersection between a surface and a point.}{203}}\n\\newlabel{s1870}{{8.2.7}{203}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.2.8}Intersection between a spline surface and a straight line.}{205}}\n\\newlabel{s1856}{{8.2.8}{205}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.2.9}Newton iteration on the intersection between a 3D NURBS surface and a line.}{207}}\n\\newlabel{s1518}{{8.2.9}{207}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.2.10}Convert a surface/line intersection into a two-dimensional surface/origo intersection}{209}}\n\\newlabel{s1328}{{8.2.10}{209}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.2.11}Intersection between a spline surface and a circle.}{210}}\n\\newlabel{s1855}{{8.2.11}{210}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.2.12}Intersection between a surface and a curve.}{212}}\n\\newlabel{s1858}{{8.2.12}{212}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {8.3}Find the Topology of the Intersection}{214}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.3.1}Find the topology for the intersections between a spline surface and a plane.}{214}}\n\\newlabel{s1851}{{8.3.1}{214}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.3.2}Find the topology for the intersection between a spline surface and a sphere.}{216}}\n\\newlabel{s1852}{{8.3.2}{216}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.3.3}Find the topology for the intersections between a spline surface and a cylinder.}{218}}\n\\newlabel{s1853}{{8.3.3}{218}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.3.4}Find the topology for the intersections between a spline surface and a cone.}{220}}\n\\newlabel{s1854}{{8.3.4}{220}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.3.5}Find the topology for the intersections between a spline surface and an \\unhbox \\voidb@x \\hbox {elliptic} cone.}{222}}\n\\newlabel{s1503}{{8.3.5}{222}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.3.6}Find the topology for the intersections between a spline surface and a \\unhbox \\voidb@x \\hbox {torus}.}{224}}\n\\newlabel{s1369}{{8.3.6}{224}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.3.7}Find the topology for the intersection between two spline surfaces.}{226}}\n\\newlabel{s1859}{{8.3.7}{226}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {8.4}Find the Topology of a Silhouette}{228}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.4.1}Find the topology of the silhouette curves of a spline surface, using parallel projection.}{228}}\n\\newlabel{s1860}{{8.4.1}{228}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.4.2}Find the topology of the silhouette curves of a spline surface, using perspective projection.}{230}}\n\\newlabel{s1510}{{8.4.2}{230}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.4.3}Find the topology of the circular silhouette curves of a spline \\unhbox \\voidb@x \\hbox {surface}.}{232}}\n\\newlabel{s1511}{{8.4.3}{232}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {8.5}Marching}{234}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.5.1}March an intersection curve between a spline surface and a plane.}{234}}\n\\newlabel{s1314}{{8.5.1}{234}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.5.2}March an intersection curve between a spline surface and a sphere.}{236}}\n\\newlabel{s1315}{{8.5.2}{236}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.5.3}March an intersection curve between a spline surface and a \\unhbox \\voidb@x \\hbox {cylinder}.}{238}}\n\\newlabel{s1316}{{8.5.3}{238}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.5.4}March an intersection curve between a spline surface and a cone.}{240}}\n\\newlabel{s1317}{{8.5.4}{240}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.5.5}March an intersection curve between a surface and an \\unhbox \\voidb@x \\hbox {elliptic} cone.}{242}}\n\\newlabel{s1501}{{8.5.5}{242}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.5.6}March an intersection curve between a spline surface and a torus.}{245}}\n\\newlabel{s1318}{{8.5.6}{245}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.5.7}March an intersection curve between two spline surfaces.}{248}}\n\\newlabel{s1310}{{8.5.7}{248}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {8.6}Marching of Silhouettes}{250}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.6.1}\\tolerance 9999\\emergencystretch 3em\\hfuzz .5\\p@ \\vfuzz \\hfuzz March a silhouette curve of a surface, using parallel \\unhbox \\voidb@x \\hbox {projection}.}{250}}\n\\newlabel{s1319}{{8.6.1}{250}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.6.2}\\tolerance 9999\\emergencystretch 3em\\hfuzz .5\\p@ \\vfuzz \\hfuzz March a silhouette curve of a surface, using perspective \\unhbox \\voidb@x \\hbox {projection}.}{253}}\n\\newlabel{s1514}{{8.6.2}{253}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.6.3}March a circular silhouette curve of a surface.}{255}}\n\\newlabel{s1515}{{8.6.3}{255}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {8.7}Check if a Surface is Closed or has Degenerate Edges.}{257}}\n\\newlabel{s1450}{{8.7}{257}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {8.8}Pick the Parameter Ranges of a Surface}{259}}\n\\newlabel{s1603}{{8.8}{259}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {8.9}Closest Points}{260}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.9.1}Find the closest point between a surface and a point.}{260}}\n\\newlabel{s1954}{{8.9.1}{260}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.9.2}Find the closest point between a surface and a point. Simple version.}{262}}\n\\newlabel{s1958}{{8.9.2}{262}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.9.3}Local iteration to closest point bewteen point and surface.}{264}}\n\\newlabel{s1775}{{8.9.3}{264}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {8.10}Find the Absolute Extremals of a Surface.}{266}}\n\\newlabel{s1921}{{8.10}{266}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {8.11}Bounding Box}{268}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.11.1}Find the bounding box of a surface.}{268}}\n\\newlabel{s1989}{{8.11.1}{268}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {8.12}Normal Cone}{269}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {8.12.1}Find the direction cone of a surface.}{269}}\n\\newlabel{s1987}{{8.12.1}{269}}\n\\@writefile{toc}{\\contentsline {chapter}{\\numberline {9}Surface Analysis}{272}}\n\\@writefile{lof}{\\addvspace {10\\p@ }}\n\\@writefile{lot}{\\addvspace {10\\p@ }}\n\\newlabel{surfaceanalysis}{{9}{272}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {9.1}Curvature Evaluation}{272}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {9.1.1}Gaussian curvature of a spline surface.}{272}}\n\\newlabel{s2500}{{9.1.1}{272}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {9.1.2}Mean curvature of a spline surface.}{275}}\n\\newlabel{s2502}{{9.1.2}{275}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {9.1.3}Absolute curvature of a spline surface.}{277}}\n\\newlabel{s2504}{{9.1.3}{277}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {9.1.4}Total curvature of a spline surface.}{279}}\n\\newlabel{s2506}{{9.1.4}{279}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {9.1.5}Second order Mehlum curvature of a spline surface.}{281}}\n\\newlabel{s2508}{{9.1.5}{281}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {9.1.6}Third order Mehlum curvature of a spline surface.}{283}}\n\\newlabel{s2510}{{9.1.6}{283}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {9.1.7}Gaussian curvature of a B-spline or NURBS surface as a NURBS surface.}{285}}\n\\newlabel{s2532}{{9.1.7}{285}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {9.1.8}Mehlum curvature of a B-spline or NURBS surface as a NURBS surface.}{287}}\n\\newlabel{s2536}{{9.1.8}{287}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {9.1.9}Curvature on a uniform grid of a NURBS surface.}{289}}\n\\newlabel{s2540}{{9.1.9}{289}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {9.1.10}Principal curvatures of a spline surface.}{291}}\n\\newlabel{s2542}{{9.1.10}{291}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {9.1.11}Normal curvature of a spline surface.}{293}}\n\\newlabel{s2544}{{9.1.11}{293}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {9.1.12}Focal values on a uniform grid of a NURBS surface.}{295}}\n\\newlabel{s2545}{{9.1.12}{295}}\n\\@writefile{toc}{\\contentsline {chapter}{\\numberline {10}Surface Utilities}{297}}\n\\@writefile{lof}{\\addvspace {10\\p@ }}\n\\@writefile{lot}{\\addvspace {10\\p@ }}\n\\newlabel{surfaceutilities}{{10}{297}}\n\\newlabel{surfaceobject}{{10.1}{297}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {10.1}Surface Object}{297}}\n\\newlabel{SISLSurf}{{10.1}{297}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {10.1.1}Create a new surface object.}{299}}\n\\newlabel{sec:newSurf}{{10.1.1}{299}}\n\\newlabel{newSurf}{{10.1.1}{299}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {10.1.2}Make a copy of a surface object.}{302}}\n\\newlabel{copySurface}{{10.1.2}{302}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {10.1.3}Delete a surface object.}{303}}\n\\newlabel{freeSurf}{{10.1.3}{303}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {10.2}Evaluation}{304}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {10.2.1}Compute the position, the derivatives and the normal of a surface at a given parameter value pair.}{304}}\n\\newlabel{s1421}{{10.2.1}{304}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {10.2.2}Compute the position and derivatives of a surface at a given parameter value pair.}{306}}\n\\newlabel{s1424}{{10.2.2}{306}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {10.2.3}Compute the position and the left- or right-hand derivatives of a surface at a given parameter value pair.}{308}}\n\\newlabel{s1422}{{10.2.3}{308}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {10.2.4}Compute the position and the derivatives of a surface at a given parameter value pair.}{311}}\n\\newlabel{s1425}{{10.2.4}{311}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {10.2.5}Evaluate the surface pointed at by ps1 over an m1 * m2 grid of points (x[i],y[j]). Compute ider derivatives and normals if suitable.}{315}}\n\\newlabel{s1506}{{10.2.5}{315}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {10.3}Subdivision}{317}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {10.3.1}Subdivide a surface along a given parameter line.}{317}}\n\\newlabel{s1711}{{10.3.1}{317}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {10.3.2}Insert a given set of knots, in each parameter direction, into the description of a surface.}{318}}\n\\newlabel{s1025}{{10.3.2}{318}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {10.4}Picking Curves from a Surface}{320}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {10.4.1}Pick a curve along a constant parameter line in a surface.}{320}}\n\\newlabel{s1439}{{10.4.1}{320}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {10.4.2}Pick the curve lying in a surface, described by a curve in the parameter plane of the surface.}{321}}\n\\newlabel{s1383}{{10.4.2}{321}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {10.5}Pick a Part of a Surface.}{323}}\n\\newlabel{s1001}{{10.5}{323}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {10.6}Turn the Direction of the Surface Normal Vector.}{324}}\n\\newlabel{s1440}{{10.6}{324}}\n\\@writefile{toc}{\\contentsline {chapter}{\\numberline {11}Data Reduction}{325}}\n\\@writefile{lof}{\\addvspace {10\\p@ }}\n\\@writefile{lot}{\\addvspace {10\\p@ }}\n\\newlabel{datareduction}{{11}{325}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {11.1}Curves}{325}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {11.1.1}Data reduction: B-spline curve as input.}{325}}\n\\newlabel{s1940}{{11.1.1}{325}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {11.1.2}Data reduction: Point data as input.}{328}}\n\\newlabel{s1961}{{11.1.2}{328}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {11.1.3}Data reduction: Points and tangents as input.}{331}}\n\\newlabel{s1962}{{11.1.3}{331}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {11.1.4}Degree reduction: B-spline curve as input.}{333}}\n\\newlabel{s1963}{{11.1.4}{333}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {11.2}Surfaces}{335}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {11.2.1}Data reduction: B-spline surface as input.}{335}}\n\\newlabel{s1965}{{11.2.1}{335}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {11.2.2}Data reduction: Point data as input.}{338}}\n\\newlabel{s1966}{{11.2.2}{338}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {11.2.3}Data reduction: Points and tangents as input.}{341}}\n\\newlabel{s1967}{{11.2.3}{341}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {11.2.4}Degree reduction: B-spline surface as input.}{344}}\n\\newlabel{s1968}{{11.2.4}{344}}\n\\@writefile{toc}{\\contentsline {chapter}{\\numberline {12}Tutorial programs}{346}}\n\\@writefile{lof}{\\addvspace {10\\p@ }}\n\\@writefile{lot}{\\addvspace {10\\p@ }}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {12.1}Compiling the programs}{346}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {12.2}Description and commentaries on the sample programs}{346}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {12.2.1}example01.C}{347}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it does}{347}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it demonstrates}{347}}\n\\@writefile{toc}{\\contentsline {subsubsection}{Input/output}{347}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {12.2.2}example02.C}{347}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it does}{347}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it demonstrates}{347}}\n\\@writefile{toc}{\\contentsline {subsubsection}{Input/output}{347}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {12.2.3}example03.C}{347}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it does}{347}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it demonstrates}{348}}\n\\@writefile{toc}{\\contentsline {subsubsection}{Input/output}{348}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {12.2.4}example04.C}{348}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it does}{348}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it demonstrates}{348}}\n\\@writefile{toc}{\\contentsline {subsubsection}{Input/output}{348}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {12.2.5}example05.C}{348}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it does}{348}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it demonstrates}{349}}\n\\@writefile{toc}{\\contentsline {subsubsection}{Input/output}{349}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {12.2.6}example06.C}{349}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it does}{349}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it demonstrates}{349}}\n\\@writefile{toc}{\\contentsline {subsubsection}{Input/output}{349}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {12.2.7}example07.C}{349}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it does}{349}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it demonstrates}{349}}\n\\@writefile{toc}{\\contentsline {subsubsection}{Input/output}{350}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {12.2.8}example08.C}{350}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it does}{350}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it demonstrates}{350}}\n\\@writefile{toc}{\\contentsline {subsubsection}{Input/output}{350}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {12.2.9}example09.C}{350}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it does}{350}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it demonstrates}{350}}\n\\@writefile{toc}{\\contentsline {subsubsection}{Input/output}{350}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {12.2.10}example10.C}{351}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it does}{351}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it demonstrates}{351}}\n\\@writefile{toc}{\\contentsline {subsubsection}{Input/output}{351}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {12.2.11}example11.C}{351}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it does}{351}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it demonstrates}{351}}\n\\@writefile{toc}{\\contentsline {subsubsection}{Input/output}{351}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {12.2.12}example12.C}{351}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it does}{351}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it demonstrates}{351}}\n\\@writefile{toc}{\\contentsline {subsubsection}{Input/output}{352}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {12.2.13}example13.C}{352}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it does}{352}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it demonstrates}{352}}\n\\@writefile{toc}{\\contentsline {subsubsection}{Input/output}{352}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {12.2.14}example14.C}{352}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it does}{352}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it demonstrates}{353}}\n\\@writefile{toc}{\\contentsline {subsubsection}{Input/output}{353}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {12.2.15}example15.C}{353}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it does}{353}}\n\\@writefile{toc}{\\contentsline {subsubsection}{What it demonstrates}{354}}\n\\@writefile{toc}{\\contentsline {subsubsection}{Input/output}{354}}\n\\@writefile{toc}{\\contentsline {chapter}{\\numberline {13}The object viewer program}{355}}\n\\@writefile{lof}{\\addvspace {10\\p@ }}\n\\@writefile{lot}{\\addvspace {10\\p@ }}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {13.1}General}{355}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {13.2}Compiling the viewer}{355}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {13.3}Command line arguments}{356}}\n\\@writefile{toc}{\\contentsline {section}{\\numberline {13.4}User controls}{356}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {13.4.1}Mouse commands}{356}}\n\\@writefile{toc}{\\contentsline {subsection}{\\numberline {13.4.2}Keyboard commands}{357}}\n\\@writefile{toc}{\\contentsline {chapter}{\\numberline {14}Appendix: Error Codes}{358}}\n\\@writefile{lof}{\\addvspace {10\\p@ }}\n\\@writefile{lot}{\\addvspace {10\\p@ }}\n\\newlabel{errorcodes}{{14}{358}}\n\\@writefile{toc}{\\contentsline {chapter}{\\numberline {A}GNU AFFERO GENERAL PUBLIC LICENSE}{363}}\n\\@writefile{lof}{\\addvspace {10\\p@ }}\n\\@writefile{lot}{\\addvspace {10\\p@ }}\n"
  },
  {
    "path": "doc/manual/manual.idx",
    "content": "\\indexentry{s1602()}{18}\n\\indexentry{s1356()}{20}\n\\indexentry{s1357()}{22}\n\\indexentry{s1380()}{25}\n\\indexentry{s1379()}{27}\n\\indexentry{s1607()}{29}\n\\indexentry{s1608()}{31}\n\\indexentry{s1609()}{33}\n\\indexentry{s1014()}{36}\n\\indexentry{s1015()}{38}\n\\indexentry{s1016()}{40}\n\\indexentry{s1606()}{42}\n\\indexentry{s1303()}{44}\n\\indexentry{s1611()}{46}\n\\indexentry{s1630()}{48}\n\\indexentry{s1360()}{50}\n\\indexentry{s1613()}{52}\n\\indexentry{s1600()}{53}\n\\indexentry{s1389()}{54}\n\\indexentry{s1730()}{55}\n\\indexentry{s1732()}{56}\n\\indexentry{s1750()}{58}\n\\indexentry{s1720()}{59}\n\\indexentry{s1522()}{60}\n\\indexentry{s1011()}{62}\n\\indexentry{s1012()}{64}\n\\indexentry{s1871()}{66}\n\\indexentry{s1850()}{68}\n\\indexentry{s1327()}{70}\n\\indexentry{s1371()}{71}\n\\indexentry{s1374()}{73}\n\\indexentry{s1857()}{75}\n\\indexentry{s1240()}{77}\n\\indexentry{s1364()}{78}\n\\indexentry{s1451()}{79}\n\\indexentry{s1363()}{80}\n\\indexentry{s1953()}{81}\n\\indexentry{s1957()}{83}\n\\indexentry{s1774()}{85}\n\\indexentry{s1955()}{87}\n\\indexentry{s1013()}{89}\n\\indexentry{s1920()}{90}\n\\indexentry{s1241()}{92}\n\\indexentry{s1243()}{93}\n\\indexentry{SISLBox()}{95}\n\\indexentry{newbox()}{96}\n\\indexentry{s1988()}{97}\n\\indexentry{SISLDir()}{98}\n\\indexentry{newdir()}{99}\n\\indexentry{s1986()}{100}\n\\indexentry{s2550()}{101}\n\\indexentry{s2553()}{103}\n\\indexentry{s2556()}{104}\n\\indexentry{s2559()}{105}\n\\indexentry{s2562()}{106}\n\\indexentry{SISLCurve()}{108}\n\\indexentry{newCurve()}{110}\n\\indexentry{copyCurve()}{112}\n\\indexentry{freeCurve()}{113}\n\\indexentry{s1227()}{114}\n\\indexentry{s1221()}{116}\n\\indexentry{s1225()}{118}\n\\indexentry{s1226()}{120}\n\\indexentry{s1542()}{122}\n\\indexentry{s1710()}{122}\n\\indexentry{s1017()}{125}\n\\indexentry{s1018()}{126}\n\\indexentry{s1714()}{127}\n\\indexentry{s1712()}{128}\n\\indexentry{s1713()}{129}\n\\indexentry{s1715()}{130}\n\\indexentry{s1716()}{132}\n\\indexentry{s1706()}{133}\n\\indexentry{s1233()}{134}\n\\indexentry{s1536()}{136}\n\\indexentry{s1537()}{139}\n\\indexentry{s1534()}{142}\n\\indexentry{s1535()}{145}\n\\indexentry{s1529()}{148}\n\\indexentry{s1530()}{150}\n\\indexentry{s1538()}{152}\n\\indexentry{s1539()}{154}\n\\indexentry{s1508()}{156}\n\\indexentry{s1390()}{157}\n\\indexentry{s1391()}{159}\n\\indexentry{s1401()}{161}\n\\indexentry{s1620()}{163}\n\\indexentry{s1332()}{165}\n\\indexentry{s1302()}{166}\n\\indexentry{s1365()}{168}\n\\indexentry{s1601()}{170}\n\\indexentry{s1388()}{171}\n\\indexentry{s1731()}{173}\n\\indexentry{s1733()}{174}\n\\indexentry{s1387()}{176}\n\\indexentry{s1386()}{177}\n\\indexentry{s1023()}{178}\n\\indexentry{s1021()}{180}\n\\indexentry{s1024()}{181}\n\\indexentry{s1022()}{183}\n\\indexentry{SISLIntcurve()}{185}\n\\indexentry{newIntcurve()}{187}\n\\indexentry{freeIntcurve()}{189}\n\\indexentry{freeIntcrvlist()}{190}\n\\indexentry{s1850()}{191}\n\\indexentry{s1371()}{193}\n\\indexentry{s1372()}{195}\n\\indexentry{s1373()}{197}\n\\indexentry{s1502()}{199}\n\\indexentry{s1375()}{201}\n\\indexentry{s1870()}{203}\n\\indexentry{s1856()}{205}\n\\indexentry{s1518()}{207}\n\\indexentry{s1328()}{209}\n\\indexentry{s1855()}{210}\n\\indexentry{s1858()}{212}\n\\indexentry{s1851()}{214}\n\\indexentry{s1852()}{216}\n\\indexentry{s1853()}{218}\n\\indexentry{s1854()}{220}\n\\indexentry{s1503()}{222}\n\\indexentry{s1369()}{224}\n\\indexentry{s1859()}{226}\n\\indexentry{s1860()}{228}\n\\indexentry{s1510()}{230}\n\\indexentry{s1511()}{232}\n\\indexentry{s1314()}{234}\n\\indexentry{s1315()}{236}\n\\indexentry{s1316()}{238}\n\\indexentry{s1317()}{240}\n\\indexentry{s1501()}{242}\n\\indexentry{s1318()}{245}\n\\indexentry{s1310()}{248}\n\\indexentry{s1319()}{250}\n\\indexentry{s1514()}{253}\n\\indexentry{s1515()}{255}\n\\indexentry{s1450()}{257}\n\\indexentry{s1603()}{259}\n\\indexentry{s1954()}{260}\n\\indexentry{s1958()}{262}\n\\indexentry{s1775()}{264}\n\\indexentry{s1921()}{266}\n\\indexentry{s1989()}{268}\n\\indexentry{s1987()}{269}\n\\indexentry{s2500()}{272}\n\\indexentry{s2502()}{275}\n\\indexentry{s2504()}{277}\n\\indexentry{s2506()}{279}\n\\indexentry{s2508()}{281}\n\\indexentry{s2510()}{283}\n\\indexentry{s2532()}{285}\n\\indexentry{s2536()}{287}\n\\indexentry{s2540()}{289}\n\\indexentry{s2542()}{291}\n\\indexentry{s2544()}{293}\n\\indexentry{s2545()}{295}\n\\indexentry{SISLSurf()}{297}\n\\indexentry{newSurf()}{299}\n\\indexentry{copySurface()}{302}\n\\indexentry{freeSurf()}{303}\n\\indexentry{s1421()}{304}\n\\indexentry{s1424()}{306}\n\\indexentry{s1422()}{308}\n\\indexentry{s1425()}{311}\n\\indexentry{s1506()}{315}\n\\indexentry{s1711()}{317}\n\\indexentry{s1025()}{318}\n\\indexentry{s1439()}{320}\n\\indexentry{s1383()}{321}\n\\indexentry{s1001()}{323}\n\\indexentry{s1440()}{324}\n\\indexentry{s1940()}{325}\n\\indexentry{s1961()}{328}\n\\indexentry{s1962()}{331}\n\\indexentry{s1963()}{333}\n\\indexentry{s1965()}{335}\n\\indexentry{s1966()}{338}\n\\indexentry{s1967()}{341}\n\\indexentry{s1968()}{344}\n"
  },
  {
    "path": "doc/manual/manual.ilg",
    "content": "This is makeindex, version 2.15 [TeX Live 2017] (kpathsea + Thai support).\nScanning input file manual.idx....done (191 entries accepted, 0 rejected).\nSorting entries....done (1486 comparisons).\nGenerating output file manual.ind....done (195 lines written, 0 warnings).\nOutput written in manual.ind.\nTranscript written in manual.ilg.\n"
  },
  {
    "path": "doc/manual/manual.ind",
    "content": "\\begin{theindex}\n\n  \\item copyCurve(), 110\n  \\item copySurface(), 305\n\n  \\indexspace\n\n  \\item freeCurve(), 111\n  \\item freeIntcrvlist(), 191\n  \\item freeIntcurve(), 190\n  \\item freeSurf(), 306\n\n  \\indexspace\n\n  \\item newbox(), 94, 270\n  \\item newCurve(), 108\n  \\item newdir(), 97, 273\n  \\item newIntcurve(), 188\n  \\item newSurf(), 302\n\n  \\indexspace\n\n  \\item s1001(), 326\n  \\item s1011(), 60\n  \\item s1012(), 62\n  \\item s1013(), 87\n  \\item s1014(), 34\n  \\item s1015(), 36\n  \\item s1016(), 38\n  \\item s1017(), 123\n  \\item s1018(), 124\n  \\item s1021(), 181\n  \\item s1022(), 184\n  \\item s1023(), 179\n  \\item s1024(), 182\n  \\item s1025(), 321\n  \\item s1221(), 114\n  \\item s1225(), 116\n  \\item s1226(), 118\n  \\item s1227(), 112\n  \\item s1233(), 132\n  \\item s1237(), 331\n  \\item s1238(), 333\n  \\item s1240(), 75\n  \\item s1241(), 90\n  \\item s1243(), 91\n  \\item s1302(), 167\n  \\item s1303(), 42\n  \\item s1310(), 249\n  \\item s1314(), 235\n  \\item s1315(), 237\n  \\item s1316(), 239\n  \\item s1317(), 241\n  \\item s1318(), 246\n  \\item s1319(), 251\n  \\item s1327(), 68\n  \\item s1328(), 210\n  \\item s1332(), 166\n  \\item s1356(), 18\n  \\item s1357(), 20\n  \\item s1360(), 48\n  \\item s1363(), 78\n  \\item s1364(), 76\n  \\item s1365(), 169\n  \\item s1369(), 225\n  \\item s1371(), 69, 194\n  \\item s1372(), 196\n  \\item s1373(), 198\n  \\item s1374(), 71\n  \\item s1375(), 202\n  \\item s1379(), 25\n  \\item s1380(), 23\n  \\item s1383(), 324\n  \\item s1386(), 178\n  \\item s1387(), 177\n  \\item s1388(), 172\n  \\item s1389(), 52\n  \\item s1390(), 158\n  \\item s1391(), 160\n  \\item s1401(), 162\n  \\item s1421(), 307\n  \\item s1422(), 311\n  \\item s1424(), 309\n  \\item s1425(), 314\n  \\item s1439(), 323\n  \\item s1440(), 327\n  \\item s1450(), 258\n  \\item s1451(), 77\n  \\item s1501(), 243\n  \\item s1502(), 200\n  \\item s1503(), 223\n  \\item s1506(), 318\n  \\item s1508(), 157\n  \\item s1510(), 231\n  \\item s1511(), 233\n  \\item s1514(), 254\n  \\item s1515(), 256\n  \\item s1518(), 208\n  \\item s1522(), 58\n  \\item s1529(), 149\n  \\item s1530(), 151\n  \\item s1534(), 143\n  \\item s1535(), 146\n  \\item s1536(), 137\n  \\item s1537(), 140\n  \\item s1538(), 153\n  \\item s1539(), 155\n  \\item s1542(), 120\n  \\item s1600(), 51\n  \\item s1601(), 171\n  \\item s1602(), 16\n  \\item s1603(), 260\n  \\item s1606(), 40\n  \\item s1607(), 27\n  \\item s1608(), 29\n  \\item s1609(), 31\n  \\item s1611(), 44\n  \\item s1613(), 50\n  \\item s1620(), 164\n  \\item s1630(), 46\n  \\item s1706(), 131\n  \\item s1710(), 120\n  \\item s1711(), 320\n  \\item s1712(), 126\n  \\item s1713(), 127\n  \\item s1714(), 125\n  \\item s1715(), 128\n  \\item s1716(), 130\n  \\item s1720(), 57\n  \\item s1730(), 53\n  \\item s1731(), 174\n  \\item s1732(), 54\n  \\item s1733(), 175\n  \\item s1750(), 56\n  \\item s1774(), 83\n  \\item s1775(), 265\n  \\item s1850(), 66, 192\n  \\item s1851(), 215\n  \\item s1852(), 217\n  \\item s1853(), 219\n  \\item s1854(), 221\n  \\item s1855(), 211\n  \\item s1856(), 206\n  \\item s1857(), 73\n  \\item s1858(), 213\n  \\item s1859(), 227\n  \\item s1860(), 229\n  \\item s1870(), 204\n  \\item s1871(), 64\n  \\item s1920(), 88\n  \\item s1921(), 267\n  \\item s1940(), 335\n  \\item s1953(), 79\n  \\item s1954(), 261\n  \\item s1955(), 85\n  \\item s1957(), 81\n  \\item s1958(), 263\n  \\item s1961(), 337\n  \\item s1962(), 340\n  \\item s1963(), 342\n  \\item s1965(), 344\n  \\item s1966(), 347\n  \\item s1967(), 350\n  \\item s1968(), 353\n  \\item s1986(), 98\n  \\item s1987(), 274\n  \\item s1988(), 95\n  \\item s1989(), 271\n  \\item s2500(), 276\n  \\item s2502(), 278\n  \\item s2504(), 280\n  \\item s2506(), 282\n  \\item s2508(), 284\n  \\item s2510(), 286\n  \\item s2532(), 288\n  \\item s2536(), 290\n  \\item s2540(), 292\n  \\item s2542(), 294\n  \\item s2544(), 296\n  \\item s2545(), 298\n  \\item s2550(), 99\n  \\item s2553(), 101\n  \\item s2556(), 102\n  \\item s2559(), 103\n  \\item s2562(), 104\n  \\item s6drawseq(), 134, 328\n  \\item s6line(), 136, 330\n  \\item s6move(), 135, 329\n  \\item SISLBox(), 93, 269\n  \\item SISLCurve(), 106\n  \\item SISLdir(), 96, 272\n  \\item SISLIntcurve(), 186\n  \\item SISLSurf(), 300\n\n\\end{theindex}\n"
  },
  {
    "path": "doc/manual/manual.log",
    "content": "This is pdfTeX, Version 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) (preloaded format=pdflatex 2019.11.18)  16 MAR 2021 08:20\nentering extended mode\n restricted \\write18 enabled.\n %&-line parsing enabled.\n**manual.tex\n(./manual.tex\nLaTeX2e <2017-04-15>\nBabel <3.18> and hyphenation patterns for 7 language(s) loaded.\n(/usr/share/texlive/texmf-dist/tex/latex/base/report.cls\nDocument Class: report 2014/09/29 v1.4h Standard LaTeX document class\n(/usr/share/texlive/texmf-dist/tex/latex/base/size10.clo\nFile: size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)\n)\n\\c@part=\\count79\n\\c@chapter=\\count80\n\\c@section=\\count81\n\\c@subsection=\\count82\n\\c@subsubsection=\\count83\n\\c@paragraph=\\count84\n\\c@subparagraph=\\count85\n\\c@figure=\\count86\n\\c@table=\\count87\n\\abovecaptionskip=\\skip41\n\\belowcaptionskip=\\skip42\n\\bibindent=\\dimen102\n) (./sislman2.sty)\n(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphicx.sty\nPackage: graphicx 2017/06/01 v1.1a Enhanced LaTeX Graphics (DPC,SPQR)\n\n(/usr/share/texlive/texmf-dist/tex/latex/graphics/keyval.sty\nPackage: keyval 2014/10/28 v1.15 key=value parser (DPC)\n\\KV@toks@=\\toks14\n)\n(/usr/share/texlive/texmf-dist/tex/latex/graphics/graphics.sty\nPackage: graphics 2017/06/25 v1.2c Standard LaTeX Graphics (DPC,SPQR)\n\n(/usr/share/texlive/texmf-dist/tex/latex/graphics/trig.sty\nPackage: trig 2016/01/03 v1.10 sin cos tan (DPC)\n)\n(/usr/share/texlive/texmf-dist/tex/latex/graphics-cfg/graphics.cfg\nFile: graphics.cfg 2016/06/04 v1.11 sample graphics configuration\n)\nPackage graphics Info: Driver file: pdftex.def on input line 99.\n\n(/usr/share/texlive/texmf-dist/tex/latex/graphics-def/pdftex.def\nFile: pdftex.def 2018/01/08 v1.0l Graphics/color driver for pdftex\n))\n\\Gin@req@height=\\dimen103\n\\Gin@req@width=\\dimen104\n)\n(/usr/share/texlive/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty\nPackage: fancyvrb 2008/02/07\n\nStyle option: `fancyvrb' v2.7a, with DG/SPQR fixes, and firstline=lastline fix \n<2008/02/07> (tvz)\n\\FV@CodeLineNo=\\count88\n\\FV@InFile=\\read1\n\\FV@TabBox=\\box26\n\\c@FancyVerbLine=\\count89\n\\FV@StepNumber=\\count90\n\\FV@OutFile=\\write3\n)\n(/usr/share/texlive/texmf-dist/tex/latex/imakeidx/imakeidx.sty\nPackage: imakeidx 2016/10/15 v1.3e Package for typesetting indices in a synchro\nnous mode\n\n(/usr/share/texlive/texmf-dist/tex/latex/xkeyval/xkeyval.sty\nPackage: xkeyval 2014/12/03 v2.7a package option processing (HA)\n\n(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkeyval.tex\n(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkvutils.tex\n\\XKV@toks=\\toks15\n\\XKV@tempa@toks=\\toks16\n)\n\\XKV@depth=\\count91\nFile: xkeyval.tex 2014/12/03 v2.7a key=value parser (HA)\n))\n(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty\nPackage: ifxetex 2010/09/12 v0.6 Provides ifxetex conditional\n)\n(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty\nPackage: ifluatex 2016/05/16 v1.4 Provides the ifluatex switch (HO)\nPackage ifluatex Info: LuaTeX not detected.\n)\n(/usr/share/texlive/texmf-dist/tex/latex/tools/multicol.sty\nPackage: multicol 2017/04/11 v1.8q multicolumn formatting (FMi)\n\\c@tracingmulticols=\\count92\n\\mult@box=\\box27\n\\multicol@leftmargin=\\dimen105\n\\c@unbalance=\\count93\n\\c@collectmore=\\count94\n\\doublecol@number=\\count95\n\\multicoltolerance=\\count96\n\\multicolpretolerance=\\count97\n\\full@width=\\dimen106\n\\page@free=\\dimen107\n\\premulticols=\\dimen108\n\\postmulticols=\\dimen109\n\\multicolsep=\\skip43\n\\multicolbaselineskip=\\skip44\n\\partial@page=\\box28\n\\last@line=\\box29\n\\maxbalancingoverflow=\\dimen110\n\\mult@rightbox=\\box30\n\\mult@grightbox=\\box31\n\\mult@gfirstbox=\\box32\n\\mult@firstbox=\\box33\n\\@tempa=\\box34\n\\@tempa=\\box35\n\\@tempa=\\box36\n\\@tempa=\\box37\n\\@tempa=\\box38\n\\@tempa=\\box39\n\\@tempa=\\box40\n\\@tempa=\\box41\n\\@tempa=\\box42\n\\@tempa=\\box43\n\\@tempa=\\box44\n\\@tempa=\\box45\n\\@tempa=\\box46\n\\@tempa=\\box47\n\\@tempa=\\box48\n\\@tempa=\\box49\n\\@tempa=\\box50\n\\c@columnbadness=\\count98\n\\c@finalcolumnbadness=\\count99\n\\last@try=\\dimen111\n\\multicolovershoot=\\dimen112\n\\multicolundershoot=\\dimen113\n\\mult@nat@firstbox=\\box51\n\\colbreak@box=\\box52\n\\mc@col@check@num=\\count100\n))\n\\manual@idxfile=\\write4\n\\openout4 = `manual.idx'.\n\n\nWriting index file manual.idx\n(./manual.aux\n\nLaTeX Warning: Label `s1850' multiply defined.\n\n\nLaTeX Warning: Label `s1371' multiply defined.\n\n)\n\\openout1 = `manual.aux'.\n\nLaTeX Font Info:    Checking defaults for OML/cmm/m/it on input line 9.\nLaTeX Font Info:    ... okay on input line 9.\nLaTeX Font Info:    Checking defaults for T1/cmr/m/n on input line 9.\nLaTeX Font Info:    ... okay on input line 9.\nLaTeX Font Info:    Checking defaults for OT1/cmr/m/n on input line 9.\nLaTeX Font Info:    ... okay on input line 9.\nLaTeX Font Info:    Checking defaults for OMS/cmsy/m/n on input line 9.\nLaTeX Font Info:    ... okay on input line 9.\nLaTeX Font Info:    Checking defaults for OMX/cmex/m/n on input line 9.\nLaTeX Font Info:    ... okay on input line 9.\nLaTeX Font Info:    Checking defaults for U/cmr/m/n on input line 9.\nLaTeX Font Info:    ... okay on input line 9.\n (/usr/share/texlive/texmf-dist/tex/context/base/mkii/supp-pdf.mkii\n[Loading MPS to PDF converter (version 2006.09.02).]\n\\scratchcounter=\\count101\n\\scratchdimen=\\dimen114\n\\scratchbox=\\box53\n\\nofMPsegments=\\count102\n\\nofMParguments=\\count103\n\\everyMPshowfont=\\toks17\n\\MPscratchCnt=\\count104\n\\MPscratchDim=\\dimen115\n\\MPnumerator=\\count105\n\\makeMPintoPDFobject=\\count106\n\\everyMPtoPDFconversion=\\toks18\n) (/usr/share/texlive/texmf-dist/tex/latex/oberdiek/epstopdf-base.sty\nPackage: epstopdf-base 2016/05/15 v2.6 Base part for package epstopdf\n\n(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/infwarerr.sty\nPackage: infwarerr 2016/05/16 v1.4 Providing info/warning/error messages (HO)\n)\n(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/grfext.sty\nPackage: grfext 2016/05/16 v1.2 Manage graphics extensions (HO)\n\n(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvdefinekeys.sty\nPackage: kvdefinekeys 2016/05/16 v1.4 Define keys (HO)\n\n(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ltxcmds.sty\nPackage: ltxcmds 2016/05/16 v1.23 LaTeX kernel commands for general use (HO)\n)))\n(/usr/share/texlive/texmf-dist/tex/latex/oberdiek/kvoptions.sty\nPackage: kvoptions 2016/05/16 v3.12 Key value format for package options (HO)\n\n(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/kvsetkeys.sty\nPackage: kvsetkeys 2016/05/16 v1.17 Key value parser (HO)\n\n(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/etexcmds.sty\nPackage: etexcmds 2016/05/16 v1.6 Avoid name clashes with e-TeX commands (HO)\nPackage etexcmds Info: Could not find \\expanded.\n(etexcmds)             That can mean that you are not using pdfTeX 1.50 or\n(etexcmds)             that some package has redefined \\expanded.\n(etexcmds)             In the latter case, load this package earlier.\n)))\n(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/pdftexcmds.sty\nPackage: pdftexcmds 2018/01/21 v0.26 Utility functions of pdfTeX for LuaTeX (HO\n)\n\n(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty\nPackage: ifpdf 2017/03/15 v3.2 Provides the ifpdf switch\n)\nPackage pdftexcmds Info: LuaTeX not detected.\nPackage pdftexcmds Info: \\pdf@primitive is available.\nPackage pdftexcmds Info: \\pdf@ifprimitive is available.\nPackage pdftexcmds Info: \\pdfdraftmode found.\n)\nPackage epstopdf-base Info: Redefining graphics rule for `.eps' on input line 4\n38.\nPackage grfext Info: Graphics extension search list:\n(grfext)             [.pdf,.png,.jpg,.mps,.jpeg,.jbig2,.jb2,.PDF,.PNG,.JPG,.JPE\nG,.JBIG2,.JB2,.eps]\n(grfext)             \\AppendGraphicsExtensions on input line 456.\n\n(/usr/share/texlive/texmf-dist/tex/latex/latexconfig/epstopdf-sys.cfg\nFile: epstopdf-sys.cfg 2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Liv\ne\n))\n[1\n\n{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./manual.toc\nLaTeX Font Info:    External font `cmex10' loaded for size\n(Font)              <7> on input line 2.\nLaTeX Font Info:    External font `cmex10' loaded for size\n(Font)              <5> on input line 2.\n [1\n\n]\n[2] [3] [4]\nOverfull \\hbox (1.86055pt too wide) in paragraph at lines 153--153\n [][] []\\OT1/cmr/m/n/10 Newton it-er-a-tion on the in-ter-sec-tion be-tween a 3\nD NURBS \n []\n\n[5]\nOverfull \\hbox (7.41725pt too wide) in paragraph at lines 178--178\n [][] []\\OT1/cmr/m/n/10 March a sil-hou-ette curve of a sur-face, us-ing par-al\n-lel []. []  \n []\n\n[6] [7])\n\\tf@toc=\\write5\n\\openout5 = `manual.toc'.\n\n [8] (./foreword.tex\nChapter 1.\nLaTeX Font Info:    Try loading font information for OMS+cmr on input line 12.\n(/usr/share/texlive/texmf-dist/tex/latex/base/omscmr.fd\nFile: omscmr.fd 2014/09/29 v2.5h Standard LaTeX font definitions\n)\nLaTeX Font Info:    Font shape `OMS/cmr/m/n' in size <10> not available\n(Font)              Font shape `OMS/cmsy/m/n' tried instead on input line 12.\nLaTeX Font Info:    Font shape `OT1/cmtt/bx/n' in size <10> not available\n(Font)              Font shape `OT1/cmtt/m/n' tried instead on input line 14.\n\nUnderfull \\hbox (badness 10000) in paragraph at lines 23--41\n\n []\n\n\nUnderfull \\hbox (badness 10000) in paragraph at lines 23--41\n\n []\n\n\nUnderfull \\hbox (badness 10000) in paragraph at lines 23--41\n\n []\n\n\nUnderfull \\hbox (badness 10000) in paragraph at lines 23--41\n\n []\n\n\nUnderfull \\hbox (badness 10000) in paragraph at lines 23--41\n\n []\n\n[1\n\n\n]) (./chap_intro_abridged.tex [2]\nChapter 2.\n[3\n\n] [4] [5]\nOverfull \\hbox (53.99652pt too wide) in paragraph at lines 159--159\n[]\\OT1/cmtt/m/n/10 $ cmake .. -DCMAKE_BUILD_TYPE=Release (-DCMAKE_INSTALL_PREFI\nX=$HOME/install)[] \n []\n\n\nOverfull \\hbox (0.16714pt too wide) in paragraph at lines 161--162\n[]\\OT1/cmr/m/n/10 For a gui-like cmake in-ter-face use cc-make (from cmake-ncur\nses-gui) or cmake-\n []\n\n\nOverfull \\hbox (36.39507pt too wide) in paragraph at lines 174--176\n[]\\OT1/cmr/m/n/10 Install the li-brary to a lo-cal folder (re-quires the use of\n -DCMAKE[]INSTALL[]PREFIX\n []\n\n[6]\nOverfull \\hbox (6.74693pt too wide) in paragraph at lines 304--304\n[]  \\OT1/cmtt/m/n/10 SISLCurve *pc=0;                    /* Pointer to spline c\nurve */[] \n []\n\n\nOverfull \\hbox (6.74693pt too wide) in paragraph at lines 304--304\n[]  \\OT1/cmtt/m/n/10 double top[3],axispt[3],conept[3];  /* Representating the \ncone */[] \n []\n\n\nOverfull \\hbox (116.99597pt too wide) in paragraph at lines 304--304\n[]  \\OT1/cmtt/m/n/10 double st[100],scoef[100];          /* Knot vector and coe\nfficients of spline curve */[] \n []\n\n\nOverfull \\hbox (90.7462pt too wide) in paragraph at lines 304--304\n[]  \\OT1/cmtt/m/n/10 double *spar;                       /* Parameter values of\n intersection points */[] \n []\n\n\nOverfull \\hbox (59.24648pt too wide) in paragraph at lines 304--304\n[]  \\OT1/cmtt/m/n/10 int kstat;                          /* Return status from \nfunction calls */[] \n []\n\n\nOverfull \\hbox (69.74638pt too wide) in paragraph at lines 304--304\n[]  \\OT1/cmtt/m/n/10 int kk,kn,kdim;                     /* Order (polynomial d\negree+1), number of[] \n []\n\n\nOverfull \\hbox (64.49643pt too wide) in paragraph at lines 304--304\n[]                                         \\OT1/cmtt/m/n/10 coefficients and sp\natial dimension */[] \n []\n\n\nOverfull \\hbox (95.99615pt too wide) in paragraph at lines 304--304\n[]  \\OT1/cmtt/m/n/10 int kpt,kcrv;                       /* Number of intersect\nion points and curves */[] \n []\n\n\nOverfull \\hbox (95.99615pt too wide) in paragraph at lines 304--304\n[]  \\OT1/cmtt/m/n/10 SISLIntcurve **qrcrv;               /* Array of pointer to\n intersection curves  */[] \n []\n\n\nOverfull \\hbox (64.49643pt too wide) in paragraph at lines 304--304\n[]  \\OT1/cmtt/m/n/10 aepsco=0.000001; /* Computational tolerance. This paramete\nr is included from[] \n []\n\n\nOverfull \\hbox (1.49698pt too wide) in paragraph at lines 304--304\n[]      \\OT1/cmtt/m/n/10 printf(\"\\n i - intersect the B-spline curve with the c\none\");[] \n []\n\n[7]\nOverfull \\hbox (111.74602pt too wide) in paragraph at lines 304--304\n[]            \\OT1/cmtt/m/n/10 /* The array containing parameter values of the \nintersection points between[] \n []\n\n\nOverfull \\hbox (95.99615pt too wide) in paragraph at lines 304--304\n[]               \\OT1/cmtt/m/n/10 the curve and the cone is allocated inside s1\n373 and must be freed */[] \n []\n\n\nOverfull \\hbox (80.24629pt too wide) in paragraph at lines 304--304\n[]           \\OT1/cmtt/m/n/10 /* The array containing pointers to intersection \npoints curves between[] \n []\n\n\nOverfull \\hbox (80.24629pt too wide) in paragraph at lines 304--304\n[]              \\OT1/cmtt/m/n/10 the curve and the cone is allocated inside s13\n73 and must be freed.[] \n []\n\n\nOverfull \\hbox (74.99634pt too wide) in paragraph at lines 304--304\n[]              \\OT1/cmtt/m/n/10 This is done in a special function taking care\n of the intersection[] \n []\n\n[8]\nOverfull \\hbox (5.08954pt too wide) in paragraph at lines 315--316\n\\OT1/cmr/m/n/10 Note that the pro-gram must be placed in the app folder and sis\nl[]COMPILE[]APPS\n []\n\n[9] (./sec_spline_curve.tex\nOverfull \\hbox (17.05832pt too wide) in paragraph at lines 41--46\n\\OT1/cmr/m/n/10 1\\OML/cmm/m/it/10 ; [] ; n:  $ \\OT1/cmr/m/n/10 e.g. when $\\OML/\ncmm/m/it/10 dim \\OT1/cmr/m/n/10 = 3$, we have $\\OT1/cmr/bx/n/10 p \\OT1/cmr/m/n/\n10 = (\\OML/cmm/m/it/10 x[]; y[]; z[]; x[]; y[]; z[]; [] ; x[]; y[]; z[]\\OT1/cmr\n/m/n/10 )$. \n []\n\n[10] [11] [12] [13] [14]) (./sec_spline_surface.tex [15]\nOverfull \\hbox (50.4583pt too wide) in paragraph at lines 29--36\n\\OT1/cmr/m/n/10 1\\OML/cmm/m/it/10 ; [] ; n[]$\\OT1/cmr/m/n/10 , $\\OML/cmm/m/it/1\n0 j \\OT1/cmr/m/n/10 = 1\\OML/cmm/m/it/10 ; [] ; n[]$\\OT1/cmr/m/n/10 . When $\\OML\n/cmm/m/it/10 dim \\OT1/cmr/m/n/10 = 3$, we have $\\OT1/cmr/bx/n/10 p \\OT1/cmr/m/n\n/10 = (\\OML/cmm/m/it/10 x[]; y[]; z[]; x[]; y[]; z[]; []$\\OT1/cmr/m/n/10 ,\n []\n\n[16\nNon-PDF special ignored!]) [17]) (./chap_curve_definition.tex\nChapter 3.\n(./func/s1602.tex [18\n\n\n]) [19] (./func/s1356.tex\nOverfull \\hbox (22.05418pt too wide) in paragraph at lines 2--2\n[]\\OT1/cmr/bx/n/12 Compute a curve in-ter-po-lat-ing a set of points, []\n []\n\n\nUnderfull \\hbox (badness 2351) in paragraph at lines 46--48\n[]\\OT1/cmr/m/n/10 Array (length \\OT1/cmr/m/sl/10 inbpnt\\OT1/cmr/m/n/10 ) con-ta\nin-ing type in-di-ca-tor for\n []\n\n[20]) [21] (./func/s1357.tex\nOverfull \\hbox (28.15141pt too wide) in paragraph at lines 2--2\n[]\\OT1/cmr/bx/n/12 Compute a curve in-ter-po-lat-ing a set of points, parameter\n-\n []\n\n\nUnderfull \\hbox (badness 2351) in paragraph at lines 47--49\n[]\\OT1/cmr/m/n/10 Array (length \\OT1/cmr/m/sl/10 inbpnt\\OT1/cmr/m/n/10 ) con-ta\nin-ing type in-di-ca-tor for\n []\n\n[22] [23]) [24] (./func/s1380.tex [25]) [26] (./func/s1379.tex\nOverfull \\hbox (14.79308pt too wide) in paragraph at lines 2--2\n[]\\OT1/cmr/bx/n/12 Compute a curve by Her-mite in-ter-po-la-tion, parameter-\n []\n\n[27]) [28] (./func/s1607.tex [29]) [30] (./func/s1608.tex [31]\nUnderfull \\hbox (badness 10000) in paragraph at lines 112--115\n[]\\OT1/cmr/m/sl/10 curve1\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 curve2\\OT1/cmr/m/n/\n10 , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point1\\OT1/cmr/m/\nn/10 , \\OT1/cmr/m/sl/10 startpt1\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point2\\OT1/c\nmr/m/n/10 , \\OT1/cmr/m/sl/10 endpt2\\OT1/cmr/m/n/10 ,\n []\n\n\nUnderfull \\hbox (badness 10000) in paragraph at lines 112--115\n\\OT1/cmr/m/sl/10 fill-type\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/10\n , \\OT1/cmr/m/sl/10 or-der\\OT1/cmr/m/n/10 , &\\OT1/cmr/m/sl/10 newcurve\\OT1/cmr/\nm/n/10 , &\\OT1/cmr/m/sl/10 parpt1\\OT1/cmr/m/n/10 , &\\OT1/cmr/m/sl/10 par-spt1\\O\nT1/cmr/m/n/10 ,\n []\n\n) [32] (./func/s1609.tex\nUnderfull \\hbox (badness 1655) in paragraph at lines 10--13\n[]\\OT1/cmr/m/sl/10 curve1\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 curve2\\OT1/cmr/m/n/\n10 , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point1\\OT1/cmr/m/\nn/10 , \\OT1/cmr/m/sl/10 pointf\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point2\\OT1/cmr\n/m/n/10 , \\OT1/cmr/m/sl/10 ra-dius\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 nor-mal\\OT\n1/cmr/m/n/10 ,\n []\n\n\nUnderfull \\hbox (badness 6063) in paragraph at lines 10--13\n\\OT1/cmr/m/sl/10 filltype\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/10 \n, \\OT1/cmr/m/sl/10 or-der\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 newcurve\\OT1/cmr/m/\nn/10 , \\OT1/cmr/m/sl/10 parend1\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 par-spt1\\OT1/\ncmr/m/n/10 , \\OT1/cmr/m/sl/10 parend2\\OT1/cmr/m/n/10 ,\n []\n\n[33] [34]) [35] (./func/s1014.tex [36]) [37] (./func/s1015.tex [38]) [39]\n(./func/s1016.tex [40]) [41] (./func/s1606.tex\nUnderfull \\hbox (badness 1742) in paragraph at lines 14--16\n[]\\OT1/cmr/m/sl/10 curve1\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 curve2\\OT1/cmr/m/n/\n10 , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point1\\OT1/cmr/m/\nn/10 , \\OT1/cmr/m/sl/10 point2\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 blend-type\\OT1\n/cmr/m/n/10 , \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 or-der\\OT1\n/cmr/m/n/10 ,\n []\n\n[42]\nUnderfull \\hbox (badness 1817) in paragraph at lines 74--76\n[]\\OT1/cmr/m/sl/10 curve1\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 curve2\\OT1/cmr/m/n/\n10 , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point1\\OT1/cmr/m/\nn/10 , \\OT1/cmr/m/sl/10 point2\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 blend-type\\OT1\n/cmr/m/n/10 , \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 or-der\\OT1\n/cmr/m/n/10 ,\n []\n\n) [43] (./func/s1303.tex [44]) [45] (./func/s1611.tex\nUnderfull \\hbox (badness 2277) in paragraph at lines 43--46\n[]\\OT1/cmr/m/n/10 Array (length numpt) con-tain-ing type in-di-ca-tor for\n []\n\n[46]\nUnderfull \\hbox (badness 6204) in paragraph at lines 99--101\n[]\\OT1/cmr/m/sl/10 point\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 numpt\\OT1/cmr/m/n/10\n , \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 typept\\OT1/cmr/m/n/10\n , \\OT1/cmr/m/sl/10 open\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 or-der\\OT1/cmr/m/n/1\n0 , \\OT1/cmr/m/sl/10 start-par\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/\nm/n/10 ,\n []\n\n) [47] (./func/s1630.tex [48]) [49] (./func/s1360.tex [50]) [51]\n(./func/s1613.tex) [52] (./func/s1600.tex) [53] (./func/s1389.tex) [54]\n(./func/s1730.tex) [55] (./func/s1732.tex [56]) [57] (./func/s1750.tex)\n[58] (./func/s1720.tex) [59] (./func/s1522.tex [60]) [61] (./func/s1011.tex\n[62]) [63] (./func/s1012.tex [64])) [65] (./chap_curve_interrogation.tex\nChapter 4.\n(./func/s1871.tex [66\n\n\n]\nUnderfull \\hbox (badness 10000) in paragraph at lines 56--60\n\n []\n\n) [67] (./func/s1850.tex\nUnderfull \\hbox (badness 3758) in paragraph at lines 10--12\n[]\\OT1/cmr/m/sl/10 curve\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point\\OT1/cmr/m/n/10\n , \\OT1/cmr/m/sl/10 nor-mal\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/1\n0 , \\OT1/cmr/m/sl/10 ep-sco\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n\n/10 , \\OT1/cmr/m/sl/10 nu-mintpt\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 int-par\\OT1/\ncmr/m/n/10 ,\n []\n\n[68]) [69] (./func/s1327.tex\nOverfull \\hbox (21.21251pt too wide) in paragraph at lines 1--1\n[]\\OT1/cmr/bx/n/12 Convert a curve/line in-ter-sec-tion into a two-dimensional\n []\n\n) [70] (./func/s1371.tex [71]) [72] (./func/s1374.tex [73]\nUnderfull \\hbox (badness 10000) in paragraph at lines 83--85\n[]\\OT1/cmr/m/sl/10 curve\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 conar-ray\\OT1/cmr/m/\nn/10 , \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 ep-sco\\OT1/cmr/m/\nn/10 , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n/10 , &\\OT1/cmr/m/sl/10 nu-mintpt\\OT1/\ncmr/m/n/10 , &\\OT1/cmr/m/sl/10 int-par\\OT1/cmr/m/n/10 ,\n []\n\n) [74] (./func/s1857.tex [75]) [76] (./func/s1240.tex) [77] (./func/s1364.tex)\n[78] (./func/s1451.tex) [79] (./func/s1363.tex) [80] (./func/s1953.tex\nUnderfull \\hbox (badness 10000) in paragraph at lines 8--10\n[]\\OT1/cmr/m/sl/10 curve\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point\\OT1/cmr/m/n/10\n , \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 ep-sco\\OT1/cmr/m/n/10\n , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 nu-mintpt\\OT1/cmr/m\n/n/10 , \\OT1/cmr/m/sl/10 int-par\\OT1/cmr/m/n/10 ,\n []\n\n[81]\nUnderfull \\hbox (badness 10000) in paragraph at lines 73--75\n[]\\OT1/cmr/m/sl/10 curve\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point\\OT1/cmr/m/n/10\n , \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 ep-sco\\OT1/cmr/m/n/10\n , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n/10 , &\\OT1/cmr/m/sl/10 nu-mintpt\\OT1/cmr/\nm/n/10 , &\\OT1/cmr/m/sl/10 int-par\\OT1/cmr/m/n/10 ,\n []\n\n) [82] (./func/s1957.tex [83]) [84] (./func/s1774.tex [85]) [86]\n(./func/s1955.tex [87]) [88] (./func/s1013.tex) [89] (./func/s1920.tex [90])\n[91] (./func/s1241.tex) [92] (./func/s1243.tex [93]) [94] (./sec_box_object.tex\n(./type/SISLBox.tex) [95] (./func/newbox.tex)) [96] (./func/s1988.tex) [97]\n(./sec_cone_object.tex (./type/SISLDir.tex) [98] (./func/newdir.tex)) [99]\n(./func/s1986.tex)) [100] (./chap_curve_analysis.tex\nChapter 5.\n(./func/s2550.tex [101\n\n\n]) [102] (./func/s2553.tex) [103] (./func/s2556.tex\nOverfull \\hbox (1.31796pt too wide) in paragraph at lines 1--1\n[]\\OT1/cmr/bx/n/12 Evaluate the Vari-a-tion of Cur-va-ture (VoC) of a curve\n []\n\n) [104] (./func/s2559.tex) [105] (./func/s2562.tex\nUnderfull \\hbox (badness 3128) in paragraph at lines 59--62\n[]\\OT1/cmr/m/n/10 Geometric prop-erty (cur-va-ture, tor-sion or vari-a-tion\n []\n\n\nUnderfull \\hbox (badness 1590) in paragraph at lines 59--62\n\\OT1/cmr/m/n/10 of cur-va-ture) of a curve at given pa-ram-e-ter val-ues\n []\n\n[106])) [107] (./chap_curve_utilities.tex\nChapter 6.\n(./sec_curve_object.tex (./type/SISLCurve.tex [108\n\n\n])\nOverfull \\hbox (3.75056pt too wide) in paragraph at lines 12--16\n[]\\OT1/cmr/m/n/10 When us-ing a curve, do not de-clare a SISLCurve but a pointe\nr to a SISLCurve,\n []\n\n[109] (./func/newCurve.tex [110]) [111] (./func/copyCurve.tex) [112]\n(./func/freeCurve.tex)) [113] (./func/s1227.tex\nUnderfull \\hbox (badness 10000) in paragraph at lines 39--42\n\n []\n\n[114]) [115] (./func/s1221.tex\nUnderfull \\hbox (badness 10000) in paragraph at lines 39--42\n\n []\n\n[116]) [117] (./func/s1225.tex [118]) [119] (./func/s1226.tex [120]) [121]\n(./func/s1542.tex) (./func/s1710.tex [122]\nUnderfull \\hbox (badness 10000) in paragraph at lines 38--41\n[]\\OT1/cmr/m/n/10 Parameter value at end of curve,\n []\n\n[123]) [124] (./func/s1017.tex) [125] (./func/s1018.tex) [126]\n(./func/s1714.tex) [127] (./func/s1712.tex) [128] (./func/s1713.tex) [129]\n(./func/s1715.tex [130]) [131] (./func/s1716.tex) [132] (./func/s1706.tex)\n[133] (./func/s1233.tex [134])) [135] (./chap_surface_definition.tex\nChapter 7.\n(./func/s1536.tex [136\n\n\n]\nUnderfull \\hbox (badness 10000) in paragraph at lines 57--58\n\n []\n\n\nOverfull \\hbox (130.0pt too wide) detected at line 60\n[]\n []\n\n[137]) [138] (./func/s1537.tex [139]\nUnderfull \\hbox (badness 10000) in paragraph at lines 56--57\n\n []\n\n\nOverfull \\hbox (130.0pt too wide) detected at line 59\n[]\n []\n\n[140]) [141] (./func/s1534.tex\nOverfull \\hbox (12.80281pt too wide) in paragraph at lines 2--2\n[]\\OT1/cmr/bx/n/12 Compute a sur-face in-ter-po-lat-ing a set of points, deriva\n-\n []\n\n\nUnderfull \\hbox (badness 10000) in paragraph at lines 74--75\n\n []\n\n\nOverfull \\hbox (130.0pt too wide) detected at line 77\n[]\n []\n\n[142] [143]) [144] (./func/s1535.tex\nOverfull \\hbox (12.80281pt too wide) in paragraph at lines 2--2\n[]\\OT1/cmr/bx/n/12 Compute a sur-face in-ter-po-lat-ing a set of points, deriva\n-\n []\n\n\nUnderfull \\hbox (badness 10000) in paragraph at lines 69--70\n\n []\n\n\nOverfull \\hbox (130.0pt too wide) detected at line 72\n[]\n []\n\n[145] [146]) [147] (./func/s1529.tex\nUnderfull \\hbox (badness 1231) in paragraph at lines 58--59\n[]\\OT1/cmr/m/n/10 Mean ac-cu-mu-lated cord-length para-meter-\n []\n\n[148]) [149] (./func/s1530.tex\nOverfull \\hbox (24.05559pt too wide) in paragraph at lines 1--1\n[]\\OT1/cmr/bx/n/12 Compute a sur-face by Her-mite in-ter-po-la-tion, parameter-\n\n []\n\n[150]) [151] (./func/s1538.tex [152]) [153] (./func/s1539.tex [154]) [155]\n(./func/s1508.tex) [156] (./func/s1390.tex\nOverfull \\hbox (130.0pt too wide) detected at line 14\n[]\n []\n\n[157]) [158] (./func/s1391.tex\nUnderfull \\hbox (badness 10000) in paragraph at lines 32--40\n\n []\n\n\nOverfull \\hbox (10.3101pt too wide) detected at line 42\n\\OML/cmm/m/it/10 pc\\OT1/cmr/m/n/10 1[\\OML/cmm/m/it/10 i\\OT1/cmr/m/n/10 ]\\OML/cm\nm/m/it/10 ; i \\OT1/cmr/m/n/10 = \\OML/cmm/m/it/10 nder\\OT1/cmr/m/n/10 [0] + [] +\n \\OML/cmm/m/it/10 nder\\OT1/cmr/m/n/10 [\\OML/cmm/m/it/10 icurv \\OMS/cmsy/m/n/10 \n^^@ \\OT1/cmr/m/n/10 2]\\OML/cmm/m/it/10 ; [] ; nder\\OT1/cmr/m/n/10 [\\OML/cmm/m/i\nt/10 icurv \\OMS/cmsy/m/n/10 ^^@ \\OT1/cmr/m/n/10 1] \\OMS/cmsy/m/n/10 ^^@ \\OT1/cm\nr/m/n/10 1\n []\n\n[159]) [160] (./func/s1401.tex\nUnderfull \\hbox (badness 10000) in paragraph at lines 28--29\n\n []\n\n\nOverfull \\hbox (130.0pt too wide) detected at line 31\n[]\n []\n\n[161]) [162] (./func/s1620.tex [163]) [164] (./func/s1332.tex) [165]\n(./func/s1302.tex [166]) [167] (./func/s1365.tex [168]) [169] (./func/s1601.tex\n) [170] (./func/s1388.tex [171]) [172] (./func/s1731.tex) [173]\n(./func/s1733.tex\nUnderfull \\hbox (badness 10000) in paragraph at lines 14--16\n[]\\OT1/cmr/m/sl/10 surf\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 num-ber1\\OT1/cmr/m/n/\n10 , \\OT1/cmr/m/sl/10 num-ber2\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 start-par1\\OT1\n/cmr/m/n/10 , \\OT1/cmr/m/sl/10 end-par1\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 start\n-par2\\OT1/cmr/m/n/10 ,\n []\n\n[174]) [175] (./func/s1387.tex) [176] (./func/s1386.tex) [177]\n(./func/s1023.tex [178]) [179] (./func/s1021.tex) [180] (./func/s1024.tex\nUnderfull \\hbox (badness 6204) in paragraph at lines 10--12\n[]\\OT1/cmr/m/sl/10 centre\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 axis\\OT1/cmr/m/n/10\n , \\OT1/cmr/m/sl/10 equa-tor\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 mi-nor[]radius\\O\nT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 start[]minor\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10\n end[]minor\\OT1/cmr/m/n/10 ,\n []\n\n[181]\nUnderfull \\hbox (badness 6461) in paragraph at lines 74--76\n[]\\OT1/cmr/m/sl/10 centre\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 axis\\OT1/cmr/m/n/10\n , \\OT1/cmr/m/sl/10 equa-tor\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 mi-nor[]radius\\O\nT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 start[]minor\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10\n end[]minor\\OT1/cmr/m/n/10 ,\n []\n\n) [182] (./func/s1022.tex [183]) [184]) (./chap_surface_interrogation.tex\nChapter 8.\n(./sec_intcurve_object.tex (./type/SISLIntcurve.tex [185\n\n\n]) [186]\n(./func/newIntcurve.tex [187]) [188] (./func/freeIntcurve.tex) [189]\n(./func/freeIntcrvlist.tex)) [190] (./func/s1850.tex\nUnderfull \\hbox (badness 3758) in paragraph at lines 10--12\n[]\\OT1/cmr/m/sl/10 curve\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point\\OT1/cmr/m/n/10\n , \\OT1/cmr/m/sl/10 nor-mal\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/1\n0 , \\OT1/cmr/m/sl/10 ep-sco\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n\n/10 , \\OT1/cmr/m/sl/10 nu-mintpt\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 int-par\\OT1/\ncmr/m/n/10 ,\n []\n\n[191]) [192] (./func/s1371.tex [193]) [194] (./func/s1372.tex [195]) [196]\n(./func/s1373.tex [197]) [198] (./func/s1502.tex\nUnderfull \\hbox (badness 4353) in paragraph at lines 42--44\n[]\\OT1/cmr/m/n/10 The ra-tio of the ma-jor and mi-nor axes = el-li-\n []\n\n[199]) [200] (./func/s1375.tex [201]) [202] (./func/s1870.tex [203]) [204]\n(./func/s1856.tex\nUnderfull \\hbox (badness 3503) in paragraph at lines 9--11\n[]\\OT1/cmr/m/sl/10 surf\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point\\OT1/cmr/m/n/10 \n, \\OT1/cmr/m/sl/10 linedir\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/10\n , \\OT1/cmr/m/sl/10 ep-sco\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n/\n10 , \\OT1/cmr/m/sl/10 nu-mintpt\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point-par\\OT1\n/cmr/m/n/10 ,\n []\n\n[205]) [206] (./func/s1518.tex [207]) [208] (./func/s1328.tex\nOverfull \\hbox (37.22502pt too wide) in paragraph at lines 1--1\n[]\\OT1/cmr/bx/n/12 Convert a sur-face/line in-ter-sec-tion into a two-dimension\nal\n []\n\n) [209] (./func/s1855.tex\nUnderfull \\hbox (badness 4479) in paragraph at lines 8--10\n[]\\OT1/cmr/m/sl/10 surf\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 cen-tre\\OT1/cmr/m/n/1\n0 , \\OT1/cmr/m/sl/10 ra-dius\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 nor-mal\\OT1/cmr/\nm/n/10 , \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 ep-sco\\OT1/cmr/\nm/n/10 , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 nu-mintpt\\OT1\n/cmr/m/n/10 ,\n []\n\n[210]) [211] (./func/s1858.tex\nUnderfull \\hbox (badness 6575) in paragraph at lines 10--13\n[]\\OT1/cmr/m/sl/10 surf\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 curve\\OT1/cmr/m/n/10 \n, \\OT1/cmr/m/sl/10 ep-sco\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n/1\n0 , \\OT1/cmr/m/sl/10 nu-mintpt\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point-par1\\OT1\n/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point-par2\\OT1/cmr/m/n/10 ,\n []\n\n[212]) [213] (./func/s1851.tex [214]) [215] (./func/s1852.tex\nUnderfull \\hbox (badness 2961) in paragraph at lines 10--13\n[]\\OT1/cmr/m/sl/10 surf\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 cen-tre\\OT1/cmr/m/n/1\n0 , \\OT1/cmr/m/sl/10 ra-dius\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/\n10 , \\OT1/cmr/m/sl/10 ep-sco\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/\nn/10 , \\OT1/cmr/m/sl/10 nu-mintpt\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point-par\\O\nT1/cmr/m/n/10 ,\n []\n\n[216]) [217] (./func/s1853.tex\nUnderfull \\hbox (badness 7415) in paragraph at lines 10--13\n[]\\OT1/cmr/m/sl/10 surf\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point\\OT1/cmr/m/n/10 \n, \\OT1/cmr/m/sl/10 cyldir\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 ra-dius\\OT1/cmr/m/n\n/10 , \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 ep-sco\\OT1/cmr/m/n\n/10 , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 nu-mintpt\\OT1/cm\nr/m/n/10 ,\n []\n\n[218]) [219] (./func/s1854.tex [220]) [221] (./func/s1503.tex\nUnderfull \\hbox (badness 4353) in paragraph at lines 51--53\n[]\\OT1/cmr/m/n/10 The ra-tio of the ma-jor and mi-nor axes = el-li-\n []\n\n[222]) [223] (./func/s1369.tex\nUnderfull \\hbox (badness 7576) in paragraph at lines 10--13\n[]\\OT1/cmr/m/sl/10 surf\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 cen-tre\\OT1/cmr/m/n/1\n0 , \\OT1/cmr/m/sl/10 nor-mal\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 cendist\\OT1/cmr/\nm/n/10 , \\OT1/cmr/m/sl/10 ra-dius\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 dim\\OT1/cmr\n/m/n/10 , \\OT1/cmr/m/sl/10 ep-sco\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 epsge\\OT1/c\nmr/m/n/10 ,\n []\n\n[224]\nUnderfull \\hbox (badness 7796) in paragraph at lines 100--103\n[]\\OT1/cmr/m/sl/10 surf\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 cen-tre\\OT1/cmr/m/n/1\n0 , \\OT1/cmr/m/sl/10 nor-mal\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 cendist\\OT1/cmr/\nm/n/10 , \\OT1/cmr/m/sl/10 ra-dius\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 dim\\OT1/cmr\n/m/n/10 , \\OT1/cmr/m/sl/10 ep-sco\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 epsge\\OT1/c\nmr/m/n/10 ,\n []\n\n) [225] (./func/s1859.tex\nUnderfull \\hbox (badness 6348) in paragraph at lines 10--13\n[]\\OT1/cmr/m/sl/10 surfl\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 surf2\\OT1/cmr/m/n/10\n , \\OT1/cmr/m/sl/10 ep-sco\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n/\n10 , \\OT1/cmr/m/sl/10 nu-mintpt\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point-par1\\OT\n1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point-par2\\OT1/cmr/m/n/10 ,\n []\n\n[226]) [227] (./func/s1860.tex [228]\nUnderfull \\hbox (badness 10000) in paragraph at lines 90--93\n[]\\OT1/cmr/m/sl/10 surf\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 viewdir\\OT1/cmr/m/n/1\n0 , \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 ep-sco\\OT1/cmr/m/n/1\n0 , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n/10 , &\\OT1/cmr/m/sl/10 num-silpt\\OT1/cmr\n/m/n/10 , &\\OT1/cmr/m/sl/10 point-par\\OT1/cmr/m/n/10 ,\n []\n\n) [229] (./func/s1510.tex [230]) [231] (./func/s1511.tex [232]) [233]\n(./func/s1314.tex\nUnderfull \\hbox (badness 4266) in paragraph at lines 12--14\n[]\\OT1/cmr/m/sl/10 surf\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point\\OT1/cmr/m/n/10 \n, \\OT1/cmr/m/sl/10 nor-mal\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/10\n , \\OT1/cmr/m/sl/10 ep-sco\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n/\n10 , \\OT1/cmr/m/sl/10 maxstep\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 intcurve\\OT1/cm\nr/m/n/10 ,\n []\n\n[234]\nUnderfull \\hbox (badness 4416) in paragraph at lines 122--124\n[]\\OT1/cmr/m/sl/10 surf\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point\\OT1/cmr/m/n/10 \n, \\OT1/cmr/m/sl/10 nor-mal\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/10\n , \\OT1/cmr/m/sl/10 ep-sco\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n/\n10 , \\OT1/cmr/m/sl/10 maxstep\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 intcurve\\OT1/cm\nr/m/n/10 ,\n []\n\n) [235] (./func/s1315.tex [236]) [237] (./func/s1316.tex [238]) [239]\n(./func/s1317.tex [240]) [241] (./func/s1501.tex\nUnderfull \\hbox (badness 4353) in paragraph at lines 55--57\n[]\\OT1/cmr/m/n/10 The ra-tio of the ma-jor and mi-nor axes = el-li-\n []\n\n[242] [243]) [244] (./func/s1318.tex [245] [246]) [247] (./func/s1310.tex\n[248]) [249] (./func/s1319.tex [250] [251]) [252] (./func/s1514.tex\nUnderfull \\hbox (badness 10000) in paragraph at lines 58--60\n\n []\n\n[253]) [254] (./func/s1515.tex\nUnderfull \\hbox (badness 10000) in paragraph at lines 61--63\n\n []\n\n[255]) [256] (./func/s1450.tex\nOverfull \\hbox (130.0pt too wide) detected at line 8\n[]\n []\n\n[257]) [258] (./func/s1603.tex) [259] (./func/s1954.tex\nUnderfull \\hbox (badness 1406) in paragraph at lines 8--10\n[]\\OT1/cmr/m/sl/10 surf\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 point\\OT1/cmr/m/n/10 \n, \\OT1/cmr/m/sl/10 dim\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 ep-sco\\OT1/cmr/m/n/10 \n, \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 num-clopt\\OT1/cmr/m/\nn/10 , \\OT1/cmr/m/sl/10 point-par\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 num-clocr\\O\nT1/cmr/m/n/10 ,\n []\n\n[260]) [261] (./func/s1958.tex [262]) [263] (./func/s1775.tex [264]) [265]\n(./func/s1921.tex [266]) [267] (./func/s1989.tex) [268] (./func/s1987.tex\n[269] [270])) [271] (./chap_surface_analysis.tex\nChapter 9.\n(./func/s2500.tex [272\n\n\n]\nUnderfull \\hbox (badness 10000) in paragraph at lines 75--77\n[]\\OT1/cmr/m/n/10 Gaussian of the sur-face at (u,v) $=$ (par-\n []\n\n[273]) [274] (./func/s2502.tex [275]\nUnderfull \\hbox (badness 4752) in paragraph at lines 75--77\n[]\\OT1/cmr/m/n/10 Mean cur-va-ture of the sur-face at (u,v) $=$ (par-\n []\n\n) [276] (./func/s2504.tex [277]\nUnderfull \\hbox (badness 1629) in paragraph at lines 75--77\n[]\\OT1/cmr/m/n/10 Absolute cur-va-ture of the sur-face at (u,v) $=$ (par-\n []\n\n) [278] (./func/s2506.tex [279]\nUnderfull \\hbox (badness 5091) in paragraph at lines 75--77\n[]\\OT1/cmr/m/n/10 Total cur-va-ture of the sur-face at (u,v) $=$ (par-\n []\n\n) [280] (./func/s2508.tex [281]) [282] (./func/s2510.tex [283]) [284]\n(./func/s2532.tex [285]\nUnderfull \\hbox (badness 10000) in paragraph at lines 91--93\n[]\\OT1/cmr/m/sl/10 surf\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 u[]continuity\\OT1/cmr\n/m/n/10 , \\OT1/cmr/m/sl/10 v[]continuity\\OT1/cmr/m/n/10 , &\\OT1/cmr/m/sl/10 u[]\nsurfnumb\\OT1/cmr/m/n/10 , &\\OT1/cmr/m/sl/10 v[]surfnumb\\OT1/cmr/m/n/10 ,\n []\n\n) [286] (./func/s2536.tex\nUnderfull \\hbox (badness 10000) in paragraph at lines 19--21\n[]\\OT1/cmr/m/sl/10 surf\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 u[]continuity\\OT1/cmr\n/m/n/10 , \\OT1/cmr/m/sl/10 v[]continuity\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 u[]s\nurfnumb\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 v[]surfnumb\\OT1/cmr/m/n/10 ,\n []\n\n[287]\nUnderfull \\hbox (badness 10000) in paragraph at lines 92--94\n[]\\OT1/cmr/m/sl/10 surf\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 u[]continuity\\OT1/cmr\n/m/n/10 , \\OT1/cmr/m/sl/10 v[]continuity\\OT1/cmr/m/n/10 , &\\OT1/cmr/m/sl/10 u[]\nsurfnumb\\OT1/cmr/m/n/10 , &\\OT1/cmr/m/sl/10 v[]surfnumb\\OT1/cmr/m/n/10 ,\n []\n\n) [288] (./func/s2540.tex\nUnderfull \\hbox (badness 1895) in paragraph at lines 69--76\n[]\\OT1/cmr/m/n/10 Array con-tain-ing the com-puted val-ues on the grid.\n []\n\n\nUnderfull \\hbox (badness 1194) in paragraph at lines 69--76\n\\OT1/cmr/m/n/10 The al-lo-ca-tion is done in-ter-nally and the di-men-sion\n []\n\n\nUnderfull \\hbox (badness 2126) in paragraph at lines 69--76\n\\OT1/cmr/m/n/10 is 3*(n[]u+1)*(n[]v+1) if ex-port[]par[]val is true, and\n []\n\n[289]) [290] (./func/s2542.tex\nUnderfull \\hbox (badness 1077) in paragraph at lines 4--9\n\\OT1/cmr/m/n/10 ci-pal di-rec-tions (d1,d2) of a spline sur-face at given val-u\nes (u,v)\n []\n\n\nUnderfull \\hbox (badness 1303) in paragraph at lines 4--9\n\\OT1/cmr/m/n/10 =$ (par-value[0],parvalue[1]), where etl[leftknot1] $\\OML/cmm/m\n/it/10 <\\OT1/cmr/m/n/10 =$ par-value[0] $\\OML/cmm/m/it/10 <$\n []\n\n[291]) [292] (./func/s2544.tex\nUnderfull \\hbox (badness 10000) in paragraph at lines 4--10\n\\OT1/cmr/m/n/10 where et1[leftknot1] $\\OML/cmm/m/it/10 <\\OT1/cmr/m/n/10 =$ par-\nvalue[0] $\\OML/cmm/m/it/10 <$ \\OT1/cmr/m/n/10 et1[leftknot1+1] and\n []\n\n[293]) [294] (./func/s2545.tex [295]\nUnderfull \\hbox (badness 1895) in paragraph at lines 75--84\n[]\\OT1/cmr/m/n/10 Array con-tain-ing the com-puted val-ues on the grid.\n []\n\n)) [296] (./chap_surface_utilities.tex\nChapter 10.\n(./sec_surface_object.tex (./type/SISLSurf.tex [297\n\n\n]) [298] (./func/newSurf.tex\nOverfull \\hbox (39.73895pt too wide) in paragraph at lines 11--16\n\\OT1/cmr/m/n/10 must the ver-tices be given as $[]$\n []\n\n[299] [300]) [301] (./func/copySurface.tex) [302] (./func/freeSurf.tex))\n[303] (./func/s1421.tex [304]) [305] (./func/s1424.tex [306]) [307]\n(./func/s1422.tex [308] [309]) [310] (./func/s1425.tex\nUnderfull \\hbox (badness 10000) in paragraph at lines 41--45\n[]\\OT1/cmr/m/n/10 No deriva-tives with re-spect to the\n []\n\n\nUnderfull \\hbox (badness 6758) in paragraph at lines 41--45\n\\OT1/cmr/m/n/10 first pa-ram-e-ter di-rec-tion will be com-\n []\n\n\nUnderfull \\hbox (badness 3826) in paragraph at lines 41--45\n\\OT1/cmr/m/n/10 puted. (Only deriva-tives of the type\n []\n\n[311]\nUnderfull \\hbox (badness 2556) in paragraph at lines 61--65\n[]\\OT1/cmr/m/n/10 No deriva-tives with re-spect to the sec-\n []\n\n\nUnderfull \\hbox (badness 7504) in paragraph at lines 61--65\n\\OT1/cmr/m/n/10 ond pa-ram-e-ter di-rec-tion will be com-\n []\n\n\nUnderfull \\hbox (badness 3826) in paragraph at lines 61--65\n\\OT1/cmr/m/n/10 puted. (Only deriva-tives of the type\n []\n\n[312] [313]) [314] (./func/s1506.tex [315]) [316] (./func/s1711.tex) [317]\n(./func/s1025.tex [318]) [319] (./func/s1439.tex) [320] (./func/s1383.tex\n[321]\nUnderfull \\hbox (badness 4060) in paragraph at lines 82--84\n[]\\OT1/cmr/m/sl/10 surf\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 curve\\OT1/cmr/m/n/10 \n, \\OT1/cmr/m/sl/10 epsge\\OT1/cmr/m/n/10 , \\OT1/cmr/m/sl/10 maxstep\\OT1/cmr/m/n/\n10 , \\OT1/cmr/m/sl/10 der\\OT1/cmr/m/n/10 , &\\OT1/cmr/m/sl/10 newcurve1\\OT1/cmr/\nm/n/10 , &\\OT1/cmr/m/sl/10 newcurve2\\OT1/cmr/m/n/10 ,\n []\n\n) [322] (./func/s1001.tex) [323] (./func/s1440.tex)) [324]\n(./chap_data_reduction.tex\nChapter 11.\n(./func/s1940.tex [325\n\n\n] [326]) [327] (./func/s1961.tex [328] [329]) [330]\n(./func/s1962.tex [331]) [332] (./func/s1963.tex [333]) [334] (./func/s1965.tex\n[335] [336]) [337] (./func/s1966.tex [338] [339]) [340] (./func/s1967.tex\n[341] [342]) [343] (./func/s1968.tex [344])) [345] (./sample_programs.tex\nChapter 12.\n[346\n\n\n] [347]\nOverfull \\hbox (16.74867pt too wide) in paragraph at lines 90--93\n\\OT1/cmr/m/n/10 The pro-gram takes as in-put the files [][]\\OT1/cmtt/m/n/10 exa\nmple1_curve.g2 []\\OT1/cmr/m/n/10 and [][]\\OT1/cmtt/m/n/10 example2_points.g2[]\\\nOT1/cmr/m/n/10 ,\n []\n\n[348] [349] [350]\nOverfull \\hbox (16.99919pt too wide) in paragraph at lines 241--246\n[]\\OT1/cmr/m/n/10 and [][]\\OT1/cmtt/m/n/10 example10_surf.g2[]\\OT1/cmr/m/n/10 ,\n re-spec-tively gen-er-ated by the sam-ple pro-grams [][]\\OT1/cmtt/m/n/10 examp\nle04\n []\n\n[351]\nOverfull \\hbox (7.6667pt too wide) in paragraph at lines 270--274\n\\OT1/cmr/m/n/10 The two sur-faces have been gen-er-ated by the pre-vi-ous sam-p\nle pro-grams [][]\\OT1/cmtt/m/n/10 example10\n []\n\n[352]\n<raytracing.pdf, id=1174, 513.11702pt x 423.50221pt>\nFile: raytracing.pdf Graphic file (type pdf)\n<use raytracing.pdf>\nPackage pdftex.def Info: raytracing.pdf  used on input line 309.\n(pdftex.def)             Requested size: 166.22081pt x 144.53812pt.\n\nUnderfull \\hbox (badness 10000) in paragraph at lines 301--335\n\n []\n\n[353 <./raytracing.pdf>]) (./viewer.tex [354]\nChapter 13.\n\nUnderfull \\hbox (badness 10000) in paragraph at lines 4--23\n\n []\n\n[355\n\n] [356]) [357] (./chap_error_codes.tex\nChapter 14.\n\nOverfull \\hbox (74.99634pt too wide) in paragraph at lines 215--215\n[]\\OT1/cmtt/m/n/10 ------------------------------------------------------------\n--------------------[] \n []\n\n\nOverfull \\hbox (53.99652pt too wide) in paragraph at lines 215--215\n[]\\OT1/cmtt/m/n/10 err111 -111  Error in Curve description. Number of vertices \nless than order.[] \n []\n\n\nOverfull \\hbox (43.49661pt too wide) in paragraph at lines 215--215\n[]\\OT1/cmtt/m/n/10 err114 -114  Error in Curve description. Open Curve when exp\necting closed.[] \n []\n\n[358\n\n\n]\nOverfull \\hbox (48.74657pt too wide) in paragraph at lines 215--215\n[]\\OT1/cmtt/m/n/10 err116 -116  Error in Surf description. Number of vertices l\ness than order.[] \n []\n\n\nOverfull \\hbox (27.74675pt too wide) in paragraph at lines 215--215\n[]\\OT1/cmtt/m/n/10 err130 -130  Error in input. Parameter value is outside para\nmeter area.[] \n []\n\n[359]\nOverfull \\hbox (6.74693pt too wide) in paragraph at lines 215--215\n[]\\OT1/cmtt/m/n/10 err140 -140  Error in data structure. Intersection interval \ncrosses[] \n []\n\n\nOverfull \\hbox (43.49661pt too wide) in paragraph at lines 215--215\n[]\\OT1/cmtt/m/n/10 err153 -153  Lower level routine reported error. SHOULD use \nlabel \"error\".[] \n []\n\n\nOverfull \\hbox (27.74675pt too wide) in paragraph at lines 215--215\n[]\\OT1/cmtt/m/n/10 err156 -156  Illegal derivative requested. Change this label\n to err178.[] \n []\n\n\nOverfull \\hbox (17.24684pt too wide) in paragraph at lines 215--215\n[]\\OT1/cmtt/m/n/10 err159 -159  No of vertices less than 1. SHOULD USE err111 o\nr err116.[] \n []\n\n[360]\nOverfull \\hbox (11.99689pt too wide) in paragraph at lines 215--215\n[]\\OT1/cmtt/m/n/10 err164 -164  No point conditions specified in interpolation \nproblem.[] \n []\n\n\nOverfull \\hbox (43.49661pt too wide) in paragraph at lines 215--215\n[]\\OT1/cmtt/m/n/10 err171 -171  Memory allocation failure: Could not create cur\nve or surface.[] \n []\n\n[361]) [362] (./licensing_information.tex\nAppendix A.\n[363\n\n\n] [1] [1] [2] [3] [4] [5] [6] [7]\nOverfull \\hbox (1.97282pt too wide) in paragraph at lines 496--500\n[]\\OT1/cmr/m/n/10 Each con-trib-u-tor grants you a non-exclusive, world-wide, r\noyalty-free patent\n []\n\n[8] [9]\nUnderfull \\hbox (badness 2020) in paragraph at lines 610--619\n[]\\OT1/cmr/m/n/10 THERE IS NO WAR-RANTY FOR THE PRO-GRAM, TO THE\n []\n\n\nOverfull \\hbox (18.39348pt too wide) in paragraph at lines 623--633\n[]\\OT1/cmr/m/n/10 IN NO EVENT UN-LESS RE-QUIRED BY AP-PLI-CA-BLE LAW OR AGREED\n []\n\n\nOverfull \\hbox (5.68616pt too wide) in paragraph at lines 623--633\n\\OT1/cmr/m/n/10 TO IN WRIT-ING WILL ANY COPY-RIGHT HOLDER, OR ANY OTHER\n []\n\n\nOverfull \\hbox (9.7184pt too wide) in paragraph at lines 623--633\n\\OT1/cmr/m/n/10 CLUD-ING ANY GEN-ERAL, SPE-CIAL, IN-CI-DEN-TAL OR CON-SE-QUEN-\n []\n\n[10] [11] (./manual.aux)\n\nLaTeX Warning: There were multiply-defined labels.\n\n ) ) \nHere is how much of TeX's memory you used:\n 3173 strings out of 494847\n 44259 string characters out of 6179079\n 125494 words of memory out of 5000000\n 5868 multiletter control sequences out of 15000+600000\n 9282 words of font info for 33 fonts, out of 8000000 for 9000\n 59 hyphenation exceptions out of 8191\n 39i,9n,37p,580b,326s stack positions out of 5000i,500n,10000p,200000b,80000s\n</usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx10.pfb></\nusr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx12.pfb></usr/sh\nare/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmbx7.pfb></usr/share/tex\nlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmbxti10.pfb></usr/share/texlive\n/texmf-dist/fonts/type1/public/amsfonts/cm/cmcsc10.pfb></usr/share/texlive/texm\nf-dist/fonts/type1/public/amsfonts/cm/cmex10.pfb></usr/share/texlive/texmf-dist\n/fonts/type1/public/amsfonts/cm/cmmi10.pfb></usr/share/texlive/texmf-dist/fonts\n/type1/public/amsfonts/cm/cmmi7.pfb></usr/share/texlive/texmf-dist/fonts/type1/\npublic/amsfonts/cm/cmr10.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/\namsfonts/cm/cmr12.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfont\ns/cm/cmr17.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cm\nr5.pfb></usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmr7.pfb><\n/usr/share/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmsl10.pfb></usr/s\nhare/texlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy10.pfb></usr/share/t\nexlive/texmf-dist/fonts/type1/public/amsfonts/cm/cmsy7.pfb></usr/share/texlive/\ntexmf-dist/fonts/type1/public/amsfonts/cm/cmti10.pfb></usr/share/texlive/texmf-\ndist/fonts/type1/public/amsfonts/cm/cmtt10.pfb></usr/share/texlive/texmf-dist/f\nonts/type1/public/amsfonts/cm/cmtt8.pfb></usr/share/texlive/texmf-dist/fonts/ty\npe1/public/amsfonts/latxfont/lcircle1.pfb></usr/share/texlive/texmf-dist/fonts/\ntype1/public/amsfonts/latxfont/lcirclew.pfb></usr/share/texlive/texmf-dist/font\ns/type1/public/amsfonts/latxfont/line10.pfb></usr/share/texlive/texmf-dist/font\ns/type1/public/amsfonts/latxfont/linew10.pfb>\nOutput written on manual.pdf (384 pages, 828126 bytes).\nPDF statistics:\n 1343 PDF objects out of 1440 (max. 8388607)\n 921 compressed objects within 10 object streams\n 0 named destinations out of 1000 (max. 500000)\n 6 words of extra memory for PDF output out of 10000 (max. 10000000)\n\n"
  },
  {
    "path": "doc/manual/manual.tex",
    "content": "%\\documentstyle[a4,twoside,epsf,makeidx]{sislman}\n\\documentclass[a4paper]{report}\n\\usepackage{sislman2}\n\\usepackage{graphicx}\n\\usepackage{fancyvrb}\n\\pagestyle{headings}\n\\usepackage{imakeidx} \n\\makeindex\n\\begin{document}\n\n\\begin{titlepage}\n  \\vspace{5 cm}\n  \\begin{center}\n  \\Huge\n  \\textbf{SISL} \\\\\n  \\huge\n  The SINTEF Spline Library \\\\ \n  \\LARGE\n  Reference Manual \\\\\n  (version 4.7)\\\\ \n  \\vspace{10 mm}\n  \\large\n  SINTEF Digital, Mathematics and Cybernetics \\\\\n  Mars 16, 2021\n  \\end{center}\n\n\\end{titlepage}\n\n\\pagenumbering{roman}\n\\tableofcontents\n\\cleardoublepage\n\\pagenumbering{arabic}\n\\setcounter{page}{1}\n\\input{foreword}\n\\input{chap_intro_abridged}\n\\cleardoublepage\n\\input{chap_curve_definition}\n\\cleardoublepage\n\\input{chap_curve_interrogation}\n\\cleardoublepage\n\\input{chap_curve_analysis}\n\\cleardoublepage\n\\input{chap_curve_utilities}\n\\cleardoublepage\n\\input{chap_surface_definition}\n\\cleardoublepage\n\\input{chap_surface_interrogation}\n\\cleardoublepage\n\\input{chap_surface_analysis}\n\\cleardoublepage\n\\input{chap_surface_utilities}\n\\cleardoublepage\n\\input{chap_data_reduction}\n\\cleardoublepage\n\\input{sample_programs}\n\\input{viewer}\n\\cleardoublepage\n\\input{chap_error_codes}\n\\cleardoublepage\n\\input{licensing_information}\n\\cleardoublepage\n\\printindex\n\\end{document}\n"
  },
  {
    "path": "doc/manual/manual.toc",
    "content": "\\contentsline {chapter}{\\numberline {1}Preface}{1}\n\\contentsline {section}{\\numberline {1.1}The structure of this document}{1}\n\\contentsline {section}{\\numberline {1.2}The structure of the software package}{2}\n\\contentsline {section}{\\numberline {1.3}Licensing information}{2}\n\\contentsline {chapter}{\\numberline {2}General Introduction}{3}\n\\contentsline {section}{\\numberline {2.1}C Syntax Used in Manual}{4}\n\\contentsline {section}{\\numberline {2.2}Dynamic Allocation in SISL}{4}\n\\contentsline {section}{\\numberline {2.3}Creating the library}{6}\n\\contentsline {section}{\\numberline {2.4}An Example Program}{7}\n\\contentsline {section}{\\numberline {2.5}B-spline Curves}{10}\n\\contentsline {subsection}{\\numberline {2.5.1}B-splines}{11}\n\\contentsline {subsection}{\\numberline {2.5.2}The Control Polygon}{13}\n\\contentsline {subsection}{\\numberline {2.5.3}The Knot Vector}{13}\n\\contentsline {subsection}{\\numberline {2.5.4}NURBS Curves}{14}\n\\contentsline {section}{\\numberline {2.6}B-spline Surfaces}{15}\n\\contentsline {subsection}{\\numberline {2.6.1}The Basis Functions}{16}\n\\contentsline {subsection}{\\numberline {2.6.2}NURBS Surfaces}{17}\n\\contentsline {chapter}{\\numberline {3}Curve Definition}{18}\n\\contentsline {section}{\\numberline {3.1}Interpolation}{18}\n\\contentsline {subsection}{\\numberline {3.1.1}Compute a curve interpolating a straight line between two points.}{18}\n\\contentsline {subsection}{\\numberline {3.1.2}Compute a curve interpolating a set of points, \\unhbox \\voidb@x \\hbox {automatic} parameterization.}{20}\n\\contentsline {subsection}{\\numberline {3.1.3}Compute a curve interpolating a set of points, parameter\\-ization as input.}{22}\n\\contentsline {subsection}{\\numberline {3.1.4}\\tolerance 9999\\emergencystretch 3em\\hfuzz .5\\p@ \\vfuzz \\hfuzz Compute a curve by Hermite interpolation, automatic parameteriza\\-tion.}{25}\n\\contentsline {subsection}{\\numberline {3.1.5}Compute a curve by Hermite interpolation, parameter\\-ization as input.}{27}\n\\contentsline {subsection}{\\numberline {3.1.6}Compute a fillet curve based on parameter value.}{29}\n\\contentsline {subsection}{\\numberline {3.1.7}Compute a fillet curve based on points.}{31}\n\\contentsline {subsection}{\\numberline {3.1.8}Compute a fillet curve based on radius.}{33}\n\\contentsline {subsection}{\\numberline {3.1.9}Compute a circular fillet between a 2D curve and a circle.}{36}\n\\contentsline {subsection}{\\numberline {3.1.10}Compute a circular fillet between two 2D curves.}{38}\n\\contentsline {subsection}{\\numberline {3.1.11}Compute a circular fillet between a 2D curve and a 2D line.}{40}\n\\contentsline {subsection}{\\numberline {3.1.12}Compute a blending curve between two curves.}{42}\n\\contentsline {section}{\\numberline {3.2}Approximation}{44}\n\\contentsline {subsection}{\\numberline {3.2.1}Approximate a circular arc with a curve.}{44}\n\\contentsline {subsection}{\\numberline {3.2.2}Approximate a conic arc with a curve.}{46}\n\\contentsline {subsection}{\\numberline {3.2.3}Compute a curve using the input points as controlling \\unhbox \\voidb@x \\hbox {vertices}, automatic parameterization.}{48}\n\\contentsline {subsection}{\\numberline {3.2.4}Approximate the offset of a curve with a curve.}{50}\n\\contentsline {subsection}{\\numberline {3.2.5}Approximate a curve with a sequence of straight lines.}{52}\n\\contentsline {section}{\\numberline {3.3}Mirror a Curve}{53}\n\\contentsline {section}{\\numberline {3.4}Conversion}{54}\n\\contentsline {subsection}{\\numberline {3.4.1}Convert a curve of order up to four, to a sequence of cubic polynomials.}{54}\n\\contentsline {subsection}{\\numberline {3.4.2}Convert a curve to a sequence of Bezier curves.}{55}\n\\contentsline {subsection}{\\numberline {3.4.3}Pick out the next Bezier curve from a curve.}{56}\n\\contentsline {subsection}{\\numberline {3.4.4}Express a curve using a higher order basis.}{58}\n\\contentsline {subsection}{\\numberline {3.4.5}Express the ``i''-th derivative of an open curve as a curve.}{59}\n\\contentsline {subsection}{\\numberline {3.4.6}Express a 2D or 3D ellipse as a curve.}{60}\n\\contentsline {subsection}{\\numberline {3.4.7}Express a conic arc as a curve.}{62}\n\\contentsline {subsection}{\\numberline {3.4.8}Express a truncated helix as a curve.}{64}\n\\contentsline {chapter}{\\numberline {4}Curve Interrogation}{66}\n\\contentsline {section}{\\numberline {4.1}Intersections}{66}\n\\contentsline {subsection}{\\numberline {4.1.1}Intersection between a curve and a point.}{66}\n\\contentsline {subsection}{\\numberline {4.1.2}\\tolerance 9999\\emergencystretch 3em\\hfuzz .5\\p@ \\vfuzz \\hfuzz Intersection between a spline curve and a straight line or a plane.}{68}\n\\contentsline {subsection}{\\numberline {4.1.3}Convert a curve/line intersection into a two-dimensional curve/origo intersection}{70}\n\\contentsline {subsection}{\\numberline {4.1.4}Intersection between a spline curve and a 2D circle or a sphere.}{71}\n\\contentsline {subsection}{\\numberline {4.1.5}Intersection between a curve and a quadric curve.}{73}\n\\contentsline {subsection}{\\numberline {4.1.6}\\tolerance 9999\\emergencystretch 3em\\hfuzz .5\\p@ \\vfuzz \\hfuzz Intersection between two curves.}{75}\n\\contentsline {section}{\\numberline {4.2}Compute the Length of a Curve}{77}\n\\contentsline {section}{\\numberline {4.3}Check if a Curve is Closed}{78}\n\\contentsline {section}{\\numberline {4.4}Check if a Curve is Degenerated.}{79}\n\\contentsline {section}{\\numberline {4.5}Pick the Parameter Range of a Curve}{80}\n\\contentsline {section}{\\numberline {4.6}Closest Points}{81}\n\\contentsline {subsection}{\\numberline {4.6.1}Find the closest point between a curve and a point.}{81}\n\\contentsline {subsection}{\\numberline {4.6.2}Find the closest point between a curve and a point. Simple version.}{83}\n\\contentsline {subsection}{\\numberline {4.6.3}Local iteration to closest point between point and curve.}{85}\n\\contentsline {subsection}{\\numberline {4.6.4}Find the closest points between two curves.}{87}\n\\contentsline {subsection}{\\numberline {4.6.5}Find a point on a 2D curve along a given direction.}{89}\n\\contentsline {section}{\\numberline {4.7}Find the Absolute Extremals of a Curve.}{90}\n\\contentsline {section}{\\numberline {4.8}Area between Curve and Point}{92}\n\\contentsline {subsection}{\\numberline {4.8.1}Calculate the area between a 2D curve and a 2D point.}{92}\n\\contentsline {subsection}{\\numberline {4.8.2}Calculate the weight point and rotational momentum of an area between a 2D curve and a 2D point.}{93}\n\\contentsline {section}{\\numberline {4.9}Bounding Box}{95}\n\\contentsline {subsection}{\\numberline {4.9.1}Bounding box object.}{95}\n\\contentsline {subsection}{\\numberline {4.9.2}Create and initialize a curve/surface bounding box instance.}{96}\n\\contentsline {subsection}{\\numberline {4.9.3}Find the bounding box of a curve.}{97}\n\\contentsline {section}{\\numberline {4.10}Normal Cone}{98}\n\\contentsline {subsection}{\\numberline {4.10.1}Normal cone object.}{98}\n\\contentsline {subsection}{\\numberline {4.10.2}Create and initialize a curve/surface direction instance.}{99}\n\\contentsline {subsection}{\\numberline {4.10.3}Find the direction cone of a curve.}{100}\n\\contentsline {chapter}{\\numberline {5}Curve Analysis}{101}\n\\contentsline {section}{\\numberline {5.1}Curvature Evaluation}{101}\n\\contentsline {subsection}{\\numberline {5.1.1}Evaluate the curvature of a curve at given parameter values.}{101}\n\\contentsline {subsection}{\\numberline {5.1.2}Evaluate the torsion of a curve at given parameter values.}{103}\n\\contentsline {subsection}{\\numberline {5.1.3}Evaluate the Variation of Curvature (VoC) of a curve at given parameter values.}{104}\n\\contentsline {subsection}{\\numberline {5.1.4}Evaluate the Frenet Frame (t,n,b) of a curve at given parameter values.}{105}\n\\contentsline {subsection}{\\numberline {5.1.5}Evaluate geometric properties at given parameter values.}{106}\n\\contentsline {chapter}{\\numberline {6}Curve Utilities}{108}\n\\contentsline {section}{\\numberline {6.1}Curve Object}{108}\n\\contentsline {subsection}{\\numberline {6.1.1}Create new curve object.}{110}\n\\contentsline {subsection}{\\numberline {6.1.2}Make a copy of a curve.}{112}\n\\contentsline {subsection}{\\numberline {6.1.3}Delete a curve object.}{113}\n\\contentsline {section}{\\numberline {6.2}Evaluation}{114}\n\\contentsline {subsection}{\\numberline {6.2.1}Compute the position and the left-hand derivatives of a curve at a given parameter value.}{114}\n\\contentsline {subsection}{\\numberline {6.2.2}Compute the position and the right-hand derivatives of a curve at a given parameter value.}{116}\n\\contentsline {subsection}{\\numberline {6.2.3}Evaluate position, first derivative, curvature and radius of curvature of a curve at a given parameter value, from the left hand side.}{118}\n\\contentsline {subsection}{\\numberline {6.2.4}Evaluate position, first derivative, curvature and radius of curvature of a curve at a given parameter value, from the right hand side.}{120}\n\\contentsline {subsection}{\\numberline {6.2.5}Evaluate the curve over a grid of m points. Only positions are evaluated.}{122}\n\\contentsline {section}{\\numberline {6.3}Subdivision}{122}\n\\contentsline {subsection}{\\numberline {6.3.1}Subdivide a curve at a given parameter value.}{122}\n\\contentsline {subsection}{\\numberline {6.3.2}Insert a given knot into the description of a curve.}{125}\n\\contentsline {subsection}{\\numberline {6.3.3}Insert a given set of knots into the description of a curve.}{126}\n\\contentsline {subsection}{\\numberline {6.3.4}Split a curve into two new curves.}{127}\n\\contentsline {subsection}{\\numberline {6.3.5}Pick a part of a curve.}{128}\n\\contentsline {subsection}{\\numberline {6.3.6}Pick a part of a closed curve.}{129}\n\\contentsline {section}{\\numberline {6.4}Joining}{130}\n\\contentsline {subsection}{\\numberline {6.4.1}Join two curves at specified ends.}{130}\n\\contentsline {subsection}{\\numberline {6.4.2}Join two curves at closest ends.}{132}\n\\contentsline {section}{\\numberline {6.5}Reverse the Orientation of a Curve.}{133}\n\\contentsline {section}{\\numberline {6.6}Extend a B-spline Curve.}{134}\n\\contentsline {chapter}{\\numberline {7}Surface Definition}{136}\n\\contentsline {section}{\\numberline {7.1}Interpolation}{136}\n\\contentsline {subsection}{\\numberline {7.1.1}Compute a surface interpolating a set of points, automatic parameterization.}{136}\n\\contentsline {subsection}{\\numberline {7.1.2}Compute a surface interpolating a set of points, parameterization as input.}{139}\n\\contentsline {subsection}{\\numberline {7.1.3}Compute a surface interpolating a set of points, derivatives as input.}{142}\n\\contentsline {subsection}{\\numberline {7.1.4}Compute a surface interpolating a set of points, derivatives and parameterization as input.}{145}\n\\contentsline {subsection}{\\numberline {7.1.5}\\tolerance 9999\\emergencystretch 3em\\hfuzz .5\\p@ \\vfuzz \\hfuzz Compute a surface by Hermite interpolation, automatic parameter\\-ization.}{148}\n\\contentsline {subsection}{\\numberline {7.1.6}Compute a surface by Hermite interpolation, parameter\\-ization as input.}{150}\n\\contentsline {subsection}{\\numberline {7.1.7}Create a lofted surface from a set of B-spline input curves.}{152}\n\\contentsline {subsection}{\\numberline {7.1.8}Create a lofted surface from a set of B-spline input curves and parametrization.}{154}\n\\contentsline {subsection}{\\numberline {7.1.9}Create a rational lofted surface from a set of rational input-curves}{156}\n\\contentsline {subsection}{\\numberline {7.1.10}Compute a rectangular blending surface from a set of \\unhbox \\voidb@x \\hbox {B-spline} input curves.}{157}\n\\contentsline {subsection}{\\numberline {7.1.11}Compute a first derivative continuous blending surface set, over a 3-, 4-, 5- or 6-sided region in space, from a set of B-spline input curves.}{159}\n\\contentsline {subsection}{\\numberline {7.1.12}Compute a surface, representing a Gordon patch, from a set of B-spline input curves.}{161}\n\\contentsline {section}{\\numberline {7.2}Approximation}{163}\n\\contentsline {subsection}{\\numberline {7.2.1}Compute a surface using the input points as control vertices, automatic parameterization.}{163}\n\\contentsline {subsection}{\\numberline {7.2.2}Compute a linear swept surface.}{165}\n\\contentsline {subsection}{\\numberline {7.2.3}Compute a rotational swept surface.}{166}\n\\contentsline {subsection}{\\numberline {7.2.4}Compute a surface approximating the offset of a surface.}{168}\n\\contentsline {section}{\\numberline {7.3}Mirror a Surface}{170}\n\\contentsline {section}{\\numberline {7.4}Conversion}{171}\n\\contentsline {subsection}{\\numberline {7.4.1}Convert a surface of order up to four to a mesh of Coons patches.}{171}\n\\contentsline {subsection}{\\numberline {7.4.2}Convert a surface to a mesh of Bezier surfaces.}{173}\n\\contentsline {subsection}{\\numberline {7.4.3}Pick the next Bezier surface from a surface.}{174}\n\\contentsline {subsection}{\\numberline {7.4.4}Express a surface using a higher order basis.}{176}\n\\contentsline {subsection}{\\numberline {7.4.5}Express the ``i,j''-th derivative of an open surface as a \\unhbox \\voidb@x \\hbox {surface}.}{177}\n\\contentsline {subsection}{\\numberline {7.4.6}Express the octants of a sphere as a surface.}{178}\n\\contentsline {subsection}{\\numberline {7.4.7}Express a truncated cylinder as a surface.}{180}\n\\contentsline {subsection}{\\numberline {7.4.8}Express the octants of a torus as a surface.}{181}\n\\contentsline {subsection}{\\numberline {7.4.9}Express a truncated cone as a surface.}{183}\n\\contentsline {chapter}{\\numberline {8}Surface Interrogation}{185}\n\\contentsline {section}{\\numberline {8.1}Intersection Curves}{185}\n\\contentsline {subsection}{\\numberline {8.1.1}Intersection curve object.}{185}\n\\contentsline {subsection}{\\numberline {8.1.2}Create a new intersection curve object.}{187}\n\\contentsline {subsection}{\\numberline {8.1.3}Delete an intersection curve object.}{189}\n\\contentsline {subsection}{\\numberline {8.1.4}Free a list of intersection curves.}{190}\n\\contentsline {section}{\\numberline {8.2}Find the Intersections}{191}\n\\contentsline {subsection}{\\numberline {8.2.1}\\tolerance 9999\\emergencystretch 3em\\hfuzz .5\\p@ \\vfuzz \\hfuzz Intersection between a spline curve and a straight line or a plane.}{191}\n\\contentsline {subsection}{\\numberline {8.2.2}Intersection between a spline curve and a 2D circle or a sphere.}{193}\n\\contentsline {subsection}{\\numberline {8.2.3}Intersection between a spline curve and a cylinder.}{195}\n\\contentsline {subsection}{\\numberline {8.2.4}Intersection between a spline curve and a cone.}{197}\n\\contentsline {subsection}{\\numberline {8.2.5}Intersection between a spline curve and an elliptic cone.}{199}\n\\contentsline {subsection}{\\numberline {8.2.6}Intersection between a curve and a torus.}{201}\n\\contentsline {subsection}{\\numberline {8.2.7}Intersection between a surface and a point.}{203}\n\\contentsline {subsection}{\\numberline {8.2.8}Intersection between a spline surface and a straight line.}{205}\n\\contentsline {subsection}{\\numberline {8.2.9}Newton iteration on the intersection between a 3D NURBS surface and a line.}{207}\n\\contentsline {subsection}{\\numberline {8.2.10}Convert a surface/line intersection into a two-dimensional surface/origo intersection}{209}\n\\contentsline {subsection}{\\numberline {8.2.11}Intersection between a spline surface and a circle.}{210}\n\\contentsline {subsection}{\\numberline {8.2.12}Intersection between a surface and a curve.}{212}\n\\contentsline {section}{\\numberline {8.3}Find the Topology of the Intersection}{214}\n\\contentsline {subsection}{\\numberline {8.3.1}Find the topology for the intersections between a spline surface and a plane.}{214}\n\\contentsline {subsection}{\\numberline {8.3.2}Find the topology for the intersection between a spline surface and a sphere.}{216}\n\\contentsline {subsection}{\\numberline {8.3.3}Find the topology for the intersections between a spline surface and a cylinder.}{218}\n\\contentsline {subsection}{\\numberline {8.3.4}Find the topology for the intersections between a spline surface and a cone.}{220}\n\\contentsline {subsection}{\\numberline {8.3.5}Find the topology for the intersections between a spline surface and an \\unhbox \\voidb@x \\hbox {elliptic} cone.}{222}\n\\contentsline {subsection}{\\numberline {8.3.6}Find the topology for the intersections between a spline surface and a \\unhbox \\voidb@x \\hbox {torus}.}{224}\n\\contentsline {subsection}{\\numberline {8.3.7}Find the topology for the intersection between two spline surfaces.}{226}\n\\contentsline {section}{\\numberline {8.4}Find the Topology of a Silhouette}{228}\n\\contentsline {subsection}{\\numberline {8.4.1}Find the topology of the silhouette curves of a spline surface, using parallel projection.}{228}\n\\contentsline {subsection}{\\numberline {8.4.2}Find the topology of the silhouette curves of a spline surface, using perspective projection.}{230}\n\\contentsline {subsection}{\\numberline {8.4.3}Find the topology of the circular silhouette curves of a spline \\unhbox \\voidb@x \\hbox {surface}.}{232}\n\\contentsline {section}{\\numberline {8.5}Marching}{234}\n\\contentsline {subsection}{\\numberline {8.5.1}March an intersection curve between a spline surface and a plane.}{234}\n\\contentsline {subsection}{\\numberline {8.5.2}March an intersection curve between a spline surface and a sphere.}{236}\n\\contentsline {subsection}{\\numberline {8.5.3}March an intersection curve between a spline surface and a \\unhbox \\voidb@x \\hbox {cylinder}.}{238}\n\\contentsline {subsection}{\\numberline {8.5.4}March an intersection curve between a spline surface and a cone.}{240}\n\\contentsline {subsection}{\\numberline {8.5.5}March an intersection curve between a surface and an \\unhbox \\voidb@x \\hbox {elliptic} cone.}{242}\n\\contentsline {subsection}{\\numberline {8.5.6}March an intersection curve between a spline surface and a torus.}{245}\n\\contentsline {subsection}{\\numberline {8.5.7}March an intersection curve between two spline surfaces.}{248}\n\\contentsline {section}{\\numberline {8.6}Marching of Silhouettes}{250}\n\\contentsline {subsection}{\\numberline {8.6.1}\\tolerance 9999\\emergencystretch 3em\\hfuzz .5\\p@ \\vfuzz \\hfuzz March a silhouette curve of a surface, using parallel \\unhbox \\voidb@x \\hbox {projection}.}{250}\n\\contentsline {subsection}{\\numberline {8.6.2}\\tolerance 9999\\emergencystretch 3em\\hfuzz .5\\p@ \\vfuzz \\hfuzz March a silhouette curve of a surface, using perspective \\unhbox \\voidb@x \\hbox {projection}.}{253}\n\\contentsline {subsection}{\\numberline {8.6.3}March a circular silhouette curve of a surface.}{255}\n\\contentsline {section}{\\numberline {8.7}Check if a Surface is Closed or has Degenerate Edges.}{257}\n\\contentsline {section}{\\numberline {8.8}Pick the Parameter Ranges of a Surface}{259}\n\\contentsline {section}{\\numberline {8.9}Closest Points}{260}\n\\contentsline {subsection}{\\numberline {8.9.1}Find the closest point between a surface and a point.}{260}\n\\contentsline {subsection}{\\numberline {8.9.2}Find the closest point between a surface and a point. Simple version.}{262}\n\\contentsline {subsection}{\\numberline {8.9.3}Local iteration to closest point bewteen point and surface.}{264}\n\\contentsline {section}{\\numberline {8.10}Find the Absolute Extremals of a Surface.}{266}\n\\contentsline {section}{\\numberline {8.11}Bounding Box}{268}\n\\contentsline {subsection}{\\numberline {8.11.1}Find the bounding box of a surface.}{268}\n\\contentsline {section}{\\numberline {8.12}Normal Cone}{269}\n\\contentsline {subsection}{\\numberline {8.12.1}Find the direction cone of a surface.}{269}\n\\contentsline {chapter}{\\numberline {9}Surface Analysis}{272}\n\\contentsline {section}{\\numberline {9.1}Curvature Evaluation}{272}\n\\contentsline {subsection}{\\numberline {9.1.1}Gaussian curvature of a spline surface.}{272}\n\\contentsline {subsection}{\\numberline {9.1.2}Mean curvature of a spline surface.}{275}\n\\contentsline {subsection}{\\numberline {9.1.3}Absolute curvature of a spline surface.}{277}\n\\contentsline {subsection}{\\numberline {9.1.4}Total curvature of a spline surface.}{279}\n\\contentsline {subsection}{\\numberline {9.1.5}Second order Mehlum curvature of a spline surface.}{281}\n\\contentsline {subsection}{\\numberline {9.1.6}Third order Mehlum curvature of a spline surface.}{283}\n\\contentsline {subsection}{\\numberline {9.1.7}Gaussian curvature of a B-spline or NURBS surface as a NURBS surface.}{285}\n\\contentsline {subsection}{\\numberline {9.1.8}Mehlum curvature of a B-spline or NURBS surface as a NURBS surface.}{287}\n\\contentsline {subsection}{\\numberline {9.1.9}Curvature on a uniform grid of a NURBS surface.}{289}\n\\contentsline {subsection}{\\numberline {9.1.10}Principal curvatures of a spline surface.}{291}\n\\contentsline {subsection}{\\numberline {9.1.11}Normal curvature of a spline surface.}{293}\n\\contentsline {subsection}{\\numberline {9.1.12}Focal values on a uniform grid of a NURBS surface.}{295}\n\\contentsline {chapter}{\\numberline {10}Surface Utilities}{297}\n\\contentsline {section}{\\numberline {10.1}Surface Object}{297}\n\\contentsline {subsection}{\\numberline {10.1.1}Create a new surface object.}{299}\n\\contentsline {subsection}{\\numberline {10.1.2}Make a copy of a surface object.}{302}\n\\contentsline {subsection}{\\numberline {10.1.3}Delete a surface object.}{303}\n\\contentsline {section}{\\numberline {10.2}Evaluation}{304}\n\\contentsline {subsection}{\\numberline {10.2.1}Compute the position, the derivatives and the normal of a surface at a given parameter value pair.}{304}\n\\contentsline {subsection}{\\numberline {10.2.2}Compute the position and derivatives of a surface at a given parameter value pair.}{306}\n\\contentsline {subsection}{\\numberline {10.2.3}Compute the position and the left- or right-hand derivatives of a surface at a given parameter value pair.}{308}\n\\contentsline {subsection}{\\numberline {10.2.4}Compute the position and the derivatives of a surface at a given parameter value pair.}{311}\n\\contentsline {subsection}{\\numberline {10.2.5}Evaluate the surface pointed at by ps1 over an m1 * m2 grid of points (x[i],y[j]). Compute ider derivatives and normals if suitable.}{315}\n\\contentsline {section}{\\numberline {10.3}Subdivision}{317}\n\\contentsline {subsection}{\\numberline {10.3.1}Subdivide a surface along a given parameter line.}{317}\n\\contentsline {subsection}{\\numberline {10.3.2}Insert a given set of knots, in each parameter direction, into the description of a surface.}{318}\n\\contentsline {section}{\\numberline {10.4}Picking Curves from a Surface}{320}\n\\contentsline {subsection}{\\numberline {10.4.1}Pick a curve along a constant parameter line in a surface.}{320}\n\\contentsline {subsection}{\\numberline {10.4.2}Pick the curve lying in a surface, described by a curve in the parameter plane of the surface.}{321}\n\\contentsline {section}{\\numberline {10.5}Pick a Part of a Surface.}{323}\n\\contentsline {section}{\\numberline {10.6}Turn the Direction of the Surface Normal Vector.}{324}\n\\contentsline {chapter}{\\numberline {11}Data Reduction}{325}\n\\contentsline {section}{\\numberline {11.1}Curves}{325}\n\\contentsline {subsection}{\\numberline {11.1.1}Data reduction: B-spline curve as input.}{325}\n\\contentsline {subsection}{\\numberline {11.1.2}Data reduction: Point data as input.}{328}\n\\contentsline {subsection}{\\numberline {11.1.3}Data reduction: Points and tangents as input.}{331}\n\\contentsline {subsection}{\\numberline {11.1.4}Degree reduction: B-spline curve as input.}{333}\n\\contentsline {section}{\\numberline {11.2}Surfaces}{335}\n\\contentsline {subsection}{\\numberline {11.2.1}Data reduction: B-spline surface as input.}{335}\n\\contentsline {subsection}{\\numberline {11.2.2}Data reduction: Point data as input.}{338}\n\\contentsline {subsection}{\\numberline {11.2.3}Data reduction: Points and tangents as input.}{341}\n\\contentsline {subsection}{\\numberline {11.2.4}Degree reduction: B-spline surface as input.}{344}\n\\contentsline {chapter}{\\numberline {12}Tutorial programs}{346}\n\\contentsline {section}{\\numberline {12.1}Compiling the programs}{346}\n\\contentsline {section}{\\numberline {12.2}Description and commentaries on the sample programs}{346}\n\\contentsline {subsection}{\\numberline {12.2.1}example01.C}{347}\n\\contentsline {subsubsection}{What it does}{347}\n\\contentsline {subsubsection}{What it demonstrates}{347}\n\\contentsline {subsubsection}{Input/output}{347}\n\\contentsline {subsection}{\\numberline {12.2.2}example02.C}{347}\n\\contentsline {subsubsection}{What it does}{347}\n\\contentsline {subsubsection}{What it demonstrates}{347}\n\\contentsline {subsubsection}{Input/output}{347}\n\\contentsline {subsection}{\\numberline {12.2.3}example03.C}{347}\n\\contentsline {subsubsection}{What it does}{347}\n\\contentsline {subsubsection}{What it demonstrates}{348}\n\\contentsline {subsubsection}{Input/output}{348}\n\\contentsline {subsection}{\\numberline {12.2.4}example04.C}{348}\n\\contentsline {subsubsection}{What it does}{348}\n\\contentsline {subsubsection}{What it demonstrates}{348}\n\\contentsline {subsubsection}{Input/output}{348}\n\\contentsline {subsection}{\\numberline {12.2.5}example05.C}{348}\n\\contentsline {subsubsection}{What it does}{348}\n\\contentsline {subsubsection}{What it demonstrates}{349}\n\\contentsline {subsubsection}{Input/output}{349}\n\\contentsline {subsection}{\\numberline {12.2.6}example06.C}{349}\n\\contentsline {subsubsection}{What it does}{349}\n\\contentsline {subsubsection}{What it demonstrates}{349}\n\\contentsline {subsubsection}{Input/output}{349}\n\\contentsline {subsection}{\\numberline {12.2.7}example07.C}{349}\n\\contentsline {subsubsection}{What it does}{349}\n\\contentsline {subsubsection}{What it demonstrates}{349}\n\\contentsline {subsubsection}{Input/output}{350}\n\\contentsline {subsection}{\\numberline {12.2.8}example08.C}{350}\n\\contentsline {subsubsection}{What it does}{350}\n\\contentsline {subsubsection}{What it demonstrates}{350}\n\\contentsline {subsubsection}{Input/output}{350}\n\\contentsline {subsection}{\\numberline {12.2.9}example09.C}{350}\n\\contentsline {subsubsection}{What it does}{350}\n\\contentsline {subsubsection}{What it demonstrates}{350}\n\\contentsline {subsubsection}{Input/output}{350}\n\\contentsline {subsection}{\\numberline {12.2.10}example10.C}{351}\n\\contentsline {subsubsection}{What it does}{351}\n\\contentsline {subsubsection}{What it demonstrates}{351}\n\\contentsline {subsubsection}{Input/output}{351}\n\\contentsline {subsection}{\\numberline {12.2.11}example11.C}{351}\n\\contentsline {subsubsection}{What it does}{351}\n\\contentsline {subsubsection}{What it demonstrates}{351}\n\\contentsline {subsubsection}{Input/output}{351}\n\\contentsline {subsection}{\\numberline {12.2.12}example12.C}{351}\n\\contentsline {subsubsection}{What it does}{351}\n\\contentsline {subsubsection}{What it demonstrates}{351}\n\\contentsline {subsubsection}{Input/output}{352}\n\\contentsline {subsection}{\\numberline {12.2.13}example13.C}{352}\n\\contentsline {subsubsection}{What it does}{352}\n\\contentsline {subsubsection}{What it demonstrates}{352}\n\\contentsline {subsubsection}{Input/output}{352}\n\\contentsline {subsection}{\\numberline {12.2.14}example14.C}{352}\n\\contentsline {subsubsection}{What it does}{352}\n\\contentsline {subsubsection}{What it demonstrates}{353}\n\\contentsline {subsubsection}{Input/output}{353}\n\\contentsline {subsection}{\\numberline {12.2.15}example15.C}{353}\n\\contentsline {subsubsection}{What it does}{353}\n\\contentsline {subsubsection}{What it demonstrates}{354}\n\\contentsline {subsubsection}{Input/output}{354}\n\\contentsline {chapter}{\\numberline {13}The object viewer program}{355}\n\\contentsline {section}{\\numberline {13.1}General}{355}\n\\contentsline {section}{\\numberline {13.2}Compiling the viewer}{355}\n\\contentsline {section}{\\numberline {13.3}Command line arguments}{356}\n\\contentsline {section}{\\numberline {13.4}User controls}{356}\n\\contentsline {subsection}{\\numberline {13.4.1}Mouse commands}{356}\n\\contentsline {subsection}{\\numberline {13.4.2}Keyboard commands}{357}\n\\contentsline {chapter}{\\numberline {14}Appendix: Error Codes}{358}\n\\contentsline {chapter}{\\numberline {A}GNU AFFERO GENERAL PUBLIC LICENSE}{363}\n"
  },
  {
    "path": "doc/manual/raytracing.ps",
    "content": "%!PS-Adobe-2.0 EPSF-2.0\n%%Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software\n%%Title: f2pspost.dvi\n%%BoundingBox: 133 188 644 610\n%%EndComments\n%DVIPSWebPage: (www.radicaleye.com)\n%DVIPSCommandLine: dvips -E -o f2pspost.ps f2pspost\n%DVIPSParameters: dpi=600, compressed\n%DVIPSSource:  TeX output 2005.02.08:1046\n%%BeginProcSet: texc.pro\n%!\n/TeXDict 300 dict def TeXDict begin/N{def}def/B{bind def}N/S{exch}N/X{S\nN}B/A{dup}B/TR{translate}N/isls false N/vsize 11 72 mul N/hsize 8.5 72\nmul N/landplus90{false}def/@rigin{isls{[0 landplus90{1 -1}{-1 1}ifelse 0\n0 0]concat}if 72 Resolution div 72 VResolution div neg scale isls{\nlandplus90{VResolution 72 div vsize mul 0 exch}{Resolution -72 div hsize\nmul 0}ifelse TR}if Resolution VResolution vsize -72 div 1 add mul TR[\nmatrix currentmatrix{A A round sub abs 0.00001 lt{round}if}forall round\nexch round exch]setmatrix}N/@landscape{/isls true N}B/@manualfeed{\nstatusdict/manualfeed true put}B/@copies{/#copies X}B/FMat[1 0 0 -1 0 0]\nN/FBB[0 0 0 0]N/nn 0 N/IEn 0 N/ctr 0 N/df-tail{/nn 8 dict N nn begin\n/FontType 3 N/FontMatrix fntrx N/FontBBox FBB N string/base X array\n/BitMaps X/BuildChar{CharBuilder}N/Encoding IEn N end A{/foo setfont}2\narray copy cvx N load 0 nn put/ctr 0 N[}B/sf 0 N/df{/sf 1 N/fntrx FMat N\ndf-tail}B/dfs{div/sf X/fntrx[sf 0 0 sf neg 0 0]N df-tail}B/E{pop nn A\ndefinefont setfont}B/Cw{Cd A length 5 sub get}B/Ch{Cd A length 4 sub get\n}B/Cx{128 Cd A length 3 sub get sub}B/Cy{Cd A length 2 sub get 127 sub}\nB/Cdx{Cd A length 1 sub get}B/Ci{Cd A type/stringtype ne{ctr get/ctr ctr\n1 add N}if}B/id 0 N/rw 0 N/rc 0 N/gp 0 N/cp 0 N/G 0 N/CharBuilder{save 3\n1 roll S A/base get 2 index get S/BitMaps get S get/Cd X pop/ctr 0 N Cdx\n0 Cx Cy Ch sub Cx Cw add Cy setcachedevice Cw Ch true[1 0 0 -1 -.1 Cx\nsub Cy .1 sub]/id Ci N/rw Cw 7 add 8 idiv string N/rc 0 N/gp 0 N/cp 0 N{\nrc 0 ne{rc 1 sub/rc X rw}{G}ifelse}imagemask restore}B/G{{id gp get/gp\ngp 1 add N A 18 mod S 18 idiv pl S get exec}loop}B/adv{cp add/cp X}B\n/chg{rw cp id gp 4 index getinterval putinterval A gp add/gp X adv}B/nd{\n/cp 0 N rw exit}B/lsh{rw cp 2 copy get A 0 eq{pop 1}{A 255 eq{pop 254}{\nA A add 255 and S 1 and or}ifelse}ifelse put 1 adv}B/rsh{rw cp 2 copy\nget A 0 eq{pop 128}{A 255 eq{pop 127}{A 2 idiv S 128 and or}ifelse}\nifelse put 1 adv}B/clr{rw cp 2 index string putinterval adv}B/set{rw cp\nfillstr 0 4 index getinterval putinterval adv}B/fillstr 18 string 0 1 17\n{2 copy 255 put pop}for N/pl[{adv 1 chg}{adv 1 chg nd}{1 add chg}{1 add\nchg nd}{adv lsh}{adv lsh nd}{adv rsh}{adv rsh nd}{1 add adv}{/rc X nd}{\n1 add set}{1 add clr}{adv 2 chg}{adv 2 chg nd}{pop nd}]A{bind pop}\nforall N/D{/cc X A type/stringtype ne{]}if nn/base get cc ctr put nn\n/BitMaps get S ctr S sf 1 ne{A A length 1 sub A 2 index S get sf div put\n}if put/ctr ctr 1 add N}B/I{cc 1 add D}B/bop{userdict/bop-hook known{\nbop-hook}if/SI save N @rigin 0 0 moveto/V matrix currentmatrix A 1 get A\nmul exch 0 get A mul add .99 lt{/QV}{/RV}ifelse load def pop pop}N/eop{\nSI restore userdict/eop-hook known{eop-hook}if showpage}N/@start{\nuserdict/start-hook known{start-hook}if pop/VResolution X/Resolution X\n1000 div/DVImag X/IEn 256 array N 2 string 0 1 255{IEn S A 360 add 36 4\nindex cvrs cvn put}for pop 65781.76 div/vsize X 65781.76 div/hsize X}N\n/p{show}N/RMat[1 0 0 -1 0 0]N/BDot 260 string N/Rx 0 N/Ry 0 N/V{}B/RV/v{\n/Ry X/Rx X V}B statusdict begin/product where{pop false[(Display)(NeXT)\n(LaserWriter 16/600)]{A length product length le{A length product exch 0\nexch getinterval eq{pop true exit}if}{pop}ifelse}forall}{false}ifelse\nend{{gsave TR -.1 .1 TR 1 1 scale Rx Ry false RMat{BDot}imagemask\ngrestore}}{{gsave TR -.1 .1 TR Rx Ry scale 1 1 false RMat{BDot}\nimagemask grestore}}ifelse B/QV{gsave newpath transform round exch round\nexch itransform moveto Rx 0 rlineto 0 Ry neg rlineto Rx neg 0 rlineto\nfill grestore}B/a{moveto}B/delta 0 N/tail{A/delta X 0 rmoveto}B/M{S p\ndelta add tail}B/b{S p tail}B/c{-4 M}B/d{-3 M}B/e{-2 M}B/f{-1 M}B/g{0 M}\nB/h{1 M}B/i{2 M}B/j{3 M}B/k{4 M}B/w{0 rmoveto}B/l{p -4 w}B/m{p -3 w}B/n{\np -2 w}B/o{p -1 w}B/q{p 1 w}B/r{p 2 w}B/s{p 3 w}B/t{p 4 w}B/x{0 S\nrmoveto}B/y{3 2 roll p a}B/bos{/SS save N}B/eos{SS restore}B end\n\n%%EndProcSet\n%%BeginProcSet: special.pro\n%!\nTeXDict begin/SDict 200 dict N SDict begin/@SpecialDefaults{/hs 612 N\n/vs 792 N/ho 0 N/vo 0 N/hsc 1 N/vsc 1 N/ang 0 N/CLIP 0 N/rwiSeen false N\n/rhiSeen false N/letter{}N/note{}N/a4{}N/legal{}N}B/@scaleunit 100 N\n/@hscale{@scaleunit div/hsc X}B/@vscale{@scaleunit div/vsc X}B/@hsize{\n/hs X/CLIP 1 N}B/@vsize{/vs X/CLIP 1 N}B/@clip{/CLIP 2 N}B/@hoffset{/ho\nX}B/@voffset{/vo X}B/@angle{/ang X}B/@rwi{10 div/rwi X/rwiSeen true N}B\n/@rhi{10 div/rhi X/rhiSeen true N}B/@llx{/llx X}B/@lly{/lly X}B/@urx{\n/urx X}B/@ury{/ury X}B/magscale true def end/@MacSetUp{userdict/md known\n{userdict/md get type/dicttype eq{userdict begin md length 10 add md\nmaxlength ge{/md md dup length 20 add dict copy def}if end md begin\n/letter{}N/note{}N/legal{}N/od{txpose 1 0 mtx defaultmatrix dtransform S\natan/pa X newpath clippath mark{transform{itransform moveto}}{transform{\nitransform lineto}}{6 -2 roll transform 6 -2 roll transform 6 -2 roll\ntransform{itransform 6 2 roll itransform 6 2 roll itransform 6 2 roll\ncurveto}}{{closepath}}pathforall newpath counttomark array astore/gc xdf\npop ct 39 0 put 10 fz 0 fs 2 F/|______Courier fnt invertflag{PaintBlack}\nif}N/txpose{pxs pys scale ppr aload pop por{noflips{pop S neg S TR pop 1\n-1 scale}if xflip yflip and{pop S neg S TR 180 rotate 1 -1 scale ppr 3\nget ppr 1 get neg sub neg ppr 2 get ppr 0 get neg sub neg TR}if xflip\nyflip not and{pop S neg S TR pop 180 rotate ppr 3 get ppr 1 get neg sub\nneg 0 TR}if yflip xflip not and{ppr 1 get neg ppr 0 get neg TR}if}{\nnoflips{TR pop pop 270 rotate 1 -1 scale}if xflip yflip and{TR pop pop\n90 rotate 1 -1 scale ppr 3 get ppr 1 get neg sub neg ppr 2 get ppr 0 get\nneg sub neg TR}if xflip yflip not and{TR pop pop 90 rotate ppr 3 get ppr\n1 get neg sub neg 0 TR}if yflip xflip not and{TR pop pop 270 rotate ppr\n2 get ppr 0 get neg sub neg 0 S TR}if}ifelse scaleby96{ppr aload pop 4\n-1 roll add 2 div 3 1 roll add 2 div 2 copy TR .96 dup scale neg S neg S\nTR}if}N/cp{pop pop showpage pm restore}N end}if}if}N/normalscale{\nResolution 72 div VResolution 72 div neg scale magscale{DVImag dup scale\n}if 0 setgray}N/psfts{S 65781.76 div N}N/startTexFig{/psf$SavedState\nsave N userdict maxlength dict begin/magscale true def normalscale\ncurrentpoint TR/psf$ury psfts/psf$urx psfts/psf$lly psfts/psf$llx psfts\n/psf$y psfts/psf$x psfts currentpoint/psf$cy X/psf$cx X/psf$sx psf$x\npsf$urx psf$llx sub div N/psf$sy psf$y psf$ury psf$lly sub div N psf$sx\npsf$sy scale psf$cx psf$sx div psf$llx sub psf$cy psf$sy div psf$ury sub\nTR/showpage{}N/erasepage{}N/setpagedevice{pop}N/copypage{}N/p 3 def\n@MacSetUp}N/doclip{psf$llx psf$lly psf$urx psf$ury currentpoint 6 2 roll\nnewpath 4 copy 4 2 roll moveto 6 -1 roll S lineto S lineto S lineto\nclosepath clip newpath moveto}N/endTexFig{end psf$SavedState restore}N\n/@beginspecial{SDict begin/SpecialSave save N gsave normalscale\ncurrentpoint TR @SpecialDefaults count/ocount X/dcount countdictstack N}\nN/@setspecial{CLIP 1 eq{newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs\nneg 0 rlineto closepath clip}if ho vo TR hsc vsc scale ang rotate\nrwiSeen{rwi urx llx sub div rhiSeen{rhi ury lly sub div}{dup}ifelse\nscale llx neg lly neg TR}{rhiSeen{rhi ury lly sub div dup scale llx neg\nlly neg TR}if}ifelse CLIP 2 eq{newpath llx lly moveto urx lly lineto urx\nury lineto llx ury lineto closepath clip}if/showpage{}N/erasepage{}N\n/setpagedevice{pop}N/copypage{}N newpath}N/@endspecial{count ocount sub{\npop}repeat countdictstack dcount sub{end}repeat grestore SpecialSave\nrestore end}N/@defspecial{SDict begin}N/@fedspecial{end}B/li{lineto}B\n/rl{rlineto}B/rc{rcurveto}B/np{/SaveX currentpoint/SaveY X N 1\nsetlinecap newpath}N/st{stroke SaveX SaveY moveto}N/fil{fill SaveX SaveY\nmoveto}N/ellipse{/endangle X/startangle X/yrad X/xrad X/savematrix\nmatrix currentmatrix N TR xrad yrad scale 0 0 1 startangle endangle arc\nsavematrix setmatrix}N end\n\n%%EndProcSet\n%%BeginProcSet: color.pro\n%!\nTeXDict begin/setcmykcolor where{pop}{/setcmykcolor{dup 10 eq{pop\nsetrgbcolor}{1 sub 4 1 roll 3{3 index add neg dup 0 lt{pop 0}if 3 1 roll\n}repeat setrgbcolor pop}ifelse}B}ifelse/TeXcolorcmyk{setcmykcolor}def\n/TeXcolorrgb{setrgbcolor}def/TeXcolorgrey{setgray}def/TeXcolorgray{\nsetgray}def/TeXcolorhsb{sethsbcolor}def/currentcmykcolor where{pop}{\n/currentcmykcolor{currentrgbcolor 10}B}ifelse/DC{exch dup userdict exch\nknown{pop pop}{X}ifelse}B/GreenYellow{0.15 0 0.69 0 setcmykcolor}DC\n/Yellow{0 0 1 0 setcmykcolor}DC/Goldenrod{0 0.10 0.84 0 setcmykcolor}DC\n/Dandelion{0 0.29 0.84 0 setcmykcolor}DC/Apricot{0 0.32 0.52 0\nsetcmykcolor}DC/Peach{0 0.50 0.70 0 setcmykcolor}DC/Melon{0 0.46 0.50 0\nsetcmykcolor}DC/YellowOrange{0 0.42 1 0 setcmykcolor}DC/Orange{0 0.61\n0.87 0 setcmykcolor}DC/BurntOrange{0 0.51 1 0 setcmykcolor}DC\n/Bittersweet{0 0.75 1 0.24 setcmykcolor}DC/RedOrange{0 0.77 0.87 0\nsetcmykcolor}DC/Mahogany{0 0.85 0.87 0.35 setcmykcolor}DC/Maroon{0 0.87\n0.68 0.32 setcmykcolor}DC/BrickRed{0 0.89 0.94 0.28 setcmykcolor}DC/Red{\n0 1 1 0 setcmykcolor}DC/OrangeRed{0 1 0.50 0 setcmykcolor}DC/RubineRed{\n0 1 0.13 0 setcmykcolor}DC/WildStrawberry{0 0.96 0.39 0 setcmykcolor}DC\n/Salmon{0 0.53 0.38 0 setcmykcolor}DC/CarnationPink{0 0.63 0 0\nsetcmykcolor}DC/Magenta{0 1 0 0 setcmykcolor}DC/VioletRed{0 0.81 0 0\nsetcmykcolor}DC/Rhodamine{0 0.82 0 0 setcmykcolor}DC/Mulberry{0.34 0.90\n0 0.02 setcmykcolor}DC/RedViolet{0.07 0.90 0 0.34 setcmykcolor}DC\n/Fuchsia{0.47 0.91 0 0.08 setcmykcolor}DC/Lavender{0 0.48 0 0\nsetcmykcolor}DC/Thistle{0.12 0.59 0 0 setcmykcolor}DC/Orchid{0.32 0.64 0\n0 setcmykcolor}DC/DarkOrchid{0.40 0.80 0.20 0 setcmykcolor}DC/Purple{\n0.45 0.86 0 0 setcmykcolor}DC/Plum{0.50 1 0 0 setcmykcolor}DC/Violet{\n0.79 0.88 0 0 setcmykcolor}DC/RoyalPurple{0.75 0.90 0 0 setcmykcolor}DC\n/BlueViolet{0.86 0.91 0 0.04 setcmykcolor}DC/Periwinkle{0.57 0.55 0 0\nsetcmykcolor}DC/CadetBlue{0.62 0.57 0.23 0 setcmykcolor}DC\n/CornflowerBlue{0.65 0.13 0 0 setcmykcolor}DC/MidnightBlue{0.98 0.13 0\n0.43 setcmykcolor}DC/NavyBlue{0.94 0.54 0 0 setcmykcolor}DC/RoyalBlue{1\n0.50 0 0 setcmykcolor}DC/Blue{1 1 0 0 setcmykcolor}DC/Cerulean{0.94 0.11\n0 0 setcmykcolor}DC/Cyan{1 0 0 0 setcmykcolor}DC/ProcessBlue{0.96 0 0 0\nsetcmykcolor}DC/SkyBlue{0.62 0 0.12 0 setcmykcolor}DC/Turquoise{0.85 0\n0.20 0 setcmykcolor}DC/TealBlue{0.86 0 0.34 0.02 setcmykcolor}DC\n/Aquamarine{0.82 0 0.30 0 setcmykcolor}DC/BlueGreen{0.85 0 0.33 0\nsetcmykcolor}DC/Emerald{1 0 0.50 0 setcmykcolor}DC/JungleGreen{0.99 0\n0.52 0 setcmykcolor}DC/SeaGreen{0.69 0 0.50 0 setcmykcolor}DC/Green{1 0\n1 0 setcmykcolor}DC/ForestGreen{0.91 0 0.88 0.12 setcmykcolor}DC\n/PineGreen{0.92 0 0.59 0.25 setcmykcolor}DC/LimeGreen{0.50 0 1 0\nsetcmykcolor}DC/YellowGreen{0.44 0 0.74 0 setcmykcolor}DC/SpringGreen{\n0.26 0 0.76 0 setcmykcolor}DC/OliveGreen{0.64 0 0.95 0.40 setcmykcolor}\nDC/RawSienna{0 0.72 1 0.45 setcmykcolor}DC/Sepia{0 0.83 1 0.70\nsetcmykcolor}DC/Brown{0 0.81 1 0.60 setcmykcolor}DC/Tan{0.14 0.42 0.56 0\nsetcmykcolor}DC/Gray{0 0 0 0.50 setcmykcolor}DC/Black{0 0 0 1\nsetcmykcolor}DC/White{0 0 0 0 setcmykcolor}DC end\n\n%%EndProcSet\nTeXDict begin 40258437 52099154 1000 600 600 (f2pspost.dvi)\n@start end\n%%EndProlog\n%%BeginSetup\n%%Feature: *Resolution 600dpi\nTeXDict begin\n end\n%%EndSetup\nTeXDict begin 1 0 bop Black Black Black 515 4426 a @beginspecial\n0 @llx 0 @lly 509 @urx 420 @ury 5090 @rwi @setspecial\n%%BeginDocument: pre.ps\n%!PS-Adobe-2.0 EPSF-2.0\n%%Title: pre.fig\n%%Creator: fig2dev Version 3.2 Patchlevel 4\n%%CreationDate: Tue Feb  8 10:46:37 2005\n%%For: oan@gollum (Odd Andersen)\n%%BoundingBox: 0 0 509 420\n%%Magnification: 1.0000\n%%EndComments\n/$F2psDict 200 dict def\n$F2psDict begin\n$F2psDict /mtrx matrix put\n/col-1 {0 setgray} bind def\n/col0 {0.000 0.000 0.000 srgb} bind def\n/col1 {0.000 0.000 1.000 srgb} bind def\n/col2 {0.000 1.000 0.000 srgb} bind def\n/col3 {0.000 1.000 1.000 srgb} bind def\n/col4 {1.000 0.000 0.000 srgb} bind def\n/col5 {1.000 0.000 1.000 srgb} bind def\n/col6 {1.000 1.000 0.000 srgb} bind def\n/col7 {1.000 1.000 1.000 srgb} bind def\n/col8 {0.000 0.000 0.560 srgb} bind def\n/col9 {0.000 0.000 0.690 srgb} bind def\n/col10 {0.000 0.000 0.820 srgb} bind def\n/col11 {0.530 0.810 1.000 srgb} bind def\n/col12 {0.000 0.560 0.000 srgb} bind def\n/col13 {0.000 0.690 0.000 srgb} bind def\n/col14 {0.000 0.820 0.000 srgb} bind def\n/col15 {0.000 0.560 0.560 srgb} bind def\n/col16 {0.000 0.690 0.690 srgb} bind def\n/col17 {0.000 0.820 0.820 srgb} bind def\n/col18 {0.560 0.000 0.000 srgb} bind def\n/col19 {0.690 0.000 0.000 srgb} bind def\n/col20 {0.820 0.000 0.000 srgb} bind def\n/col21 {0.560 0.000 0.560 srgb} bind def\n/col22 {0.690 0.000 0.690 srgb} bind def\n/col23 {0.820 0.000 0.820 srgb} bind def\n/col24 {0.500 0.190 0.000 srgb} bind def\n/col25 {0.630 0.250 0.000 srgb} bind def\n/col26 {0.750 0.380 0.000 srgb} bind def\n/col27 {1.000 0.500 0.500 srgb} bind def\n/col28 {1.000 0.630 0.630 srgb} bind def\n/col29 {1.000 0.750 0.750 srgb} bind def\n/col30 {1.000 0.880 0.880 srgb} bind def\n/col31 {1.000 0.840 0.000 srgb} bind def\n/col32 {0.738 0.742 0.738 srgb} bind def\n/col33 {0.805 0.793 0.805 srgb} bind def\n/col34 {0.805 0.793 0.805 srgb} bind def\n/col35 {0.805 0.793 0.805 srgb} bind def\n/col36 {0.805 0.793 0.805 srgb} bind def\n/col37 {0.805 0.793 0.805 srgb} bind def\n/col38 {0.805 0.793 0.805 srgb} bind def\n/col39 {0.805 0.793 0.805 srgb} bind def\n/col40 {0.805 0.793 0.805 srgb} bind def\n/col41 {0.805 0.793 0.805 srgb} bind def\n/col42 {0.805 0.793 0.805 srgb} bind def\n/col43 {0.805 0.793 0.805 srgb} bind def\n/col44 {0.805 0.793 0.805 srgb} bind def\n/col45 {0.805 0.793 0.805 srgb} bind def\n/col46 {0.805 0.793 0.805 srgb} bind def\n/col47 {0.805 0.793 0.805 srgb} bind def\n/col48 {0.805 0.793 0.805 srgb} bind def\n/col49 {0.805 0.793 0.805 srgb} bind def\n/col50 {0.805 0.793 0.805 srgb} bind def\n/col51 {0.805 0.793 0.805 srgb} bind def\n/col52 {0.805 0.793 0.805 srgb} bind def\n/col53 {0.805 0.793 0.805 srgb} bind def\n/col54 {0.805 0.793 0.805 srgb} bind def\n/col55 {0.805 0.793 0.805 srgb} bind def\n/col56 {0.805 0.793 0.805 srgb} bind def\n/col57 {0.805 0.793 0.805 srgb} bind def\n/col58 {0.805 0.793 0.805 srgb} bind def\n/col59 {0.805 0.793 0.805 srgb} bind def\n/col60 {0.805 0.793 0.805 srgb} bind def\n/col61 {0.805 0.793 0.805 srgb} bind def\n/col62 {0.805 0.793 0.805 srgb} bind def\n/col63 {0.805 0.793 0.805 srgb} bind def\n/col64 {0.805 0.793 0.805 srgb} bind def\n/col65 {0.805 0.793 0.805 srgb} bind def\n/col66 {0.805 0.793 0.805 srgb} bind def\n/col67 {0.805 0.793 0.805 srgb} bind def\n/col68 {0.805 0.793 0.805 srgb} bind def\n/col69 {0.805 0.793 0.805 srgb} bind def\n/col70 {0.805 0.793 0.805 srgb} bind def\n/col71 {0.805 0.793 0.805 srgb} bind def\n/col72 {0.773 0.777 0.773 srgb} bind def\n/col73 {0.867 0.840 0.867 srgb} bind def\n/col74 {0.965 0.949 0.965 srgb} bind def\n/col75 {0.387 0.379 0.387 srgb} bind def\n/col76 {0.805 0.793 0.805 srgb} bind def\n/col77 {0.418 0.426 0.418 srgb} bind def\n/col78 {0.805 0.793 0.805 srgb} bind def\n/col79 {0.418 0.426 0.418 srgb} bind def\n/col80 {0.516 0.508 0.516 srgb} bind def\n/col81 {0.773 0.762 0.773 srgb} bind def\n/col82 {0.902 0.887 0.902 srgb} bind def\n/col83 {0.516 0.508 0.516 srgb} bind def\n/col84 {0.738 0.742 0.738 srgb} bind def\n/col85 {0.867 0.871 0.867 srgb} bind def\n/col86 {0.547 0.555 0.547 srgb} bind def\n/col87 {0.547 0.555 0.547 srgb} bind def\n/col88 {0.547 0.555 0.547 srgb} bind def\n/col89 {0.547 0.555 0.547 srgb} bind def\n/col90 {0.258 0.270 0.258 srgb} bind def\n/col91 {0.547 0.555 0.547 srgb} bind def\n/col92 {0.516 0.523 0.516 srgb} bind def\n/col93 {0.773 0.777 0.773 srgb} bind def\n/col94 {0.902 0.902 0.902 srgb} bind def\n/col95 {0.965 0.965 0.965 srgb} bind def\n/col96 {0.609 0.617 0.609 srgb} bind def\n/col97 {0.516 0.508 0.516 srgb} bind def\n/col98 {0.449 0.457 0.449 srgb} bind def\n/col99 {0.258 0.270 0.258 srgb} bind def\n/col100 {0.773 0.777 0.773 srgb} bind def\n/col101 {0.449 0.457 0.449 srgb} bind def\n/col102 {0.609 0.617 0.609 srgb} bind def\n/col103 {0.516 0.508 0.516 srgb} bind def\n/col104 {0.773 0.762 0.773 srgb} bind def\n/col105 {0.547 0.555 0.547 srgb} bind def\n/col106 {0.547 0.555 0.547 srgb} bind def\n/col107 {0.258 0.254 0.258 srgb} bind def\n/col108 {0.773 0.762 0.773 srgb} bind def\n/col109 {0.934 0.980 0.996 srgb} bind def\n/col110 {0.547 0.555 0.547 srgb} bind def\n/col111 {0.258 0.270 0.258 srgb} bind def\n/col112 {0.773 0.762 0.773 srgb} bind def\n/col113 {0.516 0.508 0.516 srgb} bind def\n/col114 {0.547 0.555 0.547 srgb} bind def\n/col115 {0.258 0.270 0.258 srgb} bind def\n/col116 {0.258 0.254 0.258 srgb} bind def\n/col117 {0.516 0.508 0.516 srgb} bind def\n/col118 {0.738 0.742 0.738 srgb} bind def\n/col119 {0.867 0.871 0.867 srgb} bind def\n/col120 {0.934 0.949 0.934 srgb} bind def\n/col121 {0.516 0.508 0.516 srgb} bind def\n/col122 {0.934 0.949 0.934 srgb} bind def\n/col123 {0.516 0.508 0.516 srgb} bind def\n/col124 {0.676 0.664 0.676 srgb} bind def\n/col125 {0.547 0.555 0.547 srgb} bind def\n/col126 {0.258 0.270 0.258 srgb} bind def\n/col127 {0.547 0.555 0.547 srgb} bind def\n/col128 {0.258 0.270 0.258 srgb} bind def\n/col129 {0.676 0.664 0.676 srgb} bind def\n/col130 {0.320 0.332 0.320 srgb} bind def\n/col131 {0.547 0.555 0.547 srgb} bind def\n/col132 {0.258 0.270 0.258 srgb} bind def\n/col133 {0.773 0.762 0.773 srgb} bind def\n/col134 {0.516 0.508 0.516 srgb} bind def\n/col135 {0.738 0.742 0.738 srgb} bind def\n/col136 {0.867 0.871 0.867 srgb} bind def\n/col137 {0.547 0.555 0.547 srgb} bind def\n/col138 {0.258 0.270 0.258 srgb} bind def\n/col139 {0.547 0.555 0.547 srgb} bind def\n/col140 {0.258 0.270 0.258 srgb} bind def\n/col141 {0.547 0.555 0.547 srgb} bind def\n/col142 {0.836 0.824 0.836 srgb} bind def\n/col143 {0.676 0.664 0.676 srgb} bind def\n/col144 {0.773 0.762 0.773 srgb} bind def\n/col145 {0.449 0.457 0.449 srgb} bind def\n/col146 {0.449 0.457 0.449 srgb} bind def\n/col147 {0.934 0.949 0.934 srgb} bind def\n/col148 {0.516 0.508 0.516 srgb} bind def\n/col149 {0.449 0.457 0.449 srgb} bind def\n/col150 {0.773 0.762 0.773 srgb} bind def\n/col151 {0.449 0.457 0.449 srgb} bind def\n/col152 {0.449 0.457 0.449 srgb} bind def\n/col153 {0.934 0.949 0.934 srgb} bind def\n/col154 {0.516 0.508 0.516 srgb} bind def\n/col155 {0.449 0.457 0.449 srgb} bind def\n/col156 {0.191 0.188 0.191 srgb} bind def\n/col157 {0.320 0.332 0.320 srgb} bind def\n/col158 {0.516 0.508 0.516 srgb} bind def\n/col159 {0.547 0.555 0.547 srgb} bind def\n/col160 {0.258 0.270 0.258 srgb} bind def\n/col161 {0.773 0.777 0.773 srgb} bind def\n/col162 {0.773 0.777 0.773 srgb} bind def\n/col163 {0.547 0.555 0.547 srgb} bind def\n/col164 {0.258 0.270 0.258 srgb} bind def\n/col165 {0.547 0.555 0.547 srgb} bind def\n/col166 {0.258 0.270 0.258 srgb} bind def\n/col167 {0.547 0.555 0.547 srgb} bind def\n/col168 {0.258 0.270 0.258 srgb} bind def\n/col169 {0.387 0.395 0.387 srgb} bind def\n/col170 {0.867 0.871 0.867 srgb} bind def\n/col171 {0.258 0.270 0.258 srgb} bind def\n/col172 {0.547 0.555 0.547 srgb} bind def\n/col173 {0.516 0.508 0.516 srgb} bind def\n/col174 {0.516 0.508 0.516 srgb} bind def\n/col175 {0.773 0.762 0.773 srgb} bind def\n/col176 {0.773 0.777 0.773 srgb} bind def\n/col177 {0.449 0.457 0.449 srgb} bind def\n/col178 {0.773 0.777 0.773 srgb} bind def\n/col179 {0.449 0.457 0.449 srgb} bind def\n/col180 {0.547 0.555 0.547 srgb} bind def\n/col181 {0.258 0.270 0.258 srgb} bind def\n/col182 {0.516 0.508 0.516 srgb} bind def\n/col183 {0.773 0.762 0.773 srgb} bind def\n/col184 {0.773 0.762 0.773 srgb} bind def\n/col185 {0.449 0.441 0.449 srgb} bind def\n/col186 {0.516 0.508 0.516 srgb} bind def\n/col187 {0.773 0.762 0.773 srgb} bind def\n/col188 {0.449 0.441 0.449 srgb} bind def\n/col189 {0.934 0.949 0.934 srgb} bind def\n/col190 {0.516 0.508 0.516 srgb} bind def\n/col191 {0.547 0.555 0.547 srgb} bind def\n/col192 {0.258 0.270 0.258 srgb} bind def\n/col193 {0.547 0.555 0.547 srgb} bind def\n/col194 {0.258 0.270 0.258 srgb} bind def\n/col195 {0.516 0.508 0.516 srgb} bind def\n/col196 {0.738 0.742 0.738 srgb} bind def\n/col197 {0.867 0.871 0.867 srgb} bind def\n/col198 {0.738 0.742 0.738 srgb} bind def\n/col199 {0.867 0.871 0.867 srgb} bind def\n/col200 {0.258 0.270 0.258 srgb} bind def\n/col201 {0.516 0.508 0.516 srgb} bind def\n/col202 {0.738 0.742 0.738 srgb} bind def\n/col203 {0.738 0.742 0.738 srgb} bind def\n/col204 {0.516 0.508 0.516 srgb} bind def\n/col205 {0.258 0.270 0.258 srgb} bind def\n/col206 {0.516 0.508 0.516 srgb} bind def\n/col207 {0.738 0.742 0.738 srgb} bind def\n/col208 {0.609 0.000 0.000 srgb} bind def\n/col209 {0.547 0.539 0.547 srgb} bind def\n/col210 {0.258 0.254 0.258 srgb} bind def\n/col211 {0.547 0.539 0.547 srgb} bind def\n/col212 {0.258 0.254 0.258 srgb} bind def\n/col213 {0.547 0.539 0.547 srgb} bind def\n/col214 {0.258 0.254 0.258 srgb} bind def\n/col215 {0.547 0.539 0.547 srgb} bind def\n/col216 {0.258 0.254 0.258 srgb} bind def\n/col217 {0.547 0.539 0.547 srgb} bind def\n/col218 {0.258 0.254 0.258 srgb} bind def\n/col219 {0.547 0.539 0.547 srgb} bind def\n/col220 {0.258 0.254 0.258 srgb} bind def\n/col221 {0.547 0.539 0.547 srgb} bind def\n/col222 {0.258 0.254 0.258 srgb} bind def\n/col223 {0.547 0.539 0.547 srgb} bind def\n/col224 {0.258 0.254 0.258 srgb} bind def\n/col225 {0.547 0.539 0.547 srgb} bind def\n/col226 {0.258 0.254 0.258 srgb} bind def\n/col227 {0.547 0.539 0.547 srgb} bind def\n/col228 {0.258 0.254 0.258 srgb} bind def\n/col229 {0.547 0.539 0.547 srgb} bind def\n/col230 {0.258 0.254 0.258 srgb} bind def\n/col231 {0.547 0.539 0.547 srgb} bind def\n/col232 {0.258 0.254 0.258 srgb} bind def\n/col233 {0.547 0.539 0.547 srgb} bind def\n/col234 {0.258 0.254 0.258 srgb} bind def\n/col235 {0.547 0.539 0.547 srgb} bind def\n/col236 {0.258 0.254 0.258 srgb} bind def\n/col237 {0.547 0.539 0.547 srgb} bind def\n/col238 {0.258 0.254 0.258 srgb} bind def\n/col239 {0.547 0.539 0.547 srgb} bind def\n/col240 {0.258 0.254 0.258 srgb} bind def\n/col241 {0.547 0.539 0.547 srgb} bind def\n/col242 {0.258 0.254 0.258 srgb} bind def\n/col243 {0.547 0.539 0.547 srgb} bind def\n/col244 {0.258 0.254 0.258 srgb} bind def\n/col245 {0.867 0.617 0.578 srgb} bind def\n/col246 {0.934 0.918 0.867 srgb} bind def\n/col247 {0.773 0.762 0.773 srgb} bind def\n/col248 {0.867 0.777 0.645 srgb} bind def\n/col249 {0.867 0.871 0.867 srgb} bind def\n/col250 {0.805 0.824 0.805 srgb} bind def\n/col251 {0.934 0.918 0.934 srgb} bind def\n/col252 {0.836 0.473 0.094 srgb} bind def\n/col253 {0.934 0.887 0.094 srgb} bind def\n/col254 {0.516 0.488 0.773 srgb} bind def\n/col255 {0.836 0.840 0.836 srgb} bind def\n/col256 {0.547 0.539 0.645 srgb} bind def\n/col257 {0.289 0.285 0.289 srgb} bind def\n/col258 {0.547 0.410 0.418 srgb} bind def\n/col259 {0.352 0.348 0.352 srgb} bind def\n/col260 {0.387 0.379 0.387 srgb} bind def\n/col261 {0.547 0.555 0.547 srgb} bind def\n/col262 {0.707 0.602 0.449 srgb} bind def\n/col263 {0.258 0.570 0.996 srgb} bind def\n/col264 {0.738 0.441 0.223 srgb} bind def\n/col265 {0.867 0.457 0.000 srgb} bind def\n/col266 {0.836 0.711 0.000 srgb} bind def\n/col267 {0.000 0.395 0.000 srgb} bind def\n/col268 {0.352 0.410 0.223 srgb} bind def\n/col269 {0.836 0.824 0.836 srgb} bind def\n/col270 {0.676 0.664 0.676 srgb} bind def\n/col271 {0.547 0.555 0.645 srgb} bind def\n/col272 {0.934 0.727 0.352 srgb} bind def\n/col273 {0.547 0.602 0.418 srgb} bind def\n/col274 {0.289 0.285 0.289 srgb} bind def\n/col275 {0.387 0.395 0.387 srgb} bind def\n/col276 {0.836 0.840 0.836 srgb} bind def\n/col277 {0.547 0.539 0.645 srgb} bind def\n/col278 {0.352 0.348 0.352 srgb} bind def\n/col279 {0.387 0.379 0.387 srgb} bind def\n/col280 {0.707 0.902 0.996 srgb} bind def\n/col281 {0.516 0.742 0.934 srgb} bind def\n/col282 {0.738 0.742 0.738 srgb} bind def\n/col283 {0.836 0.586 0.320 srgb} bind def\n/col284 {0.547 0.555 0.547 srgb} bind def\n/col285 {0.578 0.824 0.996 srgb} bind def\n/col286 {0.547 0.555 0.547 srgb} bind def\n/col287 {0.836 0.840 0.836 srgb} bind def\n/col288 {0.547 0.539 0.645 srgb} bind def\n/col289 {0.547 0.410 0.418 srgb} bind def\n/col290 {0.352 0.348 0.352 srgb} bind def\n/col291 {0.387 0.379 0.387 srgb} bind def\n/col292 {0.547 0.602 0.418 srgb} bind def\n/col293 {0.965 0.410 0.000 srgb} bind def\n/col294 {0.352 0.410 0.223 srgb} bind def\n/col295 {0.547 0.602 0.418 srgb} bind def\n/col296 {0.289 0.285 0.289 srgb} bind def\n/col297 {0.836 0.840 0.836 srgb} bind def\n/col298 {0.547 0.539 0.645 srgb} bind def\n/col299 {0.547 0.410 0.418 srgb} bind def\n/col300 {0.352 0.348 0.352 srgb} bind def\n/col301 {0.387 0.379 0.387 srgb} bind def\n/col302 {0.547 0.602 0.418 srgb} bind def\n/col303 {0.965 0.410 0.000 srgb} bind def\n/col304 {0.547 0.602 0.480 srgb} bind def\n/col305 {0.289 0.285 0.289 srgb} bind def\n/col306 {0.094 0.285 0.094 srgb} bind def\n/col307 {0.352 0.410 0.223 srgb} bind def\n/col308 {0.836 0.840 0.836 srgb} bind def\n/col309 {0.676 0.680 0.676 srgb} bind def\n/col310 {0.547 0.539 0.645 srgb} bind def\n/col311 {0.965 0.742 0.352 srgb} bind def\n/col312 {0.547 0.602 0.418 srgb} bind def\n/col313 {0.289 0.285 0.289 srgb} bind def\n/col314 {0.387 0.379 0.387 srgb} bind def\n/col315 {0.387 0.410 0.609 srgb} bind def\n/col316 {0.547 0.410 0.418 srgb} bind def\n/col317 {0.867 0.000 0.000 srgb} bind def\n/col318 {0.352 0.348 0.352 srgb} bind def\n/col319 {0.547 0.602 0.418 srgb} bind def\n/col320 {0.289 0.285 0.289 srgb} bind def\n/col321 {0.387 0.379 0.387 srgb} bind def\n/col322 {0.352 0.410 0.223 srgb} bind def\n/col323 {0.836 0.840 0.836 srgb} bind def\n/col324 {0.676 0.680 0.676 srgb} bind def\n/col325 {0.547 0.539 0.645 srgb} bind def\n/col326 {0.965 0.742 0.352 srgb} bind def\n/col327 {0.547 0.602 0.418 srgb} bind def\n/col328 {0.289 0.285 0.289 srgb} bind def\n/col329 {0.387 0.379 0.387 srgb} bind def\n/col330 {0.352 0.410 0.223 srgb} bind def\n/col331 {0.836 0.840 0.836 srgb} bind def\n/col332 {0.676 0.680 0.676 srgb} bind def\n/col333 {0.547 0.539 0.645 srgb} bind def\n/col334 {0.965 0.742 0.352 srgb} bind def\n/col335 {0.547 0.602 0.418 srgb} bind def\n/col336 {0.289 0.285 0.289 srgb} bind def\n/col337 {0.387 0.379 0.387 srgb} bind def\n/col338 {0.387 0.410 0.609 srgb} bind def\n/col339 {0.320 0.410 0.160 srgb} bind def\n/col340 {0.387 0.379 0.387 srgb} bind def\n/col341 {0.352 0.410 0.223 srgb} bind def\n/col342 {0.578 0.570 0.578 srgb} bind def\n/col343 {0.387 0.379 0.387 srgb} bind def\n/col344 {0.000 0.379 0.000 srgb} bind def\n/col345 {0.547 0.539 0.645 srgb} bind def\n/col346 {0.547 0.539 0.645 srgb} bind def\n/col347 {0.547 0.539 0.645 srgb} bind def\n/col348 {0.000 0.379 0.289 srgb} bind def\n/col349 {0.480 0.508 0.289 srgb} bind def\n/col350 {0.902 0.742 0.480 srgb} bind def\n/col351 {0.547 0.602 0.480 srgb} bind def\n/col352 {0.645 0.711 0.773 srgb} bind def\n/col353 {0.418 0.410 0.578 srgb} bind def\n/col354 {0.516 0.410 0.418 srgb} bind def\n/col355 {0.320 0.602 0.289 srgb} bind def\n/col356 {0.836 0.902 0.902 srgb} bind def\n/col357 {0.320 0.379 0.387 srgb} bind def\n/col358 {0.094 0.410 0.289 srgb} bind def\n/col359 {0.609 0.648 0.707 srgb} bind def\n/col360 {0.996 0.570 0.000 srgb} bind def\n/col361 {0.996 0.570 0.000 srgb} bind def\n/col362 {0.547 0.410 0.418 srgb} bind def\n/col363 {0.000 0.379 0.289 srgb} bind def\n/col364 {0.480 0.508 0.289 srgb} bind def\n/col365 {0.387 0.441 0.480 srgb} bind def\n/col366 {0.902 0.742 0.480 srgb} bind def\n/col367 {0.094 0.285 0.094 srgb} bind def\n/col368 {0.352 0.410 0.223 srgb} bind def\n/col369 {0.547 0.539 0.645 srgb} bind def\n/col370 {0.965 0.742 0.352 srgb} bind def\n/col371 {0.547 0.602 0.418 srgb} bind def\n/col372 {0.289 0.285 0.289 srgb} bind def\n/col373 {0.387 0.379 0.387 srgb} bind def\n/col374 {0.836 0.840 0.836 srgb} bind def\n/col375 {0.676 0.680 0.676 srgb} bind def\n/col376 {0.547 0.539 0.645 srgb} bind def\n/col377 {0.289 0.285 0.289 srgb} bind def\n/col378 {0.387 0.379 0.387 srgb} bind def\n/col379 {0.547 0.410 0.418 srgb} bind def\n/col380 {0.352 0.348 0.352 srgb} bind def\n/col381 {0.289 0.285 0.289 srgb} bind def\n/col382 {0.387 0.379 0.387 srgb} bind def\n/col383 {0.676 0.680 0.676 srgb} bind def\n/col384 {0.387 0.379 0.387 srgb} bind def\n/col385 {0.547 0.602 0.418 srgb} bind def\n/col386 {0.289 0.285 0.289 srgb} bind def\n/col387 {0.352 0.410 0.223 srgb} bind def\n/col388 {0.676 0.680 0.676 srgb} bind def\n/col389 {0.289 0.285 0.289 srgb} bind def\n/col390 {0.000 0.395 0.000 srgb} bind def\n/col391 {0.352 0.410 0.223 srgb} bind def\n/col392 {0.836 0.824 0.836 srgb} bind def\n/col393 {0.676 0.664 0.676 srgb} bind def\n/col394 {0.547 0.555 0.645 srgb} bind def\n/col395 {0.934 0.727 0.352 srgb} bind def\n/col396 {0.547 0.602 0.418 srgb} bind def\n/col397 {0.289 0.285 0.289 srgb} bind def\n/col398 {0.387 0.395 0.387 srgb} bind def\n/col399 {0.836 0.840 0.836 srgb} bind def\n/col400 {0.547 0.539 0.645 srgb} bind def\n/col401 {0.352 0.348 0.352 srgb} bind def\n/col402 {0.387 0.379 0.387 srgb} bind def\n/col403 {0.836 0.840 0.836 srgb} bind def\n/col404 {0.352 0.410 0.223 srgb} bind def\n/col405 {0.547 0.539 0.645 srgb} bind def\n/col406 {0.547 0.410 0.418 srgb} bind def\n/col407 {0.352 0.348 0.352 srgb} bind def\n/col408 {0.387 0.379 0.387 srgb} bind def\n/col409 {0.547 0.602 0.418 srgb} bind def\n/col410 {0.289 0.285 0.289 srgb} bind def\n/col411 {0.836 0.840 0.836 srgb} bind def\n/col412 {0.547 0.539 0.645 srgb} bind def\n/col413 {0.547 0.410 0.418 srgb} bind def\n/col414 {0.352 0.348 0.352 srgb} bind def\n/col415 {0.387 0.379 0.387 srgb} bind def\n/col416 {0.547 0.602 0.480 srgb} bind def\n/col417 {0.289 0.285 0.289 srgb} bind def\n/col418 {0.000 0.379 0.000 srgb} bind def\n/col419 {0.352 0.410 0.223 srgb} bind def\n/col420 {0.867 0.871 0.867 srgb} bind def\n/col421 {0.676 0.680 0.676 srgb} bind def\n/col422 {0.547 0.539 0.645 srgb} bind def\n/col423 {0.965 0.742 0.352 srgb} bind def\n/col424 {0.547 0.602 0.418 srgb} bind def\n/col425 {0.289 0.285 0.289 srgb} bind def\n/col426 {0.387 0.379 0.387 srgb} bind def\n/col427 {0.387 0.410 0.609 srgb} bind def\n/col428 {0.836 0.840 0.836 srgb} bind def\n/col429 {0.547 0.410 0.418 srgb} bind def\n/col430 {0.352 0.348 0.352 srgb} bind def\n/col431 {0.000 0.395 0.000 srgb} bind def\n/col432 {0.352 0.410 0.223 srgb} bind def\n/col433 {0.836 0.824 0.836 srgb} bind def\n/col434 {0.676 0.664 0.676 srgb} bind def\n/col435 {0.547 0.555 0.645 srgb} bind def\n/col436 {0.934 0.727 0.352 srgb} bind def\n/col437 {0.547 0.602 0.418 srgb} bind def\n/col438 {0.289 0.285 0.289 srgb} bind def\n/col439 {0.387 0.395 0.387 srgb} bind def\n/col440 {0.352 0.410 0.223 srgb} bind def\n/col441 {0.836 0.824 0.836 srgb} bind def\n/col442 {0.676 0.664 0.676 srgb} bind def\n/col443 {0.547 0.555 0.645 srgb} bind def\n/col444 {0.934 0.727 0.352 srgb} bind def\n/col445 {0.547 0.602 0.418 srgb} bind def\n/col446 {0.289 0.285 0.289 srgb} bind def\n/col447 {0.387 0.395 0.387 srgb} bind def\n/col448 {0.352 0.410 0.223 srgb} bind def\n/col449 {0.836 0.824 0.836 srgb} bind def\n/col450 {0.676 0.664 0.676 srgb} bind def\n/col451 {0.547 0.555 0.645 srgb} bind def\n/col452 {0.934 0.727 0.352 srgb} bind def\n/col453 {0.547 0.602 0.418 srgb} bind def\n/col454 {0.289 0.285 0.289 srgb} bind def\n/col455 {0.387 0.395 0.387 srgb} bind def\n/col456 {0.352 0.410 0.223 srgb} bind def\n/col457 {0.836 0.824 0.836 srgb} bind def\n/col458 {0.676 0.664 0.676 srgb} bind def\n/col459 {0.547 0.555 0.645 srgb} bind def\n/col460 {0.934 0.727 0.352 srgb} bind def\n/col461 {0.547 0.602 0.418 srgb} bind def\n/col462 {0.289 0.285 0.289 srgb} bind def\n/col463 {0.387 0.395 0.387 srgb} bind def\n/col464 {0.352 0.410 0.223 srgb} bind def\n/col465 {0.836 0.824 0.836 srgb} bind def\n/col466 {0.676 0.664 0.676 srgb} bind def\n/col467 {0.547 0.555 0.645 srgb} bind def\n/col468 {0.934 0.727 0.352 srgb} bind def\n/col469 {0.547 0.602 0.418 srgb} bind def\n/col470 {0.289 0.285 0.289 srgb} bind def\n/col471 {0.387 0.395 0.387 srgb} bind def\n/col472 {0.836 0.840 0.836 srgb} bind def\n/col473 {0.547 0.539 0.645 srgb} bind def\n/col474 {0.352 0.348 0.352 srgb} bind def\n/col475 {0.387 0.379 0.387 srgb} bind def\n/col476 {0.000 0.395 0.000 srgb} bind def\n/col477 {0.352 0.410 0.223 srgb} bind def\n/col478 {0.836 0.824 0.836 srgb} bind def\n/col479 {0.676 0.664 0.676 srgb} bind def\n/col480 {0.547 0.555 0.645 srgb} bind def\n/col481 {0.934 0.727 0.352 srgb} bind def\n/col482 {0.547 0.602 0.418 srgb} bind def\n/col483 {0.289 0.285 0.289 srgb} bind def\n/col484 {0.387 0.395 0.387 srgb} bind def\n/col485 {0.352 0.410 0.223 srgb} bind def\n/col486 {0.836 0.824 0.836 srgb} bind def\n/col487 {0.676 0.664 0.676 srgb} bind def\n/col488 {0.547 0.555 0.645 srgb} bind def\n/col489 {0.934 0.727 0.352 srgb} bind def\n/col490 {0.547 0.602 0.418 srgb} bind def\n/col491 {0.289 0.285 0.289 srgb} bind def\n/col492 {0.387 0.395 0.387 srgb} bind def\n/col493 {0.352 0.410 0.223 srgb} bind def\n/col494 {0.836 0.824 0.836 srgb} bind def\n/col495 {0.676 0.664 0.676 srgb} bind def\n/col496 {0.547 0.555 0.645 srgb} bind def\n/col497 {0.934 0.727 0.352 srgb} bind def\n/col498 {0.547 0.602 0.418 srgb} bind def\n/col499 {0.289 0.285 0.289 srgb} bind def\n/col500 {0.387 0.395 0.387 srgb} bind def\n/col501 {0.352 0.410 0.223 srgb} bind def\n/col502 {0.836 0.824 0.836 srgb} bind def\n/col503 {0.676 0.664 0.676 srgb} bind def\n/col504 {0.547 0.555 0.645 srgb} bind def\n/col505 {0.934 0.727 0.352 srgb} bind def\n/col506 {0.547 0.602 0.418 srgb} bind def\n/col507 {0.289 0.285 0.289 srgb} bind def\n/col508 {0.387 0.395 0.387 srgb} bind def\n/col509 {0.836 0.840 0.836 srgb} bind def\n/col510 {0.547 0.539 0.645 srgb} bind def\n/col511 {0.352 0.348 0.352 srgb} bind def\n/col512 {0.387 0.379 0.387 srgb} bind def\n/col513 {0.934 0.934 0.836 srgb} bind def\n/col514 {0.965 0.680 0.352 srgb} bind def\n/col515 {0.578 0.809 0.609 srgb} bind def\n/col516 {0.676 0.664 0.676 srgb} bind def\n/col517 {0.707 0.078 0.480 srgb} bind def\n/col518 {0.934 0.934 0.934 srgb} bind def\n/col519 {0.516 0.508 0.516 srgb} bind def\n/col520 {0.000 0.379 0.000 srgb} bind def\n/col521 {0.352 0.410 0.223 srgb} bind def\n/col522 {0.836 0.840 0.836 srgb} bind def\n/col523 {0.676 0.680 0.676 srgb} bind def\n/col524 {0.547 0.539 0.645 srgb} bind def\n/col525 {0.965 0.742 0.352 srgb} bind def\n/col526 {0.547 0.602 0.418 srgb} bind def\n/col527 {0.289 0.285 0.289 srgb} bind def\n/col528 {0.387 0.379 0.387 srgb} bind def\n/col529 {0.387 0.410 0.609 srgb} bind def\n/col530 {0.480 0.473 0.480 srgb} bind def\n/col531 {0.000 0.348 0.000 srgb} bind def\n/col532 {0.902 0.441 0.449 srgb} bind def\n/col533 {0.996 0.793 0.191 srgb} bind def\n/col534 {0.160 0.473 0.289 srgb} bind def\n/col535 {0.867 0.156 0.129 srgb} bind def\n/col536 {0.129 0.348 0.773 srgb} bind def\n/col537 {0.965 0.965 0.965 srgb} bind def\n/col538 {0.934 0.934 0.934 srgb} bind def\n/col539 {0.902 0.902 0.902 srgb} bind def\n/col540 {0.258 0.270 0.258 srgb} bind def\n/col541 {0.516 0.508 0.516 srgb} bind def\n/col542 {0.738 0.742 0.738 srgb} bind def\n\nend\nsave\nnewpath 0 420 moveto 0 0 lineto 509 0 lineto 509 420 lineto closepath clip newpath\n-90.7 464.3 translate\n1 -1 scale\n\n/cp {closepath} bind def\n/ef {eofill} bind def\n/gr {grestore} bind def\n/gs {gsave} bind def\n/sa {save} bind def\n/rs {restore} bind def\n/l {lineto} bind def\n/m {moveto} bind def\n/rm {rmoveto} bind def\n/n {newpath} bind def\n/s {stroke} bind def\n/sh {show} bind def\n/slc {setlinecap} bind def\n/slj {setlinejoin} bind def\n/slw {setlinewidth} bind def\n/srgb {setrgbcolor} bind def\n/rot {rotate} bind def\n/sc {scale} bind def\n/sd {setdash} bind def\n/ff {findfont} bind def\n/sf {setfont} bind def\n/scf {scalefont} bind def\n/sw {stringwidth} bind def\n/tr {translate} bind def\n/tnt {dup dup currentrgbcolor\n  4 -2 roll dup 1 exch sub 3 -1 roll mul add\n  4 -2 roll dup 1 exch sub 3 -1 roll mul add\n  4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}\n  bind def\n/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul\n  4 -2 roll mul srgb} bind def\n /DrawEllipse {\n\t/endangle exch def\n\t/startangle exch def\n\t/yrad exch def\n\t/xrad exch def\n\t/y exch def\n\t/x exch def\n\t/savematrix mtrx currentmatrix def\n\tx y tr xrad yrad sc 0 0 1 startangle endangle arc\n\tclosepath\n\tsavematrix setmatrix\n\t} def\n\n/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def\n/$F2psEnd {$F2psEnteredState restore end} def\n\n$F2psBegin\n10 setmiterlimit\n0 slj 0 slc\n 0.06299 0.06299 sc\n%\n% Fig objects follow\n%\n% \n% here starts figure with depth 50\n% Ellipse\n7.500 slw\nn 1883 6873 86 69 0 360 DrawEllipse gs col7 0.00 shd ef gr gs col0 s gr\n\n% Polyline\nn 3423 3796 m 3423 5096 l 5561 6120 l 5561 4753 l\n 3423 3796 l  cp gs col0 s gr \n% Polyline\n [60] 0 sd\nn 1883 6873 m\n 6673 1267 l gs col0 s gr  [] 0 sd\n% Polyline\n [60] 0 sd\nn 1883 6873 m\n 4962 720 l gs col0 s gr  [] 0 sd\n% Polyline\n [60] 0 sd\nn 1969 6873 m\n 9238 2566 l gs col0 s gr  [] 0 sd\n% Polyline\n [60] 0 sd\nn 1883 6873 m\n 9495 5300 l gs col0 s gr  [] 0 sd\n/Times-Roman ff 300.00 scf sf\n1440 7290 m\ngs 1 -1 sc (viewpoint) col0 sh gr\n/Times-Roman ff 300.00 scf sf\n6300 2250 m\ngs 1 -1 sc (object) col0 sh gr\n/Times-Roman ff 300.00 scf sf\n4005 5040 m\ngs 1 -1 sc (frame) col0 sh gr\n% here ends figure;\n% \n% here starts figure with depth 0\n% Polyline\n7.500 slw\nn 5594 3013 m 5116 3710 l 6741 3788 l 6838 3013 l\n cp gs col-1 s gr \n% Polyline\nn 5594 3555 m 5785 3555 l 5785 3710 l 5594 3710 l\n cp gs col-1 s gr \n% Polyline\nn 5880 3555 m 6072 3555 l 6072 3710 l 5880 3710 l\n cp gs col-1 s gr \n% Polyline\nn 6168 3555 m 6358 3555 l 6358 3710 l 6168 3710 l\n cp gs col-1 s gr \n% Polyline\nn 6263 3323 m 6455 3323 l 6455 3477 l 6263 3477 l\n cp gs col-1 s gr \n% Polyline\nn 5976 3323 m 6168 3323 l 6168 3477 l 5976 3477 l\n cp gs col-1 s gr \n% Polyline\nn 5689 3323 m 5880 3323 l 5880 3477 l 5689 3477 l\n cp gs col-1 s gr \n% Polyline\nn 5785 3090 m 5976 3090 l 5976 3245 l 5785 3245 l\n cp gs col-1 s gr \n% Polyline\nn 6072 3090 m 6263 3090 l 6263 3245 l 6072 3245 l\n cp gs col-1 s gr \n% Polyline\nn 6358 3090 m 6550 3090 l 6550 3245 l 6358 3245 l\n cp gs col-1 s gr \n% Polyline\nn 6741 3788 m 6838 3942 l 6838 4097 l 5019 4020 l 5019 3788 l 5594 2858 l\n 5594 2702 l 5689 2626 l 5785 2626 l 5880 2780 l 6646 2780 l\n 6646 2702 l 6741 2626 l 6838 2626 l 6838 2858 l 7124 3245 l\n\n 7124 3168 l gs col-1 s gr \n% Polyline\nn 5499 3013 m 5210 3013 l 5116 2935 l 5402 2626 l 5689 2470 l 7124 2547 l\n 7411 2626 l 7603 2935 l 7507 3168 l 7411 3245 l 7124 3168 l\n 6933 2702 l\n 6838 2626 l gs col-1 s gr \n% Polyline\nn 5426 2602 m 5865 2574 l 6733 2588 l 7267 2718 l\n 7385 2645 l gs col-1 s gr \n% Polyline\nn 7322 2797 m\n 7484 3052 l gs col-1 s gr \n% Polyline\nn 7511 3124 m 7223 3088 l 7007 2740 l\n 6946 2733 l gs col-1 s gr \n% Polyline\nn 6401 2849 m 6705 2864 l\n 6713 2689 l gs col-1 s gr \n% Polyline\nn 5776 2864 m 5802 2761 l\n 5838 2696 l gs col-1 s gr \n% Polyline\nn 7196 3196 m 7267 3320 l 7285 3747 l\n 6840 4102 l gs col-1 s gr \n% here ends figure;\n$F2psEnd\nrs\nshowpage\n\n%%EndDocument\n @endspecial Black Black Black eop end\n%%Trailer\n\nuserdict /end-hook known{end-hook}if\n%%EOF\n"
  },
  {
    "path": "doc/manual/sample_programs.tex",
    "content": "\\chapter{Tutorial programs}\n\nThis release of SISL is bundled with a number of sample programs which are intended\nto make the user more familiar with the use of the API, as well as demonstrating \nsome of its capabilities.  \n\n\\section{Compiling the programs}\nThe default cmake setup is not to compile example programs, the stream library and the viewer.\nTo enable compilation of the example programs the cmake call must be extended with\n-Dsisl\\_COMPILE\\_EXAMPLES=ON. This option also enables compilation of the streaming library.\nWith ccmake compile options are changed pressing enter. In cmake-gui compilation of the examples\nis invoked by ticking the appropriate box. Compilation and linking is performed with the call\n\\begin{verbatim}\n$ make example01\n\\end{verbatim}\nThe example programs and the code for the streaming library is written in C++.\n\n\n\\section{Description and commentaries on the sample programs}\n\nThe example programs are named \\verb/example01/ through \\verb/example15/.  Each of the\nprogram demonstrates the use of a single or a couple of SISL functions.  The programs\nproduces output files that contain geometric objects in the \\verb/Go/-format, which \ncan then be visualised by the provided viewer. These objects can also be visualized\nin the viewer belonging to the GoTools library.\n\nTo keep things as simple as possible, the example programs (with the exception of\n\\verb/example15/) take no command line arguments.  Instead, upon execution they inform\nthe user about what they are about to do, and which files will be read from and written\nto.  The names of the input and output files are hard-coded in each example, but the\nuser can experiment by changing the name of these files if she wants to.  Several of\nthe sample programs rely upon files generated by earlier examples, so the user should \nmake sure she runs through them in chronological order.\n\n\\subsection{example01.C}\n\n\\subsubsection{What it does}\nThis program demonstrates how to directly specify a spline curve by providing the \nposition of control points and a knotvector (parametrization).  It generates such\na curve by using hard-coded values as input to the SISL  \\verb/newCurve/ routine.\n\\subsubsection{What it demonstrates}\n\\begin{enumerate}\n\\item How control points and knotvectors are specified in memory.\n\\item How to use the \\verb/newCurve/ routine.\n\\item How to clean up memory using \\verb/freeCurve/.\n\\end{enumerate}\n\n\\subsubsection{Input/output}\nThe program takes no input files.\\\\\nThe program generates the files \\verb/example1_curve.g2/ and \\verb/example1_points.g2/.\nThe former contains the curve object and the latter contains the control points, expressed\nin the \\verb/Go/-format.\n\n\\subsection{example02.C}\n\n\\subsubsection{What it does}\nThis program demonstrates one of the simplest \\emph{interpolation} cases for spline \ncurves in SISL.  A sequence of 6 3D-points are provided (hardcoded), and the routine\ngenerates a spline curve that fits exactly through these points.  Note that this is a\nsimple example of a more general routine, which can also take into consideration\ntangents, end point conditions, etc.\n\n\\subsubsection{What it demonstrates}\n\\begin{enumerate}\n\\item The use of the SISL routine \\verb/s1356/ for interpolating points with a curve.\n\\end{enumerate}\n\\subsubsection{Input/output}\nThe program takes no input files.\\\\\nThe program generates the file \\verb/example2_points.g2/ and \\verb/example2_curve.g2/.\nThe first file contains the points to be interpolated, and the second file contains the\ngenerated curve.\n\n\\subsection{example03.C}\n\n\\subsubsection{What it does}\nThis program creates a so-called \\emph{blend-curve} between two other curves, creating a\nsmooth connection between these.  In this program, the blend curve connects the \\emph{end \npoints} of the two other curves, but in its generality, the routine can be used to create \nblend curves connecting to any point on the other curves.\n\n\\subsubsection{What it demonstrates}\n\\begin{enumerate}\n\\item What a blend curve is and how it can be specified.\n\\item The use of the SISL routine \\verb/s1606/, which computes the blend curve.\n\\item The use of the SISL routine \\verb/s1227/, which evaluates points (and derivatives)\non a spline curve.\n\\item How to directly access data members of the \\verb/SISLCurve/ struct.\n\\end{enumerate}\n\\subsubsection{Input/output}\nThe program takes as input the files \\verb/example1_curve.g2/ and \\verb/example2_points.g2/,\nwhich are respectively generated by the programs \\verb/example01/ and \\verb/example02/.\nThe generated blend curve will be saved to the file \\verb/example3_curve.g2/.\n\n\\subsection{example04.C}\n\n\\subsubsection{What it does}\nThis program generates an \\emph{offset curve} from another curve.  An offset curve is\nspecified as having a fixed distance in a specified direction from the original curve.\nThe generated offset curve will not be exact, as this would in general be impossible using\na spline-function.  We can however obtain an approximation within a user-specified tolerance.\n\n\\subsubsection{What it demonstrates}\n\\begin{enumerate}\n\\item What an offset curve is and how it can be specified.\n\\item The way in which many SISL routines deal with geometric tolerances.\n\\item The use of the SISL routine \\verb/s1360/, which computes the offset curve within a \nspecified, geometric tolerance.\n\\end{enumerate}\n\\subsubsection{Input/output}\nThe original curve is read from the file \\verb/example1_curve.g2/, which is generated by\nthe program \\verb/example01/.  The resulting approximation of the offset curve will be \nwritten to the file \\verb/example4_curve.g2/.\n\n\\subsection{example05.C}\n\n\\subsubsection{What it does}\nThis program generates a family of conic section curves, which are represented as rational\nsplines.  Conic sections can be \\emph{exactly} represented with such splines, so no geometric \ntolerance specification is needed.  The program will generate three ellipse segments, one\nparabola segment and three hyperbola segments, based on internal, hard-coded data.\n\n\\subsubsection{What it demonstrates}\n\\begin{enumerate}\n\\item The use of the SISL routine \\verb/s1011/ to generate all kinds of conic sections.\n\\item The important fact that conic sections can be exactly represented by rational splines.\n\\item How a single \\emph{shape} parameter can specify whether the generated curve will be an\nellipse, a parabola or a hyperbola.\n\\end{enumerate}\n\\subsubsection{Input/output}\nThe program takes no input files.\\\\\nThe program generates the file \\verb/example5_curve.g2/ which contains all the generated curves.\n\n\\subsection{example06.C}\n\n\\subsubsection{What it does}\nThis program generates two curves (from internal, hardcoded data), and computes their \nintersections.  Computation of intersections is an extremely important part of SISL, although \nthe intersection of two curves is a minor problem in this respect.\n\\subsubsection{What it demonstrates}\n\\begin{enumerate}\n\\item The use of the SISL routine \\verb/s1857/ for computing the intersection points between\ntwo given spline curves.\n\\item Underlines the fact that the detected intersection points are returned as parameter values,\nand have to be evaluated in order to find their 3D positions.\n\\item How to clean up an array of intersection curves (SISLIntcurve), although, in \nthis example, this array will already be empty.\n\\end{enumerate}\n\\subsubsection{Input/output}\nThe program takes no input files (the data for the curves is hard-coded).  \\\\\nThe generated curves will be written to the files \\verb/example6_curve_1.g2/ and \\\\\n\\verb/example6_curve_2.g2/.  The intersection point positions will be written to the file\n\\verb/example6_isectpoints.g2/.\n\n\\subsection{example07.C}\n\n\\subsubsection{What it does}\nThis is a very short and simple program that calculates the arc length of a curve.\n\\subsubsection{What it demonstrates}\n\\begin{enumerate}\n\\item The use of the SISL routine \\verb/s1240/ for computing the length of a spline curve.\n\\end{enumerate}\n\\subsubsection{Input/output}\nThe curve whose length is calculated is read from the file \\verb/example6_curve_1/, which\nhas been generated by the sample program \\verb/example06/.  The calculated length will be\nwritten to standard output.\n\n\\subsection{example08.C}\n\n\\subsubsection{What it does}\nThis program generates two non-intersecting spline curves (from internal, hard-coded cata), and\ncomputes their mutual closest point.  The call is very similar to the one in \\verb/example06/, \nwhere we wanted to compute curve intersections.\n\\subsubsection{What it demonstrates}\n\\begin{enumerate}\n\\item The use of the SISL routine \\verb/s1955/ for locating the closest points of two curves.\n\\end{enumerate}\n\\subsubsection{Input/output}\nAs the curves are specified directly by internal data, no input files are needed.\\\\\nThe two generated curves will be saved to the two files \\verb/example8_curve_1.g2/ and \n\\verb/example8_curve_2.g2/.  The closest points will be written to the file \\\\\n\\verb/example8_closestpoints.g2/.\n\n\\subsection{example09.C}\n\n\\subsubsection{What it does}\nThis program generates four different surfaces interpolating an array of spatial points.  \nThe surfaces have different spline order, so that even though they interpolate the same \npoints, they have different shapes.\n\\subsubsection{What it demonstrates}\n\\begin{enumerate}\n\\item The use of the SISL routine \\verb/s1537/ for generating an interpolating surface to a grid\nof points.\n\\item The effect of the spline order on the interpolating surface.\n\\end{enumerate}\n\\subsubsection{Input/output}\nThe program takes no input files (the points to be interpolated are hard-coded). \\\\\nThe program creates two data files: \\verb/example9_points.g2/, which contains all the \ninterpolated points, and \\verb/example9_surf.g2/, which contains the four generated\nsurfaces.\n\n\\subsection{example10.C}\n\n\\subsubsection{What it does}\nThis program generates a sequence of spline curves.  Moreover, it generates a \\emph{lofted\nsurface} interpolating these curves.  The lofted surface has the original sequence of curves\nas isoparametric curves in one of its parameters.\n\\subsubsection{What it demonstrates}\n\\begin{enumerate}\n\\item The use of the SISL routine \\verb/s1538/ for generating lofted spline surfaces.\n\\item Gives a good example of what a lofted surface looks like.\n\\end{enumerate}\n\\subsubsection{Input/output}\nThe program takes no input files (the curves to be interpolated are hard-coded).\\\\\nThe program creates two data files: \\verb/example10_curves.g2/, containing the generated\nsequence of curves, and \\verb/example10_surf.g2/, containing the lofted surface.\n\n\\subsection{example11.C}\n\n\\subsubsection{What it does}\nThis program generates a cylindrical surface with an oval base.\n\\subsubsection{What it demonstrates}\n\\begin{enumerate}\n\\item The use of the SISL routine \\verb/s1021/ for generating cylindrical surfaces.\n\\item The fact that cylindrical surfaces are exactly representable as rational spline surfaces.\n\\end{enumerate}\n\\subsubsection{Input/output}\nThe program takes no input files.\\\\\nThe program creates one data file: \\verb/example11_surf.g2/, containing the generated surface.\n\n\\subsection{example12.C}\n\n\\subsubsection{What it does}\nThis program finds the intersection points between a curve and a surface.  The curve and the \nsurface in question have been defined by previous example programs.\n\\subsubsection{What it demonstrates}\n\\begin{enumerate}\n\\item The use of the SISL routine \\verb/s1858/ for computing intersection points between a \ncurve and a surface.\n\\end{enumerate}\n\\subsubsection{Input/output}\nThe curve and the surface in question are read from the files \\verb/example4_curve.g2/ \nand \\verb/example10_surf.g2/, respectively generated by the sample programs\n\\verb/example04/ and \\verb/example10/.  The found intersections are written to\nthe file \\\\\n\\verb/example12_isectpoints.g2/.\n\n\\subsection{example13.C}\n\n\\subsubsection{What it does}\nThis program computes all intersection curves between two surfaces.  This is a nontrivial\ntask in geometrical modeling.  The problem is twofold.  The first problem is to determine\nthe number of intersections, and their topology. The region of an intersection can be either\na point, a curve and a surface.  In the two latter cases, the shape of the region can usually\nonly be approximated.  We do not know a priori how many separate intersections there exists\nbetween two surfaces, so we have to look systematically for them.  Intersection curves can\ntake the form of closed loops on the interior of the surfaces, of curves running\nfrom the surface edges, or of curves meeting in a singularity.\nWhen we have successfully determined the topology of the intersections,\nthe second problem is to determine their acutal shape.  This is usually done by \\emph{marching\ntechniques}.  However, we may run into problems with 'degenerated' surfaces, or surfaces being \nclose to coplanar in the intersection.\n\\subsubsection{What it demonstrates}\n\\begin{enumerate}\n\\item The use of the SISL routine \\verb/s1859/ for determining the topology of the intersections\nbetween two spline surfaces.\n\\item The use of the SISL routine \\verb/s1310/ for marching out the detected curves after their\ntopologies have been determined.\n\\end{enumerate}\n\\subsubsection{Input/output}\nThe two surfaces have been generated by the previous sample programs \\verb/example10/ and \n\\verb/example11/, and can be found in the files \\verb/example10_surf.g2/ and \\\\\n\\verb/example11_surf.g2/.  The resulting intersection curves will be written to the file\n\\verb/example13_isectcurves.g2/.\n\n\\subsection{example14.C}\n\n\\subsubsection{What it does}\nThis program demonstrates one of the data reduction techniques of SISL.  As input data, it first\ngenerates a dense point set by sampling from a (predefined) spline curve.  Then, using this\ndata, it attempts to generate a new spline curve that fits closely to these samples, while using \nas few control points as possible.  Since we know that in this case the data points come from\na simple spline curve, it should be no surprise that the generated curve will have approximately\nthe same expression as the sampled curve (and thus reduce the quantity of data substantially\ncompared to what is needed to store the points).  However, data reduction can be obtained on any\nsufficiently smooth point set, even if it originates from other processes.\n\n\\subsubsection{What it demonstrates}\n\\begin{enumerate}\n\\item The use of the SISL routine \\verb/s1961/ for generating approximating spline curves through\na set of data, using as few control points as possible.\n\\item The power of this data reduction technique on smooth point data.\n\\end{enumerate}\n\\subsubsection{Input/output}\nThe program takes no input files, as the curve to be sampled from is hard-coded.  \\\\\nThe sampled points will be written to the file \\verb/example14_points.g2/, and the obtained\ncurve will be stored in \\verb/example14_curve.g2/.\n\n\\subsection{example15.C}\n\n\\subsubsection{What it does}\nThis is the last of the sample programs, and by far the most complicated.  It aims not only to \ndemonstrate a certain feature of SISL, but to show how this feature can be used for a purpose\n(raytracing).  Moreover, it demonstrates two ways of achieveing this, one slow and robust method\nand one rapid but fragile method. \\\\\nRaytracing can be seen as the process of determining what an object 'looks like' from a \ncertain viewpoint, through a certain 'window', as illustrated below.\n\\begin{figure}[h]\n\\begin{center}\n\\includegraphics[width=2.3in, height=2in,angle = 0]{raytracing.pdf}\n\\end{center}\n\\end{figure}\nLines ('rays') are extended from the viewpoint through a dense grid of points on the window,\nand checked for intersection with the object.  If such an intersection exists, it should be \nregistered as a point on the object 'visible' from the viewpoint.  In computer graphics, these \npoints are projected back on the window, which becomes a 2D image that can be displayed on the\ncomputer screen.  For our purposes, we refrain from doing this projection, and store the \nfull 3D coordinates of the detected point.\\\\\nNote that a ray may intersect the object more than once.  In these cases, the intersection point\nclosest to the viewpoint is chosen, as the other points are 'hidden' by it.  As mentioned above,\nthere are two raytracing routines in this example program.  The robust routine calculates all\npossible intersection points for each ray, and then choses the nearest one.  This should always\nwork, but can be slow since no information is re-used.  When we have found an intersection point\nfor a given ray, we can usually expect that the next, neighouring ray will intersect in a point\nclose to the one already found.  If this is the case, it would be speedier to use a local \nalgorithm that converges on the intersection point quickly given a good initial guess.  This is\nthe basis for our 'quick' routine.  This routine uses the robust raytracing algorithm to find\nthe first point on a surface, and then it switches over to the fast method as long as it is \npossible to do so.  However, since the quick method never finds more than one intersection point,\nand since a ray may generally intersect an object more than once, we have no guarantee that\nthe point found is the one truly visible from the viewpoint.  There are some checking procedures\nthat make things better, but we still have no guarantee.   If the user inspects the results \nobtained, he will notice this problem even on the simple example given here.  In general, it\ncan be said that the rapid algorithm should only be used in some special cases, where we know\nfor a fact that any ray from the viewpoint will not intersect the surface more than once.\\\\\n\nThis is the only of the example programs that can be run with a command line argument.  If the \nfirst argument is \\verb/q/, then the quick raytracing routine will be invoked.  Else, the\nrobust and slow routine is used.\n\n\\subsubsection{What it demonstrates}\n\\begin{enumerate}\n\\item The basic setting and principe of a raytracer, with a defined viewpoint, window and \nintersection with rays.\n\\item The use of the SISL routine \\verb/s1856/, which calculates all intersections between a \nspline surface and a line.\n\\item The use of the SISL routine \\verb/s1518/, which converges to an intersection between\na spline surface and a line, given a good initial guess.\n\\end{enumerate}\n\\subsubsection{Input/output}\nThe surface to be raytraced is read from the file \\verb/example10_surf.g2/, generated by\nthe \\verb/example10/ program.  The other parameters necessary for the raytracing are hard-\ncoded (viewpoint, view window, resolution, etc.).  The resulting points are written to the\nfile \\verb/example15_points.g2/. \n"
  },
  {
    "path": "doc/manual/sec_box_object.tex",
    "content": "\n\n\\subsection{Bounding box object.} \\label{sec:bbox}\n\nIn the library a bounding box is stored in a struct SISLbox\ncontaining the following:\n\\input{type/SISLBox}\n\\pgsbreak\n\\input{func/newbox}\n\n"
  },
  {
    "path": "doc/manual/sec_cone_object.tex",
    "content": "\n\n\\subsection{Normal cone object.} \\label{sec:dcone}\n\nIn the library a direction cone is stored in a struct SISLdir\ncontaining the following:\n\n\\input{type/SISLDir}\n\\pgsbreak\n\\input{func/newdir}\n\n"
  },
  {
    "path": "doc/manual/sec_curve_object.tex",
    "content": "\\section{\\label{curveobject}Curve Object}\n\nIn the library both B-spline and NURBS curves are stored in a struct SISLCurve containing\nthe following:\n\\input{type/SISLCurve}\nNote that in the rational case are the curve coefficients stored as\n\\newline\n${w_1  {\\bf p}_1, w_1, w_2 {\\bf p}_2, w_2, \\ldots,\n  w_n  {\\bf p}_n, w_n}$ where $w_i$ are the weights and ${\\bf p}_i$, $i=1, \\ldots, n$ are the\ncurve coefficients.\n\nWhen using a curve, do not declare a SISLCurve but a pointer to a SISLCurve,\nand initialize it to point on NULL. Then you may use the\ndynamic allocation functions newCurve and freeCurve described below,\nto create and delete curves.\n\nThere are two ways to pass coefficient and knot arrays\nto newCurve.\nBy setting $icopy=1$, newCurve\nallocates new arrays and copies the given ones.\nBut by setting $icopy=0$ or 2, newCurve simply points\nto the given arrays. Therefore it is IMPORTANT that the\ngiven arrays have been allocated in free memory beforehand.\n\n\\pgsbreak\n\\input{func/newCurve}\n\\pgsbreak\n\\input{func/copyCurve}\n\\pgsbreak\n\\input{func/freeCurve}\n"
  },
  {
    "path": "doc/manual/sec_intcurve_object.tex",
    "content": "\\section{Intersection Curves}\nIntersection curves are tied to two objects where at\nleast one is a surface or a curve.\nThe representation of the intersection curves in the SISLIntcurve structure has two levels.\nThe first level is guide points which are\npoints in the parametric space and on the intersection\ncurve. In every case\nthere must be at least one guide point, but there is no\nupper bound. Guide points are computed in the topology detection routines.\nThe second level is curves,\none curve in the geometric space and one curve in each\nparameter plane if each surface is parametric. These curves are the results of the marching routines.\n\n\\subsection{Intersection curve object.}\n\nIn the library an intersection curve is stored in a struct SISLIntcurve\ncontaining the following:\n\\input{type/SISLIntcurve}\nSingularities are points on the intersection curve where, in an intersection between a curve and a surface, the tangent\nof the curve lies in the tangent plane of the surface, or in an intersection between two surfaces, the tangent plane\nof the surfaces coincide.\n\\pgsbreak\n\\input{func/newIntcurve}\n\\pgsbreak\n\\input{func/freeIntcurve}\n\\pgsbreak\n\\input{func/freeIntcrvlist}\n"
  },
  {
    "path": "doc/manual/sec_spline_curve.tex",
    "content": "\\section{B-spline Curves}\n\nThis section is optional reading for those who want to\nbecome acquainted with some of the mathematics of\nB-splines curves. For a description of the data structure for\nB-spline curves in SISL, see section \\ref{curveobject}.\n\nA B-spline curve is defined by the formula\n$$ {\\bf c}(t) = \\sum_{i=1}^{n} {\\bf p}_{i} B_{i,k,{\\bf t}}(t). $$\nThe dimension of the curve ${\\bf c}$ is equal to that of its\n{\\it control points} ${\\bf p}_i$. For example, if the dimension of the\ncontrol points\nis one, the curve is a function, if the dimension is two,\nthe curve is planar, and if the dimension is three,\nthe curve is spatial. SISL also allows higher dimensions.\n\nThus, a B-spline curve is a linear combination of a sequence of B-splines\n$B_{i,k,{\\bf t}}$ (called a B-basis)\nuniquely determined by a knot vector ${\\bf t}$ and\nthe order $k$. Order is equivalent to polynomial degree plus one.\nFor example, if the order is two, the degree is one and the B-splines\nand the curve $c$ they generate are (piecewise) linear.\nIf the order is three, the degree is two and the B-splines and\nthe curve are quadratic. Cubic B-splines and\ncurves have order 4 and degree 3, etc.\n\nThe parameter range of a B-spline curve ${\\bf c}$ is the interval\n$$ [t_k, t_{n+1}], $$\nand so mathematically, the curve is a mapping\n${\\bf c}: [t_k, t_{n+1}] \\to \\RR^d$, where $d$ is the Euclidean space\ndimension of its control points.\n\nThe complete representation of a B-spline curve consists of\n\\begin{description}\n\\item[$dim$]: The dimension of the underlying Euclidean space,\n              $1,2,3,\\ldots$.\n\\item[$n$]: The number of vertices (also the number of B-splines)\n\\item[$k$]: The order (degree plus one) of the B-splines.\n\\item[${\\bf t}$]: The knot vector of the B-splines.\n            ${\\bf t} = (t_1, t_2, \\ldots, t_{n+k})$.\n\\item[${\\bf p}$]: The control points of the B-spline curve.\n           $p_{d,i}\\;,\\; d=1,\\ldots,dim\\;,\\;\n                i=1,\\ldots,n.\\;\\;$\n                e.g. when $dim = 3$, we have\n                ${\\bf p} = (x_1,y_1,z_1,x_2,y_2,z_2,\\ldots,x_n,y_n,z_n)$.\n\\end{description}\n\nWe note that arrays in $c$ start at index 0 which means,\nfor example, that if the array $t$ holds the knot vector,\nthen $t[0] = t_1,\\ldots, t[n+k-1] = t_{n+k}$\nand the parameter interval goes from\n$t[k-1]$ to $t[n]$. Similar considerations apply to the other arrays.\n\nThe data in the representation must satisfy certain conditions:\n\\begin{itemize}\n\\item The knot vector must be non-decreasing: $t_i \\le t_{i+1}$.\n      Moreover, two knots $t_i$ and $t_{i+k}$ must be distinct:\n      $t_i < t_{i+k}$.\n\\item The number of vertices should be greater than or equal\n      to the order of the curve: $n \\ge k$.\n\\item There should be $k$ equal knots at the beginning and at the end\n      of the knot vector; that is the knot vector ${\\bf t}$\n      must satisfy the conditions $t_1 = t_2 = \\ldots = t_k$\n      and $t_{n+1} = t_{n+2} = \\ldots = t_{n + k}$.\n\\end{itemize}\n\nTo understand the representation better, we will look at\nthree parts of the\nrepresentation: the B-splines (the basis functions),\nthe knot vector and the control polygon.\n\n\\subsection{B-splines}\n\nA set of B-splines is determined by the order $k$\nand the knots. For example,\nto define a single B-spline of degree one, we need three knots.\nIn figure~\\ref{curve1} the three knots are marked as dots.\nKnots can also be equal as shown in figure\n\\ref{curve2}.\nBy taking a linear combination of the three types of B-splines shown\nin figures~\\ref{curve1} and~\\ref{curve2}\nwe can generate a linear spline function\nas shown in figure~\\ref{curve3}.\n\\begin{figure}\n        \\begin{center}\n                \\begin{picture}(250,80)(0,0)\n                \\put(80,0){\\circle*{2}}\n                \\put(150,0){\\circle*{2}}\n                \\put(230,0){\\circle*{2}}\n\n                \\put(30,4){\\vector(0,1){76}}\n                \\put(28,10){\\line(1,0){4}}\n                \\put(28,70){\\line(1,0){4}}\n                \\put(20,10){\\makebox(0,0){0.0}}\n                \\put(20,70){\\makebox(0,0){1.0}}\n\n                \\thicklines\n                \\put(80,10){\\line(6,5){70}}\n                \\put(150,70){\\line(4,-3){80}}\n                \\end{picture}\\\\\n        \\end{center}\n  \\caption{\\label{curve1}A linear B-spline (order 2) defined by\n                        three knots.}\n\\end{figure}\n\\begin{figure}\n        \\begin{center}\n                \\begin{picture}(300,85)(0,0)\n                \\put(40,0){\\circle*{2}}\n                \\put(280,0){\\circle*{2}}\n                \\put(120,5){\\circle*{2}}\n                \\put(200,5){\\circle*{2}}\n                \\put(40,5){\\circle*{2}}\n                \\put(280,5){\\circle*{2}}\n\n                \\put(20,9){\\vector(0,1){76}}\n                \\put(18,15){\\line(1,0){4}}\n                \\put(18,75){\\line(1,0){4}}\n                \\put(10,15){\\makebox(0,0){0.0}}\n                \\put(10,75){\\makebox(0,0){1.0}}\n\n                \\put(170,9){\\vector(0,1){76}}\n                \\put(168,15){\\line(1,0){4}}\n                \\put(168,75){\\line(1,0){4}}\n                \\put(160,15){\\makebox(0,0){0.0}}\n                \\put(160,75){\\makebox(0,0){1.0}}\n\n                \\thicklines\n                \\put(120,15){\\line(-4,3){80}}\n                \\put(200,15){\\line(4,3){80}}\n                \\end{picture}\\\\\n        \\end{center}\n  \\caption{\\label{curve2}Linear B-splines of with multiple knots at one end.}\n\\end{figure}\n\\begin{figure}\n        \\begin{center}\n                \\begin{picture}(300,90)(0,0)\n                \\put(0,0){\\circle*{2}}\n                \\put(0,5){\\circle*{2}}\n                \\put(60,5){\\circle*{2}}\n                \\put(120,5){\\circle*{2}}\n                \\put(160,5){\\circle*{2}}\n                \\put(240,5){\\circle*{2}}\n                \\put(300,5){\\circle*{2}}\n                \\put(300,0){\\circle*{2}}\n\n                \\multiput(0,10)(12,10){5}{\\line(6,5){10}}\n                \\multiput(60,10)(-12,8){5}{\\line(-3,2){10}}\n                \\multiput(60,10)(12,2){5}{\\line(6,1){10}}\n                \\multiput(120,10)(-12,10){5}{\\line(-6,5){10}}\n                \\multiput(120,10)(12,6){3}{\\line(2,1){10}}\n                \\multiput(160,10)(-12,3){3}{\\line(-4,1){10}}\n                \\multiput(160,10)(12,12){6}{\\line(1,1){10}}\n                \\multiput(240,10)(-12,3){6}{\\line(-4,1){10}}\n                \\multiput(240,10)(12,12){5}{\\line(1,1){10}}\n                \\multiput(300,10)(-12,16){5}{\\line(-3,4){10}}\n\n                \\thicklines\n                \\put(0,50){\\line(6,1){60}}\n                \\put(60,60){\\line(3,-2){60}}\n                \\put(120,20){\\line(4,1){40}}\n                \\put(160,30){\\line(4,3){80}}\n                \\put(240,90){\\line(3,-1){60}}\n                \\end{picture}\\\\\n        \\end{center}\n  \\caption{\\label{curve3}A B-spline curve of dimension 1 as a linear\n            combination of a sequence of B-splines.\n            Each B-spline (dashed) is scaled by a coefficient.}\n\\end{figure}\n\nA quadratic B-spline is a linear combination of two linear\nB-splines. Shown in figure~\\ref{curve4}\nis a quadratic B-spline defined by four knots.\nA quadratic B-spline is\nthe sum of two products, the first product between the linear B-spline\non the left and a corresponding line from 0 to 1,\nthe second product between the linear B-spline\non the right and a corresponding line from 1 to 0;\nsee figure~\\ref{curve4}.\nFor higher degree B-splines there is a similar definition.\nA B-spline of order $k$ is the sum of two B-splines of\norder $k-1$, each weighted with weights in the interval [0,1].\nIn fact we define B-splines of order 1 explicitly as box functions,\n$$  B_{i,1}(t) =  \\cases{1 & if $t_i \\le t < t_{i+1}$; \\cr\n                              0 &  otherwise, \\cr } $$\nand then the complete definition of a $k$-th order B-spline is\n$$ B_{i,k}(t) = {t - t_i \\over t_{i+k-1} - t_i} B_{i,k-1}(t)\n             +\n             {t_{i+k} - t \\over t_{i+k} - t_{i+1}} B_{i-1,k-1}(t). $$\n\n\\begin{figure}\n        \\begin{center}\n                \\begin{picture}(250,70)(0,0)\n\n                \\put(10,4){\\vector(0,1){76}}\n                \\put(8,10){\\line(1,0){4}}\n                \\put(8,70){\\line(1,0){4}}\n                \\put(0,10){\\makebox(0,0){0.0}}\n                \\put(0,70){\\makebox(0,0){1.0}}\n\n                \\put(35,0){\\circle*{2}}\n                \\put(95,0){\\circle*{2}}\n                \\put(155,0){\\circle*{2}}\n                \\put(215,0){\\circle*{2}}\n\n                \\multiput(35,10)(18,9){7}{\\line(2,1){10}}\n                \\multiput(215,10)(-18,9){7}{\\line(-2,1){10}}\n\n                \\thicklines\n                \\put(35,10){\\line(1,1){60}}\n                \\put(95,10){\\line(1,1){60}}\n                \\put(155,10){\\line(-1,1){60}}\n                \\put(215,10){\\line(-1,1){60}}\n\n                \\bezier{70}(35,10)(65,10)(95,40)\n                \\bezier{70}(95,40)(125,70)(155,40)\n                \\bezier{70}(215,10)(185,10)(155,40)\n                \\end{picture}\\\\\n        \\end{center}\n  \\caption{\\label{curve4}A quadratic B-spline, the two linear\n           B-splines and the corresponding lines (dashed)\n           in the quadratic B-spline definition.}\n\\end{figure}\n\nB-splines satisfy some important properties for curve and surface design.\nEach B-spline is non-negative and it can be shown that they sum to\none,\n$$ \\sum_{i=1}^{n}B_{i,k,{\\bf t}}(t) = 1. $$\nThese properties combined mean that B-spline curves\nsatisfy the {\\it convex hull property}: the curve lies in the convex\nhull of its control points.\nFurthermore, the support of the B-spline $B_{i,k,{\\bf t}}$ is\nthe interval $[t_i,t_{i+k}]$ which means that B-spline\ncurves has {\\it local control}: moving one control point only\nalters the curve locally.\n\nDue to the demand of $k$ multiple knots at the ends of the knot\nvector, B-spline curves in SISL also have the {\\it endpoint property}:\nthe start point of the B-spline curve\nequals the first control point and the end point equals the\nlast control point, in other words\n$$ {\\bf c}(t_k) = {\\bf p}_1\n     \\qquad \\hbox{and} \\qquad\n   {\\bf c}(t_{n+1}) = {\\bf p}_n. $$\n\n\\subsection{\\label{contrlpoly}The Control Polygon}\n\nThe control points ${\\bf p}_i$ define the vertices\nThe {\\it control polygon} of a B-spline curve is the polygonal\narc formed by its control points,\n${\\bf p}_0, {\\bf p}_1, \\ldots,{\\bf p}_n$.\nThis means that\nthe control polygon, regarded as a parametric curve,\nis itself piecewise linear B-spline curve (order two).\nIf we increase the order, the distance between the control polygon\nand the curve increases (see figure~\\ref{curve5}).\nA higher order B-spline curve tends to smooth\nthe control polygon and at the same time mimic its shape.\nFor example, if the control polygon is convex, so is the B-spline curve.\n\nAnother property of the control polygon is that it will get closer\nto the curve if it is redefined by inserting knots into the curve\nand thereby increasing the number of vertices;\nsee figure~\\ref{curve6}.\nIf the refinement is infinite then the control polygon converges to the curve.\n\\begin{figure}\n        \\begin{center}\n                \\begin{picture}(240,80)(0,0)\n                \\thicklines\n                \\put(0,40){\\line(2,1){80}}\n                \\put(80,80){\\line(1,-1){80}}\n                \\put(160,0){\\line(1,1){80}}\n\n                \\bezier{120}(0,40)(80,80)(120,40)\n                \\bezier{120}(120,40)(160,0)(240,80)\n\n                \\bezier{120}(0,40)(60,70)(120,40)\n                \\bezier{120}(120,40)(180,20)(240,80)\n\n                \\end{picture}\\\\\n        \\end{center}\n  \\caption{\\label{curve5}Linear, quadratic, and cubic B-spline\n           curves sharing the same control polygon. The control polygon is\n                equal to the linear B-spline curve. The curves\n                are planar, i.e. the space dimension is two.}\n\\end{figure}\n\n\\begin{figure}\n        \\begin{center}\n                \\begin{picture}(240,80)(0,0)\n                \\thicklines\n                \\put(0,40){\\line(2,1){40}}\n                \\put(40,60){\\line(5,0){40}}\n                \\put(80,60){\\line(2,-1){60}}\n                \\put(140,30){\\line(6,1){60}}\n                \\put(200,40){\\line(1,1){40}}\n\n                \\bezier{120}(0,40)(60,70)(120,40)\n                \\bezier{120}(120,40)(180,20)(240,80)\n\n                \\end{picture}\\\\\n        \\end{center}\n  \\caption{\\label{curve6}The cubic B-spline curve with a\n                redefined knot vector.}\n\\end{figure}\n\n\\subsection{The Knot Vector}\n\nThe knots of a B-spline curve describe the following properties of the curve:\n\\begin{itemize}\n\\item The parameterization of the B-spline curve\n\\item The continuity at the joins between the adjacent polynomial\n   segments of the B-spline curve.\n\\end{itemize}\nIn figure~\\ref{curve7} we have two curves\nwith the same control polygon and order but\nwith different parameterization.\n\nThis example is not meant as an encouragement to use\nparameterization for modelling, rather to make users\naware of the effect of parameterization. Something close to\ncurve length parameterization is in most cases\npreferable. For interpolation, chord-length parameterization\nis used in most cases.\n\nThe number of equal knots determines the degree\nof continuity. If $k$ consecutive internal knots are equal,\nthe curve is discontinuous.\nSimilarly if $k-1$ consecutive internal knots are equal,\nthe curve is continuous but not in general differentiable.\nA continuously differentiable curve\nwith a discontinuity in the second derivative\ncan be modelled using $k-2$ equal knots etc. (see figure~\\ref{curve8}).\nNormally, B-spline curves in SISL are expected to be continuous.\nFor intersection algorithms, curves are usually expected to\nbe continuously differentiable ($C^1$).\n\n\\begin{figure}\n        \\begin{center}\n                \\begin{picture}(240,240)(0,0)\n                \\thicklines\n                \\put(0,130){\\circle*{2}}\n                \\put(0,135){\\circle*{2}}\n                \\put(0,140){\\circle*{2}}\n                \\put(240,130){\\circle*{2}}\n                \\put(240,135){\\circle*{2}}\n                \\put(240,140){\\circle*{2}}\n\n                \\put(60,140){\\circle*{2}}\n                \\put(180,10){\\circle*{2}}\n\n\n                \\put(0,0){\\circle*{2}}\n                \\put(0,5){\\circle*{2}}\n                \\put(0,10){\\circle*{2}}\n                \\put(240,0){\\circle*{2}}\n                \\put(240,5){\\circle*{2}}\n                \\put(240,10){\\circle*{2}}\n\n                \\put(0,185){\\line(2,1){80}}\n                \\put(80,225){\\line(1,-1){80}}\n                \\put(160,145){\\line(1,1){80}}\n\n                \\put(0,55){\\line(2,1){80}}\n                \\put(80,95){\\line(1,-1){80}}\n                \\put(160,15){\\line(1,1){80}}\n\n                \\bezier{130}(0,185)(80,225)(100,205)\n                \\bezier{160}(100,205)(160,145)(240,225)\n\n                \\bezier{160}(0,55)(80,95)(140,35)\n                \\bezier{130}(140,35)(160,15)(240,95)\n                \\end{picture}\\\\\n        \\end{center}\n  \\caption{\\label{curve7}Two quadratic B-spline curves with the same\ncontrol polygon but different knot vectors. The curves and the control\npolygons are two-dimensional.}\n\\end{figure}\n\n\\begin{figure}\n        \\begin{center}\n                \\begin{picture}(300,90)(0,0)\n                \\thicklines\n                \\put(0,0){\\circle*{2}}\n                \\put(0,5){\\circle*{2}}\n                \\put(0,10){\\circle*{2}}\n\n                \\put(150,5){\\circle*{2}}\n                \\put(150,10){\\circle*{2}}\n\n                \\put(300,0){\\circle*{2}}\n                \\put(300,5){\\circle*{2}}\n                \\put(300,10){\\circle*{2}}\n\n                \\bezier{200}(0,50)(80,90)(150,20)\n                \\bezier{200}(150,20)(220,80)(300,90)\n                \\end{picture}\\\\\n        \\end{center}\n  \\caption{\\label{curve8}A quadratic B-spline curve with two\nequal internal knots.}\n\\end{figure}\n\n\\subsection{NURBS Curves}\n\nA NURBS (Non-Uniform Rational B-Spline) curve is a generalization\nof a B-spline curve,\n$$ {\\bf c}(t) = {\\sum_{i=1}^{n} w_i {\\bf p}_{i} B_{i,k,{\\bf t}}(t)\n                 \\over\n                 \\sum_{i=1}^{n} w_i B_{i,k,{\\bf t}}(t)} . $$\nIn addition to the data of a B-spline curve, the NURBS curve\n${\\bf c}$ has a sequence of weights $w_1,\\ldots,w_n$.\nOne of the advantages of NURBS curves over B-spline curves is that\nthey can be used to represent conic sections exactly (taking the\norder $k$ to be three).\nA disadvantage is that NURBS curves depend nonlinearly on their weights,\nmaking some calculations, like the evaluation of derivatives,\nmore complicated and less efficient than with B-spline curves.\n\nThe representation of a NURBS curve is the same as for a B-spline\nexcept that it also includes\n\\begin{description}\n\\item[${\\bf w}$]: A sequence of weights\n            ${\\bf w} = (w_1, w_2, \\ldots, w_n)$.\n\\end{description}\n\nIn SISL we make the assumption that\n\\begin{itemize}\n\\item The weights are (strictly) positive: $w_i > 0$.\n\\end{itemize}\n\nUnder this condition, a NURBS curve, like its B-spline cousin,\nenjoys the convex hull property. \nDue to $k$-fold knots at the ends of the knot vector,\nNURBS curves in SISL alos have the endpoint \n\n"
  },
  {
    "path": "doc/manual/sec_spline_surface.tex",
    "content": "\\section{B-spline Surfaces}\n\nThis section is optional reading for those who want to\nbecome acquainted with some of the mathematics of\ntensor-product B-splines surfaces. For a description of the data structure for\nB-spline surfaces in SISL, see section \\ref{surfaceobject}.\n\nA tensor product B-spline surface is defined as\n\\[{\\bf s}(u,v) = \\sum_{i=1}^{n_1}\\sum_{j=1}^{n_2}{\\bf p}_{i,j} \n\tB_{i,k_1,{\\bf u}}(u) B_{j,k_2,{\\bf v}}(v) \\]\nwith control points ${\\bf p}_{i,j}$ and two variables\n(or parameters) $u$ and $v$.\nThe formula shows that a basis function of a B-spline surface is a\nproduct of two basis functions of B-spline curves (B-splines).\nThis is why a B-spline surface is called a tensor-product surface.\nThe following is a list of the components of the representation:\n\\begin{description}\n\\item[$dim$]: The dimension of the underlying Euclidean space.\n\\item[$n_1$]: The number of vertices with respect to the first parameter.\n\\item[$n_1$]: The number of vertices with respect to the second parameter.\n\\item[$k_1$]: The order of the B-splines in the first parameter.\n\\item[$k_2$]: The order of the B-splines in the second parameter.\n\\item[${\\bf u}$]: The knot vector of the B-splines with respect to\n                  the first parameter,\n                  ${\\bf u} = (u_1,u_2,\\ldots,u_{n_1+k_1})$.\n\\item[${\\bf v}$]: The knot vector of the B-splines with respect to\n                  the second parameter,\n                  ${\\bf v} = (v_1,v_2,\\ldots,v_{n_2+k_2})$.\n\\item[${\\bf p}$]: The control points of the B-spline surface,\n           $c_{d,i,j}$, $d=1,\\ldots,dim$, $i=1,\\ldots,n_1$,\n\t\t$j=1,\\ldots,n_2$.\n\tWhen $dim = 3$, we have\n          ${\\bf p} = (x_{1,1},y_{1,1},z_{1,1},x_{2,1},y_{2,1},z_{2,1},\\ldots$,\n                  $x_{n_1,1},y_{n_1,1},z_{n_1,1},\\ldots$,\n                     $x_{n_1,n_2},y_{n_1,n_2},z_{n_1,n_2})$.\n\\end{description}\n\nThe data of the B-spline surface must fulfill the following requirements:\n\\begin{itemize}\n\\item\nBoth knot vectors must be non-decreasing.\n\\item\nThe number of vertices must be greater than or equal to the order\nwith respect to both parameters: $n_1 \\ge k_1$ and $n_2 \\ge k_2$.\n\\item\nThere should be $k_1$ equal knots at the beginning and end \nof knot vector ${\\bf u}$ and $k_2$ equal knots at the beginning and\nend of knot vector ${\\bf v}$.\n\\end{itemize}\n\nThe properties of the representation of a B-spline surface are\nsimilar to the properties of the representation of a B-spline curve.\nThe control points ${\\bf p}_{i,j}$ form a {\\it control net} as shown in\nfigure~\\ref{surf1}.\nThe control net has similar properties to the control\npolygon of a B-spline curve, described in section~\\ref{contrlpoly}.\nA B-spline surface has two knot vectors, one\nfor each parameter. In figure~\\ref{surf1} we can\nsee {\\it isocurves}, surface curves\ndefined by fixing the value of one of the parameters.\n\n\\begin{figure}\n\\vspace{50 mm}\n  \\special{psfile=surf1.ps hoffset=-30 voffset=-170 hscale=90 vscale=60}\n  %\\special{psfile=surf1.ps hoffset=95 hscale=40 vscale=40}\n%  \\epsffile{surf1.ps}\n  \\caption{\\label{surf1}\n\t\tA B-spline surface and its control net.\n\t\tThe surface is drawn using isocurves.\n\t\tThe dimension is 3.}\n\\end{figure}\n\n\\subsection{The Basis Functions}\n\nA basis function of a B-spline surface is the product of two\nbasis functions of two B-spline curves,\n\\[ B_{i,k_1,{\\bf u}}(u) B_{j,k_2,{\\bf v}}(v). \\]\nIts support is the rectangle $[u_i,u_{i+k_1}] \\times [v_j,v_{j+k_2}]$.\nIf the basis functions in both directions are of degree one and all\nknots have multiplicity one, then the surface basis functions are\npyramid-shaped \n(see figure~\\ref{surf2}).\nFor higher degrees, the surface basis functions are bell shaped.\n\n\\begin{figure}\n\t\\begin{center}\n\t\t\\begin{picture}(250,125)(0,0)\n\n\t\t\\put(10,39){\\vector(0,1){86}}\n\t\t\\put(8,45){\\line(1,0){4}}\n\t\t\\put(8,120){\\line(1,0){4}}\n\t\t\\put(0,45){\\makebox(0,0){0.0}}\n\t\t\\put(0,120){\\makebox(0,0){1.0}}\n\n\t\t\\put(50,5){\\circle*{2}}\n\t\t\\put(100,5){\\circle*{2}}\n\t\t\\put(150,5){\\circle*{2}}\n\n\t\t\\put(190,20){\\circle*{2}}\n\t\t\\put(215,45){\\circle*{2}}\n\t\t\\put(240,70){\\circle*{2}}\n\n\t\t\\thicklines\n\t\t\\put(65,20){\\line(1,0){100}}\n\t\t\\put(165,20){\\line(1,1){50}}\n\t\t\\multiput(65,20)(18,18){3}{\\line(1,1){10}}\n\t\t\\multiput(115,70)(20,0){5}{\\line(1,0){10}}\n\n\n\t\t\\put(65,20){\\line(3,4){75}}\n\t\t\\put(165,20){\\line(-1,4){25}}\n\t\t\\put(215,70){\\line(-3,2){75}}\n\t\t\\multiput(115,70)(8,16){3}{\\line(1,2){5}}\n\t\t\\end{picture}\\\\\n\t\\end{center}\n\n  \\caption{\\label{surf2}\n\t\tA basis function of degree one in\n\t\tboth variables.}\n\\end{figure}\n\n\\subsection{NURBS Surfaces}\n\nA NURBS (Non-Uniform Rational B-Spline) surface is a generalization\nof a B-spline surface,\n$$ {\\bf s}(u,v) = {\\sum_{i=1}^{n_1}\\sum_{j=1}^{n_2} w_{i,j} {\\bf p}_{i,j} \n\t    B_{i,k_1,{\\bf u}}(u) B_{j,k_2,{\\bf v}}(v)  \\over\n             \\sum_{i=1}^{n_1}\\sum_{j=1}^{n_2} w_{i,j}\n\t         B_{i,k_1,{\\bf u}}(u) B_{j,k_2,{\\bf v}}(v)}. $$\nIn addition to the data of a B-spline surface, the NURBS surface\nhas a weights $w_{i,j}$.\nNURBS surfaces can be used to exactly represent several common\n`analytic' surfaces such as spheres, cylinders, tori, and cones.\nA disadvantage is that NURBS surfaces depend nonlinearly on their weights,\nmaking some calculations, like with NURBS curves,\nless efficient.\n\nThe representation of a NURBS surface is the same as for a B-spline\nexcept that it also includes\n\\begin{description}\n\\item[${\\bf w}$]: The weights of the NURBS surface,\n           $w_{i,j}$, $i=1,\\ldots,n_1$, $j=1,\\ldots,n_2$, so\n          ${\\bf w} = (w_{1,1},w_{2,1},\\ldots,w_{n_1,1},\\ldots$,\n                  $w_{1,2},\\ldots,w_{n_1,n_2})$.\n\\end{description}\nIn SISL we make the assumption that\n\\begin{itemize}\n\\item The weights are (strictly) positive: $w_{i,j} > 0$.\n\\end{itemize}\n\n"
  },
  {
    "path": "doc/manual/sec_surface_object.tex",
    "content": "\\section{\\label{surfaceobject}Surface Object}\n\nIn the library both B-spline and NURBS surfaces are stored in a struct SISLSurf containing\nthe following:\n\\input{type/SISLSurf}\nWhen using a surface, do not declare a Surface but a pointer to a Surface,\nand initialize it to point to NULL. Then you may use the\ndynamic allocation functions newSurface and freeSurface, which are described below,\nto create and delete surfaces.\n\nThere are two ways to pass coefficient and knot arrays\nto newSurf.\nBy setting $icopy=1$, newSurf\nallocates new arrays and copies the given ones.\nBut by setting $icopy=0$ or 2, newSurf simply points\nto the given arrays. Therefore it is IMPORTANT that the\ngiven arrays have been allocated in free memory beforehand.\n\\pgsbreak\n\\input{func/newSurf}\n\\pgsbreak\n\\input{func/copySurface}\n\\pgsbreak\n\\input{func/freeSurf}\n"
  },
  {
    "path": "doc/manual/sislman.sty",
    "content": "% sislman.sty 2 feb 1990.\n\n\\typeout{Document Style `sislman' <2 feb 90>.}\n\n\\def\\ds@twoside{\\@twosidetrue \\@mparswitchtrue}\n\\def\\ds@draft{\\overfullrule 5pt} \n\\@options\n\\lineskip 1pt \\normallineskip 1pt\n\\def\\baselinestretch{1}\n\n\\def\\@normalsize{\\@setsize\\normalsize{13.6pt}\\xipt\\@xipt\n\\abovedisplayskip 11pt plus3pt minus6pt\\belowdisplayskip \\abovedisplayskip\n\\abovedisplayshortskip \\z@ plus3pt\\belowdisplayshortskip 6.5pt plus3.5pt\nminus3pt\\let\\@listi\\@listI} \n\\def\\small{\\@setsize\\small{12pt}\\xpt\\@xpt\n\\abovedisplayskip 10pt plus2pt minus5pt\\belowdisplayskip \\abovedisplayskip\n\\abovedisplayshortskip \\z@ plus3pt\\belowdisplayshortskip 6pt plus3pt minus3pt\n\\def\\@listi{\\leftmargin\\leftmargini \\topsep 6pt plus 2pt minus 2pt\\parsep 3pt\nplus 2pt minus 1pt\n\\itemsep \\parsep}}\n\\def\\footnotesize{\\@setsize\\footnotesize{11pt}\\ixpt\\@ixpt\n\\abovedisplayskip 8pt plus 2pt minus 4pt\\belowdisplayskip \\abovedisplayskip\n\\abovedisplayshortskip \\z@ plus 1pt\\belowdisplayshortskip 4pt plus 2pt minus\n2pt\n\\def\\@listi{\\leftmargin\\leftmargini \\topsep 4pt plus 2pt minus 2pt\\parsep 2pt\nplus 1pt minus 1pt\n\\itemsep \\parsep}}\n\\def\\scriptsize{\\@setsize\\scriptsize{9.5pt}\\viiipt\\@viiipt}\n\\def\\tiny{\\@setsize\\tiny{7pt}\\vipt\\@vipt}\n\\def\\large{\\@setsize\\large{14pt}\\xiipt\\@xiipt}\n\\def\\Large{\\@setsize\\Large{18pt}\\xivpt\\@xivpt}\n\\def\\LARGE{\\@setsize\\LARGE{22pt}\\xviipt\\@xviipt}\n\\def\\huge{\\@setsize\\huge{25pt}\\xxpt\\@xxpt}\n\\def\\Huge{\\@setsize\\Huge{30pt}\\xxvpt\\@xxvpt}\n\\normalsize \n\f\n\\if@twoside \\oddsidemargin 30pt \\evensidemargin 30pt \\marginparwidth 85pt\n%\\if@twoside \\oddsidemargin 21pt \\evensidemargin 59pt \\marginparwidth 85pt\n%\\if@twoside \\oddsidemargin 24pt \\evensidemargin 26pt \\marginparwidth 85pt\n\\else \\oddsidemargin 39.5pt \\evensidemargin 39.5pt\n \\marginparwidth 68pt \n\\fi\n\\marginparsep 10pt \n \\topmargin 15pt \\headheight 12pt \\headsep 25pt \\footskip 30pt \n\n\\textheight = 40\\baselineskip\n\\advance\\textheight by \\topskip\n\\textwidth 390pt \\columnsep 10pt \\columnseprule 0pt \n\n\\footnotesep 8.4pt \n\\skip\\footins 10.8pt plus 4pt minus 2pt \n\\floatsep 14pt plus 2pt minus 4pt \\textfloatsep 20pt plus 2pt minus 4pt\n\\intextsep 14pt plus 4pt minus 4pt \\@maxsep 20pt \\dblfloatsep 14pt plus 2pt\nminus 4pt \\dbltextfloatsep 20pt plus 2pt minus 4pt \\@dblmaxsep 20pt \n\\@fptop 0pt plus 1fil \\@fpsep 10pt plus 2fil \\@fpbot 0pt plus 1fil \n\\@dblfptop 0pt plus 1fil \\@dblfpsep 10pt plus 2fil \\@dblfpbot 0pt plus 1fil\n\\marginparpush 7pt \n\f\n\\parskip 0pt plus 1pt \\parindent 1.5em \\partopsep 3pt plus 2pt minus 2pt \n\\@lowpenalty 51 \\@medpenalty 151 \\@highpenalty 301 \n\\@beginparpenalty -\\@lowpenalty \\@endparpenalty -\\@lowpenalty \\@itempenalty\n-\\@lowpenalty \n\f\n\n\\def\\@makechapterhead#1{ \\vspace*{50pt} { \\parindent 0pt \\raggedright \n \\ifnum \\c@secnumdepth >\\m@ne \\huge\\bf \\@chapapp{} \\thechapter \\par \n \\vskip 20pt \\fi \\Huge \\bf #1\\par \n \\nobreak \\vskip 40pt } }\n\n\\def\\@makeschapterhead#1{ \\vspace*{50pt} { \\parindent 0pt \\raggedright \n \\Huge \\bf #1\\par \n \\nobreak \\vskip 40pt } }\n\n\\def\\chapter{\\clearpage \\thispagestyle{plain} \\global\\@topnum\\z@\n\\@afterindentfalse \\secdef\\@chapter\\@schapter} \n\\def\\@chapter[#1]#2{\\ifnum \\c@secnumdepth >\\m@ne\n \\refstepcounter{chapter}\n \\typeout{\\@chapapp\\space\\thechapter.}\n \\addcontentsline{toc}{chapter}{\\protect\n \\numberline{\\thechapter}#1}\\else\n \\addcontentsline{toc}{chapter}{#1}\\fi\n \\chaptermark{#1}\n \\addtocontents{lof}{\\protect\\addvspace{10pt}}\n\\addtocontents{lot}{\\protect\\addvspace{10pt}} \\if@twocolumn\n\\@topnewpage[\\@makechapterhead{#2}] \n \\else \\@makechapterhead{#2}\n \\@afterheading \\fi} \n\\def\\@schapter#1{\\if@twocolumn \\@topnewpage[\\@makeschapterhead{#1}]\n \\else \\@makeschapterhead{#1} \n \\@afterheading\\fi}\n\n\\def\\section{\\@startsection {section}{1}{\\z@}{-3.5ex plus -1ex minus \n -.2ex}{2.3ex plus .2ex}{\\Large\\bf}}\n\\def\\subsection{\\@startsection{subsection}{2}{\\z@}{-3.25ex plus -1ex minus \n -.2ex}{1.5ex plus .2ex}{\\large\\bf}}\n\\def\\subsubsection{\\@startsection{subsubsection}{3}{\\z@}{-3.25ex plus \n -1ex minus -.2ex}{1.5ex plus .2ex}{\\normalsize\\bf}}\n\\def\\paragraph{\\@startsection\n {paragraph}{4}{\\z@}{3.25ex plus 1ex minus .2ex}{-1em}{\\normalsize\\bf}}\n\\def\\subparagraph{\\@startsection\n {subparagraph}{4}{\\parindent}{3.25ex plus 1ex minus \n .2ex}{-1em}{\\normalsize\\bf}}\n\n\\def\\chaptermark#1{}\n\n\\setcounter{secnumdepth}{2}\n\n\\def\\appendix{\\par\n \\setcounter{chapter}{0}\n \\setcounter{section}{0}\n \\def\\@chapapp{Appendix}\n \\def\\thechapter{\\Alph{chapter}}}\n\f\n\n\\leftmargini 2.5em\n\\leftmarginii 2.2em \\leftmarginiii 1.87em \\leftmarginiv 1.7em \\leftmarginv 1em\n\\leftmarginvi 1em\n\\leftmargin\\leftmargini\n\\labelsep .5em\n\\labelwidth\\leftmargini\\advance\\labelwidth-\\labelsep\n\\def\\@listI{\\leftmargin\\leftmargini \\parsep 5pt plus 2.5pt minus 1pt\\topsep\n10pt plus 4pt minus 6pt\\itemsep 5pt plus 2.5pt minus 1pt}\n\\let\\@listi\\@listI\n\\@listi \n\\def\\@listii{\\leftmargin\\leftmarginii\n \\labelwidth\\leftmarginii\\advance\\labelwidth-\\labelsep\n \\topsep 5pt plus 2.5pt minus 1pt\n \\parsep 2.5pt plus 1pt minus 1pt\n \\itemsep \\parsep}\n\\def\\@listiii{\\leftmargin\\leftmarginiii\n \\labelwidth\\leftmarginiii\\advance\\labelwidth-\\labelsep\n \\topsep 2.5pt plus 1pt minus 1pt \n \\parsep \\z@ \\partopsep 1pt plus 0pt minus 1pt\n \\itemsep \\topsep}\n\\def\\@listiv{\\leftmargin\\leftmarginiv\n \\labelwidth\\leftmarginiv\\advance\\labelwidth-\\labelsep}\n\\def\\@listv{\\leftmargin\\leftmarginv\n \\labelwidth\\leftmarginv\\advance\\labelwidth-\\labelsep}\n\\def\\@listvi{\\leftmargin\\leftmarginvi\n \\labelwidth\\leftmarginvi\\advance\\labelwidth-\\labelsep}\n\n\f\n\n\\def\\labelenumi{\\theenumi.} \n\\def\\theenumi{\\arabic{enumi}} \n\\def\\labelenumii{(\\theenumii)}\n\\def\\theenumii{\\alph{enumii}}\n\\def\\p@enumii{\\theenumi}\n\\def\\labelenumiii{\\theenumiii.}\n\\def\\theenumiii{\\roman{enumiii}}\n\\def\\p@enumiii{\\theenumi(\\theenumii)}\n\\def\\labelenumiv{\\theenumiv.}\n\\def\\theenumiv{\\Alph{enumiv}} \n\\def\\p@enumiv{\\p@enumiii\\theenumiii}\n\n\\def\\labelitemi{$\\bullet$}\n\\def\\labelitemii{\\bf --}\n\\def\\labelitemiii{$\\ast$}\n\\def\\labelitemiv{$\\cdot$}\n\n\\def\\verse{\\let\\\\=\\@centercr \n \\list{}{\\itemsep\\z@ \\itemindent -1.5em\\listparindent \\itemindent \n \\rightmargin\\leftmargin\\advance\\leftmargin 1.5em}\\item[]}\n\\let\\endverse\\endlist\n\\def\\quotation{\\list{}{\\listparindent 1.5em\n \\itemindent\\listparindent\n \\rightmargin\\leftmargin\\parsep 0pt plus 1pt}\\item[]}\n\\let\\endquotation=\\endlist\n\\def\\quote{\\list{}{\\rightmargin\\leftmargin}\\item[]}\n\\let\\endquote=\\endlist\n\n\\def\\descriptionlabel#1{\\hspace\\labelsep \\bf #1}\n\\def\\description{\\list{}{\\labelwidth\\z@ \\itemindent-\\leftmargin\n \\let\\makelabel\\descriptionlabel}}\n\\let\\enddescription\\endlist\n\\newdimen\\descriptionmargin\n\\descriptionmargin=3em\n\f\n\n\\def\\titlepage{\\@restonecolfalse\\if@twocolumn\\@restonecoltrue\\onecolumn\n \\else \\newpage \\fi \\thispagestyle{empty}\\c@page\\z@}\n\\def\\endtitlepage{\\if@restonecol\\twocolumn \\else \\newpage \\fi}\n\n\\arraycolsep 5pt \\tabcolsep 6pt \\arrayrulewidth .4pt \\doublerulesep 2pt \n\\tabbingsep \\labelsep \n\\skip\\@mpfootins = \\skip\\footins\n\\fboxsep = 3pt \\fboxrule = .4pt \n\f\n\\newcounter{part}\n\\newcounter {chapter}\n\\newcounter {section}[chapter]\n\\newcounter {subsection}[section]\n\\newcounter {subsubsection}[subsection]\n\\newcounter {paragraph}[subsubsection]\n\\newcounter {subparagraph}[paragraph]\n\n\\def\\thepart {\\Roman{part}}\n\\def\\thechapter {\\arabic{chapter}}\n\\def\\thesection {\\thechapter.\\arabic{section}}\n\\def\\thesubsection {\\thesection.\\arabic{subsection}}\n\\def\\thesubsubsection {\\thesubsection .\\arabic{subsubsection}}\n\\def\\theparagraph {\\thesubsubsection.\\arabic{paragraph}}\n\\def\\thesubparagraph {\\theparagraph.\\arabic{subparagraph}}\n\\def\\@chapapp{Chapter}\n\n\\def\\part{\\cleardoublepage \\thispagestyle{plain} \\if@twocolumn \\onecolumn\n\\@tempswatrue \\else \\@tempswafalse \\fi \\hbox{}\\vfil \\secdef\\@part\\@spart} \n\n\\def\\@part[#1]#2{\\ifnum \\c@secnumdepth >-2\\relax \\refstepcounter{part}\n\\addcontentsline{toc}{part}{\\thepart \\hspace{1em}#1}\\else\n\\addcontentsline{toc}{part}{#1}\\fi \\markboth{}{}\n {\\centering \\ifnum \\c@secnumdepth >-2\\relax \\huge\\bf Part \\thepart \\par\n\\vskip 20pt \\fi \\Huge \\bf #1\\par}\\@endpart} \n\\def\\@endpart{\\vfil\\newpage \\if@twoside \\hbox{} \\thispagestyle{empty} \n \\newpage \n \\fi \\if@tempswa \\twocolumn \\fi} \n\\def\\@spart#1{{\\centering \\Huge \\bf #1\\par}\\@endpart}\n\n\f\n\\def\\@pnumwidth{1.55em}\n\\def\\@tocrmarg {2.55em}\n\\def\\@dotsep{4.5}\n\\setcounter{tocdepth}{2}\n\n\n\\def\\tableofcontents{\\@restonecolfalse\\if@twocolumn\\@restonecoltrue\\onecolumn\n \\fi\\chapter*{Contents\\@mkboth{CONTENTS}{CONTENTS}}\n \\@starttoc{toc}\\if@restonecol\\twocolumn\\fi}\n\\def\\l@part#1#2{\\addpenalty{-\\@highpenalty}\n \\addvspace{2.25em plus 1pt} \\begingroup\n \\@tempdima 3em \\parindent \\z@ \\rightskip \\@pnumwidth \\parfillskip\n-\\@pnumwidth \n {\\large \\bf \\leavevmode #1\\hfil \\hbox to\\@pnumwidth{\\hss #2}}\\par\n \\nobreak \\endgroup}\n\n\\def\\l@chapter#1#2{\\pagebreak[3] \n \\vskip 1.0em plus 1pt \\@tempdima 1.5em \\begingroup\n \\parindent \\z@ \\rightskip \\@pnumwidth \n \\parfillskip -\\@pnumwidth \n \\bf \\leavevmode \\advance\\leftskip\\@tempdima \\hskip -\\leftskip #1\\nobreak\\hfil\n\\nobreak\\hbox to\\@pnumwidth{\\hss #2}\\par\n \\endgroup}\n\\def\\l@section{\\@dottedtocline{1}{1.5em}{2.3em}}\n\\def\\l@subsection{\\@dottedtocline{2}{3.8em}{3.2em}}\n\\def\\l@subsubsection{\\@dottedtocline{3}{7.0em}{4.1em}}\n\\def\\l@paragraph{\\@dottedtocline{4}{10em}{5em}}\n\\def\\l@subparagraph{\\@dottedtocline{5}{12em}{6em}}\n\\def\\listoffigures{\\@restonecolfalse\\if@twocolumn\\@restonecoltrue\\onecolumn\n \\fi\\chapter*{List of Figures\\@mkboth\n {LIST OF FIGURES}{LIST OF FIGURES}}\\@starttoc{lof}\\if@restonecol\n \\twocolumn\\fi}\n\\def\\l@figure{\\@dottedtocline{1}{1.5em}{2.3em}}\n\\def\\listoftables{\\@restonecolfalse\\if@twocolumn\\@restonecoltrue\\onecolumn\n \\fi\\chapter*{List of Tables\\@mkboth\n {LIST OF TABLES}{LIST OF TABLES}}\\@starttoc{lot}\\if@restonecol\n \\twocolumn\\fi}\n\\let\\l@table\\l@figure\n\n\f\n\\def\\thebibliography#1{\\chapter*{Bibliography\\@mkboth\n {BIBLIOGRAPHY}{BIBLIOGRAPHY}}\\list\n {[\\arabic{enumi}]}{\\settowidth\\labelwidth{[#1]}\\leftmargin\\labelwidth\n \\advance\\leftmargin\\labelsep\n \\usecounter{enumi}}\n \\def\\newblock{\\hskip .11em plus .33em minus .07em}\n \\sloppy\\clubpenalty4000\\widowpenalty4000\n \\sfcode`\\.=1000\\relax}\n\\let\\endthebibliography=\\endlist\n \n\f\n\\newif\\if@restonecol\n\\def\\theindex{\\@restonecoltrue\\if@twocolumn\\@restonecolfalse\\fi\n\\columnseprule \\z@\n\\columnsep 35pt\\twocolumn[\\@makeschapterhead{Index}]\n \\@mkboth{INDEX}{INDEX}\\thispagestyle{plain}\\parindent\\z@\n \\parskip\\z@ plus .3pt\\relax\\let\\item\\@idxitem}\n\\def\\@idxitem{\\par\\hangindent 40pt}\n\\def\\subitem{\\par\\hangindent 40pt \\hspace*{20pt}}\n\\def\\subsubitem{\\par\\hangindent 40pt \\hspace*{30pt}}\n\\def\\endtheindex{\\if@restonecol\\onecolumn\\else\\clearpage\\fi}\n\\def\\indexspace{\\par \\vskip 10pt plus 5pt minus 3pt\\relax}\n\f\n\\def\\footnoterule{\\kern-3\\p@ \n \\hrule width .4\\columnwidth \n \\kern 2.6\\p@} \n\\@addtoreset{footnote}{chapter} \n\\long\\def\\@makefntext#1{\\parindent 1em\\noindent \n \\hbox to 1.8em{\\hss$^{\\@thefnmark}$}#1}\n\n\f\n\\setcounter{topnumber}{2}\n\\def\\topfraction{.7}\n\\setcounter{bottomnumber}{1}\n\\def\\bottomfraction{.3}\n\\setcounter{totalnumber}{3}\n\\def\\textfraction{.2}\n\\def\\floatpagefraction{.5}\n\\setcounter{dbltopnumber}{2}\n\\def\\dbltopfraction{.7}\n\\def\\dblfloatpagefraction{.5}\n\n\\long\\def\\@makecaption#1#2{\n \\vskip 10pt \n \\setbox\\@tempboxa\\hbox{#1: #2}\n \\ifdim \\wd\\@tempboxa >\\hsize #1: #2\\par \\else \\hbox\nto\\hsize{\\hfil\\box\\@tempboxa\\hfil} \n \\fi}\n\n\n\\newcounter{figure}[chapter]\n\\def\\thefigure{\\thechapter.\\@arabic\\c@figure}\n\\def\\fps@figure{tbp}\n\\def\\ftype@figure{1}\n\\def\\ext@figure{lof}\n\\def\\fnum@figure{Figure \\thefigure}\n\\def\\figure{\\@float{figure}}\n\\let\\endfigure\\end@float\n\\@namedef{figure*}{\\@dblfloat{figure}}\n\\@namedef{endfigure*}{\\end@dblfloat}\n\\newcounter{table}[chapter]\n\\def\\thetable{\\thechapter.\\@arabic\\c@table}\n\\def\\fps@table{tbp}\n\\def\\ftype@table{2}\n\\def\\ext@table{lot}\n\\def\\fnum@table{Table \\thetable}\n\\def\\table{\\@float{table}}\n\\let\\endtable\\end@float\n\\@namedef{table*}{\\@dblfloat{table}}\n\\@namedef{endtable*}{\\end@dblfloat}\n\f\n\\input titlepage.sty\n\f\n\\mark{{}{}} \n\n\\if@twoside \\def\\ps@headings{\\let\\@mkboth\\markboth\n\\def\\@oddfoot{}\\def\\@evenfoot{}\\def\\@evenhead{\\rm \\thepage\\hfil \\sl\n\\leftmark}\\def\\@oddhead{\\hbox{}\\sl \\rightmark \\hfil\n\\rm\\thepage}\\def\\chaptermark##1{\\markboth {\\uppercase{\\ifnum \\c@secnumdepth\n>\\m@ne\n \\@chapapp\\ \\thechapter. \\ \\fi ##1}}{}}\\def\\sectionmark##1{\\markright\n{\\uppercase{\\ifnum \\c@secnumdepth >\\z@\n \\thesection. \\ \\fi ##1}}}}\n\\else \\def\\ps@headings{\\let\\@mkboth\\markboth\n\\def\\@oddfoot{}\\def\\@evenfoot{}\\def\\@oddhead{\\hbox {}\\sl \\rightmark \\hfil\n\\rm\\thepage}\\def\\chaptermark##1{\\markright {\\uppercase{\\ifnum \\c@secnumdepth\n>\\m@ne\n \\@chapapp\\ \\thechapter. \\ \\fi ##1}}}}\n\\fi\n\\def\\ps@myheadings{\\let\\@mkboth\\@gobbletwo\n\\def\\@oddhead{\\hbox{}\\sl\\rightmark \\hfil\n\\rm\\thepage}\\def\\@oddfoot{}\\def\\@evenhead{\\rm \\thepage\\hfil\\sl\\leftmark\\hbox\n{}}\\def\\@evenfoot{}\\def\\chaptermark##1{}%\n\\def\\sectionmark##1{}\\def\\subsectionmark##1{}}\n\n\f\n\\def\\today{\\ifcase\\month\\or\n January\\or February\\or March\\or April\\or May\\or June\\or\n July\\or August\\or September\\or October\\or November\\or December\\fi\n \\space\\number\\day, \\number\\year}\n\\@addtoreset{equation}{chapter} \n\\def\\theequation{\\thechapter.\\arabic{equation}}\n\n\f\n\\ps@plain \\pagenumbering{arabic} \\onecolumn \\if@twoside\\else\\raggedbottom\\fi \n\n% bezier.sty  17-Dec-85\n\n\\newcounter{@sc}\n\\newcounter{@scp}\n\\newcounter{@t}\n\\newlength{\\@x}\n\\newlength{\\@xa}\n\\newlength{\\@xb}\n\\newlength{\\@y}\n\\newlength{\\@ya}\n\\newlength{\\@yb}\n\\newsavebox{\\@pt}\n\\def\\bezier#1(#2,#3)(#4,#5)(#6,#7){\\c@@sc#1\\relax\n \\c@@scp\\c@@sc \\advance\\c@@scp\\@ne\n \\@xb #4\\unitlength \\advance\\@xb -#2\\unitlength \\multiply\\@xb \\tw@\n \\@xa #6\\unitlength \\advance\\@xa -#2\\unitlength\n \\advance\\@xa -\\@xb \\divide\\@xa\\c@@sc\n \\@yb #5\\unitlength \\advance\\@yb -#3\\unitlength \\multiply\\@yb \\tw@\n \\@ya #7\\unitlength \\advance\\@ya -#3\\unitlength\n \\advance\\@ya -\\@yb \\divide\\@ya\\c@@sc\n \\setbox\\@pt\\hbox{\\vrule height\\@halfwidth depth\\@halfwidth \n width\\@wholewidth}\\c@@t\\z@ \n \\put(#2,#3){\\@whilenum{\\c@@t<\\c@@scp}\\do\n {\\@x\\c@@t\\@xa \\advance\\@x\\@xb \\divide\\@x\\c@@sc \\multiply\\@x\\c@@t \n \\@y\\c@@t\\@ya \\advance\\@y\\@yb \\divide\\@y\\c@@sc \\multiply\\@y\\c@@t \n \\raise \\@y \\hbox to \\z@{\\hskip \\@x\\unhcopy\\@pt\\hss}\\advance\\c@@t\\@ne}}}\n\n\\def\\pgsbreak{\n\t\\vfill\n\t\\pagebreak}\n\n\\def\\newpagetabs{\n\t\\end{tabbing}\n\t\\vfill\n\t\\newpage\n\t\\begin{tabbing}\n******\\=****\\=************\\=***\\=*******\\=*****\\=    \\kill}\n\n\\def\\funclabel#1{\n\t\\label{#1}\n\t\\index{#1()}\n\t\\begin{tabbing}\n******\\=****\\=************\\=***\\=*******\\=*****\\=    \\kill\n\tNAME\\\\\n\t\\>\\large\n\t{\\bf{#1}}\n\t\\normalsize -} \n\n\\def\\typelabel#1{\n\t\\label{#1}\n\t\\index{#1()}\n\t\\begin{tabbing}\n****\\=************\\=****\\=*****\\=*****\\=*****\\=    \\kill}\n\n\\newcommand{\\fov}{\\sl}\n\n\\newenvironment{minipg1}{\\begin{minipage}[t]{109.9mm}}{\\end{minipage}}\n\\newenvironment{minipg2}{\\begin{minipage}[t]{88.8mm}}{\\end{minipage}}\n\\newenvironment{minipg3}{\\begin{minipage}[t]{106mm}}{\\end{minipage}}\n\\newenvironment{minipg4}{\\begin{minipage}[t]{106.2mm}}{\\end{minipage}}\n\\newenvironment{minipg5}{\\begin{minipage}[t]{69.5mm}}{\\end{minipage}}\n\\newenvironment{minipg6}{\\begin{minipage}[t]{125.5mm}}{\\end{minipage}}\n\\newenvironment{minipg7}{\\begin{minipage}[t]{105mm}}{\\end{minipage}}\n"
  },
  {
    "path": "doc/manual/sislman2.sty",
    "content": "\\def \\RR{\\hbox{\\rm I\\negthinspace R}}\n\n\\newif\\if@restonecol\n\\def\\theindex{\\@restonecoltrue\\if@twocolumn\\@restonecolfalse\\fi\n\\columnseprule \\z@\n\\columnsep 35pt\\twocolumn[\\@makeschapterhead{Index}]\n \\@mkboth{INDEX}{INDEX}\\thispagestyle{plain}\\parindent\\z@\n \\parskip\\z@ plus .3pt\\relax\\let\\item\\@idxitem}\n\\def\\@idxitem{\\par\\hangindent 40pt}\n\\def\\subitem{\\par\\hangindent 40pt \\hspace*{20pt}}\n\\def\\subsubitem{\\par\\hangindent 40pt \\hspace*{30pt}}\n\\def\\endtheindex{\\if@restonecol\\onecolumn\\else\\clearpage\\fi}\n\\def\\indexspace{\\par \\vskip 10pt plus 5pt minus 3pt\\relax}\n\n\\def\\pgsbreak{\n\t\\vfill\n\t\\pagebreak}\n\n\\def\\newpagetabs{\n\t\\end{tabbing}\n\t\\vfill\n\t\\newpage\n\t\\begin{tabbing}\n******\\=****\\=************\\=***\\=*******\\=*****\\=    \\kill}\n\n\\def\\funclabel#1{\n\t\\label{#1}\n\t\\index{#1()}\n\t\\begin{tabbing}\n******\\=****\\=************\\=***\\=*******\\=*****\\=    \\kill\n\tNAME\\\\\n\t\\>\\large\n\t{\\bf{#1}}\n\t\\normalsize -} \n\n\\def\\typelabel#1{\n\t\\label{#1}\n\t\\index{#1()}\n\t\\begin{tabbing}\n****\\=************\\=****\\=*****\\=*****\\=*****\\=    \\kill}\n\n\\newcommand{\\fov}{\\sl}\n\n\\newenvironment{minipg1}{\\begin{minipage}[t]{109.9mm}}{\\end{minipage}}\n\\newenvironment{minipg2}{\\begin{minipage}[t]{88.8mm}}{\\end{minipage}}\n\\newenvironment{minipg3}{\\begin{minipage}[t]{106mm}}{\\end{minipage}}\n\\newenvironment{minipg4}{\\begin{minipage}[t]{106.2mm}}{\\end{minipage}}\n\\newenvironment{minipg5}{\\begin{minipage}[t]{69.5mm}}{\\end{minipage}}\n\\newenvironment{minipg6}{\\begin{minipage}[t]{125.5mm}}{\\end{minipage}}\n\\newenvironment{minipg7}{\\begin{minipage}[t]{105mm}}{\\end{minipage}}\n"
  },
  {
    "path": "doc/manual/surf1.fig",
    "content": "#FIG 3.2\nLandscape\nCenter\nMetric\nA4      \n100.00\nSingle\n-2\n1200 2\n1 3 0 1 0 7 50 -1 0 0.000 1 0.0000 3330 7335 45 45 3330 7335 3375 7335\n1 3 0 1 0 7 50 -1 0 0.000 1 0.0000 5670 8595 45 45 5670 8595 5715 8595\n1 3 0 1 0 7 50 -1 0 0.000 1 0.0000 6165 6975 45 45 6165 6975 6210 6975\n1 3 0 1 0 7 50 -1 0 0.000 1 0.0000 7515 7020 45 45 7515 7020 7560 7020\n1 3 0 1 0 7 50 -1 0 0.000 1 0.0000 6570 5535 45 45 6570 5535 6615 5535\n1 3 0 1 0 7 50 -1 0 0.000 1 0.0000 3555 5895 45 45 3555 5895 3600 5895\n1 3 0 1 0 7 50 -1 0 0.000 1 0.0000 5265 5760 45 45 5265 5760 5310 5760\n1 3 0 1 0 7 50 -1 0 0.000 1 0.0000 4680 7020 45 45 4680 7020 4725 7020\n1 3 0 1 0 7 50 -1 0 0.000 1 0.0000 5040 5400 30 30 5040 5400 5070 5400\n2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 9\n\t 3330 7335 4680 7020 5674 8593 6120 6975 7515 7020 6570 5535\n\t 5040 5400 3555 5895 3330 7335\n2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3\n\t 4680 7020 5265 5760 6165 6975\n2 1 0 1 0 7 50 -1 -1 0.000 0 0 -1 0 0 3\n\t 6615 5535 5265 5760 3555 5895\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 3330 7335 4680 7020 5670 8595\n\t 0.000 1.000 0.000\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 5670 8595 6120 6975 7515 7020\n\t 0.000 1.000 0.000\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 3330 7335 3555 5850 5040 5400\n\t 0.000 1.000 0.000\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 5044 5400 6570 5535 7515 7020\n\t 0.000 1.000 0.000\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 6252 7275 5265 5760 3804 5973\n\t 0.000 1.000 0.000\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 5895 7875 4905 6525 3491 6614\n\t 0.000 1.000 0.000\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 6840 7065 5895 5670 4500 5580\n\t 0.000 1.000 0.000\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 5130 7830 5670 6345 6885 6165\n\t 0.000 1.000 0.000\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 5400 8190 5985 6705 7200 6570\n\t 0.000 1.000 0.000\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 4860 7515 5517 6087 6637 5879\n\t 0.000 1.000 0.000\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 4320 7245 4995 5760 5788 5509\n\t 0.000 1.000 0.000\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 3600 7290 3945 5895 5265 5400\n\t 0.000 1.000 0.000\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 6054 7541 5040 6210 3600 6300\n\t 0.000 1.000 0.000\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 6481 7134 5580 5715 4221 5712\n\t 0.000 1.000 0.000\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 7200 7020 6210 5580 4788 5478\n\t 0.000 1.000 0.000\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 4635 7335 5265 5715 6330 5676\n\t 0.000 1.000 0.000\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 3915 7245 4476 5817 5549 5447\n\t 0.000 1.000 0.000\n3 0 0 1 0 7 50 -1 -1 0.000 0 0 0 3\n\t 5760 8235 4815 6750 3403 6957\n\t 0.000 1.000 0.000\n"
  },
  {
    "path": "doc/manual/surf1.ps",
    "content": "%!PS-Adobe-2.0 EPSF-2.0\n%%Creator: dvips(k) 5.92b Copyright 2002 Radical Eye Software\n%%Title: f2pspost.dvi\n%%BoundingBox: 133 294 406 503\n%%EndComments\n%DVIPSWebPage: (www.radicaleye.com)\n%DVIPSCommandLine: dvips -E -o f2pspost.ps f2pspost\n%DVIPSParameters: dpi=600, compressed\n%DVIPSSource:  TeX output 2005.02.08:1652\n%%BeginProcSet: texc.pro\n%!\n/TeXDict 300 dict def TeXDict begin/N{def}def/B{bind def}N/S{exch}N/X{S\nN}B/A{dup}B/TR{translate}N/isls false N/vsize 11 72 mul N/hsize 8.5 72\nmul N/landplus90{false}def/@rigin{isls{[0 landplus90{1 -1}{-1 1}ifelse 0\n0 0]concat}if 72 Resolution div 72 VResolution div neg scale isls{\nlandplus90{VResolution 72 div vsize mul 0 exch}{Resolution -72 div hsize\nmul 0}ifelse TR}if Resolution VResolution vsize -72 div 1 add mul TR[\nmatrix currentmatrix{A A round sub abs 0.00001 lt{round}if}forall round\nexch round exch]setmatrix}N/@landscape{/isls true N}B/@manualfeed{\nstatusdict/manualfeed true put}B/@copies{/#copies X}B/FMat[1 0 0 -1 0 0]\nN/FBB[0 0 0 0]N/nn 0 N/IEn 0 N/ctr 0 N/df-tail{/nn 8 dict N nn begin\n/FontType 3 N/FontMatrix fntrx N/FontBBox FBB N string/base X array\n/BitMaps X/BuildChar{CharBuilder}N/Encoding IEn N end A{/foo setfont}2\narray copy cvx N load 0 nn put/ctr 0 N[}B/sf 0 N/df{/sf 1 N/fntrx FMat N\ndf-tail}B/dfs{div/sf X/fntrx[sf 0 0 sf neg 0 0]N df-tail}B/E{pop nn A\ndefinefont setfont}B/Cw{Cd A length 5 sub get}B/Ch{Cd A length 4 sub get\n}B/Cx{128 Cd A length 3 sub get sub}B/Cy{Cd A length 2 sub get 127 sub}\nB/Cdx{Cd A length 1 sub get}B/Ci{Cd A type/stringtype ne{ctr get/ctr ctr\n1 add N}if}B/id 0 N/rw 0 N/rc 0 N/gp 0 N/cp 0 N/G 0 N/CharBuilder{save 3\n1 roll S A/base get 2 index get S/BitMaps get S get/Cd X pop/ctr 0 N Cdx\n0 Cx Cy Ch sub Cx Cw add Cy setcachedevice Cw Ch true[1 0 0 -1 -.1 Cx\nsub Cy .1 sub]/id Ci N/rw Cw 7 add 8 idiv string N/rc 0 N/gp 0 N/cp 0 N{\nrc 0 ne{rc 1 sub/rc X rw}{G}ifelse}imagemask restore}B/G{{id gp get/gp\ngp 1 add N A 18 mod S 18 idiv pl S get exec}loop}B/adv{cp add/cp X}B\n/chg{rw cp id gp 4 index getinterval putinterval A gp add/gp X adv}B/nd{\n/cp 0 N rw exit}B/lsh{rw cp 2 copy get A 0 eq{pop 1}{A 255 eq{pop 254}{\nA A add 255 and S 1 and or}ifelse}ifelse put 1 adv}B/rsh{rw cp 2 copy\nget A 0 eq{pop 128}{A 255 eq{pop 127}{A 2 idiv S 128 and or}ifelse}\nifelse put 1 adv}B/clr{rw cp 2 index string putinterval adv}B/set{rw cp\nfillstr 0 4 index getinterval putinterval adv}B/fillstr 18 string 0 1 17\n{2 copy 255 put pop}for N/pl[{adv 1 chg}{adv 1 chg nd}{1 add chg}{1 add\nchg nd}{adv lsh}{adv lsh nd}{adv rsh}{adv rsh nd}{1 add adv}{/rc X nd}{\n1 add set}{1 add clr}{adv 2 chg}{adv 2 chg nd}{pop nd}]A{bind pop}\nforall N/D{/cc X A type/stringtype ne{]}if nn/base get cc ctr put nn\n/BitMaps get S ctr S sf 1 ne{A A length 1 sub A 2 index S get sf div put\n}if put/ctr ctr 1 add N}B/I{cc 1 add D}B/bop{userdict/bop-hook known{\nbop-hook}if/SI save N @rigin 0 0 moveto/V matrix currentmatrix A 1 get A\nmul exch 0 get A mul add .99 lt{/QV}{/RV}ifelse load def pop pop}N/eop{\nSI restore userdict/eop-hook known{eop-hook}if showpage}N/@start{\nuserdict/start-hook known{start-hook}if pop/VResolution X/Resolution X\n1000 div/DVImag X/IEn 256 array N 2 string 0 1 255{IEn S A 360 add 36 4\nindex cvrs cvn put}for pop 65781.76 div/vsize X 65781.76 div/hsize X}N\n/p{show}N/RMat[1 0 0 -1 0 0]N/BDot 260 string N/Rx 0 N/Ry 0 N/V{}B/RV/v{\n/Ry X/Rx X V}B statusdict begin/product where{pop false[(Display)(NeXT)\n(LaserWriter 16/600)]{A length product length le{A length product exch 0\nexch getinterval eq{pop true exit}if}{pop}ifelse}forall}{false}ifelse\nend{{gsave TR -.1 .1 TR 1 1 scale Rx Ry false RMat{BDot}imagemask\ngrestore}}{{gsave TR -.1 .1 TR Rx Ry scale 1 1 false RMat{BDot}\nimagemask grestore}}ifelse B/QV{gsave newpath transform round exch round\nexch itransform moveto Rx 0 rlineto 0 Ry neg rlineto Rx neg 0 rlineto\nfill grestore}B/a{moveto}B/delta 0 N/tail{A/delta X 0 rmoveto}B/M{S p\ndelta add tail}B/b{S p tail}B/c{-4 M}B/d{-3 M}B/e{-2 M}B/f{-1 M}B/g{0 M}\nB/h{1 M}B/i{2 M}B/j{3 M}B/k{4 M}B/w{0 rmoveto}B/l{p -4 w}B/m{p -3 w}B/n{\np -2 w}B/o{p -1 w}B/q{p 1 w}B/r{p 2 w}B/s{p 3 w}B/t{p 4 w}B/x{0 S\nrmoveto}B/y{3 2 roll p a}B/bos{/SS save N}B/eos{SS restore}B end\n\n%%EndProcSet\n%%BeginProcSet: special.pro\n%!\nTeXDict begin/SDict 200 dict N SDict begin/@SpecialDefaults{/hs 612 N\n/vs 792 N/ho 0 N/vo 0 N/hsc 1 N/vsc 1 N/ang 0 N/CLIP 0 N/rwiSeen false N\n/rhiSeen false N/letter{}N/note{}N/a4{}N/legal{}N}B/@scaleunit 100 N\n/@hscale{@scaleunit div/hsc X}B/@vscale{@scaleunit div/vsc X}B/@hsize{\n/hs X/CLIP 1 N}B/@vsize{/vs X/CLIP 1 N}B/@clip{/CLIP 2 N}B/@hoffset{/ho\nX}B/@voffset{/vo X}B/@angle{/ang X}B/@rwi{10 div/rwi X/rwiSeen true N}B\n/@rhi{10 div/rhi X/rhiSeen true N}B/@llx{/llx X}B/@lly{/lly X}B/@urx{\n/urx X}B/@ury{/ury X}B/magscale true def end/@MacSetUp{userdict/md known\n{userdict/md get type/dicttype eq{userdict begin md length 10 add md\nmaxlength ge{/md md dup length 20 add dict copy def}if end md begin\n/letter{}N/note{}N/legal{}N/od{txpose 1 0 mtx defaultmatrix dtransform S\natan/pa X newpath clippath mark{transform{itransform moveto}}{transform{\nitransform lineto}}{6 -2 roll transform 6 -2 roll transform 6 -2 roll\ntransform{itransform 6 2 roll itransform 6 2 roll itransform 6 2 roll\ncurveto}}{{closepath}}pathforall newpath counttomark array astore/gc xdf\npop ct 39 0 put 10 fz 0 fs 2 F/|______Courier fnt invertflag{PaintBlack}\nif}N/txpose{pxs pys scale ppr aload pop por{noflips{pop S neg S TR pop 1\n-1 scale}if xflip yflip and{pop S neg S TR 180 rotate 1 -1 scale ppr 3\nget ppr 1 get neg sub neg ppr 2 get ppr 0 get neg sub neg TR}if xflip\nyflip not and{pop S neg S TR pop 180 rotate ppr 3 get ppr 1 get neg sub\nneg 0 TR}if yflip xflip not and{ppr 1 get neg ppr 0 get neg TR}if}{\nnoflips{TR pop pop 270 rotate 1 -1 scale}if xflip yflip and{TR pop pop\n90 rotate 1 -1 scale ppr 3 get ppr 1 get neg sub neg ppr 2 get ppr 0 get\nneg sub neg TR}if xflip yflip not and{TR pop pop 90 rotate ppr 3 get ppr\n1 get neg sub neg 0 TR}if yflip xflip not and{TR pop pop 270 rotate ppr\n2 get ppr 0 get neg sub neg 0 S TR}if}ifelse scaleby96{ppr aload pop 4\n-1 roll add 2 div 3 1 roll add 2 div 2 copy TR .96 dup scale neg S neg S\nTR}if}N/cp{pop pop showpage pm restore}N end}if}if}N/normalscale{\nResolution 72 div VResolution 72 div neg scale magscale{DVImag dup scale\n}if 0 setgray}N/psfts{S 65781.76 div N}N/startTexFig{/psf$SavedState\nsave N userdict maxlength dict begin/magscale true def normalscale\ncurrentpoint TR/psf$ury psfts/psf$urx psfts/psf$lly psfts/psf$llx psfts\n/psf$y psfts/psf$x psfts currentpoint/psf$cy X/psf$cx X/psf$sx psf$x\npsf$urx psf$llx sub div N/psf$sy psf$y psf$ury psf$lly sub div N psf$sx\npsf$sy scale psf$cx psf$sx div psf$llx sub psf$cy psf$sy div psf$ury sub\nTR/showpage{}N/erasepage{}N/setpagedevice{pop}N/copypage{}N/p 3 def\n@MacSetUp}N/doclip{psf$llx psf$lly psf$urx psf$ury currentpoint 6 2 roll\nnewpath 4 copy 4 2 roll moveto 6 -1 roll S lineto S lineto S lineto\nclosepath clip newpath moveto}N/endTexFig{end psf$SavedState restore}N\n/@beginspecial{SDict begin/SpecialSave save N gsave normalscale\ncurrentpoint TR @SpecialDefaults count/ocount X/dcount countdictstack N}\nN/@setspecial{CLIP 1 eq{newpath 0 0 moveto hs 0 rlineto 0 vs rlineto hs\nneg 0 rlineto closepath clip}if ho vo TR hsc vsc scale ang rotate\nrwiSeen{rwi urx llx sub div rhiSeen{rhi ury lly sub div}{dup}ifelse\nscale llx neg lly neg TR}{rhiSeen{rhi ury lly sub div dup scale llx neg\nlly neg TR}if}ifelse CLIP 2 eq{newpath llx lly moveto urx lly lineto urx\nury lineto llx ury lineto closepath clip}if/showpage{}N/erasepage{}N\n/setpagedevice{pop}N/copypage{}N newpath}N/@endspecial{count ocount sub{\npop}repeat countdictstack dcount sub{end}repeat grestore SpecialSave\nrestore end}N/@defspecial{SDict begin}N/@fedspecial{end}B/li{lineto}B\n/rl{rlineto}B/rc{rcurveto}B/np{/SaveX currentpoint/SaveY X N 1\nsetlinecap newpath}N/st{stroke SaveX SaveY moveto}N/fil{fill SaveX SaveY\nmoveto}N/ellipse{/endangle X/startangle X/yrad X/xrad X/savematrix\nmatrix currentmatrix N TR xrad yrad scale 0 0 1 startangle endangle arc\nsavematrix setmatrix}N end\n\n%%EndProcSet\n%%BeginProcSet: color.pro\n%!\nTeXDict begin/setcmykcolor where{pop}{/setcmykcolor{dup 10 eq{pop\nsetrgbcolor}{1 sub 4 1 roll 3{3 index add neg dup 0 lt{pop 0}if 3 1 roll\n}repeat setrgbcolor pop}ifelse}B}ifelse/TeXcolorcmyk{setcmykcolor}def\n/TeXcolorrgb{setrgbcolor}def/TeXcolorgrey{setgray}def/TeXcolorgray{\nsetgray}def/TeXcolorhsb{sethsbcolor}def/currentcmykcolor where{pop}{\n/currentcmykcolor{currentrgbcolor 10}B}ifelse/DC{exch dup userdict exch\nknown{pop pop}{X}ifelse}B/GreenYellow{0.15 0 0.69 0 setcmykcolor}DC\n/Yellow{0 0 1 0 setcmykcolor}DC/Goldenrod{0 0.10 0.84 0 setcmykcolor}DC\n/Dandelion{0 0.29 0.84 0 setcmykcolor}DC/Apricot{0 0.32 0.52 0\nsetcmykcolor}DC/Peach{0 0.50 0.70 0 setcmykcolor}DC/Melon{0 0.46 0.50 0\nsetcmykcolor}DC/YellowOrange{0 0.42 1 0 setcmykcolor}DC/Orange{0 0.61\n0.87 0 setcmykcolor}DC/BurntOrange{0 0.51 1 0 setcmykcolor}DC\n/Bittersweet{0 0.75 1 0.24 setcmykcolor}DC/RedOrange{0 0.77 0.87 0\nsetcmykcolor}DC/Mahogany{0 0.85 0.87 0.35 setcmykcolor}DC/Maroon{0 0.87\n0.68 0.32 setcmykcolor}DC/BrickRed{0 0.89 0.94 0.28 setcmykcolor}DC/Red{\n0 1 1 0 setcmykcolor}DC/OrangeRed{0 1 0.50 0 setcmykcolor}DC/RubineRed{\n0 1 0.13 0 setcmykcolor}DC/WildStrawberry{0 0.96 0.39 0 setcmykcolor}DC\n/Salmon{0 0.53 0.38 0 setcmykcolor}DC/CarnationPink{0 0.63 0 0\nsetcmykcolor}DC/Magenta{0 1 0 0 setcmykcolor}DC/VioletRed{0 0.81 0 0\nsetcmykcolor}DC/Rhodamine{0 0.82 0 0 setcmykcolor}DC/Mulberry{0.34 0.90\n0 0.02 setcmykcolor}DC/RedViolet{0.07 0.90 0 0.34 setcmykcolor}DC\n/Fuchsia{0.47 0.91 0 0.08 setcmykcolor}DC/Lavender{0 0.48 0 0\nsetcmykcolor}DC/Thistle{0.12 0.59 0 0 setcmykcolor}DC/Orchid{0.32 0.64 0\n0 setcmykcolor}DC/DarkOrchid{0.40 0.80 0.20 0 setcmykcolor}DC/Purple{\n0.45 0.86 0 0 setcmykcolor}DC/Plum{0.50 1 0 0 setcmykcolor}DC/Violet{\n0.79 0.88 0 0 setcmykcolor}DC/RoyalPurple{0.75 0.90 0 0 setcmykcolor}DC\n/BlueViolet{0.86 0.91 0 0.04 setcmykcolor}DC/Periwinkle{0.57 0.55 0 0\nsetcmykcolor}DC/CadetBlue{0.62 0.57 0.23 0 setcmykcolor}DC\n/CornflowerBlue{0.65 0.13 0 0 setcmykcolor}DC/MidnightBlue{0.98 0.13 0\n0.43 setcmykcolor}DC/NavyBlue{0.94 0.54 0 0 setcmykcolor}DC/RoyalBlue{1\n0.50 0 0 setcmykcolor}DC/Blue{1 1 0 0 setcmykcolor}DC/Cerulean{0.94 0.11\n0 0 setcmykcolor}DC/Cyan{1 0 0 0 setcmykcolor}DC/ProcessBlue{0.96 0 0 0\nsetcmykcolor}DC/SkyBlue{0.62 0 0.12 0 setcmykcolor}DC/Turquoise{0.85 0\n0.20 0 setcmykcolor}DC/TealBlue{0.86 0 0.34 0.02 setcmykcolor}DC\n/Aquamarine{0.82 0 0.30 0 setcmykcolor}DC/BlueGreen{0.85 0 0.33 0\nsetcmykcolor}DC/Emerald{1 0 0.50 0 setcmykcolor}DC/JungleGreen{0.99 0\n0.52 0 setcmykcolor}DC/SeaGreen{0.69 0 0.50 0 setcmykcolor}DC/Green{1 0\n1 0 setcmykcolor}DC/ForestGreen{0.91 0 0.88 0.12 setcmykcolor}DC\n/PineGreen{0.92 0 0.59 0.25 setcmykcolor}DC/LimeGreen{0.50 0 1 0\nsetcmykcolor}DC/YellowGreen{0.44 0 0.74 0 setcmykcolor}DC/SpringGreen{\n0.26 0 0.76 0 setcmykcolor}DC/OliveGreen{0.64 0 0.95 0.40 setcmykcolor}\nDC/RawSienna{0 0.72 1 0.45 setcmykcolor}DC/Sepia{0 0.83 1 0.70\nsetcmykcolor}DC/Brown{0 0.81 1 0.60 setcmykcolor}DC/Tan{0.14 0.42 0.56 0\nsetcmykcolor}DC/Gray{0 0 0 0.50 setcmykcolor}DC/Black{0 0 0 1\nsetcmykcolor}DC/White{0 0 0 0 setcmykcolor}DC end\n\n%%EndProcSet\nTeXDict begin 40258437 52099154 1000 600 600 (f2pspost.dvi)\n@start end\n%%EndProlog\n%%BeginSetup\n%%Feature: *Resolution 600dpi\nTeXDict begin\n end\n%%EndSetup\nTeXDict begin 1 0 bop Black Black Black 515 3540 a @beginspecial\n0 @llx 0 @lly 271 @urx 207 @ury 2710 @rwi @setspecial\n%%BeginDocument: pre.ps\n%!PS-Adobe-2.0 EPSF-2.0\n%%Title: pre.fig\n%%Creator: fig2dev Version 3.2 Patchlevel 4\n%%CreationDate: Tue Feb  8 16:52:13 2005\n%%For: oan@gollum (Odd Andersen)\n%%BoundingBox: 0 0 271 207\n%%Magnification: 1.0000\n%%EndComments\n/$F2psDict 200 dict def\n$F2psDict begin\n$F2psDict /mtrx matrix put\n/col-1 {0 setgray} bind def\n/col0 {0.000 0.000 0.000 srgb} bind def\n/col1 {0.000 0.000 1.000 srgb} bind def\n/col2 {0.000 1.000 0.000 srgb} bind def\n/col3 {0.000 1.000 1.000 srgb} bind def\n/col4 {1.000 0.000 0.000 srgb} bind def\n/col5 {1.000 0.000 1.000 srgb} bind def\n/col6 {1.000 1.000 0.000 srgb} bind def\n/col7 {1.000 1.000 1.000 srgb} bind def\n/col8 {0.000 0.000 0.560 srgb} bind def\n/col9 {0.000 0.000 0.690 srgb} bind def\n/col10 {0.000 0.000 0.820 srgb} bind def\n/col11 {0.530 0.810 1.000 srgb} bind def\n/col12 {0.000 0.560 0.000 srgb} bind def\n/col13 {0.000 0.690 0.000 srgb} bind def\n/col14 {0.000 0.820 0.000 srgb} bind def\n/col15 {0.000 0.560 0.560 srgb} bind def\n/col16 {0.000 0.690 0.690 srgb} bind def\n/col17 {0.000 0.820 0.820 srgb} bind def\n/col18 {0.560 0.000 0.000 srgb} bind def\n/col19 {0.690 0.000 0.000 srgb} bind def\n/col20 {0.820 0.000 0.000 srgb} bind def\n/col21 {0.560 0.000 0.560 srgb} bind def\n/col22 {0.690 0.000 0.690 srgb} bind def\n/col23 {0.820 0.000 0.820 srgb} bind def\n/col24 {0.500 0.190 0.000 srgb} bind def\n/col25 {0.630 0.250 0.000 srgb} bind def\n/col26 {0.750 0.380 0.000 srgb} bind def\n/col27 {1.000 0.500 0.500 srgb} bind def\n/col28 {1.000 0.630 0.630 srgb} bind def\n/col29 {1.000 0.750 0.750 srgb} bind def\n/col30 {1.000 0.880 0.880 srgb} bind def\n/col31 {1.000 0.840 0.000 srgb} bind def\n\nend\nsave\nnewpath 0 207 moveto 0 0 lineto 271 0 lineto 271 207 lineto closepath clip newpath\n-206.4 544.8 translate\n1 -1 scale\n\n/cp {closepath} bind def\n/ef {eofill} bind def\n/gr {grestore} bind def\n/gs {gsave} bind def\n/sa {save} bind def\n/rs {restore} bind def\n/l {lineto} bind def\n/m {moveto} bind def\n/rm {rmoveto} bind def\n/n {newpath} bind def\n/s {stroke} bind def\n/sh {show} bind def\n/slc {setlinecap} bind def\n/slj {setlinejoin} bind def\n/slw {setlinewidth} bind def\n/srgb {setrgbcolor} bind def\n/rot {rotate} bind def\n/sc {scale} bind def\n/sd {setdash} bind def\n/ff {findfont} bind def\n/sf {setfont} bind def\n/scf {scalefont} bind def\n/sw {stringwidth} bind def\n/tr {translate} bind def\n/tnt {dup dup currentrgbcolor\n  4 -2 roll dup 1 exch sub 3 -1 roll mul add\n  4 -2 roll dup 1 exch sub 3 -1 roll mul add\n  4 -2 roll dup 1 exch sub 3 -1 roll mul add srgb}\n  bind def\n/shd {dup dup currentrgbcolor 4 -2 roll mul 4 -2 roll mul\n  4 -2 roll mul srgb} bind def\n /DrawEllipse {\n\t/endangle exch def\n\t/startangle exch def\n\t/yrad exch def\n\t/xrad exch def\n\t/y exch def\n\t/x exch def\n\t/savematrix mtrx currentmatrix def\n\tx y tr xrad yrad sc 0 0 1 startangle endangle arc\n\tclosepath\n\tsavematrix setmatrix\n\t} def\n\n/$F2psBegin {$F2psDict begin /$F2psEnteredState save def} def\n/$F2psEnd {$F2psEnteredState restore end} def\n\n$F2psBegin\n10 setmiterlimit\n0 slj 0 slc\n 0.06299 0.06299 sc\n%\n% Fig objects follow\n%\n% \n% here starts figure with depth 50\n% Ellipse\n7.500 slw\nn 3330 7335 45 45 0 360 DrawEllipse gs col7 0.00 shd ef gr gs col0 s gr\n\n% Ellipse\nn 5670 8595 45 45 0 360 DrawEllipse gs col7 0.00 shd ef gr gs col0 s gr\n\n% Ellipse\nn 6165 6975 45 45 0 360 DrawEllipse gs col7 0.00 shd ef gr gs col0 s gr\n\n% Ellipse\nn 7515 7020 45 45 0 360 DrawEllipse gs col7 0.00 shd ef gr gs col0 s gr\n\n% Ellipse\nn 6570 5535 45 45 0 360 DrawEllipse gs col7 0.00 shd ef gr gs col0 s gr\n\n% Ellipse\nn 3555 5895 45 45 0 360 DrawEllipse gs col7 0.00 shd ef gr gs col0 s gr\n\n% Ellipse\nn 5265 5760 45 45 0 360 DrawEllipse gs col7 0.00 shd ef gr gs col0 s gr\n\n% Ellipse\nn 4680 7020 45 45 0 360 DrawEllipse gs col7 0.00 shd ef gr gs col0 s gr\n\n% Ellipse\nn 5040 5400 30 30 0 360 DrawEllipse gs col7 0.00 shd ef gr gs col0 s gr\n\n% Polyline\nn 3330 7335 m 4680 7020 l 5674 8593 l 6120 6975 l 7515 7020 l 6570 5535 l\n 5040 5400 l 3555 5895 l\n 3330 7335 l  cp gs col0 s gr \n% Polyline\nn 4680 7020 m 5265 5760 l\n 6165 6975 l gs col0 s gr \n% Polyline\nn 6615 5535 m 5265 5760 l\n 3555 5895 l gs col0 s gr \n% Polyline\n2 slj\nn 3330 7335 m 3332 7335 l 3337 7334 l 3346 7332 l 3360 7329 l 3380 7326 l\n 3406 7321 l 3438 7316 l 3477 7310 l 3520 7303 l 3569 7295 l\n 3621 7287 l 3677 7280 l 3734 7272 l 3792 7265 l 3850 7258 l\n 3908 7252 l 3965 7247 l 4020 7243 l 4073 7240 l 4123 7238 l\n 4172 7237 l 4218 7238 l 4263 7240 l 4305 7243 l 4345 7247 l\n 4383 7253 l 4420 7260 l 4456 7269 l 4490 7279 l 4524 7291 l\n 4556 7304 l 4588 7319 l 4620 7335 l 4647 7350 l 4673 7366 l\n 4700 7384 l 4726 7402 l 4753 7423 l 4780 7444 l 4807 7468 l\n 4834 7493 l 4862 7520 l 4891 7550 l 4921 7581 l 4951 7614 l\n 4982 7650 l 5015 7688 l 5048 7729 l 5082 7771 l 5117 7816 l\n 5153 7863 l 5190 7912 l 5228 7963 l 5266 8015 l 5305 8068 l\n 5343 8121 l 5381 8174 l 5418 8227 l 5454 8278 l 5487 8326 l\n 5519 8372 l 5548 8415 l 5574 8453 l 5597 8487 l 5617 8516 l\n 5633 8540 l 5646 8559 l 5656 8573 l 5662 8584 l 5667 8590 l\n 5669 8593 l\n 5670 8595 l gs col0 s gr \n% Polyline\nn 5670 8595 m 5671 8593 l 5672 8589 l 5674 8581 l 5678 8569 l 5683 8552 l\n 5691 8529 l 5700 8501 l 5711 8467 l 5723 8428 l 5738 8383 l\n 5754 8334 l 5771 8282 l 5790 8227 l 5810 8169 l 5830 8111 l\n 5851 8052 l 5872 7994 l 5893 7937 l 5914 7881 l 5935 7827 l\n 5956 7775 l 5977 7725 l 5997 7678 l 6017 7634 l 6037 7592 l\n 6056 7552 l 6076 7515 l 6095 7481 l 6114 7448 l 6134 7418 l\n 6153 7390 l 6173 7363 l 6193 7338 l 6213 7315 l 6234 7293 l\n 6256 7272 l 6278 7253 l 6303 7232 l 6329 7213 l 6356 7195 l\n 6384 7178 l 6414 7162 l 6445 7148 l 6478 7135 l 6513 7123 l\n 6551 7111 l 6590 7101 l 6632 7091 l 6676 7082 l 6723 7074 l\n 6772 7067 l 6824 7060 l 6878 7054 l 6934 7048 l 6991 7043 l\n 7050 7039 l 7108 7035 l 7165 7032 l 7220 7029 l 7273 7027 l\n 7322 7025 l 7366 7023 l 7405 7022 l 7438 7021 l 7464 7021 l\n 7484 7020 l 7499 7020 l 7508 7020 l 7513 7020 l\n 7515 7020 l gs col0 s gr \n% Polyline\nn 3330 7335 m 3330 7333 l 3331 7329 l 3333 7320 l 3335 7307 l 3339 7289 l\n 3343 7264 l 3349 7234 l 3357 7198 l 3365 7157 l 3375 7110 l\n 3385 7060 l 3397 7006 l 3409 6949 l 3422 6892 l 3436 6833 l\n 3450 6775 l 3464 6718 l 3479 6661 l 3493 6607 l 3508 6555 l\n 3523 6505 l 3538 6457 l 3553 6412 l 3568 6369 l 3584 6329 l\n 3600 6291 l 3616 6255 l 3632 6220 l 3649 6188 l 3667 6157 l\n 3685 6128 l 3704 6100 l 3723 6073 l 3744 6048 l 3765 6023 l\n 3787 5998 l 3810 5975 l 3835 5952 l 3860 5929 l 3887 5907 l\n 3916 5886 l 3947 5865 l 3979 5844 l 4013 5823 l 4050 5801 l\n 4089 5780 l 4130 5759 l 4174 5737 l 4220 5716 l 4269 5694 l\n 4321 5671 l 4374 5649 l 4429 5626 l 4486 5603 l 4543 5581 l\n 4601 5558 l 4658 5537 l 4713 5516 l 4767 5496 l 4817 5478 l\n 4863 5462 l 4904 5447 l 4940 5434 l 4970 5424 l 4994 5416 l\n 5012 5409 l 5025 5405 l 5034 5402 l 5038 5401 l\n 5040 5400 l gs col0 s gr \n% Polyline\nn 5044 5400 m 5046 5400 l 5050 5401 l 5057 5402 l 5069 5403 l 5085 5405 l\n 5107 5408 l 5135 5412 l 5168 5416 l 5207 5421 l 5250 5427 l\n 5298 5434 l 5349 5441 l 5404 5450 l 5460 5458 l 5518 5468 l\n 5576 5477 l 5635 5487 l 5692 5498 l 5749 5508 l 5804 5519 l\n 5857 5530 l 5909 5542 l 5958 5553 l 6006 5565 l 6051 5577 l\n 6094 5589 l 6135 5602 l 6175 5615 l 6212 5629 l 6249 5643 l\n 6284 5657 l 6317 5673 l 6350 5688 l 6382 5705 l 6413 5723 l\n 6443 5741 l 6473 5760 l 6501 5779 l 6529 5799 l 6557 5819 l\n 6584 5841 l 6612 5864 l 6640 5888 l 6667 5914 l 6695 5941 l\n 6724 5970 l 6753 6000 l 6783 6033 l 6813 6067 l 6844 6103 l\n 6876 6141 l 6909 6182 l 6943 6224 l 6978 6268 l 7013 6314 l\n 7050 6362 l 7086 6412 l 7124 6462 l 7161 6513 l 7198 6565 l\n 7235 6616 l 7271 6667 l 7306 6716 l 7339 6763 l 7369 6807 l\n 7397 6848 l 7423 6884 l 7445 6917 l 7464 6945 l 7480 6967 l\n 7492 6986 l 7501 6999 l 7508 7009 l 7512 7015 l 7514 7019 l\n\n 7515 7020 l gs col0 s gr \n% Polyline\nn 6252 7275 m 6251 7274 l 6249 7270 l 6244 7264 l 6238 7254 l 6228 7240 l\n 6215 7222 l 6199 7199 l 6179 7171 l 6156 7138 l 6130 7101 l\n 6101 7060 l 6069 7016 l 6035 6969 l 5999 6919 l 5962 6869 l\n 5924 6817 l 5885 6766 l 5847 6715 l 5808 6664 l 5770 6615 l\n 5733 6568 l 5696 6522 l 5661 6479 l 5626 6437 l 5592 6398 l\n 5559 6361 l 5528 6326 l 5497 6293 l 5467 6262 l 5437 6234 l\n 5408 6207 l 5380 6182 l 5352 6158 l 5324 6137 l 5297 6116 l\n 5269 6098 l 5242 6080 l 5214 6063 l 5186 6048 l 5155 6032 l\n 5123 6017 l 5090 6004 l 5057 5991 l 5023 5980 l 4988 5970 l\n 4952 5962 l 4914 5954 l 4874 5947 l 4833 5942 l 4790 5937 l\n 4744 5934 l 4696 5931 l 4647 5929 l 4595 5928 l 4541 5928 l\n 4485 5928 l 4427 5930 l 4368 5932 l 4309 5934 l 4250 5937 l\n 4191 5941 l 4135 5945 l 4080 5949 l 4029 5953 l 3983 5956 l\n 3941 5960 l 3905 5963 l 3874 5966 l 3850 5968 l 3832 5970 l\n 3819 5971 l 3810 5972 l 3806 5973 l\n 3804 5973 l gs col0 s gr \n% Polyline\nn 5895 7875 m 5894 7873 l 5891 7870 l 5886 7864 l 5878 7854 l 5867 7839 l\n 5853 7820 l 5834 7797 l 5812 7769 l 5786 7736 l 5756 7699 l\n 5724 7658 l 5689 7615 l 5652 7569 l 5613 7521 l 5573 7473 l\n 5532 7424 l 5492 7376 l 5451 7328 l 5411 7282 l 5372 7237 l\n 5334 7194 l 5297 7153 l 5261 7114 l 5226 7077 l 5192 7042 l\n 5159 7010 l 5127 6979 l 5096 6951 l 5065 6924 l 5036 6899 l\n 5006 6876 l 4978 6854 l 4949 6834 l 4920 6815 l 4892 6797 l\n 4863 6781 l 4834 6765 l 4804 6749 l 4772 6735 l 4741 6721 l\n 4708 6709 l 4675 6697 l 4641 6686 l 4605 6677 l 4568 6668 l\n 4530 6660 l 4489 6652 l 4447 6646 l 4403 6640 l 4357 6634 l\n 4308 6630 l 4258 6626 l 4205 6622 l 4151 6619 l 4095 6617 l\n 4038 6615 l 3981 6613 l 3923 6612 l 3866 6611 l 3811 6611 l\n 3759 6611 l 3709 6611 l 3664 6611 l 3624 6611 l 3589 6612 l\n 3559 6612 l 3536 6613 l 3518 6613 l 3505 6614 l 3497 6614 l\n 3493 6614 l\n 3491 6614 l gs col0 s gr \n% Polyline\nn 6840 7065 m 6839 7063 l 6836 7060 l 6832 7053 l 6824 7043 l 6813 7028 l\n 6799 7008 l 6782 6984 l 6760 6954 l 6735 6920 l 6707 6882 l\n 6676 6839 l 6643 6794 l 6607 6746 l 6570 6697 l 6532 6646 l\n 6493 6595 l 6454 6544 l 6415 6495 l 6377 6446 l 6339 6399 l\n 6303 6354 l 6267 6310 l 6232 6269 l 6198 6230 l 6166 6193 l\n 6134 6158 l 6103 6126 l 6073 6095 l 6044 6066 l 6015 6039 l\n 5987 6013 l 5959 5989 l 5931 5967 l 5904 5945 l 5876 5925 l\n 5848 5906 l 5820 5888 l 5790 5869 l 5760 5851 l 5729 5835 l\n 5697 5819 l 5665 5804 l 5631 5790 l 5596 5776 l 5560 5763 l\n 5522 5751 l 5483 5739 l 5441 5727 l 5398 5716 l 5352 5706 l\n 5305 5695 l 5255 5685 l 5203 5675 l 5150 5666 l 5095 5657 l\n 5039 5648 l 4982 5639 l 4926 5631 l 4870 5624 l 4816 5616 l\n 4764 5610 l 4715 5604 l 4671 5599 l 4631 5594 l 4596 5590 l\n 4567 5587 l 4544 5584 l 4527 5583 l 4514 5581 l 4506 5581 l\n 4502 5580 l\n 4500 5580 l gs col0 s gr \n% Polyline\nn 5130 7830 m 5131 7828 l 5133 7824 l 5136 7815 l 5141 7802 l 5148 7784 l\n 5158 7760 l 5170 7730 l 5184 7694 l 5201 7653 l 5220 7607 l\n 5240 7557 l 5262 7504 l 5286 7448 l 5310 7391 l 5335 7334 l\n 5360 7277 l 5385 7220 l 5410 7165 l 5434 7112 l 5458 7061 l\n 5482 7013 l 5505 6967 l 5527 6923 l 5550 6882 l 5571 6843 l\n 5592 6807 l 5613 6773 l 5634 6741 l 5655 6711 l 5676 6683 l\n 5696 6656 l 5717 6631 l 5739 6607 l 5760 6584 l 5783 6563 l\n 5806 6541 l 5831 6520 l 5856 6500 l 5883 6481 l 5910 6462 l\n 5939 6445 l 5969 6428 l 6000 6412 l 6034 6396 l 6069 6381 l\n 6107 6366 l 6146 6351 l 6188 6337 l 6232 6323 l 6278 6308 l\n 6326 6295 l 6375 6281 l 6425 6268 l 6477 6255 l 6528 6242 l\n 6578 6230 l 6627 6219 l 6673 6209 l 6716 6199 l 6755 6191 l\n 6789 6184 l 6817 6178 l 6840 6174 l 6858 6170 l 6871 6168 l\n 6879 6166 l 6883 6165 l\n 6885 6165 l gs col0 s gr \n% Polyline\nn 5400 8190 m 5401 8188 l 5403 8184 l 5406 8175 l 5412 8162 l 5420 8144 l\n 5430 8120 l 5443 8090 l 5458 8054 l 5476 8013 l 5496 7967 l\n 5518 7918 l 5542 7864 l 5567 7809 l 5593 7752 l 5620 7695 l\n 5646 7638 l 5673 7582 l 5700 7527 l 5726 7474 l 5751 7423 l\n 5776 7375 l 5801 7329 l 5825 7286 l 5848 7245 l 5871 7206 l\n 5893 7170 l 5915 7137 l 5937 7105 l 5958 7075 l 5980 7048 l\n 6001 7021 l 6023 6997 l 6045 6973 l 6067 6951 l 6090 6930 l\n 6115 6909 l 6140 6888 l 6166 6869 l 6192 6851 l 6220 6833 l\n 6249 6817 l 6280 6801 l 6312 6786 l 6346 6771 l 6381 6757 l\n 6419 6743 l 6459 6730 l 6501 6717 l 6545 6704 l 6591 6692 l\n 6639 6680 l 6689 6668 l 6739 6656 l 6791 6645 l 6842 6634 l\n 6892 6624 l 6941 6615 l 6988 6606 l 7031 6598 l 7069 6591 l\n 7103 6586 l 7132 6581 l 7155 6577 l 7173 6574 l 7186 6572 l\n 7194 6571 l 7198 6570 l\n 7200 6570 l gs col0 s gr \n% Polyline\nn 4860 7515 m 4861 7513 l 4863 7509 l 4867 7501 l 4873 7488 l 4882 7471 l\n 4893 7448 l 4907 7419 l 4924 7384 l 4944 7345 l 4966 7300 l\n 4991 7252 l 5017 7201 l 5044 7147 l 5073 7093 l 5101 7037 l\n 5131 6982 l 5160 6928 l 5188 6875 l 5217 6823 l 5244 6774 l\n 5271 6727 l 5297 6683 l 5323 6641 l 5347 6601 l 5371 6564 l\n 5394 6528 l 5417 6495 l 5440 6464 l 5462 6435 l 5484 6408 l\n 5506 6382 l 5528 6357 l 5550 6334 l 5572 6312 l 5594 6290 l\n 5620 6267 l 5646 6246 l 5673 6225 l 5701 6205 l 5730 6186 l\n 5760 6167 l 5791 6150 l 5824 6133 l 5859 6116 l 5896 6099 l\n 5935 6083 l 5977 6067 l 6020 6051 l 6066 6036 l 6113 6020 l\n 6162 6005 l 6212 5990 l 6263 5975 l 6314 5961 l 6363 5947 l\n 6411 5935 l 6456 5923 l 6496 5913 l 6532 5904 l 6563 5896 l\n 6588 5890 l 6607 5886 l 6621 5883 l 6630 5881 l 6635 5879 l\n\n 6637 5879 l gs col0 s gr \n% Polyline\nn 4320 7245 m 4321 7243 l 4323 7240 l 4326 7232 l 4331 7221 l 4339 7205 l\n 4349 7184 l 4361 7158 l 4376 7127 l 4394 7090 l 4413 7049 l\n 4435 7004 l 4459 6955 l 4484 6904 l 4510 6850 l 4536 6796 l\n 4564 6741 l 4591 6687 l 4618 6633 l 4644 6581 l 4670 6530 l\n 4695 6481 l 4720 6434 l 4744 6390 l 4767 6347 l 4789 6307 l\n 4810 6269 l 4831 6233 l 4851 6200 l 4870 6168 l 4889 6138 l\n 4908 6109 l 4926 6082 l 4944 6057 l 4962 6032 l 4979 6009 l\n 4997 5987 l 5015 5966 l 5039 5938 l 5063 5912 l 5088 5887 l\n 5113 5863 l 5140 5840 l 5167 5818 l 5196 5796 l 5226 5775 l\n 5258 5755 l 5292 5734 l 5328 5714 l 5366 5694 l 5405 5674 l\n 5446 5654 l 5488 5634 l 5530 5615 l 5571 5597 l 5611 5580 l\n 5649 5564 l 5683 5550 l 5713 5538 l 5738 5528 l 5757 5521 l\n 5772 5515 l 5781 5512 l 5786 5510 l\n 5788 5509 l gs col0 s gr \n% Polyline\nn 3600 7290 m 3601 7288 l 3602 7284 l 3604 7276 l 3607 7264 l 3612 7246 l\n 3619 7224 l 3627 7195 l 3637 7161 l 3648 7122 l 3661 7078 l\n 3676 7031 l 3691 6980 l 3707 6927 l 3725 6872 l 3742 6817 l\n 3760 6762 l 3778 6708 l 3797 6655 l 3815 6603 l 3833 6554 l\n 3851 6507 l 3868 6462 l 3886 6419 l 3903 6378 l 3921 6340 l\n 3938 6303 l 3956 6269 l 3973 6236 l 3991 6205 l 4009 6176 l\n 4028 6148 l 4047 6121 l 4066 6095 l 4087 6069 l 4108 6045 l\n 4129 6021 l 4151 5998 l 4175 5975 l 4199 5953 l 4224 5932 l\n 4251 5910 l 4279 5889 l 4309 5867 l 4341 5846 l 4375 5825 l\n 4410 5803 l 4448 5781 l 4488 5759 l 4530 5736 l 4574 5713 l\n 4620 5689 l 4668 5666 l 4718 5642 l 4769 5618 l 4820 5594 l\n 4872 5570 l 4923 5547 l 4973 5525 l 5021 5504 l 5066 5484 l\n 5107 5466 l 5144 5451 l 5176 5437 l 5202 5426 l 5224 5417 l\n 5240 5410 l 5252 5405 l 5259 5402 l 5263 5401 l\n 5265 5400 l gs col0 s gr \n% Polyline\nn 6054 7541 m 6053 7540 l 6050 7536 l 6045 7530 l 6037 7520 l 6026 7506 l\n 6011 7487 l 5992 7464 l 5969 7436 l 5942 7404 l 5912 7367 l\n 5879 7327 l 5843 7284 l 5805 7239 l 5765 7192 l 5724 7144 l\n 5683 7096 l 5641 7049 l 5600 7002 l 5559 6956 l 5519 6912 l\n 5480 6869 l 5442 6829 l 5405 6791 l 5369 6754 l 5334 6720 l\n 5300 6688 l 5268 6658 l 5236 6630 l 5205 6604 l 5175 6579 l\n 5145 6556 l 5115 6535 l 5086 6515 l 5057 6496 l 5028 6479 l\n 4998 6462 l 4969 6447 l 4938 6432 l 4906 6417 l 4873 6404 l\n 4840 6392 l 4806 6380 l 4771 6370 l 4735 6360 l 4697 6351 l\n 4658 6343 l 4617 6336 l 4574 6330 l 4529 6324 l 4482 6319 l\n 4432 6314 l 4381 6310 l 4328 6307 l 4272 6304 l 4215 6302 l\n 4157 6300 l 4099 6298 l 4040 6297 l 3982 6297 l 3926 6296 l\n 3873 6296 l 3822 6296 l 3776 6297 l 3735 6297 l 3699 6298 l\n 3670 6298 l 3646 6299 l 3627 6299 l 3615 6300 l 3606 6300 l\n 3602 6300 l\n 3600 6300 l gs col0 s gr \n% Polyline\nn 6481 7134 m 6480 7132 l 6478 7129 l 6473 7122 l 6466 7111 l 6456 7096 l\n 6442 7076 l 6425 7052 l 6405 7022 l 6381 6987 l 6354 6948 l\n 6325 6905 l 6293 6859 l 6259 6811 l 6223 6761 l 6187 6709 l\n 6149 6658 l 6112 6607 l 6075 6556 l 6039 6507 l 6003 6460 l\n 5967 6414 l 5933 6370 l 5900 6329 l 5868 6290 l 5836 6253 l\n 5806 6218 l 5776 6185 l 5748 6155 l 5720 6126 l 5692 6099 l\n 5665 6074 l 5638 6050 l 5611 6028 l 5584 6007 l 5558 5987 l\n 5531 5969 l 5504 5951 l 5475 5933 l 5445 5917 l 5415 5901 l\n 5385 5886 l 5353 5873 l 5321 5860 l 5287 5848 l 5252 5836 l\n 5215 5826 l 5177 5816 l 5137 5806 l 5094 5797 l 5050 5789 l\n 5004 5781 l 4956 5774 l 4905 5767 l 4854 5760 l 4800 5754 l\n 4746 5748 l 4691 5743 l 4635 5738 l 4581 5734 l 4528 5730 l\n 4478 5726 l 4430 5723 l 4387 5720 l 4348 5718 l 4315 5716 l\n 4287 5715 l 4264 5714 l 4247 5713 l 4235 5713 l 4227 5712 l\n 4223 5712 l\n 4221 5712 l gs col0 s gr \n% Polyline\nn 7200 7020 m 7199 7019 l 7197 7015 l 7192 7009 l 7186 7000 l 7176 6987 l\n 7163 6969 l 7147 6947 l 7127 6920 l 7104 6889 l 7078 6853 l\n 7049 6814 l 7017 6771 l 6983 6726 l 6947 6678 l 6910 6629 l\n 6872 6579 l 6833 6529 l 6795 6480 l 6756 6431 l 6718 6383 l\n 6681 6337 l 6644 6292 l 6609 6249 l 6574 6208 l 6541 6169 l\n 6508 6133 l 6476 6098 l 6445 6065 l 6416 6034 l 6386 6004 l\n 6358 5977 l 6330 5950 l 6302 5926 l 6274 5903 l 6247 5881 l\n 6220 5860 l 6193 5840 l 6166 5821 l 6138 5803 l 6107 5784 l\n 6076 5766 l 6044 5748 l 6011 5732 l 5978 5716 l 5944 5701 l\n 5908 5687 l 5871 5674 l 5832 5661 l 5792 5648 l 5749 5636 l\n 5705 5624 l 5658 5613 l 5610 5602 l 5559 5591 l 5506 5581 l\n 5451 5571 l 5395 5561 l 5338 5551 l 5280 5542 l 5222 5533 l\n 5165 5525 l 5110 5518 l 5057 5510 l 5007 5504 l 4962 5498 l\n 4921 5493 l 4886 5489 l 4857 5486 l 4833 5483 l 4815 5481 l\n 4802 5480 l 4794 5479 l 4790 5478 l\n 4788 5478 l gs col0 s gr \n% Polyline\nn 4635 7335 m 4636 7333 l 4637 7329 l 4641 7321 l 4646 7309 l 4653 7292 l\n 4662 7269 l 4674 7241 l 4689 7207 l 4705 7167 l 4724 7123 l\n 4745 7074 l 4768 7021 l 4792 6965 l 4817 6908 l 4843 6850 l\n 4869 6791 l 4896 6732 l 4922 6674 l 4948 6618 l 4974 6564 l\n 4999 6512 l 5023 6462 l 5047 6414 l 5070 6369 l 5093 6327 l\n 5115 6287 l 5136 6249 l 5157 6214 l 5178 6181 l 5198 6150 l\n 5218 6121 l 5238 6093 l 5257 6068 l 5277 6043 l 5297 6021 l\n 5317 5999 l 5338 5979 l 5362 5955 l 5387 5934 l 5413 5913 l\n 5439 5894 l 5467 5877 l 5495 5860 l 5525 5845 l 5557 5830 l\n 5590 5816 l 5625 5803 l 5663 5791 l 5702 5779 l 5743 5768 l\n 5787 5758 l 5832 5748 l 5878 5738 l 5926 5730 l 5974 5721 l\n 6023 5714 l 6070 5707 l 6115 5701 l 6157 5695 l 6196 5690 l\n 6231 5686 l 6260 5683 l 6284 5680 l 6302 5679 l 6315 5677 l\n 6323 5677 l 6328 5676 l\n 6330 5676 l gs col0 s gr \n% Polyline\nn 3915 7245 m 3916 7243 l 3918 7239 l 3921 7231 l 3926 7218 l 3934 7201 l\n 3943 7177 l 3956 7148 l 3970 7114 l 3987 7074 l 4007 7029 l\n 4028 6981 l 4050 6929 l 4074 6875 l 4099 6820 l 4124 6764 l\n 4149 6708 l 4174 6653 l 4199 6599 l 4224 6547 l 4248 6497 l\n 4272 6450 l 4294 6404 l 4317 6361 l 4339 6320 l 4360 6282 l\n 4381 6246 l 4401 6211 l 4421 6179 l 4441 6149 l 4461 6120 l\n 4480 6092 l 4500 6066 l 4520 6041 l 4541 6017 l 4561 5993 l\n 4585 5968 l 4609 5944 l 4634 5920 l 4660 5897 l 4687 5875 l\n 4715 5853 l 4745 5832 l 4776 5811 l 4809 5790 l 4844 5768 l\n 4881 5747 l 4920 5726 l 4961 5704 l 5004 5683 l 5049 5661 l\n 5096 5639 l 5144 5617 l 5192 5595 l 5240 5574 l 5288 5554 l\n 5333 5534 l 5376 5517 l 5415 5501 l 5449 5487 l 5478 5475 l\n 5502 5465 l 5521 5458 l 5534 5453 l 5542 5450 l 5547 5448 l\n\n 5549 5447 l gs col0 s gr \n% Polyline\nn 5760 8235 m 5759 8233 l 5756 8230 l 5752 8223 l 5744 8211 l 5733 8196 l\n 5719 8175 l 5702 8149 l 5680 8118 l 5655 8082 l 5627 8042 l\n 5596 7997 l 5562 7950 l 5527 7899 l 5490 7847 l 5451 7794 l\n 5413 7741 l 5374 7688 l 5335 7636 l 5296 7586 l 5259 7537 l\n 5222 7490 l 5186 7446 l 5151 7403 l 5117 7363 l 5085 7326 l\n 5053 7291 l 5022 7258 l 4992 7227 l 4963 7199 l 4934 7172 l\n 4905 7147 l 4877 7125 l 4849 7103 l 4821 7083 l 4794 7065 l\n 4765 7048 l 4737 7032 l 4707 7016 l 4676 7002 l 4645 6989 l\n 4613 6976 l 4580 6966 l 4547 6956 l 4511 6947 l 4475 6940 l\n 4437 6933 l 4397 6928 l 4355 6923 l 4311 6919 l 4265 6917 l\n 4217 6915 l 4167 6914 l 4115 6914 l 4061 6914 l 4005 6915 l\n 3948 6917 l 3891 6920 l 3834 6923 l 3777 6926 l 3722 6930 l\n 3670 6933 l 3621 6937 l 3576 6941 l 3535 6944 l 3500 6947 l\n 3471 6950 l 3448 6952 l 3430 6954 l 3417 6955 l 3409 6956 l\n 3405 6957 l\n 3403 6957 l gs col0 s gr \n% here ends figure;\n$F2psEnd\nrs\nshowpage\n\n%%EndDocument\n @endspecial Black Black Black eop end\n%%Trailer\n\nuserdict /end-hook known{end-hook}if\n%%EOF\n"
  },
  {
    "path": "doc/manual/titlepage.sty",
    "content": "% THIS is a dummy titlepage.sty file - it was missing from the two\n% manual directories, but required by the sislman.sty documentstyle file.\n"
  },
  {
    "path": "doc/manual/type/SISLBox.tex",
    "content": "\\typelabel{SISLBox}\n \\> double      \\>*emax;        \\>\\> \\begin{minipg2}\n                                Allocated array containing\n                                the minimum values of the bounding box\n                                \\end{minipg2}\\\\[0.3ex]\n \\> double      \\>*emin;        \\>\\> \\begin{minipg2}\n                                Allocated array containing\n                                the maximum values of the bounding box\n                                \\end{minipg2}\\\\[0.3ex]\n \\> int         \\>imin;         \\>\\> \\begin{minipg2}\n                                The index of the minimum coefficient\n                                {\\fov ecoef}[{\\fov imin}].\n                                Only used in dimension one.\n                                {\\fov ecoef} is the control polygon of\n                                the curve/surface.\n                                \\end{minipg2}\\\\[0.3ex]\n \\> int         \\>imax;         \\>\\> \\begin{minipg2}\n                                The index of the maximum coefficient\n                                {\\fov ecoef}[{\\fov imax}].\n                                Only used in dimension one.\n                                {\\fov ecoef} is the control polygon of\n                                the curve/surface.\n                                \\end{minipg2}\\\\[0.3ex]\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/type/SISLCurve.tex",
    "content": "\\typelabel{SISLCurve}\n  \\>int         \\>{\\fov ik};     \\>\\>Order of curve. \\\\\n  \\>int         \\>{\\fov in};     \\>\\>Number of vertices. \\\\\n  \\>double      \\>*{\\fov et};    \\>\\>Pointer to the knot vector.  \\\\\n  \\>double      \\>*{\\fov ecoef}; \\>\\> \\begin{minipg2}\n                         Pointer to the array containing\n                         non-rational vertices, size $in\\times idim$.\n                                      \\end{minipg2}\\\\[0.8ex]\n \\>double       \\>*{\\fov rcoef}; \\>\\> \\begin{minipg2}\n                         Pointer to the array of rational\n                         vertices and weights, size $in\\times (idim+1)$.\n                                      \\end{minipg2}\\\\[0.8ex]\n \\>int  \\>{\\fov ikind};  \\>\\>Type of curve\\\\\n        \\>\\>\\>\\>\\>     $= 1$ :\\> Polynomial B-spline curve.\\\\\n        \\>\\>\\>\\>\\>     $= 2$ :\\> Rational B-spline (nurbs) curve.\\\\\n        \\>\\>\\>\\>\\>     $= 3$ :\\> Polynomial Bezier curve.\\\\\n        \\>\\>\\>\\>\\>     $= 4$ :\\> Rational Bezier curve.\\\\\n  \\>int         \\>{\\fov idim};   \\>\\>Dimension of the space in which the\n                                        curve lies.  \\\\\n  \\>int         \\>{\\fov icopy};  \\>\\> \\begin{minipg2}\n                        Indicates whether the arrays of the curve are\n                       allocated and copied or referenced by creation of the curve.\n                                \\end{minipg2}\\\\[0.3ex]\n        \\>\\>\\>\\>\\>     $= 0$ :\\>        \\begin{minipg5}\n                                 Pointer set to input arrays. The\n                                arrays are not deleted by freeCurve.\n                                        \\end{minipg5}\\\\[0.3ex]\n        \\>\\>\\>\\>\\>     $= 1$ :\\>        \\begin{minipg5}\n                                Array allocated and copied. The\n                                arrays are deleted by freeCurve.\n                                        \\end{minipg5}\\\\[0.3ex]\n        \\>\\>\\>\\>\\>     $= 2$ :\\>        \\begin{minipg5}\n                                Pointer set to input arrays,\n                             but are to be treated as copied. The\n                                arrays are deleted by freeCurve.\n                                        \\end{minipg5}\\\\[0.3ex]\n  \\>SISLdir     \\>*{\\fov pdir}; \\>\\>\\begin{minipg2}\n                        Pointer to a SISLdir object used for storing curve direction.\n                                \\end{minipg2}\\\\[0.8ex]\n  \\>SISLbox     \\>*{\\fov pbox}; \\>\\>\\begin{minipg2}\n                        Pointer to a SISLbox object used for storing the surrounding boxes.\n                                \\end{minipg2}\\\\[0.8ex]\n  \\>int         \\>{\\fov cuopen}; \\>\\>       Open/closed/periodic flag. \\\\\n        \\>\\>\\>\\>\\>     $=-1$ \\> : \\begin{minipg5}\n                                Closed curve with periodic (cyclic)\n                                parameterization and overlapping\n                                end vertices.\n                                   \\end{minipg5}\\\\[0.3ex]\n        \\>\\>\\>\\>\\>     $=0$ \\>  : \\begin{minipg5}\n                                Closed curve with k-tuple end knots and\n                                coinciding start/end vertices.\n                                  \\end{minipg5}\\\\[0.3ex]\n        \\>\\>\\>\\>\\>     $=1$ \\>  : Open curve (default).\\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/type/SISLDir.tex",
    "content": "\\typelabel{SISLDir}\n \\> int         \\>{\\fov igtpi}; \\>\\> \\begin{minipg2}\n                                To mark if the angle of direction cone\n                                is greater than $\\pi$.\n                                \\end{minipg2}\\\\\n                \\>\\>\\>\\>\\>      $= 0$   :\\>\\hspace*{0.3em}\\begin{minipg5}\n                                The direction of a surface\n                                and its boundary curves or a curve\n                                is not greater than $\\pi$ in any\n                                parameter direction.\n                                \\end{minipg5}\\\\[0.3ex]\n                \\>\\>\\>\\>\\>      $= 1$   :\\>\\hspace*{0.3em}\\begin{minipg5}\n                                The direction of a surface or a curve\n                                is greater than $\\pi$ in the first\n                                parameter direction.\n                                \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>\\>      $= 2$   :\\>\\hspace*{0.3em}\\begin{minipg5}\n                                The angle of direction cone of a surface is greater\n                                than $\\pi$ in the second parameter\n                                direction.\n                                \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>\\>      $= 10:$\\>\\hspace*{0.3em}\\begin{minipg5}\n                                The angle of direction cone of a boundary curve\n                                in first parameter direction of a\n                                surface is greater than $\\pi$.\n                                \\end{minipg5}\\\\[0.8ex]\n                \\>\\>\\>\\>\\>      $= 20:$\\>\\hspace*{0.3em}\\begin{minipg5}\n                                The angle of direction cone of a boundary curve\n                                in second parameter direction of a\n                                surface is greater than $\\pi$.\n                                \\end{minipg5}\\\\[0.3ex]\n \\> double      \\>*{\\fov ecoef};        \\>\\> \\begin{minipg2}\n                                Allocated array containing\n                                the coordinates of the centre of the cone.\n                                \\end{minipg2}\\\\[0.3ex]\n \\> double      \\>{\\fov aang};          \\>\\> \\begin{minipg2}\n                                The angle from the centre which\n                                describes the cone.\n                                \\end{minipg2}\\\\[0.3ex]\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/type/SISLIntcurve.tex",
    "content": "\\typelabel{SISLIntcurve}\n \\> int \t\\>{\\fov ipoint};\t\\>\\>Number of guide points defining the curve.\\\\\n \\> double \t\\>*{\\fov epar1};   \t\\>\\> \\begin{minipg2}\n\t\t\t\tPointer to the parameter values of the points in the first object. \n\t\t\t\t\\end{minipg2}\\\\[0.3ex]\n \\> double\t\\>*{\\fov epar2};\t\\>\\> \\begin{minipg2}\n\t\t\t\tPointer to the parameter values of the points in the second object.\n\t\t\t\t\\end{minipg2}\\\\[0.3ex]\n \\> int\t\t\\>{\\fov ipar1};\t\t\\>\\> Number of parameter directions of first object.\\\\\n \\> int\t\t\\>{\\fov ipar2};\t\t\\>\\>Number of parameter directions of second object.\\\\\n \\> SISLCurve \t\\>*{\\fov pgeom}; \t\\>\\> \\begin{minipg2}\n\t\t\t\tPointer to the intersection curve in the\n                           \tgeometry space. If the curve is not \n                           \tcomputed, pgeom points to NULL.\n\t\t\t\t\\end{minipg2}\\\\[0.3ex]\n \\> SISLCurve \t\\>*{\\fov ppar1};  \t\\>\\> \\begin{minipg2}\n\t\t\t\tPointer to the intersection curve in the\n                           \tparameter plane of the first object. If \n                           \tthe curve is not computed, ppar1 points \n                           \tto NULL.\n\t\t\t\t\\end{minipg2}\\\\[0.3ex]\n \\> SISLCurve \t\\>*{\\fov ppar2};  \t\\>\\> \\begin{minipg2}\n\t\t\t\tPointer to the intersection curve in the\n                           \tparameter plane of the second object. If \n                           \tthe curve is not computed, ppar2 points \n                           \tto NULL.\n\t\t\t\t\\end{minipg2}\\\\[0.3ex]\n \\> int \t\\>{\\fov itype};\t\\>\\>Type of curve:\\\\\n\t\\>\\>\\>\\>\\>\t$= 1$ :\\> Straight line.\\\\\n\t\\>\\>\\>\\>\\>\t$= 2$ :\\> Closed loop. No singularities.\\\\\n\t\\>\\>\\>\\>\\>\t$= 3$ :\\> Closed loop. One singularity. Not used.\\\\\n\t\\>\\>\\>\\>\\>\t$= 4$ :\\> Open curve. No singularity.\\\\\n\t\\>\\>\\>\\>\\>\t$= 5$ :\\> \\begin{minipg5}\n\t\t\t\tOpen curve. Singularity at the \n                           \tbeginning of the curve.\n\t\t\t\t\\end{minipg5}\\\\[0.8ex]\n\t\\>\\>\\>\\>\\>\t$= 6$ :\\> \\begin{minipg5}\n\t\t\t\tOpen curve. Singularity at the end\n                            \tof the curve.\n\t\t\t\t\\end{minipg5}\\\\[0.8ex]\n\t\\>\\>\\>\\>\\>\t$= 7$ :\\> \\begin{minipg5}\n\t\t\t\tOpen curve. Singularity at the beginning\n                            \tand end of the curve.\n\t\t\t\t\\end{minipg5}\\\\[0.8ex]\n\t\\>\\>\\>\\>\\>\t$= 8$ :\\> An isolated singularity. Not used.\\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/type/SISLSurf.tex",
    "content": "\\typelabel{SISLSurf}\n  \\>int         \\>{\\fov ik1};    \\>\\>Order of surface in first parameter direction.     \\\\\n  \\>int         \\>{\\fov ik2};    \\>\\>Order of surface in second parameter direction.    \\\\\n  \\>int         \\>{\\fov in1};    \\>\\>Number of coefficients in first parameter direction.  \\\\\n  \\>int         \\>{\\fov in2};    \\>\\>Number of coefficients in second parameter direction. \\\\\n  \\>double      \\>*{\\fov et1};   \\>\\>Pointer to knot vector in first parameter direction.  \\\\\n  \\>double      \\>*{\\fov et2};   \\>\\>Pointer to knot vector in second parameter direction. \\\\\n  \\>double      \\>*{\\fov ecoef}; \\>\\>\n                \\begin{minipg2}\n                  Pointer to array of non-rational coefficients of the\n                  surface, size $in1\\times in2\\times idim$.\n                \\end{minipg2}\\\\[0.8ex]\n  \\>double      \\>*{\\fov rcoef}; \\>\\>\n                \\begin{minipg2}\n                  Pointer to the array of rational vertices and weights,\n                  size $in1\\times in2\\times (idim+1)$.\n                \\end{minipg2}\\\\[0.8ex]\n  \\>int         \\>{\\fov ikind};  \\>\\>Type of surface\\\\\n        \\>\\>\\>\\>     $= 1$ \\>: Polynomial B-spline tensor-product surface.\\\\\n        \\>\\>\\>\\>     $= 2$ \\>: Rational B-spline (nurbs) tensor-product surface.\\\\\n        \\>\\>\\>\\>     $= 3$ \\>: Polynomial Bezier tensor-product surface.\\\\\n        \\>\\>\\>\\>     $= 4$ \\>: Rational Bezier tensor-product surface.\\\\\n  \\>int         \\>{\\fov idim};   \\>\\>Dimension of the space in which the\n                                        surface lies.  \\\\\n\\newpagetabs\n  \\>int         \\>{\\fov icopy};  \\>\\> \\begin{minipg2}\n                                Indicates whether the arrays of the surface are\n                                allocated and copied or referenced\n                                when the surface was created.\n                                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>\\>\\>     $= 0$ \\>: \\begin{minipg5}\n                                 Pointer set to input arrays. The\n                                arrays are not deleted by freeSurf.\n                                \\end{minipg5}\\\\[0.3ex]\n        \\>\\>\\>\\>     $= 1$ \\>: \\begin{minipg5}\n                                 Array allocated and copied. The\n                                arrays are deleted by freeSurf.\n                                \\end{minipg5}\\\\[0.3ex]\n        \\>\\>\\>\\>     $= 2$ \\>: \\begin{minipg5}\n                                Pointer set to input arrays,\n                                but the arrays are to be treated\n                                as allocated and copied. The\n                                arrays are deleted by freeSurf.\n                                \\end{minipg5}\\\\[0.8ex]\n  \\>SISLdir     \\>\\hspace*{2em}*{\\fov pdir}; \\>\\>\\begin{minipg2}\n                        Pointer to a SISLdir object used for storing\n                        surface direction.\n                                \\end{minipg2}\\\\[0.8ex]\n  \\>SISLbox     \\>\\hspace*{2em}*{\\fov pbox}; \\>\\>\\begin{minipg2}\n                        Pointer to a SISLbox object used for storing the surrounded boxes.\n                                \\end{minipg2}\\\\[0.8ex]\n  \\>int         \\>{\\fov cuopen\\_1}; \\>\\>\n                \\begin{minipg2}\n                  Open/closed/periodic flag for the first parameter direction.\n                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>\\>\\>     $=-1$ \\>: \\begin{minipg5}\n                                Closed curve with periodic (cyclic)\n                                parameterization and overlapping\n                                end vertices.\n                                   \\end{minipg5}\\\\[0.8ex]\n        \\>\\>\\>\\>     $=0$ \\>: \\begin{minipg5}\n                                Closed curve with k-tuple end knots and\n                                coinciding start/end vertices.\n                                  \\end{minipg5}\\\\[0.8ex]\n        \\>\\>\\>\\>     $=1$ \\>: Open curve (default).\\\\[0.3ex]\n  \\>int         \\>{\\fov cuopen\\_2}; \\>\\>\n                \\begin{minipg2}\n                  Open/closed/periodic flag for the second parameter direction.\n                \\end{minipg2}\\\\[0.8ex]\n        \\>\\>\\>\\>     $=-1$ \\>: \\begin{minipg5}\n                                Closed curve with periodic (cyclic)\n                                parameterization and overlapping\n                                end vertices.\n                                   \\end{minipg5}\\\\[0.8ex]\n        \\>\\>\\>\\>     $=0$ \\>: \\begin{minipg5}\n                                Closed curve with k-tuple end knots and\n                                coinciding start/end vertices.\n                                  \\end{minipg5}\\\\[0.8ex]\n        \\>\\>\\>\\>     $=1$ \\>: Open curve (default).\\\\\n\\end{tabbing}\n"
  },
  {
    "path": "doc/manual/type/test.tex",
    "content": "\\documentstyle[twoside]{sislman}\n\n\\begin{document}\n\n\\chapter{Curve definition.}\n\n\\section{Straight line between two points.}\n\n\\input{SISLCurve}\n\\input{SISLSurf}\n\\input{SISLBox}\n\\input{SISLDir}\n\\input{SISLIntcurve}\n\\end{document}\n"
  },
  {
    "path": "doc/manual/viewer.tex",
    "content": "\\chapter{The object viewer program}\n\n\\section{General}\nThe object viewer program bundled with this distribution of SISL is intended to be\na simple but handy tool for visualising curves and surfaces generated by SISL.  The\nsupported file format is the \\verb/Go/ format, \nwhich is a simple, ASCII-based format defined by SINTEF.  The viewer is based on OpenGL.\nAn alternative viewer with a more evolved user interface, but also more dependencies can\nbe found in the library GoTools also provided by SINTEF Mathematics and Cybernetics.\nThe object(s) to be viewed are for this viewer specified on the command line when starting the \nprogram.  Once the program is started, the user cannot open other files containing\nSISL objects.  The viewer allows the user to zoom, pan and rotate the objects with\nthe mouse, and some other useful commands can be accessed through the keyboard.\n\\\\\n\\\\\nIn the viewer window, several curves and surfaces can be displayed simultaneously.\nAt all times, exactly \\emph{one} surface and \\emph{one} curve are defined as being\n\\emph{active} (the other ones being \\emph{passive}).  With keyboard commands, the user\ncan change the currently active surface/curve.  An object just becoming active will\nflash for a few seconds.  With other keyboard commands, the user can \\emph{enable/disable}\nsurfaces and curves.  This refers to turning the display of these objects on or off.\nFor details, refer to the section on keyboard commands.\n\n\\section{Compiling the viewer}\nThe default cmake setup is not to compile example programs, the stream library and the viewer.\nTo enable compilation of the example programs the cmake call must be extended with\n-Dsisl\\_COMPILE\\_VIEWER=ON. This option also enables compilation of the streaming library.\nWith ccmake compile options are changed pressing enter. In cmake-gui compilation of the viewer\nis invoked by ticking the appropriate box.\nCompilation and linking is performed with the call\n\\begin{verbatim}\n$ make sisl_view_demo\n\\end{verbatim}\nThe viewer is written in C++.\n\n\\section{Command line arguments}\nWhen starting up the viewer, the options listed below can be used.  If no option is\nspecified, a short text listing the available options is printed on screen.\n\n\\begin{itemize}\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/s/} \\textit{filename} - view the surface(s) contained in\nthe file \\textit{filename}.  Note: this command line option can be used repetitively if\nthe user wants to inspect several surfaces at once.\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/c/} \\textit{filename} - view the curve(s) contained in the\nfile \\textit{filename}.  Note: this command can be used repetitively if the user wants\nto inspect several curves at once.\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/p/} \\textit{filename} - view the point(s) contained in \nthe file \\textit{filename}.  Note: this command line option can be used repetitively if\nthe user wants to inspect several surfaces at once.\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/r/} \\textit{integer} set surface refinement factor \n(number of facets in each direction on the surface). Default value is 100.  Higher values\ngives smoother drawing of the surface.  NB: this option has to \\emph{precede} the 's' \noption!\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/e/} \\textit{string} the string contains keypresses to execute\ndirectly upon start (see the section on keyboard control keys for details).\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/hotkeys/} does not start the viewer, but displays a list \nof keyboard commands that can be used when viewing.\n\\end{itemize}\n\nA file can contain one or several curves, or one or several surfaces.  Files containing\nboth curves and surfaces are not supported.  The viewer can read several files to be\nviewed at once.  On the command line, each ``curve'' file should be preceded with the\nletter 'c', and each ``surface'' file should be preceded with the letter 's'.  After \nlaunch, all the objects contained in the given files are shown simultaneously.  The user\ncan disable the view of certain curves and surfaces if he or she wants to.  \n\n\\section{User controls}\n\nAfter program launch, the viewing of curves and surfaces can be controlled with the mouse\nand keyboard.  The mouse is used to define viewing angle, direction and zoom factor, while\nkeyboard keys are used to turn on/off objects and to change certain view parameters.\n\n\\subsection{Mouse commands}\nIt is assumed that a 3-button mouse is used.  By dragging the mouse while holding down the\n\\emph{left button}, the user can rotate the current view in an intuitive way.  By dragging\nwith a certain speed, the view will continue to rotate even after the left button is released.\nThe \\emph{middle button} is used for zooming.  Hold down this button and move the mouse \nforwards and backwards in order to zoom in and out.  Holding down the \\emph{right button}\nwhile dragging the mouse moves the view up and down.\n\n\\subsection{Keyboard commands}\n\nThe available keyboard commands are:\n\n\\begin{itemize}\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/q/} - quit the viewer program\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/<space>/} - change the currently active curve \n(cycles through each of them)\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/<tab/} - change the currently active surface \n(cycles through each of them)\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/w/} - turn on/off the wireframe display for surfaces\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/B/} - toggle between black and white color for backgrounds\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/A/} - toggle drawing of coordinate axes on/off\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/S/} - toggle drawing of surfaces\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/e/} - toggle visibility of currently active surface\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/a/} - make all loaded surfaces visible\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/d/} - hide all surfaces except the currently active one\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/<ctrl>-e/} - toggle visibility of currently active curve\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/<ctrl>-a/} - make all loaded curves visible\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/<ctrl>-d/} - hide all curves except the currently active one\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/O/} - center all objects around origo, and rescale objects\nso that they fit inside the unit volume (does not preserve aspect ratio)\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/o/} - center all objects around origo, no rescaling\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/+/} - increase thickness of axes\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/-/} - decrease thickness of axes\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/>/} - increase size of points\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/</} - decrease size of points\n\\item[$\\bullet$] \\textbf{\\protect \\Verb///} - decrease length of axes\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/<esc>-w-[n]/} - store viewpoint in slot [n], where [n]\nis a number from 0 to 9.  The viewpoint will be saved to file, and can such be preserved\nfrom one session to another.\n\\item[$\\bullet$] \\textbf{\\protect \\Verb/<esc>-r-[n]/} - load a previously saved viewpoint from\nslot [n], where [n] is a number from 0 to 9.\n\\end{itemize}\n"
  },
  {
    "path": "examples/example01.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <stdexcept>\n\n#include \"sisl.h\"\n#include \"GoReadWrite.h\"\n\nusing namespace std;\n\n\nnamespace {\n    string OUT_FILE_CURVE = \"example1_curve.g2\";\n    string OUT_FILE_POINTS = \"example1_points.g2\";\n\n    string DESCRIPTION = \n    \"This program will generate a new SISL spline object from \\n\"\n    \"predefined control points and parametrization, and will \\n\"\n    \"write the result in Go-format to the file '\" + OUT_FILE_CURVE + \"'.\\n\"\n    \"The curve's control points will be written separately to \\n\"\n    \"the file '\" + OUT_FILE_POINTS + \"'.\\n\";\n\n    const int number = 10;\n    const int order = 4;\n    \n    double coef[] = {0,  0,   0,\n\t\t     1,  0, 0.5,\n\t\t     1,  1,   1,\n\t\t     0,  1, 1.5,\n\t\t     0,  0,   2,\n\t\t     1,  0, 2.5,\n\t\t     1,  1,   3,\n\t\t     0,  1, 3.5,\n\t\t     0,  0,   4,\n\t\t     1,  0, 4.5};\n\n    double knots[] = {0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 7, 7, 7};\n\n}; // end anonymous namespace \n\n//===========================================================================\nint main(int avnum, char** vararg)\n//===========================================================================\n{\n    cout << '\\n' << vararg[0] << \":\\n\" << DESCRIPTION << endl;\n    cout << \"To proceed, press enter, or ^C to quit.\" << endl;\n    getchar();\n\n    try {\n\t\n\tSISLCurve* curve = newCurve(number, // number of control points\n\t\t\t\t    order,  // order of spline curve (degree + 1)\n\t\t\t\t    knots,  // pointer to knot vector (parametrization)\n\t\t\t\t    coef,   // pointer to coefficient vector (control points)\n\t\t\t\t    1,      // kind = polynomial B-spline curve\n\t\t\t\t    3,      // dimension\n\t\t\t\t    0);     // no copying of information, 'borrow' arrays\n\tif (!curve) {\n\t    throw runtime_error(\"Error occured while generating curve.\");\n\t}\n\t\n\tofstream os_curve(OUT_FILE_CURVE.c_str());\n\tofstream os_points(OUT_FILE_POINTS.c_str());\n\tif (!os_curve || !os_points) {\n\t    throw runtime_error(\"Unable to open output file.\");\n\t}\n\t\n\t// write result to file\n\twriteGoCurve(curve, os_curve);\n\twriteGoPoints(number, coef, os_points);\n\n\t// cleaning up\n\tfreeCurve(curve);\n\tos_curve.close();\n\tos_points.close();\n\n    } catch (exception& e) {\n\tcerr << \"Exception thrown: \" << e.what() << endl;\n\treturn 0;\n    }\n\n    return 1;\n};\n"
  },
  {
    "path": "examples/example02.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <stdexcept>\n#include <cstdlib>\n\n#include \"sisl.h\"\n#include \"GoReadWrite.h\"\n\nusing namespace std;\n\n\nnamespace {\n    string OUT_FILE_POINTS = \"example2_points.g2\";\n    string OUT_FILE_CURVE  = \"example2_curve.g2\";\n\n    string DESCRIPTION = \n    \"This program will generate a SISL spline curve object by \\n\"\n    \"interpolating a set of given points.  The parametrization \\n\"\n    \"will be calculated automatically.  No derivative \\n\"\n    \"information is provided.  The routine used is 's1356'. The \\n\"\n    \"points will be written in Go-format to the file: \\n'\" \n    + OUT_FILE_POINTS + \"'.  The resulting curve will be written \\n\"\n    \"in Go-format to the file: '\" + OUT_FILE_CURVE + \"'\\n\";\n\n    const int num_points = 6;\n    const double cstartpar = 0;\n\n    int type[] = {1, 1, 1, 1, 1, 1};\n\n    double points[] = {0, 0, 0,\n\t\t       1, 1, 0,\n\t\t       2, -1, 0,\n\t\t       3, 0, 0,\n\t\t       4, 1, 1,\n\t\t       3, 0, 4};\n}; // end anonymous namespace \n\n//===========================================================================\nint main(int avnum, char** vararg)\n//===========================================================================\n{\n    cout << '\\n' << vararg[0] << \":\\n\" << DESCRIPTION << endl;\n    cout << \"To proceed, press enter, or ^C to quit.\" << endl;\n    getchar();\n\n\n    try {\n\n\tdouble cendpar;\n\tSISLCurve* result_curve = 0;\n\tdouble* gpar = 0;\n\tint jnbpar;\n\tint jstat = 0;\n\n\ts1356(points,        // pointer to where the point coordinates are stored\n\t      num_points,    // number of points to be interpolated\n\t      3,             // the dimension\n\t      type,          // what type of information is stored at a particular point\n\t      0,             // no additional condition at start point\n\t      0,             // no additional condition at end point\n\t      1,             // open curve\n\t      4,             // order of the spline curve to be produced\n\t      cstartpar,     // parameter value to be used at start of curve\n\t      &cendpar,      // parameter value at the end of the curve (to be determined)\n\t      &result_curve, // the resulting spline curve (to be determined)\n\t      &gpar,         // pointer to the parameter values of the points in the curve\n\t                     // (to be determined)\n\t      &jnbpar,       // number of unique parameter values (to be determined)\n\t      &jstat);       // status message\n\n\tif (jstat < 0) {\n\t    throw runtime_error(\"Error occured inside call to SISL routine.\");\n\t} else if (jstat > 0) {\n\t    cerr << \"WARNING: warning occured inside call to SISL routine. \\n\" << endl;\n\t}\n\t      \n\tcout << \"Total parameter interval of curve: [\" << cstartpar << \", \" \n\t     << cendpar << \"]\\n\\n\";\n\tcout << \"Point parameter values was decided to be: \\n\";\n\tfor (int i = 0; i < num_points; ++i) {\n\t    cout << gpar[i] << ' ';\n\t}\n\tcout << endl;\n\n\tofstream os_points(OUT_FILE_POINTS.c_str());\n\tofstream os_curve(OUT_FILE_CURVE.c_str());\n\tif (!os_points || !os_curve) {\n\t    throw runtime_error(\"Unable to open output file.\");\n\t}\n\n\t// write result to file\n\twriteGoPoints(num_points, points, os_points);\n\twriteGoCurve(result_curve, os_curve);\n\t\n\t// cleaning up\n\tif (result_curve) freeCurve(result_curve);\n\tif (gpar) free(gpar);\n\tos_points.close();\n\tos_curve.close();\n\n    } catch (exception& e) {\n\tcerr << \"Exception thrown: \" << e.what() << endl;\n\treturn 0;\n    }\n\n    return 1;\n};\n"
  },
  {
    "path": "examples/example03.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <stdexcept>\n\n#include \"sisl.h\"\n#include \"GoReadWrite.h\"\n\nusing namespace std;\n\n\nnamespace {\n    string IN_FILE_CURVE_1 = \"example1_curve.g2\";\n    string IN_FILE_CURVE_2 = \"example2_curve.g2\";\n    string OUT_FILE_CURVE  = \"example3_curve.g2\";\n\n    string DESCRIPTION = \n    \"This program will create a 'blend curve' to connect the \\n\"\n    \"endpoints of the two curves generated in the two previous \\n\"\n    \"example programs.  The routine used is s1606. \\n\"\n    \"Input: \" + IN_FILE_CURVE_1 + \" and \" + IN_FILE_CURVE_2 + \"\\n\"\n    \"Output: \" + OUT_FILE_CURVE + \"\\n\\n\";\n\n}; // end anonymous namespace \n\n//===========================================================================\nint main(int avnum, char** vararg)\n//===========================================================================\n{\n    cout << '\\n' << vararg[0] << \":\\n\" << DESCRIPTION << endl;\n    cout << \"To proceed, press enter, or ^C to quit.\" << endl;\n    getchar();\n\n\n    try {\n\tifstream stream_1(IN_FILE_CURVE_1.c_str());\n\tifstream stream_2(IN_FILE_CURVE_2.c_str());\n\tif (!stream_1 || !stream_2) {\n\t    string error_message = \n\t\t\"Unable to open input files: \" + IN_FILE_CURVE_1 +\n\t\t\" and \" + IN_FILE_CURVE_2 + \".  Are you sure you have run the \"\n\t\t\"two previous sample programs?\";\n\t    throw runtime_error(error_message.c_str());\n\t}\n\n\tSISLCurve* c1 = readGoCurve(stream_1);\n\tSISLCurve* c2 = readGoCurve(stream_2);\n\n\tdouble epsge = 1.0e-5; // geometric precision\n\tint blendtype = 0; // generate polynomial segment\n\tint dim = 3;\n\tint order = 4;\n\tdouble c1_endpoint[3]; // endpoint of curve 1 (must be calculated)\n\tdouble c2_endpoint[3]; // endpoint of curve 2 (must be calculated)\n\t\n\t// The blend curve will extend from the endpoint of curve 1 to the\n\t// endpoint of curve 2.  As input, the SISL routine needs (approximate)\n\t// coordinates for these points on the curve.  We therefore preliminarly\n\t// need to evaluate these.  For this purpose, we use SISL routine s1227.\n\t\n\t// The end parameters of the curves' parametric domains can be found by \n\t// looking at their knotvectors (pointed to by data member 'et').  \n\t// If the number of control points is 'n', then the knot numbered 'n'\n\t// would represent the end parameter (when counting from 0).  The number\n\t// of control points is indicated by the data member 'in'.\n\tdouble c1_endpar = c1->et[c1->in]; // end parameter of curve 1\n\tdouble c2_endpar = c2->et[c2->in]; // end parameter of curve 2\n\tint temp, jstat1=0, jstat2=0;\n\t\n\t// evaluating endpoint positions of both curves\n\ts1227(c1,          // input curve\n\t      0,           // evaluate position only (no derivatives)\n\t      c1_endpar,   // end parameter\n\t      &temp,       // indicates param. interval (not interesting for our purposes)\n\t      c1_endpoint, // this is what we want to calculate (3D position)\n\t      &jstat1);     // status variable (0 if everything all right)\n\t\n\ts1227(c2,          // input curve\n\t      0,           // evaluate position only (no derivatives)\n\t      c2_endpar,   // end parameter\n\t      &temp,       // indicates param. interval (not interesting for our purposes)\n\t      c2_endpoint, // this is what we want to calculate (3D position)\n\t      &jstat2);     // status variable (0 if everything all right)\n\t\n\tif (jstat1 < 0 || jstat2 < 0) {\n\t    throw runtime_error(\"Error occured inside call to SISL routine s1227.\");\n\t} else if (jstat1 > 0 || jstat2 > 0) {\n\t    cerr << \"WARNING: warning occured inside call to SISL routine s1227.\";\n\t}\n    \n\t// calculating blend curve\n\tSISLCurve* blend_curve = 0;\n\tint jstat=0;\n\n\ts1606(c1,           // the first input curve\n\t      c2,           // the second input curve\n\t      epsge,        // geometric tolerance\n\t      c1_endpoint,  // endpoint of curve 1 (geometric)\n\t      c2_endpoint,  // endpoint of curve 2 (geometric)\n\t      blendtype,    // type of blend curve (circle, conic, polynomial)\n\t      dim,          // dimension (3D)\n\t      order,        // order of generated spline curve\n\t      &blend_curve, // the generated curve\n\t      &jstat);      // status message\n\t     \n\tif (jstat < 0) {\n\t    throw runtime_error(\"Error occured inside call to SISL routine s1606.\");\n\t} else if (jstat > 0) {\n\t    cerr << \"WARNING: warning occured inside call to SISL routine s1606.\\n\" << endl;\n\t}\n\n\tofstream os(OUT_FILE_CURVE.c_str());\n\tif (!os) {\n\t    throw runtime_error(\"Unable to open output file.\");\n\t}\n\n\t// write result to file\n\twriteGoCurve(blend_curve, os);\n\t\n\t// cleaning up\n\tif (blend_curve) freeCurve(blend_curve);\n\tif (c1) freeCurve(c1);\n\tif (c2) freeCurve(c2);\n\tos.close();\n\tstream_1.close();\n\tstream_2.close();\n\n    } catch (exception& e) {\n\tcerr << \"Exception thrown: \" << e.what() << endl;\n\treturn 0;\n    }\n\n    return 1;\n};\n"
  },
  {
    "path": "examples/example04.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <stdexcept>\n\n#include \"sisl.h\"\n#include \"GoReadWrite.h\"\n\nusing namespace std;\n\nnamespace {\n    string IN_FILE_CURVE = \"example1_curve.g2\";\n    string OUT_FILE_CURVE = \"example4_curve.g2\";\n\n    string DESCRIPTION = \n    \"This program will generate a SISL spline curve object that \\n\"\n    \"approximates an offset from a given input curve (note that \\n\"\n    \"the exact offset curve is not generally possible to \\n\"\n    \"represent exactly using splines).  The routine used is \\n\"\n    \"s1360.\\n\"\n    \"Input: \" + IN_FILE_CURVE + \" \\n\"\n    \"Output: \" + OUT_FILE_CURVE + \"\\n\\n\";\n\n}; // end anonymous namespace \n\n//===========================================================================\nint main(int avnum, char** vararg)\n//===========================================================================\n{\n    cout << '\\n' << vararg[0] << \":\\n\" << DESCRIPTION << endl;\n    cout << \"To proceed, press enter, or ^C to quit.\" << endl;\n    getchar();\n\n\n    try {\n\tifstream is(IN_FILE_CURVE.c_str());\n\tif (!is) {\n\t    string error_message = \n\t\t\"Unable to open input file: \" + IN_FILE_CURVE +\n\t\t\".  Are you sure you have run the previous sample program?\";\n\t    throw runtime_error(error_message.c_str());\n\t}\n\n\tSISLCurve* c1 = readGoCurve(is);\n\n\tdouble offset = double(1); // the offset between the 'old' curve and the result.\n\tdouble epsge = 1.0e-5;     // geometric tolerance \n\tdouble direction[] = {0, 0, 1}; // the direction of the offset\n\tint dim = 3; // the dimension of the Euclidean space\n\tint jstat = 0; // status variable\n\tSISLCurve* offset_curve = 0;\n\n\ts1360(c1,            // the 'old' curve\n\t      offset,        // the offset value\n\t      epsge,         // geometric tolerance\n\t      direction,     // offset direction\n\t      0,             // max step length.  0 indicate the longest box side of 's1'\n\t      dim,           // the dimension\n\t      &offset_curve, // the resulting offset curve\n\t      &jstat);       // status variable\n\tif (jstat < 0) {\n\t    throw runtime_error(\"Error occured inside call to SISL routine s1360.\");\n\t} else if (jstat > 0) {\n\t    cerr << \"WARNING: warning occured inside call to SISL routine s1360. \\n\" << endl;\n\t}\n\n\tofstream os(OUT_FILE_CURVE.c_str());\n\tif (!os) {\n\t    throw runtime_error(\"Unable to open output file.\");\n\t}\n\n\t// write result to file\n\twriteGoCurve(offset_curve, os);\n\t\n\t// cleaning up\n\tif (c1) freeCurve(c1);\n\tif (offset_curve) freeCurve(offset_curve);\n\tis.close();\n\tos.close();\n\n    } catch (exception& e) {\n\tcerr << \"Exception thrown: \" << e.what() << endl;\n\treturn 0;\n    }\n\n    return 1;\n};\n"
  },
  {
    "path": "examples/example05.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <stdexcept>\n\n#include \"sisl.h\"\n#include \"GoReadWrite.h\"\n\nusing namespace std;\n\nnamespace {\n    string OUT_FILE_CURVE = \"example5_curve.g2\";\n\n    string DESCRIPTION = \n    //==========================================================\n    \"This program generates some conic sections represented as \\n\"\n    \"SISLCurves.  Since the NURBS representation is used, the \\n\"\n    \"generated curves would be exact. The SISL routine used is\\n\"\n    \"s1011.  The resulting curves will be saved in Go-format to \\n\"\n    \"the file \" + OUT_FILE_CURVE + \".\\n\\n\";\n\n    const int num_shapes = 7; // number of generated shapes \n    const int dim = 3;\n\n    // logically, the following arrays are 'const'.  But this generates calling error\n    // with SISL,so we leave them un-consted for now.\n    double shape[] = {0.01,  // an ellipse\n\t\t      0.25,  // an ellipse\n\t\t      0.4,   // an ellipse\n\t\t      0.5,   // a parabola\n\t\t      0.6,   // a hyperbola\n\t\t      0.75,  // a hyperbola\n\t\t      0.99}; // a hyperbola\n    double start_pos[] = {0, 0, 0}; // start position (3D)\n    double top_pos[] = {1, 2, 0};   // shoulder point (3D)\n    double end_pos[] = {2, 0, 0};   // end position\n\n}; // end anonymous namespace \n\n//===========================================================================\nint main(int avnum, char** vararg)\n//===========================================================================\n{\n    cout << '\\n' << vararg[0] << \":\\n\" << DESCRIPTION << endl;\n    cout << \"To proceed, press enter, or ^C to quit.\" << endl;\n    getchar();\n\n    try {\n\n\tofstream os(OUT_FILE_CURVE.c_str());\n\tif (!os) {\n\t    throw runtime_error(\"Unable to open output file.\");\n\t}\n\n\tfor (int i = 0; i < num_shapes; ++i) {\n\n\t    SISLCurve* result_curve = 0;\n\t    int jstat = 0;\n\t    \n\t    // generate the conic section\n\t    s1011(start_pos,\n\t\t  top_pos,\n\t\t  end_pos,\n\t\t  shape[i],\n\t\t  dim,\n\t\t  &result_curve,\n\t\t  &jstat);\n\t    if (jstat < 0) {\n\t\tthrow runtime_error(\"Error occured inside call to SISL routine s1011.\");\n\t    } else if (jstat > 0) {\n\t\tcerr << \"WARNING: warning occured inside call to SISL routine s1011. \\n\" \n\t\t     << endl;\n\t    }\n\n\t    // write the result to file\n\t    writeGoCurve(result_curve, os);\n\n\t    if (result_curve) freeCurve(result_curve);\n\n\t}\n\n\tos.close();\n\n    } catch (exception& e) {\n\tcerr << \"Exception thrown: \" << e.what() << endl;\n\treturn 0;\n    }\n\n    return 1;\n};\n"
  },
  {
    "path": "examples/example06.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <stdexcept>\n#include <cstdlib>\n\n#include \"sisl.h\"\n#include \"GoReadWrite.h\"\n\nusing namespace std;\n\nnamespace {\n    string OUT_FILE_CURVE_1 = \"example6_curve_1.g2\";\n    string OUT_FILE_CURVE_2 = \"example6_curve_2.g2\";\n    string OUT_FILE_POINT   = \"example6_isectpoints.g2\";\n\n    string DESCRIPTION = \n    //==========================================================\n    \"This program generates two curves (from internal data), and \\n\"\n    \"computes their intersections, using SISL routine s1857.  \\n\"\n    \"The curves are planar, but lying in 3D space.  The curves \\n\"\n    \"and the intersections will then be saved to file.  The \\n\"\n    \"curves will be saved to the two files '\" + OUT_FILE_CURVE_1 \n    + \"' \\nand '\" + OUT_FILE_CURVE_2 + \"'. The intersection points \\n\"\n    \" will be saved to the file '\" + OUT_FILE_POINT + \"'\\n\\n\";\n\n    const int dim = 3;\n\n    const int c1_number = 4;\n    const int c1_order = 4;\n    \n    double c1_coef[] = {0, 0, 0,\n\t\t\t0, 2, 0,\n\t\t\t2, 2, 0,\n\t\t\t2, 0, 0};\n    double c1_knots[] = {0, 0, 0, 0, 1, 1, 1, 1};\n\n    const int c2_number = 5;\n    const int c2_order = 3;\n    \n    double c2_coef[] = {  0,   1,  0,\n\t\t\t0.5, 0.5,  0,\n\t\t\t  1,   2,  0,\n\t\t\t1.5, 0.5,  0,\n\t\t\t  2,   1,  0};\n\t\t\t\n    double c2_knots[] = {0, 0, 0, 1, 2, 3, 3, 3};\n\n}; // end anonymous namespace \n\n//===========================================================================\nint main(int avnum, char** vararg)\n//===========================================================================\n{\n    cout << '\\n' << vararg[0] << \":\\n\" << DESCRIPTION << endl;\n    cout << \"To proceed, press enter, or ^C to quit.\" << endl;\n    getchar();\n\n    try {\n\tofstream os_cv1(OUT_FILE_CURVE_1.c_str());\n\tofstream os_cv2(OUT_FILE_CURVE_2.c_str());\n\tofstream os_pts(OUT_FILE_POINT.c_str());\n\tif (!os_cv1 || !os_cv2 || !os_pts) {\n\t    throw runtime_error(\"Unable to open output file.\");\n\t}\n\n\t// generating curves from internal data\n\tSISLCurve* c1 = newCurve(c1_number, // num. of control points\n\t\t\t\t c1_order,  // spline order\n\t\t\t\t c1_knots,  // knotvector\n\t\t\t\t c1_coef,   // control points\n\t\t\t\t 1,         // kind = polynomial B-spline curve\n\t\t\t\t dim,       // dimension of space (3D)\n\t\t\t\t 1);        // copy input arrays\n\n\tSISLCurve* c2 = newCurve(c2_number, // num. of control points\n\t\t\t\t c2_order,  // spline order\n\t\t\t\t c2_knots,  // knotvector\n\t\t\t\t c2_coef,   // control points\n\t\t\t\t 1,         // kind = polynomial B-spline curve\n\t\t\t\t dim,       // dimension of space (3D)\n\t\t\t\t 1);        // copy input arrays\n\t\t \n\tif(!c1 || !c2) {\n\t    throw runtime_error(\"Error occured while generating curves.\");\n\t}\n\n\t// calculating intersection points\n\tdouble epsco = 1.0e-15; // computational epsilon\n\tdouble epsge = 1.0e-5; // geometric tolerance\n\tint num_int_points = 0; // number of found intersection points\n\tdouble* intpar1 = 0; // parameter values for the first curve in the intersections\n\tdouble* intpar2 = 0; // parameter values for the second curve in the intersections\n\tint num_int_curves = 0;   // number of intersection curves\n\tSISLIntcurve** intcurve = 0; // pointer to array of detected intersection curves\n\tint jstat = 0; // status variable\n\n\ts1857(c1,              // first curve \n\t      c2,              // second curve\n\t      epsco,           // computational resolution\n\t      epsge,           // geometry resolution\n\t      &num_int_points, // number of single intersection points\n\t      &intpar1,        // pointer to array of parameter values\n\t      &intpar2,        //               \"\n\t      &num_int_curves, // number of detected intersection curves\n\t      &intcurve,       // pointer to array of detected intersection curves.\n\t      &jstat);\n\t\n\tif (jstat < 0) {\n\t    throw runtime_error(\"Error occured inside call to SISL routine s1857.\");\n\t} else if (jstat > 0) {\n\t    cerr << \"WARNING: warning occured inside call to SISL routine s1857. \\n\" \n\t\t     << endl;\n\t}\n\n\t// In this example, we do not expect to find intersection curves, since the\n\t// input curves do not overlap for more than one point at a time.\n\n\tcout << \"Number of intersection points detected: \" << num_int_points << endl;\n\tcout << \"Number of intersection curves detected: \" << num_int_curves << endl;\n\t\n\t// evaluating intersection points and writing them to file\n\tvector<double> point_coords_3D(3 * num_int_points);\n\tint i;\n\tfor (i = 0; i < num_int_points; ++i) {\n\t    // calculating position, using curve 1\n\t    // (we could also have used curve 2, which would give approximately\n\t    // the same points).\n\t    int temp;\n\t    s1227(c1,         // we evaluate on the first curve\n\t\t  0,          // calculate no derivatives\n\t\t  intpar1[i], // parameter value on which to evaluate\n\t\t  &temp,      // not used for our purposes (gives parameter interval)\n\t\t  &point_coords_3D[3 * i], // result written here\n\t\t  &jstat);\n\n\t    if (jstat < 0) {\n\t\tthrow runtime_error(\"Error occured inside call to SISL routine s1227.\");\n\t    } else if (jstat > 0) {\n\t\tcerr << \"WARNING: warning occured inside call to SISL routine s1227. \\n\" \n\t\t     << endl;\n\t    }\n\t}\n\n\t// writing curves and intersections to file\n\twriteGoCurve(c1, os_cv1);\n\twriteGoCurve(c2, os_cv2);\n\twriteGoPoints(num_int_points, &point_coords_3D[0], os_pts);\n\n\t// cleaning up\n\tif (c1) freeCurve(c1);\n\tif (c2) freeCurve(c2);\n\tos_cv1.close();\n\tos_cv2.close();\n\tos_pts.close();\n\tif (intpar1) free(intpar1);\n\tif (intpar2) free(intpar2);\n\tif (num_int_curves > 0)\n\t  freeIntcrvlist(intcurve, num_int_curves);\n\n    } catch (exception& e) {\n\tcerr << \"Exception thrown: \" << e.what() << endl;\n\treturn 0;\n    }\n\n    return 1;\n};\n"
  },
  {
    "path": "examples/example07.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <stdexcept>\n\n#include \"sisl.h\"\n#include \"GoReadWrite.h\"\n\nusing namespace std;\n\nnamespace {\n    string IN_FILE_CURVE = \"example6_curve_1.g2\";\n\n    string DESCRIPTION = \n    //==========================================================\n    \"This program computes the length of a curve read from file.\\n\"\n    \"The name of this curve is: '\" + IN_FILE_CURVE + \"'.\\n\\n\";\n\n}; // end anonymous namespace \n\n//===========================================================================\nint main(int avnum, char** vararg)\n//===========================================================================\n{\n    cout << '\\n' << vararg[0] << \":\\n\" << DESCRIPTION << endl;\n    cout << \"To proceed, press enter, or ^C to quit.\" << endl;\n    getchar();\n\n    try {\n\tifstream is(IN_FILE_CURVE.c_str());\n\tif (!is) {\n\t    throw runtime_error(\"Unable to open input file.\");\n\t}\n\n\t// read curve from file\n\tSISLCurve* cv = readGoCurve(is);\n\n\t// computing length of curve\n\tdouble epsge = 1.0e-5; // geometric tolerance\n\tdouble length = 0;\n\tint jstat = 0;\n\n\ts1240(cv,      // the curve we want to know the length of\n\t      epsge,   // geometric tolerance\n\t      &length, // the calculated length\n\t      &jstat); // status report variable\n\n\tif (jstat < 0) {\n\t    throw runtime_error(\"Error occured inside call to SISL routine s1240.\");\n\t} else if (jstat > 0) {\n\t    cerr << \"WARNING: warning occured inside call to SISL routine s1240. \\n\" \n\t\t << endl;\n\t}\n\n\tcout << \"Computed length of curve: \" << length << \"\\n\";\n\n\t// cleaning up\n\tif (cv) freeCurve(cv);\n\tis.close();\n\n    } catch (exception& e) {\n\tcerr << \"Exception thrown: \" << e.what() << endl;\n\treturn 0;\n    }\n\n    return 1;\n};\n"
  },
  {
    "path": "examples/example08.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <stdexcept>\n#include <cstdlib>\n\n#include \"sisl.h\"\n#include \"GoReadWrite.h\"\n\nusing namespace std;\n\nnamespace {\n    string OUT_FILE_CURVE_1 = \"example8_curve_1.g2\";\n    string OUT_FILE_CURVE_2 = \"example8_curve_2.g2\";\n    string OUT_FILE_POINT   = \"example8_closestpoints.g2\";\n\n    string DESCRIPTION = \n    //==========================================================\n    \"This program generates two non-intersecting curves (from \\n\"\n    \"internal data), and computes their mutual closest points, \\n\"\n    \"using SISL routine s1955.  The curves will be saved to the \\n\"\n    \"two files '\" + OUT_FILE_CURVE_1 + \"' and '\" + OUT_FILE_CURVE_2 + \"'\\n\"\n    \"The closest points will be saved to the file '\" + OUT_FILE_POINT + \"'\\n\\n\";\n\n\n    const int dim = 3;\n\n    const int c1_number = 4;\n    const int c1_order = 4;\n    \n    double c1_coef[] = {0, 0, 0,\n\t\t\t0, 1, 0,\n\t\t\t1, 1, 0,\n\t\t\t1, 0, 0};\n\n    double c1_knots[] = {0, 0, 0, 0, 1, 1, 1, 1};\n\n    const int c2_number = 4;\n    const int c2_order = 4;\n    \n    double c2_coef[] = {-2,   0, 0,\n                         0, 1.2, 0,\n                         1, 1.2, 0,\n\t\t\t 3,   0, 0};\n\t\t\t\n    double c2_knots[] = {0, 0, 0, 0, 1, 1, 1, 1};\n\n}; // end anonymous namespace \n\n//===========================================================================\nint main(int avnum, char** vararg)\n//===========================================================================\n{\n    cout << '\\n' << vararg[0] << \":\\n\" << DESCRIPTION << endl;\n    cout << \"To proceed, press enter, or ^C to quit.\" << endl;\n    getchar();\n\n    try {\n\tofstream os_cv1(OUT_FILE_CURVE_1.c_str());\n\tofstream os_cv2(OUT_FILE_CURVE_2.c_str());\n\tofstream os_pts(OUT_FILE_POINT.c_str());\n\tif (!os_cv1 || !os_cv2 || !os_pts) {\n\t    throw runtime_error(\"Unable to open output file.\");\n\t}\n\n\t// generating curves from internal data\n\tSISLCurve* c1 = newCurve(c1_number, // num. of control points\n\t\t\t\t c1_order,  // spline order\n\t\t\t\t c1_knots,  // knotvector\n\t\t\t\t c1_coef,   // control points\n\t\t\t\t 1,         // kind = polynomial B-spline curve\n\t\t\t\t dim,       // dimension of space (3D)\n\t\t\t\t 1);        // copy input arrays\n\n\tSISLCurve* c2 = newCurve(c2_number, // num. of control points\n\t\t\t\t c2_order,  // spline order\n\t\t\t\t c2_knots,  // knotvector\n\t\t\t\t c2_coef,   // control points\n\t\t\t\t 1,         // kind = polynomial B-spline curve\n\t\t\t\t dim,       // dimension of space (3D)\n\t\t\t\t 1);        // copy input arrays\n\t\t \n\tif(!c1 || !c2) {\n\t    throw runtime_error(\"Error occured while generating curves.\");\n\t}\n\n\t// calculating closest point\n\n \tdouble epsco = 1.0e-15; // computational epsilon\n \tdouble epsge = 1.0e-5; // geometric tolerance\n \tint num_cl_points = 0; // number of found intersection points\n \tdouble* intpar1 = 0; // parameter values for the first curve in the intersections\n \tdouble* intpar2 = 0; // parameter values for the second curve in the intersections\n \tint num_int_curves = 0;   // number of intersection curves\n \tSISLIntcurve** intcurve = 0; // pointer to array of detected intersection curves\n \tint jstat = 0; // status variable\n\n\ts1955(c1,              // first curve \n\t      c2,              // second curve\n\t      epsco,           // computational resolution\n\t      epsge,           // geometry resolution\n\t      &num_cl_points,  // number of single closest points\n\t      &intpar1,        // pointer to array of parameter values for curve 1\n\t      &intpar2,        //               \"                      for curve 2\n\t      &num_int_curves, // number of detected intersection curves\n\t      &intcurve,       // pointer to array of detected intersection curves.\n\t      &jstat);\n\t\n\tif (jstat < 0) {\n\t    throw runtime_error(\"Error occured inside call to SISL routine s1955.\");\n\t} else if (jstat > 0) {\n\t    cerr << \"WARNING: warning occured inside call to SISL routine s1955. \\n\" \n\t\t << endl;\n\t}\n\n \t// In this example, we do not expect to find intersection curves, since the\n \t// input curves do not intersect at all.\n\n \tcout << \"Number of pairs of closest points detected: \" << num_cl_points << endl;\n \tcout << \"Number of intersection curves detected: \" << num_int_curves << endl;\n\t\n\t// evaluating closest points and writing them to file\n\tvector<double> point_coords_3D(3 * num_cl_points * 2);\n\tint i;\n\tfor (i = 0; i < num_cl_points; ++i) {\n\t    // calculating closest point on curve 1\n\t    int temp, jstat1=0, jstat2=0;\n\t    s1227(c1,         // we evaluate on the first curve\n\t\t  0,          // calculate no derivatives\n\t\t  intpar1[i], // parameter value on which to evaluate\n\t\t  &temp,      // not used for our purposes (gives parameter interval)\n\t\t  &point_coords_3D[3 * 2 * i], // result written here\n\t\t  &jstat1);\n\n\t    // calculating closest point on curve 2\n\t    s1227(c2,\n\t\t  0,\n\t\t  intpar2[i],\n\t\t  &temp,\n\t\t  &point_coords_3D[3 * 2 * i + 3],\n\t\t  &jstat2);\n\n\t    if (jstat1 < 0 || jstat2 < 0) {\n\t\tthrow runtime_error(\"Error occured inside call to SISL routine s1227.\");\n\t    } else if (jstat1 > 0 || jstat2 > 0) {\n\t\tcerr << \"WARNING: warning occured inside call to SISL routine s1227. \\n\" \n\t\t     << endl;\n\t    }\n\t}\n\n\t// writing curves and intersections to file\n\twriteGoCurve(c1, os_cv1);\n\twriteGoCurve(c2, os_cv2);\n \twriteGoPoints(num_cl_points * 2, &point_coords_3D[0], os_pts);\n\n\t// cleaning up\n\tif (c1) freeCurve(c1);\n\tif (c2) freeCurve(c2);\n\tos_cv1.close();\n\tos_cv2.close();\n\tos_pts.close();\n\tif (intpar1) free(intpar1);\n\tif (intpar2) free(intpar2);\n\tif (num_int_curves > 0)\n\t  freeIntcrvlist(intcurve, num_int_curves);\n\n    } catch (exception& e) {\n\tcerr << \"Exception thrown: \" << e.what() << endl;\n\treturn 0;\n    }\n\n    return 1;\n};\n"
  },
  {
    "path": "examples/example09.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <stdexcept>\n\n#include \"sisl.h\"\n#include \"GoReadWrite.h\"\n\nusing namespace std;\n\nnamespace {\n    string OUT_FILE_SURFACE = \"example9_surf.g2\";\n    string OUT_FILE_POINTS = \"example9_points.g2\";\n\n    string DESCRIPTION = \n    //==========================================================\n    \"This program generates a series of surfaces that \\n\"\n    \"each interpolate an array of (internally defined) points in \\n\"\n    \"3D space.  The results will be written to file in Go-format.\\n\"\n    \"The generated surfaces will be written to the file \\n\"\n    + OUT_FILE_SURFACE + \"'.  The interpolated points will be \\n\"\n    \"written to the file '\" + OUT_FILE_POINTS + \"'.  The \\n\"\n    \"interpolating routine used is s1534.  When inspecting the \\n\"\n    \"result, note the effect of the varying order of the surfaces. \\n\"\n    \"Note also the 'artificial' bumps generated due to the \\n\"\n    \"interpolation criterion.\\n\\n\";\n\n    const int num_points_u = 5; // number of points in the u parameter direction\n    const int num_points_v = 5; // number of points in the v parameter direction\n    \n    double points[] = \n\t{\n\t 0, 0, 0,      1, 0, 0,      2, 0, 0,      3, 0, 0,      4, 0, 0,\n\t 0, 1, 0,      1, 1, 0,      2, 1, 0,      3, 1, 0,      4, 1, 0,\n\t 0, 2, 0,      1, 2, 0,      2, 2, 1,      3, 2, 0,      4, 2, 0,\n\t 0, 3, 0,      1, 3, 0,      2, 3, 0,      3, 3, 0,      4, 3, 0,\n\t 0, 4, 0,      1, 4, 0,      2, 4, 0,      3, 4, 0,      4, 4, 0\n\t};\n\n    double u_par[] = {0, 1, 2, 3, 4}; // point parametrization in u-direction\n    double v_par[] = {0, 1, 2, 3, 4}; // point parametrization in v-direction\n\n    const int dim = 3; // dimension of the space we are working in\n    \n    const int num_surf = 4;\n\n    const int order_u[] = {2, 3, 4, 4};\n    const int order_v[] = {2, 3, 4, 2};\n\n}; // end anonymous namespace \n\n//===========================================================================\nint main(int avnum, char** vararg)\n//===========================================================================\n{\n    cout << '\\n' << vararg[0] << \":\\n\" << DESCRIPTION << endl;\n    cout << \"To proceed, press enter, or ^C to quit.\" << endl;\n    getchar();\n\n    try {\n\tofstream os_surf(OUT_FILE_SURFACE.c_str());\n\tofstream os_pts(OUT_FILE_POINTS.c_str());\n\tif (!os_surf || !os_pts) {\n\t    throw runtime_error(\"Unable to open output file.\");\n\t}\n\n\t// generating interpolating surface\n\tfor (int i = 0; i < num_surf; ++i) {\n\n\t    SISLSurf* result_surf = 0;\n\t    int jstat = 0;\n\n\t    s1537(points,       // pointer to the array of points to interpolate\n\t\t  num_points_u, // number of interpolating points along the 'u' parameter\n\t\t  num_points_v, // number of interpolating points along the 'v' parameter\n\t\t  dim,          // dimension of the Euclidean space\n\t\t  u_par,        // pointer to the 'u' parameter values of the points\n\t\t  v_par,        // pointer to the 'v' parameter values of the points\n\t\t  0,            // no additional condition along edge 1\n\t\t  0,            // no additional condition along edge 2\n\t\t  0,            // no additional condition along edge 3\n\t\t  0,            // no additional condition along edge 4\n\t\t  order_u[i],   // the order of the generated surface in the 'u' parameter\n\t\t  order_v[i],   // the order of the generated surface in the 'v' parameter\n\t\t  1,            // open surface in the u direction\n\t\t  1,            // open surface in the v direction \n\t\t  &result_surf, // the generated surface\n\t\t  &jstat);      // status variable\n\t    if (jstat < 0) {\n\t\tthrow runtime_error(\"Error occured inside call to SISL routine s1537.\");\n\t    } else if (jstat > 0) {\n\t\tcerr << \"WARNING: warning occured inside call to SISL routine s1537. \\n\" \n\t\t     << endl;\n\t    }\n\t    \n\t    // writing surface and interpolated points to file\n\t    writeGoSurface(result_surf, os_surf);\n\t    \n\t    if (result_surf) freeSurf(result_surf);\n\t}\n\n\twriteGoPoints(num_points_u * num_points_v, points, os_pts);\n\n\t// cleaning up\n\tos_surf.close();\n\tos_pts.close();\n\n    } catch (exception& e) {\n\tcerr << \"Exception thrown: \" << e.what() << endl;\n\treturn 0;\n    }\n\n    return 1;\n};\n"
  },
  {
    "path": "examples/example10.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <stdexcept>\n#include <cstdlib>\n\n#include \"sisl.h\"\n#include \"GoReadWrite.h\"\n\nusing namespace std;\n\nnamespace {\n    string OUT_FILE_CURVES = \"example10_curves.g2\";\n    string OUT_FILE_SURFACE = \"example10_surf.g2\";\n\n    string DESCRIPTION = \n    //==========================================================\n    \"This program generates a series of curves, and then  \\n\"\n    \"generates a lofted surface through these curves.  The \\n\"\n    \"routine used is s1538.  The resulting curves and surfaces \\n\"\n    \" are written respectively to '\" + OUT_FILE_CURVES + \"' and\\n\"\n    \"'\" + OUT_FILE_SURFACE + \"'.\\n\\n\";\n    //==========================================================\n\n    const int num_curves = 16;\n    const int num_control_points = 4;\n    const int curve_order = 4;\n    const int loft_order = 4;\n    \n    // defining coefficients for the first of the curves\n    double curve_coef[] = {0, 0, 0,\n\t\t\t   1, 2, 0,\n\t\t\t   2, 3, 0,\n\t\t\t   3, 0, 0};\n\n    // defining the knotvector of the curve\n    double curve_kvec[] = {0, 0, 0, 0, 1, 1, 1, 1};\n\n    // values used to successfully change the curve shape\n    const double x_dilate = 1.15;\n    const double y_increment = 2;\n    const double z_increment = 2;\n    \n    void incrementally_change_control_points();\n\n}; // end anonymous namespace \n\n//===========================================================================\nint main(int avnum, char** vararg)\n//===========================================================================\n{\n    cout << '\\n' << vararg[0] << \":\\n\" << DESCRIPTION << endl;\n    cout << \"To proceed, press enter, or ^C to quit.\" << endl;\n    getchar();\n\n    try {\n\tofstream os_curves(OUT_FILE_CURVES.c_str());\n\tofstream os_surf(OUT_FILE_SURFACE.c_str());\n\tif (!os_surf || !os_curves) {\n\t    throw runtime_error(\"Unable to open output file.\");\n\t}\n\n\t// generating series of curves\n\tvector<SISLCurve*> curves(num_curves);\n\tfor (int c = 0; c < num_curves; ++c) {\n\t    curves[c] = newCurve(num_control_points, // number of curve control points\n\t\t\t\t curve_order,        // the order of the curve \n\t\t\t\t curve_kvec,         // pointer to the knotvector\n\t\t\t\t curve_coef,         // pointer to the control points,\n\t\t\t\t 1,                  // kind = 1: polynomial spline curve\n\t\t\t\t 3,                  // dimension of Euclidean space\n\t\t\t\t 1);                 // copy input arrays\n\t    if (!curves[c]) {\n\t\tthrow runtime_error(\"Unable to generate curve.\");\n\t    }\n\n\t    incrementally_change_control_points();\n\n\t    // writing curve to file\n\t    writeGoCurve(curves[c], os_curves);\n\t}\n\n\t// generating lofted surface\n\tSISLSurf* result_surf = 0;\n\tdouble* gpar = 0;\n\tvector<int> cv_type(num_curves, 1); // to indicate that all curves are 'ordinary'\n\tint jstat = 0;\n\t\n\ts1538(num_curves,   // the number of curves that are used to generate the lofted surf.\n\t      &curves[0],   // pointer to the array of input curves\n\t      &cv_type[0],  // indicate the type of the input curves\n\t      0,            // start parameter for lofting direction\n\t      1,            // flag telling that the surface should be open\n\t      loft_order,   // order of the surface in the lofting direction\n\t      0,            // do not adjust tangents in the derivative curve\n\t      &result_surf, // the resulting surface\n\t      &gpar,        // get the parametrization along the lofted dir \n\t      &jstat);      // status variable\n\tif (jstat < 0) {\n\t    throw runtime_error(\"Error occured inside call to SISL routine s1538.\");\n\t} else if (jstat > 0) {\n\t    cerr << \"WARNING: warning occured inside call to SISL routine s1538. \\n\" \n\t\t << endl;\n\t}\n\n\t// writing surface to file\n\twriteGoSurface(result_surf, os_surf);\n\n\t// cleaning up\n\tif (gpar) free(gpar);\n\tfor (int i = 0; i < num_curves; ++i) {\n\t  if (curves[i]) freeCurve(curves[i]);\n\t}\n\tif (result_surf) freeSurf(result_surf);\n\tos_surf.close();\n\tos_curves.close();\n\n    } catch (exception& e) {\n\tcerr << \"Exception thrown: \" << e.what() << endl;\n\treturn 0;\n    }\n\n    return 1;\n};\n\nnamespace {\n\nvoid incrementally_change_control_points()\n{\n    // incremental change in control points, so that the next curve will differ\n    // (Feel free to experiment with your own formulas here!)\n\n    for (int p = 0; p < num_control_points; ++p) {\n\t// incrementing z value\n\tcurve_coef[3 * p + 0] *= x_dilate;\n\tcurve_coef[3 * p + 2] += z_increment;\n\t    }\n    curve_coef[3 * 1 + 1] -= 0.1 * y_increment;  // subtract increment value here\n    curve_coef[3 * 2 + 1] += y_increment;  // add the increment value here\n}\n\n}; // end anonymous namespace\n"
  },
  {
    "path": "examples/example11.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <stdexcept>\n\n#include \"sisl.h\"\n#include \"GoReadWrite.h\"\n\nusing namespace std;\n\nnamespace {\n    string OUT_FILE_SURFACE = \"example11_surf.g2\";\n\n    string DESCRIPTION = \n    //==========================================================\n    \"This program generates a cylindrical surface and saves it \\n\"\n    \"to the file '\" + OUT_FILE_SURFACE + \"'.\\n\\n\";\n    //==========================================================\n\n    double bottom_pos[] = {10, 1, -1};\n    double bottom_axis[] = {5, 0, 0};\n    double ellipse_ratio = 1.2;\n    double axis_dir[] = {0, 0, 1};\n    double height = 35;\n\n}; // end anonymous namespace \n\n//===========================================================================\nint main(int avnum, char** vararg)\n//===========================================================================\n{\n    cout << '\\n' << vararg[0] << \":\\n\" << DESCRIPTION << endl;\n    cout << \"To proceed, press enter, or ^C to quit.\" << endl;\n    getchar();\n\n    try {\n\tofstream os_surf(OUT_FILE_SURFACE.c_str());\n\tif (!os_surf) {\n\t    throw runtime_error(\"Unable to open output file.\");\n\t}\n\n\tSISLSurf* result_surf = 0;\n\tint jstat = 0;\n\t\n\t// generating the surface\n\ts1021(bottom_pos,      // bottom position of the cylinder\n\t      bottom_axis,     // the axis of the base of the cylinder\n\t      ellipse_ratio,   // the ellipticalness of the base of the cylinder\n\t      axis_dir,        // direction of the main axis\n\t      height,          // height of the cylinder\n\t      &result_surf,    // resulting surface\n\t      &jstat);         // status variable\n\tif (jstat < 0) {\n\t    throw runtime_error(\"Error occured inside call to SISL routine s1024.\");\n\t} else if (jstat > 0) {\n\t    cerr << \"WARNING: warning occured inside call to SISL routine s1024. \\n\" \n\t\t << endl;\n\t}\n\n\t// writing surface to file\n\twriteGoSurface(result_surf, os_surf);\n\n\t// cleaning up\n\tif (result_surf) freeSurf(result_surf);\n\tos_surf.close();\n\n    } catch (exception& e) {\n\tcerr << \"Exception thrown: \" << e.what() << endl;\n\treturn 0;\n    }\n\n    return 1;\n};\n\n"
  },
  {
    "path": "examples/example12.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <stdexcept>\n#include <cstdlib>\n\n#include \"sisl.h\"\n#include \"GoReadWrite.h\"\n\nusing namespace std;\n\nnamespace {\n    string IN_FILE_CURVE = \"example4_curve.g2\";\n    string IN_FILE_SURFACE = \"example10_surf.g2\";\n    string OUT_FILE_POINT   = \"example12_isectpoints.g2\";\n\n    string DESCRIPTION = \n    //==========================================================\n    \"This program computes all intersection points between a \\n\"\n    \"curve and a surface.  The curve and surface in question has \\n\"\n    \"been generated by earlier example programs (example4 and \\n\"\n    \"example10), so you should run these first.  The resulting \\n\"\n    \"points will be written to the file '\" + OUT_FILE_POINT + \"'.\\n\\n\";\n    //==========================================================\n\n}; // end anonymous namespace \n\n//===========================================================================\nint main(int avnum, char** vararg)\n//===========================================================================\n{\n    cout << '\\n' << vararg[0] << \":\\n\" << DESCRIPTION << endl;\n    cout << \"To proceed, press enter, or ^C to quit.\" << endl;\n    getchar();\n\n    try {\n\tifstream is_cv(IN_FILE_CURVE.c_str());\n\tifstream is_sf(IN_FILE_SURFACE.c_str());\n\tif (!is_cv || !is_sf) {\n\t    throw runtime_error(\"Could not open input files.  Have you run \"\n\t\t\t\t\"the necessary example programs? (example4 \"\n\t\t\t\t\"and example 10).\");\n\t}\n\tofstream os(OUT_FILE_POINT.c_str());\n\tif (!os) {\n\t    throw runtime_error(\"Unable to open output file.\");\n\t}\n\n\t// reading curve and surface\n\tSISLCurve* curve = readGoCurve(is_cv);\n\tSISLSurf* surf = readGoSurface(is_sf);\n\n\t// calculating intersection points\n\tdouble epsco = 1.0e-15; // computational epsilon\n\tdouble epsge = 1.0e-5; // geometric tolerance\n\tint num_int_points = 0; // number of detected intersection points\n\tdouble* intpar_surf  = 0; // parameter values for the surface in the intersections\n\tdouble* intpar_curve = 0; // parameter values for the curve in the intersections\n\tint num_int_curves = 0;   // number of intersection curves\n\tSISLIntcurve** intcurve = 0; // pointer to array of detected intersection curves\n\tint jstat = 0; // status variable\n\n\ts1858(surf,            // the surface\n\t      curve,           // the curve\n\t      epsco,           // computational resolution\n\t      epsge,           // geometry resolution\n\t      &num_int_points, // number of single intersection points\n\t      &intpar_surf,    // pointer to array of parameter values for the surface\n\t      &intpar_curve,   //               -\"-                    for the curve\n\t      &num_int_curves, // number of detected intersection curves\n\t      &intcurve,       // pointer to array of detected intersection curves.\n\t      &jstat);         // status variable\n\t\n\tif (jstat < 0) {\n\t    throw runtime_error(\"Error occured inside call to SISL routine s1858.\");\n\t} else if (jstat > 0) {\n\t    cerr << \"WARNING: warning occured inside call to SISL routine s1858. \\n\" \n\t\t     << endl;\n\t}\n\n\t// In this example, we do not expect to find intersection curves, since the \n\t// assumed curve does not lie in the surface at any interval with measure > 0.\n\n\tcout << \"Number of intersection points detected: \" << num_int_points << endl;\n\tcout << \"Number of intersection curves detected: \" << num_int_curves << endl;\n\t\n\t// evaluating intersection points and writing them to file\n\tvector<double> point_coords_3D(3 * num_int_points);\n\tint i;\n\tfor (i = 0; i < num_int_points; ++i) {\n\t    // calculating position, using the curve\n\t    // (we could also have used the surface, which would give approximately\n\t    // the same points).\n\t    int temp;\n\t    s1227(curve,           // we evaluate on the first curve\n\t\t  0,               // calculate no derivatives\n\t\t  intpar_curve[i], // parameter value on which to evaluate\n\t\t  &temp,           // not used for our purposes (gives parameter interval)\n\t\t  &point_coords_3D[3 * i], // result written here\n\t\t  &jstat);         // status variable\n\t    if (jstat < 0) {\n\t\tthrow runtime_error(\"Error occured inside call to SISL routine s1227.\");\n\t    } else if (jstat > 0) {\n\t\tcerr << \"WARNING: warning occured inside call to SISL routine s1227. \\n\" \n\t\t     << endl;\n\t    }\n\t}\n\n\t// writing intersection points to file\n\twriteGoPoints(num_int_points, &point_coords_3D[0], os);\n\n\t// cleaning up\n\tif (surf) freeSurf(surf);\n\tif (curve) freeCurve(curve);\n\tos.close();\n\tis_sf.close();\n\tis_cv.close();\n\tif (intpar_surf) free(intpar_surf);\n\tif (intpar_curve) free(intpar_curve);\n\tif (num_int_curves > 0)\n\t  freeIntcrvlist(intcurve, num_int_curves);\n\n    } catch (exception& e) {\n\tcerr << \"Exception thrown: \" << e.what() << endl;\n\treturn 0;\n    }\n\n    return 1;\n};\n"
  },
  {
    "path": "examples/example13.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Department of Mathematics and Cybernetics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                   \n\n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <stdexcept>\n#include <cstdlib>\n\n#include \"sisl.h\"\n#include \"GoReadWrite.h\"\n\nusing namespace std;\n\nnamespace {\n    string IN_FILE_SURFACE_1 = \"example10_surf.g2\";\n    string IN_FILE_SURFACE_2 = \"example11_surf.g2\";\n    string OUT_FILE_CURVE   = \"example13_isectcurves.g2\";\n\n    string DESCRIPTION = \n    //==========================================================\n    \"This program computes the intersection curves between two \\n\"\n    \"surfaces.  The two surfaces used have been generated by \\n\"\n    \"earlier example programs (example10 and example11), so you\\n\"\n    \"should run these first. The filenames for these surfaces \\n\"\n    \"are '\" + IN_FILE_SURFACE_1 + \"' and '\" + IN_FILE_SURFACE_2 +\n    \"'.  \\n The resulting curves will be written to the file \\n'\" \n    + OUT_FILE_CURVE + \"'.\\n\\n\";\n    //==========================================================\n\n}; // end anonymous namespace \n\n//===========================================================================\nint main(int avnum, char** vararg)\n//===========================================================================\n{\n    cout << '\\n' << vararg[0] << \":\\n\" << DESCRIPTION << endl;\n    cout << \"To proceed, press enter, or ^C to quit.\" << endl;\n    getchar();\n\n    try {\n\tifstream is_sf1(IN_FILE_SURFACE_1.c_str());\n\tifstream is_sf2(IN_FILE_SURFACE_2.c_str());\n\tif (!is_sf1 || !is_sf2) {\n\t    throw runtime_error(\"Could not open input files.  Have you run \"\n\t\t\t\t\"the necessary example programs? (example10 \"\n\t\t\t\t\"and example11).\");\n\t}\n\n\tofstream os(OUT_FILE_CURVE.c_str());\n\tif (!os) {\n\t    throw runtime_error(\"Unable to open output file.\");\n\t}\n\n\t// reading surfaces\n\tSISLSurf* surf_1 = readGoSurface(is_sf1);\n\tSISLSurf* surf_2 = readGoSurface(is_sf2);\n\n\t// detecting (but not tracing out) intersection curves\n\tdouble epsco = 1.0e-15; // computational epsilon\n\tdouble epsge = 1.0e-5; // geometric tolerance\n\tint num_int_points = 0; // number of detected intersection points\n\tdouble* intpar_surf_1  = 0; // parameter values for the surface in the intersections\n\tdouble* intpar_surf_2 = 0; // parameter values for the curve in the intersections\n\tint num_int_curves = 0;   // number of intersection curves\n\tSISLIntcurve** intcurve = 0; // pointer to array of detected intersection curves\n\tint jstat = 0; // status variable\n\n\t// calculating topology of intersections\n\ts1859(surf_1,          // the first surface\n\t      surf_2,          // the second surface\n\t      epsco,           // computational resolution\n\t      epsge,           // geometry resolution\n\t      &num_int_points, // number of single intersection points\n\t      &intpar_surf_1,  // pointer to array of parameter values for surface 1\n\t      &intpar_surf_2,  //               -\"-                    for surface 2\n\t      &num_int_curves, // number of detected intersection curves\n\t      &intcurve,       // pointer to array of detected intersection curves.\n\t      &jstat);         // status variable\n\t\n\tif (jstat < 0) {\n\t    throw runtime_error(\"Error occured inside call to SISL routine s1859.\");\n\t} else if (jstat > 0) {\n\t    cerr << \"WARNING: warning occured inside call to SISL routine s1859. \\n\" \n\t\t << endl;\n\t}\n\n\t// In this example, we expect to detect two intersection curves, but no isolated\n\t// intersection points.\n\n\tcout << \"Number of intersection points detected: \" << num_int_points << endl;\n\tcout << \"Number of intersection curves detected: \" << num_int_curves << endl;\n\t\n\t// evaluating (tracing out) intersection curves and writing them to file\n\tint i;\n\tfor (i = 0; i < num_int_curves; ++i) {\n\t    s1310(surf_1,          // the first surface\n\t\t  surf_2,          // the second surface\n\t\t  intcurve[i],     // pointer to the intersection curve object \n\t\t  epsge,           // geometric tolerance\n\t\t  double(0),       // maximum step size (ignored if <= 0)\n\t\t  1,               // make only 3D curve (no 2D curve in parametric domain)\n\t\t  0,               // don't draw the curve\n\t\t  &jstat);\n\t    if (jstat < 0) {\n\t\tthrow runtime_error(\"Error occured inside call to SISL routine s1310.\");\n\t    } else if (jstat == 3) {\n\t\tthrow runtime_error(\"Iteration stopped due to singular point or degenerate \"\n\t\t\t\t    \"surface.\");\n\t    }\n\t    writeGoCurve(intcurve[i]->pgeom, os);\n\t}\n\n\t// cleaning up\n\tif (surf_1) freeSurf(surf_1);\n\tif (surf_2) freeSurf(surf_2);\n\tis_sf1.close();\n\tis_sf2.close();\n\tos.close();\n\tif (intpar_surf_1) free(intpar_surf_1);\n\tif (intpar_surf_2)  free(intpar_surf_2);\n\tif (num_int_curves > 0)\n\t  freeIntcrvlist(intcurve, num_int_curves);\n\tif (intcurve) free(intcurve);\n\t\n    } catch (exception& e) {\n      cerr << \"Exception thrown: \" << e.what() << endl;\n      return 0;\n    }\n\n    return 1;\n};\n"
  },
  {
    "path": "examples/example14.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <algorithm>\n#include <stdexcept>\n\n#include \"sisl.h\"\n#include \"GoReadWrite.h\"\n\nusing namespace std;\n\nnamespace {\n    string OUT_FILE_POINTS = \"example14_points.g2\";\n    string OUT_FILE_CURVE = \"example14_curve.g2\";\n\n    string DESCRIPTION = \n    //==========================================================\n    \"This program demonstrates one of the data reduction \\n\"\n    \"capabilities in SISL.  It generates a dense point set by \\n\"\n    \"sampling from a predefined curve, and then try to generate \\n\"\n    \"a curve that fits closely to to these samples, using as few \\n\"\n    \"control points as possible.  (In our case, since we know that \\n\"\n    \"the points were sampled from a simple curve, we already \\n\"\n    \"have knowledge about the ideal solution to this problem). \\n\"\n    \"The sampled points will be saved to the file '\" + OUT_FILE_POINTS + \"'\\n\"\n    \"and the generated curve will be saved to the file \\n'\"\n    + OUT_FILE_CURVE + \"'.\\n\\n\";\n    //==========================================================\n\n\n    // information for the sample curve (a simple parabola)\n    const int number = 3;\n    const int order = 3;\n    \n    double coef[] = {0, 0, 0,\n\t\t     1, 1, 0,\n\t\t     2, 0, 0};\n    \n    double knots[] = {0, 0, 0, 1, 1, 1};\n    \n    const int num_samples = 500;\n\n}; // end anonymous namespace \n\n//===========================================================================\nint main(int avnum, char** vararg)\n//===========================================================================\n{\n    cout << '\\n' << vararg[0] << \":\\n\" << DESCRIPTION << endl;\n    cout << \"To proceed, press enter, or ^C to quit.\" << endl;\n    getchar();\n\n    try {\n\tofstream os_pts(OUT_FILE_POINTS.c_str());\n\tofstream os_cv(OUT_FILE_CURVE.c_str());\n\tif (!os_pts || !os_cv) {\n\t    throw runtime_error(\"Unable to open output file.\");\n\t}\n\t\n\t// generating sample curve\n\tSISLCurve* sample_curve = \n\t    newCurve(number, // number of control points\n\t\t     order,  // order of spline curve (degree + 1)\n\t\t     knots,  // pointer to knot vector (parametrization)\n\t\t     coef,   // pointer to coefficient vector (control points)\n\t\t     1,      // kind = polynomial B-spline curve\n\t\t     3,      // dimension\n\t\t     0);     // no copying of information, 'borrow' arrays\n\tif (!sample_curve) {\n\t    throw runtime_error(\"Error occured while generating curve.\");\n\t}\n\n\t// sampling curve densely\n\tvector<double> sampled_point_coords(3 * num_samples);\n\tfor (int i = 0; i < num_samples; ++i) {\n\t    double parameter = double(i)/(num_samples - 1);\n\t    int temp, jstat = 0;\n\n\t    s1227(sample_curve, // the curve to sample from\n\t\t  0,            // calculate no derivatives\n\t\t  parameter,    // sample in this parameter\n\t\t  &temp,        // not used for our purposes (returns parameter interval)\n\t\t  &sampled_point_coords[3 * i], // sampled point written here\n\t\t  &jstat); // status\n\t    if (jstat < 0) {\n\t\tthrow runtime_error(\"Error occured inside call to SISL routine s1227.\");\n\t    } else if (jstat > 0) {\n\t\tcerr << \"WARNING: warning occured inside call to SISL routine 1227.\"\n\t\t     << endl;\n\t    }\n\t}\n\n\t//generating approximating curve\n\tSISLCurve* result_curve = 0;\n\tconst double tolerance = 1.0e-5; // pointwise tolerance\n\tconst double afctol = 0.1; // number between 0 and 1 describing how tolerance\n\t                           // is to be distributed in two different steps of the\n\t                           // algorithm.\n\tconst int max_iterations = 150;\n\tvector<double> tolerance_vec(num_samples, tolerance); // same tolerance for all samples\n\tvector<double> emxerr(num_samples);\n\tint jstat = 0;\n\n\ts1961(&sampled_point_coords[0], // array of points to be approximated\n\t      num_samples,              // number of sample points\n\t      3,                        // dimension of Euclidean space\n\t      2,                        // flag indicating uniform parametrization\n\t      NULL,                     // we do not use this argument\n\t      &tolerance_vec[0],        // the pointwise tolerance\n\t      0,                        // number of fixed derivatives at left\n\t      0,                        // number of fixed derivatives at right\n\t      1,                        // flag indicating that we want an open curve\n\t      afctol,                   // distribution of tolerance\n\t      max_iterations,           // maximum number of iterations in the routine\n\t      3,                        // polynomial order of approximation\n\t      &result_curve,            // pointer to the generated curve\n\t      &emxerr[0],               // reporting the max deviation in each point\n\t      &jstat);                  // status variable\n\n\tif (jstat < 0) {\n\t    throw runtime_error(\"Error occured inside call to SISL routine s1961.\");\n\t} else if (jstat > 0) {\n\t    cerr << \"WARNING: warning occured inside call to SISL routine s1961. \\n\" \n\t\t << endl;\n\t}\n\t\n\tcout << \"Number of initial data points: \" << num_samples << endl;\n\tcout << \"Number of control points in final approximation: \" << result_curve->in << endl;\n\tcout << \"Max pointwise error is : \" << *(max_element(emxerr.begin(), emxerr.end()));\n\tcout << endl << endl;\n\n\t// saving to file\n\twriteGoPoints(num_samples, &sampled_point_coords[0], os_pts);\n\twriteGoCurve(result_curve, os_cv);\n\n\t// cleaning up\n\tif (result_curve) freeCurve(result_curve);\n\tos_pts.close();\n\tos_cv.close();\n\n    } catch (exception& e) {\n\tcerr << \"Exception thrown: \" << e.what() << endl;\n\treturn 0;\n    }\n\n    return 1;\n};\n"
  },
  {
    "path": "examples/example15.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <limits>\n#include <iostream>\n#include <fstream>\n#include <string>\n#include <stdexcept>\n#include <time.h>\n#include <cstdlib>\n\n#include \"sisl.h\"\n#include \"GoReadWrite.h\"\n\nusing namespace std;\n\nnamespace {\n    string OUT_FILE_POINTS = \"example15_points.g2\";\n    string IN_FILE_SURFACE = \"example10_surf.g2\";\n\n    string DESCRIPTION = \n    //==========================================================\n    \"This program will do a simple ray-tracing of a bspline \\n\"\n    \"surface.  From one point P in space, we will extend lines \\n\"\n    \"('rays') towards the surface, and calculate the point where \\n\"\n    \"the line intersects with the surface.  All points obtained \\n\"\n    \"in this way thus describe how the surface is 'visible' from \\n\"\n    \"P.  They will be stored to the file '\" + OUT_FILE_POINTS + \"'\\n\"\n    \"The surface used is the one generated by 'example10', namely \\n\"\n    + IN_FILE_SURFACE + \"'.\\n\\n\"\n    \"Note that in this program, two ray-tracing routines are \\n\"\n    \"provided; (1) one slow and robust one, which would always \\n\"\n    \"work, and one quick but more fragile one (2), which bases \\n\"\n    \"its point estimates on previously obtained results, and \\n\"\n    \"thus is likely to fail when some parts of a surface shadows \\n\"\n    \"other parts.  The default method is (1); however the user \\n\"\n    \"can invoke the quick method by running the program with the\\n\"\n    \"additional argument 'q' (quick).  An examination of the \\n\"\n    \"obtained point cloud will in this case reveal erroneous \\n\"\n    \"behaviour where the examined surface 'folds over' itself.\\n\"\n    \"The user will notice, though, that the execution time is \\n\"\n    \"significantly shorter.  This method is therefore useful in\\n\"\n    \"some cases where surfaces are not self-obstructing.\\n\\n\";\n    //==========================================================\n \n    double P[] = {0, 0, -30};\n\n    // definition of view window\n    const double WIN_LL[] = {-5, -5, -10}; // lower left corner\n    const double WIN_LR[] = { 5, -5, -10}; // lower right corner\n    const double WIN_UL[] = {-5,  5, -10}; // upper left corner\n    const double WIN_UR[] = { 5,  5, -10}; // upper right corner\n    \n    const int HRES = 200;\n    const int VRES = 200;\n\n    const double EPSGE = 1.0e-5;  // geometrical tolerance\n    const double EPSCO = 1.0e-15; // computational tolerance\n\n    void raytracer_simple(SISLSurf* surf, vector<double>& points);\n    void raytracer_advanced(SISLSurf* surf, vector<double>& points);\n    void calculate_direction(int vscan, int hscan, double* dir);\n    bool trace_ray_robust(SISLSurf* surf, double* param_val, double* dir);\n    bool trace_ray_rapid(SISLSurf* surf, double* init_guess, double* dir) ;\n\n    bool USE_LOCAL_METHOD = false;\n}; // end anonymous namespace \n\n//===========================================================================\nint main(int varnum, char** vararg)\n//===========================================================================\n{\n    cout << '\\n' << vararg[0] << \":\\n\" << DESCRIPTION << endl;\n    cout << \"To proceed, press enter, or ^C to quit.\" << endl;\n    getchar();\n\n    try {\n\t// parsing command line argument\n\tif (varnum > 1) {\n\t    string arg1(vararg[1]);\n\t    if (arg1 == \"q\" || arg1 == \"Q\") {\n\t\tUSE_LOCAL_METHOD = true;\n\t    } else {\n\t\tcerr << \"Invalid command argument '\" << arg1 << \"' specified.\\n\";\n\t\treturn 0;\n\t    }\n\t}\n\n\tifstream is(IN_FILE_SURFACE.c_str());\n\tif (!is) {\n\t    throw runtime_error(\"Unable to open input file.\");\n\t}\n\tofstream os(OUT_FILE_POINTS.c_str());\n\tif (!os) {\n\t    throw runtime_error(\"Unable to open output file.\");\n\t}\n\n\t// read surface to be raytraced\n\tSISLSurf* surf = readGoSurface(is);\n\tvector<double> points;\n\n\t// the complete raytracing is carried out here\n\tclock_t starttime = clock();\n\tif ( ! USE_LOCAL_METHOD ) {\n\t    raytracer_simple(surf, points);\n\t} else {\n\t    raytracer_advanced(surf, points);\n\t}\n\tclock_t endtime = clock();\n\tcout << \"Time used: \" << (endtime - starttime) / double(1000) << endl;\n\n\t// saving to file\n\twriteGoPoints(points.size() / 3, &points[0], os);\n\n\t// cleaning up\n\tif (surf) freeSurf(surf);\n\tis.close();\n\tos.close();\n\n    } catch (exception& e) {\n\tcerr << \"Exception thrown: \" << e.what() << endl;\n\treturn 0;\n    }\n\n    return 1;\n};\n\nnamespace {\n\nvoid raytracer_simple(SISLSurf* surf, vector<double>& points)\n{\n    // a simple, slow and robust raytracer.  It scans the view\n    // line by line, and find all intersections with the\n    // current line and the surface.  When several intersections are found,\n    // the one closest to the viewpoint (P) is chosen.\n    points.clear();\n    double dir[3];\n    double param_val[2];\n    for (int vscan = 0; vscan < VRES; ++vscan) {\n\tfor (int hscan = 0; hscan < HRES; ++hscan) {\n\t    calculate_direction(vscan, hscan, dir);\n\t    bool found = trace_ray_robust(surf, param_val, dir);\n\t    if (found) {\n\t\tpoints.insert(points.end(), &dir[0], &dir[3]);\n\t    }\n\t}\n    }\n}\n\nvoid raytracer_advanced(SISLSurf* surf, vector<double>& points)\n{\n    // A relatively quick raytracer, scanning the view line by line,\n    // and using previously found points as estimates for detecting new\n    // ones, thus speeding up the location of intersections.  However,\n    // this is likely to give rise to points on hidden parts of the surface\n    // if the surface 'hides' parts of itself as seen from the vieweing\n    // point.  To avoid this problem, either the 'raytracer_simple' routine\n    // should be used, or this routine should be elaborated to take into\n    // account non-local properties of the surface.\n    points.clear();\n    double dir[3];\n    double param_val[2];\n    param_val[0] = surf->et1[surf->ik1 - 1] - 1;\n    param_val[1] = surf->et2[surf->ik2 - 1] - 1;\n    bool hscan_forwards = true;\n    int start, stop, inc;\n    bool found_last = false;\n\n    for (int vscan = 0; vscan < VRES; ++vscan) {\n\tstart = hscan_forwards ? 0 : HRES;\n\tstop  = hscan_forwards ? HRES - 1 : -1;\n\tinc   = hscan_forwards ? 1 : -1;\n\thscan_forwards = !hscan_forwards;\n\n\tfor (int hscan = start; hscan != stop; hscan += inc) {\n\t    calculate_direction(vscan, hscan, dir);\n\t    if (found_last) {\n\t\tfound_last = trace_ray_rapid(surf, param_val, dir);\n\t    } else {\n\t\tfound_last = trace_ray_robust(surf, param_val, dir);\n\t    }\n \t    if (found_last) {\n \t\tpoints.insert(points.end(), &dir[0], &dir[3]);\n\t    } \n\t}\n    }\n}\n\nvoid calculate_direction(int vscan, int hscan, double* dir)\n{\n    // find the direction of the 'line-of-sight', as seen from the point \n    // P through the 'window' specified by WIN_LL, WIN_LR, WIN_UL and WIN_UR.\n    double v_ratio = double(vscan) / double(VRES - 1);\n    double h_ratio = double(hscan) / double(HRES - 1);\n    for (int d = 0; d < 3; ++d) {\n\tdir[d] = (1-h_ratio) * ((1-v_ratio) * WIN_LL[d] + v_ratio * WIN_LR[d]) +\n\t    h_ratio * ((1-v_ratio) * WIN_UL[d] + v_ratio * WIN_UR[d]) - P[d];\n    }\n}\n\nbool trace_ray_rapid(SISLSurf* surf, double* init_guess, double* dir) \n{\n    // Rapidly find the intersection of a ray with the surface, provided \n    // we have a good initial guess for the parameters in that point ('init_guess').\n    // If this is not the case, the routine will invoke the slower\n    // 'trace_ray_robust' routine.\n\n    // caching of parameter domain in order to save time\n    static double start_dom[2];\n    static double end_dom[2];\n    static SISLSurf* cached_surf = 0;\n    if (surf != cached_surf) {\n\t// caching parameter domain\n\tstart_dom[0] = surf->et1[surf->ik1 - 1];\n\tstart_dom[1] = surf->et2[surf->ik2 - 1];\n\tend_dom[0] = surf->et1[surf->in1];\n\tend_dom[1] = surf->et2[surf->in2];\n\tcached_surf = surf;\n    }\n\n    if (init_guess[0] < start_dom[0]) {\n\t// there is no (valid) initial guess available\n\treturn trace_ray_robust(surf, init_guess, dir);\n    }\n\n    double isect_uv[2];\n    int jstat = 0;\n\n    // Using local properties of the surface to converge to the solution point, \n    // provided we have a 'good' initial guess.\n\n    s1518(surf,        // the surface to 'raytrace'\n\t  P,           // observer's position\n\t  dir,         // direction of ray \n\t  EPSGE,       // geometric resolution\n\t  start_dom,   // lower limit of search rectangle (umin, vmin)\n\t  end_dom,     // upper limit of search rectangle (umax, vmax)\n\t  init_guess,  // initial guess - we can use the last found value\n\t  isect_uv,    // the intersection point - if found!\n\t  &jstat);     // status\n    \n    if (jstat < 0) {\n\tcout << jstat << endl;\n\tthrow runtime_error(\"Error occurred in SISL routine s1518.\");\n    } else if (jstat != 1) {\n\t// no point found.  Resorting to robust technique\n\treturn trace_ray_robust(surf, init_guess, dir);\n    } \n    // we found a point.  Checking quality of result.\n    \n    //  do not want a point that is in reality hidden behind another, closer point.\n    // If our initial guess was good, this would not happen all too often, but once\n    // in a while, we can have 'marched across' a visible silhouette.  In order to check\n    // if we might have done such a thing, we will verify that the scalar product of the \n    // normal in the previous point with the direction 'dir' has the same sign as the\n    // scalar product of the normal in the calculated point with 'dir'.  If this is \n    // NOT the case, we will resort to the robust method\n    \n    // calculating normal for the initial guess point\n    int temp1, temp2;\n    double point[9]; // point and tangents in u and v parameter will be stored here\n    double n[3]; // normal will be stored here\n    \n    s1421(surf, // the surface in question\n\t  1,    // we need at least one derivative in order to calculate normal\n\t  init_guess, // parameter value\n\t  &temp1,   // uninteresting for our purposes - parameter interval\n\t  &temp2,   // uninteresting for our purposes - parameter interval\n\t  point,   // storage for the point and its derivatives\n\t  n,       // storage for the normal\n\t  &jstat);\n\n    if (jstat < 0) {\n\tthrow runtime_error(\"Error occurred in SISL routine s1421.\");\n    } else if (jstat > 0) {\n\t    cerr << \"WARNING: warning occured inside call to SISL routine s1857. \\n\" \n\t\t << endl;\n    }\n    double scalar_product_1 = n[0] * dir[0] + n[1] * dir[1] + n[2] * dir[2];\n    \n    // calculating normal for the found point\n    s1421(surf, // the surface in question\n\t  1,    // we need at least one derivative in order to calculate normal\n\t  isect_uv, // parameter value\n\t  &temp1,   // uninteresting for our purposes - parameter interval\n\t  &temp2,   // uninteresting for our purposes - parameter interval\n\t  point,   // storage for the point and its derivatives\n\t  n,       // storage for the normal\n\t  &jstat);\n    if (jstat < 0) {\n\tthrow runtime_error(\"Error occurred in SISL routine s1421.\");\n    } else if (jstat > 0) {\n\t    cerr << \"WARNING: warning occured inside call to SISL routine s1857. \\n\" \n\t\t << endl;\n    }\n    double scalar_product_2 = n[0] * dir[0] + n[1] * dir[1] + n[2] * dir[2];\n    if (scalar_product_1 * scalar_product_2 < 0) {\n\t// the normals are pointing in distinct directions\n\treturn trace_ray_robust(surf, init_guess, dir);\n    }\n    // if we got here, the point found in the 'rapid' way should be completely OK\n    copy(&point[0], &point[3], dir);\n    copy(&isect_uv[0], &isect_uv[2], init_guess);\n    return true;\n}\n\n\n\nbool trace_ray_robust(SISLSurf* surf, double* param_val, double* dir) \n{\n    // Find the intersection of a ray with a surface that is closest to the \n    // viewpoint P.  We do not depend on any initial guess for this point; the\n    // routine does a global search.  If several intersection points are found\n    // for the same ray, the one closest to the viewpoint P is chosen.\n\n    int num_intpoints = 0;\n    double* pointpar = 0;\n    int num_intcurves;\n    int jstat;\n    SISLIntcurve** intcurves = 0;\n\n    // intersect a surface with a line\n    s1856(surf,    // the surface to intersect with\n\t  P,       // a point on the line (in our case: the viewpoint)\n\t  dir,     // the directional vector of the line\n\t  3,       // dimension of the Euclidean space\n\t  EPSCO,   // machine (computational) tolerance\n\t  EPSGE,   // geometric tolerance\n\t  &num_intpoints,  // reports the number of intersection points found\n\t  &pointpar,       // pointer to array containing the surface parameters for the \n\t                   // found intersection points\n\t  &num_intcurves,  // returns the number of intersection curves found (usually none!)\n\t  &intcurves,      // pointer to an array containing the intersection curves found\n\t  &jstat);\n    if (jstat < 0 ) {\n\tthrow runtime_error(\"Error occured in SISL routine s1856.\");\n    } else if (jstat > 0) {\n\tcerr << \"WARNING: warning occured inside call to SISL routine s1856.\"\n\t     << endl;\n    }\n    \n    if (num_intpoints == 0) {\n\treturn false; // no intersection with ray\n    }\n    // If we got here, there was at least one intersection with the ray.  We want to find\n    // the closest one.\n    double dist = numeric_limits<double>::max();\n    int i;\n    for (i = 0; i < num_intpoints; ++i) {\n\tint temp1, temp2;\n\tdouble temp_pos[3];\n\t// calculating 3D point\n\ts1424(surf,             // input surface\n\t      0,                // evaluate position only (no derivatives in u-param)\n\t      0,                // evaluate position only (no derivatives in v-param)\n\t      &pointpar[2 * i], // parameter values\n\t      &temp1,           // unused for our purposes (returns used u-interval)\n\t      &temp2,           // unused for our purposes (returns used v-interval)\n\t      temp_pos,         // the calculated position\n\t      &jstat);          // status variable \n\tif (jstat < 0 ) {\n\t    throw runtime_error(\"Error occured in SISL routine s1424.\");\n\t} else if (jstat > 0) {\n\t    cerr << \"WARNING: warning occured inside call to SISL routine s1424.\"\n\t\t << endl;\n\t}\n\t\n\t// calculating distance of 3D point\n\tdouble cur_dist = 0;\n\tfor (int j = 0; j < 3; ++j) {\n\t    double tmp = (temp_pos[j] - P[j]);\n\t    tmp *= tmp;\n\t    cur_dist += tmp;\n\t}\n\tif (cur_dist < dist) {\n\t    dist = cur_dist;\n\t    param_val[0] = pointpar[2 * i];\n\t    param_val[1] = pointpar[2 * i + 1];\n\t    for (int k = 0; k < 3; ++k) {\n\t\tdir[k] = temp_pos[k];\n\t    }\n\t}\n    }\n    free(pointpar);\n    for (i = 0; i < num_intcurves; ++i) {\n\tfree(intcurves[i]);\n    }\n    free(intcurves);\n    return true;\n}\n\n\n}; // end anonymous namespace\n\n"
  },
  {
    "path": "include/sisl-copyright.h",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#ifndef _SISL_COPYRIGHT_H\n#define _SISL_COPYRIGHT_H\n#endif\n"
  },
  {
    "path": "include/sisl.h",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#ifndef SISL_INCLUDED\n#define SISL_INCLUDED\n\n\n/// \\mainpage SISL Documentation\n///\n/// SISL is a comprehensive NURBS library for the modeling and\n/// interrogation of curves and surfaces.\n\n\n\n/*\n * Enable function prototypes for ANSI C and C++\n * ----------------------------------------------\n*/\n\n#if defined(sgi)\n#undef SISLNEEDPROTOTYPES\n#define SISLNEEDPROTOTYPES\n#endif\n\n#if defined(__STDC__) || defined (c_plusplus) || defined (__cplusplus) || defined(__BORLANDC__)\n#undef SISLNEEDPROTOTYPES\n#define SISLNEEDPROTOTYPES\n#endif\n\n#ifdef __BORLANDC__\n# define GO_API __declspec(package)\n#elif defined(MICROSOFT) || defined(_MSC_VER)\n# if defined(__DLL__) || defined(_DLL)\n#  define GO_API __declspec(dllexport)\n# else\n#  define GO_API __declspec(dllimport)\n# endif // __DLL__\n#else\n# define GO_API\n#endif // __BORLANDC__\n\ntypedef struct SISLdir\n{\n  int igtpi;\t\t\t/* 0 - The direction of the surface or curve\n\t\t\t               is not greater than pi in any\n\t\t\t               parameter direction.\n\t\t\t           1 - The direction of the surface or curve\n\t\t\t               is greater than pi in the first\n\t\t\t               parameter direction.\n\t\t\t           2 - The direction of the surface is greater\n\t\t\t               than pi in the second parameter\n\t\t\t               direction. \t\t\t     */\n  double *ecoef;\t\t/* The coordinates to the center of the cone.*/\n  double aang;\t\t\t/* The angle from the center whice describe the\n\t\t\t           cone.\t\t\t\t     */\n  double *esmooth;\t\t/* Coordinates of object after smoothing.    */\n} SISLdir;\n /* The following structure contains 3 different boxes. The\n    first box is the plain box given by the coefficients of the\n    object. The second box is expanded with the half of a given\n    tolerance. The third box is expanded with half the tolerance\n    in the inner and for the vertices at the edges/endpoints\n    a distance of half the tolerance is removed. The minimum and\n    maximum values of the boxes are given by the arrays\n    e2min[0] - e2min[2] and e2max[0] - e2max[2]. The tolerances used\n    when making the boxes are stored in etol[0] - etol[2]. etol[0]\n    will always be equal to zero. If a box is made, the pointers\n    belonging to this box points to arrays, otherwise they point\n    to SISL_NULL.                                                       */\n\ntypedef struct SISLbox\n{\n  double *emax;\t\t\t/* The minimum values to the boxes.\t     */\n  double *emin;\t\t\t/* The maximum values to the boxes.\t     */\n  int imin;\t\t\t/* The index of the min coeff (one-dim case) */\n  int imax;\t\t\t/* The index of the max coeff (one-dim case) */\n\n  double *e2max[3];\t\t/* The minimum values dependant on tolerance.*/\n  double *e2min[3];\t\t/* The maximum values dependant on tolerance.*/\n  double etol[3];\t\t/* Tolerances of the boxes.                  */\n} SISLbox;\n\n/* Information used in intersection functionality           */\nenum /* SEGMENTATION_TYPE */\n  {\n    NO_SEG_TYPE = 0,\n    TANGENTIAL_BELT_LEFT,\n    TANGENTIAL_BELT_RIGHT,\n    ISOLATED_SING_LEFT_LEFT,\n    ISOLATED_SING_LEFT_RIGHT,\n    ISOLATED_SING_RIGHT_LEFT,\n    ISOLATED_SING_RIGHT_RIGHT,\n    LIMITING_SEG\n  };\n\nenum /* SURFACE_TYPE */\n  {\n    NO_SURFACE_TYPE = 0,\n    TANGENTIAL_BELT,\n    SINGULARITY_BOUND\n  };\n\ntypedef struct SISLSegmentation\n{\n  double *seg_val;\n  int *seg_type;   /* SEGMENTATION_TYPE */\n  int num_seg;\n} SISLSegmentation;\n\n/* This file will contain the definition of the structure SISLCurve which\n   will contain the description of a B-spline curve.                        */\n\ntypedef struct SISLCurve\n{\n  int ik;\t\t\t/* Order of curve.                           */\n  int in;\t\t\t/* Number of vertices.                       */\n  double *et;\t\t\t/* Pointer to the knotvector.                */\n  double *ecoef;\t\t/* Pointer to the array containing vertices. */\n  double *rcoef;\t\t/*Pointer to the array of scaled vertices if\n\t\t\t\t  rational.  */\n  int ikind;\t\t\t/* Kind of curve\n\t                           = 1 : Polynomial B-spline curve.\n\t                           = 2 : Rational B-spline curve.\n\t                           = 3 : Polynomial Bezier curve.\n\t                           = 4 : Rational Bezier curve.             */\n  int idim;\t\t\t/* Dimension of the space in which the curve\n\t\t\t\t   lies.      */\n  int icopy;\t\t\t/* Indicates whether the arrays of the curve\n\t\t\t\t   are copied or referenced by creation of the\n\t\t\t\t   curve.\n\t                           = 0 : Pointer set to input arrays.\n\t\t\t           = 1 : Copied.\n\t                           = 2 : Pointer set to input arrays,\n\t\t\t\t         but are to be treated as copied.   */\n  SISLdir *pdir;\t\t/* Pointer to a structur to store curve\n\t\t\t\t   direction.      */\n  SISLbox *pbox;\t\t/* Pointer to a structur to store the\n\t\t\t\t   surrounded boxes. */\n  int cuopen;\t\t\t/* Open/closed flag.                         */\n} SISLCurve;\n\n/* This file will contain the definition of the structure SISLSurf which\n   contains the description of a tensor-product surface.                    */\n\ntypedef struct SISLSurf\n{\n  int ik1;\t\t\t/* Order of surface in first parameter\n\t\t\t\t   direction.       */\n  int ik2;\t\t\t/* Order of surface in second parameter\n\t\t\t\t   direction.      */\n  int in1;\t\t\t/* Number of vertices in first parameter\n\t\t\t\t   direction.     */\n  int in2;\t\t\t/* Number of vertices in second parameter\n\t\t\t\t   direction.    */\n  double *et1;\t\t\t/* Pointer to knotvector in first parameter\n\t\t\t\t   direction.  */\n  double *et2;\t\t\t/* Pointer to knotvector in second parameter\n\t\t\t\t   direction. */\n  double *ecoef;\t\t/* Pointer to array of vertices of surface. */\n  double *rcoef;\t\t/* Pointer to the array of scaled vertices\n\t\t\t\t   if surface is rational. */\n  int ikind;\t\t\t/* Kind of surface\n\t                           = 1 : Polynomial B-spline tensor-product\n\t\t\t\t         surface.\n\t                           = 2 : Rational B-spline tensor-product\n\t\t\t\t         surface.\n\t                           = 3 : Polynomial Bezier tensor-product\n\t\t\t\t         surface.\n\t                           = 4 : Rational Bezier tensor-product\n\t\t\t\t         surface.                           */\n  int idim;\t\t\t/* Dimension of the space in which the surface\n\t\t\t\t   lies.    */\n  int icopy;\t\t\t/* Indicates whether the arrays of the surface\n\t\t\t\t   are copied or referenced by creation of\n\t\t\t\t   the surface.\n\t                           = 0 : Pointer set to input arrays.\n\t\t\t           = 1 : Copied.\n\t                           = 2 : Pointer set to input arrays,\n\t\t\t\t         but are to be treated as copied.               */\n  SISLdir *pdir;\t\t/* Pointer to a structur to store surface\n\t\t\t\t   direction.    */\n  SISLbox *pbox;\t\t/* Pointer to a structur to store the\n\t\t\t\t   surrounded boxes. */\n  int use_count;                /* use count so that several tracks can share\n\t\t\t\t   surfaces, no internal use */\n int cuopen_1;                  /* Open/closed flag, 1. par directiion */\n int cuopen_2;                  /* Open/closed flag. 2. par direction  */\n  SISLSegmentation *seg1;       /* Segmentation information for use in\n\t\t\t\t   intersection functionality, 1. par. dir. */\n  SISLSegmentation *seg2;       /* Segmentation information for use in\n\t\t\t\t   intersection functionality, 2. par. dir. */\n  int sf_type;        /* SURFACE_TYPE, Flag for special surface information */\n} SISLSurf;\n\n/* This file contains the description of an intersection curve.\n   The curve is given by a number of points represented by the\n   parameter-values of the point in the objects involved in the\n   intersection. Pointers to the curve in the geometry space and\n   in the parameter planes of the objects might exist.            */\n\ntypedef struct SISLIntcurve\n{\n  int ipoint;\t\t\t/* Number of points defining the curve.      */\n  int ipar1;\t\t\t/* Number of parameter directions of first\n\t\t\t\t   object.                                   */\n  int ipar2;\t\t\t/* Number of parameter directions of second\n\t\t\t\t * object.                                   */\n  double *epar1;\t\t/* Pointer to the parameter-values of the\n\t\t\t\t   points\n\t                           in the first object.                      */\n  double *epar2;\t\t/* Pointer to the parameter-values of the\n\t\t\t\t   points\n\t                           in the second object. If one of the objects\n\t                           is an analytic curve or surface epar2 points\n\t                           to nothing.                               */\n  SISLCurve *pgeom;\t\t/* Pointer to the intersection curve in the\n\t\t\t\t   geometry space. If the curve is not\n\t\t\t\t   computed, pgeom points to nothing.       */\n  SISLCurve *ppar1;\t\t/* Pointer to the intersection curve in the\n\t\t\t\t   parameter plane of the first object. If\n\t\t\t\t   the curve is not computed, ppar1 points\n\t\t\t\t   to nothing.                              */\n  SISLCurve *ppar2;\t\t/* Pointer to the intersection curve in the\n\t\t\t\t   parameter plane of the second object. If\n\t\t\t\t   the curve is not computed, ppar2 points\n\t\t\t\t   to nothing.                              */\n  int itype;\t\t\t/* Kind of curve.\n\t                           = 1 : Straight line.\n\t                           = 2 : Closed loop. No singularities.\n\t                           = 3 : Closed loop. One singularity.\n\t\t\t\t         Not used.\n\t                           = 4 : Open curve. No singularity.\n\t                           = 5 : Open curve. Singularity at the\n\t                                 beginning of the curve.\n\t                           = 6 : Open curve. Singularity at the end\n\t                                 of the curve.\n\t                           = 7 : Open curve. Singularity at the\n\t\t\t\t         beginning  and end of the curve.\n\t                           = 8 : An isolated singularity. Not used.\n\t\t\t\t   = 9 : The curve is exact, pgeom and either\n\t\t\t\t   \t ppar1 or ppar2 is set.      */\n\n  int pretop[4];\t\t/* Pretopology */\n} SISLIntcurve;\n\n/* Pretopology information. */\n\nenum\n{\n  SI_RIGHT=1, SI_LEFT=2\n};\nenum\n{\n  SI_UNDEF, SI_IN, SI_OUT, SI_ON, SI_AT\n};\n\n#define SISL_CRV_PERIODIC -1\n#define SISL_CRV_OPEN 1\n#define SISL_CRV_CLOSED 0\n\n#define SISL_SURF_PERIODIC -1\n#define SISL_SURF_OPEN 1\n#define SISL_SURF_CLOSED 0\n\n /*\n * Required for C++ 2.0 and later version\n * --------------------------------------\n */\n#if defined(__cplusplus)\n    extern \"C\" {\n#endif\n#if defined(SISLNEEDPROTOTYPES)\n\n#ifndef CONSTRUCT\nextern\n#endif\nSISLbox GO_API *newbox(int);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLCurve GO_API *newCurve(int,int,double *,double *,int,int,int);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLCurve GO_API *copyCurve(SISLCurve *);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLdir GO_API *newdir(int);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLIntcurve GO_API *newIntcurve(int,int,int,double *,double *,int);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLSurf GO_API *newSurf(int,int,int,int,double *,double *,double *,int,int,int);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLSurf GO_API *copySurface(SISLSurf *);\n\n#ifndef DESTRUCT\nextern\n#endif\nvoid GO_API freeCurve(SISLCurve *);\n#ifndef DESTRUCT\nextern\n#endif\nvoid GO_API freeIntcrvlist(SISLIntcurve **,int);\n#ifndef DESTRUCT\nextern\n#endif\nvoid GO_API freeIntcurve(SISLIntcurve *);\n#ifndef DESTRUCT\nextern\n#endif\nvoid GO_API freeSurf(SISLSurf *);\n#ifndef  S1001\nextern\n#endif\nvoid GO_API s1001(SISLSurf *,double,double,double,double,SISLSurf **,int *);\n#ifndef  S1011\nextern\n#endif\nvoid GO_API s1011(double [],double [],double [],double,int,SISLCurve **,int *);\n#ifndef  S1012\nextern\n#endif\nvoid GO_API s1012(double [],double [],double [],double,int,int,\n\t\tSISLCurve **,int *);\n#ifndef  S1013\nextern\n#endif\nvoid GO_API s1013(SISLCurve *,double,double,double,double *,int *);\n#ifndef  S1014\nextern\n#endif\nvoid GO_API s1014(SISLCurve *,double[],double,double,double[],double[],double,\n                  double *,double *,double[],int *);\n#ifndef  S1015\nextern\n#endif\nvoid GO_API s1015(SISLCurve *,SISLCurve *,double,double[],double[],double,\n\t\t  double *,double *,double[],int *);\n#ifndef  S1016\nextern\n#endif\nvoid GO_API s1016(SISLCurve *,double[],double[],double,double[],double[],\n\t\t  double,double *,double *,double[],int *);\n#ifndef  S1017\nextern\n#endif\nvoid GO_API s1017(SISLCurve *,SISLCurve **,double,int *);\n#ifndef  S1018\nextern\n#endif\nvoid GO_API s1018(SISLCurve *,double [],int,SISLCurve **,int *);\n#ifndef  S1021\nextern\n#endif\nvoid GO_API s1021(double [],double [],double,double [],double,SISLSurf **,int *);\n#ifndef  S1022\nextern\n#endif\nvoid GO_API s1022(double [],double[],double,double [],double,double,\n\t       SISLSurf **,int *);\n#ifndef  S1023\nextern\n#endif\nvoid GO_API s1023(double [],double [],double [],int,int,SISLSurf **,int *);\n#ifndef  S1024\nextern\n#endif\nvoid GO_API s1024(double [],double [],double [],double,int,int,int,\n\t      SISLSurf **,int *);\n#ifndef  S1025\nextern\n#endif\nvoid GO_API s1025(SISLSurf *,double [],int,double [],int,SISLSurf **,int *);\n#ifndef  S1221\nextern\n#endif\nvoid GO_API s1221(SISLCurve *,int,double,int *,double [],int *);\n#ifndef  S1225\nextern\n#endif\nvoid GO_API s1225(SISLCurve *,int,double,int *,double [],double [],double *,int *);\n#ifndef  S1226\nextern\n#endif\nvoid GO_API s1226(SISLCurve *,int,double,int *,double [],double [],double *,int *);\n#ifndef  S1227\nextern\n#endif\nvoid GO_API s1227(SISLCurve *,int,double,int *,double [],int *);\n#ifndef  S1233\nextern\n#endif\nvoid GO_API s1233(SISLCurve *,double,double,SISLCurve **,int *);\n#ifndef  S1237\nextern\n#endif\nvoid GO_API s1237(SISLSurf *,int,int,double,int *);\n#ifndef  S1238\nextern\n#endif\nvoid GO_API s1238(SISLSurf *,SISLCurve *,int,int,double,double,int *);\n#ifndef  S1240\nextern\n#endif\nvoid GO_API s1240(SISLCurve *,double,double *,int *);\n#ifndef  S1241\nextern\n#endif\nvoid GO_API s1241(SISLCurve *,double [],int,double,double *,int *);\n#ifndef  S1243\nextern\n#endif\nvoid GO_API s1243(SISLCurve *,double [],int,double,double[],double *,\n            double *,int *);\n#ifndef  S1302\nextern\n#endif\nvoid GO_API s1302(SISLCurve *,double,double,double [],double [],SISLSurf **,int *);\n#ifndef  S1303\nextern\n#endif\nvoid GO_API s1303(double [],double,double,double [],double [],int,SISLCurve **,int *);\n#ifndef  S1310\nextern\n#endif\nvoid GO_API s1310(SISLSurf *,SISLSurf *,SISLIntcurve *,double,double,int,int,int *);\n#ifndef  S1314\nextern\n#endif\nvoid GO_API s1314(SISLSurf *,double *,double *,int,double,double,double,\n\t   SISLIntcurve *,int,int,int *);\n#ifndef  S1315\nextern\n#endif\nvoid GO_API s1315(SISLSurf *,double *,double,int,double,double,double,\n\t   SISLIntcurve *,int,int,int *);\n#ifndef  S1316\nextern\n#endif\nvoid GO_API s1316(SISLSurf *,double *,double *,double,int,double,double,double,\n\t   SISLIntcurve *,int,int,int *);\n#ifndef  S1317\nextern\n#endif\nvoid GO_API s1317(SISLSurf *,double *,double *,double *,int,double,double,double,\n\t   SISLIntcurve *,int,int,int *);\n#ifndef  S1318\nextern\n#endif\nvoid GO_API s1318(SISLSurf *,double *,double *,double,double,int,double,double,\n\t   double,SISLIntcurve *,int,int,int *);\n#ifndef  S1319\nextern\n#endif\nvoid GO_API s1319(SISLSurf *,double *,int,double,double,double,SISLIntcurve *,\n\t   int,int,int *);\n#ifndef  S1327\nextern\n#endif\nvoid GO_API s1327(SISLCurve *,double [],double [],double [],int,SISLCurve **,int *);\n#ifndef  S1328\nextern\n#endif\nvoid GO_API s1328(SISLSurf *,double [],double [],double [],int,SISLSurf **,int *);\n#ifndef  S1332\nextern\n#endif\nvoid GO_API s1332(SISLCurve *,SISLCurve *,double,double [],SISLSurf **,int *);\n#ifndef  S1356\nextern\n#endif\nvoid GO_API s1356(double [],int,int,int [],int,int,int,int,double,\n\t   double *,SISLCurve **,double **,int *,int *);\n#ifndef  S1357\nextern\n#endif\nvoid GO_API s1357(double [],int,int,int [],double [],int,int,int,int,double,\n\t   double *,SISLCurve **,double **,int *,int *);\n#ifndef  S1360\nextern\n#endif\nvoid GO_API s1360(SISLCurve *,double,double,double [],double,int,SISLCurve **,int *);\n#ifndef  S1363\nextern\n#endif\nvoid GO_API s1363(SISLCurve *,double *,double *,int *);\n#ifndef  S1364\nextern\n#endif\nvoid GO_API s1364(SISLCurve *,double,int *);\n#ifndef S1365\nextern\n#endif\nvoid GO_API s1365(SISLSurf *,double,double, double,int,SISLSurf **,int *);\n#ifndef  S1369\nextern\n#endif\nvoid GO_API s1369(SISLSurf *,double [],double [],double,double,int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1371\nextern\n#endif\nvoid GO_API s1371(SISLCurve *,double [],double,int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1372\nextern\n#endif\nvoid GO_API s1372(SISLCurve *,double [],double [],double,int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1373\nextern\n#endif\nvoid GO_API s1373(SISLCurve *,double [],double [],double [],int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1374\nextern\n#endif\nvoid GO_API s1374(SISLCurve *,double [],int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1375\nextern\n#endif\nvoid GO_API s1375(SISLCurve *,double [],double [],double,double,int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1379\nextern\n#endif\nvoid GO_API s1379(double [],double [],double [],int,int,SISLCurve **,int *);\n#ifndef  S1380\nextern\n#endif\nvoid GO_API s1380(double [],double [],int,int,int,SISLCurve **,int *);\n#ifndef  S1383\nextern\n#endif\nvoid GO_API s1383(SISLSurf *,SISLCurve *,double,double,int,SISLCurve **,\n\t   SISLCurve **,SISLCurve **,int *);\n#ifndef  S1386\nextern\n#endif\nvoid GO_API s1386(SISLSurf *,int,int,SISLSurf **,int *);\n#ifndef  S1387\nextern\n#endif\nvoid GO_API s1387(SISLSurf *,int,int,SISLSurf **,int *);\n#ifndef  S1388\nextern\n#endif\nvoid GO_API s1388(SISLSurf *,double *[],int *,int *,int *,int *);\n#ifndef  S1389\nextern\n#endif\nvoid GO_API s1389(SISLCurve *,double *[],int *,int *,int *);\n#ifndef  S1390\nextern\n#endif\nvoid GO_API s1390(SISLCurve *[],SISLSurf **,int [],int *);\n#ifndef  S1391\nextern\n#endif\nvoid GO_API s1391(SISLCurve **,SISLSurf ***,int,int [],int *);\n#ifndef  S1401\nextern\n#endif\nvoid GO_API s1401(SISLCurve *[],double [],SISLSurf **,int *);\n#ifndef  S1421\nextern\n#endif\nvoid GO_API s1421(SISLSurf *,int,double [],int *,int *,double [],double [],int *);\n#ifndef  S1422\nextern\n#endif\nvoid GO_API s1422(SISLSurf *,int,int,int,double [],int *,int *,\n\t\t double [],double [],int *);\n#ifndef  S1424\nextern\n#endif\nvoid GO_API s1424(SISLSurf *,int,int,double [],int *,int *,double [],int *);\n#ifndef  S1425\nextern\n#endif\nvoid GO_API s1425(SISLSurf *,int,int,int,int,double [],int *,int *,\n\t\t double [],int *);\n#ifndef  S1439\nextern\n#endif\nvoid GO_API s1439(SISLSurf *,double,int,SISLCurve **,int *);\n#ifndef  S1440\nextern\n#endif\nvoid GO_API s1440(SISLSurf *,SISLSurf **,int *);\n#ifndef  S1450\nextern\n#endif\nvoid GO_API s1450(SISLSurf *,double,int *,int *,int *,int *,int *,int *,int *);\n#ifndef  S1451\nextern\n#endif\nvoid GO_API s1451(SISLCurve *,double,int *,int *);\n#ifndef S1501\nextern\n#endif\nvoid GO_API s1501(SISLSurf *,double *,double *,double *,double,double,int,\n\t   double,double,double,SISLIntcurve *,int,int,int *);\n#ifndef S1502\nextern\n#endif\nvoid GO_API s1502(SISLCurve *,double [],double [],double [],double,double,int,\n\t   double,double,int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef S1503\nextern\n#endif\nvoid GO_API s1503(SISLSurf *,double [],double [],double [],double,double,int,\n\t   double,double,int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef S1506\nextern\n#endif\nvoid GO_API s1506(SISLSurf *,int,int,double *,int,double *,double [],\n           double [],int *);\n#ifndef S1508\nextern\n#endif\nvoid GO_API s1508(int,SISLCurve **,double[],SISLSurf **,int *);\n#ifndef S1510\nextern\n#endif\nvoid GO_API s1510(SISLSurf *,double [],int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef S1511\nextern\n#endif\nvoid GO_API s1511(SISLSurf *,double [],double [],int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef S1514\nextern\n#endif\nvoid GO_API s1514(SISLSurf *,double [],int,double,double,double,SISLIntcurve *,\n\t   int,int,int *);\n#ifndef S1515\nextern\n#endif\nvoid GO_API s1515(SISLSurf *,double [],double [],int,double,double,double,\n\t   SISLIntcurve *,int,int,int *);\n#ifndef S1518\nextern\n#endif\nvoid GO_API s1518(SISLSurf *surf, double point[], double dir[], double epsge,\n\t   double start[], double end[], double parin[], double parout[],\n\t   int *stat);\n#ifndef  S1522\nextern\n#endif\nvoid GO_API s1522(double [],double [],double [],double,int,SISLCurve **,int *);\n#ifndef S1529\nextern\n#endif\nvoid GO_API s1529(double [],double [],double [],double [],\n           int,int,int,int,SISLSurf **,int *);\n#ifndef S1530\nextern\n#endif\nvoid GO_API s1530(double [],double [],double [],double [], double [],double [],\n           int ,int ,int , SISLSurf **,int *);\n#ifndef S1534\nextern\n#endif\nvoid GO_API s1534(double [],double [],double [],double [],int,int,int,\n\t   int,int,int,int,int,int,int,int,int,SISLSurf **,int *);\n#ifndef S1535\nextern\n#endif\nvoid GO_API s1535(double [],double [],double [],double [],int,int,int,double [],\n\t   double [],int,int,int,int,int,int,int,int,SISLSurf **,int *);\n#ifndef S1536\nextern\n#endif\nvoid GO_API s1536(double [],int,int,int,int,int,int,int,int,int,int,\n\t   int,int,SISLSurf **,int *);\n#ifndef S1537\nextern\n#endif\nvoid GO_API s1537(double [],int,int,int,double [],double [],int,int,\n\t   int,int,int,int,int,int,SISLSurf **,int *);\n#ifndef  S1538\nextern\n#endif\nvoid GO_API s1538(int,SISLCurve *[],int [],double,int,int,int,SISLSurf **,\n\t   double **,int *);\n#ifndef  S1539\nextern\n#endif\nvoid GO_API s1539(int,SISLCurve *[],int [],double [], double,int,int,int,SISLSurf **,\n\t   double **,int *);\n#ifndef  S1542\nextern\n#endif\nvoid GO_API s1542(SISLCurve *, int, double *, double [], int *);\n#ifndef  S1600\nextern\n#endif\nvoid GO_API s1600(SISLCurve *,double [],double [],int,SISLCurve **,int *);\n#ifndef  S1601\nextern\n#endif\nvoid GO_API s1601(SISLSurf *,double [],double [],int,SISLSurf **,int *);\n#ifndef  S1602\nextern\n#endif\nvoid GO_API s1602(double [],double [],int,int,double,double *,SISLCurve **,int *);\n#ifndef  S1603\nextern\n#endif\nvoid GO_API s1603(SISLSurf *,double *,double *,double *,double *,int *);\n#ifndef  S1606\nextern\n#endif\nvoid GO_API s1606(SISLCurve *,SISLCurve *,double,double [],double [],\n\t   int,int,int,SISLCurve **,int *);\n#ifndef  S1607\nextern\n#endif\nvoid GO_API s1607(SISLCurve *,SISLCurve *,double,double,double,double,double,\n\t   int,int,int,SISLCurve **,int *);\n#ifndef  S1608\nextern\n#endif\nvoid GO_API s1608(SISLCurve *,SISLCurve *,double,double [],double [],double [],\n\t   double [],int,int,int,SISLCurve **,double *,double *,\n\t   double *,double *,int *);\n#ifndef  S1609\nextern\n#endif\nvoid GO_API s1609(SISLCurve *,SISLCurve *,double,double [],double [],double [],\n\t   double,double [],int,int,int,SISLCurve **,double *,double *,\n\t   double *,double *,int *);\n#ifndef  S1611\nextern\n#endif\nvoid GO_API s1611(double [],int,int,double [],int,int,double,double,\n\t   double *,SISLCurve **,int *);\n#ifndef  S1613\nextern\n#endif\nvoid GO_API s1613(SISLCurve *,double,double **,int *,int *);\n#ifndef S1620\nextern\n#endif\nvoid GO_API s1620(double epoint[],int inbpnt1, int inbpnt2, int ipar,\n           int iopen1, int iopen2, int ik1, int ik2, int idim,\n           SISLSurf **rs,int *jstat);\n#ifndef  S1630\nextern\n#endif\nvoid GO_API s1630(double [],int,double,int,int,int,SISLCurve **,int *);\n#ifndef  S1706\nextern\n#endif\nvoid GO_API s1706(SISLCurve *);\n#ifndef  S1710\nextern\n#endif\nvoid GO_API s1710(SISLCurve *,double,SISLCurve **,SISLCurve **,int *);\n#ifndef  S1711\nextern\n#endif\nvoid GO_API s1711(SISLSurf *,int,double,SISLSurf **,SISLSurf **,int *);\n#ifndef  S1712\nextern\n#endif\nvoid GO_API s1712(SISLCurve *,double,double,SISLCurve **,int *);\n#ifndef  S1713\nextern\n#endif\nvoid GO_API s1713(SISLCurve *,double,double,SISLCurve **,int *);\n#ifndef  S1714\nextern\n#endif\nvoid GO_API s1714(SISLCurve *,double,double,SISLCurve **,SISLCurve **,int *);\n#ifndef  S1715\nextern\n#endif\nvoid GO_API s1715(SISLCurve *,SISLCurve *,int,int,SISLCurve **,int *);\n#ifndef  S1716\nextern\n#endif\nvoid GO_API s1716(SISLCurve *,SISLCurve *,double,SISLCurve **,int *);\n#ifndef  S1720\nextern\n#endif\nvoid GO_API s1720(SISLCurve *,int,SISLCurve **,int *);\n#ifndef  S1730\nextern\n#endif\nvoid GO_API s1730(SISLCurve *,SISLCurve **,int *);\n#ifndef  S1731\nextern\n#endif\nvoid GO_API s1731(SISLSurf *,SISLSurf **,int *);\n#ifndef  S1732\nextern\n#endif\nvoid GO_API s1732(SISLCurve *,int,double *,double *,double *,int *);\n#ifndef  S1733\nextern\n#endif\nvoid GO_API s1733(SISLSurf *,int,int,double *,double *,double *,double *,\n\t   double *,int *);\n#ifndef  S1750\nextern\n#endif\nvoid GO_API s1750(SISLCurve *,int,SISLCurve **,int *);\n#ifndef  S1774\nextern\n#endif\nvoid GO_API s1774(SISLCurve *,double [],int,double,double,double,double,double *,\n\t   int *);\n#ifndef  S1775\nextern\n#endif\nvoid GO_API s1775(SISLSurf *,double [],int,double,double [],double [],double [],\n\t   double [],int *);\n#ifndef  S1850\nextern\n#endif\nvoid GO_API s1850(SISLCurve *,double [],double [],int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1851\nextern\n#endif\nvoid GO_API s1851(SISLSurf *,double [],double [],int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1852\nextern\n#endif\nvoid GO_API s1852(SISLSurf *,double [],double,int,double,double,\n\t   int *,double **, int *,SISLIntcurve ***,int *);\n#ifndef  S1853\nextern\n#endif\nvoid GO_API s1853(SISLSurf *,double [],double [],double,int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1854\nextern\n#endif\nvoid GO_API s1854(SISLSurf *,double [],double [],double [],int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1855\nextern\n#endif\nvoid GO_API s1855(SISLSurf *,double [],double,double [],int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1856\nextern\n#endif\nvoid GO_API s1856(SISLSurf *,double [],double [],int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1857\nextern\n#endif\nvoid GO_API s1857(SISLCurve *,SISLCurve *,double,double,\n\t   int *,double **,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1858\nextern\n#endif\nvoid GO_API s1858(SISLSurf *,SISLCurve *,double,double,\n\t   int *,double **,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1859\nextern\n#endif\nvoid GO_API s1859(SISLSurf *,SISLSurf *,double,double,\n\t   int *,double **,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1860\nextern\n#endif\nvoid GO_API s1860(SISLSurf *,double [],int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1870\nextern\n#endif\nvoid\n   s1870(SISLSurf *ps1, double *pt1, int idim, double aepsge,\n\t int *jpt,double **gpar1,int *jcrv,SISLIntcurve ***wcurve,int *jstat);\n#ifndef S1871\nextern\n#endif\nvoid\n   s1871(SISLCurve *pc1, double *pt1, int idim, double aepsge,\n\t int *jpt,double **gpar1,int *jcrv,SISLIntcurve ***wcurve,int *jstat);\n#ifndef  S1920\nextern\n#endif\nvoid GO_API s1920(SISLCurve *,double [],int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1921\nextern\n#endif\nvoid GO_API s1921(SISLSurf *,double [],int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef S1940\nextern\n#endif\nvoid GO_API s1940(SISLCurve *oldcurve, double eps[], int startfix, int endfix,\n\t   int iopen, int itmax, SISLCurve **newcurve, double maxerr[],\n\t   int *stat);\n#ifndef  S1953\nextern\n#endif\nvoid GO_API s1953(SISLCurve *,double [],int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1954\nextern\n#endif\nvoid GO_API s1954(SISLSurf *,double [],int,double,double,\n\t   int *,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1955\nextern\n#endif\nvoid GO_API s1955(SISLCurve *,SISLCurve *,double,double,\n\t   int *,double **,double **,int *,SISLIntcurve ***,int *);\n#ifndef  S1957\nextern\n#endif\nvoid GO_API s1957(SISLCurve *,double [],int,double,double,double *,double *,int *);\n#ifndef  S1958\nextern\n#endif\nvoid GO_API s1958(SISLSurf *,double [],int,double,double,double [],double *,int *);\n#ifndef S1961\nextern\n#endif\nvoid GO_API s1961(double ep[],int im,int idim,int ipar,double epar[],\n\t   double eeps[],int ilend,int irend,int iopen,double afctol,\n\t   int itmax,int ik,SISLCurve **rc,double emxerr[],\n\t   int *jstat);\n#ifndef S1962\nextern\n#endif\nvoid GO_API s1962(double ep[],double ev[],int im,int idim,int ipar,double epar[],\n           double eeps[],int ilend,int irend,int iopen,int itmax,\n           SISLCurve **rc,double emxerr[],int *jstat);\n#ifndef S1963\nextern\n#endif\nvoid GO_API s1963(SISLCurve *pc,double eeps[],int ilend,int irend,int iopen,\n           int itmax, SISLCurve **rc,int *jstat);\n#ifndef S1965\nextern\n#endif\nvoid GO_API s1965(SISLSurf *oldsurf,double eps[],int edgefix[4],int iopen1,\n           int iopen2,double edgeps[],int opt,int itmax,\n           SISLSurf **newsurf,double maxerr[],int *stat);\n#ifndef S1966\nextern\n#endif\nvoid GO_API s1966(double ep[],int im1,int im2,int idim,int ipar,double epar1[],\n           double epar2[],double eeps[],int nend[],int iopen1,int iopen2,\n           double edgeps[],double afctol,int iopt,int itmax,\n           int ik1,int ik2,SISLSurf **rs,double emxerr[],int *jstat);\n#ifndef S1967\nextern\n#endif\nvoid GO_API s1967(double ep[],double etang1[],double etang2[],double eder11[],\n           int im1,int im2,int idim,int ipar,double epar1[],double epar2[],\n           double eeps[],int nend[],int iopen1,int iopen2,double edgeps[],\n           int iopt,int itmax,SISLSurf **rs,double emxerr[],\n           int *jstat);\n#ifndef S1968\nextern\n#endif\nvoid GO_API s1968(SISLSurf *ps,double eeps[],int nend[],int iopen1,int iopen2,\n           double edgeps[],int iopt,int itmax,SISLSurf **rs,\n           int *jstat);\n#ifndef S1986\nextern\n#endif\nvoid GO_API s1986(SISLCurve *pc, double aepsge, int *jgtpi, double **gaxis,\n\t   double *cang,int *jstat);\n#ifndef S1987\nextern\n#endif\nvoid GO_API s1987(SISLSurf *ps, double aepsge, int *jgtpi, double **gaxis,\n\t   double *cang,int *jstat);\n#ifndef S1988\nextern\n#endif\nvoid GO_API s1988(SISLCurve *,double **,double **,int *);\n#ifndef S1989\nextern\n#endif\nvoid GO_API s1989(SISLSurf *,double **,double **,int *);\n#ifndef  S2500\nextern\n#endif\nvoid GO_API s2500(SISLSurf *, int, int, int, double [], int *, int *, double *, int *);\n#ifndef  S2502\nextern\n#endif\nvoid GO_API s2502(SISLSurf *, int, int, int, double [], int *, int *, double *, int *);\n#ifndef  S2504\nextern\n#endif\nvoid GO_API s2504(SISLSurf *, int, int, int, double [], int *, int *, double *, int *);\n#ifndef  S2506\nextern\n#endif\nvoid GO_API s2506(SISLSurf *, int, int, int, double [], int *, int *, double *, int *);\n#ifndef  S2508\nextern\n#endif\nvoid GO_API s2508(SISLSurf *, int, int, int, double [], int *, int *, double *, int *);\n#ifndef  S2510\nextern\n#endif\nvoid GO_API s2510(SISLSurf *, int, int, int, double [], int *, int *, double *, int *);\n#ifndef  S2532\nextern\n#endif\nvoid GO_API s2532(SISLSurf *, int, int, int *, int *, SISLSurf ***, int *);\n#ifndef  S2536\nextern\n#endif\nvoid GO_API s2536(SISLSurf *, int, int, int *, int *, SISLSurf ***, int *);\n#ifndef  S2540\nextern\n#endif\nvoid GO_API s2540(SISLSurf *, int, int, int, double [], int, int, double **, int *);\n#ifndef  S2542\nextern\n#endif\nvoid GO_API s2542(SISLSurf *, int, int, int, double [], int *, int *, double *,\n\t   double *, double [], double [],int *);\n#ifndef  S2544\nextern\n#endif\nvoid GO_API s2544(SISLSurf *, int, int, int, double [], int *, int *, double *, int *);\n#ifndef  S2545\nextern\n#endif\nvoid GO_API s2545(SISLSurf *, int, int, int, double [], int, int, double, double **,\n\t   int *);\n#ifndef  S2550\nextern\n#endif\nvoid GO_API s2550(SISLCurve *, double [], int, double [], int *);\n#ifndef  S2553\nextern\n#endif\nvoid GO_API s2553(SISLCurve *, double [], int, double [], int *);\n#ifndef  S2556\nextern\n#endif\nvoid GO_API s2556(SISLCurve *, double [], int, double [], int *);\n#ifndef  S2559\nextern\n#endif\nvoid GO_API s2559(SISLCurve *, double [], int, double [], double [], double [],\n           double [], int *);\n#ifndef  S2562\nextern\n#endif\nvoid GO_API s2562(SISLCurve *, double [], int, int, double [], double [], double [],\n           double [], double [], int *);\n#ifndef  S6DRAWSEQ\nextern\n#endif\nvoid GO_API s6drawseq(double [],int);\n#ifndef  MAKE_CV_CYCLIC\nextern\n#endif\nvoid make_cv_cyclic(SISLCurve *,int,int *);\n\n#else /* not SISLNEEDPROTOTYPES */\n\n#ifndef CONSTRUCT\nextern\n#endif\nSISLbox       *newbox();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLCurve     *newCurve();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLCurve     *copyCurve();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLdir       *newdir();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLIntcurve  *newIntcurve();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLSurf      *newSurf();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLSurf      *copySurface();\n\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeCurve();\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeIntcrvlist();\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeIntcurve();\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeSurf();\n#ifndef  S1001\nextern\n#endif\nvoid s1001();\n#ifndef  S1011\nextern\n#endif\nvoid s1011();\n#ifndef  S1012\nextern\n#endif\nvoid s1012();\n#ifndef  S1013\nextern\n#endif\nvoid s1013();\n#ifndef  S1014\nextern\n#endif\nvoid s1014();\n#ifndef  S1015\nextern\n#endif\nvoid s1015();\n#ifndef  S1016\nextern\n#endif\nvoid s1016();\n#ifndef  S1017\nextern\n#endif\nvoid s1017();\n#ifndef  S1018\nextern\n#endif\nvoid s1018();\n#ifndef  S1021\nextern\n#endif\nvoid s1021();\n#ifndef  S1022\nextern\n#endif\nvoid s1022();\n#ifndef  S1023\nextern\n#endif\nvoid s1023();\n#ifndef  S1024\nextern\n#endif\nvoid s1024();\n#ifndef  S1025\nextern\n#endif\nvoid s1025();\n#ifndef  S1221\nextern\n#endif\nvoid s1221();\n#ifndef  S1225\nextern\n#endif\nvoid s1225();\n#ifndef  S1226\nextern\n#endif\nvoid s1226();\n#ifndef  S1227\nextern\n#endif\nvoid s1227();\n#ifndef  S1233\nextern\n#endif\nvoid s1233();\n#ifndef  S1237\nextern\n#endif\nvoid s1237();\n#ifndef  S1238\nextern\n#endif\nvoid s1238();\n#ifndef  S1240\nextern\n#endif\nvoid s1240();\n#ifndef  S1241\nextern\n#endif\nvoid s1241();\n#ifndef  S1243\nextern\n#endif\nvoid s1243();\n#ifndef  S1302\nextern\n#endif\nvoid s1302();\n#ifndef  S1303\nextern\n#endif\nvoid s1303();\n#ifndef  S1310\nextern\n#endif\nvoid s1310();\n#ifndef  S1314\nextern\n#endif\nvoid s1314();\n#ifndef  S1315\nextern\n#endif\nvoid s1315();\n#ifndef  S1316\nextern\n#endif\nvoid s1316();\n#ifndef  S1317\nextern\n#endif\nvoid s1317();\n#ifndef  S1318\nextern\n#endif\nvoid s1318();\n#ifndef  S1319\nextern\n#endif\nvoid s1319();\n#ifndef  S1327\nextern\n#endif\nvoid s1327();\n#ifndef  S1328\nextern\n#endif\nvoid s1328();\n#ifndef  S1332\nextern\n#endif\nvoid s1332();\n#ifndef  S1356\nextern\n#endif\nvoid s1356();\n#ifndef  S1357\nextern\n#endif\nvoid s1357();\n#ifndef  S1360\nextern\n#endif\nvoid s1360();\n#ifndef  S1363\nextern\n#endif\nvoid s1363();\n#ifndef  S1364\nextern\n#endif\nvoid s1364();\n#ifndef  S1365\nextern\n#endif\nvoid s1365();\n#ifndef  S1369\nextern\n#endif\nvoid s1369();\n#ifndef  S1371\nextern\n#endif\nvoid s1371();\n#ifndef  S1372\nextern\n#endif\nvoid s1372();\n#ifndef  S1373\nextern\n#endif\nvoid s1373();\n#ifndef  S1374\nextern\n#endif\nvoid s1374();\n#ifndef  S1375\nextern\n#endif\nvoid s1375();\n#ifndef  S1379\nextern\n#endif\nvoid s1379();\n#ifndef  S1380\nextern\n#endif\nvoid s1380();\n#ifndef  S1383\nextern\n#endif\nvoid s1383();\n#ifndef  S1386\nextern\n#endif\nvoid s1386();\n#ifndef  S1387\nextern\n#endif\nvoid s1387();\n#ifndef  S1388\nextern\n#endif\nvoid s1388();\n#ifndef  S1389\nextern\n#endif\nvoid s1389();\n#ifndef  S1390\nextern\n#endif\nvoid s1390();\n#ifndef  S1391\nextern\n#endif\nvoid s1391();\n#ifndef  S1401\nextern\n#endif\nvoid s1401();\n#ifndef  S1421\nextern\n#endif\nvoid s1421();\n#ifndef  S1422\nextern\n#endif\nvoid s1422();\n#ifndef  S1424\nextern\n#endif\nvoid s1424();\n#ifndef  S1425\nextern\n#endif\nvoid s1425();\n#ifndef  S1439\nextern\n#endif\nvoid s1439();\n#ifndef  S1440\nextern\n#endif\nvoid s1440();\n#ifndef  S1450\nextern\n#endif\nvoid s1450();\n#ifndef  S1451\nextern\n#endif\nvoid s1451();\n#ifndef S1501\nextern\n#endif\nvoid s1501();\n#ifndef S1502\nextern\n#endif\nvoid s1502();\n#ifndef S1503\nextern\n#endif\nvoid s1503();\n#ifndef S1506\nextern\n#endif\nvoid s1506();\n#ifndef S1508\nextern\n#endif\nvoid s1508();\n#ifndef S1510\nextern\n#endif\nvoid s1510();\n#ifndef S1511\nextern\n#endif\nvoid s1511();\n#ifndef S1514\nextern\n#endif\nvoid s1514();\n#ifndef S1515\nextern\n#endif\nvoid s1515();\n#ifndef S1522\nextern\n#endif\nvoid s1522();\n#ifndef S1529\nextern\n#endif\nvoid s1529();\n#ifndef S1530\nextern\n#endif\nvoid s1530();\n#ifndef S1534\nextern\n#endif\nvoid s1534();\n#ifndef S1535\nextern\n#endif\nvoid s1535();\n#ifndef S1536\nextern\n#endif\nvoid s1536();\n#ifndef S1537\nextern\n#endif\nvoid s1537();\n#ifndef S1538\nextern\n#endif\nvoid s1538();\n#ifndef S1539\nextern\n#endif\nvoid s1539();\n#ifndef S1542\nextern\n#endif\nvoid s1542();\n#ifndef  S1600\nextern\n#endif\nvoid s1600();\n#ifndef  S1601\nextern\n#endif\nvoid s1601();\n#ifndef  S1602\nextern\n#endif\nvoid s1602();\n#ifndef  S1603\nextern\n#endif\nvoid s1603();\n#ifndef  S1606\nextern\n#endif\nvoid s1606();\n#ifndef  S1607\nextern\n#endif\nvoid s1607();\n#ifndef  S1608\nextern\n#endif\nvoid s1608();\n#ifndef  S1609\nextern\n#endif\nvoid s1609();\n#ifndef  S1611\nextern\n#endif\nvoid s1611();\n#ifndef  S1613\nextern\n#endif\nvoid s1613();\n#ifndef  S1620\nextern\n#endif\nvoid s1620();\n#ifndef  S1630\nextern\n#endif\nvoid s1630();\n#ifndef  S1706\nextern\n#endif\nvoid s1706();\n#ifndef  S1710\nextern\n#endif\nvoid s1710();\n#ifndef  S1711\nextern\n#endif\nvoid s1711();\n#ifndef  S1712\nextern\n#endif\nvoid s1712();\n#ifndef  S1713\nextern\n#endif\nvoid s1713();\n#ifndef  S1714\nextern\n#endif\nvoid s1714();\n#ifndef  S1715\nextern\n#endif\nvoid s1715();\n#ifndef  S1716\nextern\n#endif\nvoid s1716();\n#ifndef  S1720\nextern\n#endif\nvoid s1720();\n#ifndef  S1730\nextern\n#endif\nvoid s1730();\n#ifndef  S1731\nextern\n#endif\nvoid s1731();\n#ifndef  S1732\nextern\n#endif\nvoid s1732();\n#ifndef  S1733\nextern\n#endif\nvoid s1733();\n#ifndef  S1750\nextern\n#endif\nvoid s1750();\n#ifndef  S1774\nextern\n#endif\nvoid s1774();\n#ifndef  S1775\nextern\n#endif\nvoid s1775();\n#ifndef  S1850\nextern\n#endif\nvoid s1850();\n#ifndef  S1851\nextern\n#endif\nvoid s1851();\n#ifndef  S1852\nextern\n#endif\nvoid s1852();\n#ifndef  S1853\nextern\n#endif\nvoid s1853();\n#ifndef  S1854\nextern\n#endif\nvoid s1854();\n#ifndef  S1855\nextern\n#endif\nvoid s1855();\n#ifndef  S1856\nextern\n#endif\nvoid s1856();\n#ifndef  S1857\nextern\n#endif\nvoid s1857();\n#ifndef  S1858\nextern\n#endif\nvoid s1858();\n#ifndef  S1859\nextern\n#endif\nvoid s1859();\n#ifndef  S1860\nextern\n#endif\nvoid s1860();\n#ifndef  S1870\nextern\n#endif\nvoid s1870();\n#ifndef  S1871\nextern\n#endif\nvoid s1871();\n#ifndef  S1920\nextern\n#endif\nvoid s1920();\n#ifndef  S1921\nextern\n#endif\nvoid s1921();\n#ifndef  S1940\nextern\n#endif\nvoid s1940();\n#ifndef  S1953\nextern\n#endif\nvoid s1953();\n#ifndef  S1954\nextern\n#endif\nvoid s1954();\n#ifndef  S1955\nextern\n#endif\nvoid s1955();\n#ifndef  S1957\nextern\n#endif\nvoid s1957();\n#ifndef  S1958\nextern\n#endif\nvoid s1958();\n#ifndef  S1961\nextern\n#endif\nvoid s1961();\n#ifndef  S1962\nextern\n#endif\nvoid s1962();\n#ifndef  S1963\nextern\n#endif\nvoid s1963();\n#ifndef  S1965\nextern\n#endif\nvoid s1965();\n#ifndef  S1966\nextern\n#endif\nvoid s1966();\n#ifndef  S1967\nextern\n#endif\nvoid s1967();\n#ifndef  S1968\nextern\n#endif\nvoid s1968();\n#ifndef S1986\nextern\n#endif\nvoid s1986();\n#ifndef S1987\nextern\n#endif\nvoid s1987();\n#ifndef S1988\nextern\n#endif\nvoid s1988();\n#ifndef S1989\nextern\n#endif\nvoid s1989();\n#ifndef  S2500\nextern\n#endif\nvoid s2500();\n#ifndef  S2502\nextern\n#endif\nvoid s2502();\n#ifndef  S2504\nextern\n#endif\nvoid s2504();\n#ifndef  S2506\nextern\n#endif\nvoid s2506();\n#ifndef  S2508\nextern\n#endif\nvoid s2508();\n#ifndef  S2510\nextern\n#endif\nvoid s2510();\n#ifndef  S2532\nextern\n#endif\nvoid s2532();\n#ifndef  S2536\nextern\n#endif\nvoid s2536();\n#ifndef  S2540\nextern\n#endif\nvoid s2540();\n#ifndef  S2542\nextern\n#endif\nvoid s2542();\n#ifndef  S2544\nextern\n#endif\nvoid s2544();\n#ifndef  S2545\nextern\n#endif\nvoid s2545();\n#ifndef  S2550\nextern\n#endif\nvoid s2550();\n#ifndef  S2553\nextern\n#endif\nvoid s2553();\n#ifndef  S2556\nextern\n#endif\nvoid s2556();\n#ifndef  S2559\nextern\n#endif\nvoid s2559();\n#ifndef  S2562\nextern\n#endif\nvoid s2562();\n#ifndef  S6DRAWSEQ\nextern\n#endif\nvoid s6drawseq();\n#ifndef  MAKE_CV_CYCLIC\nextern\n#endif\nvoid make_cv_cyclic();\n#endif /* End of forward declarations of sisl top level routines */\n\n#if defined(__cplusplus)\n    }\n#endif\n#endif /* SISL_INCLUDED */\n/* DO NOT ADD ANYTHING AFTER THIS LINE */\n"
  },
  {
    "path": "include/sislP.h",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#ifndef SISLP_INCLUDED\n#define SISLP_INCLUDED\n/*\n * If _SISL_COPYRIGHT_H is defined before sisl-copyright.h is included\n * then flag this by defining SISL_INTERNAL as we're compiling SISL\n * library source files. By doing this we can hide internal SISL macros\n * if this header file is included in external files.\n * ---------------------------------------------------------------------\n */\n#if defined(_SISL_COPYRIGHT_H)\n#define SISL_INTERNAL 1\n#endif\n\n#include \"sisl-copyright.h\"\n\n#include \"sisl.h\"\n/*\n *\n * $Id: sislP.h,v 1.56 2009-03-18 13:30:41 vsk Exp $\n *\n */\n\n#if defined(SISL_ALIGNMENT)\n#pragma HP_ALIGN NATURAL\n#endif\n\n/* Get size_t */\n#include <sys/types.h>\n\n#if defined(SISL_INTERNAL)\n\n/* Get standard I/O library definitions */\n#include <stdio.h>\n\n/* Get standard library definitions (includes malloc defs) */\n#include <stdlib.h>\n\n/* Get  string library definitions (includes memcpy defs) */\n#include <string.h>\n\n/* Get system spesific limits */\n#include <limits.h>\n\n/* Get system spesific values */\n#ifndef MAXDOUBLE\n#  define MAXDOUBLE   1.79769313486231570e+308\n#endif\n\n#if defined(_MSC_VER) || defined(__BORLANDC__) || defined(__MINGW32__) || defined(__APPLE__)\n#  define MAXFLOAT    ((float)3.40282346638528860e+38)\n#  define MINDOUBLE   2.22507385850720140e-308\n#  define MINFLOAT    ((float)1.17549435082228750e-38)\n#  define M_PI        3.14159265358979323846\n#  define M_PI_2      1.57079632679489661923\n#  define M_SQRT2     1.41421356237309504880\n#  define M_SQRT1_2   0.70710678118654752440\n#endif\n\n/* Get floating point limits */\n#include <float.h>\n\n/* Get math library routines definition. */\n#include <math.h>\n\n#endif  /* SISL_INTERNAL */\n\n#if !defined(apollo)\n#if defined(__STDC__)\n\n#if !defined(CONST)\n#define CONST const\n#endif\n#define VOIDP      (void *)\n#define CONSTVOIDP (const void *)\n\n#else /* Not __STDC__ */\n#if !defined(CONST)\n#define CONST\n#endif\n#define VOIDP       (char *)\n#define CONSTVOIDP  (char *)\n#endif\n\n#else /* apollo */\n#if !defined(CONST)\n#define CONST\n#endif\n#define VOIDP        (void *)\n#define CONSTVOIDP   (void *)\n#endif\n\n\n\n/* This file contains the definition of the structure SISLPoint\n   The structure is created 18.04.89 by UJK.                           */\n\n\ntypedef struct SISLPoint\n{\n  double ec[3];\n  int idim;\t\t\t/* The dimension the point lies in           */\n  double *ecoef;\t\t/* Pointer to the array containing the\n\t\t\t\t   coordinates */\n  int icopy;\t\t\t/* Indicates whether the arrays of the point\n\t\t\t\t   are copied or referenced by creation of\n\t\t\t\t   the point.\n\t\t\t\t   = 0 : Pointer set to input arrays.\n\t\t\t\t   = 1 : Copied.\n\t\t\t\t   = 2 : Pointer set to input arrays,\n\t\t\t\t         but are to be treated as copied.    */\n\n  SISLbox *pbox;\t\t/*Pointer to a structur to store the boxes.  */\n} SISLPoint;\n\n\n\n/* This file contains the definition of the structure SISLObject that contains\n   the description of a geometric object that take part in an intersection\n   problem or in a related problem. SISLObject can represent any geometric\n   structure, but only on at a time.                                   */\n\ntypedef struct SISLObject\n{\n  int iobj;\t\t\t/* Integer indicates which kind of geometric\n\t\t\t\t   object is contained in a particular\n\t\t\t\t   instance of the structure.\n\t\t                   = 1 (SISLCurve) - curve.\n\t\t                   = 2 (SURFACE) - tensor-product surface.   */\n  SISLPoint *p1;\t\t/* Pointer to a point (instance of Point).   */\n  SISLCurve *c1;\t\t/* Pointer to a curve\n\t\t\t\t * (instance of SISLCurve).                  */\n  SISLSurf *s1;\t\t\t/* Pointer to a surface\n\t\t\t\t * (instance of SISLSurf).                   */\n  struct SISLObject *o1;\t/* Pointer to parent object\n\t\t\t\t * (instance of Object).                     */\n  struct SISLObject *edg[4];\t/* Pointer to objects edges\n\t\t\t\t * (instance of Object).                     */\n  struct SISLObject *psimple;\t/* Indicates if object/object intersection\n\t\t\t\t * is simple case. */\n} SISLObject;\n\ntypedef struct SISLIntsurf\n{\n  int ipoint;\t\t\t/* Number of points defining the curve.    */\n  int ipar;\t\t\t/* Number of parameter directions of       */\n  double *epar;\t\t        /* Pointer to the parameter-values of the\n\t\t\t\t   points, dimension: ipoint*ipar          */\n  int *const_par;               /* Constant parameter direction between\n\t\t\t\t   two points in epar.                     */\n} SISLIntsurf;\n\n\ntypedef struct SISLTrimpar\n{\n    int ptindex;  /* Index in pnext of pointer to an adjacent point\n\t\t      in the trim curve. */\n    int parindex;  /* The parameter which is constant along\n\t\t      the trim curve, between\n                      this point and the ptindex point. */\n} SISLTrimpar;\n\n/* This file contains the description of an intersection point (or\n   closest point or extremal point) found in the recursive part of\n   an intersection routine.                                        */\n\n\ntypedef struct SISLIntpt\n{\n  int ipar;\t\t\t/* Number of parameter directions in\n\t\t\t\t * intersection problem.                     */\n  double *epar;\t\t\t/* Parametervalues of point, possibly in two\n\t\t\t\t * objects.                                  */\n  double adist;\t\t\t/* Distance between the objects in this point.\n\t\t\t\t * tdist is used in closest point problems.  */\n  struct SISLIntpt *pcurve;\t/* Not used, kept for compatibility with old\n\t\t\t           version on the structure.*/\n  int iinter;\t\t\t/* = 1 ORDINARY MAIN POINT\n\t\t\t\t   = 2 SINGULAR MAIN POINT\n\t\t\t\t   = 3 TRIM MAIN POINT\n\t\t                   = -1 ORDINARY HELP POINT\n\t\t\t\t   = -2 SINGULAR HELP POINT\n\t\t\t\t   = -3 TRIM HELP POINT */\n  struct SISLIntpt **pnext;\t/* Pointers to next points in each curve\n\t\t\t\t * chain.                                   */\n  int *curve_dir;\t\t/* An array of curve directions + from - to\n\t\t\t\t * this point.                              */\n  int no_of_curves;\t\t/* Number of curves containing this point.  */\n  int no_of_curves_alloc;\t/* The size of the arrays allocated         */\n  int *left_obj_1;\t\t/* Pretopology information, one for each\n\t\t\t\t * curve.                                   */\n  int *left_obj_2;\t\t/* Pretopology information, one for each\n\t\t\t\t * curve.                                   */\n  int *right_obj_1;\t\t/* Pretopology information, one for each\n\t\t\t\t   curve.                                   */\n  int *right_obj_2;\t\t/* Pretopology information, one for each\n\t\t\t\t   curve.                                   */\n  int size_1;\t\t\t/* Size of geo_data_1                       */\n  int size_2;\t\t\t/* Size of geo_data_2                       */\n  double *geo_data_1;\t\t/* Containing geometric info first object   */\n  double *geo_data_2;\t\t/* Containing geometric info second object  */\n  /*  double  geo_aux[3]; Containing auxiliary geo info, see sh6idput*/\n  double geo_track_3d[10];\t/* To store intersection curve info */\n  double geo_track_2d_1[7];\n  double geo_track_2d_2[7];\n  int edge_1;                   /* Edge flag for topology           */\n  int edge_2;\n  int marker;                   /* Help attribute when creating lists  */\n  int evaluated;                /* Help attribute when creating tracks */\n  struct SISLTrimpar *trim[2];          /* Used if pt is in trim curve. */\n  int iside_1;\t\t\t/* Left/right evaluator flag.  -1,0+ */\n  int iside_2;\t\t\t/* Left/right evaluator flag.  -1,0+*/\n  int fromhelp;\n} SISLIntpt;\n\n/* This file contains the definition of the structure SISLTrack\n   The structure is created 10.06.91 by UJK.                           */\n\ntypedef struct SISLTrack\n{\n  SISLSurf *psurf_1;\t\t/* Pointer to first surface in intersection */\n  SISLSurf *psurf_2;\t\t/* Pointer to second surface in intersection */\n  SISLCurve *pcurve_3d;\t\t/* Pointer to 3D support curve. */\n  SISLCurve *pcurve_2d_1;\t/* Pointer to 2D support curve in first\n\t\t\t\t   parameter space. */\n  SISLCurve *pcurve_2d_2;\t/* Pointer to 2D support curve in second\n\t\t\t\t   parameter space. */\n  int ideg;\t\t\t/* Type of track.\n\t\t\t\t    = 0, Bspline vs Bspline\n\t\t\t\t= 1, Bspline vs Plane\n\t\t\t\t= 2, Bspline vs Quadric surface\n\t\t\t\t= 1001 Bspline vs Torus surface\n\t\t\t\t= 1003 Bspline silhouette line, parallel\n\t\t\t\t  projection\n\t\t\t\t= 1004 Bspline silhouette line, perspective\n\t\t\t\t  projection\n\t\t\t\t= 1005 Bspline silhouette line, circular\n\t\t\t          projection */\n\n  double eimpli[16];\t\t/* Description of the implicit surface */\n  int turned;\t\t\t/* Connection between the direction of the\n\t\t\t\t   support curve and the cross product\n\t\t\t\t   between the two surface normals.\n\t\t\t\t= 0, same direction\n\t\t\t\t= 1, oposite direction */\n  int exact;                    /* Flag if curve is exact */\n  int pretop[4];\t\t/* Pretopology */\n  int sing_start;               /* Singular start end point markers */\n  int sing_end;\n} SISLTrack;\n\n/* This file contains the description of a list connecting points that\n   belong to an intersection curve.                                    */\n\ntypedef struct SISLIntlist\n{\n  SISLIntpt *pfirst;\t\t/* Pointer to first point in list. */\n  SISLIntpt *plast;\t\t/* Pointer to last point in list.  */\n  int ind_first;\t\t/* Index pointer in pfirst         */\n  int ind_last;\t\t\t/* Index pointer in plast          */\n  int itype;\t\t\t/* Status of curve-segment.\n                               = 0 : open curve, no singularities.\n                               = 1 : closed curve, no singularities.\n                               = 2 : more than two curves meet at start point.\n                               = 3 : more than two curves meet at end point.\n                               = 4 : more than two curves meet at start\n                                     and end point.\n                               = 5 : isolated singularity.\n                               = 6 : touching area of surface.            */\n  int inumb;\t\t\t/* Number of points in the list.          */\n  int pretop[4];\t\t/* Pretopology */\n} SISLIntlist;\n\n/* This file contains the definition of an element in a list where\n   each element points to an intersection point. The structure is\n   used internally in intersection routines and related routines.   */\n\ntypedef struct SISLPtedge\n{\n  SISLIntpt *ppt;\t\t/* Pointer to intersection points.      */\n  struct SISLPtedge *pnext;\t/* Pointer to next element in the list. */\n} SISLPtedge;\n\n/* This file contains the definition of the structure keeping\n   track of intersections on edges/endpoints of objects. This\n   structure is used internally in the recursive part of intersection\n   routines and related routines.                                     */\n\ntypedef struct SISLEdge\n{\n  int iedge;\t\t\t/* Number of edges/endpoints of object.      */\n  int ipoint;\t\t\t/* Number of intersection points found on\n\t\t\t\t * the edges.                                */\n  SISLPtedge **prpt;\t\t/* Array containing lists of pointers to the\n\t\t\t         * intersections at the edges.               */\n} SISLEdge;\n\n/* This file contains the definition of the structure SISLIntdat used\n   intarnally in intersection routines in order to store information\n   in intersection points and curves.                                        */\n\ntypedef struct SISLIntdat\n{\n  SISLIntpt **vpoint;\n  int ipoint;\n  int ipmax;\n  SISLIntlist **vlist;\n  int ilist;\n  int ilmax;\n} SISLIntdat;\n\ntypedef struct rank_info\n    {\n    int *prio;\n    int *groups;\n    int antgr;\n    int antrem;\n  }rank_info;\n\n/* UJK: NEW INTERSECTION STUFF START*/\n\nenum\n{\n  SI_ORD = 1, SI_SING, SI_TRIM, SI_TOUCH\n};\n\n/* UJK: NEW INTERSECTION STUFF END*/\n\n#if defined(SISL_INTERNAL)\n#ifndef HUGE\n#define HUGE          MAXDOUBLE\n#endif\n\n/* Storage classes. Used in space allocation.  */\n#define  INT     int\n#define  DOUBLE  double\n#endif /* SISL_INTERNAL */\n\n/* Name of geometry objects. Used in branching. */\n#define SISLPOINT    0\n#define SISLCURVE    1\n#define SISLSURFACE  2\n\n/* The resolution of double precision numbers */\n#define AEPSGE (double)1.e-6\n#define AEPSCO (double)0.0\n\n#define REL_COMP_RES                   (double)0.000000000000001\n#define REL_PAR_RES                    (double)0.000000000001\n#define ANGULAR_TOLERANCE              (double)0.01  /* IN RADIANS */\n#define MAXIMAL_RADIUS_OF_CURVATURE    (double)10000.0\n\n/*\n * Name of the nullobject, what a pointer points to when\n * it points to  nothing.\n */\n\n#ifndef SISL_NULL\n#define SISL_NULL 0\n#endif\n\n/* Name of double 0.0 */\n\n#ifndef DZERO\n#define DZERO (double)0.0\n#endif\n\n#if defined(SISL_INTERNAL)\n#define ONE_THIRD  (double)0.333333333333333333333333\n#define ONE_SIXTH  (double)0.166666666666666666666667\n#define ONE_FOURTH (double)0.25\n\n/* Functions taking max/min of two arguments. */\n\n#ifndef max\n#define max(a,b) ((a) > (b) ? (a) : (b))\n#endif\n\n#ifndef min\n#define min(a,b) ((a) < (b) ? (a) : (b))\n#endif\n\n#ifndef MAX\n#define MAX max\n#endif\n#ifndef MIN\n#define MIN min\n#endif\n\n/* Macros checking for equality/non-equality  between two double numbers */\n\n#define DEQUAL(a,b) \\\n  ( (fabs((a) - (b)) <= (REL_PAR_RES * MAX(MAX(fabs(a),fabs(b)),(double)1.0))) ? (1) : (0) )\n\n#define DNEQUAL(a,b) \\\n  ( (fabs((a) - (b)) >  (REL_PAR_RES * MAX(MAX(fabs(a),fabs(b)),(double)1.0))) ? (1) : (0) )\n\n#define ZEROLEN(a) \\\n  ( (fabs(a) <= AEPSGE) ? (1) : (0) )\n\n/* Space allocation.  */\n\n#if defined(SISL_INTERNAL) || defined(USING_SISL_NEWARRAY)\n\n#define newarray(a,b) \\\n  ((a)>(SISL_NULL)?((b*)malloc((size_t)((a)*sizeof(b)))):(SISL_NULL))\n\n#define new0array(a,b) \\\n  ((a)>(SISL_NULL)?((b*)calloc((size_t)(a),(size_t)(sizeof(b)))):(SISL_NULL))\n\n#define increasearray(a,b,c) (c*)realloc(VOIDP(a),(size_t)((b)*sizeof(c)))\n\n#define freearray(a) { (void)free(VOIDP a); a = SISL_NULL; }\n\n#define free0array(a) { (void)free(VOIDP a); a = SISL_NULL; }\n\n\n/* Copying of arrays   */\n\n#define memcopy(a,b,c,d) \\\n  VOIDP memcpy(VOIDP (a),CONSTVOIDP(b),(size_t)((c)*sizeof(d)))\n\n/* Zero out an array   */\n\n#define memzero(a,b,c) \\\n  VOIDP memset(VOIDP (a),0,(size_t)((b)*sizeof(c)))\n\n#endif /* SISL_INTERNAL || USING_SISL_NEWARRAY */\n\n/* Set value of PI/2, PI, 3PI/2 and 2PI */\n\n#ifndef PIHALF\n#define PIHALF       (double)M_PI_2\n#endif\n#ifndef PI\n#define PI           (double)M_PI\n#endif\n/* #ifndef PIHALF\n   #define PIHALF       (double)1.57079632679489661923\n   #endif\n   #ifndef PI\n   #define PI           (double)3.14159265358979323846\n   #endif                            */\n#ifndef THREEPIHALF\n#define THREEPIHALF  (double)4.71238898038468985769\n#endif\n#ifndef TWOPI\n#define TWOPI        (double)6.28318530717958647692\n#endif\n#ifndef ROTM\n/* #define ROTM         (double)0.70710678118654752440 */\n#define ROTM         (double)M_SQRT1_2\n#endif\n#ifndef SIMPLECASE\n#define SIMPLECASE   (double)0.75\n#endif\n\n/* Values of logicals */\n\n#ifndef TRUE\n#define TRUE 1\n#endif\n#ifndef FALSE\n#define FALSE 0\n#endif\n#endif          /* SISL_INTERNAL */\n\n\n/*\n * --------------------------------------------------------------\n * Forward declarations of all sisl low-level routines, all in C.\n * --------------------------------------------------------------\n */\n\n#if defined(__cplusplus)\n    extern \"C\" {\n#endif\n#if defined(SISLNEEDPROTOTYPES)\n\n#ifndef CONSTRUCT\nextern\n#endif\nSISLIntpt    *copyIntpt(SISLIntpt *);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLEdge     *newEdge(int);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLIntdat   *newIntdat(void);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLIntlist  *newIntlist(SISLIntpt *,SISLIntpt *,int);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLIntpt    *newIntpt(int,double *,double);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLObject   *newObject(int);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLPoint    *newPoint(double *,int,int);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLPtedge   *newPtedge(SISLIntpt *);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLIntsurf  *newIntsurf(SISLIntlist *);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLTrack    *newTrack(SISLSurf *,SISLSurf *,SISLCurve *,SISLCurve *,\n\t\t       SISLCurve *,int,double[],int,int,int);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLTrimpar  *newTrimpar(int,int);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLIntpt    *hp_newIntpt(int,double *,double,int,int,int,int,int,\n\t\t\t  int,int,double [],double []);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLIntpt    *hp_copyIntpt(SISLIntpt *);\n#ifndef CONSTRUCT\nextern\n#endif\nSISLSegmentation *newSegmentation(double *segmentation, \n\t\t\t\t\t int *type, int nseg);\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeEdge(SISLEdge *);\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeIntdat(SISLIntdat *);\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeIntlist(SISLIntlist *);\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeIntpt(SISLIntpt *);\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeObject(SISLObject *);\n#ifndef DESTRUCT\nextern\n#endif\nvoid freePoint(SISLPoint *);\n#ifndef DESTRUCT\nextern\n#endif\nvoid freePtedge(SISLPtedge *);\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeIntsurf(SISLIntsurf *);\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeTrimpar(SISLTrimpar *);\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeTrack(SISLTrack * ptrack);\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeSegmentation(SISLSegmentation *);\n#ifndef MAKE3D\nextern\n#endif\nvoid make3D(SISLSurf *, SISLSurf **, int *);\n#ifndef S1119\nextern\n#endif\nvoid s1119(double *,double *,double *,int,int,int,int,int *,int *,int *,int *);\n#ifndef S1161\nextern\n#endif\nvoid s1161(SISLObject *,double *,double ,SISLIntdat **,int *);\n#ifndef S1162\nextern\n#endif\nvoid s1162(SISLObject *,double *,double,SISLIntdat **,SISLEdge *[2],int,\n\t   int,int *);\n#ifndef S1172\nextern\n#endif\nvoid s1172(SISLCurve *,double,double,double,double *,int *);\n#ifndef S1173\nextern\n#endif\nvoid s1173(SISLPoint *,SISLSurf *,double,double [],double [],double [],\n\t   double [],int *);\n#ifndef S1174\nextern\n#endif\nvoid s1174(SISLSurf *,double [],double [],double [],double [],int *);\n#ifndef S1190\nextern\n#endif\nvoid s1190(SISLObject *, double *, double, int *);\n#ifndef  S1192\nextern\n#endif\nvoid s1192(SISLObject *, double, int *);\n#ifndef  S1219\nextern\n#endif\nvoid s1219(double *,int,int,int *,double,int *);\n#ifndef  S1220\nextern\n#endif\nvoid s1220(double *,int,int,int *,double,int,double [],int *);\n#ifndef  S1222\nextern\n#endif\nvoid s1222(double *,int,int,int,double,int,double [],int *);\n#ifndef  S1223\nextern\n#endif\nvoid s1223(double [],double [],int,int,int,int,int,int,double [],\n\t   int,int,double [],int *);\n#ifndef  S1224\nextern\n#endif\nvoid s1224(double [],double [],int,int,int,int,int, int,double [],int,\n\t   double [],int *);\n#ifndef  S1231\nextern\n#endif\nvoid s1231(SISLCurve *,double,SISLCurve **,SISLCurve **,int *);\n#ifndef  S1232\nextern\n#endif\nvoid s1232(double [],int,int,double,double,double [],int *);\n#ifndef  S1235\nextern\n#endif\nvoid s1235(double [],int,int,int *,double **,int *);\n#ifndef  S1236\nextern\n#endif\nvoid s1236(double [],int,int,int,double [],int *);\n#ifndef  S1239\nextern\n#endif\nvoid s1239(SISLCurve *,int,double,SISLCurve *,double,double,SISLCurve **,\n\t   int,int *,int *);\n#ifndef  S1244\nextern\n#endif\nvoid s1244(double [],int,int,int,int,int,int,double *,int *);\n#ifndef  S1245\nextern\n#endif\nvoid s1245(double [],int,int,double [],double,int,double [],double *,\n           double *,int *);\n#ifndef  S1251\nextern\n#endif\nvoid s1251(SISLCurve *,double,double *,int *);\n#ifndef  S1252\nextern\n#endif\nvoid s1252(SISLCurve *,double,double,double *,int *);\n#ifndef S1291\nextern\n#endif\nvoid s1291(double cvder[], double sfder[], int idim, double cvder2[], \n\t   int *jstat);\n#ifndef  S1301\nextern\n#endif\nvoid s1301(double,double,int,SISLCurve **,int *);\n#ifndef  S1304\nextern\n#endif\nvoid s1304(double [],double [],double [],double [],\n\t   double [],double [],double [],int *);\n#ifndef  S1305\nextern\n#endif\nvoid s1305(double [],double [],double [],double [],int *,double [],int *);\n#ifndef  S1306\nextern\n#endif\nvoid s1306(double [],double [],double [],int,double [],double [],int *);\n#ifndef  S1307\nextern\n#endif\nvoid s1307(double [],int,double [],int *);\n#ifndef  S1308\nextern\n#endif\nvoid s1308(double [],int,double [],int,double [],int *);\n#ifndef  S1309\nextern\n#endif\ndouble s1309(double [],double [],double [],int,int *);\n#ifndef  S1311\nextern\n#endif\ndouble s1311(double,double,double,int *);\n#ifndef  S1312\nextern\n#endif\nvoid s1312(double [],int,int,int,double [],SISLCurve **,int *);\n#ifndef  S1313\nextern\n#endif\nvoid s1313(SISLSurf *,double [],int,double,double,double,\n\t   SISLIntcurve *,int,int,int *);\n#ifndef  S1320\nextern\n#endif\nvoid s1320(SISLSurf *,double [],int,int,SISLSurf **,int *);\n#ifndef  S1321\nextern\n#endif\nvoid s1321(double [],double,int,int,double [],int *);\n#ifndef  S1322\nextern\n#endif\nvoid s1322(double [],double [],double,int,int,double [],int *);\n#ifndef  S1323\nextern\n#endif\nvoid s1323(double [],double [],double [],int,int,double [],int *);\n#ifndef  S1324\nextern\n#endif\nvoid s1324(double [],double,double [],int,double [],int *);\n#ifndef  S1325\nextern\n#endif\ndouble s1325(double,double);\n#ifndef  S1326\nextern\n#endif\nvoid s1326(SISLSurf *ps, int power, double *ecimp, int inarr, double **et1,\n\t   double **et2, double **ecoef, int *ik1, int *ik2, int *in1,\n\t   int *in2, int *numprd, int *jstat);\n#ifndef  S1329\nextern\n#endif\nvoid s1329(SISLSurf *,double [],double [],int,SISLSurf **,int *);\n#ifndef  S1330\nextern\n#endif\nvoid s1330(double [],double [],double [],double [],double [],double [],\n\t   double [],double [],int *,double [],double [],int *);\n#ifndef  S1331\nextern\n#endif\nvoid s1331(double [],double [],int,int,double [],double [],int *);\n#ifndef  S1333\nextern\n#endif\nvoid s1333(int,SISLCurve *[],int [],double,int,int,int,SISLSurf **,\n\t   double **,int *);\n#ifndef  S1333_COUNT\nextern\n#endif\nvoid s1333_count(int,SISLCurve *[],int *,int *);\n#ifndef  S1333_CYCLIC\nextern\n#endif\nvoid s1333_cyclic(SISLSurf *,int,int *);\n#ifndef  S1334\nextern\n#endif\nvoid s1334(double [],int,int,double [],int,int,int,int,double,\n\t   double *,SISLCurve **,double **,int *,int *);\n#ifndef  S1339\nextern\n#endif\nvoid s1339(SISLSurf *ps, int ipow, double ea[], int inumprd, int incoef,\n\t   double aepsge, double ecimp[], double *cgrad, int *jstat);\n#ifndef  S1340\nextern\n#endif\nvoid s1340(SISLCurve *,double [],int,int,double,int,SISLCurve **,\n\t   double [],int *);\n#ifndef  S1341\nextern\n#endif\nvoid s1341(double [],int,int,int,double [],double [],int,int,\n\t   double,double,int,int,SISLCurve **,double [],int *);\n#ifndef  S1342\nextern\n#endif\nvoid s1342(double [],double [],int,int,int,double [],\n\t   double [],int,int,double,int,SISLCurve **,double [],int *);\n#ifndef  S1343\nextern\n#endif\nvoid s1343(SISLCurve *,double [],int,int,double,int,SISLCurve **,int *);\n#ifndef  S1345\nextern\n#endif\nvoid s1345(SISLSurf *,double [],int [],double [],double,int,int,\n\t   SISLSurf **,double [],int *);\n#ifndef  S1346\nextern\n#endif\nvoid s1346(double [],int,int,int,int,double [],double [],double [],\n\t   int [],double [],double,double,int,int,int,int,\n\t   SISLSurf **,double [],int *);\n#ifndef  S1347\nextern\n#endif\nvoid s1347(double [],double [],double [],double [],int,int,int,int,\n\t   double [],double [],double [],int [],double [],double,int,\n\t   int,SISLSurf **,double [],int *);\n#ifndef  S1348\nextern\n#endif\nvoid s1348(SISLSurf *,double [],int [],double [],double,int,int,\n\t   SISLSurf **,int *);\n#ifndef  S1349\nextern\n#endif\nvoid s1349(int,SISLCurve *[],int *);\n#ifndef  S1350\nextern\n#endif\nvoid s1350(double [],double [],int,int,int,SISLCurve **,int *);\n#ifndef  S1351\nextern\n#endif\nvoid s1351(double [],int,int,int,int,SISLCurve **,int *);\n#ifndef  S1352\nextern\n#endif\nvoid  s1352(double [],int,int,double [],double [],\n\t    double [],int,int,int,double [],int *);\n#ifndef  S1353\nextern\n#endif\nvoid s1353(SISLCurve *,double [],rank_info *,int *);\n#ifndef  S1354\nextern\n#endif\nvoid s1354(SISLCurve *,SISLCurve *,rank_info *,double [],\n\t   double [],int,int,int,int,SISLCurve **,double [],int *);\n#ifndef  S1355\nextern\n#endif\nvoid s1355(SISLCurve *,double [],double **,int *,int *);\n#ifndef  S1358\nextern\n#endif\nvoid s1358(double [],int,int,double [],double [],int,int,int,int,double,\n\t   double *,SISLCurve **,double **,int *,int *);\n#ifndef  S1359\nextern\n#endif\nvoid s1359(double [],double,int,int,int,double [],SISLCurve **,int *);\n#ifndef  S1361\nextern\n#endif\nvoid s1361(double [],double [],int,double [],double [],int *);\n#ifndef  S1362\nextern\n#endif\nvoid s1362(SISLCurve *,double,double [],int,int,double,int *,double [],int *);\n#ifndef S1366\nextern\n#endif\nvoid s1366(SISLSurf *,double,double,double,int,\n\t   double *,int,int,double *,int,int,SISLSurf **,int *);\n#ifndef S1367\nextern\n#endif\nvoid s1367(SISLSurf *,double,double,int,double [],\n\t   int,int *,int *,double [],int *);\n#ifndef  S1370\nextern\n#endif\nvoid s1370(SISLCurve *,double [],int,int,int,SISLCurve **,int *);\n#ifndef  S1376\nextern\n#endif\nvoid s1376(double [],int,int,double **,int *,int *,int *);\n#ifndef  S1377\nextern\n#endif\nvoid s1377(SISLCurve *,double [],int,int,SISLCurve **,int *);\n#ifndef  S1378\nextern\n#endif\nvoid s1378(SISLSurf *,double [],int,int,SISLSurf **,int *);\n#ifndef  S1381\nextern\n#endif\nvoid s1381(double [],int,int,double **,int *,int,int *);\n#ifndef  S1382\nextern\n#endif\nvoid s1382(SISLSurf *,double [],int,SISLSurf **,int *);\n#ifndef  S1384\nextern\n#endif\nvoid s1384(SISLCurve *,SISLSurf *,int,int,double,int *,int *,int *,double [],\n\t   double [],double [],double [],int *);\n#ifndef  S1385\nextern\n#endif\nvoid s1385(double [],double [],double [],double,int,double,SISLCurve **,int *);\n#ifndef  S1393\nextern\n#endif\nvoid s1393(int,SISLCurve *[],SISLCurve *[],SISLCurve *[],int *);\n#ifndef  S1399\nextern\n#endif\nvoid s1399(SISLCurve *,double,double);\n#ifndef  S1435\nextern\n#endif\nvoid s1435(SISLSurf *,int,SISLCurve **,double *,int *);\n#ifndef  S1436\nextern\n#endif\nvoid s1436(SISLSurf *,double,SISLCurve **,int *);\n#ifndef  S1437\nextern\n#endif\nvoid s1437(SISLSurf *,double,SISLCurve **,int *);\n#ifndef  S1438\nextern\n#endif\nvoid s1438(SISLCurve  *,int,SISLPoint **,double *,int *);\n#ifndef  S1452\nextern\n#endif\nvoid s1452(SISLSurf *,double,double,SISLSurf **,int *);\n#ifndef S1500\nextern\n#endif\nvoid s1500(double [],double [],double [],double,double,int,int,\n\t   double [],int *);\n#ifndef S1504\nextern\n#endif\nvoid s1504(double *,int,int,double *,int,int,double [],int [],int *);\n#ifndef S1505\nextern\n#endif\nvoid s1505(const SISLSurf *,int,int,int,double *,double *, int *,\n           int *,double [],double [],int *);\n#ifndef S1507\nextern\n#endif\nvoid s1507(SISLCurve **, int, int, SISLCurve ***, int *);\n#ifndef S1512\nextern\n#endif\nvoid s1512(SISLSurf *,double [],int,SISLSurf **,int *);\n#ifndef S1513\nextern\n#endif\nvoid s1513(SISLSurf *,double [],double [],int,SISLSurf **,int *);\n#ifndef S1516\nextern\n#endif\nvoid s1516(double [],double [],int,int,double **,int *);\n#ifndef S1517\nextern\n#endif\nvoid s1517(double [],double [],double [],int,double,double **,int *);\n#ifndef  S1520\nextern\n#endif\nvoid s1520(SISLCurve *,double,double [],double [],SISLSurf **,int *);\n#ifndef S1521\nextern\n#endif\nSISLCurve* s1521(SISLCurve *,int *);\n#ifndef S1528\nextern\n#endif\nvoid s1528(int,int,int,double [],int,int,int,double **,double **,int *);\n#ifndef S1531\nextern\n#endif\nvoid s1531(double [],int,int,int,double **,int *);\n#ifndef S1540\nextern\n#endif\nvoid s1540(double [], int, int, double [], int, int, double [], int [], int *);\n#ifndef S1541\nextern\n#endif\nvoid s1541(SISLCurve *, int, double [], int [], double [], int *);\n#ifndef  S1604\nextern\n#endif\nvoid s1604(double [],int,double,int,int,int,SISLCurve **,int *);\n#ifndef  S1605\nextern\n#endif\nvoid s1605(SISLCurve *,double,double **,int *,int *);\n#ifndef  S1612\nextern\n#endif\nvoid s1612(SISLCurve *,double,double **,int *,int *,int *);\n#ifndef  S1613BEZ\nextern\n#endif\nvoid s1613bez(SISLCurve *,int,double,double **,int *,int *);\n#ifndef S1614\nextern\n#endif\nvoid s1614(double [],int,int,int [],double [],int *,int [],int *);\n#ifndef S1615\nextern\n#endif\nvoid s1615(double [],int,int,int [],int *);\n#ifndef S1616\nextern\n#endif\nvoid s1616(double [],int,int,int [],double [],int *);\n#ifndef S1617\nextern\n#endif\nvoid s1617(double [],int,int,int [],double,double [],\n           double [],double [],double [],double *,int *);\n#ifndef S1618\nextern\n#endif\nvoid s1618(double [],double [],double[],int,double *);\n#ifndef S1619\nextern\n#endif\nvoid s1619(double [],int,int,int [],double [],int,double[],double *, int *);\n#ifndef  S1700\nextern\n#endif\nvoid s1700(int,int,int,int,int *,int *,int *,double *,double,double *,int *);\n#ifndef  S1701\nextern\n#endif\nvoid s1701(int,int,int,int,int *,int *,int *,\n\t   double *,double *,double *,double *,int *);\n#ifndef  S1705\nextern\n#endif\nvoid s1705(SISLCurve *,int *);\n#ifndef  S1707\nextern\n#endif\nvoid s1707(SISLCurve *,int *);\n#ifndef  S1708\nextern\n#endif\nvoid s1708(SISLSurf *,int *);\n#ifndef  S1741\nextern\n#endif\nvoid s1741(SISLObject *,SISLObject *,double,int *);\n#ifndef S1753\nextern\n#endif\nvoid\ns1753(double [],double [],int,int,int,double [],double [],int,\n      double [],double [],int *);\n#ifndef S1754\nextern\n#endif\nvoid\ns1754(double *,int,int,int,double **,int *,int *);\n#ifndef S1755\nextern\n#endif\nvoid\ns1755(double [],int,int,double [],int *,int *);\n#ifndef  S1770\nextern\n#endif\nvoid s1770(SISLCurve *,SISLCurve *,double,double,double,double,double,\n\t   double,double,double *,double *,int *);\n#ifndef  S1770_2D\nextern\n#endif\n   void s1770_2D(SISLCurve *,SISLCurve *,double,double,double,double,double,\n\t\t double,double,double *,double *,int *);\n#ifndef  S1771\nextern\n#endif\nvoid s1771(SISLPoint *,SISLCurve *,double,double,double,double,double *,int *);\n#ifndef  S1772\nextern\n#endif\nvoid s1772(SISLCurve *,SISLSurf *,double,double,double [],double,double [],\n\t   double,double [],double *,double [],int *);\n#ifndef  S1773\nextern\n#endif\nvoid s1773(SISLPoint *,SISLSurf *,double,double [],double [],double [],\n\t   double [],int *);\n#ifndef  S1780\nextern\n#endif\nvoid s1780(SISLCurve *,SISLCurve *,SISLIntpt *[],int *);\n#ifndef  S1785\nextern\n#endif\nvoid s1785(SISLCurve *,SISLSurf *,double,double [],double [],int,int *);\n#ifndef  S1786\nextern\n#endif\nvoid s1786(SISLCurve *,SISLCurve *,double,double [],double [],int *);\n#ifndef  S1787\nextern\n#endif\nvoid s1787(SISLSurf *,double,double,double [],double [],double [],int *);\n#ifndef  S1788\nextern\n#endif\nvoid s1788(SISLSurf *,SISLSurf *,double,double [],double [],double [],int *);\n#ifndef  S1789\nextern\n#endif\nvoid s1789(SISLPoint *,SISLSurf *,double ,double [],double [],int *);\n#ifndef  S1790\nextern\n#endif\nvoid s1790(SISLObject *,SISLObject *,double,int *);\n#ifndef  S1791\nextern\n#endif\nint s1791(double [],int,int);\n#ifndef  S1792\nextern\n#endif\ndouble s1792(double [],int,int);\n#ifndef  S1795\nextern\n#endif\nvoid s1795(SISLSurf *,SISLSurf *,double,double,int *);\n#ifndef  S1796\nextern\n#endif\nvoid s1796(SISLCurve *,SISLCurve *,double,double,int *);\n#ifndef  S1797\nextern\n#endif\nvoid s1797(SISLSurf *,SISLCurve *,double,double,int *);\n#ifndef  S1830\nextern\n#endif\nvoid s1830(SISLSurf *,SISLCurve *,int *);\n#ifndef  S1834\nextern\n#endif\nvoid s1834(double [],int,double [],int,int,double [],double [],int *);\n#ifndef  S1839\nextern\n#endif\nvoid s1839(SISLSurf *,double [],int,int,int *);\n#ifndef  S1840\nextern\n#endif\nvoid s1840(SISLCurve *,double *,int *);\n#ifndef  S1880\nextern\n#endif\nvoid s1880(int,int,int *,SISLIntpt **,int *,SISLIntlist **,\n\t   int *,double **,double **,int *,SISLIntcurve ***,int *);\n#ifndef S1890\nextern\n#endif\nvoid\ns1890(double [],int,int,double *[],int *[],int *);\n#ifndef S1891\nextern\n#endif\nvoid\ns1891(double [],double [],int,int,int,int [],int,double [],\n      double *[],int *,int,int,int,int *);\n#ifndef S1893\nextern\n#endif\nvoid\ns1893(SISLCurve *,double [],int,int,int,int,SISLCurve **,int *);\n#ifndef S1894\nextern\n#endif\nvoid\ns1894(double [],int,int,int,int,double [],int,int,double *[],int *,\n      int *,int *);\n#ifndef S1896\nextern\n#endif\nvoid\ns1896(SISLSurf *,double [],int,int,int [],int [],int [],int [],SISLSurf **,int *);\n#ifndef S1897\nextern\n#endif\nvoid\ns1897(double [],int,double,int,int,double [],int *);\n#ifndef S1900\nextern\n#endif\nvoid\ns1900(double [],double [],double [],int [],int,int,int,int,\n      double *,SISLCurve **,double **,int *,int *);\n#ifndef S1901\nextern\n#endif\nvoid\ns1901(void (*)(double[],int[],int,int,int,double,double *,\n\t       double *[],double *[],int *),\n      void (*)(double[],int,int,int,double *[],int *),\n      double [],int [],int,double,int,int,int,\n      double *,SISLCurve **,double **,int *,int *);\n#ifndef S1902\nextern\n#endif\nvoid\ns1902(double [],int,int,int,double *[],int *);\n#ifndef S1903\nextern\n#endif\nvoid\ns1903(double [],int,int,int,double *[],int *);\n#ifndef S1904\nextern\n#endif\nvoid\ns1904(double [],int,int,int,double *[],int *);\n#ifndef S1905\nextern\n#endif\nvoid\ns1905(double [],int [],int,int,int,int,double **,int **,int *,int *);\n#ifndef S1906\nextern\n#endif\nvoid\ns1906(double *,int *,int,int,int,int,double **,int **,int *,int *);\n#ifndef S1907\nextern\n#endif\nvoid\ns1907(double *,int *,double *,int,int,int,int,int,\n      double *[],int *[],double *[],int *,int *);\n#ifndef S1908\nextern\n#endif\nvoid\ns1908(double [],int [],double [],int,int,int,int,\n      double *[],int *[],double *[],int *,int *);\n#ifndef S1909\nextern\n#endif\nvoid\ns1909(double [],int [],int,int,int,double,double *,double *[],\n      double *[],int *);\n#ifndef S1910\nextern\n#endif\nvoid\ns1910(double [],int [],int,int,int,double,double *,double *[],\n      double *[],int *);\n#ifndef S1911\nextern\n#endif\nvoid\ns1911(double [],int [],int,int,int,double,double *,double *[],\n      double *[],int *);\n#ifndef S1912\nextern\n#endif\nvoid\ns1912(void (*)(double[],int[],int,int,int,double,double *,\n\t       double *[],double *[],int *),\n      void (*)(double[],int,int,int,double *[],int *),\n      double [],int [],int,double,int,int,int,\n      double *,SISLCurve **,double **,int *,int *);\n#ifndef S1916\nextern\n#endif\nvoid\ns1916(int,double [],double [],int,int,int,int,double [],int [],int *);\n#ifndef S1917\nextern\n#endif\nvoid\ns1917(int,double [],int,int,int [],double,int,double *[],int *[],int *i,int *);\n#ifndef S1918\nextern\n#endif\nvoid\ns1918(int,double [],double [],int,int,int,double [],int [],int *);\n#ifndef S1919\nextern\n#endif\nvoid\ns1919(double [],double [],double [],double [],double [],int,int,int,int,int,\n      double,double,double,int *);\n#ifndef S1924\nextern\n#endif\nvoid\ns1924(int,int,int,int,int,int,double **,int *);\n#ifndef S1925\nextern\n#endif\nvoid\ns1925(double [],double [],int,int [],double [],double [],int,int,int,int,\n      double [],int,int [],double [],int,double [],int,int *);\n#ifndef S1926\nextern\n#endif\nvoid\ns1926(double *,int,int,int *,double *,int,double *,int,int *);\n#ifndef S1927\nextern\n#endif\nvoid\ns1927(double *,int,int,int *,double *,int,double *,int,double *[],\n      double *,int *);\n#ifndef S1930\nextern\n#endif\nvoid\ns1930(int,SISLCurve **,double **,double **,int *,int *,int *);\n#ifndef S1931\nextern\n#endif\nvoid\ns1931(int,SISLCurve **,double **,double **,int *,int *,int *);\n#ifndef S1931UNIT\nextern\n#endif\nvoid s1931unit (int,SISLCurve **,double **,double **,int *,int *,int *);\n#ifndef S1932\nextern\n#endif\nvoid\ns1932(int,SISLCurve **,double,double,double *,int,int,double **,int *);\n#ifndef S1933\nextern\n#endif\nvoid\ns1933(int,SISLCurve *[],double,double,double **,int *,int *,int *);\n#ifndef S1934\nextern\n#endif\nvoid\ns1934(double *,int,int,double,double,int *);\n#ifndef S1935\nextern\n#endif\nvoid\ns1935(double *,int,double *,int,double *[],int *,int,int *);\n#ifndef S1936\nextern\n#endif\nvoid\ns1936(SISLCurve *,double [],int,double *,int *);\n#ifndef S1937\nextern\n#endif\nvoid\ns1937(double [],int,int,int,double [],double []);\n#ifndef S1938\nextern\n#endif\nvoid\ns1938(SISLSurf *,double [],int,double [],int,double **,int *);\n#ifndef S1941\nextern\n#endif\nvoid\ns1941(SISLCurve *pcurve,int icont,int *jstat);\n#ifndef S1942\nextern\n#endif\nvoid s1942(SISLCurve *pc1,SISLCurve *pc2,int idim,double ea[],int nstart[],\n             int nstop[],double emxerr[],double el2err[],int *jstat);\n#ifndef S1943\nextern\n#endif\nvoid\n   s1943(SISLCurve *pcurve,double etau[],int ik,int in,int ileftfix,\n             int irightfix,int incont,SISLCurve **rnewcurve,\n             double gmaxerr[],double gl2err[],int *jstat);\n#ifndef S1944\nextern\n#endif\nvoid\n   s1944(double etau[],int ik,int in,int idim,double et[],double ed[],\n             int im,int inlc,int inlr,int inorm,double ea[],double ew1[],\n             int nfirst[],int nlast[],double eb[],double ew2[],\n             int n2sta[],double ec[],int *jstat);\n#ifndef S1945\nextern\n#endif\nvoid\n   s1945(double etau[],int ik,int in,int idim,double et[],\n             double ed[],int im,int ilend,int irend, int inlc,\n             int inlr, int inorm, double ea[], double ew1[], int inh,\n             int nfirst[],int nlast[],double eb[],\n             double ew2[], double ec[],int n2sta[],int *jstat);\n#ifndef S1946\nextern\n#endif\nvoid\n   s1946(double ea[],double ew1[],int nfirst[],int nlast[],double ed[],\n         double ec[],int ik,int in,int im,int idim,int ilend,int irend,\n         int inlr, int inlc,int *jstat);\n#ifndef S1947\nextern\n#endif\nvoid\n   s1947(double ea[], int nfirst[], int nlast[], int ik, int im,\n         double etau[], int in, int incont, double ew[], int inlr,\n         int *jnred, double efac[], int *jstat);\n#ifndef S1948\nextern\n#endif\nvoid\n   s1948(double *ea,double *ew,int in,int ik,int inlr,\n         int *nstart,int *jstat);\n#ifndef S1949\nextern\n#endif\nvoid\n   s1949(double *ea,double *ew,double *eb,int in,int ik,int inlr,\n         int idim,int *nstart,int *jstat);\n#ifndef S1950\nextern\n#endif\nvoid s1950(SISLCurve *oldcurve,SISLCurve *rankcurve,rank_info *ranking,\n           double eps[],double epsco[],int startfix,int endfix,int *jncont,\n           int mini,int maxi,SISLCurve **newcurve,double maxerr[],int *stat);\n#ifndef S1951\nextern\n#endif\nvoid\n   s1951(double etau[], double ecoef[], int in, int ik, int idim,\n         int ilend, int irend, int incont, double efac[]);\n#ifndef  S1956\nextern\n#endif\nvoid s1956(SISLCurve *,SISLCurve *,SISLSurf **,int *);\n#ifndef  S1959\nextern\n#endif\nvoid s1959(SISLPoint *, SISLCurve *, double *, int *);\n#ifndef  S1960\nextern\n#endif\nvoid s1960(SISLPoint *, SISLSurf *, double [], int *);\n#ifndef S1990\nextern\n#endif\nvoid s1990(SISLSurf *, double, int *);\n#ifndef  S1991\nextern\n#endif\nvoid s1991(SISLCurve *,double,int *);\n#ifndef  S1992\nextern\n#endif\nvoid s1992(SISLObject *,int *);\n#ifndef  S1992\nextern\n#endif\nvoid s1992cu(SISLCurve *,int *);\n#ifndef  S1992\nextern\n#endif\nvoid s1992su(SISLSurf *,int *);\n#ifndef  S1993\nextern\n#endif\nvoid s1993(SISLCurve *,int *);\n#ifndef  S1994\nextern\n#endif\nvoid s1994(SISLSurf *,int *);\n#ifndef  S2501\nextern\n#endif\nvoid s2501(SISLSurf *, int, double [], double [], double *, int *);\n#ifndef  S2503\nextern\n#endif\nvoid s2503(SISLSurf *, int, double [], double [], double *, int *);\n#ifndef  S2505\nextern\n#endif\nvoid s2505(SISLSurf *, int, double [], double [], double *, int *);\n#ifndef  S2507\nextern\n#endif\nvoid s2507(SISLSurf *, int, double [], double [], double *, int *);\n#ifndef  S2509\nextern\n#endif\nvoid s2509(SISLSurf *, int, double [], double [], double *, int *);\n#ifndef  S2511\nextern\n#endif\nvoid s2511(SISLSurf *, int, double [], double [], double *, int *);\n#ifndef  S2512\nextern\n#endif\nvoid s2512(SISLSurf *, int, int, int, double [], int *, int *, double [], int *);\n#ifndef  S2513\nextern\n#endif\nvoid s2513(SISLSurf *, int, int, int, double [], double [], double [], int *);\n#ifndef  S2514\nextern\n#endif\nvoid s2514(SISLSurf *, int, double [], double [], double [], int *);\n#ifndef  S2515\nextern\n#endif\nvoid s2515(SISLSurf *, int, int, int, double [], int *,int *, double [], int *);\n#ifndef  S2516\nextern\n#endif\nvoid s2516(SISLSurf *, int, double [], double [], double [], int *);\n#ifndef  S2533\nextern\n#endif\nvoid s2533(double *, int, int, int, int, int *, double **, int *);\n#ifndef  S2534\nextern\n#endif\nvoid s2534(SISLSurf *, int, int, int, int,\n           void evalp(SISLSurf *, int, int, int,\n\t\t     double [], int *, int *,\n\t\t     double *, int *),\n\t int, SISLSurf **, int *);\n#ifndef  S2535\nextern\n#endif\nvoid s2535(SISLSurf *, int, int, int *, int *, SISLSurf ***, int *);\n#ifndef  S2541\nextern\n#endif\nvoid s2541(SISLSurf *surf,\n           void evalp(SISLSurf *, int, int, int, double [], int *, int *,\n\t\t      double *, int *),\n\t int, int, int, double [], int, int, double **, int *);\n#ifndef  S2543\nextern\n#endif\nvoid s2543(SISLSurf *, int, double [], double [], double *, double *,\n\t   double [], double [], int *);\n#ifndef  S2551\nextern\n#endif\nvoid s2551(SISLCurve *, double, int *, double [], double *, int *);\n#ifndef  S2554\nextern\n#endif\nvoid s2554(SISLCurve *, double, int *, double [], double *, int *);\n#ifndef  S2555\nextern\n#endif\nvoid s2555(double [], double *, int *);\n#ifndef  S2557\nextern\n#endif\nvoid s2557(SISLCurve *, double, int *, double [], double *, int *);\n#ifndef  S2558\nextern\n#endif\nvoid s2558(double [], int, double *, int *);\n#ifndef  S2560\nextern\n#endif\nvoid s2560(SISLCurve *, double, int *, double [], double [], double [],\n           double [], double [], int *);\n#ifndef  S2561\nextern\n#endif\nvoid s2561(double [], int, double [], double [], double [], double [], int *);\n#ifndef  S6ADDCURVE\nextern\n#endif\nvoid s6addcurve(SISLCurve *,SISLCurve *,int,SISLCurve **,int *);\n#ifndef  S6AFFDIST\nextern\n#endif\ndouble s6affdist(double [],double [],double [],int);\n#ifndef  S6ANG\nextern\n#endif\ndouble s6ang(double [],double [],int);\n#ifndef  S6ANGLE\nextern\n#endif\ndouble s6angle(double [],double [],double [],int,int *);\n#ifndef S6BEZPOWSF\n      extern\n#endif\n      void  s6bezpowsf(double *c1, int order11,int order12, int power, \n\t\t       double *Pascal, double *c1_power);\n#ifndef  S6CHPAR\nextern\n#endif\nvoid s6chpar(double [],int,int,int,double []);\n#ifndef  S6CRSS\nextern\n#endif\nvoid s6crss(double [],double [],double []);\n#ifndef  S6CRVCHECK\nextern\n#endif\nvoid s6crvcheck(SISLCurve *,int *);\n#ifndef  S6CURVATURE\nextern\n#endif\nvoid s6curvature(double [],int,double [],int *);\n#ifndef  s6CURVRAD\nextern\n#endif\nvoid s6curvrad(double [],double [],double [],int,double *,int *);\n#ifndef  S6DECASTELJAU\nextern\n#endif\nvoid     s6deCasteljau(double [],double,double,double,int,double [],int *);\n#ifndef  S6DECOMP\nextern\n#endif\nvoid s6decomp(double [],double [],double [],double [],double [],int *);\n#ifndef  S6DEGNORM\nextern\n#endif\nvoid s6degnorm(SISLSurf *,int,double[],double[],double[],double[],\n\t       double[],int *);\n#ifndef  S6DERTOPT\nextern\n#endif\nvoid s6dertopt(double [],int [],int,int,double [],int *);\n#ifndef  S6DIFF\nextern\n#endif\nvoid s6diff(double [],double [],int,double []);\n#ifndef  S6DIST\nextern\n#endif\ndouble s6dist(double [],double [],int);\n#ifndef  S6DLINE\nextern\n#endif\ndouble s6dline(double [],double [],double [],int,int *);\n#ifndef  S6DPLANE\nextern\n#endif\ndouble  s6dplane(double [],double [],double [],double [],int,int *);\n#ifndef  S6EQUAL\nextern\n#endif\nint s6equal(double,double,double);\n#ifndef  S6ERR\nextern\n#endif\nvoid s6err(char *,int,int);\n#ifndef  S6EXISTBOX\nextern\n#endif\nint s6existbox(SISLbox *,int,double);\n#ifndef S6FINDFAC\nextern\n#endif\nvoid s6findfac(double [],double [],double [],double [],int,int,\n\t       double *,double *,double *,int *);\n#ifndef S6FNDINTVL\nextern\n#endif\nvoid s6fndintvl(double *et,int ik,int in,int *ileft,\n\t      double ax1,double ax2,int mu_max,int *jstat);\n#ifndef S6HERM\nextern\n#endif\nvoid s6herm(double *,double *,double *,int,int,int,int,int,double [],int *);\n#ifndef  S6HERMITE_BEZIER\nextern\n#endif\nvoid     s6hermite_bezier(SISLSurf *,double [],double [],int,double [],int *);\n#ifndef  S6IDCON\nextern\n#endif\nvoid s6idcon(SISLIntdat **,SISLIntpt **,SISLIntpt **,int *);\n#ifndef  S6IDCPT\nextern\n#endif\nvoid s6idcpt(SISLIntdat *,SISLIntpt *,SISLIntpt **);\n#ifndef  S6IDEDG\nextern\n#endif\nvoid s6idedg(SISLObject *,SISLObject *,int,int,double,SISLIntdat *,\n\t     SISLPtedge **,int *,int *);\n#ifndef  S6IDENTIFY\nextern\n#endif\nvoid     s6identify(SISLSurf *,double [],double [],double,double,double,int *);\n#ifndef  S6IDGET\nextern\n#endif\nvoid s6idget(SISLObject *,SISLObject *,int,double,SISLIntdat *,\n\t     SISLIntdat **,int *);\n#ifndef  S6IDINT\nextern\n#endif\nvoid s6idint(SISLObject *,SISLObject *,SISLIntdat *,SISLIntpt **,int);\n#ifndef  S6IDKLIST\nextern\n#endif\nvoid s6idklist(SISLIntdat **,SISLIntlist *,int *);\n#ifndef  S6IDKPT\nextern\n#endif\nvoid s6idkpt(SISLIntdat **,SISLIntpt **,SISLIntpt **,SISLIntpt **,int *);\n#ifndef  S6IDLIS\nextern\n#endif\nvoid s6idlis(SISLObject *,SISLObject *,SISLIntdat **,int *);\n#ifndef  S6IDNPT\nextern\n#endif\nvoid s6idnpt(SISLIntdat **,SISLIntpt **,int,int *);\n#ifndef  S6IDPUT\nextern\n#endif\nvoid s6idput(SISLIntdat **,SISLIntdat *,int,double,int *);\n#ifndef S6INV4\nextern\n#endif\nvoid s6inv4 (double [], double [], int *);\n#ifndef  S6INVERT\nextern\n#endif\nvoid s6invert(double [],int,double [],int *);\n#ifndef  S6KNOTMULT\nextern\n#endif\nint s6knotmult(double [],int,int,int *,double,int *);\n#ifndef  S6LENGTH\nextern\n#endif\ndouble s6length(double [],int,int *);\n#ifndef  S6LINE\nextern\n#endif\nvoid s6line(double []);\n#ifndef  S6LPRJ\nextern\n#endif\ndouble s6lprj(double [],double [],int);\n#ifndef  S6LUFACP\nextern\n#endif\nvoid s6lufacp(double [],int [],int,int *);\n#ifndef  S6LUSOLP\nextern\n#endif\nvoid s6lusolp(double [],double [],int [],int,int *);\n#ifndef  S6METRIC\nextern\n#endif\nvoid s6metric(double [],int,int,double [],int *);\n#ifndef  S6MOVE\nextern\n#endif\nvoid s6move(double []);\n#ifndef S6MULVEC\nextern\n#endif\nvoid s6mulvec (double [],double [],double []);\n#ifndef S6MULTSFS\nextern\n#endif\nvoid \ns6multsfs(double *c1, int order11,int order12,\n\t  double* c2, int order21,int order22,\n\t  double *Pascal,\n\t  double *newsurf, int *order_newsurf1,int *order_newsurf2);\n#ifndef  S6MVEC\nextern\n#endif\nvoid s6mvec(double [],double [],int,double []);\n#ifndef  S6NEWBOX\nextern\n#endif\nvoid s6newbox(SISLbox *pbox,int inum,int itype,double aepsge,int *jstat);\n#ifndef  S6NORM\nextern\n#endif\ndouble s6norm(double [],int,double [],int *);\n#ifndef S6NULLSPACE\nextern\n#endif\nvoid s6nullspace(double ea[],int im1,int im2,double aepsge,\n\t\t double **nullspace,int *numbvect,int *jstat);\n#ifndef  S6RATDER\nextern\n#endif\nvoid s6ratder(double [],int,int,double [],int *);\n#ifndef  S6ROTAX\nextern\n#endif\nvoid s6rotax(double [],double [],double [],double [],int *);\n#ifndef S6ROTMAT\nextern\n#endif\nvoid s6rotmat (double [],double [],double [],double [],int *);\n#ifndef S6SCHOEN\nextern\n#endif\ndouble s6schoen(double [],int, int);\n#ifndef S6SCPR\nextern\n#endif\ndouble s6scpr(double [],double [],int);\n#ifndef  S6SORTPAR\nextern\n#endif\nvoid s6sortpar(double [],double [],int,int,double [],double [],int *);\n#ifndef S6SRATDER\nextern\n#endif\nvoid s6sratder(double [],int,int,int,double [],int *);\n#ifndef S6STRIDER\nextern\n#endif\nvoid s6strider(double [],int,int,double [],int *);\n#ifndef  S6TAKEUNION\nextern\n#endif\nvoid s6takeunion(double [],int,double [],int,double **,int *,int *);\n#ifndef  S6TESTIMPL\nextern\n#endif\nvoid s6testimpl(SISLSurf *ps1, SISLSurf *ps2, int first, SISLIntpt *vintpt[],\n\t\tint inmbpt, double aepsge, int *jstat);\n#ifndef  S6TWONORM\nextern\n#endif\nvoid s6twonorm(double [],double [],double [],int *);\n#ifndef S9ADSIMP\nextern\n#endif\ndouble s9adsimp(double [],double [],double [],int,double [],\n\t\tdouble [],double [],double [],double,int *);\n#ifndef S9ADSTEP\nextern\n#endif\ndouble s9adstep(double [],double [],double [],double [],\n\t\tdouble [],double [],double [],double [],\n\t\tdouble [],double [],double [],double,int *);\n#ifndef S9BOUNDIMP\nextern\n#endif\nvoid s9boundimp(double [],double [],SISLSurf *,double [],\n\t\tint,double,int,double,double [],double [],int *);\n#ifndef  S9BOUNDIT\nextern\n#endif\nvoid s9boundit(double [],double [],double [],double [],\n\t       SISLSurf *,SISLSurf *,double,int,double,\n\t       double [],double [],double [],double [],int *);\n#ifndef  S9CLIPIMP\nextern\n#endif\nvoid s9clipimp(double [],double [],SISLSurf *,double [],\n\t       int,double [],double [],double,double [],double [],int *);\n#ifndef  S9CLIPIT\nextern\n#endif\nvoid s9clipit(double [],double [],double [],double [],SISLSurf *,SISLSurf *,\n\t      double [],double [],double [],double [],double,double [],\n\t      double [],double [],double [],int *);\n#ifndef  S9CONMARCH\nextern\n#endif\nvoid s9conmarch(SISLSurf *,double,double [],int [],int,\n\t\tdouble *[],int *[],int *,int *);\n#ifndef  S9ITERATE\nextern\n#endif\nvoid s9iterate(double [],double [],double [],double [],double [],\n\t       SISLSurf *,SISLSurf *,double,double,double [],double [],\n\t       double [],double [],int *);\n#ifndef  S9ITERIMP\nextern\n#endif\nvoid s9iterimp(double [],double [],double [],SISLSurf *,double [],int,\n\t       double,double,double [],double [],int *);\n#ifndef  S9SIMPLE_KNOT\nextern\n#endif\nvoid \t s9simple_knot(SISLSurf *,int,double [],int *,int *);\n#ifndef  S9SURMARCH\nextern\n#endif\nvoid s9surmarch(SISLSurf *,SISLSurf *,double [],int [],int,\n\t\tdouble *[],int *[],int *,int *);\n#ifndef  SH1260\nextern\n#endif\nvoid sh1260(double aconst,SISLCurve *vcurve[],int icurve,int *jstat);\n#ifndef  SH1261\nextern\n#endif\nvoid sh1261(SISLCurve *pcurve1,SISLCurve *pcurve2,double ecoef1[],\n             int ik1,double ecoef2[],int ik2,SISLCurve **rcrtanc,int *jstat);\n#ifndef  SH1262\nextern\n#endif\nvoid sh1262(SISLCurve *vcurve[],int iedge,int inmbx,double ecoef[],int *jstat);\n#ifndef  SH1263\nextern\n#endif\nvoid sh1263(SISLCurve *vcurve[],int iedge,SISLCurve *vboundc[],int *jstat);\n#ifndef  SH1365\nextern\n#endif\nvoid sh1365(SISLCurve *,double [],int,int,int,int,SISLCurve **,\n\t    double **,double **,int *);\n#ifndef  SH1369\nextern\n#endif\nvoid sh1369(SISLSurf *,double [],double [],double,double,int,double,\n\t    double,int,int *,SISLTrack ***,int *,double **,int **,int *,\n\t    SISLIntcurve ***,int *,SISLIntsurf ***,int *);\n#ifndef  SH1371\nextern\n#endif\nvoid sh1371(SISLCurve *,double [],double,int,double,double,int,int *,\n\t    SISLTrack ***,int *,double **,int **,int *,SISLIntcurve ***,int *);\n#ifndef  SH1372\nextern\n#endif\nvoid sh1372(SISLCurve *,double [],double [],double,int,double,double,int,\n\t    int *,SISLTrack ***,int *,double **,int **,int *,\n\t    SISLIntcurve ***,int *);\n#ifndef  SH1373\nextern\n#endif\nvoid sh1373(SISLCurve *,double [],double [],double [],int,double,double,\n\t    int,int *,SISLTrack ***,int *,double **,int **,int *,\n\t    SISLIntcurve ***,int *);\n#ifndef  SH1374\nextern\n#endif\nvoid sh1374(SISLCurve *,double [],int,double,double,int,int *,SISLTrack ***,\n\t    int *,double **,int **,int *,SISLIntcurve ***,int *);\n#ifndef  SH1375\nextern\n#endif\nvoid sh1375(SISLCurve *,double [],double [],double,double,int,double,\n\t    double,int,int *,SISLTrack ***,int *,double **,int **,\n\t    int *,SISLIntcurve ***,int *);\n#ifndef  SH1460\nextern\n#endif\nvoid sh1460(void (*)(double [],double [],int,int,int *),\n\t    SISLCurve *[],int,SISLSurf ***,int *);\n#ifndef  SH1461\nextern\n#endif\nvoid sh1461(void (*)(double [],double [],int,int,int *),\n\t    void (*)(void (*)(double [],double [],int,int,int *),\n\t\t     SISLCurve *[],int,double [],double [],double [],int *),\n\t    SISLCurve *[],int,SISLSurf *[],int *);\n#ifndef  SH1462\nextern\n#endif\nvoid sh1462(void (*)(double [],double [],int,int,int *),\n\t    SISLCurve *[],int,double [],double [],double [],int *);\n#ifndef  SH1463\nextern\n#endif\nvoid sh1463(void (*)(double [],double [],int,int,int *),\n\t    SISLCurve *[],int,double [],double [],double [],int *);\n#ifndef  SH1464\nextern\n#endif\nvoid sh1464(void (*)(double [],double [],int,int,int *),\n\t    SISLCurve *[],int,double [],double [],double [],int *);\n#ifndef  SH1465\nextern\n#endif\nvoid sh1465(void (*)(double [],double [],int,int,int *),\n\t    SISLCurve *[],int,double [],double [],double [],int *);\n#ifndef  SH1466\nextern\n#endif\nvoid sh1466(SISLCurve *[],double [],int,double [],double [],int *);\n#ifndef  SH1467\nextern\n#endif\nvoid sh1467(SISLCurve *[],double [],int,double [],double [],int *);\n#ifndef  SH1502\nextern\n#endif\nvoid sh1502(SISLCurve *,double [],double [],double [],double,double,\n\t    int,double,double,int,int *,SISLTrack ***,int *,double **,\n\t    int **,int *,SISLIntcurve ***,int *);\n#ifndef  SH1503\nextern\n#endif\nvoid sh1503(SISLSurf *,double [],double [],double [],double,double,int,\n\t    double,double,int,int *,SISLTrack ***,int *,double **,int **,\n\t    int *,SISLIntcurve ***,int *,SISLIntsurf ***,int *);\n#ifndef  SH1510\nextern\n#endif\nvoid sh1510(SISLSurf *,double [],int,double,double,int,int *,\n\t    SISLTrack ***,int *,double **,int **,int *,\n\t    SISLIntcurve ***,int *,SISLIntsurf ***,int *);\n#ifndef  SH1511\nextern\n#endif\nvoid sh1511(SISLSurf *,double [],double [],int,double,double,int,\n\t    int *,SISLTrack ***,int *,double **,int **,int *,\n\t    SISLIntcurve ***,int *,SISLIntsurf ***,int *);\n#ifndef  SH1761\nextern\n#endif\nvoid sh1761(SISLObject *,SISLObject *,double,SISLIntdat **,int *);\n#ifndef  SH1762\nextern\n#endif\nvoid sh1762(SISLObject *,SISLObject *,double,SISLIntdat **,SISLEdge *[],int *);\n#ifndef  SH1779\nextern\n#endif\nvoid sh1779(SISLObject *,SISLObject *,double,SISLIntdat **,SISLIntpt *,\n\t    int *,int *);\n#ifndef  SH1779_AT\nextern\n#endif\nvoid sh1779_at(SISLObject *,SISLObject *,SISLIntpt *,int *);\n#ifndef  SH1780\nextern\n#endif\nvoid sh1780(SISLObject *,SISLObject *,double,SISLIntdat **,\n\t    SISLIntpt *,int *,int *);\n#ifndef  SH1780_AT\nextern\n#endif\nvoid sh1780_at(SISLObject *,SISLObject *,SISLIntpt *,int *);\n#ifndef  SH1781\nextern\n#endif\nvoid sh1781(SISLObject *,SISLObject *,double,SISLIntdat **,\n\t    SISLIntpt *,int *,int *);\n#ifndef  SH1781_AT\nextern\n#endif\nvoid sh1781_at(SISLObject *,SISLObject *,SISLIntpt *,int *);\n#ifndef  SH1782\nextern\n#endif\nvoid sh1782(SISLObject *,SISLObject *,double,SISLIntdat *,int,double,\n\t    SISLIntdat **,int *,int *);\n#ifndef  SH1783\nextern\n#endif\nvoid sh1783(SISLCurve *,SISLCurve *,double,double [],int,int,double [],\n\t    double [],int *);\n#ifndef  SH1784\nextern\n#endif\nvoid sh1784(SISLCurve *,SISLSurf *,double,double [],int,int,double [],\n\t    double [],int *);\n#ifndef  SH1786\nextern\n#endif\nvoid sh1786(SISLObject *,SISLObject *,double,SISLIntdat **,SISLIntpt *,\n\t    int *,int *);\n#ifndef  SH1787\nextern\n#endif\nvoid sh1787(SISLObject *,SISLObject *,double,SISLIntdat **,SISLIntpt *,\n\t    int *,int *);\n#ifndef  SH1790\nextern\n#endif\nvoid sh1790(SISLObject *,SISLObject *,int,double,int *);\n#ifndef SH1794\nextern\n#endif\nvoid sh1794(SISLObject *po1, SISLObject *po2, SISLIntpt **up, int nmb_pt,\n\t    double aepsge, int *jstat);\n#ifndef SH1795\nextern\n#endif\nvoid sh1795(SISLObject *po1, SISLObject *po2, SISLIntpt *pt,\n\t    double aepsge, int *jstat);\n#ifndef  SH1830\nextern\n#endif\nvoid sh1830(SISLObject *,SISLObject *,double,int *);\n#ifndef  SH1831\nextern\n#endif\nvoid sh1831(SISLCurve *pc1, SISLCurve *pc2, int isign, double epoint[],\n            double enorm[], double aepsge, int *jstat);\n#ifndef  SH1834\nextern\n#endif\nvoid sh1834(SISLObject *,SISLObject *,double,int,double [],double [],int *);\n#ifndef  SH1839\nextern\n#endif\nvoid sh1839(SISLObject *,SISLObject *,double,int *);\n#ifndef  SH1850\nextern\n#endif\nvoid sh1850(SISLCurve *,double [],double [],int,double,double,int,int *,\n\t    SISLTrack ***,int *,double **,int **,int *,SISLIntcurve ***,int *);\n#ifndef  SH1851\nextern\n#endif\nvoid sh1851(SISLSurf *,double [],double [],int,double,double,int,int *,\n\t    SISLTrack ***,int *,double **,int **,int *,SISLIntcurve ***,\n\t    int *,SISLIntsurf ***,int *);\n#ifndef  SH1852\nextern\n#endif\nvoid sh1852(SISLSurf *,double [],double,int,double,double,int,int *,\n\t    SISLTrack ***,int *,double **,int **,int *,SISLIntcurve ***,\n\t    int *,SISLIntsurf ***,int *);\n#ifndef  SH1853\nextern\n#endif\nvoid sh1853(SISLSurf *,double [],double [],double,int,double,double,int,\n\t    int *,SISLTrack ***,int *,double **,int **,int *,\n\t    SISLIntcurve ***,int *,SISLIntsurf ***,int *);\n#ifndef  SH1854\nextern\n#endif\nvoid sh1854(SISLSurf *,double[],double[],double[],int,double,double,int,\n\t    int *, SISLTrack ***,int *,double **,int **,int *,\n\t    SISLIntcurve ***,int *,SISLIntsurf ***,int *);\n#ifndef  SH1855\nextern\n#endif\nvoid sh1855(SISLSurf *,double [],double,double [],int,double,double,\n\t    int,int *,SISLTrack ***,int *,double **,int **,int *,\n\t    SISLIntcurve ***,int *);\n#ifndef  SH1856\nextern\n#endif\nvoid sh1856(SISLSurf *,double [],double [],int,double,double,int,int *,\n\t    SISLTrack ***,int *,double **,int **,int *,SISLIntcurve ***,int *);\n#ifndef  SH1857\nextern\n#endif\nvoid sh1857(SISLCurve *,SISLCurve *,double,double,int,int *,SISLTrack ***,\n\t    int *,double **,double **,int **,int *,SISLIntcurve ***,int *);\n#ifndef  SH1858\nextern\n#endif\nvoid sh1858(SISLSurf *,SISLCurve *,double,double,int,int *,SISLTrack ***,\n\t    int *,double **,double **,int **,int *,SISLIntcurve ***,int *);\n#ifndef  SH1859\nextern\n#endif\nvoid sh1859(SISLSurf *,SISLSurf *,double,double,int,int *,SISLTrack ***,\n\t    int *,double **,double **,int **,int *,SISLIntcurve ***,\n\t    int *,SISLIntsurf ***,int *);\n#ifndef  SH1860\nextern\n#endif\nvoid sh1860(SISLSurf *,double[],int,double,double,int,int *,SISLTrack ***,\n\t    int *,double **,int **,int *,SISLIntcurve ***,int *,\n\t    SISLIntsurf ***,int *);\n\n#ifndef  SH1870\nextern\n#endif\nvoid sh1870(SISLSurf *,double *,int,double,double,int,int *,SISLTrack ***,\n\t    int *,double **,int **,int *,SISLIntcurve ***,int *);\n#ifndef  SH1871\nextern\n#endif\nvoid sh1871(SISLCurve *,double *,int,double,double,int,int *,SISLTrack ***,\n\t    int *,double **,int **,int *,SISLIntcurve ***,int *);\n#ifndef  SH1922\nextern\n#endif\nvoid sh1922(double [],int,int,double [],int,double [],\n\t    int [],int [],int *);\n#ifndef  SH1923\nextern\n#endif\nvoid sh1923(double *,int,int,int *,int *);\n#ifndef  SH1924\nextern\n#endif\nvoid sh1924(double *,double *,int,int,int,int *,int *);\n#ifndef  SH1925\nextern\n#endif\nvoid sh1925(SISLCurve *,SISLCurve *,int,double [],int [],\n\t    int [],double [],double [],int,int,int *);\n#ifndef  SH1926\nextern\n#endif\nvoid sh1926(double [],int,int,int,double [],double [],int,double [],\n\t    int [],int [],double [],int [],double [],int *);\n#ifndef  SH1927\nextern\n#endif\nvoid sh1927(double [],int,int,int,SISLCurve *,int,int,double [],int *);\n#ifndef  SH1928\nextern\n#endif\nvoid sh1928(double [],int,int,int,double [],double [],int,int,int,\n\t    double [],int,int [],int [],double [],double [],int [],int *);\n#ifndef  SH1929\nextern\n#endif\nvoid sh1929(double [],int,int,int,double [],int,int,double [],\n\t    int *,int *,int *);\n#ifndef  SH1930\nextern\n#endif\nvoid sh1930(double [],int [],int [],double [],double [],\n\t    int,int,int,int,int,int,int *);\n#ifndef  SH1992\nextern\n#endif\nvoid sh1992(SISLObject *,int,double,int *);\n#ifndef  SH1992CU\nextern\n#endif\nvoid sh1992cu(SISLCurve *,int,double,int *);\n#ifndef  SH1992SU\nextern\n#endif\nvoid sh1992su(SISLSurf *,int,double,int *);\n#ifndef  SH1993\nextern\n#endif\nvoid sh1993(SISLCurve *,double,int *);\n#ifndef  SH1994\nextern\n#endif\nvoid sh1994(SISLSurf *,double,int *);\n#ifndef SH6CLOSEVERT\nextern\n#endif\nvoid sh6closevert(SISLCurve *,SISLSurf *,double *,double []);\n#ifndef SH6CVVERT\nextern\n#endif\nvoid\nsh6cvvert(SISLCurve *pc1, SISLCurve *pc2, double *cpar1, double *cpar2);\n#ifndef  SH6COMEDG\nextern\n#endif\nvoid sh6comedg(SISLObject *,SISLObject *,SISLIntpt *,SISLIntpt *,int *);\n#ifndef  SH6CONDIR\nextern\n#endif\nvoid sh6condir(SISLIntdat *, SISLIntpt *,SISLIntpt *,int *);\n#ifndef  SH6CONNECT\nextern\n#endif\nvoid sh6connect(SISLIntpt *,SISLIntpt *,int *);\n#ifndef  SH6COUNT\nextern\n#endif\nint sh6count(SISLIntpt *,int *);\n#ifndef  SH6DEGEN\nextern\n#endif\nvoid sh6degen(SISLObject *,SISLObject *,SISLIntdat **,double,int *);\n#ifndef  SH6DISCONNECT\nextern\n#endif\nvoid sh6disconnect(SISLIntpt *,SISLIntpt *,int *);\n#ifndef  SH6EDGPOINT\nextern\n#endif\nvoid sh6edgpoint(SISLEdge *[],SISLIntpt ***,int *,int *);\n#ifndef  SH6EDGRED\nextern\n#endif\nvoid sh6edgred(SISLObject *,SISLObject *,SISLIntdat *,int *);\n#ifndef  SH6EVALINT\nextern\n#endif\nvoid sh6evalint(SISLObject *,SISLObject *,double [],int,SISLIntpt *,\n\t\tdouble,double *[],double *[],double *[],int *);\n#ifndef  SH6FINDSPLIT\nextern\n#endif\nvoid sh6findsplit(SISLSurf *,SISLSurf *,double,int *);\n#ifndef  SH6FLOOP\nextern\n#endif\nvoid sh6floop(SISLIntpt *[],int,int *,int *);\n#ifndef  SH6GETGEOM\nextern\n#endif\nvoid sh6getgeom(SISLObject *,int,SISLIntpt *,double **,double **,double,int *);\n#ifndef  SH6GETLIST\nextern\n#endif\nvoid sh6getlist(SISLIntpt *,SISLIntpt *,int *,int *,int *);\n#ifndef  SH6GETMAIN\nextern\n#endif\nSISLIntpt *sh6getmain(SISLIntpt *);\n#ifndef  SH6GETNEXT\nextern\n#endif\nSISLIntpt *sh6getnext(SISLIntpt *,int);\n#ifndef  SH6GETNHBRS\nextern\n#endif\nvoid sh6getnhbrs(SISLIntpt *,SISLIntpt **,SISLIntpt **,int *);\n#ifndef  SH6GETOTHER\nextern\n#endif\nvoid sh6getother(SISLIntpt *,SISLIntpt *,SISLIntpt **,int *);\n#ifndef  SH6GETPREV\nextern\n#endif\nint sh6getprev(SISLIntpt *,SISLIntpt *);\n#ifndef  SH6GETSEGDIV\nextern\n#endif\nint sh6getsegdiv(SISLSurf *ps, int idiv, double epar[], int *seg_flag);\n#ifndef  SH6GETTOP\nextern\n#endif\nvoid sh6gettop(SISLIntpt *,int,int *,int *,int *,int *,int *);\n#ifndef  SH6GETTOPHLP\nextern\n#endif\nvoid sh6gettophlp(SISLIntpt *,int [4],int,int *);\n#ifndef  SH6IDALLEDG\nextern\n#endif\nvoid sh6idalledg(SISLObject *,SISLObject *,SISLIntdat *,SISLEdge *[],int *);\n#ifndef  SH6IDCON\nextern\n#endif\nvoid sh6idcon (SISLIntdat **,SISLIntpt **,SISLIntpt **,int *);\n#ifndef  SH6IDFCROSS\nextern\n#endif\nvoid sh6idfcross(SISLIntdat *,SISLIntpt *[],int *,int,int,int *);\n#ifndef  SH6IDGET\nextern\n#endif\nvoid sh6idget(SISLObject *,SISLObject *,int,double,SISLIntdat *,\n\t      SISLIntdat **,double,int *);\n#ifndef  SH6IDKPT\nextern\n#endif\nvoid sh6idkpt(SISLIntdat **,SISLIntpt **,int,int *);\n#ifndef  SH6IDLIS\nextern\n#endif\nvoid sh6idlis(SISLObject *,SISLObject *,SISLIntdat **,double,int *);\n#ifndef  SH6IDNPT\nextern\n#endif\nvoid sh6idnpt(SISLIntdat **,SISLIntpt **,int,int *);\n#ifndef  SH6IDNEWUNITE\nextern\n#endif\nvoid sh6idnewunite(SISLObject *,SISLObject *,SISLIntdat **,\n\t\t   SISLIntpt **,SISLIntpt **,double,double,int *);\n#ifndef  SH6IDPUT\nextern\n#endif\nvoid sh6idput(SISLObject *,SISLObject *,SISLIntdat **,SISLIntdat *,\n\t      int,double,SISLIntpt ***,int *,int *);\n#ifndef  SH6IDRMCROSS\nextern\n#endif\nvoid sh6idrmcross(SISLObject *,SISLObject *,SISLIntdat **,SISLIntpt *[],\n\t\t  int,SISLIntpt *[],int,int *);\n#ifndef  SH6IDSPLIT\nextern\n#endif\nvoid sh6idsplit(SISLIntdat **,SISLIntpt *,int *);\n#ifndef  SH6IDUNITE\nextern\n#endif\nvoid sh6idunite(SISLIntdat **,SISLIntpt **,SISLIntpt **,double,int *);\n#ifndef  SH6INSERT\nextern\n#endif\nvoid sh6insert(SISLIntdat **,SISLIntpt *,SISLIntpt *,SISLIntpt **,int *);\n#ifndef  SH6INSERTPT\nextern\n#endif\nvoid sh6insertpt(SISLIntpt *,SISLIntpt *,SISLIntpt *,int *);\n#ifndef  SH6ISCONNECT\nextern\n#endif\nint sh6isconnect(SISLIntpt *,SISLIntpt *,SISLIntpt *);\n#ifndef  SH6ISHELP\nextern\n#endif\nint sh6ishelp (SISLIntpt *);\n#ifndef  SH6ISINSIDE\nextern\n#endif\nvoid sh6isinside(SISLObject *,SISLObject *,SISLIntpt *,int *);\n#ifndef  SH6ISMAIN\nextern\n#endif\nint sh6ismain(SISLIntpt *);\n#ifndef  SH6NMBHELP\nextern\n#endif\nint sh6nmbhelp(SISLIntpt *,int *);\n#ifndef  SH6NMBMAIN\nextern\n#endif\nint sh6nmbmain (SISLIntpt *,int *);\n#ifndef  SH6PTOBJ\nextern\n#endif\nvoid sh6ptobj(double *,SISLObject *,double,double [],double [],int *);\n#ifndef  SH6PUTSING\nextern\n#endif\nvoid sh6putsing( SISLIntpt *,SISLIntpt *);\n#ifndef  SH6PUTTOUCH\nextern\n#endif\nvoid sh6puttouch( SISLIntpt *,SISLIntpt *,int);\n#ifndef  SH6RED\nextern\n#endif\nvoid sh6red(SISLObject *,SISLObject *,SISLIntdat *,int *);\n#ifndef  SH6REMCON\nextern\n#endif\nvoid sh6remcon (SISLIntdat **,SISLIntpt *,SISLIntpt *,int *);\n#ifndef  SH6REMOVEPT\nextern\n#endif\nvoid sh6removept(SISLIntpt *,SISLIntpt *,SISLIntpt *,int *);\n#ifndef  SH6SEPCRV\nextern\n#endif\nvoid sh6sepcrv(SISLCurve *,SISLCurve *,double,double [],double *,int *);\n#ifndef  SH6SETCNSDIR\nextern\n#endif\nvoid sh6setcnsdir(SISLIntpt *,SISLIntpt *,int,int *);\n#ifndef  SH6SETDIR\nextern\n#endif\nvoid sh6setdir(SISLIntpt *,SISLIntpt *,int *);\n#ifndef SH6SETSEG\nextern\n#endif\nvoid sh6setseg(SISLSurf *ps, int idir, double *segmentation, int nseg,\n\t       int type, int *jstat);\n#ifndef  SH6SETTOP\nextern\n#endif\nvoid sh6settop(SISLIntpt *,int,int,int,int,int,int *);\n#ifndef  SH6SPLITGEOM\nextern\n#endif\nvoid sh6splitgeom(SISLSurf *,SISLSurf *,double,double [],double [],\n\t\t  double *,double *,int *);\n#ifndef  SH6TOHELP\nextern\n#endif\nvoid sh6tohelp(SISLIntpt *,int *);\n#ifndef  SH6TOMAIN\nextern\n#endif\nvoid sh6tomain(SISLIntpt *,int *);\n#ifndef  SH6TRIMLIST\nextern\n#endif\nvoid sh6trimlist(SISLIntpt *,SISLIntpt ***,int *,int *);\n#ifndef  CRV_ARC_TANG\nextern\n#endif\nvoid crv_arc_tang(SISLCurve *,double[],double,double,double[],double[],int *);\n#ifndef  CRV_CRV_TANG\nextern\n#endif\nvoid crv_crv_tang(SISLCurve *,SISLCurve *,double,double[],double[],int *);\n#ifndef  CRV_LIN_TANG\nextern\n#endif\nvoid crv_lin_tang(SISLCurve *,double[],double[],double,double,double *,int *);\n#ifndef  EV_CV_OFF\nextern\n#endif\nvoid ev_cv_off(SISLCurve *,int,double,int *,double,double[],int *);\n#ifndef  EVAL_2_CRV\nextern\n#endif\nvoid eval_2_crv(SISLCurve *,SISLCurve *,int,double[],int *,int *,\n\t\tdouble[],int *);\n#ifndef  EVAL_CRV_ARC\nextern\n#endif\nvoid eval_crv_arc(SISLCurve *,double[],double,int,double[],int *,\n\t\t  double[],int *);\n#ifndef  HP_S1880\nextern\n#endif\nvoid hp_s1880(SISLObject *,SISLObject *,int,int,int,SISLIntdat *,int *,\n\t      double **,double **,int **,int *,SISLIntcurve ***,\n\t      int *,SISLIntsurf ***,int *);\n#ifndef  INT_JOIN_PER\nextern\n#endif\nvoid int_join_per(SISLIntdat **,SISLObject *,SISLObject *,double [],\n\t\t  int,double,int *);\n#ifndef  MAKE_CV_KREG\nextern\n#endif\nvoid make_cv_kreg(SISLCurve *,SISLCurve **,int *);\n#ifndef  MAKE_SF_KREG\nextern\n#endif\nvoid make_sf_kreg(SISLSurf *,SISLSurf **,int *);\n#ifndef  MAKE_TRACKS\nextern\n#endif\nvoid make_tracks(SISLObject *,SISLObject *,int,double [],int,SISLIntlist **,\n\t\t int *,SISLTrack ***,double,int *);\n#ifndef  NEWKNOTS\nextern\n#endif\nvoid newknots(double [],int,int,double [],int,double,double **,int *,int *);\n#ifndef  PICK_CRV_SF\nextern\n#endif\nvoid pick_crv_sf(SISLObject *,SISLObject *,int,SISLIntpt *,SISLIntpt *,\n\t\t SISLCurve **,int *);\n#ifndef  PO_CRV_TANG\nextern\n#endif\nvoid po_crv_tang(SISLCurve *,double[],double,double,double *,int *);\n#ifndef  REFINE_ALL\nextern\n#endif\nvoid refine_all(SISLIntdat **,SISLObject *,SISLObject *,double [],\n\t\tint,double,int *);\n#ifndef  SH_1D_DIV\nextern\n#endif\nvoid sh_1d_div(SISLObject *,SISLObject *,double,SISLIntdat **,\n\t       SISLEdge *[],int *);\n#ifndef  SH_DIV_CRV\nextern\n#endif\nvoid sh_div_crv(SISLCurve *,int,double,SISLCurve **,int *);\n#ifndef  SH_DIV_SURF\nextern\n#endif\nvoid sh_div_surf(SISLSurf *,int,int,double,SISLSurf **,int *);\n#ifndef  SH_SET_AT\nextern\n#endif\nvoid sh_set_at(SISLObject *,SISLObject *,SISLIntdat *,int *);\n#ifndef  SHAPE\nextern\n#endif\nvoid shape(double [],double [],int,int,int *);\n#ifndef  SHCHECKPUT\nextern\n#endif\nvoid shcheckput(SISLObject *,SISLIntdat **,SISLIntdat *,int,double,int *);\n#ifndef  SHCHECKTYPE\nextern\n#endif\nint shchecktype(SISLObject *,double *);\n#ifndef  SHCSFSING\nextern\n#endif\nvoid shcsfsing(SISLCurve *,SISLSurf *,double [],double [],double [],int *);\n#ifndef  SHEVALC\nextern\n#endif\nvoid shevalc(SISLCurve *,int,double,double,int *,double [],int *);\n#ifndef  SHMKHLPPTS\nextern\n#endif\nvoid shmkhlppts(SISLObject *,SISLObject *,double,SISLIntdat **,\n\t\tSISLEdge *[],int *,int *);\n#ifndef  SHSING\nextern\n#endif\nvoid shsing(SISLSurf *,SISLSurf *,double [],double [],double [],int *);\n#ifndef  SPLI_SILH\nextern\n#endif\nvoid spli_silh (SISLIntdat ** pintdat,SISLObject * po1,int *jstat);\n#ifndef  TEST_CYCLIC_KNOTS\nextern\n#endif\nvoid test_cyclic_knots(double [],int,int,int *);\n\n#else /* NOT SISLNEEDPROTOTYPES */\n\n#ifndef CONSTRUCT\nextern\n#endif\nSISLIntpt     *copyIntpt();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLEdge      *newEdge();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLIntdat    *newIntdat();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLIntlist   *newIntlist();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLIntpt     *newIntpt();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLObject    *newObject();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLPoint     *newPoint();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLPtedge    *newPtedge();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLIntsurf   *newIntsurf();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLTrack     *newTrack();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLTrimpar   *newTrimpar();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLIntpt     *hp_newIntpt();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLIntpt     *hp_copyIntpt();\n#ifndef CONSTRUCT\nextern\n#endif\nSISLSegmentation *newSegmentation();\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeEdge();\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeIntdat();\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeIntlist();\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeIntpt();\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeObject();\n#ifndef DESTRUCT\nextern\n#endif\nvoid freePoint();\n#ifndef DESTRUCT\nextern\n#endif\nvoid freePtedge();\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeIntsurf();\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeTrimpar();\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeTrack();\n#ifndef DESTRUCT\nextern\n#endif\nvoid freeSegmentation();\n#ifndef MAKE3D\nextern\n#endif\nvoid make3D();\n#ifndef S1119\nextern\n#endif\nvoid s1119();\n#ifndef S1161\nextern\n#endif\nvoid s1161();\n#ifndef S1162\nextern\n#endif\nvoid s1162();\n#ifndef S1172\nextern\n#endif\nvoid s1172();\n#ifndef S1173\nextern\n#endif\nvoid s1173();\n#ifndef S1174\nextern\n#endif\nvoid s1174();\n#ifndef S1190\nextern\n#endif\nvoid s1190();\n#ifndef  S1192\nextern\n#endif\nvoid s1192();\n#ifndef  S1219\nextern\n#endif\nvoid s1219();\n#ifndef  S1220\nextern\n#endif\nvoid s1220();\n#ifndef  S1222\nextern\n#endif\nvoid s1222();\n#ifndef  S1223\nextern\n#endif\nvoid s1223();\n#ifndef  S1224\nextern\n#endif\nvoid s1224();\n#ifndef  S1231\nextern\n#endif\nvoid s1231();\n#ifndef  S1232\nextern\n#endif\nvoid s1232();\n#ifndef  S1235\nextern\n#endif\nvoid s1235();\n#ifndef  S1236\nextern\n#endif\nvoid s1236();\n#ifndef  S1239\nextern\n#endif\nvoid s1239();\n#ifndef  S1244\nextern\n#endif\nvoid s1244();\n#ifndef  S1245\nextern\n#endif\nvoid s1245();\n#ifndef  S1251\nextern\n#endif\nvoid s1251();\n#ifndef  S1252\nextern\n#endif\nvoid s1252();\n#ifndef S1291\nextern\n#endif\nvoid s1291();\n#ifndef  S1301\nextern\n#endif\nvoid s1301();\n#ifndef  S1304\nextern\n#endif\nvoid s1304();\n#ifndef  S1305\nextern\n#endif\nvoid s1305();\n#ifndef  S1306\nextern\n#endif\nvoid s1306();\n#ifndef  S1307\nextern\n#endif\nvoid s1307();\n#ifndef  S1308\nextern\n#endif\nvoid s1308();\n#ifndef  S1309\nextern\n#endif\ndouble s1309();\n#ifndef  S1311\nextern\n#endif\ndouble s1311();\n#ifndef  S1312\nextern\n#endif\nvoid s1312();\n#ifndef  S1313\nextern\n#endif\nvoid s1313();\n#ifndef  S1320\nextern\n#endif\nvoid s1320();\n#ifndef  S1321\nextern\n#endif\nvoid s1321();\n#ifndef  S1322\nextern\n#endif\nvoid s1322();\n#ifndef  S1323\nextern\n#endif\nvoid s1323();\n#ifndef  S1324\nextern\n#endif\nvoid s1324();\n#ifndef  S1325\nextern\n#endif\ndouble s1325();\n#ifndef  S1326\nextern\n#endif\nvoid s1326();\n#ifndef  S1329\nextern\n#endif\nvoid s1329();\n#ifndef  S1330\nextern\n#endif\nvoid s1330();\n#ifndef  S1331\nextern\n#endif\nvoid s1331();\n#ifndef  S1333\nextern\n#endif\nvoid s1333();\n#ifndef  S1333_COUNT\nextern\n#endif\nvoid s1333_count();\n#ifndef  S1333_CYCLIC\nextern\n#endif\nvoid s1333_cyclic();\n#ifndef  S1334\nextern\n#endif\nvoid s1334();\n#ifndef  S1339\nextern\n#endif\nvoid s1339();\n#ifndef  S1340\nextern\n#endif\nvoid s1340();\n#ifndef  S1341\nextern\n#endif\nvoid s1341();\n#ifndef  S1342\nextern\n#endif\nvoid s1342();\n#ifndef  S1343\nextern\n#endif\nvoid s1343();\n#ifndef  S1345\nextern\n#endif\nvoid s1345();\n#ifndef  S1346\nextern\n#endif\nvoid s1346();\n#ifndef  S1347\nextern\n#endif\nvoid s1347();\n#ifndef  S1348\nextern\n#endif\nvoid s1348();\n#ifndef  S1349\nextern\n#endif\nvoid s1349();\n#ifndef  S1350\nextern\n#endif\nvoid s1350();\n#ifndef  S1351\nextern\n#endif\nvoid s1351();\n#ifndef  S1352\nextern\n#endif\nvoid s1352();\n#ifndef  S1353\nextern\n#endif\nvoid s1353();\n#ifndef  S1354\nextern\n#endif\nvoid s1354();\n#ifndef  S1355\nextern\n#endif\nvoid s1355();\n#ifndef  S1358\nextern\n#endif\nvoid s1358();\n#ifndef  S1359\nextern\n#endif\nvoid s1359();\n#ifndef  S1361\nextern\n#endif\nvoid s1361();\n#ifndef  S1362\nextern\n#endif\nvoid s1362();\n#ifndef  S1366\nextern\n#endif\nvoid s1366();\n#ifndef  S1367\nextern\n#endif\nvoid s1367();\n#ifndef  S1370\nextern\n#endif\nvoid s1370();\n#ifndef  S1376\nextern\n#endif\nvoid s1376();\n#ifndef  S1377\nextern\n#endif\nvoid s1377();\n#ifndef  S1378\nextern\n#endif\nvoid s1378();\n#ifndef  S1381\nextern\n#endif\nvoid s1381();\n#ifndef  S1382\nextern\n#endif\nvoid s1382();\n#ifndef  S1384\nextern\n#endif\nvoid s1384();\n#ifndef  S1385\nextern\n#endif\nvoid s1385();\n#ifndef  S1393\nextern\n#endif\nvoid s1393();\n#ifndef  S1399\nextern\n#endif\nvoid s1399();\n#ifndef  S1435\nextern\n#endif\nvoid s1435();\n#ifndef  S1436\nextern\n#endif\nvoid s1436();\n#ifndef  S1437\nextern\n#endif\nvoid s1437();\n#ifndef  S1438\nextern\n#endif\nvoid s1438();\n#ifndef  S1452\nextern\n#endif\nvoid s1452();\n#ifndef S1500\nextern\n#endif\nvoid s1500();\n#ifndef S1504\nextern\n#endif\nvoid s1504();\n#ifndef S1505\nextern\n#endif\nvoid s1505();\n#ifndef S1507\nextern\n#endif\nvoid s1507();\n#ifndef S1512\nextern\n#endif\nvoid s1512();\n#ifndef S1513\nextern\n#endif\nvoid s1513();\n#ifndef S1516\nextern\n#endif\nvoid s1516();\n#ifndef S1517\nextern\n#endif\nvoid s1517();\n#ifndef S1520\nextern\n#endif\nvoid s1520();\n#ifndef S1521\nextern\n#endif\nSISLCurve *s1521();\n#ifndef S1528\nextern\n#endif\nvoid s1528();\n#ifndef S1531\nextern\n#endif\nvoid s1531();\n#ifndef S1540\nextern\n#endif\nvoid s1540();\n#ifndef S1541\nextern\n#endif\nvoid s1541();\n#ifndef  S1604\nextern\n#endif\nvoid s1604();\n#ifndef  S1605\nextern\n#endif\nvoid s1605();\n#ifndef  S1612\nextern\n#endif\nvoid s1612();\n#ifndef  S1613BEZ\nextern\n#endif\nvoid s1613bez();\n#ifndef S1614\nextern\n#endif\nvoid s1614 ();\n#ifndef S1615\nextern\n#endif\nvoid s1615 ();\n#ifndef S1616\nextern\n#endif\nvoid s1616 ();\n#ifndef S1617\nextern\n#endif\nvoid s1617 ();\n#ifndef S1618\nextern\n#endif\nvoid s1618 ();\n#ifndef S1619\nextern\n#endif\nvoid s1619 ();\n#ifndef  S1700\nextern\n#endif\nvoid s1700();\n#ifndef  S1701\nextern\n#endif\nvoid s1701();\n#ifndef  S1705\nextern\n#endif\nvoid s1705();\n#ifndef  S1707\nextern\n#endif\nvoid s1707();\n#ifndef  S1708\nextern\n#endif\nvoid s1708();\n#ifndef  S1741\nextern\n#endif\nvoid s1741();\n#ifndef S1753\nextern\n#endif\nvoid s1753();\n#ifndef S1754\nextern\n#endif\nvoid s1754();\n#ifndef S1755\nextern\n#endif\nvoid s1755();\n#ifndef  S1770\nextern\n#endif\nvoid s1770();\n#ifndef  S1770_2D\nextern\n#endif\nvoid s1770_2D();\n#ifndef  S1771\nextern\n#endif\nvoid s1771();\n#ifndef  S1772\nextern\n#endif\nvoid s1772();\n#ifndef  S1773\nextern\n#endif\nvoid s1773();\n#ifndef  S1780\nextern\n#endif\nvoid s1780();\n#ifndef  S1785\nextern\n#endif\nvoid s1785();\n#ifndef  S1786\nextern\n#endif\nvoid s1786();\n#ifndef  S1787\nextern\n#endif\nvoid s1787();\n#ifndef  S1788\nextern\n#endif\nvoid s1788();\n#ifndef  S1789\nextern\n#endif\nvoid s1789();\n#ifndef  S1790\nextern\n#endif\nvoid s1790();\n#ifndef  S1791\nextern\n#endif\nint s1791();\n#ifndef  S1792\nextern\n#endif\ndouble s1792();\n#ifndef  S1795\nextern\n#endif\nvoid s1795();\n#ifndef  S1796\nextern\n#endif\nvoid s1796();\n#ifndef  S1797\nextern\n#endif\nvoid s1797();\n#ifndef  S1830\nextern\n#endif\nvoid s1830();\n#ifndef  S1834\nextern\n#endif\nvoid s1834();\n#ifndef  S1839\nextern\n#endif\nvoid s1839();\n#ifndef  S1840\nextern\n#endif\nvoid s1840();\n#ifndef  S1880\nextern\n#endif\nvoid s1880();\n#ifndef S1890\nextern\n#endif\nvoid s1890();\n#ifndef S1891\nextern\n#endif\nvoid s1891();\n#ifndef S1893\nextern\n#endif\nvoid s1893();\n#ifndef S1894\nextern\n#endif\nvoid s1894();\n#ifndef S1896\nextern\n#endif\nvoid s1896();\n#ifndef S1897\nextern\n#endif\nvoid s1897();\n#ifndef S1900\nextern\n#endif\nvoid s1900();\n#ifndef S1901\nextern\n#endif\nvoid s1901();\n#ifndef S1902\nextern\n#endif\nvoid s1902();\n#ifndef S1903\nextern\n#endif\nvoid s1903();\n#ifndef S1904\nextern\n#endif\nvoid s1904();\n#ifndef S1905\nextern\n#endif\nvoid s1905();\n#ifndef S1906\nextern\n#endif\nvoid s1906();\n#ifndef S1907\nextern\n#endif\nvoid s1907();\n#ifndef S1908\nextern\n#endif\nvoid s1908();\n#ifndef S1909\nextern\n#endif\nvoid s1909();\n#ifndef S1910\nextern\n#endif\nvoid s1910();\n#ifndef S1911\nextern\n#endif\nvoid s1911();\n#ifndef S1912\nextern\n#endif\nvoid s1912();\n#ifndef S1916\nextern\n#endif\nvoid s1916();\n#ifndef S1917\nextern\n#endif\nvoid s1917();\n#ifndef S1918\nextern\n#endif\nvoid s1918();\n#ifndef S1919\nextern\n#endif\nvoid s1919();\n#ifndef S1924\nextern\n#endif\nvoid s1924();\n#ifndef S1925\nextern\n#endif\nvoid s1925();\n#ifndef S1926\nextern\n#endif\nvoid s1926();\n#ifndef S1927\nextern\n#endif\nvoid s1927();\n#ifndef S1931\nextern\n#endif\nvoid s1931();\n#ifndef S1931UNIT\nextern\n#endif\nvoid s1931unit();\n#ifndef S1932\nextern\n#endif\nvoid s1932();\n#ifndef S1933\nextern\n#endif\nvoid s1933();\n#ifndef S1934\nextern\n#endif\nvoid s1934();\n#ifndef S1935\nextern\n#endif\nvoid s1935();\n#ifndef S1936\nextern\n#endif\nvoid s1936();\n#ifndef S1937\nextern\n#endif\nvoid s1937();\n#ifndef S1938\nextern\n#endif\nvoid s1938();\n#ifndef S1940\nextern\n#endif\nvoid s1940();\n#ifndef S1941\nextern\n#endif\nvoid s1941();\n#ifndef S1942\nextern\n#endif\nvoid s1942();\n#ifndef S1943\nextern\n#endif\nvoid s1943();\n#ifndef S1944\nextern\n#endif\nvoid s1944();\n#ifndef S1945\nextern\n#endif\nvoid s1945();\n#ifndef S1946\nextern\n#endif\nvoid s1946();\n#ifndef S1947\nextern\n#endif\nvoid s1947();\n#ifndef S1948\nextern\n#endif\nvoid s1948();\n#ifndef S1949\nextern\n#endif\nvoid s1949();\n#ifndef S1950\nextern\n#endif\nvoid s1950();\n#ifndef S1951\nextern\n#endif\nvoid s1951();\n#ifndef  S1956\nextern\n#endif\nvoid s1956();\n#ifndef  S1959\nextern\n#endif\nvoid s1959();\n#ifndef  S1960\nextern\n#endif\nvoid s1960();\n#ifndef S1990\nextern\n#endif\nvoid s1990();\n#ifndef  S1991\nextern\n#endif\nvoid s1991();\n#ifndef  S1992\nextern\n#endif\nvoid s1992();\n#ifndef  S1992\nextern\n#endif\nvoid s1992cu();\n#ifndef  S1992\nextern\n#endif\nvoid s1992su();\n#ifndef  S1993\nextern\n#endif\nvoid s1993();\n#ifndef  S1994\nextern\n#endif\nvoid s1994();\n#ifndef  S2501\nextern\n#endif\nvoid s2501();\n#ifndef  S2503\nextern\n#endif\nvoid s2503();\n#ifndef  S2505\nextern\n#endif\nvoid s2505();\n#ifndef  S2507\nextern\n#endif\nvoid s2507();\n#ifndef  S2509\nextern\n#endif\nvoid s2509();\n#ifndef  S2511\nextern\n#endif\nvoid s2511();\n#ifndef  S2512\nextern\n#endif\nvoid s2512();\n#ifndef  S2513\nextern\n#endif\nvoid s2513();\n#ifndef  S2514\nextern\n#endif\nvoid s2514();\n#ifndef  S2515\nextern\n#endif\nvoid s2515();\n#ifndef  S2516\nextern\n#endif\nvoid s2516();\n#ifndef  S2533\nextern\n#endif\nvoid s2533();\n#ifndef  S2534\nextern\n#endif\nvoid s2534();\n#ifndef  S2535\nextern\n#endif\nvoid s2535();\n#ifndef  S2541\nextern\n#endif\nvoid s2541();\n#ifndef  S2543\nextern\n#endif\nvoid s2543();\n#ifndef  S2551\nextern\n#endif\nvoid s2551();\n#ifndef  S2554\nextern\n#endif\nvoid s2554();\n#ifndef  S2555\nextern\n#endif\nvoid s2555();\n#ifndef  S2557\nextern\n#endif\nvoid s2557();\n#ifndef  S2558\nextern\n#endif\nvoid s2558();\n#ifndef  S2560\nextern\n#endif\nvoid s2560();\n#ifndef  S2561\nextern\n#endif\nvoid s2561();\n#ifndef  S6ADDCURVE\nextern\n#endif\nvoid s6addcurve();\n#ifndef  S6AFFDIST\nextern\n#endif\ndouble s6affdist();\n#ifndef  S6ANG\nextern\n#endif\ndouble s6ang();\n#ifndef  S6ANGLE\nextern\n#endif\ndouble s6angle();\n#ifndef S6BEZPOWSF\n      extern\n#endif\n      void s6bezpowsf();\n#ifndef  S6CHPAR\nextern\n#endif\nvoid s6chpar();\n#ifndef  S6CRSS\nextern\n#endif\nvoid s6crss();\n#ifndef  S6CRVCHECK\nextern\n#endif\nvoid s6crvcheck();\n#ifndef  S6CURVATURE\nextern\n#endif\nvoid s6curvature();\n#ifndef  s6CURVRAD\nextern\n#endif\nvoid s6curvrad();\n#ifndef  S6DECASTELJAU\nextern\n#endif\nvoid s6deCasteljau();\n#ifndef  S6DECOMP\nextern\n#endif\nvoid s6decomp();\n#ifndef  S6DEGNORM\nextern\n#endif\nvoid s6degnorm();\n#ifndef  S6DERTOPT\nextern\n#endif\nvoid s6dertopt();\n#ifndef  S6DIFF\nextern\n#endif\nvoid s6diff();\n#ifndef  S6DIST\nextern\n#endif\ndouble s6dist();\n#ifndef  S6DLINE\nextern\n#endif\ndouble s6dline();\n#ifndef  S6DPLANE\nextern\n#endif\ndouble  s6dplane();\n#ifndef  S6EQUAL\nextern\n#endif\nint s6equal();\n#ifndef  S6ERR\nextern\n#endif\nvoid s6err();\n#ifndef  S6EXISTBOX\nextern\n#endif\nint s6existbox();\n#ifndef S6FINDFAC\nextern\n#endif\nvoid s6findfac();\n#ifndef S6FNDINTVL\nextern\n#endif\nvoid s6fndintvl();\n#ifndef  S6HERM\nextern\n#endif\nvoid s6herm();\n#ifndef  S6HERMITE_BEZIER\nextern\n#endif\nvoid s6hermite_bezier();\n#ifndef  S6IDCON\nextern\n#endif\nvoid s6idcon();\n#ifndef  S6IDCPT\nextern\n#endif\nvoid s6idcpt();\n#ifndef  S6IDEDG\nextern\n#endif\nvoid s6idedg();\n#ifndef  S6IDENTIFY\nextern\n#endif\nvoid     s6identify();\n#ifndef  S6IDGET\nextern\n#endif\nvoid s6idget();\n#ifndef  S6IDINT\nextern\n#endif\nvoid s6idint();\n#ifndef  S6IDKLIST\nextern\n#endif\nvoid s6idklist();\n#ifndef  S6IDKPT\nextern\n#endif\nvoid s6idkpt();\n#ifndef  S6IDLIS\nextern\n#endif\nvoid s6idlis();\n#ifndef  S6IDNPT\nextern\n#endif\nvoid s6idnpt();\n#ifndef  S6IDPUT\nextern\n#endif\nvoid s6idput();\n#ifndef S6INV4\nextern\n#endif\nvoid s6inv4 ();\n#ifndef  S6INVERT\nextern\n#endif\nvoid s6invert();\n#ifndef  S6KNOTMULT\nextern\n#endif\nint s6knotmult();\n#ifndef  S6LENGTH\nextern\n#endif\ndouble s6length();\n#ifndef  S6LINE\nextern\n#endif\nvoid s6line();\n#ifndef  S6LPRJ\nextern\n#endif\ndouble s6lprj();\n#ifndef  S6LUFACP\nextern\n#endif\nvoid s6lufacp();\n#ifndef  S6LUSOLP\nextern\n#endif\nvoid s6lusolp();\n#ifndef  S6METRIC\nextern\n#endif\nvoid s6metric();\n#ifndef  S6MOVE\nextern\n#endif\nvoid s6move();\n#ifndef S6MULVEC\nextern\n#endif\nvoid s6mulvec ();\n#ifndef S6MULTSFS\nextern\n#endif\nvoid s6multsfs();\n#ifndef  S6MVEC\nextern\n#endif\nvoid s6mvec();\n#ifndef  S6NEWBOX\nextern\n#endif\nvoid s6newbox();\n#ifndef  S6NORM\nextern\n#endif\ndouble s6norm();\n#ifndef S6NULLSPACE\nextern\n#endif\nvoid s6nullspace();\n#ifndef  S6RATDER\nextern\n#endif\nvoid s6ratder();\n#ifndef  S6ROTAX\nextern\n#endif\nvoid s6rotax();\n#ifndef S6SCPR\nextern\n#endif\ndouble s6scpr();\n#ifndef S6ROTMAT\nextern\n#endif\nvoid s6rotmat ();\n#ifndef S6SCHOEN\nextern\n#endif\ndouble s6schoen();\n#ifndef  S6SORTPAR\nextern\n#endif\nvoid s6sortpar();\n#ifndef S6SRATDER\nextern\n#endif\nvoid s6sratder();\n#ifndef S6STRIDER\nextern\n#endif\nvoid s6strider();\n#ifndef  S6TAKEUNION\nextern\n#endif\nvoid s6takeunion();\n#ifndef  S6TESTIMPL\nextern\n#endif\nvoid s6testimpl();\n#ifndef  S6TWONORM\nextern\n#endif\nvoid s6twonorm();\n#ifndef S9ADSIMP\nextern\n#endif\ndouble s9adsimp();\n#ifndef S9ADSTEP\nextern\n#endif\ndouble s9adstep();\n#ifndef S9BOUNDIMP\nextern\n#endif\nvoid s9boundimp();\n#ifndef  S9BOUNDIT\nextern\n#endif\nvoid s9boundit();\n#ifndef  S9CLIPIMP\nextern\n#endif\nvoid s9clipimp();\n#ifndef  S9CLIPIT\nextern\n#endif\nvoid s9clipit();\n#ifndef  S9CONMARCH\nextern\n#endif\nvoid s9conmarch();\n#ifndef  S9ITERATE\nextern\n#endif\nvoid s9iterate();\n#ifndef  S9ITERIMP\nextern\n#endif\nvoid s9iterimp();\n#ifndef  S9SIMPLE_KNOT\nextern\n#endif\nvoid \t s9simple_knot();\n#ifndef  S9SURMARCH\nextern\n#endif\nvoid s9surmarch();\n#ifndef  SH1260\nextern\n#endif\nvoid sh1260();\n#ifndef  SH1261\nextern\n#endif\nvoid sh1261();\n#ifndef  SH1262\nextern\n#endif\nvoid sh1262();\n#ifndef  SH1263\nextern\n#endif\nvoid sh1263();\n#ifndef  SH1365\nextern\n#endif\nvoid sh1365();\n#ifndef  SH1369\nextern\n#endif\nvoid sh1369();\n#ifndef  SH1371\nextern\n#endif\nvoid sh1371();\n#ifndef  SH1372\nextern\n#endif\nvoid sh1372();\n#ifndef  SH1373\nextern\n#endif\nvoid sh1373();\n#ifndef  SH1374\nextern\n#endif\nvoid sh1374();\n#ifndef  SH1375\nextern\n#endif\nvoid sh1375();\n#ifndef  SH1460\nextern\n#endif\nvoid sh1460();\n#ifndef  SH1461\nextern\n#endif\nvoid sh1461();\n#ifndef  SH1462\nextern\n#endif\nvoid sh1462();\n#ifndef  SH1463\nextern\n#endif\nvoid sh1463();\n#ifndef  SH1464\nextern\n#endif\nvoid sh1464();\n#ifndef  SH1465\nextern\n#endif\nvoid sh1465();\n#ifndef  SH1466\nextern\n#endif\nvoid sh1466();\n#ifndef  SH1467\nextern\n#endif\nvoid sh1467();\n#ifndef  SH1502\nextern\n#endif\nvoid sh1502();\n#ifndef  SH1503\nextern\n#endif\nvoid sh1503();\n#ifndef  SH1510\nextern\n#endif\nvoid sh1510();\n#ifndef  SH1511\nextern\n#endif\nvoid sh1511();\n#ifndef  SH1761\nextern\n#endif\nvoid sh1761();\n#ifndef  SH1762\nextern\n#endif\nvoid sh1762();\n#ifndef  SH1779\nextern\n#endif\nvoid sh1779();\n#ifndef  SH1779_AT\nextern\n#endif\nvoid sh1779_at();\n#ifndef  SH1780\nextern\n#endif\nvoid sh1780();\n#ifndef  SH1780_AT\nextern\n#endif\nvoid sh1780_at();\n#ifndef  SH1781\nextern\n#endif\nvoid sh1781();\n#ifndef  SH1781_AT\nextern\n#endif\nvoid sh1781_at();\n#ifndef  SH1782\nextern\n#endif\nvoid sh1782();\n#ifndef  SH1783\nextern\n#endif\nvoid sh1783();\n#ifndef  SH1784\nextern\n#endif\nvoid sh1784();\n#ifndef  SH1786\nextern\n#endif\nvoid sh1786();\n#ifndef  SH1787\nextern\n#endif\nvoid sh1787();\n#ifndef  SH1790\nextern\n#endif\nvoid sh1790();\n#ifndef SH1794\nextern\n#endif\nvoid sh1794();\n#ifndef SH1795\nextern\n#endif\nvoid sh1795();\n#ifndef  SH1830\nextern\n#endif\nvoid sh1830();\n#ifndef  SH1831\nextern\n#endif\nvoid sh1831();\n#ifndef  SH1834\nextern\n#endif\nvoid sh1834();\n#ifndef  SH1839\nextern\n#endif\nvoid sh1839();\n#ifndef  SH1850\nextern\n#endif\nvoid sh1850();\n#ifndef  SH1851\nextern\n#endif\nvoid sh1851();\n#ifndef  SH1852\nextern\n#endif\nvoid sh1852();\n#ifndef  SH1853\nextern\n#endif\nvoid sh1853();\n#ifndef  SH1854\nextern\n#endif\nvoid sh1854();\n#ifndef  SH1855\nextern\n#endif\nvoid sh1855();\n#ifndef  SH1856\nextern\n#endif\nvoid sh1856();\n#ifndef  SH1857\nextern\n#endif\nvoid sh1857();\n#ifndef  SH1858\nextern\n#endif\nvoid sh1858();\n#ifndef  SH1859\nextern\n#endif\nvoid sh1859();\n#ifndef  SH1860\nextern\n#endif\nvoid sh1860();\n#ifndef  SH1870\nextern\n#endif\nvoid sh1870();\n#ifndef  SH1871\nextern\n#endif\nvoid sh1871();\n#ifndef  SH1922\nextern\n#endif\nvoid sh1922();\n#ifndef  SH1923\nextern\n#endif\nvoid sh1923();\n#ifndef  SH1924\nextern\n#endif\nvoid sh1924();\n#ifndef  SH1925\nextern\n#endif\nvoid sh1925();\n#ifndef  SH1926\nextern\n#endif\nvoid sh1926();\n#ifndef  SH1927\nextern\n#endif\nvoid sh1927();\n#ifndef  SH1928\nextern\n#endif\nvoid sh1928();\n#ifndef  SH1929\nextern\n#endif\nvoid sh1929();\n#ifndef  SH1930\nextern\n#endif\nvoid sh1930();\n#ifndef  SH1992\nextern\n#endif\nvoid sh1992();\n#ifndef  SH1992CU\nextern\n#endif\nvoid sh1992cu();\n#ifndef  SH1992SU\nextern\n#endif\nvoid sh1992su();\n#ifndef  SH1993\nextern\n#endif\nvoid sh1993();\n#ifndef  SH1994\nextern\n#endif\nvoid sh1994();\n#ifndef SH6CLOSEVERT\nextern\n#endif\nvoid sh6closevert();\n#ifndef SH6CVVERT\nextern\n#endif\nvoid sh6cvvert();\n#ifndef  SH6COMEDG\nextern\n#endif\nvoid sh6comedg();\n#ifndef  SH6CONDIR\nextern\n#endif\nvoid sh6condir();\n#ifndef  SH6CONNECT\nextern\n#endif\nvoid sh6connect();\n#ifndef  SH6COUNT\nextern\n#endif\nint sh6count();\n#ifndef  SH6DEGEN\nextern\n#endif\nvoid sh6degen();\n#ifndef  SH6DISCONNECT\nextern\n#endif\nvoid sh6disconnect();\n#ifndef  SH6EDGPOINT\nextern\n#endif\nvoid sh6edgpoint();\n#ifndef  SH6EDGRED\nextern\n#endif\nvoid sh6edgred();\n#ifndef  SH6EVALINT\nextern\n#endif\nvoid sh6evalint();\n#ifndef  SH6FINDSPLIT\nextern\n#endif\nvoid sh6findsplit();\n#ifndef  SH6FLOOP\nextern\n#endif\nvoid sh6floop();\n#ifndef  SH6GETGEOM\nextern\n#endif\nvoid sh6getgeom();\n#ifndef  SH6GETLIST\nextern\n#endif\nvoid sh6getlist();\n#ifndef  SH6GETMAIN\nextern\n#endif\nSISLIntpt *sh6getmain();\n#ifndef  SH6GETNEXT\nextern\n#endif\nSISLIntpt *sh6getnext();\n#ifndef  SH6GETNHBRS\nextern\n#endif\nvoid sh6getnhbrs();\n#ifndef  SH6GETOTHER\nextern\n#endif\nvoid sh6getother();\n#ifndef  SH6GETPREV\nextern\n#endif\nint sh6getprev();\n#ifndef  SH6GETSEGDIV\nextern\n#endif\nint sh6getsegdiv();\n#ifndef  SH6GETTOP\nextern\n#endif\nvoid sh6gettop();\n#ifndef  SH6GETTOPHLP\nextern\n#endif\nvoid sh6gettophlp();\n#ifndef  SH6IDALLEDG\nextern\n#endif\nvoid sh6idalledg();\n#ifndef  SH6IDCON\nextern\n#endif\nvoid sh6idcon ();\n#ifndef  SH6IDFCROSS\nextern\n#endif\nvoid sh6idfcross();\n#ifndef  SH6IDGET\nextern\n#endif\nvoid sh6idget();\n#ifndef  SH6IDKPT\nextern\n#endif\nvoid sh6idkpt();\n#ifndef  SH6IDLIS\nextern\n#endif\nvoid sh6idlis();\n#ifndef  SH6IDNPT\nextern\n#endif\nvoid sh6idnpt();\n#ifndef  SH6IDNEWUNITE\nextern\n#endif\nvoid sh6idnewunite();\n#ifndef  SH6IDPUT\nextern\n#endif\nvoid sh6idput();\n#ifndef  SH6IDRMCROSS\nextern\n#endif\nvoid sh6idrmcross();\n#ifndef  SH6IDSPLIT\nextern\n#endif\nvoid sh6idsplit();\n#ifndef  SH6IDUNITE\nextern\n#endif\nvoid sh6idunite();\n#ifndef  SH6INSERT\nextern\n#endif\nvoid sh6insert();\n#ifndef  SH6INSERTPT\nextern\n#endif\nvoid sh6insertpt();\n#ifndef  SH6ISCONNECT\nextern\n#endif\nint sh6isconnect();\n#ifndef  SH6ISHELP\nextern\n#endif\nint sh6ishelp();\n#ifndef  SH6ISINSIDE\nextern\n#endif\nvoid sh6isinside();\n#ifndef  SH6ISMAIN\nextern\n#endif\nint sh6ismain();\n#ifndef  SH6NMBHELP\nextern\n#endif\nint sh6nmbhelp();\n#ifndef  SH6NMBMAIN\nextern\n#endif\nint sh6nmbmain ();\n#ifndef  SH6PTOBJ\nextern\n#endif\nvoid sh6ptobj();\n#ifndef  SH6PUTSING\nextern\n#endif\nvoid sh6putsing();\n#ifndef  SH6PUTTOUCH\nextern\n#endif\nvoid sh6puttouch();\n#ifndef  SH6RED\nextern\n#endif\nvoid sh6red();\n#ifndef  SH6REMCON\nextern\n#endif\nvoid sh6remcon();\n#ifndef  SH6REMOVEPT\nextern\n#endif\nvoid sh6removept();\n#ifndef  SH6SEPCRV\nextern\n#endif\nvoid sh6sepcrv();\n#ifndef  SH6SETCNSDIR\nextern\n#endif\nvoid sh6setcnsdir();\n#ifndef  SH6SETDIR\nextern\n#endif\nvoid sh6setdir();\n#ifndef SH6SETSEG\nextern\n#endif\nvoid sh6setseg();\n#ifndef  SH6SETTOP\nextern\n#endif\nvoid sh6settop();\n#ifndef  SH6SPLITGEOM\nextern\n#endif\nvoid sh6splitgeom();\n#ifndef  SH6TOHELP\nextern\n#endif\nvoid sh6tohelp();\n#ifndef  SH6TOMAIN\nextern\n#endif\nvoid sh6tomain();\n#ifndef  SH6TRIMLIST\nextern\n#endif\nvoid sh6trimlist();\n#ifndef  CRV_ARC_TANG\nextern\n#endif\nvoid crv_arc_tang();\n#ifndef  CRV_CRV_TANG\nextern\n#endif\nvoid crv_crv_tang();\n#ifndef  CRV_LIN_TANG\nextern\n#endif\nvoid crv_lin_tang();\n#ifndef  EV_CV_OFF\nextern\n#endif\nvoid ev_cv_off();\n#ifndef  EVAL_2_CRV\nextern\n#endif\nvoid eval_2_crv();\n#ifndef  EVAL_CRV_ARC\nextern\n#endif\nvoid eval_crv_arc();\n#ifndef  HP_S1880\nextern\n#endif\nvoid hp_s1880();\n#ifndef  INT_JOIN_PER\nextern\n#endif\nvoid int_join_per();\n#ifndef  MAKE_CV_KREG\nextern\n#endif\nvoid make_cv_kreg();\n#ifndef  MAKE_SF_KREG\nextern\n#endif\nvoid make_sf_kreg();\n#ifndef  MAKE_TRACKS\nextern\n#endif\nvoid make_tracks();\n#ifndef  NEWKNOTS\nextern\n#endif\nvoid newknots();\n#ifndef  PICK_CRV_SF\nextern\n#endif\nvoid pick_crv_sf();\n#ifndef  PO_CRV_TANG\nextern\n#endif\nvoid po_crv_tang();\n#ifndef  REFINE_ALL\nextern\n#endif\nvoid refine_all();\n#ifndef  SH_1D_DIV\nextern\n#endif\nvoid sh_1d_div();\n#ifndef  SH_DIV_CRV\nextern\n#endif\nvoid sh_div_crv();\n#ifndef  SH_DIV_SURF\nextern\n#endif\nvoid sh_div_surf();\n#ifndef  SH_SET_AT\nextern\n#endif\nvoid sh_set_at();\n#ifndef  SHAPE\nextern\n#endif\nvoid shape();\n#ifndef  SHCHECKPUT\nextern\n#endif\nvoid shcheckput();\n#ifndef  SHCHECKTYPE\nextern\n#endif\nint shchecktype();\n#ifndef  SHCSFSING\nextern\n#endif\nvoid shcsfsing();\n#ifndef  SHEVALC\nextern\n#endif\nvoid shevalc();\n#ifndef  SHMKHLPPTS\nextern\n#endif\nvoid shmkhlppts();\n#ifndef  SHSING\nextern\n#endif\nvoid shsing();\n#ifndef  SPLI_SILH\nextern\n#endif\nvoid spli_silh();\n#ifndef  TEST_CYCLIC_KNOTS\nextern\n#endif\nvoid test_cyclic_knots();\n\n#endif /* End forward declarations of  SISL C routines */\n\n#if defined(__cplusplus)\n    }\n#endif\n\n#endif  /* SISLP_INCLUDED */\n\n/* DO NOT ADD ANYTHING AFTER THIS LINE */\n"
  },
  {
    "path": "src/construct.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: construct.c,v 1.2 2001-03-19 15:58:39 afr Exp $\n *\n */\n\n\n#define CONSTRUCT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLIntpt *copyIntpt (SISLIntpt * ppt)\n#else\nSISLIntpt *\ncopyIntpt (ppt)\n     SISLIntpt *ppt;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Make a copy of an instance of Intpt, but do not\n*              copy the contents of pcurve.\n*\n*\n*\n* INPUT      : ppt    - Pointer to the intersection point that is\n*                       to be copied.\n*\n*\n*\n* OUTPUT     : copyIntpt - New intersection point.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newIntpt - Make new intersection point.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-06.\n*\n*********************************************************************\n*/\n{\n  SISLIntpt *qcopy;\t\t/* Local pointer to copied intersection point. */\n\n  /* Create copy.  */\n\n  qcopy = newIntpt (ppt->ipar, ppt->epar, ppt->adist);\n  if (qcopy == SISL_NULL)\n    goto err101;\n\n  /* Set remaining parameter.  */\n\n  qcopy->iinter = ppt->iinter;\n\n  /* Copy made.  */\n\n  goto out;\n\n  /* Error in space allocation. Return zero.  */\n\nerr101:goto out;\n\nout:return (qcopy);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLIntpt *hp_copyIntpt (SISLIntpt * ppt)\n#else\nSISLIntpt *\nhp_copyIntpt (ppt)\n     SISLIntpt *ppt;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Make a copy of an instance of Intpt, but do not\n*              copy the contents of pcurve.\n*\n*\n*\n* INPUT      : ppt    - Pointer to the intersection point that is\n*                       to be copied.\n*\n*\n*\n* OUTPUT     : copyIntpt - New intersection point.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : hp_newIntpt - Make new intersection point.\n*\n* WRITTEN BY : Ulf J. Krystad, SI,  90-06.\n*\n*********************************************************************\n*/\n{\n  SISLIntpt *qcopy;\t\t/* Local pointer to copied intersection point. */\n\n  /* Create copy.  */\n\n  qcopy = hp_newIntpt (ppt->ipar, ppt->epar, ppt->adist, ppt->iinter,\n\t\t       ppt->left_obj_1[0], ppt->right_obj_1[0],\n\t\t       ppt->left_obj_2[0], ppt->right_obj_2[0],\n\t\t       ppt->size_1, ppt->size_2, ppt->geo_data_1,\n\t\t       ppt->geo_data_2);\n  if (qcopy == SISL_NULL)\n    goto err101;\n\n  /* Copy made.  */\n\n  goto out;\n\n  /* Error in space allocation. Return zero.  */\n\nerr101:goto out;\n\nout:return (qcopy);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLbox *\nnewbox (int idim)\n#else\nSISLbox *\nnewbox (idim)\n     int idim;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Create and initialize a curve/surface surrounded\n*\t       SISLbox -instance.\n*\n*\n*\n* INPUT      : idim  -  Dimension of geometry space.\n*\n*\n*\n* OUTPUT     : newbox - Pointer to new SISLbox structure. If there is\n*                       impossible to allocate space for the structure,\n*                       newbox returns zero.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-03.\n* REWISED BY : Vibeke Skytt, SI, 91-01.\n*\n*********************************************************************\n*/\n{\n  SISLbox *qnew;\t\t/* Local pointer to new direction structure.*/\n  int ki;\t\t\t/* Counter.                                 */\n  int knum;\t\t\t/* Number of corners in the box.\t          */\n\n\n  /* Initialise number of corners. */\n\n  if (idim == 3)\n    knum = 12;\n  else if (idim == 2)\n    knum = 4;\n  else\n    knum = idim;\n\n  /* Allocate space for SISLbox structure.  */\n\n  if ((qnew = newarray (1, SISLbox)) != SISL_NULL)\n    {\n      /* Initialise new direction structure. */\n\n      qnew->imin = 0;\n      qnew->imax = 0;\n\n      /* Initialize arrays.  */\n\n      for (ki = 0; ki < 3; ki++)\n\t{\n\t  qnew->e2max[ki] = SISL_NULL;\n\t  qnew->e2min[ki] = SISL_NULL;\n\t  qnew->etol[ki] = DZERO;\n\t}\n\n      if ((qnew->emax = newarray (knum, double)) == SISL_NULL)\n\t{\n\t  freearray (qnew);\n\t  qnew = SISL_NULL;\n\t}\n      else if ((qnew->emin = newarray (knum, double)) == SISL_NULL)\n\t{\n\t  freearray (qnew->emax);\n\t  freearray (qnew);\n\t  qnew = SISL_NULL;\n\t}\n    }\n  return (qnew);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLCurve *newCurve (int in, int ik, double *et, double *ecoef,\n\t  int ikind, int idim, int icopy)\n#else\nSISLCurve *\nnewCurve (in, ik, et, ecoef, ikind, idim, icopy)\n     int in;\n     int ik;\n     double *et;\n     double *ecoef;\n     int ikind;\n     int idim;\n     int icopy;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Create and initialize a Curve-instance.\n*\n*\n*\n* INPUT      : in     - Number of vertices in new curve.\n*              ik     - Order of curve.\n*              et     - Knotvector of curve.\n*              ecoef  - Vertices of curve.\n*              ikind  - Kind of curve\n*                        = 1 : Polynomial B-spline curve.\n*                        = 2 : Rational B-spline curve.\n*                        = 3 : Polynomial Bezier curve.\n*                        = 4 : Rational Bezier curve.\n*              idim   - Dimension of the space in which the curve lies.\n*              icopy  - Flag\n*                       = 0 : Set pointer to input arrays.\n*                       = 1 : Copy input arrays.\n*                       = 2 : Set pointer and remember to free arrays.\n*\n*\n*\n* OUTPUT     : newCurve - Pointer to new curve. If there is impossible\n*                         to allocate space for the curve, newCurve\n*                         returns zero.\n*\n*\n* METHOD     :\n*              If curve is rational,\n*              points input in ecoef should have the form (w*P1,...,w*Pidim,w)\n*              The new curve will then have two arrays:\n*              qnew -> ecoef with points of the form (P1,...,Pidim)\n*              qnew -> rcoef with points of the form (w*P1,...w*Pidim,w).\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY  : Vibeke Skytt, SI, 88-05.\n* MODIFIED BY : Mike Floater, SI, 91-01 for rational curves.\n*\n*             : UJK, 92.03.27 Default value set for cuopen SISL_CRV_OPEN\n*             : VSK, 92.09.04 Remove superfluous knots and vertices\n*                             in the start and end of the curve.\n*\n*********************************************************************\n*/\n{\n  SISLCurve *qnew;\t\t/* Local pointer to new curve.  */\n  int i, j, J, jj, k;\t\t/* loop variables               */\n  int k1,k2;                    /* Superflous knots in the ends. */\n  int kdim;\t\t\t/* Dimension of space (also including potential\n\t\t\t\t   homogenous coordinate        */\n  double *st = SISL_NULL;\t\t/* Copy of knotvector.          */\n  double *rcoef = SISL_NULL;\t\t/* Copy of vertices in rational case.  */\n  double *scoef = SISL_NULL;\t\t/* Copy of vertices.            */\n\n\n  /* Allocate space for curve.  */\n\n  if ((qnew = newarray (1, SISLCurve)) == SISL_NULL)\n    goto err101;\n\n  if (ikind == 2 || ikind == 4)\n    kdim = idim + 1;\n  else\n    kdim = idim;\n\n  /* Count superflous knots in the start.  */\n  \n  for (k1=0; k1<in; k1++)\n     if (et[ik-1] < et[ik+k1]) break;\n  \n  /* Count superflous knots in the end.  */\n  \n  for (k2=0; k2<in; k2++)\n     if (et[in] > et[in-1-k2]) break;\n  \n  /* Reduce knots and vertices according to k1 and k2.  */\n  \n  if (k1 > 0)\n  {\n     memcopy(ecoef,ecoef+k1*kdim,(in-k1)*kdim,DOUBLE);\n     memcopy(et,et+k1,in+ik-k1,DOUBLE);\n  }\n  in -= (k1+k2);\n\n  /* Check if the curve is still valid. Otherwise return zero. */\n  \n  if (in < ik) goto err101;\n     \n  if (icopy == 1)\n    {\n\n      /* Copy input arrays. First allocate space for new arrays. */\n\n      if ((st = newarray (in +ik, DOUBLE)) == SISL_NULL ||\n\t  (scoef = newarray (in *kdim, DOUBLE)) == SISL_NULL)\n\tgoto err101;\n\n      /* Copy contents of arrays.  */\n\n      memcopy (st, et, in +ik, double);\n      memcopy (scoef, ecoef, in *kdim, double);\n    }\n  else\n    {\n      st = et;\n      scoef = ecoef;\n    }\n\n  /* Initialize new curve.  */\n\n  qnew->in = in;\n  qnew->ik = ik;\n  qnew->ikind = ikind;\n  qnew->idim = idim;\n  qnew->icopy = icopy;\n  qnew->et = st;\n  qnew->pdir = SISL_NULL;\n  qnew->pbox = SISL_NULL;\n\n  if (ikind == 2 || ikind == 4)\n    {\n      /* Calculate the weighted control points if the object is rational  */\n      rcoef = newarray (in *idim, DOUBLE);\n      if (rcoef == SISL_NULL)\n\tgoto err101;\n      for (i = 0, j = 0, J = 0, k = idim; i < in; i++, k += kdim)\n\t{\n\t  for (jj = 0; jj < idim; jj++, j++, J++)\n\t    {\n\t      rcoef[J] = scoef[j] / scoef[k];\n\t    }\n\t  j++;\n\t}\n      qnew->ecoef = rcoef;\n      qnew->rcoef = scoef;\n    }\n  else\n    {\n      qnew->ecoef = scoef;\n      qnew->rcoef = SISL_NULL;\n    }\n\n\n  /* UJK, 92.03.27 Default value must be set for cuopen */\n  qnew->cuopen = SISL_CRV_OPEN;\n\n  /* Task done. */\n  goto out;\n\n  /* Error in space allocation. Return zero. */\n\nerr101:if (qnew != SISL_NULL)\n          { freearray (qnew);  qnew = SISL_NULL;}  \n  if (st != SISL_NULL)\n    freearray (st);\n  if (rcoef != SISL_NULL)\n    freearray (rcoef);\n  if (scoef != SISL_NULL)\n    freearray (scoef);\n  goto out;\n\nout:return (qnew);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLdir *\nnewdir (int idim)\n#else\nSISLdir *\nnewdir (idim)\n     int idim;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Create and initialize a curve/surface direction-instance.\n*\n*\n*\n* INPUT      : idim   - Dimension of the space in which the object lies.\n*\n*\n*\n* OUTPUT     : newdir - Pointer to new direction structure. If there is\n*                       impossible to allocate space for the structure,\n*                       newdir returns zero.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-03.\n*\n*********************************************************************\n*/\n{\n  SISLdir *qnew;\t\t/* Local pointer to new direction structure.*/\n\n  /* Allocate space for direction structure.  */\n\n  if ((qnew = newarray (1, SISLdir)) != SISL_NULL)\n    {\n      /* Initialise new direction structure. */\n\n      qnew->igtpi = 0;\n      qnew->esmooth = SISL_NULL;\n      if ((qnew->ecoef = newarray (idim, double)) == SISL_NULL)\n\tfreearray (qnew);\n    }\n  return (qnew);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLEdge *newEdge (int iedge)\n#else\nSISLEdge *\nnewEdge (iedge)\n     int iedge;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Create and initialize to zero an instance of the\n*              structure Edge. The instance keeps track of intersection\n*              points on the edges/endpoints of an object.\n*\n*\n*\n* INPUT      : iedge  - Number of edges/endpoints of the object to\n*                       which it corresponds.\n*                       A curve has iedge = 2.\n*                       A tensor-product surface has iedge = 4.\n*\n*\n*\n* OUTPUT     : newEdge - A pointer to the instance created.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-05.\n*\n*********************************************************************\n*/\n{\n  int ki;\t\t\t/* Counter.                          */\n  SISLEdge *pnew;\t\t/* Local pointer to the instance.    */\n  SISLPtedge *(*ppt);\t\t/* Pointer to traverst array prpt of\n  \t\t\t       pointers to Ptedge-instances.     */\n\n  /* Allocate space for instance.  */\n\n  pnew = newarray (1, SISLEdge);\n  if (pnew == SISL_NULL)\n    goto err101;\n\n  /* Allocate space for array of pointers to Ptedge. */\n\n  pnew->prpt = newarray (iedge, SISLPtedge *);\n  if (pnew->prpt == SISL_NULL)\n    goto err101;\n\n  /* Initiate the variables of the instance. */\n\n  pnew->iedge = iedge;\n  pnew->ipoint = 0;\n\n  ppt = pnew->prpt;\n  for (ki = 0; ki < iedge; ki++)\n    *(ppt++) = SISL_NULL;\n\n  /* Task done. */\n\n  goto out;\n\n  /* Error in space allocation. Retrun zero. */\n\nerr101:pnew = SISL_NULL;\n  goto out;\n\nout:return (pnew);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLIntcurve *newIntcurve (int ipoint, int ipar1, int ipar2,\n\t\t\t   double *epar1, double *epar2, int itype)\n#else\nSISLIntcurve *\nnewIntcurve (ipoint, ipar1, ipar2, epar1, epar2, itype)\n     int ipoint;\n     int ipar1;\n     int ipar2;\n     double *epar1;\n     double *epar2;\n     int itype;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Create and initialize a new instance of the structure\n*              Intlist.\n*\n*\n*\n* INPUT      : ipoint - Number of points that define the curve.\n*              ipar1  - Number of parameter directions of first object\n*                       involved in the intersection.\n*              ipar2  - Number of parameter direction of second object.\n*              epar1  - Parameter values of points in the parameter\n*                       area of the first object.\n*                       NB! The epar1-pointer is set to point to this\n*                           array. The values are not copied.\n*              epar2  - Parameter values of points in the parameter\n*                       area of the second object.\n*                       NB! The epar2-pointer is set to point to this\n*                           array. The values are not copied.\n*              itype  - Kind of curve. (See intcurve.dcl).\n*\n*\n*\n* OUTPUT     : newIntcurve - An instance of the structure Intlist.\n*                            If it is not possible to allocate the\n*                            necessary space, zero is returned.\n*              istat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-05.\n*\n*********************************************************************\n*/\n{\n  SISLIntcurve *qnew;\n\n  /* Allocate space for the new Intcurve.  */\n\n  qnew = newarray (1, SISLIntcurve);\n  if (qnew == SISL_NULL)\n    goto err101;\n\n  /* Set variables of the intersection curve.  */\n\n  qnew->ipoint = ipoint;\n  qnew->ipar1 = ipar1;\n  qnew->ipar2 = ipar2;\n  qnew->epar1 = epar1;\n  qnew->epar2 = epar2;\n  qnew->pgeom = SISL_NULL;\n  qnew->ppar1 = SISL_NULL;\n  qnew->ppar2 = SISL_NULL;\n  qnew->itype = itype;\n\n  /* Task done.  */\n\n  goto out;\n\n  /* Error in space allocation. Return zero.  */\n\nerr101:qnew = SISL_NULL;\n  goto out;\n\nout:return (qnew);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLIntdat *newIntdat (void)\n#else\nSISLIntdat *\nnewIntdat ()\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Create and initialize to zero an instance of the\n*              structure Intdat.\n*\n*\n*\n* INPUT\n*\n*\n*\n* OUTPUT     : newIntdat - A pointer to the instance created.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : UJK         , SI, 89-04.\n*\n*********************************************************************\n*/\n{\n  SISLIntdat *pnew = SISL_NULL;\t/* Local pointer to the instance.       */\n\n  /* Allocate space for instance.                                      */\n\n  if ((pnew = newarray (1, SISLIntdat)) != SISL_NULL)\n    {\n      /* Initiate the variables of the instance.                   */\n      pnew->ipmax = 20;\n      pnew->ilmax = 10;\n      pnew->ipoint = 0;\n      pnew->ilist = 0;\n\n      /* Allocate space for array of pointers to Intlist.          */\n\n      if ((pnew->vlist = new0array (pnew->ilmax, SISLIntlist *)) != SISL_NULL)\n\t{\n\t  /* Allocate space for array of pointers to SISLIntpt     */\n\t  if ((pnew->vpoint = new0array (pnew->ipmax, SISLIntpt *))\n\t      != SISL_NULL) ;\n\n\t  /* Task done.                                        */\n\n\t  else\n\t    {\n\t      /* Error in space allocation of pnew->vpoint.*/\n\t      freearray (pnew->vlist);\n\t      freearray (pnew);\n\t    }\n\t}\n      else\n\t/* Error in space allocation of pnew->vlist.\t     */\n\tfreearray (pnew);\n    }\n  return pnew;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLIntlist *newIntlist (SISLIntpt * pfirst, SISLIntpt * plast, int itype)\n#else\nSISLIntlist *\nnewIntlist (pfirst, plast, itype)\n     SISLIntpt *pfirst;\n     SISLIntpt *plast;\n     int itype;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Create and initialize an instance of the structure\n*              SISLIntlist that contains a list of intersection points\n*              defining an intersection curve.\n*\n*\n*\n* INPUT      : pfirst - Pointer to first intersection point in the list.\n*              plast  - Pointer to last intersection point in the list.\n*              itype  - Kind of curve. See definition of the structure\n*                       Intlist.\n*\n*\n*\n* OUTPUT     : newIntlist - Pointer to the new instance of Intlist.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-05.\n*\n*********************************************************************\n*/\n{\n  SISLIntlist *pnew;\t\t/* Local pointer to this instance. */\n\n  /* Allocate space for the instance.  */\n\n  pnew = newarray (1, SISLIntlist);\n  if (pnew == SISL_NULL)\n    goto err101;\n\n  /* Initialize.  */\n\n  pnew->pfirst = pfirst;\n  pnew->plast = plast;\n  pnew->itype = itype;\n  pnew->inumb = 2;\n\n  /* Tast done. */\n\n  goto out;\n\n  /* Error in space allocation. Return zero.  */\n\nerr101:pnew = SISL_NULL;\n  goto out;\n\nout:return (pnew);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLIntpt *newIntpt (int ipar, double *epar, double adist)\n#else\nSISLIntpt *\nnewIntpt (ipar, epar, adist)\n     int ipar;\n     double *epar;\n     double adist;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Create and initializes a new instance of the structure\n*              Intpt. A pointer to this instance is returned.\n*\n*\n*\n* INPUT      : ipar   - Number of parameter directions in the intersection\n*                       problem, i.e. dimension of the array epar.\n*              epar   - Parameter value of intersection point, possibly\n*                       in two objects.\n*              adist  - Distance between the objects in the point if\n*                       there is two objects in the problem.\n*\n*\n*\n* OUTPUT     : newIntpt - Pointer to the new instance of Intpt.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-05.\n*\n*********************************************************************\n*/\n{\n  SISLIntpt *pnew;\t\t/* Local pointer to instance to create. */\n  int ki;\t\t\t/* Counter.                             */\n\n  /* Allocate space for instance of Intpt. */\n\n  pnew = newarray (1, SISLIntpt);\n  if (pnew == SISL_NULL)\n    goto err101;\n\n  /* Initialize instance. First allocate space for parameter array. */\n\n  if (ipar > 0)\n    {\n      pnew->epar = newarray (ipar, DOUBLE);\n      if (pnew->epar == SISL_NULL)\n\tgoto err101;\n    }\n\n\n  /* Initialize the variables of the instance. */\n\n  pnew->ipar = ipar;\n  for (ki = 0; ki < ipar; ki++)\n    pnew->epar[ki] = epar[ki];\n  pnew->adist = adist;\n  pnew->pcurve = SISL_NULL;\n  pnew->iinter = 0;\n\n  /* Set intersection atributes to SISL_NULL */\n  pnew->no_of_curves_alloc = 0;\n  pnew->no_of_curves = 0;\n\n  pnew->pnext = SISL_NULL;\n  pnew->curve_dir = SISL_NULL;\n  pnew->left_obj_1 = SISL_NULL;\n  pnew->left_obj_2 = SISL_NULL;\n  pnew->right_obj_1 = SISL_NULL;\n  pnew->right_obj_2 = SISL_NULL;\n  pnew->geo_data_1 = SISL_NULL;\n  pnew->size_1 = 0;\n  pnew->geo_data_2 = SISL_NULL;\n  pnew->size_2 = 0;\n\n  pnew->trim[0] = SISL_NULL;\n  pnew->trim[1] = SISL_NULL;\n  pnew->fromhelp = 0;\n\n  /* Task done.  */\n\n\n  goto out;\n\n  /* Error in space allocation. Return zero. */\n\nerr101:pnew = SISL_NULL;\n  goto out;\n\nout:return (pnew);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLIntsurf *newIntsurf (SISLIntlist * pintlist)\n#else\nSISLIntsurf *\nnewIntsurf (pintlist)\n     SISLIntlist *pintlist;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Create a new instance of the structure\n*              Intsurf.\n*\n*\n*\n* INPUT      : pintlist - Pointer to the surround curve.\n*\n*\n* OUTPUT     : newIntsurf - Pointer to the new instance,\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 91-10.\n*\n*********************************************************************\n*/\n{\n  SISLIntsurf *pnew = SISL_NULL;\t/* Local pointer to instance to create. */\n  SISLIntpt *qpt = SISL_NULL;\t/* Local help pointer                   */\n  SISLIntpt *qpfirst = SISL_NULL;\t/* Local help pointer                   */\n  SISLIntpt *qplast = SISL_NULL;\t/* Local help pointer                   */\n  SISLIntpt *qprev = SISL_NULL;\t/* Local help pointer                   */\n  SISLIntpt *qnext = SISL_NULL;\t/* Local help pointer                   */\n  int index, ipar, ipoint;\n  int ki, kk, kdir;\t\t/* Counter.                             */\n  int dummy,kstat;\n  double *stpar1, *stpar2;\n  /* ------------------------------------------------------------------ */\n\n  if (pintlist == SISL_NULL)\n    goto out;\n\n  qpfirst = pintlist->pfirst;\n  qplast  = pintlist->plast;\n  ipoint  = pintlist->inumb - 1;\n  ipar    = qpfirst->ipar;\n  index   = pintlist->ind_first;\n\n\n  if (ipar <= 0)\n    goto out;\n  if (ipoint <= 1)\n    goto out;\n\n  /* Allocate space for instance of Intsurf. */\n  pnew = newarray (1, SISLIntsurf);\n  if (pnew == SISL_NULL)\n    goto err101;\n\n  pnew->ipar = ipar;\n  pnew->ipoint = ipoint;\n\n  /* First allocate space for parameter array. */\n  pnew->epar = stpar1 = newarray (ipar * ipoint, DOUBLE);\n  if (pnew->epar == SISL_NULL)\n    goto err101;\n\n  /* Allocate space for constant direction array. */\n  /* UJK, sept 92 */\n  /* pnew->const_par = newarray (ipar, int); */\n  pnew->const_par = newarray (ipoint, int);\n  if (pnew->const_par == SISL_NULL)\n    goto err101;\n\n  /* Fill in arrays */\n\n  qpt = qprev = qpfirst;\n  qnext = qpt->pnext[index];\n\n    for (ki = 0; ki < ipoint; ki++)\n    {\n      qpt->marker = -99;\n      stpar2 = qpt->epar;\n      for (kk = 0; kk < ipar; kk++)\n\t*(stpar1++) = *(stpar2++);\n\n      for (kdir = 0; kdir < ipar; kdir++)\n\tif (qpt->curve_dir[index] &\n\t    (1 << (kdir + 1)))\n\t  break;\n\n      pnew->const_par[ki] = kdir;\n\n      /* Next point */\n      qprev = qpt;\n      qpt = qnext;\n      sh6getother (qpt, qprev, &qnext, &kstat);\n\n      sh6getlist (qpt, qnext, &index, &dummy, &kstat);\n    }\n\n  /* Task done.  */\n\n\n  goto out;\n\n  /* Error in space allocation. Return zero. */\n\nerr101:pnew = SISL_NULL;\n  goto out;\n\nout:return (pnew);\n}\n\f\n\n\n\n\n#if defined(SISLNEEDPROTOTYPES)\nSISLTrimpar *newTrimpar (int pt, int par)\n#else\nSISLTrimpar *\nnewTrimpar (pt, par)\n     int pt;\n     int par;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Create and initializes a new instance of the structure\n*              SISLTrimpar. A pointer to this instance is returned.\n*\n*\n*\n* INPUT      : pt     - Index in pnext to a pointer to an adjacent\n*                       point in the trim curve.\n*              par    - An integer between 0 and 3 indicating\n*                          which parameter is constant on the\n*                          trim curve joining ptindex.\n*\n*\n* OUTPUT     : newTrimpar - Pointer to the new instance of Trimpar.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Michael Floater, SI, 91-10.\n*\n*********************************************************************\n*/\n{\n  SISLTrimpar *newtrim;\t\t/* Local pointer to instance to create. */\n\n  /* Allocate space for instance of Trimpar. */\n\n  newtrim = newarray (1, SISLTrimpar);\n  if (newtrim == SISL_NULL)\n    goto err101;\n\n  /* Initialize the variables of the instance. */\n\n  newtrim->ptindex = pt;\n  newtrim->parindex = par;\n\n  /* Task done.  */\n\n\n  goto out;\n\n  /* Error in space allocation. Return zero. */\n\nerr101:newtrim = SISL_NULL;\n  goto out;\n\nout:return (newtrim);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLIntpt *\nhp_newIntpt (int ipar, double *epar, double adist, int itype,\n\t     int ileft1, int iright1, int ileft2, int iright2,\n\t     int size_1, int size_2, double egeom1[], double egeom2[])\n#else\nSISLIntpt *\nhp_newIntpt (ipar, epar, adist, itype, ileft1, iright1, ileft2, iright2,\n\t     size_1, size_2, egeom1, egeom2)\n     int ipar;\n     double *epar;\n     double adist;\n     int itype;\n     int ileft1;\n     int iright1;\n     int ileft2;\n     int iright2;\n     int size_1;\n     int size_2;\n     double *egeom1;\n     double *egeom2;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Create and initializes a new instance of the structure\n*              Intpt. A pointer to this instance is returned.\n*\n*\n*\n* INPUT      : ipar   - Number of parameter directions in the intersection\n*                       problem, i.e. dimension of the array epar.\n*              epar   - Parameter value of intersection point, possibly\n*                       in two objects.\n*              adist  - Distance between the objects in the point if\n*                       there is two objects in the problem.\n*              itype  - Type of intersection point.\n*              ileft1, iright1, ileft2, iright2 - Pre-topology information\n*                       conserning interpolation point.\n*              size_1 - length of egeom1.\n*              size_2 - length of egeom2.\n*              egeom1 - Geometry information of intersection point in\n*                       first object.\n*              egeom2 - Geometry information of intersection point in\n*                       second object.\n*\n*\n*\n* OUTPUT     : hp_newIntpt - Pointer to the new instance of Intpt.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 91-06.\n*\n*********************************************************************\n*/\n{\n  SISLIntpt *pnew;\t\t/* Local pointer to instance to create. */\n  int ki;\t\t\t/* Counter.                             */\n\n\n  /* Allocate space for instance of Intpt. */\n\n  pnew = new0array (1, SISLIntpt);\n  if (pnew == SISL_NULL)\n    goto err101;\n\n  /* Initialize parameters concerning the size of arrays describing\n     the intersection curves in which this points lie, and allocate\n     scratch for the arrays.      */\n\n  pnew->no_of_curves_alloc = 4;\n  pnew->no_of_curves = 0;\n\n  if ((pnew->pnext = newarray (pnew->no_of_curves_alloc, SISLIntpt *)) == SISL_NULL)\n    goto err101;\n  if ((pnew->curve_dir = newarray (pnew->no_of_curves_alloc, INT)) == SISL_NULL)\n    goto err101;\n  if ((pnew->left_obj_1 = newarray (pnew->no_of_curves_alloc, INT)) == SISL_NULL)\n    goto err101;\n  if ((pnew->left_obj_2 = newarray (pnew->no_of_curves_alloc, INT)) == SISL_NULL)\n    goto err101;\n  if ((pnew->right_obj_1 = newarray (pnew->no_of_curves_alloc, INT)) == SISL_NULL)\n    goto err101;\n  if ((pnew->right_obj_2 = newarray (pnew->no_of_curves_alloc, INT)) == SISL_NULL)\n    goto err101;\n\n  /* Initialize instance. First allocate space for parameter array. */\n\n  pnew->epar = SISL_NULL;\n  if (ipar > 0)\n    {\n      pnew->epar = newarray (ipar, DOUBLE);\n      if (pnew->epar == SISL_NULL)\n\tgoto err101;\n    }\n\n\n  /* Initialize the variables of the instance. */\n\n  pnew->ipar = ipar;\n  for (ki = 0; ki < ipar; ki++)\n    pnew->epar[ki] = epar[ki];\n  pnew->adist = adist;\n  pnew->pcurve = SISL_NULL;\n  pnew->edge_1 = 0;\n  pnew->edge_2 = 0;\n  pnew->iinter = itype;\n  pnew->marker = 0;\n  pnew->evaluated = 0;\n\n  if (size_1 > 0)\n    {\n      pnew->geo_data_1 = newarray (size_1, DOUBLE);\n      pnew->size_1 = size_1;\n      memcopy (pnew->geo_data_1, egeom1, size_1, double);\n    }\n  else\n    {\n      pnew->geo_data_1 = SISL_NULL;\n      pnew->size_1 = 0;\n    }\n\n  if (size_2 > 0)\n    {\n      pnew->geo_data_2 = newarray (size_2, DOUBLE);\n      pnew->size_2 = size_2;\n      memcopy (pnew->geo_data_2, egeom2, size_2, double);\n    }\n  else\n    {\n      pnew->geo_data_2 = SISL_NULL;\n      pnew->size_2 = 0;\n    }\n\n\n  *(pnew->left_obj_1) = ileft1;\n  *(pnew->left_obj_2) = ileft2;\n  *(pnew->right_obj_1) = iright1;\n  *(pnew->right_obj_2) = iright2;\n\n  for (ki = 0; ki < pnew->no_of_curves_alloc; ki++)\n    pnew->pnext[ki] = SISL_NULL;\n\n  /*  for (ki=0; ki<6; ki++) pnew -> geo_aux[ki] = DZERO; */\n\n  pnew->trim[0] = SISL_NULL;\n  pnew->trim[1] = SISL_NULL;\n\n  /* Init the left/right evaluator to default value zero. */\n  pnew->iside_1 = 0;\n  pnew->iside_2 = 0;\n  pnew->fromhelp = 0;\n  \n  /* Task done.  */\n\n  goto out;\n\n  /* Error in space allocation. Return zero. */\n\nerr101:pnew = SISL_NULL;\n  goto out;\n\nout:return (pnew);\n}\n\n#if defined(SISLNEEDPROTOTYPES)\nSISLTrack *\nnewTrack (SISLSurf * psurf_1, SISLSurf * psurf_2, SISLCurve * pcurve_3d,\n\t  SISLCurve * pcurve_2d_1, SISLCurve * pcurve_2d_2,\n\tint ideg, double eimpli[], int sing_start, int sing_end, int turned)\n#else\nSISLTrack *\nnewTrack (psurf_1, psurf_2, pcurve_3d,\n\t  pcurve_2d_1, pcurve_2d_2,\n\t  ideg, eimpli, sing_start, sing_end, turned)\n     SISLSurf *psurf_1;\n     SISLSurf *psurf_2;\n     SISLCurve *pcurve_3d;\n\n     SISLCurve *pcurve_2d_1;\n     SISLCurve *pcurve_2d_2;\n\n     int ideg;\n     double eimpli[];\n     int sing_start;\n     int sing_end;\n     int turned;\n\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Create and initializes a new instance of the structure\n*              SISLTrack. A pointer to this instance is returned.\n*\n*\n*\n* INPUT      : Compatible with the attributes in the structure track\n*\n*\n*\n* OUTPUT     : newTrack - Pointer to the new instance of SISLTrack\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 91-06.\n*\n*********************************************************************\n*/\n{\n  SISLTrack *pnew;\t\t/* Local pointer to instance to create. */\n\n\n  /* Allocate space for instance of Intpt. */\n\n  pnew = new0array (1, SISLTrack);\n  if (pnew == SISL_NULL)\n    goto err101;\n\n  /* Set atributes */\n\n\n  pnew->psurf_1 = psurf_1;\n  pnew->psurf_2 = psurf_2;\n  pnew->pcurve_3d = pcurve_3d;\n  pnew->pcurve_2d_1 = pcurve_2d_1;\n  pnew->pcurve_2d_2 = pcurve_2d_2;\n  pnew->ideg = ideg;\n  if (pnew->ideg)\n    memcopy (pnew->eimpli, eimpli, 16, DOUBLE);\n  pnew->sing_start = sing_start;\n  pnew->sing_end = sing_end;\n  pnew->turned = turned;\n\n  /* Task done.  */\n\n  goto out;\n\n  /* Error in space allocation. Return zero. */\n\nerr101:pnew = SISL_NULL;\n  goto out;\n\nout:return (pnew);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLObject *newObject (int iobj)\n#else\nSISLObject *\nnewObject (iobj)\n     int iobj;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Create and initialize partly an Object-instance.\n*\n*\n*\n* INPUT      : iobj   - Kind of object.\n*\n*\n*\n* OUTPUT     : newObject - Pointer to new object. If there is impossible\n*                          to allocate space for the object, newObject\n*                          returns zero.\n*              istat     - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-05.\n* MODIFIED BY: UJK               89-04.\n*              The structure SISLPoint is included.\n*              The pointer to structure object itself is included.\n*\n*********************************************************************\n*/\n{\n  SISLObject *qnew;\t\t/* Local pointer to new object.  */\n\n  qnew = newarray (1, SISLObject);\n  if (qnew == SISL_NULL)\n    goto out;\n\n  qnew->iobj = iobj;\n\n  qnew->p1 = SISL_NULL;\n  qnew->c1 = SISL_NULL;\n  qnew->s1 = SISL_NULL;\n  qnew->o1 = SISL_NULL;\n  qnew->edg[0] = SISL_NULL;\n  qnew->edg[1] = SISL_NULL;\n  qnew->edg[2] = SISL_NULL;\n  qnew->edg[3] = SISL_NULL;\n  qnew->psimple = SISL_NULL;\n\n  /* Task done.  */\n\nout:return qnew;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLPoint *newPoint (double *ecoef, int idim, int icopy)\n#else\nSISLPoint *\nnewPoint (ecoef, idim, icopy)\n     double *ecoef;\n     int idim;\n     int icopy;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Create and initialize a Point-instance.\n*\n*\n*\n* INPUT      : ecoef  - Coordinates of point.\n*              idim   - Dimension of the space in which the point lies.\n*              icopy  - Flag\n*                       = 0 : Set pointer to input array.\n*                       = 1 : Copy input arrays.\n*                       = 2 : Set pointer and remember to free array.\n*\n*\n*\n* OUTPUT     : newPoint - Pointer to new point. If there is impossible\n*                         to allocate space for the point, newPoint\n*                         returns zero.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : UJK, SI. 89-04.\n*\n*********************************************************************\n*/\n{\n  SISLPoint *qnew;\t\t/* Local pointer to new point.  */\n  double *scoef = SISL_NULL;\t\t/* Copy of coordinates          */\n\n\n  /* Allocate space for point.  */\n\n  if ((qnew = newarray (1, SISLPoint)) == SISL_NULL)\n    goto err101;\n\n\n  if (icopy == 1)\n    {\n\n      /* Copy input array. First allocate space for new array. */\n\n      if (idim < 4) \tscoef = qnew->ec;\n      else if ((scoef = newarray (idim, double)) == SISL_NULL) goto err101;\n\n      /* Copy contents of arrays.  */\n\n      memcopy (scoef, ecoef, idim, double);\n    }\n  else\n    {\n      scoef = ecoef;\n    }\n\n  /* Initialize new point.  */\n\n  qnew->idim = idim;\n  qnew->icopy = icopy;\n  qnew->ecoef = scoef;\n  qnew->pbox = SISL_NULL;\n\n  /* Task done. */\n\n  goto out;\n\n  /* Error in space allocation. Return zero. */\n\nerr101:if (qnew != SISL_NULL)\n    freearray (qnew);\n  qnew = SISL_NULL;\n  goto out;\nout:return qnew;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLPtedge *newPtedge (SISLIntpt * ppt)\n#else\nSISLPtedge *\nnewPtedge (ppt)\n     SISLIntpt *ppt;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Create and initialize an instance of the structure\n*              Ptedge, that contains elements in a list where each\n*              element has a pointer to an intersection point.\n*\n*\n*\n* INPUT      : ppt    - The intersection point at which this instance\n*                       point.\n*\n*\n*\n* OUTPUT     : newPtedge - Pointer to the crated instance.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-05.\n*\n*********************************************************************\n*/\n{\n  SISLPtedge *pnew;\t\t/* Local pointer to the instance to create. */\n\n  /* Allocate space for the instance. */\n\n  pnew = newarray (1, SISLPtedge);\n  if (pnew == SISL_NULL)\n    goto err101;\n\n  /* Initialize instance.  */\n\n  pnew->ppt = ppt;\n  pnew->pnext = SISL_NULL;\n\n  /* Task done.  */\n\n  goto out;\n\n  /* Error in space allocation. Return zero. */\n\nerr101:pnew = SISL_NULL;\n  goto out;\n\nout:return (pnew);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLSurf *\nnewSurf (int in1, int in2, int ik1, int ik2, double *et1, double *et2,\n\t double *ecoef, int ikind, int idim, int icopy)\n#else\nSISLSurf *\nnewSurf (in1, in2, ik1, ik2, et1, et2, ecoef, ikind, idim, icopy)\n     int in1;\n     int in2;\n     int ik1;\n     int ik2;\n     double *et1;\n     double *et2;\n     double *ecoef;\n     int ikind;\n     int idim;\n     int icopy;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Create and initialize a surface (instance of SISLSurf).\n*\n*\n*\n* INPUT      : in1    - Number of vertices in first parameter direction\n*                       of new surface.\n*            : in2    - Number of vertices in second parameter direction\n*                       of new surface.\n*              ik1    - Order of surface in first parameter direction.\n*              ik2    - Order of surface in second parameter direction.\n*              et1    - Knotvector of surface in first parameter direction.\n*              et2    - Knotvector of surface in second parameter direction.\n*              ecoef  - Vertices of surface.\n*              ikind  - Kind of surface\n*                        = 1 : Polynomial B-spline surface.\n*                        = 2 : Rational B-spline surface.\n*                        = 3 : Polynomial Bezier surface.\n*                        = 4 : Rational Bezier surface.\n*              idim   - Dimension of the space in which the surface lies.\n*              icopy  - Flag\n*                       = 0 : Set pointer to input arrays.\n*                       = 1 : Copy input arrays.\n*                       = 2 : Set pointer and mark to free.\n*\n*\n*\n* OUTPUT     : newSurf  - Pointer to new surface. If there is impossible\n*                         to allocate space for the surface, newSurf\n*                         returns zero.\n*\n*\n* METHOD     :\n*              If surface is rational,\n*              points input in ecoef should have the form (w*P1,...,w*Pidim,w)\n*              The new surface will then have two arrays:\n*              qnew -> ecoef with points of the form (P1,...,Pidim)\n*              qnew -> rcoef with points of the form (w*P1,...w*Pidim,w).\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-05.\n* MODIFIED BY : Mike Floater, SI, 91-01 for rational surfaces.\n*\n*********************************************************************\n*/\n{\n  SISLSurf *qnew;\t\t/* Local pointer to new surface.       */\n  int i, j, J, jj, k;\t\t/* loop variables                      */\n  int k1, k2;                   /* Superfluous knots at the ends.      */\n  int kdim;\t\t\t/* Dimension indicator.                */\n  double *st1 = SISL_NULL, *st2 = SISL_NULL;\t/* Copy of knotvectors.        */\n  double *rcoef = SISL_NULL;\t\t/* Copy of vertices in rational case.  */\n  double *scoef = SISL_NULL;\t\t/* Copy of vertices.                   */\n  double *ucoef = SISL_NULL;         /* Utility coefficient array.          */\n\n  /* Allocate space for surface.  */\n\n  if ((qnew = newarray (1, SISLSurf)) == SISL_NULL)\n    goto err101;\n\n  if (ikind == 2 || ikind == 4)\n    kdim = idim + 1;\n  else\n    kdim = idim;\n\n  /* Count superfluous knots at ends, first in u parameter directions. */\n\n  if (ik1 == 0)\n  {\n    k1 = k2 = 0;\n  }\n  else\n  {\n    /* Count superfluous knots in the start. */\n\n    for (k1 = 0; k1 < in1; k1++)\n      if (et1[ik1 - 1] < et1[ik1 + k1]) break;\n\n    /* Count superfluous knots in the end. */\n\n    for (k2 = 0; k2 < in1; k2++)\n      if (et1[in1] > et1[in1 - 1 - k2]) break;\n  }\n\n  /* Reduce knots and vertices according to k1 and k2. */\n\n  if (k1 > 0 || k2 > 0)\n  {\n     ucoef = newarray(in1*in2*kdim, DOUBLE);\n     s6chpar(ecoef, in1, in2, kdim, ucoef);\n  }\n  if (k1 > 0)\n  {\n     memcopy(ucoef, ucoef + k1*in2*kdim, (in1 - k1)*in2*kdim, DOUBLE);\n     memcopy(et1, et1 + k1, in1 + ik1 - k1, DOUBLE);\n  }\n  in1 -= (k1 + k2);\n  if (k1 > 0 || k2 > 0)\n  {\n     s6chpar(ucoef, in2, in1, kdim, ecoef);\n     if (ucoef != SISL_NULL) freearray(ucoef);\n  }\n\n  /* Count superfluous knots at ends in v parameter directions. */\n\n  if (ik2 == 0)\n  {\n    k1 = k2 = 0;\n  }\n  else\n  {\n    /* Count superfluous knots in the start. */\n\n    for (k1 = 0; k1 < in2; k1++)\n     if (et2[ik2 - 1] < et2[ik2 + k1]) break;\n\n    /* Count superfluous knots in the end. */\n\n    for (k2 = 0; k2 < in2; k2++)\n      if (et2[in2] > et2[in2 - 1 - k2]) break;\n  }\n  /* Reduce knots and vertices according to k1 and k2. */\n\n  if (k1 > 0)\n  {\n     memcopy(ecoef, ecoef + k1*in1*kdim, (in2 - k1)*in1*kdim, DOUBLE);\n     memcopy(et2, et2 + k1, in2 + ik2 - k1, DOUBLE);\n  }\n  in2 -= (k1 + k2);\n\n  if (icopy == 1)\n    {\n\n      /* Copy input arrays. First allocate space for new arrays. */\n\n      st1 = newarray (in1 + ik1, DOUBLE);\n      st2 = newarray (in2 + ik2, DOUBLE);\n      scoef = newarray (in1 * in2 * kdim, DOUBLE);\n      if (st1 == SISL_NULL || st2 == SISL_NULL || scoef == SISL_NULL)\n\tgoto err101;\n\n      /* Copy contents of arrays.  */\n      memcopy (st1, et1, in1 + ik1, double);\n      memcopy (st2, et2, in2 + ik2, double);\n      memcopy (scoef, ecoef, in1 * in2 * kdim, double);\n    }\n  else\n    {\n      st1 = et1;\n      st2 = et2;\n      scoef = ecoef;\n    }\n\n  /* Initialize new surface. */\n\n  qnew->in1 = in1;\n  qnew->in2 = in2;\n  qnew->ik1 = ik1;\n  qnew->ik2 = ik2;\n  qnew->ikind = ikind;\n  qnew->idim = idim;\n  qnew->icopy = icopy;\n  qnew->et1 = st1;\n  qnew->et2 = st2;\n  qnew->pdir = SISL_NULL;\n  qnew->pbox = SISL_NULL;\n  qnew->seg1 = SISL_NULL;\n  qnew->seg2 = SISL_NULL;\n  qnew->sf_type = NO_SURFACE_TYPE;\n\n  if (ikind == 2 || ikind == 4)\n    {\n      /* Calculate the weighted control points if the object is rational  */\n      rcoef = newarray (in1 * in2 * idim, DOUBLE);\n      if (rcoef == SISL_NULL)\n\tgoto err101;\n      for (i = 0, j = 0, J = 0, k = idim; i < in1 * in2; i++, k += kdim)\n\t{\n\t  for (jj = 0; jj < idim; jj++, j++, J++)\n\t    {\n\t      rcoef[J] = scoef[j] / scoef[k];\n\t    }\n\t  j++;\n\t}\n      qnew->ecoef = rcoef;\n      qnew->rcoef = scoef;\n    }\n  else\n    {\n      qnew->ecoef = scoef;\n      qnew->rcoef = SISL_NULL;\n    }\n  \n  /* UJK, 92.05.05 Default value must be set for cuopen */\n  qnew->cuopen_1 = SISL_SURF_OPEN;\n  qnew->cuopen_2 = SISL_SURF_OPEN;\n\n  /* Segmentation and type information not set   */\n  qnew->seg1 = NULL;\n  qnew->seg2 = NULL;\n  qnew->sf_type = NO_SURFACE_TYPE;\n\n  /* Task done. */\n\n  goto out;\n\n  /* Error in space allocation. Return zero. */\n\nerr101:if (qnew != SISL_NULL)\n    freearray (qnew);\n  /* if (st1 != SISL_NULL) */\n  /*   freearray (st1); */\n  /* if (st2 != SISL_NULL) */\n  /*   freearray (st2); */\n  /* if (rcoef != SISL_NULL) */\n  /*   freearray (rcoef); */\n  /* if (scoef != SISL_NULL) */\n  /*   freearray (scoef); */\n  goto out;\n\nout:return (qnew);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLCurve *copyCurve (SISLCurve * pcurve)\n#else\nSISLCurve *\ncopyCurve (pcurve)\n     SISLCurve *pcurve;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Make a copy of a SISLCurve.\n*\n*\n*\n* INPUT      : pcurve  -  Curve to be copied.\n*\n*\n*\n* OUTPUT     : copyCurve - The new curve.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newCurve - Make new SISLCurve.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 93-11.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\n  SISLCurve *qc = SISL_NULL;\n  int knum;\n  int ki;\n  \n  /* Make new curve. */\n\n  if (pcurve->ikind == 2 || pcurve->ikind == 4)\n  {\n     if ((qc = newCurve(pcurve->in, pcurve->ik, pcurve->et, pcurve->rcoef,\n\t\t\tpcurve->ikind, pcurve->idim, 1)) == SISL_NULL) goto err101;\n  }\n  else\n  {\n     if ((qc = newCurve(pcurve->in, pcurve->ik, pcurve->et, pcurve->ecoef,\n\t\t\tpcurve->ikind, pcurve->idim, 1)) == SISL_NULL) goto err101;\n  }\n  \n  /* Set the open/closed flag. */\n  \n  qc->cuopen = pcurve->cuopen;\n  \n  /* Copy box and  cone information. */\n  \n  if (pcurve->pbox != SISL_NULL)\n  {\n     /* Copy box information. */\n     \n     if ((qc->pbox = newbox(pcurve->idim)) == SISL_NULL) \n     {\n\tfreeCurve(qc);\n\tqc = SISL_NULL;\n\tgoto err101;\n     }\n     if (pcurve->idim == 3) knum = 9;\n     else if (pcurve->idim == 2) knum = 4;\n     else knum = pcurve->idim;\n     \n     memcopy(qc->pbox->emin, pcurve->pbox->emin, knum, DOUBLE);\n     memcopy(qc->pbox->emax, pcurve->pbox->emax, knum, DOUBLE);\n     memcopy(qc->pbox->etol, pcurve->pbox->etol, 3, DOUBLE);\n\n     for (ki=0; ki<3; ki++)\n     {\n\tif (s6existbox(pcurve->pbox, ki, pcurve->pbox->etol[ki]))\n\t{\n\t   s6newbox(qc->pbox, knum, ki, pcurve->pbox->etol[ki], &kstat);\n\t   if (kstat < 0)\n\t   {\n\t      freeCurve(qc);\n\t      qc = SISL_NULL;\n\t      goto err101;\n\t   }\n\t   memcopy(qc->pbox->e2min[ki], pcurve->pbox->e2min[ki], knum,\n\t\t   DOUBLE);\n\t   memcopy(qc->pbox->e2max[ki], pcurve->pbox->e2max[ki], knum,\n\t\t   DOUBLE);\n\t}\n     }\n  }\n  \n  if (pcurve->pdir != SISL_NULL)\n  {\n     /* Copy cone information. */\n     \n     if ((qc->pdir = newdir(pcurve->idim)) == SISL_NULL)\n     {\n\tfreeCurve(qc);\n\tqc = SISL_NULL;\n\tgoto err101;\n     }\n     qc->pdir->igtpi = pcurve->pdir->igtpi;\n     qc->pdir->aang = pcurve->pdir->aang;\n     memcopy(qc->pdir->ecoef, pcurve->pdir->ecoef, pcurve->idim, DOUBLE);\n     \n     if (pcurve->pdir->esmooth != SISL_NULL)\n     {\n\tif ((qc->pdir->esmooth = newarray(qc->in*qc->idim,DOUBLE)) == SISL_NULL)\n\t{\n\t   freeCurve(qc);\n\t   qc = SISL_NULL;\n\t   goto err101;\n\t}\n\tmemcopy(qc->pdir->esmooth, pcurve->pdir->esmooth, qc->in*qc->idim,\n\t\tDOUBLE);\n     }\n  }\n  \n  goto out;\n  \n  /* Error in allocation. */\n  \n  err101 : \n     goto out;\n  \n  out :\n     return qc;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLSurf *copySurface (SISLSurf * psurf)\n#else\nSISLSurf *\ncopySurface (psurf)\n     SISLSurf *psurf;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Make a copy of a SISLSurface.\n*\n*\n*\n* INPUT      : psurf  -  Surface to be copied.\n*\n*\n*\n* OUTPUT     : copySurface - The new curve.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newSurf - Make new SISLSurface.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 93-11.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\n  SISLSurf *qs = SISL_NULL;\n  int knum;\n  int ki;\n  \n  /* Make new curve. */\n\n  if (psurf->ikind == 2 || psurf->ikind == 4)\n  {\n     if ((qs = newSurf(psurf->in1, psurf->in2, psurf->ik1, psurf->ik2,\n\t\t       psurf->et1, psurf->et2, psurf->rcoef,\n\t\t       psurf->ikind, psurf->idim, 1)) == SISL_NULL) goto err101;\n  }\n  else\n  {\n     if ((qs = newSurf(psurf->in1, psurf->in2, psurf->ik1, psurf->ik2,\n\t\t       psurf->et1, psurf->et2, psurf->ecoef,\n\t\t       psurf->ikind, psurf->idim, 1)) == SISL_NULL) goto err101;\n  }\n  \n  /* Set the open/closed flag. */\n  \n  qs->cuopen_1 = psurf->cuopen_1;\n  qs->cuopen_2 = psurf->cuopen_2;\n  \n  /* Copy box and  cone information. */\n  \n  if (psurf->pbox != SISL_NULL)\n  {\n     /* Copy box information. */\n     \n     if ((qs->pbox = newbox(psurf->idim)) == SISL_NULL) \n     {\n\tfreeSurf(qs);\n\tqs = SISL_NULL;\n\tgoto err101;\n     }\n     if (psurf->idim == 3) knum = 9;\n     else if (psurf->idim == 2) knum = 4;\n     else knum = psurf->idim;\n     \n     memcopy(qs->pbox->emin, psurf->pbox->emin, knum, DOUBLE);\n     memcopy(qs->pbox->emax, psurf->pbox->emax, knum, DOUBLE);\n     memcopy(qs->pbox->etol, psurf->pbox->etol, 3, DOUBLE);\n\n     for (ki=0; ki<3; ki++)\n     {\n\tif (s6existbox(psurf->pbox, ki, psurf->pbox->etol[ki]))\n\t{\n\t   s6newbox(qs->pbox, knum, ki, psurf->pbox->etol[ki], &kstat);\n\t   if (kstat < 0)\n\t   {\n\t      freeSurf(qs);\n\t      qs = SISL_NULL;\n\t      goto err101;\n\t   }\n\t   memcopy(qs->pbox->e2min[ki], psurf->pbox->e2min[ki], knum,\n\t\t   DOUBLE);\n\t   memcopy(qs->pbox->e2max[ki], psurf->pbox->e2max[ki], knum,\n\t\t   DOUBLE);\n\t}\n     }\n  }\n  \n  if (psurf->pdir != SISL_NULL)\n  {\n     /* Copy cone information. */\n     \n     if ((qs->pdir = newdir(psurf->idim)) == SISL_NULL)\n     {\n\tfreeSurf(qs);\n\tqs = SISL_NULL;\n\tgoto err101;\n     }\n     qs->pdir->igtpi = psurf->pdir->igtpi;\n     qs->pdir->aang = psurf->pdir->aang;\n     memcopy(qs->pdir->ecoef, psurf->pdir->ecoef, psurf->idim, DOUBLE);\n     \n     if (psurf->pdir->esmooth != SISL_NULL)\n     {\n\tif ((qs->pdir->esmooth = newarray(qs->in1*qs->in2*qs->idim,DOUBLE)) \n\t    == SISL_NULL)\n\t{\n\t   freeSurf(qs);\n\t   qs = SISL_NULL;\n\t   goto err101;\n\t}\n\tmemcopy(qs->pdir->esmooth, psurf->pdir->esmooth, \n\t\tqs->in1*qs->in2*qs->idim, DOUBLE);\n     }\n  }\n  \n  if (psurf->seg1 != NULL)\n    {\n    }\n  if (psurf->seg2 != NULL)\n    {\n    }\n  qs->sf_type = psurf->sf_type;\n\n  goto out;\n  \n  /* Error in allocation. */\n  \n  err101 : \n     goto out;\n  \n  out :\n     return qs;\n}   \n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLSegmentation*\nnewSegmentation(double *segmentation, int *type, int nseg)\n#else\nSISLSegmentation *\nnewSegmentation(segmentation, type, nseg)\ndouble *segmentation;\nint type; \nint nseg;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Create and initialize a segmentation array for use in\n*              intersection problems. Each segmentation value has\n*              a corresponding type.\n*\n*\n*\n* INPUT      : \n*\n*\n*\n* OUTPUT     : newSegmentation - Pointer to resulting structure\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 2018-02\n*\n*********************************************************************\n*/\n{\n  SISLSegmentation *qseg = SISL_NULL;\n  qseg = newarray(1, SISLSegmentation);\n\n  if (qseg != NULL)\n    {\n      qseg->seg_val = newarray(nseg, DOUBLE);\n      qseg->seg_type = newarray(nseg, INT);  /* SEGMENTATION_TYPE */\n\n      if (qseg->seg_val == NULL || qseg->seg_type == NULL)\n\t{\n\t  if (qseg->seg_val != NULL) freearray(qseg->seg_val);\n\t  if (qseg->seg_type != NULL) freearray(qseg->seg_type);\n\t  freearray(qseg);\n\t  qseg = NULL;\n\t}\n      else\n\t{\n\t  memcopy(qseg->seg_val, segmentation, nseg, DOUBLE);\n\t  memcopy(qseg->seg_type, type, nseg, INT);\n\t  qseg->num_seg = nseg;\n\t}\n    }\n  return qseg;\n}\n\n"
  },
  {
    "path": "src/crvarctang.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: crvarctang.c,v 1.2 2001-03-19 15:58:39 afr Exp $\n *\n */\n#define CRV_ARC_TANG\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   c_a_t_s9corr(double [],double,double,double,double,double,double);\nstatic\nvoid\n   c_a_t_s9dir(double *,double *,double *,double [],double [],double [],\n\t\t  double [],double [], int);\n#else\nstatic void c_a_t_s9corr();\nstatic void c_a_t_s9dir();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   crv_arc_tang(SISLCurve *pc1, double center[], double radius,\n\t   double aepsge, double guess_par[], double iter_par[],\n\t   int *jstat)\n#else\n     void crv_arc_tang(pc1, center, radius, aepsge, guess_par,\n\t\t       iter_par, jstat)\n     SISLCurve   *pc1;\n     double center[];\n     double radius;\n     double aepsge;\n     double guess_par[];\n     double iter_par[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Newton iteration to find a tangent between the curve\n*              pc1 and a circle.\n*\n*\n* INPUT      : pc1       - Pointer to the first curve.\n*              center    - Center of the circle.\n*              radius    - Radius of the circle.\n*              aepsge    - Geometry resolution.\n*              guess_par - Guess parameter values in pc1 and circle.\n*\n*\n*\n* OUTPUT     : iter_par  - Tangential parameter values in pc1 and circle.\n*              jstat   - status messages  \n*                                < 0   : error.\n*\n*\n* METHOD     : Newton iteration on the surface ((pc2x - pc1x,pc2y - pc1y)\n*              *(-(dpc1/ds)y,(dpc1/ds)x), (pc2x - pc1x,pc2y - pc1y)*\n*              (-(dpc2/dt)y,(dpc2/dt)x)), towards the point (0,0).\n*              Guess_par and iter_par must not be separated by a tangential\n*              discontinuity.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Johannes Kaasa, SI, March 1992 (based on s1773).\n*\n*********************************************************************\n*/                       \n{                        \n  int kstat = 0;            /* Local status variable.                      */\n  int kpos = 0;             /* Position of error.                          */\n  int kleft1=0;             /* Variables used in the evaluator.            */\n  int kder=1;               /* Order of derivatives to be calulated        */\n  int kdim;                 /* Dimension of space the curves lie in        */\n  int knbit;                /* Number of iterations                        */\n  int kdir;                 /* Changing direction.                         */\n  double tdelta[2];         /* Parameter intervals of the surface.         */\n  double tdist;             /* Distance between position and origo.        */\n  double td[2],t1[2],tdn[2];/* Distances between old and new parameter\n\t\t\t       value in the tree parameter directions.     */\n  double tprev;             /* Previous difference between the curves.     */\n  double *sval =SISL_NULL;       /* Value ,first and second derivatiev of surf. */ \n  double *sdiff;            /* Difference between the point and the surf.  */\n  double enext[2];          /* Parameter values                            */\n  double snext[2];          /* Parameter values                            */\n  \n  double estart[2];         /* Lower borders in the parameter plane.       */\n  double eend[2];           /* Higher borders in the parameter plane.      */\n  double zero_pnt[2];       /* The zero point.                             */\n  \n  /* Test input.  */\n  \n  if (pc1->idim != 2) goto err106;\n  \n  kdim = 2;\n  \n  /* Initiation. */\n  \n  estart[0] = pc1->et[pc1->ik - 1];\n  estart[1] = (double)0.;\n  eend[0] = pc1->et[pc1->in];\n  eend[1] = TWOPI;\n  zero_pnt[0] = (double)0.;\n  zero_pnt[1] = (double)0.;\n  enext[0] = guess_par[0];\n  enext[1] = guess_par[1];\n  \n  /* Fetch endpoints and the intervals of parameter interval of curves.  */\n  \n  tdelta[0] = eend[0] - estart[0];\n  tdelta[1] = eend[1] - estart[1];\n  \n  /* Allocate local used memory */\n  \n  sval = newarray(4*kdim,double);\n  if (sval == SISL_NULL) goto err101;\n  \n  sdiff = sval + 3*kdim;\n  \n  /* Initiate variables.  */\n  \n  tprev = (double)HUGE;\n  \n  /* Evaluate 0-1.st derivatives of surface */\n  \n  eval_crv_arc(pc1, center, radius, kder, enext, &kleft1,\n\t       sval, &kstat);\n  if (kstat < 0) goto error;\n  \n  /* Compute the distanse vector and value and the new step. */\n  \n  c_a_t_s9dir(&tdist,td,td+1,sdiff,zero_pnt,sval,sval+kdim,sval+kdim+kdim,kdim);\n  \n  /* Correct if we are not inside the parameter intervall. */\n  \n  t1[0] = td[0];\n  t1[1] = td[1];\n  c_a_t_s9corr(t1,enext[0],enext[1],estart[0],eend[0],estart[1],eend[1]);\n  \n  /* Iterate to find the intersection point.  */\n  \n  for (knbit = 0; knbit < 50; knbit++)\n    {\n      /* Evaluate 0-1.st derivatives of surface */\n      \n      snext[0] = enext[0] + t1[0];\n      snext[1] = enext[1] + t1[1];\n      \n      eval_crv_arc(pc1, center, radius, kder, snext, &kleft1,\n \t           sval, &kstat);\n      if (kstat < 0) goto error;\n      \n      /* Compute the distanse vector and value and the new step. */\n      \n      c_a_t_s9dir(&tdist,tdn,tdn+1,sdiff,zero_pnt,\n\t    sval,sval+kdim,sval+kdim+kdim,kdim);\n      \n      /* Check if the direction of the step have change. */\n      \n      kdir = (s6scpr(td,tdn,2) >= DZERO);     /* 0 if changed. */\n      \n      /* Ordinary converging. */\n      \n      if (tdist < tprev/(double)2 || kdir)\n\t{\n          enext[0] += t1[0];\n          enext[1] += t1[1];\n\t  \n          td[0] = t1[0] = tdn[0];\n          td[1] = t1[1] = tdn[1];\n\t  \n\t  /* Correct if we are not inside the parameter intervall. */\n\t  \n\t  c_a_t_s9corr(t1,enext[0],enext[1],estart[0],eend[0],estart[1],eend[1]);\n\t  \n          if ( (fabs(t1[0]/tdelta[0]) <= REL_COMP_RES) &&\n\t      (fabs(t1[1]/tdelta[1]) <= REL_COMP_RES)) break;\n\t  \n          tprev = tdist;\n\t}\n      \n      /* Not converging, corrigate and try again. */\n      \n      else\n\t{\n          t1[0] /= (double)2;\n          t1[1] /= (double)2;\n          knbit--;\n\t}\n    }\n  \n  /* Iteration stopped, test if point founds found is within resolution */\n  \n  if (tdist <= aepsge)\n    *jstat = 1;\n  else\n    *jstat = 2;\n  \n  iter_par[0] = enext[0];\n  iter_par[1] = enext[1];\n  \n  /* Iteration completed.  */\n  \n  goto out;\n  \n  /* Error in allocation */\n  \n err101: *jstat = -101;\n  s6err(\"crv_arc_tang\",*jstat,kpos);\n  goto out;                  \n  \n  /* Error in input. Conflicting dimensions.  */\n  \n err106: *jstat = -106;\n  s6err(\"crv_arc_tang\",*jstat,kpos);\n  goto out;                  \n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"crv_arc_tang\",*jstat,kpos);\n  goto out;                  \n  \n out:    if (sval != SISL_NULL) freearray(sval);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   c_a_t_s9corr(double gd[],double acoef1,double acoef2,\n\t\t   double astart1,double aend1,double astart2,double aend2)\n#else\nstatic void c_a_t_s9corr(gd,acoef1,acoef2,astart1,aend1,astart2,aend2)\n     double gd[];\n     double acoef1;\n     double acoef2;\n     double astart1;\n     double aend1;\n     double astart2;\n     double aend2;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To be sure that we are inside the boorder of the\n*              parameter plan. If we are outside clipping is used\n*\t       to corrigate the step value.\n*\n*\n* INPUT      : acoef1  - Coeffisient in the first direction.\n*              acoef2  - Coeffisient in the second direction.\n*              astart1 - The lower boorder in first direction.\n*              aend1   - The higher boorder in first direction.\n*              estart2 - The lower boorder in second direction.\n*              eend2   - The higher boorder in second direction.\n*\n*\n*\n* INPUT/OUTPUT : gd    - Old and new step value.\n*\n*\n* METHOD     : We are cutting a line inside a rectangle.\n*\t       In this case we always know that the startpoint of\n*\t       the line is inside the rectangel, and we may therfor\n*\t       use a simple kind of clipping.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/                       \n{\n  if (acoef1 + gd[0] < astart1)  gd[0] = astart1 - acoef1;\n  else if (acoef1 + gd[0] > aend1) gd[0] = aend1 - acoef1;\n  \n  if (acoef2 + gd[1] < astart2)  gd[1] = astart2 - acoef2;\n  else if (acoef2 + gd[1] > aend2) gd[1] = aend2 - acoef2;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   c_a_t_s9dir(double *cdist,double *cdiff1,double *cdiff2,\n\t\t  double gdiff[],double eval1[],double eval2[],\n\t\t  double eder1[],double eder2[], int idim)\n#else\nstatic void c_a_t_s9dir(cdist,cdiff1,cdiff2,gdiff,eval1,eval2,eder1,eder2,idim)\n     double *cdist;\n     double *cdiff1;\n     double *cdiff2;\n     double gdiff[];\n     double eval1[];\n     double eval2[];\n     double eder1[];\n     double eder2[];\n     int    idim;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the distance vector and value beetween\n*\t       a point and a point on a surface.\n*\t       And to compute a next step on both parameter direction\n*\t       This is equivalent to the nearest way to the\n*\t       parameter plan in the tangent plan from a point in the\n*\t       distance surface between a point and a surface.\n*\n*\n* INPUT      : eval1 - Value in point.\n*              eval2 - Value in point on surface.\n*              eder1 - Derevative in first parameter direction.\n*              eder2 - Derevative in second parameter direction.\n*\t       idim  - Dimension of space the surface lie in.\n*\n*\n* OUTPUT     : gdiff   - Array to use when computing the differens vector.\n*\t       cdiff1  - Relative parameter value in intersection \n*                        point in first direction.\n*              cdiff2  - Relative parameter value in intersection \n*                        point in second direction.\n*              cdist   - The value to the point in the distance surface.\n*\n*\n* METHOD     : The method is to compute the parameter distance to the points\n*\t       on both tangents which is closest to the point.\n*\t       The differens vector beetween these points are orthogonal\n*\t       to both tangents. If the distance vector beetween the point and\n*\t       point on the surface is \"diff\" and the two derevativ vectors\n*\t       are \"der1\" and \"der2\", and the two wanted parameter distance\n*\t       are \"dt1\" and \"dt2\", then we get the following system of \n*\t       equations:\n*\t\t <-dist+dt1*der1+dt2*der2,der1> = 0\n*\t\t <-dist+dt1*der1+dt2*der2,der2> = 0\n*\t       This is futher:\n*\n*\t\t | <der1,der1>   <der1,der2> |  | dt1 |   | <dist,der1> |\n*\t\t |                           |  |     | = |     \t|\n*\t\t | <der1,der2>   <der2,der2> |  | dt2 |   | <dist,der2> |\n*\n*\t       The solution of this matrix equation is the\n*\t       following function.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/                       \n{                        \n  int kstat;\t\t          /* Local status variable. */\n  register double tdet;\t\t  /* Determinant */\n  register double t1,t2,t3,t4,t5; /* Variables in equation system */\n  \n  /* Computing the different vector */\n  \n  s6diff(eval1,eval2,idim,gdiff);\n    \n  /* Computing the length of the different vector. */\n  \n  *cdist = s6length(gdiff,idim,&kstat);\n  \n  t1 =  s6scpr(eder1,eder1,idim);\n  t2 =  s6scpr(eder1,eder2,idim);\n  t3 =  s6scpr(eder2,eder2,idim);\n  t4 =  s6scpr(gdiff,eder1,idim);\n  t5 =  s6scpr(gdiff,eder2,idim);\n  \n  /* Computing the determinant. */\n  \n  tdet = t1*t3 - t2*t2;\n  \n  if (DEQUAL(tdet,DZERO))\n    {\n      *cdiff1 = DZERO;\n      *cdiff2 = DZERO;\n    }\n  else \n    {\n      /* Using Cramer's rule to find the solution of the system. */\n      \n      *cdiff1 =  (t4*t3-t5*t2)/tdet;\n      *cdiff2 =  (t1*t5-t2*t4)/tdet;\n    }\n}\n"
  },
  {
    "path": "src/crvcrvtang.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: crvcrvtang.c,v 1.2 2001-03-19 15:58:40 afr Exp $\n *\n */\n#define CRV_CRV_TANG\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   c_c_t_s9corr(double [],double,double,double,double,double,double);\nstatic\nvoid\n   c_c_t_s9dir(double *,double *,double *,double [],double [],double [],\n\t\t  double [],double [], int);\n#else\nstatic void c_c_t_s9corr();\nstatic void c_c_t_s9dir();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   crv_crv_tang(SISLCurve *pc1, SISLCurve *pc2, double aepsge,\n\t   double guess_par[], double iter_par[], int *jstat)\n#else\n     void crv_crv_tang(pc1, pc2, aepsge, guess_par, iter_par, jstat)\n     SISLCurve   *pc1;\n     SISLCurve   *pc2;\n     double aepsge;\n     double guess_par[];\n     double iter_par[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Newton iteration to find a tangent between the two\n*              curves pc1 and pc2.\n*\n*\n* INPUT      : pc1       - Pointer to the first curve.\n*              pc2       - Pointer to the second curve.\n*              aepsge    - Geometry resolution.\n*              guess_par - Guess parameter values in pc1 and pc2.\n*\n*\n*\n* OUTPUT     : iter_par  - Tangential parameter values in pc1 and pc2.\n*              jstat   - status messages  \n*                                < 0   : error.\n*\n*\n* METHOD     : Newton iteration on the surface ((pc2x - pc1x,pc2y - pc1y)\n*              *(-(dpc1/ds)y,(dpc1/ds)x), (pc2x - pc1x,pc2y - pc1y)*\n*              (-(dpc2/dt)y,(dpc2/dt)x)), towards the point (0,0).\n*              Guess_par and iter_par must not be separated by a tangential\n*              discontinuity.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Johannes Kaasa, SI, March 1992 (based on s1773).\n*\n*********************************************************************\n*/                       \n{                        \n  int kstat = 0;            /* Local status variable.                      */\n  int kpos = 0;             /* Position of error.                          */\n  int kleft1=0;             /* Variables used in the evaluator.            */\n  int kleft2=0;             /* Variables used in the evaluator.            */\n  int kder=1;               /* Order of derivatives to be calulated        */\n  int kdim;                 /* Dimension of space the curves lie in        */\n  int knbit;                /* Number of iterations                        */\n  int kdir;                 /* Changing direction.                         */\n  double tdelta[2];         /* Parameter intervals of the surface.         */\n  double tdist;             /* Distance between position and origo.        */\n  double td[2],t1[2],tdn[2];/* Distances between old and new parameter\n\t\t\t       value in the tree parameter directions.     */\n  double tprev;             /* Previous difference between the curves.     */\n  double *sval =SISL_NULL;       /* Value ,first and second derivatiev of surf. */ \n  double *sdiff;            /* Difference between the point and the surf.  */\n  double enext[2];          /* Parameter values                            */\n  double snext[2];          /* Parameter values                            */\n  \n  double estart[2];         /* Lower borders in the parameter plane.       */\n  double eend[2];           /* Higher borders in the parameter plane.      */\n  double zero_pnt[2];       /* The zero point.                             */\n  \n  /* Test input.  */\n  \n  if (pc1->idim != 2 || pc2->idim != 2) goto err106;\n  \n  kdim = 2;\n  \n  /* Initiation. */\n  \n  estart[0] = pc1->et[pc1->ik - 1];\n  estart[1] = pc2->et[pc2->ik - 1];\n  eend[0] = pc1->et[pc1->in];\n  eend[1] = pc2->et[pc2->in];\n  zero_pnt[0] = (double)0.;\n  zero_pnt[1] = (double)0.;\n  enext[0] = guess_par[0];\n  enext[1] = guess_par[1];\n  \n  /* Fetch endpoints and the intervals of parameter interval of curves.  */\n  \n  tdelta[0] = eend[0] - estart[0];\n  tdelta[1] = eend[1] - estart[1];\n  \n  /* Allocate local used memory */\n  \n  sval = newarray(4*kdim,double);\n  if (sval == SISL_NULL) goto err101;\n  \n  sdiff = sval + 3*kdim;\n  \n  /* Initiate variables.  */\n  \n  tprev = (double)HUGE;\n  \n  /* Evaluate 0-1.st derivatives of surface */\n  \n  eval_2_crv(pc1, pc2, kder, enext, &kleft1, &kleft2,\n\t     sval, &kstat);\n  if (kstat < 0) goto error;\n  \n  /* Compute the distanse vector and value and the new step. */\n  \n  c_c_t_s9dir(&tdist,td,td+1,sdiff,zero_pnt,sval,sval+kdim,sval+kdim+kdim,kdim);\n  \n  /* Correct if we are not inside the parameter intervall. */\n  \n  t1[0] = td[0];\n  t1[1] = td[1];\n  c_c_t_s9corr(t1,enext[0],enext[1],estart[0],eend[0],estart[1],eend[1]);\n  \n  /* Iterate to find the intersection point.  */\n  \n  for (knbit = 0; knbit < 50; knbit++)\n    {\n      /* Evaluate 0-1.st derivatives of surface */\n      \n      snext[0] = enext[0] + t1[0];\n      snext[1] = enext[1] + t1[1];\n      \n      eval_2_crv(pc1, pc2, kder, snext, &kleft1, &kleft2,\n    \t         sval, &kstat);\n      if (kstat < 0) goto error;\n      \n      /* Compute the distanse vector and value and the new step. */\n      \n      c_c_t_s9dir(&tdist,tdn,tdn+1,sdiff,zero_pnt,\n\t    sval,sval+kdim,sval+kdim+kdim,kdim);\n      \n      /* Check if the direction of the step have change. */\n      \n      kdir = (s6scpr(td,tdn,2) >= DZERO);     /* 0 if changed. */\n      \n      /* Ordinary converging. */\n      \n      if (tdist < tprev/(double)2 || kdir)\n\t{\n          enext[0] += t1[0];\n          enext[1] += t1[1];\n\t  \n          td[0] = t1[0] = tdn[0];\n          td[1] = t1[1] = tdn[1];\n\t  \n\t  /* Correct if we are not inside the parameter intervall. */\n\t  \n\t  c_c_t_s9corr(t1,enext[0],enext[1],estart[0],eend[0],estart[1],eend[1]);\n\t  \n          if ( (fabs(t1[0]/tdelta[0]) <= REL_COMP_RES) &&\n\t      (fabs(t1[1]/tdelta[1]) <= REL_COMP_RES)) break;\n\t  \n          tprev = tdist;\n\t}\n      \n      /* Not converging, corrigate and try again. */\n      \n      else\n\t{\n          t1[0] /= (double)2;\n          t1[1] /= (double)2;\n          knbit--;\n\t}\n    }\n  \n  /* Iteration stopped, test if point founds found is within resolution */\n  \n  if (tdist <= aepsge)\n    *jstat = 1;\n  else\n    *jstat = 2;\n  \n  iter_par[0] = enext[0];\n  iter_par[1] = enext[1];\n  \n  /* Iteration completed.  */\n  \n  goto out;\n  \n  /* Error in allocation */\n  \n err101: *jstat = -101;\n  s6err(\"crv_crv_tang\",*jstat,kpos);\n  goto out;                  \n  \n  /* Error in input. Conflicting dimensions.  */\n  \n err106: *jstat = -106;\n  s6err(\"crv_crv_tang\",*jstat,kpos);\n  goto out;                  \n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"crv_crv_tang\",*jstat,kpos);\n  goto out;                  \n  \n out:    if (sval != SISL_NULL) freearray(sval);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   c_c_t_s9corr(double gd[],double acoef1,double acoef2,\n\t\t   double astart1,double aend1,double astart2,double aend2)\n#else\nstatic void c_c_t_s9corr(gd,acoef1,acoef2,astart1,aend1,astart2,aend2)\n     double gd[];\n     double acoef1;\n     double acoef2;\n     double astart1;\n     double aend1;\n     double astart2;\n     double aend2;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To be sure that we are inside the boorder of the\n*              parameter plan. If we are outside clipping is used\n*\t       to corrigate the step value.\n*\n*\n* INPUT      : acoef1  - Coeffisient in the first direction.\n*              acoef2  - Coeffisient in the second direction.\n*              astart1 - The lower boorder in first direction.\n*              aend1   - The higher boorder in first direction.\n*              estart2 - The lower boorder in second direction.\n*              eend2   - The higher boorder in second direction.\n*\n*\n*\n* INPUT/OUTPUT : gd    - Old and new step value.\n*\n*\n* METHOD     : We are cutting a line inside a rectangle.\n*\t       In this case we always know that the startpoint of\n*\t       the line is inside the rectangel, and we may therfor\n*\t       use a simple kind of clipping.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/                       \n{\n  if (acoef1 + gd[0] < astart1)  gd[0] = astart1 - acoef1;\n  else if (acoef1 + gd[0] > aend1) gd[0] = aend1 - acoef1;\n  \n  if (acoef2 + gd[1] < astart2)  gd[1] = astart2 - acoef2;\n  else if (acoef2 + gd[1] > aend2) gd[1] = aend2 - acoef2;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   c_c_t_s9dir(double *cdist,double *cdiff1,double *cdiff2,\n\t\t  double gdiff[],double eval1[],double eval2[],\n\t\t  double eder1[],double eder2[], int idim)\n#else\nstatic void c_c_t_s9dir(cdist,cdiff1,cdiff2,gdiff,eval1,eval2,eder1,eder2,idim)\n     double *cdist;\n     double *cdiff1;\n     double *cdiff2;\n     double gdiff[];\n     double eval1[];\n     double eval2[];\n     double eder1[];\n     double eder2[];\n     int    idim;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the distance vector and value beetween\n*\t       a point and a point on a surface.\n*\t       And to compute a next step on both parameter direction\n*\t       This is equivalent to the nearest way to the\n*\t       parameter plan in the tangent plan from a point in the\n*\t       distance surface between a point and a surface.\n*\n*\n* INPUT      : eval1 - Value in point.\n*              eval2 - Value in point on surface.\n*              eder1 - Derevative in first parameter direction.\n*              eder2 - Derevative in second parameter direction.\n*\t       idim  - Dimension of space the surface lie in.\n*\n*\n* OUTPUT     : gdiff   - Array to use when computing the differens vector.\n*\t       cdiff1  - Relative parameter value in intersection \n*                        point in first direction.\n*              cdiff2  - Relative parameter value in intersection \n*                        point in second direction.\n*              cdist   - The value to the point in the distance surface.\n*\n*\n* METHOD     : The method is to compute the parameter distance to the points\n*\t       on both tangents which is closest to the point.\n*\t       The differens vector beetween these points are orthogonal\n*\t       to both tangents. If the distance vector beetween the point and\n*\t       point on the surface is \"diff\" and the two derevativ vectors\n*\t       are \"der1\" and \"der2\", and the two wanted parameter distance\n*\t       are \"dt1\" and \"dt2\", then we get the following system of \n*\t       equations:\n*\t\t <-dist+dt1*der1+dt2*der2,der1> = 0\n*\t\t <-dist+dt1*der1+dt2*der2,der2> = 0\n*\t       This is futher:\n*\n*\t\t | <der1,der1>   <der1,der2> |  | dt1 |   | <dist,der1> |\n*\t\t |                           |  |     | = |     \t|\n*\t\t | <der1,der2>   <der2,der2> |  | dt2 |   | <dist,der2> |\n*\n*\t       The solution of this matrix equation is the\n*\t       following function.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/                       \n{                        \n  int kstat;\t\t          /* Local status variable. */\n  register double tdet;\t\t  /* Determinant */\n  register double t1,t2,t3,t4,t5; /* Variables in equation system */\n  \n  /* Computing the different vector */\n  \n  s6diff(eval1,eval2,idim,gdiff);\n    \n  /* Computing the length of the different vector. */\n  \n  *cdist = s6length(gdiff,idim,&kstat);\n  \n  t1 =  s6scpr(eder1,eder1,idim);\n  t2 =  s6scpr(eder1,eder2,idim);\n  t3 =  s6scpr(eder2,eder2,idim);\n  t4 =  s6scpr(gdiff,eder1,idim);\n  t5 =  s6scpr(gdiff,eder2,idim);\n  \n  /* Computing the determinant. */\n  \n  tdet = t1*t3 - t2*t2;\n  \n  if (DEQUAL(tdet,DZERO))\n    {\n      *cdiff1 = DZERO;\n      *cdiff2 = DZERO;\n    }\n  else \n    {\n      /* Using Cramer's rule to find the solution of the system. */\n      \n      *cdiff1 =  (t4*t3-t5*t2)/tdet;\n      *cdiff2 =  (t1*t5-t2*t4)/tdet;\n    }\n}\n"
  },
  {
    "path": "src/crvlintang.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: crvlintang.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define CRV_LIN_TANG\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   crv_lin_tang(SISLCurve *pc1, double point[], double normal[],\n\t   double ang_tol, double guess_par, double *iter_par,\n\t   int *jstat)\n#else\n     void crv_lin_tang(pc1, point, normal, ang_tol, guess_par,\n\t\t       iter_par, jstat)\n     SISLCurve   *pc1;\n     double point[];\n     double normal[];\n     double ang_tol;\n     double guess_par;\n     double *iter_par;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Newton iteration to find a tangent between the curve\n*              pc1 and a line.\n*\n*\n* INPUT      : pc1       - Pointer to the first curve.\n*              point     - Original point on the line.\n*              normal    - Normal to the line.\n*              ang_tol   - Angular tolerance (in radians).\n*              guess_par - Guess parameter values in pc1.\n*\n*\n*\n* OUTPUT     : iter_par  - Tangential parameter values in pc1.\n*              jstat   - status messages  \n*                                < 0   : error.\n*\n*\n* METHOD     : Use po_crv_tang.c to find the tangent from point to pc1,\n*              and check the tangent direction against normal.\n*              Guess_par and iter_par must not be separated by a tangential\n*              discontinuity.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Johannes Kaasa, SI, March 1992.\n*\n*********************************************************************\n*/                       \n{                        \n  int kstat = 0;            /* Local status variable.           */\n  int kpos = 0;             /* Position of error.               */\n  \n  int kder = 0;             /* Evaluates only position.         */\n  int kleft = 0;            /* Knot interval pointer.           */\n  double iter_pnt[2];       /* Resulting point on the curve.    */ \n  double diffvec[2];        /* Vector between point and curve.  */\n  double tangent[2];        /* Tangent along the line.          */\n  int kdim = 2;             /* 2 dimensional.                   */\n  double iter_ang;          /* Angular deviation.               */\n  \n  /* Test input.  */\n  \n  if (pc1->idim != 2) goto err106;\n  \n  /* Find the tangent from point to pc1. */\n  \n  po_crv_tang(pc1, point, ang_tol, guess_par, iter_par, &kstat);\n  if (kstat < 0) goto error;\n  \n  /* Check the result. */\n\n  s1221(pc1, kder, *iter_par, &kleft, iter_pnt, &kstat);\n  if (kstat < 0) goto error;\n  diffvec[0] = iter_pnt[0] - point[0];\n  diffvec[1] = iter_pnt[1] - point[1];\n  tangent[0] = -normal[1];\n  tangent[1] = normal[0];\n  iter_ang = s6ang(diffvec, tangent, kdim);\n  if (iter_ang < ang_tol)\n    *jstat = 1;\n  else\n    *jstat = 2;\n\n  goto out;\n  \n  /* Error in input. Conflicting dimensions.  */\n  \n err106: *jstat = -106;\n  s6err(\"crv_lin_tang\",*jstat,kpos);\n  goto out;                  \n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"crv_lin_tang\",*jstat,kpos);\n  goto out;                  \n  \n out: return;\n}\n\n\n"
  },
  {
    "path": "src/destruct.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: destruct.c,v 1.3 2001-03-19 15:58:40 afr Exp $\n *\n */\n\n\n#define DESTRUCT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     freeCurve(SISLCurve *pcurve)\n#else\nvoid freeCurve(pcurve)\n     SISLCurve *pcurve;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Free the space occupied by the curve pointed at by\n*              pcurve.\n*\n*\n*\n* INPUT      : pcurve - Pointer to curve.\n*\n*\n*\n* OUTPUT     :\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : freearray - Free space occupied by a given array.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-05. Arne Laksaa, SI, 89-03.\n*              Vibeke Skytt, SI, 91-01.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, 94-09.  Added free'ing\n*              of ecoef for rationals when icopy==0.  ecoef is ALWAYS\n*              allocated for rationals, regardless of the icopy flag value.\n*\n*********************************************************************\n*/\n{\n  int ki;         /* Counter.  */\n\n\n  if ( pcurve->icopy != 0 )\n  {\n\n    /* Free arrays.  */\n\n    freearray(pcurve->et);\n    freearray(pcurve->ecoef);\n    if ( pcurve->rcoef != SISL_NULL )  freearray(pcurve->rcoef);\n  }\n  else if ( pcurve->ikind == 2  ||  pcurve->ikind == 4 )\n  {\n    /* VSK, 940902. The array pcurve->ecoef is ALWAYS allocated in the\n       constructor for rationals and must be free'ed.                  */\n\n    freearray(pcurve->ecoef);\n  }\n\n  if ( pcurve->pdir )\n  {\n\n    /* Free direction structure. */\n\n    if ( pcurve->pdir->ecoef )  freearray(pcurve->pdir->ecoef);\n    if ( pcurve->pdir->esmooth != SISL_NULL )  freearray(pcurve->pdir->esmooth);\n    freearray(pcurve->pdir);\n  }\n\n  if ( pcurve->pbox )\n  {\n\n    /* Free surrounded SISLbox structure. */\n\n    if ( pcurve->pbox->emax )  freearray(pcurve->pbox->emax);\n    if ( pcurve->pbox->emin )  freearray(pcurve->pbox->emin);\n\n    for ( ki=0;  ki < 3;  ki++ )\n    {\n      if ( pcurve->pbox->e2max[ki] )  freearray(pcurve->pbox->e2max[ki]);\n      if ( pcurve->pbox->e2min[ki] )  freearray(pcurve->pbox->e2min[ki]);\n    }\n    freearray(pcurve->pbox);\n  }\n\n  /* Free instance of curve. */\n\n  freearray(pcurve);\n\n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     freeEdge(SISLEdge *pedge)\n#else\nvoid freeEdge(pedge)\n     SISLEdge *pedge;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Free the space occupied by an instance of the structure\n*              Edge. Also free space occupied by instances of Ptedge\n*              that belongs to pedge.\n*\n*\n*\n* INPUT      : pedge  - Pointer to the instance.\n*\n*\n*\n* OUTPUT     :\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-05.\n*\n*********************************************************************\n*/\n{\n\n  SISLPtedge *p1,*p2;  /* Pointers to traverse lists of Ptedge-elements.*/\n  SISLPtedge *(*pel);  /* Pointer to an array element.      */\n  int ki;                 /* Counter.                          */\n\n  /* First free the space occupied by the lists pointed at by\n     the array prpt.                                           */\n\n  pel = pedge -> prpt;\n  for (ki=0; ki<pedge->iedge; ki++)\n    {\n\n      /* Traverse the list connected to edge nr ki and free the elements. */\n\n      p1 = *pel;\n      while (p1 != SISL_NULL)\n\t{\n\t  p2 = p1 -> pnext;\n\t  freePtedge(p1);\n\t  p1 = p2;\n\t}\n      pel++;\n    }\n\n  /* Free the space occupied by the prpt array. */\n\n  freearray(pedge -> prpt);\n\n  /* Free the space occupied by the instance. */\n\n  freearray(pedge);\n\n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     freeIntcrvlist(SISLIntcurve **viclist, int icrv)\n#else\nvoid freeIntcrvlist(viclist,icrv)\n     SISLIntcurve **viclist;\n     int      icrv;\n#endif\n/*\n************************************************************************\n*\n* Purpose\t: Free a list of Intcurve.\n*\n* Input\t\t: viclist  - Array of pointers to pointers to instance\n*                            of Intcurve.\n*                 icrv     - # of SISLIntcurve in the list.\n*\n* Output\t: None.\n*\n* Method\t:\n*\n* References\t:\n*-\n* Calls\t\t: freeIntcurve - free instance of Intcurve.\n*\n*\n* Written by\t: B. O. Hoset, SI, Oslo, Norway, aug. 1989\n*\n************************************************************************\n*/\n{\n  /*\n   * Local declarations\n   * ------------------\n   */\n\n  int         ki;\n\n  /*\n   * Free each SISLIntcurve from bottom of the list and u to the top.\n   * ------------------------------------------------------------\n   */\n\n  if (viclist)\n    {\n      for ( ki = icrv - 1; ki >= 0; ki --)\n\t{\n\t  if (viclist[ki])\n\t    {\n\t      freeIntcurve(viclist[ki]);\n\t      viclist[ki] = SISL_NULL;\n\t    }\n\t}\n      freearray(viclist);\n      viclist = SISL_NULL;\n    }\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     freeIntcurve(SISLIntcurve *pintc)\n#else\nvoid freeIntcurve(pintc)\n     SISLIntcurve *pintc;\n#endif\n\n/*\n****************************************************************************\n*\n* Purpose    : Free the space occupied by the intersection curve structure.\n*\n* Input      : pintc   - Pointer to Intcurve.\n*\n*\n*\n* Output     :\n*\n*\n* Method     :\n*\n*\n* References :\n*\n*-\n* Calls      : freeCurve - Free space occupied by a curve.\n*\n* Written by : Bjoern Olav Hoset, SI, 06-89.\n*\n****************************************************************************\n*/\n{\n  /* Free whatever is allocated */\n\n  if (pintc)\n    {\n      if (pintc->epar1) freearray(pintc->epar1);\n      if (pintc->epar2) freearray(pintc->epar2);\n      if (pintc->pgeom) freeCurve(pintc->pgeom);\n      if (pintc->ppar1) freeCurve(pintc->ppar1);\n      if (pintc->ppar2) freeCurve(pintc->ppar2);\n      freearray(pintc);\n    }\n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     freeIntdat(SISLIntdat *pintdat)\n#else\nvoid freeIntdat(pintdat)\n     SISLIntdat *pintdat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Free the space occupied by an instance of the structure\n*              Intdat. Also free space occupied by instances of Intlist\n*              and SISLIntpt that belongs to intdat.\n*\n*\n*\n* INPUT      : pintdat - Pointer to the instance.\n*\n*\n*\n* OUTPUT     :\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : freeIntpt\n*              freeIntlist\n*\n* WRITTEN BY : UJK         , SI, 89-04.\n*\n*********************************************************************\n*/\n{\n  int ki;                    /* Counter.                                     */\n\n  if (pintdat == SISL_NULL) goto out;\n\n  /* First free the space occupied by the Intpt's pointed at by\n     the array vpoint.                                                       */\n\n  for (ki=0; ki<pintdat->ipoint; ki++)\n    if (pintdat -> vpoint[ki])   freeIntpt(pintdat -> vpoint[ki]);\n\n  /* Free the space occupied by the vpoint array. */\n\n  freearray(pintdat -> vpoint);\n\n  /* Next free the space occupied by the Intlists pointed at by\n     the array vlist.                                                       */\n\n  for (ki=0; ki<pintdat->ilist; ki++)\n    if    (pintdat -> vlist[ki])   freeIntlist(pintdat -> vlist[ki]);\n\n  /* Free the space occupied by the vpoint array. */\n\n  freearray(pintdat -> vlist);\n\n  /* Free the space occupied by the instance. */\n\n  freearray(pintdat);\n\n out:\n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     freeIntlist(SISLIntlist *plist)\n#else\nvoid freeIntlist(plist)\n     SISLIntlist *plist;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Free the space occupied by an instance of the structure\n*              Intlist. The instance contains a list of intersection\n*              points defining an intersection curve.\n*\n*\n*\n* INPUT      : plist  - The space occupied by this list is to be free.\n*\n*\n*\n* OUTPUT     :\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-05.\n*\n*********************************************************************\n*/\n{\n  /* Free space. */\n\n  freearray(plist);\n\n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     freeIntpt(SISLIntpt *ppt)\n#else\nvoid freeIntpt(ppt)\n     SISLIntpt *ppt;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Free the space allocated to keep the instance of Intpt\n*              pointed at by ppt.\n*\n*\n*\n* INPUT      : ppt    - Pointer to instance.\n*\n*\n*\n* OUTPUT     :\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 91-06.\n*\n*********************************************************************\n*/\n{\n  /* Free the arrays contained in the instance. */\n\n  if (ppt->ipar)\n    freearray(ppt -> epar);\n  if (ppt->pnext)       freearray(ppt->pnext);\n  if (ppt->curve_dir)   freearray(ppt->curve_dir);\n  if (ppt->left_obj_1)  freearray(ppt->left_obj_1);\n  if (ppt->left_obj_2)  freearray(ppt->left_obj_2);\n  if (ppt->right_obj_1) freearray(ppt->right_obj_1);\n  if (ppt->right_obj_2) freearray(ppt->right_obj_2);\n  if (ppt->geo_data_1)  freearray(ppt->geo_data_1);\n  if (ppt->geo_data_2)  freearray(ppt->geo_data_2);\n\n  if(ppt->trim[0] != SISL_NULL) freeTrimpar(ppt->trim[0]);\n  if(ppt->trim[1] != SISL_NULL) freeTrimpar(ppt->trim[1]);\n\n  /* Free the instance pointed at by ppt. */\n\n  freearray(ppt);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     freeIntsurf(SISLIntsurf *intsurf)\n#else\nvoid freeIntsurf(intsurf)\n     SISLIntsurf *intsurf;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Free the space allocated to keep the instance of Intsurf\n*              pointed at by intsurf.\n*\n*\n*\n* INPUT      : intsurf    - Pointer to instance.\n*\n*\n*\n* OUTPUT     :\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Michael Floater, SI, 91-11.\n*\n*********************************************************************\n*/\n{\n\n  /* Free the arrays if not SISL_NULL. */\n\n  if(intsurf->epar != SISL_NULL) freearray(intsurf->epar);\n  if(intsurf->const_par != SISL_NULL) freearray(intsurf->const_par);\n\n  /* Free the instance pointed at by intsurf. */\n\n  freearray(intsurf);\n\n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     freeTrimpar(SISLTrimpar *trimpar)\n#else\nvoid freeTrimpar(trimpar)\n     SISLTrimpar *trimpar;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Free the space allocated to keep the instance of Trimpar\n*              pointed at by trimpar.\n*\n*\n*\n* INPUT      : trimpar    - Pointer to instance.\n*\n*\n*\n* OUTPUT     :\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Michael Floater, SI, 91-10.\n*\n*********************************************************************\n*/\n{\n\n\n  /* Free the instance pointed at by trimpar. */\n\n  freearray(trimpar);\n\n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     freeTrack(SISLTrack *ppt)\n#else\nvoid freeTrack(ppt)\n     SISLTrack *ppt;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Free the space allocated to keep the instance of Track\n*              pointed at by ppt.\n*              Curves and surfaces are also removed.\n*\n*\n* INPUT      : ppt    - Pointer to instance.\n*\n*\n*\n* OUTPUT     :\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 91-06.\n*\n*********************************************************************\n*/\n{\n  /* Free the arrays contained in the instance. */\n\n   /*  if (ppt->psurf_1) freeSurf(ppt->psurf_1);\n      if (ppt->ideg == 0 && ppt->psurf_2) freeSurf(ppt->psurf_2); */\n  if (ppt->pcurve_3d) freeCurve(ppt->pcurve_3d);\n  if (ppt->pcurve_2d_1) freeCurve(ppt->pcurve_2d_1);\n  if (ppt->ideg==0 && ppt->pcurve_2d_2) freeCurve(ppt->pcurve_2d_2);\n\n  /* Free the instance pointed at by ppt. */\n\n  freearray(ppt);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     freeObject(SISLObject *pobj)\n#else\nvoid freeObject(pobj)\n     SISLObject *pobj;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Free the space occupied by the object pointed at by\n*              pobj. Also free the point, curve or surface that the\n*              object represents.\n*\n*\n*\n* INPUT      : pobj   - Pointer to object.\n*\n*\n*\n* OUTPUT     :\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : freePoint - Free space occupied by a point.\n*              freeCurve - Free space occupied by a curve.\n*              freeSurf  - Free space occupied by a surface.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-05.\n*\n* MODIFIED   : UJK               89-04.\n*              The structure SISLPoint is included.\n*\n*********************************************************************\n*/\n{\n  int ki;\n\n  /* Free point, curve or surface represented by pobj.                */\n\n  if (pobj -> iobj == SISLPOINT)\n    { if (pobj -> p1 != SISL_NULL) freePoint(pobj -> p1); }\n  else if (pobj -> iobj == SISLCURVE)\n    { if (pobj -> c1 != SISL_NULL) freeCurve(pobj -> c1); }\n  else if (pobj -> iobj == SISLSURFACE)\n    { if (pobj -> s1 != SISL_NULL) freeSurf(pobj -> s1);  }\n\n  for (ki=0; ki<4; ki++)\n    if (pobj->edg[ki] != SISL_NULL) freeObject(pobj->edg[ki]);\n\n  /* Free instance of object. */\n\n  freearray(pobj);\n\n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     freePoint(SISLPoint *ppoint)\n#else\nvoid freePoint(ppoint)\n     SISLPoint *ppoint;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Free the space occupied by the point pointed at by\n*              ppoint.\n*\n*\n*\n* INPUT      : ppoint - Pointer to point.\n*\n*\n*\n* OUTPUT     :\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : UJK, SI, 89-04.   Vibeke Skytt, SI, 91-01.\n*\n*********************************************************************\n*/\n{\n   int ki;   /* Counter.  */\n\n  if (ppoint != SISL_NULL)\n    {\n      if (ppoint -> pbox != SISL_NULL)\n      {\n\t if (ppoint->pbox->emax) freearray(ppoint->pbox->emax);\n\t if (ppoint->pbox->emin) freearray(ppoint->pbox->emin);\n\n\t for (ki=0; ki<3; ki++)\n\t {\n\t    if (ppoint->pbox->e2max[ki]) freearray(ppoint->pbox->e2max[ki]);\n\t    if (ppoint->pbox->e2min[ki]) freearray(ppoint->pbox->e2min[ki]);\n\t }\n\t freearray(ppoint->pbox);\n\t}\n\n      if ((ppoint -> idim > 3) &&\n\t  (ppoint -> icopy != 0) &&\n\t  (ppoint -> ecoef != SISL_NULL))\n\tfreearray(ppoint -> ecoef);\t/* Free array.  */\n\n      freearray(ppoint);\t\t/* Free instance of point. */\n    }\n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     freePtedge(SISLPtedge *p1)\n#else\nvoid freePtedge(p1)\n     SISLPtedge *p1;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Free the space allocated by an instance of the structure\n*              Ptedge.\n*\n*\n*\n* INPUT      : p1     - A pointer to the instance.\n*\n*\n*\n* OUTPUT     :\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-05.\n*\n*********************************************************************\n*/\n{\n  /* Free the space that p1 occupies. */\n\n  freearray(p1);\n\n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     freeSurf(SISLSurf *psurf)\n#else\nvoid freeSurf(psurf)\n     SISLSurf *psurf;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Free the space occupied by the surface pointed at by\n*              psurf.\n*\n*\n*\n* INPUT      : psurf - Pointer to surface.\n*\n*\n*\n* OUTPUT     :\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : freearray - Free space occupied by a given array.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-05. Arne Laksaa, SI, 89-03.\n*              Vibeke Skytt, SI, 91-01.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, 94-09.  Added free'ing\n*              of ecoef for rationals when icopy==0.  ecoef is ALWAYS\n*              allocated for rationals, regardless of the icopy flag value.\n*\n*********************************************************************\n*/\n{\n  int ki;     /* Counter.  */\n\n\n  if ( psurf->icopy != 0 )\n  {\n\n    /* Free arrays.  */\n\n    freearray(psurf->et1);\n    freearray(psurf->et2);\n    freearray(psurf->ecoef);\n    if ( psurf->rcoef != SISL_NULL )  freearray(psurf->rcoef);\n  }\n  else if ( psurf->ikind == 2  ||  psurf->ikind == 4 )\n  {\n    /* VSK, 940902. The array pcurve->ecoef is ALWAYS allocated in the\n       constructor for rationals and must be free'ed.                  */\n\n    freearray(psurf->ecoef);\n  }\n\n\n  if ( psurf->pdir )\n  {\n\n    /* Free direction structure. */\n\n    if ( psurf->pdir->ecoef )  freearray(psurf->pdir->ecoef);\n    if ( psurf->pdir->esmooth != SISL_NULL )  freearray(psurf->pdir->esmooth);\n    freearray(psurf->pdir);\n  }\n\n  if ( psurf->pbox )\n  {\n\n    /* Free surrounded SISLbox structure. */\n\n    if ( psurf->pbox->emax )  freearray(psurf->pbox->emax);\n    if ( psurf->pbox->emin )  freearray(psurf->pbox->emin);\n\n    for ( ki=0;  ki < 3;  ki++ )\n    {\n      if ( psurf->pbox->e2max[ki] )  freearray(psurf->pbox->e2max[ki]);\n      if ( psurf->pbox->e2min[ki] )  freearray(psurf->pbox->e2min[ki]);\n    }\n    freearray(psurf->pbox);\n  }\n\n  if (psurf->seg1)\n    freeSegmentation(psurf->seg1);\n  if (psurf->seg2)\n    freeSegmentation(psurf->seg2);\n\n  /* Free instance of surface. */\n\n  freearray(psurf);\n\n  return;\n}\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nfreeSegmentation(SISLSegmentation *pseg)\n#else\nvoid freeSegmentation(pseg)\n     SISLSegmentation *pseg;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Free the space occupied by the segmentation array\n*\n*\n*\n* INPUT      : psegmentation - Pointer to the segmentation information\n*\n*\n*\n* OUTPUT     :\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : freearray - Free space occupied by a given array.\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 2018-02\n*\n*********************************************************************\n*/\n{\n  if (pseg->seg_val != NULL) freearray(pseg->seg_val);\n  if (pseg->seg_type != NULL) freearray(pseg->seg_type);\n  freearray(pseg);\n  pseg = NULL;\n\n  return;\n}\n"
  },
  {
    "path": "src/ev_cv_off.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: ev_cv_off.c,v 1.2 2001-03-19 15:58:40 afr Exp $\n *\n */\n\n\n#define EV_CV_OFF\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   ev_cv_off(SISLCurve *pc1,int ider,double ax,int *ileft,\n\t       double offset,double eder[],int *jstat)\n#else\nvoid ev_cv_off(pc1,ider,ax,ileft,offset,eder,jstat)\n     SISLCurve *pc1;\n     int ider;\n     double ax;\n     int *ileft;\n     double offset;\n     double eder[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the value and ider first derivatives of the\n*              offset of the 2D B-spline curve pointed to by pc1, at \n*              the point with parameter value ax. At the moment we only\n*              calculate the first derivative.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve for which position\n*                       and derivatives are to be computed.\n*              ider   - The number of derivatives to compute.\n*                       < 0 : Error.\n*                       = 0 : Compute position.\n*                       = 1 : Compute position and first derivative.\n*                       etc.\n*              ax     - The parameter value at which to compute\n*                       position and derivatives.\n*              offset - The offset distance.\n*\n*                \n*\n* INPUT/OUTPUT : ileft - Pointer to the interval in the knot vector\n*                        where ax is located. If et is the knot vector,\n*                        the relation\n*                          \n*                          et[ileft] <= ax < et[ileft+1]\n* \n*                        should hold. (If ax == et[in] then ileft should\n*                        be in-1. Here in is the number of B-spline\n*                        coefficients.)\n*                        If ileft does not have the right value upon\n*                        entry to the routine, its value will be changed\n*                        to the value satisfying the above condition.\n*\n*\n*\n* OUTPUT     : eder   - Double array of dimension [(ider+1)*idim]\n*                       containing the position and derivative vectors.\n*                       (idim is the number of components of each B-spline\n*                       coefficient, i.e. the dimension of the Euclidean\n*                       space in which the curve lies.)\n*                       These vectors are stored in the following order:\n*                       First the idim components of the position vector,\n*                       then the idim components of the tangent vector,\n*                       then the idim components of the second derivative\n*                       vector, and so on.\n*                       (The C declaration of eder as a two dimensional array\n*                       would therefore be eder[ider+1,idim].)\n*              jstat  - Status messages  \n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : We evaluate the original curve with one derivative higher,\n*              and evaluate the expression for the offset.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1220    - Computes B-spline values and derivatives at\n*                         a given point.\n*              s6err    - Error handling routine \n*              s6ratder - Make derivative of rational expression\n*\n* WRITTEN BY : Johannes Kaasa, SI, March 1992. Based on s1221. \n*\n*********************************************************************\n*/                                     \n{\n  int kstat=0;        /* Local status variable.                          */\n  int kpos=0;         /* The position of the error.                      */\n  int kn;             /* The number of B-splines, i.e., the dimension of\n\t\t\t the spline space associated with the knot\n\t\t\t vector.                                         */\n  int kk;             /* The polynomial order of the curve.              */\n  int kdim;           /* The dimension of the space in which the curve\n\t\t\t lies. Equivalently, the number of components\n\t\t\t of each B-spline coefficient.                   */\n  int kleft;          /* Local version of ileft which is used in order to\n\t\t\t avoid the pointer.                              */\n  int kder;           /* Local version of ider+1. Since derivatives of \n\t\t\t order higher than kk-1 are all zero, we set\n\t\t\t kder = min(kk-1,ider+1).                        */\n  int kind;           /* Type of curve                                   */\n  int ki,kj,kih,kjh;  /* Control variables in for loops and for stepping\n\t\t\t through arrays.                                 */\n  int kl,kl1,kl2;     /* Control variables in for loops and for stepping\n\t\t\t through arrays.                                 */\n  double *st;         /* Pointer to the first element of the knot vector\n\t\t\t of the curve. The knot vector has [kn+kk]\n\t\t\t elements.                                       */\n  double *scoef;      /* Pointer to the first element of the curve's\n\t\t\t B-spline coefficients. This is assumed to be an\n\t\t\t array with [kn*kdim] elements stored in the\n\t\t\t following order:\n\t\t\t First the kdim components of the first B-spline\n\t\t\t coefficient, then the kdim components of the\n\t\t\t second B-spline coefficient and so on.          */\n  double tt;          /* Dummy variable used for holding an array element\n\t\t\t in a for loop.                                  */\n  double *ebder=SISL_NULL; /* Pointer to an array of dimension [kk*(ider+1)]\n\t\t       which will contain the values and ider first derivatives\n\t\t\t of the kk nonzero B-splines at ax.\n\t\t\t These are stored in the following order:\n\t\t\t First the value, 1. derivative etc. of the\n\t\t\t first nonzero B-spline, then the same for the\n\t\t\t second nonzero B-spline and so on.              */\n  double *sder=SISL_NULL;  /* Pointer to array used for storage of points, if\n\t\t\t non rational sder points to eder, if rational sder\n\t\t\t has to be allocated to make room for the homogenous\n\t\t\t coordinate */\n  double hlpnorm;     /* Length of the cross normal to the curve.        */\n  \n  /* Copy curve attributes to local parameters.  */\n  \n  kn = pc1 -> in;\n  kk = pc1 -> ik;\n  st = pc1 -> et;\n  kdim = pc1 -> idim;\n  kind = pc1 ->ikind;\n  \n  if (kind == 2 || kind == 4)\n    {\n      scoef = pc1 -> rcoef;\n      kdim +=1;\n    }\n  else\n      scoef = pc1 -> ecoef;\n\n  sder = newarray(kdim*(ider+2),DOUBLE); \n  if (sder==SISL_NULL) goto err101;\n  \n  /* Check the input. */\n  \n  if (pc1->idim != 2) goto err102;\n  \n  if (kk < 1) goto err110;\n  \n  if (kn < kk) goto err111;\n  \n  if (st[kk-1] == st[kk] || st[kn-1] == st[kn]) goto err112;\n  \n  if (ider < 0 || ider > 2) goto err178;\n  \n  kder = min(kk-1,ider+1);\n  \n  /* Allocate space for B-spline values and derivatives. */\n  \n  ebder = newarray(kk*(kder+1),double);\n  if (ebder == SISL_NULL) goto err101;\n  \n  /* Set all the elements of sder to 0. */\n  \n  for (ki=0; ki<(ider+2)*kdim; ki++) sder[ki] = DZERO;\n  \n  /* Compute the values and derivatives of the nonzero B-splines and\n     update ileft if necessary.                                      */\n  \n  s1220(st,kk,kn,ileft,ax,kder,ebder,&kstat);\n  \n  if (kstat < 0) goto error;\n  \n  kleft = *ileft;\n  \n  /* Evaluate the original curve with one derivative higher. */\n  \n  /* ki steps through the appropriate kk B-spline coefficients while kih steps\n     through the B-spline value and derivatives for the B-spline given by ki.*/\n  \n  kih = 0;\n  for (ki=kleft-kk+1; ki<=kleft; ki++)\n    {\n      \n      /* kj counts through the kder+1 derivatives to be computed.\n\t kjh steps through sder once for each ki to accumulate the contribution\n\t from the different B-splines.\n\t kl1 points to the first component of B-spline coefficient no. ki. */\n      \n      kjh = 0; kl1 = kdim*ki;\n      for (kj=0; kj<=kder; kj++)\n\t{\n\t  \n\t  /* The value of the B-spline derivative is stored in tt while\n\t     kl2 steps through the idim components of this B-spline\n\t     coefficient. */\n\t  \n\t  tt = ebder[kih++]; kl2 = kl1;\n\t  for (kl=0; kl<kdim; kl++,kjh++,kl2++)\n\t    {\n\t      sder[kjh] += scoef[kl2]*tt;\n\t    }\n\t}\n    }\n  \n  /* If rational curve calculate the derivatives based on derivatives in\n     homogenous coordinates */\n  \n  if (kind == 2 || kind == 4)\n    {\n      s6ratder(sder,pc1->idim,ider,sder,&kstat);\n      if (kstat<0) goto error;\n    }\n  \n  /* Evaluate the offset expression. */\n  \n  hlpnorm = sqrt(sder[2]*sder[2] + sder[3]*sder[3]);\n  if (hlpnorm < REL_COMP_RES) goto err113;\n  \n  eder[0] = sder[0] + offset*(-sder[3]/hlpnorm);\n  eder[1] = sder[1] + offset*(sder[2]/hlpnorm);\n  if (ider > 0)\n    {\n       eder[2] = sder[2] + offset*(sder[2]*sder[3]*sder[4] - sder[2]\n\t\t\t\t   *sder[2]*sder[5])/pow(hlpnorm,3); \n       eder[3] = sder[3] + offset*(sder[3]*sder[3]*sder[4] - sder[2]\n\t\t\t\t   *sder[3]*sder[5])/pow(hlpnorm,3);\n    }\n  if (ider > 1)\n    {\n       eder[4] = sder[4] + offset*((pow(sder[2],3)*sder[3] \n\t\t + sder[2]*pow(sder[3],3))*sder[6] - (pow(sder[2],4) \n\t\t + (sder[2]*sder[2])*(sder[3]*sder[3]))*sder[7] \n\t\t + (pow(sder[3],3) - 2*sder[3]*(sder[2]*sder[2]))*\n\t\t (sder[4]* sder[4]) + 2*(pow(sder[2],3) \n\t\t - 2*sder[2]*(sder[3]*sder[3]))*(sder[4]*\n                 sder[5]) + 3*(sder[2]*sder[2])*sder[3]*sder[5]*sder[5])/\n\t         pow(hlpnorm,5);\n       eder[5] = sder[5] + offset*(((sder[2]*sder[2])*(sder[3]*sder[3]) \n\t\t + pow(sder[3],4))*sder[6] - (pow(sder[2],3)*sder[3] \n\t\t + sder[2]*pow(sder[3],3))*sder[7] -3*sder[2]\n\t\t *(sder[3]*sder[3])*(sder[4]*sder[4]) + 2*(2*(sder[2]\n\t\t *sder[2]*sder[3]) - pow(sder[3],3))*(sder[4]*sder[5]) + \n\t\t (2*sder[2]*(sder[3]*sder[3]) - pow(sder[2],3))\n\t\t  *(sder[5]*sder[5]))/pow(hlpnorm,5);\n    }\n  \n  /* Free memory. */\n  \n  freearray(ebder);\n  freearray(sder);\n  \n  /* Successful computations.  */\n  \n  *jstat = 0;\n  goto out;\n\n/* Not enough memory. */\n err101: *jstat = -101;\n         s6err(\"ev_cv_off\",*jstat,kpos);\n         goto out;\n\n/* kdim less than 1. */\n err102: *jstat = -102;\n         s6err(\"ev_cv_off\",*jstat,kpos);\n         goto out;\n\n/* Polynomial order less than 1. */\n err110: *jstat = -110;\n         s6err(\"ev_cv_off\",*jstat,kpos);\n         goto out;\n\n/* Fewer B-splines than the order. */\n err111: *jstat = -111;\n         s6err(\"ev_cv_off\",*jstat,kpos);\n         goto out;\n\n/* Error in knot vector.\n   (The first or last interval of the knot vector is empty.) */\n err112: *jstat = -112;\n         s6err(\"ev_cv_off\",*jstat,kpos);\n         goto out;\n\n/* Singularity in the original evaluation point.\n   (The original curve tangent is zero in this point.) */\n err113: *jstat = -113;\n         s6err(\"ev_cv_off\",*jstat,kpos);\n         goto out;\n\n/* Illegal derivative requested. */\n err178: *jstat = -178;\n         s6err(\"ev_cv_off\",*jstat,kpos);\n         goto out;\n\n/* Error in lower level routine.  */\n\n error:  *jstat = kstat;\n         s6err(\"ev_cv_off\",*jstat,kpos);\n         goto out;\n\nout: return;\n}\n"
  },
  {
    "path": "src/eval_2_crv.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: eval_2_crv.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define EVAL_2_CRV\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   eval_2_crv(SISLCurve *pc1,SISLCurve *pc2,int ider,double epar[],int *ilfs,\n\t   int *ilft,double eder[],int *jstat)\n#else\nvoid eval_2_crv(pc1,pc2,ider,epar,ilfs,ilft,eder,jstat)\n     SISLCurve *pc1;\n     SISLCurve *pc2;\n     int       ider;\n     double    epar[];\n     int       *ilfs;\n     int       *ilft;\n     double    eder[];\n     int       *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Evaluate the surface expressed by ((pc2x - pc1x,pc2y -\n*              pc1y)*(-(dpc1/ds)y,(dpc1/ds)x), (pc2x - pc1x,pc2y - pc1y)\n*              *(-(dpc2/dt)y,(dpc2/dt)x)), at the parameter values given\n*              in epar. Compute ider derivatives.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the first curve.\n*            : pc2    - Pointer to the second curve.\n*              ider   - Number of derivatives to calculate.\n*                       < 0 : No derivative calculated.    \n*                       = 0 : Position calculated.\n*                       = 1 : Position and first derivative calculated.\n*                       etc.\n*              epar   - Parameter-value at which to calculate. Dimension\n*                       of epar is 2.\n*\n*                \n*\n* INPUT/OUTPUT : ilfs  - Pointer to the interval in the knotvector\n*                        in first parameter direction where epar[0] \n*                        is found. The relation\n*                          \n*                          et1[ilfs] <= epar[0] < et1[ilfs+1]\n* \n*                        where et1 is the knotvektor should hold.\n*                        ilfs is set equal to zero at the first call\n*                        to the routine. \n*                ilft  - Corresponding to ilfs in the second parameter\n*                        direction.\n*             \n*\n*\n*\n* OUTPUT     : eder   - Array where the derivative of the curve in\n*                       apar is placed. The sequence is position,\n*                       first derivative in first parameter direction,\n*                       first derivative in second parameter direction,\n*                       (2,0) derivative, (1,1) derivative, (0,2) \n*                       derivative, etc. Dimension of eder is \n*                       idim*(1+2+...+(ider+1)).\n*              jstat  - status messages  \n*                                         = 0      : ok\n*                                         < 0      : error\n*                      \n*\n* METHOD     : \n*\n* REFERENCES :\n*\n*-\n* CALLS      : \n*\n* WRITTEN BY : Johannes Kaasa, SI, March 1992. \n*\n*********************************************************************\n*/                                     \n{\n  int kstat=0;         /* Local status variable.                         */\n  int kpos=0;          /* The position of error.                         */\n  int kder = ider + 1; /* Number of necessary curve derivatives.         */ \n  double crv1[8];      /* The derivatives of the first curve.            */\n  double crv2[8];      /* The derivatives of the second curve.           */\n  double diffvec[2];   /* Difference vector between the two curves.      */\n  \n  /* Check the input. */\n  \n  if (pc1->idim != 2 || pc2->idim != 2) goto err102;\n  if (ider > 2) goto err103;\n  \n  /* Evaluate the curves. */\n  \n  s1221(pc1, kder, epar[0], ilfs, crv1, &kstat);\n  if (kstat < 0) goto error;\n\n  s1221(pc2, kder, epar[1], ilft, crv2, &kstat);\n  if (kstat < 0) goto error;\n  \n  diffvec[0] = crv2[0] - crv1[0];\n  diffvec[1] = crv2[1] - crv1[1];\n  \n  /* Calculate the position on the surface. */\n  \n  eder[0] = diffvec[1]*crv1[2] - diffvec[0]*crv1[3];\n  eder[1] = diffvec[1]*crv2[2] - diffvec[0]*crv2[3];\n  \n  /* Calculate the first derivatives. */\n  \n  if (ider > 0)\n    {\n       eder[2] = diffvec[1]*crv1[4] - diffvec[0]*crv1[5];\n       eder[3] = crv1[2]*crv2[3] - crv1[3]*crv2[2];\n       eder[4] = crv1[2]*crv2[3] - crv1[3]*crv2[2];\n       eder[5] = diffvec[1]*crv2[4] - diffvec[0]*crv2[5];\n    }\n  \n  /* Calculate the second derivatives. */\n  \n  if (ider > 1)\n    {\n       eder[6] = crv1[2]*crv1[5] - crv1[3]*crv1[4]\n\t  + diffvec[1]*crv1[6] - diffvec[0]*crv1[7];\n       eder[7] = crv1[4]*crv2[3] - crv1[5]*crv2[2];\n       eder[8] = crv1[4]*crv2[3] - crv1[5]*crv2[2];\n       eder[9] = crv1[2]*crv2[5] - crv1[3]*crv2[4];\n       eder[10] = crv1[2]*crv2[5] - crv1[3]*crv2[4];\n       eder[11] = crv2[3]*crv2[4] - crv2[2]*crv2[5]\n\t  + diffvec[1]*crv2[6] - diffvec[0]*crv2[7];\n    }\n\t  \n  \n  /* Successful computations.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"eval_2_crv\",*jstat,kpos);\n  goto out;\n  \n  /* Dimension unequal to 2. */\n  \n  err102: *jstat = -102;\n  s6err(\"eval_2_crv\",*jstat,kpos);\n\n  /* More than 2 derivatives. */\n  \n  err103: *jstat = -103;\n  s6err(\"eval_2_crv\",*jstat,kpos);\n\n  out:\n  \n  return;\n}\n\n"
  },
  {
    "path": "src/evalcrvarc.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: evalcrvarc.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define EVAL_CRV_ARC\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   eval_crv_arc(SISLCurve *pc1,double center[],double radius,int ider,\n\t   double epar[],int *ilfs,double eder[],int *jstat)\n#else\nvoid eval_crv_arc(pc1,center,radius,ider,epar,ilfs,eder,jstat)\n     SISLCurve *pc1;\n     double    center[];\n     double    radius;\n     int       ider;\n     double    epar[];\n     int       *ilfs;\n     double    eder[];\n     int       *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Evaluate the surface expressed by ((pc2x - pc1x,pc2y -\n*              pc1y)*(-(dpc1/ds)y,(dpc1/ds)x), (pc2x - pc1x,pc2y - pc1y)\n*              *(-(dpc2/dt)y,(dpc2/dt)x)), at the parameter values given\n*              in epar, where pc2 is a circle. Compute ider derivatives.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the first curve.\n*              center - Center of the circle.\n*              radius - Radius of the circle.\n*              ider   - Number of derivatives to calculate.\n*                       < 0 : No derivative calculated.    \n*                       = 0 : Position calculated.\n*                       = 1 : Position and first derivative calculated.\n*                       etc.\n*              epar   - Parameter-value at which to calculate. Dimension\n*                       of epar is 2.\n*\n*                \n*\n* INPUT/OUTPUT : ilfs  - Pointer to the interval in the knotvector\n*                        in first parameter direction where epar[0] \n*                        is found. The relation\n*                          \n*                          et1[ilfs] <= epar[0] < et1[ilfs+1]\n* \n*                        where et1 is the knotvektor should hold.\n*                        ilfs is set equal to zero at the first call\n*                        to the routine. \n*             \n*\n*\n*\n* OUTPUT     : eder   - Array where the derivative of the curve in\n*                       apar is placed. The sequence is position,\n*                       first derivative in first parameter direction,\n*                       first derivative in second parameter direction,\n*                       (2,0) derivative, (1,1) derivative, (0,2) \n*                       derivative, etc. Dimension of eder is \n*                       idim*(1+2+...+(ider+1)).\n*              jstat  - status messages  \n*                                         = 0      : ok\n*                                         < 0      : error\n*                      \n*\n* METHOD     : \n*\n* REFERENCES :\n*\n*-\n* CALLS      : \n*\n* WRITTEN BY : Johannes Kaasa, SI, March 1992. \n*\n*********************************************************************\n*/                                     \n{\n  int kstat=0;         /* Local status variable.                         */\n  int kpos=0;          /* The position of error.                         */\n  int kder = ider + 1; /* Number of necessary curve derivatives.         */ \n  double crv1[8];      /* The derivatives of the first curve.            */\n  double crv2[8];      /* The derivatives of the second curve.           */\n  double diffvec[2];   /* Difference vector between the two curves.      */\n  double ang_cos;      /* Cosine of the angle in the circle.             */\n  double ang_sin;      /* Sine of the angle in the circle.               */\n  \n  /* Check the input. */\n  \n  if (pc1->idim != 2) goto err102;\n  if (ider > 2) goto err103;\n  \n  /* Evaluate the curve. */\n  \n  s1221(pc1, kder, epar[0], ilfs, crv1, &kstat);\n  if (kstat < 0) goto error;\n  \n  /* Evaluate the circle. */\n\n  ang_cos = cos(epar[1]);\n  ang_sin = sin(epar[1]);\n  \n  crv2[0] = center[0] + radius*ang_cos;\n  crv2[1] = center[1] + radius*ang_sin;\n  crv2[2] = - radius*ang_sin;\n  crv2[3] = radius*ang_cos;\n  crv2[4] = - radius*ang_cos;\n  crv2[5] = - radius*ang_sin;\n  crv2[6] = radius*ang_sin;\n  crv2[7] = - radius*ang_cos;\n  \n  diffvec[0] = crv2[0] - crv1[0];\n  diffvec[1] = crv2[1] - crv1[1];\n  \n  /* Calculate the position on the surface. */\n  \n  eder[0] = diffvec[1]*crv1[2] - diffvec[0]*crv1[3];\n  eder[1] = diffvec[1]*crv2[2] - diffvec[0]*crv2[3];\n  \n  /* Calculate the first derivatives. */\n  \n  if (ider > 0)\n    {\n       eder[2] = diffvec[1]*crv1[4] - diffvec[0]*crv1[5];\n       eder[3] = crv1[2]*crv2[3] - crv1[3]*crv2[2];\n       eder[4] = crv1[2]*crv2[3] - crv1[3]*crv2[2];\n       eder[5] = diffvec[1]*crv2[4] - diffvec[0]*crv2[5];\n    }\n  \n  /* Calculate the second derivatives. */\n  \n  if (ider > 1)\n    {\n       eder[6] = crv1[2]*crv1[5] - crv1[3]*crv1[4]\n\t  + diffvec[1]*crv1[6] - diffvec[0]*crv1[7];\n       eder[7] = crv1[4]*crv2[3] - crv1[5]*crv2[2];\n       eder[8] = crv1[4]*crv2[3] - crv1[5]*crv2[2];\n       eder[9] = crv1[2]*crv2[5] - crv1[3]*crv2[4];\n       eder[10] = crv1[2]*crv2[5] - crv1[3]*crv2[4];\n       eder[11] = crv2[3]*crv2[4] - crv2[2]*crv2[5]\n\t  + diffvec[1]*crv2[6] - diffvec[0]*crv2[7];\n    }\n\t  \n  \n  /* Successful computations.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"eval_crv_arc\",*jstat,kpos);\n  goto out;\n  \n  /* Dimension unequal to 2. */\n  \n  err102: *jstat = -102;\n  s6err(\"eval_crv_arc\",*jstat,kpos);\n  goto out;\n\n  /* More than 2 derivatives. */\n  \n  err103: *jstat = -103;\n  s6err(\"eval_crv_arc\",*jstat,kpos);\n\n  out:\n  \n  return;\n}\n\n"
  },
  {
    "path": "src/hp_s1880.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: hp_s1880.c,v 1.5 2003-01-10 12:53:36 vsk Exp $\n *\n */\n\n\n#define HP_S1880\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n    hp_s1880(SISLObject * po1, SISLObject * po2,\n\t     int ideg,\n\t     int ipar1, int ipar2, SISLIntdat *pintdat,\n\t     int *jpar, double **gpar1, double **gpar2, int **pretop,\n\t     int *jcrv, SISLIntcurve *** wcrv, int *jsurf, SISLIntsurf *** wsurf,\n\t     int *jstat)\n#else\nvoid\n   hp_s1880(po1, po2, ideg, ipar1, ipar2, pintdat, jpar, gpar1, gpar2, pretop, jcrv,\n       wcrv, jsurf, wsurf, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     int ideg;\n     int ipar1;\n     int ipar2;\n     SISLIntdat *pintdat;\n     int *jpar;\n     double **gpar1;\n     double **gpar2;\n     int **pretop;\n     int *jcrv;\n     SISLIntcurve ***wcrv;\n     int *jsurf;\n     SISLIntsurf ***wsurf;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Transform intersection points and curves from internal\n*              format in the recursive part of intersection routines\n*              to output format.\n*\n*\n*\n* INPUT      : po1    - Pointer first object.\n*              po2    - Pointer second object.\n*              ideg   - Type of implicit geometry.\n*              ipar1  - Number of parameter directions of first object.\n*              ipar2  - Number of parameter directions of second object.\n*              pintdat - SISLIntdat object.\n*\n*\n* OUTPUT     : jpar   - Number of single intersection points.\n*              gpar1  - Parameter values of the single intersection points\n*                       in the parameter area of the first object.\n*              gpar2  - Parameter values of the single intersection points\n*                       in the parameter area of the second object.\n*              pretop - Array of pretopology information for the points.\n*              jcrv   - Number of intersection curves.\n*              wcrv   - Array containing description of intersection curves.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newIntcurve - Create a new instance of Intcurve.\n*              freeIntpt   - Free space occupied by intersection point.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-05.\n* REWRITTEN BY : Ulf J. Krystad, SI, 91-06\n* REWRITTEN BY : Arne Laksaa & Michael Floater, SI, 91-07\n*                 Use pintdat directly as input. Fetch pretop info.\n* REWRITTEN BY : UJK, SI, 93-01\n*                Exact curve treatment.\n*********************************************************************\n*/\n{\n  int kstat;\t\t\t/* Local status                                */\n  int kpos = 0;\t\t\t/* Position of error.                          */\n  int ki, kj, kk;\t\t/* Counters.                                   */\n  int kpoint;\t\t\t/* Number of points in an intersection list.   */\n  int ktype;\t\t\t/* Kind of intersection curve. (See SISLIntcurve). */\n  int kpt;\t\t\t/* Used to find number of single intersection points.*/\n  int index;\t\t\t/* Array index for next point at start        */\n  int sing_1, sing_2;\t\t/* Sing point flag at start and end           */\n  double *spar1, *spar2;\t/* Values of points belonging to an intersection\n\t\t\t\t     curve in the parameter area of the objects\n\t\t\t\t     involved in the intersection.                 */\n  double *stpar1, *stpar2, *stpar3;\t/* Pointers used to travers arrays\n\t\t\t\t           containing parameter values.        */\n  int *top1;\t                /* Pointers used to travers pretop. */\n  SISLIntcurve **ucrv;\t\t/* Pointer used to traverse *wcrv array.     */\n  SISLIntsurf **usurf;\t\t/* Pointer used to traverse *wsurf array.    */\n  SISLIntpt *qpt;\t\t/* Pointer to an intersection point.         */\n  SISLIntpt *qprev;\t\t/* Pointer to an intersection point.         */\n  SISLIntpt *qnext;\t\t/* Pointer to an intersection point.         */\n  SISLIntpt *qpfirst;\t\t/* Pointer to first intersection point.      */\n  SISLIntpt *qplast;\t\t/* Pointer to last intersection point.       */\n\n  int jpt = pintdat->ipoint;\n  SISLIntpt **vpoint = pintdat->vpoint;\n  int jlist = pintdat->ilist;\n  SISLIntlist **vlist = pintdat->vlist;\n  SISLObject *qo2 = SISL_NULL;\n  int kdir,kdir1=-1,kdir2=-1;\n  int exact=FALSE, exact_treat=FALSE;\n  int log_test = 0;\n  double dummy;\n  /* ------------------------------------------------------------------ */\n\n  for (ki = 1; ki < 5; ki++)\n     log_test |= 1 << ki;\n\n  if (po1->iobj == SISLSURFACE && ideg != 0)\n  {\n     /* Surf vs Implicit geometry */\n     qo2 = newObject (SISLPOINT);\n     exact_treat = TRUE;\n  }\n  else  if (po1->iobj == SISLSURFACE &&\n\t    po2->iobj == SISLSURFACE &&\n\t    ideg ==0)\n  {\n     /* Surf vs Implicit geometry */\n     qo2 = po2;\n     exact_treat = TRUE;\n  }\n\n\n  /* Initiate output.  */\n\n  *gpar1 = *gpar2 = SISL_NULL;\n  *wcrv = SISL_NULL;\n  *wsurf = SISL_NULL;\n\n  *jcrv = 0;\n  *jsurf = 0;\n\n  /* Allocate space for intersection curve and surface array.  */\n\n  *wcrv = newarray (jlist, SISLIntcurve *);\n  if (jlist > 0 && *wcrv == SISL_NULL)\n    goto err101;\n  *wsurf = newarray (jlist, SISLIntsurf *);\n  if (jlist > 0 && *wcrv == SISL_NULL)\n    goto err101;\n\n  /* Transfer curve-information from vlist array to wcrv and wsurf arrais. */\n\n  ucrv  = *wcrv;\n  usurf = *wsurf;\n\n  for (kpt = ki = 0; ki < jlist; ki++)\n  {\n     qpfirst = qpt = (*vlist)->pfirst;\n     qplast = (*vlist)->plast;\n     index = (*vlist)->ind_first;\n     kpoint = (*vlist)->inumb;\n     if (kpoint == 0)\n\tgoto err137;\n\n     if (qpfirst->iinter == SI_TRIM && qpfirst == qplast)\n     {\n\t/* Create new intersection surf.  */\n\n\t*usurf = newIntsurf(*vlist);\n\tif (*usurf == SISL_NULL)\n\t   goto err101;\n\n\t/* Copy pretopology\n\t   memcopy((*usurf)->pretop,(*vlist)->pretop,4,int); */\n\n\tkpt += kpoint-1;\n\tusurf++;\n\t(*jsurf)++;\n     }\n     else\n     {\n\tif (qpfirst->iinter == SI_SING ||\n\t    (sh6nmbmain (qpfirst,&kstat)) > 2)\n\t   sing_1 = TRUE;\n\telse\n\t   sing_1 = FALSE;\n\n\tif (qplast->iinter == SI_SING ||\n\t    (sh6nmbmain (qplast,&kstat)) > 2)\n\t   sing_2 = TRUE;\n\telse\n\t   sing_2 = FALSE;\n\n\n\t/* Allocate space for arrays containing parameter values of points\n\t   in intersection curves.                                          */\n\n\tspar1 = newarray (ipar1 * kpoint, double);\n\tspar2 = newarray (ipar2 * kpoint, double);\n\tif ((ipar1 > 0 && spar1 == SISL_NULL) ||\n\t    (ipar2 > 0 && spar2 == SISL_NULL))\n\t   goto err101;\n\n\t/* Collect parameter values of the points in this intersection list\n\t   and distribute values to the objects in the intersection.         */\n\n\tkj = 0;\n\tstpar1 = spar1;\n\tstpar2 = spar2;\n\twhile (qpt != SISL_NULL && kj < kpoint)\n\t{\n\t   stpar3 = qpt->epar;\n\t   for (kk = 0; kk < ipar1; kk++)\n\t      *(stpar1++) = *(stpar3++);\n\t   for (kk = 0; kk < ipar2; kk++)\n\t      *(stpar2++) = *(stpar3++);\n\n\t   /* Reduce no of single points */\n\t   if (qpt->marker != -99)\n\t   {\n\t      kpt++;\n\n\t      /* Flag point */\n\t      qpt->marker = -99;\n\t   }\n\t   if (qpt == qpfirst)\n\t   {\n\t      qprev = qpt;\n\t      qpt = qpt->pnext[index];\n\t   }\n\t   else\n\t   {\n\t      sh6getother (qpt, qprev, &qnext, &kstat);\n\t      qprev = qpt;\n\t      qpt = qnext;\n\t   }\n\t   kj++;\n\t}\n\n\t/* Find type of intersection curve.  */\n\n\tif (sing_1 && sing_2)\n\t   /* Both ends junction */\n\t   ktype = 7;\n\telse if (qpfirst == qplast)\n\t   /* Closed curve, not singular */\n\t   ktype = 2;\n\telse if (sing_1)\n\t   /* Junction at start */\n\t   ktype = 5;\n\telse if (sing_2)\n\t   /* Junction at end */\n\t   ktype = 6;\n\telse\n\t   /* Open and clean */\n\t   ktype = 4;\n\n\n\texact = FALSE;\n\t/* UJK, March 1995, when curve type is 9 and the curve is\n\t   an iso-line in both surfaces, we want to return both\n\t   ppar1 and ppar2. The logic is simple:\n\t   kdir1 > -1 (ie eq 0 or 1) means constant in 1. surf.\n\t   kdir2 > -1 (ie eq 2 or 3) means constant in 2. surf. \n\t   The object space curve pgeom is picked from the 1. surf\n\t   if kdir1 is set and from 2. surf if only kdir2 is set. */\n\t\n\t/* UJK, January 1993, if exact curve mark it with type 9. */\n\tkdir1 = kdir2 = -1;\n\tif (exact_treat &&\n\t    kj == 2 &&\n\t    (qpfirst->curve_dir[(*vlist)->ind_first] & log_test))\n\t{\n\t   /* Constant parameter curve */\n\t   for (kdir = 0; kdir < qpfirst->ipar; kdir++)\n\t      if (qpfirst->curve_dir[(*vlist)->ind_first] &\n\t\t  (1 << (kdir + 1)))\n\t      {\n\t\t exact = TRUE;\n\t\t ktype = 9;\n\t\t if (kdir >= po1->iobj) kdir2 = kdir;\n\t\t else                   kdir1 = kdir;\n\t      }\n\t}\n\t\n\tif (kdir1>-1) kdir = kdir1;\n\telse          kdir = kdir2;\n\t\n\t/* Create new intersection curve.  */\n\t*ucrv = newIntcurve (kj, ipar1, ipar2, spar1, spar2, ktype);\n\tif (*ucrv == SISL_NULL)\n\t   goto err101;\n\t\n\t/* Copy pretopology */\n\tmemcopy((*ucrv)->pretop,(*vlist)->pretop,4,int);\n\t\n\t\n\t/* UJK, January 1993, if exact curve mark it with type 9. */\n\tif (exact)\n\t{\n\t   \n\t   pick_crv_sf (po1, qo2, kdir, qpfirst, \n\t\t\tqplast, &(*ucrv)->pgeom, &kstat);\n\t   if (kstat < 0)\n\t      goto error;\n\t   \n\t   /* UJK, Pick 2D line  */\n\t   \n\t   if (kdir2 >= po1->iobj)\n\t   {\n\t      s1602(&(qpfirst->epar[po1->iobj]),\n\t\t    &(qplast->epar[po1->iobj]),\n\t\t    2,\n\t\t    2,\n\t\t    (*ucrv)->pgeom->et[(*ucrv)->pgeom->ik - 1],\n\t\t    &dummy,\n\t\t    &(*ucrv)->ppar2,\n\t\t    &kstat);\n\t      if (kstat < 0) goto error;\n\t   }\n\t   \n\t   if (kdir1 >= 0)\n\t   {\n\t      s1602(qpfirst->epar,\n\t\t    qplast->epar,\n\t\t    2,\n\t\t    2,\n\t\t    (*ucrv)->pgeom->et[(*ucrv)->pgeom->ik - 1],\n\t\t    &dummy,\n\t\t    &(*ucrv)->ppar1,\n\t\t    &kstat);\n\t      \n\t      if (kstat < 0) goto error;\n\t   }\n\t   \n\t}\n\t\n\t\n\tucrv++;\n\t(*jcrv)++;\n     }\n     vlist++;\n  }\n\n  /* Find number of single intersection points.  */\n\n  kpt = jpt - kpt;\n  if (kpt < 0) goto err137;\n\n  /* Create arrays to keep parameter values of intersection points.  */\n\n  *gpar1 = newarray (ipar1 * kpt, double);\n  *gpar2 = newarray (ipar2 * kpt, double);\n  *pretop = newarray (4 * kpt, int);\n  if ((ipar1 * kpt > 0 && *gpar1 == SISL_NULL)\n      || (ipar2 * kpt > 0 && *gpar2 == SISL_NULL)\n      || (4 * kpt > 0 && *pretop == SISL_NULL))\n    goto err101;\n\n  /* Copy parameters of single intersection points into output-arrays. */\n\n  kj = 0;\n  stpar1 = *gpar1;\n  stpar2 = *gpar2;\n  top1 = *pretop;\n  for (ki = 0; ki < jpt; ki++)\n    {\n      qpt = *vpoint;\n      if (qpt != SISL_NULL)\n\t{\n\t  if (sh6ismain(qpt) && qpt->marker != -99)\n\t    {\n\t      kj++;\n\t      stpar3 = qpt->epar;\n\t      for (kk = 0; kk < ipar1; kk++)\n\t\t*(stpar1++) = *(stpar3++);\n\t      for (kk = 0; kk < ipar2; kk++)\n\t\t*(stpar2++) = *(stpar3++);\n              *(top1++) = qpt->left_obj_1[0];\n              *(top1++) = qpt->right_obj_1[0];\n              *(top1++) = qpt->left_obj_2[0];\n              *(top1++) = qpt->right_obj_2[0];\n\t    }\n\t}\n\n      vpoint++;\n    }\n\n  *jpar = kj;\n\n  /* Adjust output arrays to correct length.  */\n\n  if ((*jcrv) < jlist)\n  {\n     if ((*jcrv) > 0)\n     {\n        if (((*wcrv) = increasearray (*wcrv, *jcrv, SISLIntcurve *)) == SISL_NULL)\n           goto err101;\n     }\n     else\n     {\n        if (*wcrv != SISL_NULL)\n\tfreearray (*wcrv);\n        *wcrv = SISL_NULL;\n     }\n  }\n  if ((*jsurf) < jlist)\n  {\n     if ((*jsurf) > 0)\n     {\n        if (((*wsurf) = increasearray (*wsurf, *jsurf, SISLIntsurf *)) == SISL_NULL)\n           goto err101;\n     }\n     else\n     {\n        if (*wsurf != SISL_NULL)\n\tfreearray (*wsurf);\n        *wsurf = SISL_NULL;\n     }\n  }\n  if (kj * ipar1 > 0)\n    {\n      if ((*gpar1 = increasearray (*gpar1, kj * ipar1, double)) == SISL_NULL)\n\tgoto err101;\n    }\n  else\n    {\n      if (*gpar1 != SISL_NULL)\n\tfreearray (*gpar1);\n      *gpar1 = SISL_NULL;\n    }\n  if (kj * ipar2 > 0)\n    {\n      if ((*gpar2 = increasearray (*gpar2, kj * ipar2, double)) == SISL_NULL)\n\tgoto err101;\n    }\n  else\n    {\n      if (*gpar2 != SISL_NULL)\n\tfreearray (*gpar2);\n      *gpar2 = SISL_NULL;\n    }\n  if (kj  > 0)\n    {\n      if ((*pretop= increasearray (*pretop, kj * 4, int)) == SISL_NULL)\n\tgoto err101;\n    }\n  else\n    {\n      if (*pretop != SISL_NULL)\n\tfreearray (*pretop);\n      *pretop = SISL_NULL;\n    }\n\n  /* Intersections copied to output format.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\nerr101:*jstat = -101;\n  s6err (\"hp_s1880\", *jstat, kpos);\n  goto out;\n\n  /* Error in data-strucuture. Expected intersection point not found. */\n\nerr137:*jstat = -137;\n  s6err (\"hp_s1880\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine. */\nerror:\n  *jstat = kstat;\n  s6err (\"hp_s1880\", *jstat, kpos);\n  goto out;\n\n\nout:\n   if (po1->iobj == SISLSURFACE && ideg != 0)\n      freeObject (qo2);\nreturn;\n}\n"
  },
  {
    "path": "src/intjoinper.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: intjoinper.c,v 1.4 2001-03-19 16:13:07 afr Exp $\n *\n */\n\n\n#define INT_JOIN_PER\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n    int_join_per (SISLIntdat ** pintdat,\n\t    SISLObject * po1,\n\t    SISLObject * po2,\n\t    double eimpli[],\n\t    int ideg,\n\t    double aepsge,\n\t    int *jstat)\n\n#else\nvoid\n   int_join_per (pintdat,\n\t    po1,\n\t    po2,\n\t    eimpli,\n\t    ideg,\n\t    aepsge,\n\t    jstat)\n\n     SISLIntdat **pintdat;\n     SISLObject *po1;\n     SISLObject *po2;\n     double eimpli[];\n     int ideg;\n     double aepsge;\n     int *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To join intersection curves based on object space data only.\n*              Curves are joined if they are G1 object space.\n*              Single point with same object space posisition are\n*              made to one point.\n*\n*\n* INPUT      : pintdat     - Pointer to pointer to the SISLIntdat data.\n*              po1         - Pointer surface object.\n*              po2         - Pointer surface object.\n*              eimpli      - Array containing descr. of implicit surf\n*\t       ideg        - Type of impl surf.\n              ang_tol     - Angle control tolerance ie ??\n*              aepsge      - Absolute tolerance\n*\n*\n* OUTPUT     :  jstat  - status messages\n*                       = ?      : ?\n*                       = 0      : ok\n*                       < 0      : error\n*\n*\n* METHOD     :\n*\n* USE        : The function is only working i 3-D\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, Oslo, Norway, July-1990\n*\n*********************************************************************\n*/\n{\n  int kstat;\t\t\t/* Local status variable.          */\n  int kpos = 0;\t\t\t/* Position of error.              */\n  int ki=0, kj=0;\t\t        /* Counter                         */\n  SISLIntpt *pcurr;\t\t/* to traverse list of points.     */\n  SISLIntpt *pnext;\t        /* to traverse list of points.     */\n  SISLIntpt *pother;\t/* to traverse list of points.     */\n  int logtest=0;                /* used for constant crv test      */\n\n  SISLIntpt *pfirst_1;\t\t/* First point in a list, periodicity     */\n  SISLIntpt *pfirst_2;\t\t/* First point in a list, periodicity     */\n  SISLIntpt *plast_1;\t\t/* Last point in a list, periodicity      */\n  SISLIntpt *plast_2;\t\t/* Last point in a list, periodicity      */\n  double *curve_val_3d  = SISL_NULL; /* Pos, tang and curvature ,3d    */\n  double *curve_val_2d_1= SISL_NULL; /* Pos, tang and curvature ,2d    */\n  double *curve_val_2d_2= SISL_NULL; /* Pos, tang and curvature ,2d    */\n  double delta_par[4];          /* Delta vector in par space, periodicity */\n  double *delta_1=delta_par;    /* Delta vector in par space, periodicity */\n  double *delta_2=delta_par+2;  /* Delta vector in par space, periodicity */\n  double dot;                   /* Scalar product, periodicity            */\n  double dist;                  /* Distance in 3D, periodicity            */\n  double dist_a;                /* Distance in 3D, periodicity            */\n  double dist_b;                /* Distance in 3D, periodicity            */\n  double dist_c;                /* Distance in 3D, periodicity            */\n  double dist_d;                /* Distance in 3D, periodicity            */\n  double ang;                   /* Angel between tangents, periodicity    */\n  int dimobj;                   /* Dimension 3, periodicity               */\n  //int dim2=2;                   /* Dimension 2, periodicity               */\n  int join=TRUE;                /* Flag to kill int point, periodicity    */\n  int const_crv_1;              /* Constant parameter direction           */\n  int const_crv_2;              /* Constant parameter direction           */\n  int same_curve;               /* Flag                                   */\n  int no_of_main;               /* No of mainpts connected to curr pt     */\n  int treat_2d;                 /* Flag, shifting of parameter values is \n\t\t\t\t   only done in surf/surf cases.          */\n  int cas;                      /* Flag, surf surf, surf analytic, other. */ \n  double epar[2];\n  double *nullp = SISL_NULL;\n  SISLIntpt *pturn=SISL_NULL;\t/* Last point in a list, periodicity      */\n  int log_1, log_2;             /* To test on an edge curve lies along\n\t\t\t\t   the same parameter direction.          */\n  int kp,no_par,index_1;\n  double min_par[4],max_par[4],legal_min[4],legal_max[4];\n  SISLObject *qo=SISL_NULL;\n  /* -------------------------------------------------------------------- */ \n       \n  /* If we do not have any intersection data we just return. */     \n  \n  if ((*pintdat) == SISL_NULL)\n     goto out;\n  if ((*pintdat)->ipoint <=1)\n     goto out;\n  \n  \n  if      (po1->iobj == SISLSURFACE) dimobj = po1->s1->idim;\n  else if (po1->iobj == SISLCURVE)   dimobj = po1->c1->idim;\n  else goto errinp;\n  \n  /* UJK, 13.08.93 : Check periodicity flag.*/\n  no_par = (*pintdat)->vpoint[0]->ipar;\n  if (no_par > 4) goto errinp;\n  \n  for (kp=0;kp<4;kp++)\n  {\n     legal_min[kp] = -HUGE;\n     legal_max[kp] =  HUGE;\n  }\n  \n  for (ki=0,qo=po1,index_1=0;ki<2;ki++,qo=po2)\n     if (qo)\n     {\n\tif (qo->iobj == SISLSURFACE) \n\t{\n\t   if (qo->s1->cuopen_1 != SISL_SURF_PERIODIC)\n\t   {\n\t      legal_min[index_1] = qo->s1->et1[qo->s1->ik1-1];\n\t      legal_max[index_1] = qo->s1->et1[qo->s1->in1];\n\t   }\n\t   \n\t   index_1++;\n\t   if (qo->s1->cuopen_2 != SISL_SURF_PERIODIC)\n\t   {\n\t      legal_min[index_1] = qo->s1->et2[qo->s1->ik2-1];\n\t      legal_max[index_1] = qo->s1->et2[qo->s1->in2];\n\t   }\n\t   index_1++;\n\t}\n\telse if (qo->iobj == SISLCURVE) \n\t{\n\t   if (qo->c1->cuopen != SISL_CRV_PERIODIC)\n\t   {\n\t      legal_min[index_1] = qo->c1->et[qo->c1->ik-1];\n\t      legal_max[index_1] = qo->c1->et[qo->c1->in];\n\t   }\n\t   index_1++;\n\t}\n     }\n  \n  \n  /*________________________________________ */\n  /* UJK, TESTING !!!!!!!!!!!!!!!!!!! For the moment: */\n  if      (dimobj == 3 && po2->iobj == SISLPOINT) goto out;\n  /*________________________________________ */\n  \n  if (po1->iobj == SISLSURFACE && \n      po2->iobj == SISLSURFACE &&  ideg == 0)\n     /* Two B-spline surf's in 3D. */\n     cas = 1;\n  else if (po1->iobj == SISLSURFACE && ideg != 2000 && ideg !=0) \n     /* B-spline surf vs analytic. */\n     cas = 2;\n  else \n     cas = 0;\n  \n  \n  \n  if (ideg != 2000 && po1->iobj == SISLSURFACE) treat_2d = TRUE;\n  else treat_2d = FALSE;\n  \n  for (ki=1;ki<5;ki++) logtest |= 1<< ki;\n  \n  /* Ensure that object space information is in place. */\n  for (kj = 0; kj < (*pintdat)->ipoint; kj++)\n  {\n     pcurr = (*pintdat)->vpoint[kj];\n     sh6evalint (po1, po2, eimpli, ideg, pcurr, aepsge,\n\t\t &curve_val_3d, &curve_val_2d_1,\n\t\t &curve_val_2d_2, &kstat);\n     if (kstat < 0)\n\tgoto error;\n  }\n  \n  /* Check direction for const_crvs. */\n  if (cas)\n     for (ki = 0; ki < (*pintdat)->ilist; ki++)\n     {\n\tpfirst_1 = (*pintdat)->vlist[ki]->pfirst;\n\tplast_1  = (*pintdat)->vlist[ki]->plast;\n\t\n\tif(((*pintdat)->vlist[ki]->inumb == 2) &&\n\t   (pfirst_1->curve_dir[(*pintdat)->vlist[ki]->ind_first] & logtest))\n\t{\n\t   if (cas == 1)\n\t   {\n\t   }\n\t   else /*if (cas == 2)*/\n\t   {\n\t      /* Select midpoint. */\n\t      epar[0] = (pfirst_1->epar[0] + plast_1->epar[0])/2.0;\n\t      epar[1] = (pfirst_1->epar[1] + plast_1->epar[1])/2.0;\n\t      pturn = hp_newIntpt (2, epar, DZERO, SI_ORD,\n\t\t\t\t   SI_UNDEF, SI_UNDEF, SI_UNDEF, SI_UNDEF,\n\t\t\t\t   0, 0, nullp, nullp);\n\t      if (pturn == SISL_NULL)\n\t\t goto err101;\n\t      \n\t      sh6evalint (po1, po2, eimpli, ideg, pturn, aepsge,\n\t\t\t  &curve_val_3d, &curve_val_2d_1,\n\t\t\t  &curve_val_2d_2, &kstat);\n\t      if (kstat < 0)\n\t\t goto error;\n\t      \n\t      if (pturn->iinter == SI_ORD)\n\t      {\n\t\t double dot;\n\t\t dot = (plast_1->epar[0]-pfirst_1->epar[0])*curve_val_2d_1[2]+\n\t\t    (plast_1->epar[1]-pfirst_1->epar[1])*curve_val_2d_1[3];\n\t\t if (dot < 0) \n\t\t {\n\t\t    /* Turn direction. */\n\t\t    int ind_1, ind_2, dir_1, dir_2;\n\t\t    \n\t\t    ind_1    = (*pintdat)->vlist[ki]->ind_first;\n\t\t    ind_2    = (*pintdat)->vlist[ki]->ind_last;\n\t\t    dir_1    = pfirst_1->curve_dir[ind_1];\n\t\t    dir_2    = plast_1->curve_dir[ind_2];\n\t\t    \n\t\t    (*pintdat)->vlist[ki]->pfirst = plast_1;\n\t\t    (*pintdat)->vlist[ki]->plast  = pfirst_1;\n\t\t    (*pintdat)->vlist[ki]->ind_first = ind_2;\n\t\t    (*pintdat)->vlist[ki]->ind_last  = ind_1;\n\t\t    pfirst_1->curve_dir[ind_1] = dir_2;\n\t\t    plast_1->curve_dir[ind_2]  = dir_1;\n\t\t    \n\t\t }\n\t      }\t\t \n\t      if (pturn) freeIntpt(pturn);\n\t      pturn = SISL_NULL;\n\t      \n\t   }\n\t}\n     }\n  \n  /* Traverse the lists to remove doubly represented curves along\n     periodic edges.     */\n  \n  for (ki = 0; ki < (*pintdat)->ilist; ki++)\n  {\n     pfirst_1 = (*pintdat)->vlist[ki]->pfirst;\n     plast_1  = (*pintdat)->vlist[ki]->plast;\n     \n     if(((*pintdat)->vlist[ki]->inumb == 2) &&\n\t(pfirst_1->curve_dir[(*pintdat)->vlist[ki]->ind_first] & logtest))\n\tconst_crv_1 = TRUE;\n     else \n\tconst_crv_1 = FALSE;\n     \n     \n     if (pfirst_1 == plast_1) continue;\n     \n     for (kj = 0; kj < (*pintdat)->ilist; kj++)\n     {\n\t\n\tsame_curve = (ki == kj); \n\tpfirst_2 = (*pintdat)->vlist[kj]->pfirst;\n\tplast_2 = (*pintdat)->vlist[kj]->plast;\n\t\n\tif(((*pintdat)->vlist[kj]->inumb == 2) &&\n\t   (pfirst_2->curve_dir[(*pintdat)->vlist[kj]->ind_first] & logtest))\n\t   const_crv_2 = TRUE;\n\telse \n\t   const_crv_2 = FALSE;\n\t\n\t/* To treat the case when two curves are on an periodic edge */\n\tif (const_crv_1 && const_crv_2 && !same_curve)\n\t{\n\t   log_1 = pfirst_1->curve_dir[(*pintdat)->vlist[ki]->ind_first];\n\t   log_1 = log_1>>1;\n\t   log_1 &= 15;\n\t   log_2 = pfirst_2->curve_dir[(*pintdat)->vlist[kj]->ind_first];\n\t   log_2 = log_2>>1;\n\t   log_2 &= 15;\n\t   \n\t   if (log_1 & log_2)\n\t   {\n\t      dist_a = s6dist(plast_1->geo_track_3d,\n\t\t\t      pfirst_2->geo_track_3d,\n\t\t\t      dimobj);\n\t      dist_b = s6dist(plast_1->geo_track_3d,\n\t\t\t      plast_2->geo_track_3d,\n\t\t\t      dimobj);\n\t      dist_c = s6dist(pfirst_1->geo_track_3d,\n\t\t\t      pfirst_2->geo_track_3d,\n\t\t\t      dimobj);\n\t      dist_d = s6dist(pfirst_1->geo_track_3d,\n\t\t\t      plast_2->geo_track_3d,\n\t\t\t      dimobj);\n\t      if ((dist_a <aepsge && dist_d < aepsge) ||\t\n\t\t  (dist_b <aepsge && dist_c < aepsge)\t)\n\t      {\n\t\t /* Kill the two points */\n\t\t sh6idkpt(pintdat, &pfirst_2, join=FALSE, &kstat);\n\t\t if (kstat < 0) goto error;\n\t\t \n\t\t sh6idkpt(pintdat, &plast_2, join=FALSE, &kstat);\n\t\t if (kstat < 0) goto error;\n\t\t \n\t\t /* Remove the curve list kj, and pack vlist array */\n\t\t freeIntlist ((*pintdat)->vlist[kj]);\n\t\t (*pintdat)->ilist--;\n\t\t (*pintdat)->vlist[kj] =\n\t\t    (*pintdat)->vlist[(*pintdat)->ilist];\n\t\t \n\t\t /* Reset to start */\n\t\t ki = -1;\n\t\t break; /* kj loop */\n\t      }\n\t      \n\t   }\n\t}\n     }\n  }\n  \n  for (ki = 0; ki < (*pintdat)->ilist; ki++)\n  {\n     pfirst_1 = (*pintdat)->vlist[ki]->pfirst;\n     plast_1  = (*pintdat)->vlist[ki]->plast;\n     \n     if(((*pintdat)->vlist[ki]->inumb == 2) &&\n\t(pfirst_1->curve_dir[(*pintdat)->vlist[ki]->ind_first] & logtest))\n\tconst_crv_1 = TRUE;\n     else \n\tconst_crv_1 = FALSE;\n     \n     \n     if (pfirst_1 == plast_1) continue;\n     \n     for (kj = 0; kj < (*pintdat)->ilist; kj++)\n     {\n\t\n\tsame_curve = (ki == kj); \n\tpfirst_2 = (*pintdat)->vlist[kj]->pfirst;\n\tplast_2 = (*pintdat)->vlist[kj]->plast;\n\t\n\tif(((*pintdat)->vlist[kj]->inumb == 2) &&\n\t   (pfirst_2->curve_dir[(*pintdat)->vlist[kj]->ind_first] & logtest))\n\t   const_crv_2 = TRUE;\n\telse \n\t   const_crv_2 = FALSE;\n\t\n\t/* Joining of curves */\n\tif (plast_1 == pfirst_2 ||\n\t    plast_1->iinter == SI_TRIM ||\n\t    plast_1->iinter == SI_SING ||\n\t    plast_1->iinter == SI_TOUCH ||\n\t    pfirst_2->iinter == SI_TRIM ||\n\t    pfirst_2->iinter == SI_SING ||\n\t    pfirst_2->iinter == SI_TOUCH)\n\t{\n\t   /* Test on edge ? */\n\t   continue;\n\t}\n\telse\n\t{\n\t   dist = s6dist(plast_1->geo_track_3d,\n\t\t\t pfirst_2->geo_track_3d,\n\t\t\t dimobj);\n\t   ang  = s6ang(plast_1->geo_track_3d + dimobj,\n\t\t\tpfirst_2->geo_track_3d + dimobj,\n\t\t\tdimobj);\n\t   dot  = s6scpr(plast_1->geo_track_3d + dimobj,\n\t\t\t pfirst_2->geo_track_3d + dimobj,\n\t\t\t dimobj);\n\t   \n\t   if (dist < aepsge &&\n\t       dot  > 0      &&\n\t       ang  < ANGULAR_TOLERANCE)\n\t   { \n\t      /* HIT, Join the two lists of curves */\n\t      if (same_curve)\n\t      {\n\t\t /*sh6connect(pfirst_1, plast_1, &kstat);\n\t\t    if (kstat != 0) goto error;\n\t\t    sh6idkpt (pintdat, &plast_1, join=TRUE, &kstat);\n\t\t    if (kstat < 0) goto error;\n\t\t    \n\t\t    (*pintdat)->vlist[ki]->inumb -= 1; \n\t\t    \n\t\t    periodic set to true ! \n\t\t    \n\t\t    (*pintdat)->vlist[ki]->plast = \n\t\t    pfirst_1; */\n\t      }\n\t      else\n\t      {\n\t\t /* Move 2D values of second part */\n\t\t s6diff(plast_1->epar,\n\t\t\tpfirst_2->epar,\n\t\t\tno_par,\n\t\t\tdelta_par);\n\t\t \n\t\t /* Last check to see if we move outside legal area */\n\t\t for(kp=0;kp<no_par;kp++)\n\t\t {\n\t\t    min_par[kp] = HUGE;\n\t\t    max_par[kp] = -HUGE;\n\t\t }\n\t\t \n\t\t pcurr = pfirst_2;\n\t\t pnext = pfirst_2->pnext[(*pintdat)->vlist[kj]->ind_first];\n\t\t while (pcurr != plast_2 && pcurr && pnext)\n\t\t {\n\t\t    for(kp=0;kp<no_par;kp++)\n\t\t    {\n\t\t       min_par[kp] = min(pnext->epar[kp]+delta_par[kp],min_par[kp]);\n\t\t       max_par[kp] = max(pnext->epar[kp]+delta_par[kp],max_par[kp]);\n\t\t    }\n\t\t    \n\t\t    sh6getother (pnext, pcurr, &pother, &kstat);\n\t\t    if (kstat && pnext != plast_2) goto errinconsist;\n\t\t    pcurr = pnext;\n\t\t    pnext = pother;\n\t\t }\t\t     \n\t\t \n\t\t for(kp=0;kp<no_par;kp++)\n\t\t {\n\t\t    if (min_par[kp] < legal_min[kp] && \n\t\t\tDNEQUAL(min_par[kp],legal_min[kp])) break;\n\t\t    if (max_par[kp] > legal_max[kp] && \n\t\t\tDNEQUAL(max_par[kp],legal_max[kp])) break;\n\t\t    \n\t\t }\n\t\t \n\t\t \n\t\t /* _______________________ */\n\t\t if (kp == no_par)\n\t\t {\n\t\t    pcurr = pfirst_2;\n\t\t    pnext = pfirst_2->pnext[(*pintdat)->vlist[kj]->ind_first];\n\t\t    while (pcurr != plast_2 && pcurr && pnext)\n\t\t    {\n\t\t       for(kp=0;kp<no_par;kp++)\n\t\t\t  pnext->epar[kp] += delta_par[kp];\n\t\t       \n\t\t       if (treat_2d)\n\t\t       {\n\t\t\t  pnext->geo_track_2d_1[0] += delta_1[0];\n\t\t\t  pnext->geo_track_2d_1[1] += delta_1[1];\n\t\t\t  if (cas==1)\n\t\t\t  {\n\t\t\t     pnext->geo_track_2d_2[0] += delta_2[0];\n\t\t\t     pnext->geo_track_2d_2[1] += delta_2[1];\n\t\t\t  }\n\t\t       }\n\t\t       sh6getother (pnext, pcurr, &pother, &kstat);\n\t\t       if (kstat && pnext != plast_2) goto errinconsist;\n\t\t       pcurr = pnext;\n\t\t       pnext = pother;\n\t\t    }\t\t     \n\t\t \n\t\t sh6connect(plast_1, pfirst_2, &kstat);\n\t\t if (kstat != 0) goto error;\n\t\t sh6idkpt (pintdat, &pfirst_2, join=TRUE, &kstat);\n\t\t if (kstat < 0) goto error;\n\t\t \n\t\t if (const_crv_1 && const_crv_2)\n\t\t {\n\t\t    sh6idkpt (pintdat, &plast_1, join=TRUE, &kstat);\n\t\t    if (kstat < 0) goto error;\n\t\t    \n\t\t    sh6getlist(pfirst_1,plast_2,\n\t\t\t       &((*pintdat)->vlist[ki]->ind_first),\n\t\t\t       &((*pintdat)->vlist[ki]->ind_last),\n\t\t\t       &kstat);\n\t\t    kpos = 111;\n\t\t    if (kstat != 0) goto errinconsist;\n\t\t    (*pintdat)->vlist[ki]->inumb = 2; \n\t\t    \n\t\t    (*pintdat)->vlist[ki]->plast = \n\t\t       plast_2;\n\t\t    \n\t\t }\n\t\t else \n\t\t {\n\t\t    \n\t\t    (*pintdat)->vlist[ki]->inumb += \n\t\t       (*pintdat)->vlist[kj]->inumb -1;\n\t\t    \n\t\t    (*pintdat)->vlist[ki]->plast = \n\t\t       plast_2;\n\t\t    (*pintdat)->vlist[ki]->ind_last = \n\t\t       (*pintdat)->vlist[kj]->ind_last;\n\t\t }\n\t\t \n\t\t /* Remove the curve list kj, and pack vlist array */\n\t\t freeIntlist ((*pintdat)->vlist[kj]);\n\t\t (*pintdat)->ilist--;\n\t\t (*pintdat)->vlist[kj] =\n\t\t    (*pintdat)->vlist[(*pintdat)->ilist];\n\t\t \n\t\t \n\t\t /* Reset to start */\n\t\t ki = -1;\n\t\t break; /* kj loop */\n\t\t }\n\t      } /* End of else not same curve */\n\t      \n\t   } /* if hit */\n\t   \n\t} /* else */\n     } /* kj */\n  } /* ki */\n  \n  \n  /* Treat single points */\n  for (ki = 0; ki < (*pintdat)->ipoint; ki++)\n  {\n     kstat = 0;\n     pcurr = (*pintdat)->vpoint[ki];\n     if (sh6ismain(pcurr)) no_of_main = sh6nmbmain(pcurr, &kstat);\n     else no_of_main = -1;\n     if (kstat < 0) goto error;\n     \n     if (no_of_main == 0)\t\t  \n\tfor (kj = 0; kj < (*pintdat)->ipoint; kj++)\n\t{\n\t   pother = (*pintdat)->vpoint[kj];\n\t   if (sh6ismain(pother) && pother != pcurr)\n\t   {\n\t      dist = s6dist(pcurr->geo_track_3d,\n\t\t\t    pother->geo_track_3d,\n\t\t\t    dimobj);\n\t      if (dist < aepsge)\n\t      {\n\t\t sh6idkpt(pintdat, &pcurr, join = FALSE, &kstat);\n\t\t if (kstat < 0) goto error;\n\t\t ki--; /* New point in array place no ki, redo the job */\n\t\t break; /* kj loop */\n\t      }\n\t   }\n\t}\n  }\n  \n  \n  \n  *jstat = 0;\n  goto out;\n\n  /* _________________________ EXIT ____________________________ */\n  /* Error in alloc */\nerr101:\n  *jstat = -101;\n  s6err (\"int_join_per\", *jstat, kpos);\n  goto out;\n\n  /* Error inconsistency */\nerrinconsist:\n  *jstat = -500;\n  s6err (\"int_join_per\", *jstat, kpos);\n  goto out;\n\n  /* Error in input */\nerrinp:\n     *jstat = -200;\n  s6err (\"int_join_per\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level function */\nerror:\n     *jstat = kstat;\n  s6err (\"int_join_per\", *jstat, kpos);\n  goto out;\n\nout:\n  ;\n}\n"
  },
  {
    "path": "src/make3D.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: make3D.c,v 1.3 2001-03-19 16:13:07 afr Exp $\n *\n */\n\n\n#define MAKE3D\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n    make3D (SISLSurf *ps, SISLSurf **rsnew, int *jstat)\n#else\nvoid \n   make3D (ps, rsnew, jstat)\n     SISLSurf *ps;\n     SISLSurf **rsnew;\n     int *jstat;\n#endif\n/*\n********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To convert a 1D surface to a 3D representation.\n*\n*\n*\n* INPUT      : ps\t- 1D Surface.\n*\n*\n*\n* OUTPUT     : rsnew\t- The 3D surface.\n*              jstat\t- status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : We want to change f(u,v) ----> (u,v,f(u,v)).\n*              Using marsdens identity on u and v will do the job.\n*              (In fact the u and v are translated to origin and scaled.)\n*\n*\n* REFERENCES :\n*\n*-\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 10.94.\n* Revised by : \n*\n**********************************************************************/\n{\n  \n  int kk1,kk2,kn1,kn2;  /* Orders and numbers of vertices              */\n  double *st1,*st2,*scoef; /* Knots and vertices of input surface      */\n  double *s3coef=SISL_NULL;  /* 3-D coeff                                   */\n  int kkm1,kkm2;        /* Orders minus 1                              */\n  int kincre;           /* Number of doubles in first vertex direction */\n  int ki,kj,kl,kstop;\n  double tsum,*sp,*sq;\n  //int kstat=0,kpos=0;\n   \n  if (!ps) goto errnull;\n  if (ps->idim != 1) goto errdim;\n\n\n  kk1   = ps -> ik1;\n  kk2   = ps -> ik2;\n  kn1   = ps -> in1;\n  kn2   = ps -> in2;\n  st1   = ps -> et1;\n  st2   = ps -> et2;\n  scoef = ps -> ecoef;\n\n  /* Allocate array for 3-D representation of surface */\n  \n  if((s3coef = newarray(kn1*kn2*3,DOUBLE)) == SISL_NULL) goto err101;\n  \n  \n  \n  /* Make 3-D description of the surface */\n  \n  \n  /* Make representation of coefficients from Marsdens identity for the\n   * function f(t) = t, this will be used as the x-coordinate in the 3-D\n   * representation */\n  \n  kkm1    = kk1 - 1;\n  kincre  = 3*kn1;\n  \n  for (ki=0,kl=0,sp=s3coef ; ki<kn1 ; ki++,kl+=3,sp+=3)\n    {\n      tsum = (double)0.0;\n      kstop = ki+kk1;\n      for (kj=ki+1;kj<kstop;kj++)\n        tsum +=st1[kj];\n      \n      tsum = tsum/kkm1;\n      \n      \n      /* Copy x-coordinate to the other vertex rows */\n      for (kj=0,sq=sp ; kj<kn2 ; kj++,sq+=kincre) *sq = tsum;\n      \n    }\n  \n  /* Make representation of coefficients from Marsdens identity for the\n   * function f(t) = t, with the knot vector in second parameter direction\n   * scaled to [0,tfak].  This will be used as the x-coordinate in the 3-D\n   * representation */\n  \n  kkm2 = kk2 - 1;\n  for (ki=0,sp=s3coef+1 ; ki< kn2 ; ki++)\n    {\n      tsum = (double)0.0;\n      kstop = ki+kk2;\n      for (kj=ki+1;kj<kstop;kj++)\n        tsum +=st2[kj];\n      \n      tsum  = tsum/kkm2;\n      \n      /*  Copy to remaining y-coordinates in first vertex row */\n      \n      for (kj=0 ; kj<kn1 ; kj++,sp+=3) *sp = tsum;\n      \n    }\n  \n  /* Copy z-coordinates */\n  \n  for (kj=0,sp=s3coef+2,sq=scoef ; kj < kn2 ; kj++)\n     for (ki=0 ; ki<kn1 ; ki++,sp+=3,sq++)\n\t*sp = *sq;\n  \n  /* Make 3-D surface */\n  \n  if(((*rsnew) = newSurf(kn1,kn2,kk1,kk2,st1,st2,s3coef,1,3,1)) == SISL_NULL) goto err101;\n   \n  goto out;\n\n  /* ____________________________________________________________________ */\n  /* Error in alloc */\nerr101:\n   *jstat = -101;\n  s6err (\"make3D\", *jstat, 0);\n  goto out;\n\n  /* Null pointer */\nerrnull:\n   *jstat = -200;\n  s6err (\"make3D\", *jstat, 0);\n  goto out;\n\n    /* Dimension NE 1 */\nerrdim:\n   *jstat = -201;\n  s6err (\"make3D\", *jstat, 0);\n  goto out;\n\nout:\n   if (s3coef) freearray(s3coef);\n     \n}\n"
  },
  {
    "path": "src/makecvkreg.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: makecvkreg.c,v 1.7 1994-11-30 14:37:16 pfu Exp $\n *\n */\n\n\n#define MAKE_CV_KREG\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n    make_cv_kreg (SISLCurve * pc, SISLCurve ** rcnew, int *jstat)\n#else\nvoid\n   make_cv_kreg (pc, rcnew, jstat)\n     SISLCurve *pc;\n     SISLCurve **rcnew;\n     int *jstat;\n#endif\n/*\n********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To convert a curve to a k-regular basis.\n*\n*\n*\n* INPUT      : pc\t- Curve to be made k-regular.\n*\n*\n*\n* OUTPUT     : rcnew\t- The new curve on a k-regular basis.\n*              jstat\t- status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 04.92.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, 94-08. Added error propagation.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov.1994. Set cuopen flag to\n*              closed when changed from periodic.\n**********************************************************************/\n{\n   int kn=pc->in;\t/* Number of vertices in 1. par. dir.  */\n   int kk=pc->ik;\t/* Order in 1. par. dir.               */\n   /* --------------------------------------------------------- */\n   /* Pick part of curve */\n   s1712 (pc, pc->et[kk-1], pc->et[kn], rcnew, jstat);\n  if (*jstat < 0)  goto error;\n\n   if (pc->cuopen == SISL_CRV_PERIODIC )\n     (*rcnew)->cuopen = SISL_CRV_CLOSED;\n\n  goto out;\n\n  /* Error in lower level routine */\nerror:\n  s6err (\"make_cv_kreg\", *jstat, 0);\n\nout:;\n\n}\n"
  },
  {
    "path": "src/makesfkreg.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: makesfkreg.c,v 1.6 1994-11-30 12:53:02 pfu Exp $\n *\n */\n\n\n#define MAKE_SF_KREG\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid make_sf_kreg (SISLSurf * ps, SISLSurf ** rsnew, int *jstat)\n#else\nvoid\n   make_sf_kreg (ps, rsnew, jstat)\n     SISLSurf *ps;\n     SISLSurf **rsnew;\n     int *jstat;\n#endif\n/*\n********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To convert a surface to a k-regular basis.\n*\n*\n*\n* INPUT      : ps\t- Surface to be made k-regular.\n*\n*\n*\n* OUTPUT     : rsnew\t- The new surface on a k-regular basis.\n*              jstat\t- status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 04.92.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, 94-08. Added error propagation.\n*\n**********************************************************************/\n{\n  int kn1=ps->in1;\t/* Number of vertices in 1. par. dir.  */\n  int kn2=ps->in2;\t/* Number of vertices in 2. par. dir.  */\n  int kk1=ps->ik1;\t/* Order in 1. par. dir.               */\n  int kk2=ps->ik2;\t/* Order in 2. par. dir.               */\n  /* --------------------------------------------------------- */\n\n  s1001 (ps, ps->et1[kk1-1], ps->et2[kk2-1],\n\t\tps->et1[kn1], ps->et2[kn2], rsnew, jstat);\n  if (*jstat < 0)  goto error;\n\n  goto out;\n\n  /* Error in lower level routine */\nerror:\n  s6err (\"make_sf_kreg\", *jstat, 0);\n\nout:;\n\n}\n"
  },
  {
    "path": "src/maketracks.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: maketracks.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define MAKE_TRACKS\n#include \"sislP.h\"\n\n#if defined (SISLNEEDPROTOTYPES)\nvoid make_tracks (SISLObject * po1, SISLObject * po2, int ideg,\n\t\t  double eimpli[], int icrv, SISLIntlist ** vlist,\n\t\t  int *jtrack,SISLTrack *** wcrv, double aepsge, int *jstat)\n#else\nvoid make_tracks (po1, po2, ideg,eimpli, icrv, vlist,\n\t\t  jtrack,wcrv, aepsge, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     int ideg;\n     double eimpli[];\n     int icrv;\n     SISLIntlist **vlist;\n     int *jtrack;\n     SISLTrack ***wcrv;\n     double aepsge;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : An empty function, (to ensure similarity with other\n*              versions).\n*\n*\n* INPUT      : po1    - Pointer first object.\n*              po2    - Pointer second object.\n*                       internal format.\n*              icrv   - Number of lists in vlist.\n*              vlist  - Array representing intersection curves on the\n*                       internal format.\n*              ideg   - Type of track\n*                           = 0, Bspline vs Bspline\n*                           = 1, Bspline vs Plane\n*                           = 2, Bspline vs Quadric surface\n*                           = 1001 Bspline vs Torus surface\n*                           = 1003 Bspline silhouette line, parallel projection\n*                           = 1004 Bspline silhouette line, perspective projection\n*                           = 1005 Bspline silhouette line, circular projection\n*\n*              eimpli[16]  Description of the implicit surface.\n*              aepsge - Geometry tolerance\n*\n*OUTPUT:       jtrack - No of tracks made.\n*              wtrack - Array containing pointers to tracks.\n*              jstat - status messages\n*                       >0:warning\n*                       = 0:ok\n*                       <0:error\n*\n*\n*\n*METHOD:   Refining datapoints and\n*          Hermite interpolation using curvature radius.\n*\n*REFERENCES:\n*\n*\n*-\n*CALLS:     control_and_refine_ss(_si)\n*          s1359 - Hermite interpolation of curve using curvature radius.\n*\n*WRITTEN BY:Ulf J.Krystad, SI, 30.06 .91.\n*\n*********************************************************************\n*/\n{\n\n  *jstat  = 0;\n  *jtrack = 0;\n\n}\n\n"
  },
  {
    "path": "src/mk_cv_cycl.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: mk_cv_cycl.c,v 1.3 2005-02-28 09:04:47 afr Exp $\n *\n */\n\n\n#define MAKE_CV_CYCLIC\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \nmake_cv_cyclic(SISLCurve *pcurve,int icont,int *jstat)\n#else\nvoid make_cv_cyclic(pcurve,icont,jstat)\n     SISLCurve  *pcurve;\n     int        icont;\n     int    \t*jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To describe the curve pcurve with a cyclic basis of continuity\n*              icont.\n*\n* INPUT      : pcurve - Pointer to the curve\n*              icont  - The required continuity\n*\n* OUTPUT     : jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*              pcurve  - The curve with modified description\n*\n* METHOD     : 1. The cyclic knot vector with the right continuity is made\n*              2. The transformation matrix for the ik first vertices between\n*                 the cyclic and the old knot vector is made.\n*              3. The transformation matrix is inverted and used to update the\n*                 ik first vertices.\n*              4. The transformation matrix for the ik last vertices between\n*                 the cyclic and the old knot vector is made.\n*              5. The transformation matrix is inverted and used to update the\n*                 ik last vertices.\n*              6. The knot vector is updated.\n*-\n* CALLS      : s1701,s6err.\n*\n* Written  by : Vibeke Skytt, SI, 05.92 based on a routine by\n*               Tor Dokken, SI, Oslo, Norway,feb-1992\n*\n*********************************************************************\n*/\n{\n  double *scycl=SISL_NULL;                    /* Cyclic version of knot vector */\n  double *smatrix=SISL_NULL;                   /* Matrix converting between baes */\n  /* Pointers to two conversion matrices  @afr: Commented out */\n  /*  double *smatr1=SISL_NULL; */\n  /*  double *smatr2=SISL_NULL; */ \n  double *salloc=SISL_NULL;                    /* Matrix for memory allocation */\n  double *salfa=SISL_NULL;                     /* The values of a discrete B-spline\n                                             calculation */ \n  double *spek=SISL_NULL;                      /* Pointer used in traversing arrays */\n  double *scoef=SISL_NULL;                     /* Copy of the vertices of the surface */\n  double *sb=SISL_NULL;                        /* Right hand side of equation */\n  double *sfrom,*sto;\n  double *sp;                             /* Help array for s1701 */  \n  double *st1=SISL_NULL;                       /* Internal version of et */  \n  double *stx=SISL_NULL;                       /* Knot vector after insertion of knots\n                                             at start */ \n \n  int    kdim = pcurve->idim; \n  int    kk = pcurve->ik;\n  int    kn = pcurve->in;\n  int    rat = (pcurve->ikind == 1 || pcurve->ikind == 3) ? 0 : 1;\n  double *sourcecoef = (rat) ? pcurve->rcoef : pcurve->ecoef;\n  int    kdim2 = kdim + rat;\n  \n  int    kcont;                           /* Checked continuity */\n  int    kmult;                           /* Multiplicity of knot kk2-1 and kn2*/ \n  int    ki,kj,kl;\n  int    kperlength;\n  int    kant;\n  int    kleft=0;                         /* Pointer into knot vector */\n  int    kpl,kfi,kla;                     /* Pointers into conversion matrix */\n  int    kstat;\n  int    *mpiv=SISL_NULL;                      /* Pointer to pivotation array */  \n  int    kpos = 0;  \n  int    knst1;                           /* NUmber of basis functions in st1 */\n  int    knstx;                           /* Number of basis functions in stx */\n\n  \n  \n  \n  /* Test continuity */\n  \n  if (icont < 0) goto finished;\n  kcont = icont;\n  if (icont >= kk-2) icont = kk-2;\n  \n  /* Make multiplicty to be used at value et[ik-1] and et[in] */\n  kmult = kk - kcont - 1;\n  \n  /* Make the number of knots to be changed at the start and the end, this\n     is also equal to extra knot to be inserted in internal version of array et */\n  \n  kant = kk-kmult;\n  \n  \n  /* Alloocate array for pivotation vector */\n  \n  mpiv = new0array(2*kk,INT);\n  if (mpiv == SISL_NULL) goto err101;\n  \n  salloc = new0array(3*kn+9*kk+4*kk*kk+kdim2*kn,DOUBLE);\n  if (salloc == SISL_NULL) goto err101;\n  scycl = salloc;                  /* Size kn+kk */\n  smatrix = scycl + kn + kk;  /* Max size 4*kk*kk */\n  salfa = smatrix + 4*kk*kk;     /* Size kk */\n  scoef = salfa + kk;           /* Size kdim2*kn */\n  sb    = scoef + kdim2*kn;    /* Size 2*kk */  \n  sp    = sb + 2*kk;              /* Size kk */\n  st1   = sp + kk;                /* Size kn + 2*kk */\n  stx   = st1 + kn + 2*kk;       /* Size kn + 2*kk */\n  \n  \n  \n  /* Copy vertices, to avoid destruction of curve */\n  \n  memcopy(scoef, (rat) ? pcurve->rcoef : pcurve->ecoef, kdim2*kn, DOUBLE);\n  \n  \n  \n  /* Make cyclic knot vector */\n  \n  \n  /* First copy all knots */\n  \n  memcopy(scycl,pcurve->et,kn+kk,DOUBLE);\n  \n  /* The change the ik first and the ik last knots to make a cyclic basis */\n  \n  kperlength = kn - kk + kmult;\n  \n  /* Make knots 0 to ik - kmult - 1 */\n  \n  for (ki=kk-kmult-1 ; 0<=ki ; ki--)\n    {\n      scycl[ki] = scycl[kk-1] - (scycl[kn] - scycl[ki+kperlength]);\n    }\n  \n  \n  /* Make knots kn + kmult to kn + kk -1 */\n  \n  for (ki=kmult ; ki < kk ; ki++)\n    {\n      scycl[kn+ki] = scycl[kn] + (scycl[kk+ki-kmult] - scycl[kk-1]);\n      \n    }\n      /* s1701 expects et to be a refinement of scyclic, thus we have to make a new\n\t version of et with the extra kk-kmult new knots before the start and\n\t after the end and one intermediate version with only kk-kmult at the start */\n \n  memcopy(st1,scycl,kant,DOUBLE);\n  memcopy(st1+kant,pcurve->et,kn+kk,DOUBLE);\n  memcopy(st1+kant+kk+kn,scycl+kn+kk-kant,kant,DOUBLE);\n  knst1 = kn + 2*kant;\n\n  memcopy(stx,scycl,kn,DOUBLE);\n  memcopy(stx+kn,st1+kn+kant,kk+kant,DOUBLE);\n  knstx = kn + kant;\n  \n  /* STEP 2 Make matrix going between bases, only the kk-kmult first and last \n     knots are to be changed.  */\n  \n  \n  /* Now we have two cases. We know that only the kk-kmult first and kk-kmult\n     last vertices are to be changed. However 2*(kk-kmult) might be a bigger\n     number than kn. Thus we have to change all vertices if kn<=2(kk-kmult) */\n  \n  \n  /* Make two steps one for the start and one for the end of the surface */\n  \n  \n  /* Make matrix for the kk first vertices */\n  \n  for (ki=kant,spek=smatrix ; ki <kk+kant ; ki++, spek+=kk)\n    {\n      \n      s1219(stx,kk,kn,&kleft,st1[ki],&kstat);\n      if (kstat<0) goto error;\n      \n      s1701(ki,kleft,kk,knstx,&kpl,&kfi,&kla,st1,stx,sp,salfa,&kstat);\n      if(kstat<0) goto error;\n      \n      /* Copy the discrete B-splines into the right position */\n      \n      memcopy(spek+kfi,salfa+kpl+kfi,kla-kfi+1,DOUBLE);\n    }\n  \n  \n  \n  /* Do the factorisation of the matrix */\n  \n  s6lufacp(smatrix,mpiv,kk,&kstat);\n  if (kstat<0) goto error;\n  \n  /* TThe only vertices of the curve\n     affected by this backsubstitution is the kant first.\n     We want to treat the back substitution\n     as idim(=3) backsubstitutions. Thus we have to copy the proper\n     parts of the vertices into a temporary array. Do backsubstitution and\n     copy back into the curve object */\n  \n  \n    for (kl=0 ; kl<kdim2 ; kl++)\n      {\n\tfor (kj=0, sfrom=(sourcecoef)+kl,sto=sb ;\n\t     kj<kk ; kj++,sfrom+=kdim2,sto++)\n\t  *sto = *sfrom;\n\t\n\t/* sb now contains the vertices to be backsubsituted */\n\t\n\ts6lusolp(smatrix,sb,mpiv,kk,&kstat);\n\tif (kstat<0) goto error;\n\t\n\t/* Copy the backsubsituted vertices back into scoef */\n\t\n\tfor (kj=0, sto=scoef+kl,sfrom=sb ;\n\t     kj<kk ; kj++,sfrom++,sto+=kdim2)\n\t  *sto = *sfrom;\n      }\n  \n  \n  /* Make matrix for the kk last vertices */\n  \n\n  for (ki=0,spek=smatrix ; ki<kk*kk ; ki++,spek++) *spek = DZERO;\n  \n  \n  for (ki=kn-kk ,spek=smatrix ; ki <kn ; ki++, spek+=kk)\n    {\n      s1219(scycl,kk,kn,&kleft,stx[ki],&kstat);\n      if (kstat<0) goto error;\n\n      s1701(ki,kleft,kk,kn,&kpl,&kfi,&kla,stx,scycl,sp,salfa,&kstat);\n      if(kstat<0) goto error;\n      \n      /* Copy the discrete B-splines into the right position */\n      \n      memcopy(spek+kfi-(kn-kk),salfa+kpl+kfi,kla-kfi+1,DOUBLE);\n    }\n  \n  \n  \n  /* Do the factorisation of the matrix */\n  \n  s6lufacp(smatrix,mpiv,kk,&kstat);\n  if (kstat<0) goto error;\n  \n  /* The only vertices of the curve\n     affected by this backsubstitution is the kant last.\n     We want to treat the back substitution\n     as idim(=3) backsubstitutions. Thus we have to copy the proper\n     parts of the vertices into a temporary array. Do backsubstitution and\n     copy back into the curve object */\n  \n    for (kl=0 ; kl<kdim2 ; kl++)  \n      {\n\tfor (kj=0, sfrom=scoef+kdim2*(kn-kk)+kl,sto=sb ;\n\t     kj<kk ; kj++,sfrom+=kdim2,sto++)\n\t  *sto = *sfrom;\n\t\n\t/* sb now contains the vertices to be backsubsituted */\n\t\n\ts6lusolp(smatrix,sb,mpiv,kk,&kstat);\n\tif (kstat<0) goto error;\n\t\n\t/* Copy the backsubsituted vertices back into scoef */\n\t\n\tfor (kj=0, sto=scoef+kdim2*(kn-kk)+kl,sfrom=sb ;\n\t     kj<kk ; kj++,sto+=kdim2,sfrom++)\n\t  *sto = *sfrom;\n      }\n  \n  \n    /* Copy knots and vertices into the curve object */\n\n    memcopy((rat) ? pcurve->rcoef : pcurve->ecoef, scoef, kdim2*kn, DOUBLE);\n    memcopy(pcurve->et,scycl,kn+kk,DOUBLE); \n    pcurve->cuopen = SISL_CRV_PERIODIC;\n\n    /* Update divided coefficients */\n    if (rat)\n      {\n\tfor (ki=0; ki<kn; ++ki)\n\t  {\n\t    for (kj=0; kj<kdim; ++kj)\n\t      pcurve->ecoef[ki*kdim+kj] = \n\t\tpcurve->rcoef[ki*kdim2+kj]/pcurve->rcoef[ki*kdim2+kdim];\n\t  }\n      }\n\n  \n  /* Task done */\n  \n finished:\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in allocation. */\n  \n err101: \n  *jstat = -101;\n  s6err(\"make_cv_cyclic\",*jstat,kpos);\n  goto out;\n  \n  \n  \n  /* Error in lower level routine.  */\n  \n  error : \n    *jstat = kstat;     \n  s6err(\"make_cv_cyclic\",*jstat,kpos);\n  goto out;\n out:\n  \n  /* Free allocated scratch  */\n  if (salloc != SISL_NULL) freearray(salloc);  \n  if (mpiv != SISL_NULL) freearray(mpiv);\n  \n  return;\n  \n}\n"
  },
  {
    "path": "src/newknots.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: newknots.c,v 1.2 2001-03-19 15:58:40 afr Exp $\n *\n */\n\n\n#define NEWKNOTS\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n  newknots(double et[],int in,int ik,double epar[],int inpar,double aeps,\n\t   double **ginsert,int *jinsert,int *jstat)\n#else\nvoid newknots(et,in,ik,epar,inpar,aeps,ginsert,jinsert,jstat)\n   double et[];\n   int in;\n   int ik;\n   double epar[];\n   int inpar;\n   double aeps;\n   double **ginsert;\n   int *jinsert;\n   int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To set up an array of parameter values to insert into\n*              a B-spline curve when the curve is to have knot \n*              multiplisity equal to the order at specified parameter\n*              values.\n*\n*\n*\n* INPUT      : et      - Knot vector of the B-spline curve.\n*              in      - Number of vertices of the curve.\n*              ik      - Order of the curve.\n*              epar    - Parameter values at which the refined curve\n*                        is going to have an order-multiple knot.\n*              inpar   - Number of parameter values in epar.\n*              aeps    - The smallest legal distance between new and\n*                        current knots.\n*\n*\n*\n* OUTPUT     : ginsert - Array containing new knots to the curve.\n*              jinsert - Number of knots in ginsert.\n*              jstat   - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1219  - Find position of parameter value in the knot\n*                       vector of a curve.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 11.90.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;        /* Local status variable.               */\n   int ki,kj;            /* Counters.                            */\n   int knpar;            /* Number of new knots found currently. */\n   int kleft = 0;        /* Position in knot vector.             */\n   double tpar;          /* Value of current new knot.           */\n   \n   /* Allocate maximum needed scratch for output array.  */\n   \n   *jinsert = 0;\n   if ((*ginsert = newarray(ik*inpar,DOUBLE)) == SISL_NULL) goto err101;\n   \n   /* Traverse the array of parameter values and compute how\n      may knots is to be inserted at each value.  */\n   \n   for (ki=0; ki<inpar; ki++)\n   {\n      tpar = epar[ki];\n      \n      /* Find position in knot vector.  */\n      \n      s1219(et,ik,in,&kleft,tpar,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Check if the parameter value is close to a knot.  */\n      \n      if (tpar-et[kleft] < aeps)\n      {\n\t tpar = et[kleft];\n\t for (kj=1, knpar=ik-1; \n\t  kj<=kleft && DEQUAL(et[kleft],et[kleft-kj]);\n\t  kj++, knpar--);\n      }\n      else if (et[kleft+1]-tpar < aeps)\n      {\n\t tpar = et[kleft+1];\n\t for (kj=2, knpar=ik-1;\n\t  kleft+kj<in+ik && DEQUAL(et[kleft+1],et[kleft+kj]);\n\t  kj++, knpar--);\n      }\n      else knpar = ik;\n      \n      /* Register the new knots.  */\n      \n      for (kj=0; kj<knpar; kj++)\n\t (*ginsert)[*jinsert + kj] = tpar;\n      (*jinsert) += knpar;\n   }\n   \n   /* Set correct size of output array.  */\n   \n   if (*jinsert != ik*inpar)\n   {\n      if ((*ginsert = increasearray(*ginsert,MAX(1,*jinsert),DOUBLE)) == SISL_NULL)\n\t goto err101;\n   }\n   \n   /* New knots found.  */\n   \n   *jstat = 0;\n   goto out;\n   \n   /* Error in scratch allocation.  */\n   \n   err101 : *jstat = -101;\n   goto out;\n   \n   /* Error in lower level routine.  */\n    \n   error : *jstat = kstat;\n   goto out;\n   \n   out :\n      return;\n}\n"
  },
  {
    "path": "src/pickcrvsf.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: pickcrvsf.c,v 1.2 2001-03-19 15:58:40 afr Exp $\n *\n */\n\n\n#define PICK_CRV_SF\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   pick_crv_sf(SISLObject *po1, SISLObject *po2,int ipar,\n\t       SISLIntpt *pt1,SISLIntpt *pt2,SISLCurve **rcrv,\n\t       int *jstat)\n#else\nvoid pick_crv_sf(po1,po2,ipar,pt1,pt2,rcrv,jstat)\nSISLObject *po1;\nSISLObject *po2;\nint ipar;\n\t       SISLIntpt *pt1;\n\t       SISLIntpt *pt2;\n\t       SISLCurve **rcrv;\n\t       int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Pick a curve along a given parameter direction\n*              in a surface.\n*\n*\n* INPUT      : po1  - first object in intersection.\n*              po2  - second object in intersection.\n*              pt1  - first intersection point.\n*              pt2  - second intersection point.\n*              ipar - index of constant parameter value\n*\n*\n*\n* OUTPUT     : rcrv - SISL curve.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1436 - Pick curve with constant second parameter.\n*              s1437 - Pick curve with constant first parameter.\n*\n* WRITTEN BY : UJK, SI, 91-09.\n*\n*********************************************************************\n*/                                     \n{\n  int kstat = 0;        /* Local status parameter.                        */\n  int kpos = 0;         /* Position of error.                             */\n  int index=0;          /* Index of other par dir in surf.                */\n  int first_const;      /* Flag, const first direction or not             */\n  double tpar;          /* Parameter value of curve in constant parameter\n\t\t\t   direction.                                     */\n  SISLSurf *ps1=SISL_NULL;   /* Pointer to surf to pick crv from               */\n  SISLCurve *pick_crv=SISL_NULL;/* Picked curve before trimming.               */\n  /* -------------------------------------------------------------------- */\n  if (ipar < 0 || ipar >= po1->iobj + po2->iobj) goto errinp;\n\n  if (ipar >= po1->iobj)\n  {\n     /* pick from second object (must be a sf) */\n     if (po2->iobj != SISLSURFACE) goto errinp;\n     ps1 = po2->s1;\n     index = (ipar == po1->iobj) ? po1->iobj + 1 : po1->iobj;\n  }\n  else\n  {\n     /* pick from first object (must be a sf) */\n     if (po1->iobj != SISLSURFACE) goto errinp;\n     ps1 = po1->s1;\n     index = (ipar == 0) ? 1 : 0;\n  }\n  \n  if (ipar < index) first_const = TRUE;\n  else first_const = FALSE;\n  tpar = pt1->epar[ipar];\n  \n  \n  if (first_const == FALSE)\n    {\n       /* Pick curve with constant second parameter.  */\n       s1436(ps1,tpar,&pick_crv,&kstat);\n       if (kstat < 0) goto error;\n    }\n  else \n    {\n       /* Pick curve with constant first parameter.  */\n       s1437(ps1,tpar,&pick_crv,&kstat);\n       if (kstat < 0) goto error;\n    }\n  \n  /* SISLCurve picked, now trim it.  */\n  if (DEQUAL(pt1->epar[index], pick_crv->et[pick_crv->ik-1]) &&\n      DEQUAL(pt2->epar[index], pick_crv->et[pick_crv->in]))\n    {\n       /* Return the whole curve */\n       (*rcrv)  = pick_crv;\n       pick_crv = SISL_NULL;\n    }\n  \n  \n  else if(DEQUAL(pt1->epar[index], pick_crv->et[pick_crv->in]) &&\n\t  DEQUAL(pt2->epar[index], pick_crv->et[pick_crv->ik-1]))\n    {\n       /* Return the whole curve, but turn it first */\n       /* Return the whole curve */\n       (*rcrv)  = pick_crv;\n       pick_crv = SISL_NULL;\n       s1706(*rcrv); \n    } \n  else\n  {\n     /* Return a part of the curve */ \n     double amin = min(pt1->epar[index], pt2->epar[index]);\n     double amax = max(pt1->epar[index], pt2->epar[index]);\n     \n     if (pick_crv->cuopen == SISL_CRV_PERIODIC)\n\ts1713(pick_crv,amin,amax,rcrv,&kstat);\n     else\n\ts1712(pick_crv,amin,amax,rcrv,&kstat);\n     \n     if (kstat < 0) goto error;\n     \n     if (pt1->epar[index] > pt2->epar[index]) s1706(*rcrv); \n\n    }\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in input.  */\n  errinp : *jstat = -1;\n  s6err(\"pick_crv_sf\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n  error : *jstat = kstat;\n  s6err(\"pick_crv_sf\",*jstat,kpos);\n  goto out;\n  \n out: if (pick_crv) freeCurve(pick_crv);\n}\n"
  },
  {
    "path": "src/pocrvtang.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: pocrvtang.c,v 1.2 2001-03-19 15:58:40 afr Exp $\n *\n */\n\n\n#define PO_CRV_TANG\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   po_crv_tang(SISLCurve *pcurve, double point[], double ang_tol,\n\t    double guess_par, double *iter_par, int *jstat)\n#else\n      void po_crv_tang(pcurve, point, ang_tol, guess_par, iter_par, jstat)\n\t SISLCurve   *pcurve;\n\t double       point[];\n\t double       ang_tol;\n\t double       guess_par; \n\t double      *iter_par;\n\t int         *jstat;\n#endif\n/********************************************************************\n*                                                                   \n* PURPOSE    : Find parameter value on a B-Spline curve for\n*              the construction of a tangent from a point to the\n*              curve (in 2D).\n*\n*\n*\n* INPUT      : pcurve    - Pointer to the curve.\n*              point     - The point.\n*              ang_tol   - The anular tolerance (in radians).\n*              guess_par - Start parameter value on the B-spl crv.\n*\n*\n* OUTPUT     : iter_par  - The found parameter value on the B-spl crv.\n*              jstat     - status messages  \n*                                = 2   : A minimum distanse found.\n*                                = 1   : Intersection found.\n*                                < 0   : error.\n*\n*\n* METHOD     : Convert the problem to a onedimention zero problem\n*              by using s1893.\n*              \n*\n*\n* REFERENCES :\n*\n*- \n* CALLS      : \n*\n* WRITTEN BY : Ulf J. Krystad, SI, 92-03.\n*\n*********************************************************************\n*/                                                               \n{                                                                     \n  int kstat   = 0;             /* Local status variable.                       */\n  int kpos    = 0;             /* Position of error.                           */\n  int kdim    = 2;             /* Legal dimension.                             */\n  int der0    = 0;             /* Derivative indicator.                        */  \n  int der1    = 1;             /* Derivative indicator.                        */  \n  int kleft   = 0;             /* Knot navigator.                              */  \n  int narr    = 1;             /* No of parallell problems (s1893)             */  \n  double zero = 0;             /* Value to iteration.                          */ \n  double iter_ang;             /* The error angle                              */\n  double diff[2];              /* Difference vector.                           */\n  double sder[4];              /* Result from s1221.                           */\n  double trans_arr[9];         /* Matrix describe the curve product (s1893)    */\n  SISLCurve *testcurve = SISL_NULL; /* The curve to iterate on.                     */\n  SISLPoint *p1 = newPoint (&zero, 1, 0);\n  /* ------------------------------------------------------------------------- */\n  \n  /* Test input. ---------------------------------------------- */\n  if (!p1) goto err101;\n  if (pcurve->idim != kdim) goto err105;\n  \n  /* Set up matrix */\n  trans_arr[0] = DZERO;\n  trans_arr[1] = -1;\n  trans_arr[2] = DZERO;\n  trans_arr[3] = 1;\n  trans_arr[4] = DZERO;\n  trans_arr[5] = DZERO;\n  trans_arr[6] = -point[1];\n  trans_arr[7] =  point[0];\n  trans_arr[8] = 1;\n\n  \n  /* Convert the problem. ------------------------------------- */\n  s1893(pcurve, trans_arr,kdim+1,narr=1,der0=0,der1=1, &testcurve, &kstat);\n  if (kstat < 0) goto error;\n  \n  \n  /* Iteration. ---------------------------------------------- */\n  s1771(p1, testcurve, REL_COMP_RES, testcurve->et[testcurve->ik - 1],\n\ttestcurve->et[testcurve->in], guess_par, iter_par, &kstat); \n  if (kstat < 0) goto error;\n  \n  /* Analyse the result */\n  s1221(pcurve, der1=1, *iter_par, &kleft, sder, &kstat);\n  if (kstat < 0) goto error;\n\n  s6diff(sder,point,kdim,diff);\n  iter_ang = s6ang(sder+2, diff, kdim);\n  \n  if (iter_ang < ang_tol)   *jstat = 1;\n  else   *jstat = 2;\n\n  goto out;\n  \n\n  /* EXITS. ------------------------------------------------ */\n\n  /* Error in space allocation.  */\n err101: *jstat = -101;\n  s6err(\"po_crv_tang\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Dimension not equal to 2.  */\n err105: *jstat = -105;\n  s6err(\"po_crv_tang\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  error : *jstat = kstat;\n  s6err(\"po_crv_tang\",*jstat,kpos);\n  goto out;\n  \n out:\n  /* Free allocated space.  */\n  if (testcurve) freeCurve(testcurve);\n  if (p1)        freePoint(p1);\n \n  return;\n}                                               \n                                           \n                       \n"
  },
  {
    "path": "src/refine_all.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: refine_all.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define REFINE_ALL\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nrefine_all (SISLIntdat ** pintdat,\n\t    SISLObject * po1,\n\t    SISLObject * po2,\n\t    double eimpli[],\n\t    int ideg,\n\t    double aepsge,\n\t    int *jstat)\n\n#else\nvoid\nrefine_all (pintdat,\n\t    po1,\n\t    po2,\n\t    eimpli,\n\t    ideg,\n\t    aepsge,\n\t    jstat)\n\n     SISLIntdat **pintdat;\n     SISLObject *po1;\n     SISLObject *po2;\n     double eimpli[];\n     int ideg;\n     double aepsge;\n     int *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : An empty function, (to ensure similarity with other\n*              versions).\n*\n*\n* INPUT      : pintdat     - Pointer to pointer to the SISLIntdat data.\n*              po1         - Pointer surface object.\n*              po2         - Pointer surface object.\n*              eimpli      - Array containing descr. of implicit surf\n*\t       ideg        - Type of impl surf.\n              ang_tol     - Angle control tolerance ie ??\n*              aepsge      - Absolute tolerance\n*\n*\n* OUTPUT     :  jstat  - status messages\n*                       = ?      : ?\n*                       = 0      : ok\n*                       < 0      : error\n*\n*\n* METHOD     :\n*\n* USE        : The function is only working i 3-D\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, Oslo, Norway, July-1990\n*\n*********************************************************************\n*/\n{\n  *jstat = 0;\n}\n"
  },
  {
    "path": "src/s1001.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1001.c,v 1.7 2001-03-19 15:58:40 afr Exp $\n *\n */\n\n\n#define S1001\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n  s1001 (SISLSurf * ps, double min1, double min2,\n\t\tdouble max1, double max2,\n\t\tSISLSurf ** rsnew, int *jstat)\n#else\nvoid\ns1001 (ps, min1, min2, max1, max2, rsnew, jstat)\n     SISLSurf *ps;\n     double min1;\n     double min2;\n     double max1;\n     double max2;\n     SISLSurf **rsnew;\n     int *jstat;\n#endif\n/*\n********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To pick a part of a surface.\n*              The surface produced will always be k-regular, i.e. with\n*              k-tupple end knots.\n*\n*\n*\n* INPUT      : ps\t- Surface to pick a part of.\n*\t       min1     - Min value 1. parameter direction.\n*\t       min2     - Min value 2. parameter direction.\n*\t       max1     - Max value 1. parameter direction.\n*\t       max2     - Max value 1. parameter direction.\n*\n*\n*\n* OUTPUT     : rsnew\t- The new, refined surface.\n*              jstat\t- status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 04.92.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, 94-08. Added error propagation.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, 94-11. Looked at handling of\n*              periodics - since this routine is used to convert a periodic into\n*              a k-regular surface, it must always return a k-regular surface,\n*              even if the whole periodic parameter range (ik-1 to in) is picked.\n*              To do this correctly the 'cuopen' flags must indicate closed after\n*              the picking of the whole periodic range.\n*\n**********************************************************************/\n{\n  int kstat;\t\t\t/* Local status variable.\t       */\n  int kpos = 0;\t\t\t/* Position of error.\t\t       */\n  int kleft1 = 0;\t\t/* Knot navigator.\t\t       */\n  int kleft2 = 0;\t\t/* Knot navigator.\t\t       */\n  int kleft3 = 0;\t\t/* Knot navigator.\t\t       */\n  int kleft4 = 0;\t\t/* Knot navigator.\t\t       */\n  int kdim = ps->idim;\t\t/* Dimension of geometry space.        */\n  int kkind = ps->ikind;\t/* Kind of surface.                    */\n  int kn1;\t\t\t/* Number of vertices in 1. par. dir.  */\n  int kn2;\t\t\t/* Number of vertices in 2. par. dir.  */\n  int cuopen_1, cuopen_2;\t/* Open flags for the new surface.     */\n  int change_1,change_2;\t/* Flag, need to change surf in dir ?  */\n  int wholeperi1 = FALSE;       /* Flag, pick whole peri. param. range */\n  int wholeperi2 = FALSE;       /* Flag, pick whole peri. param. range */\n  double *st1=SISL_NULL;\t\t/* Knot vector in 1. par. dir.         */\n  double *st2=SISL_NULL;\t\t/* Knot vector in 2. par. dir.         */\n  double *scoef1 = SISL_NULL;\t/* Coefficients of input curve to\n\t\t\t           refinement in 1. par. dir.          */\n  double *scoef2 = SISL_NULL;\t/* Coefficients of refined surface.    */\n  double *scoef  = SISL_NULL;\t/* Coefficients of refined surface.    */\n  SISLCurve *qc1 = SISL_NULL;\t/* Input curve to pick curve.          */\n  SISLCurve *qc2 = SISL_NULL;\t/* Output curve from pick curve.       */\n  SISLCurve *qc3 = SISL_NULL;\t/* Output curve from pick curve.       */\n  double *oldcoef;           \t/* Pointer to vertices of old surf.    */\n  /* ----------------------------------------------------------------- */\n\n  if(kkind == 2 || kkind == 4)\n  {\n     oldcoef = ps->rcoef;\n     kdim++;\n  }\n  else\n  {\n     oldcoef = ps->ecoef;\n  }\n\n  kleft1=ps->ik1-1;\n  kleft2=ps->in1;\n  kleft3=ps->ik2-1;\n  kleft4=ps->in2;\n  change_1 = change_2 = TRUE;\n\n  if ( min1 == ps->et1[ps->ik1 -1]  &&  max1 == ps->et1[ps->in1] )\n  {\n    if ( s6knotmult(ps->et1,ps->ik1,ps->in1,\n\t\t    &kleft1,ps->et1[ps->ik1-1],&kstat) == ps->ik1 &&\n\t s6knotmult(ps->et1,ps->ik1,ps->in1,\n\t\t    &kleft2,ps->et1[ps->in1],&kstat) == ps->ik1 )\n      change_1 = FALSE;\n    else\n      wholeperi1 = ( ps->cuopen_1 == SISL_SURF_PERIODIC );\n  }\n\n  if ( min2 == ps->et2[ps->ik2 -1]  &&  max2 == ps->et2[ps->in2] )\n  {\n    if ( s6knotmult(ps->et2,ps->ik2,ps->in2,\n\t\t    &kleft3,ps->et2[ps->ik2-1],&kstat) == ps->ik2 &&\n\t s6knotmult(ps->et2,ps->ik2,ps->in2,\n\t\t    &kleft4,ps->et2[ps->in2],&kstat) == ps->ik2 )\n      change_2 = FALSE;\n    else\n      wholeperi2 = ( ps->cuopen_2 == SISL_SURF_PERIODIC );\n  }\n\n  if (change_1)\n    {\n       /* Treat the first parameter direction of the\n\t  surface. First express the surface as a curve.  */\n       if ((scoef1 = newarray (kdim * ps->in1 * ps->in2, double)) == SISL_NULL)\n\t goto err101;\n\n       /* Change parameter directions of surface.  */\n       s6chpar (oldcoef, ps->in1, ps->in2, kdim, scoef1);\n\n       /* Create curve.  */\n       qc1 = newCurve (ps->in1, ps->ik1, ps->et1, scoef1, 1, kdim * ps->in2, 0);\n       if (qc1 == SISL_NULL)\n\t goto err101;\n       qc1->cuopen = ps->cuopen_1;\n\n       /* Pick part of curve */\n       s1713 (qc1, min1, max1, &qc2, &kstat);\n       if (kstat < 0)\n\t goto error;\n\n       /* Change parameter directions of the coefficient array of\n\t  the refined curve.     */\n\n       if ((scoef2 = newarray (qc2->in *ps->in2 * kdim, DOUBLE)) == SISL_NULL)\n\t goto err101;\n       s6chpar (qc2->ecoef, ps->in2, qc2->in, kdim, scoef2);\n\n       /* Set local parameters of refined surface. */\n\n       kn1 = qc2->in;\n       kn2 = ps->in2;\n       st1 = qc2->et;\n       st2 = ps->et2;\n       if ( wholeperi1 )\n\t cuopen_1 = SISL_SURF_CLOSED;\n       else\n\t cuopen_1 = qc2->cuopen;\n\n       /* Free curve used as input to s1713. */\n       if (qc1)\n\t freeCurve (qc1);\n       qc1 = SISL_NULL;\n    }\n\n  else\n    {\n       /* Set local parameters of input surface. */\n\n       kn1 = ps -> in1;\n       kn2 = ps -> in2;\n       st1 = ps -> et1;\n       st2 = ps -> et2;\n       scoef2   = oldcoef;\n       cuopen_1 = ps->cuopen_1;\n    }\n\n  if (change_2)\n    {\n       /* Treat the first parameter direction of the\n\t  surface. First express the surface as a curve.  */\n\n       if ((qc1 = newCurve (kn2, ps->ik2, st2, scoef2, 1, kn1 * kdim, 0))\n\t   == SISL_NULL)\n\t goto err101;\n       qc1->cuopen = ps->cuopen_2;\n\n       /* Pick part of curve */\n       s1713 (qc1, min2, max2, &qc3, &kstat);\n       if (kstat < 0)\n\t goto error;\n\n\n       /*\tSet local parameters of the refined surface. */\n       kn2 = qc3->in;\n       st2 = qc3->et;\n       scoef = qc3->ecoef;\n       if ( wholeperi2 )\n\t cuopen_2 = SISL_SURF_CLOSED;\n       else\n\t cuopen_2 = qc3->cuopen;\n\n       /* Free curve used as input to s1713. */\n       if (qc1)\n\t freeCurve (qc1);\n       qc1 = SISL_NULL;\n    }\n  else\n    {\n       scoef = scoef2;\n       cuopen_2 = ps->cuopen_2;\n    }\n\n  /* Express result as a surface.  */\n  if ((*rsnew = newSurf (kn1, kn2, ps->ik1, ps->ik2, st1, st2,\n\t\t\t scoef, kkind, ps->idim, 1)) == SISL_NULL)\n    goto err101;\n\n\n  (*rsnew)->cuopen_1 = cuopen_1;\n  (*rsnew)->cuopen_2 = cuopen_2;\n\n  /* Task done  */\n\n  *jstat = 0;\n  goto out;\n\n  /* ---------------------- ERROR EXITS ------------------------------- */\n  /* Error in scratch allocation.  */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1001\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1001\", *jstat, kpos);\n  goto out;\n\n  out:\n     /* Free scratch occupied by local arrays and objects.  */\n\n     if (change_1)\n       {\n\t  if (scoef1) freearray (scoef1);\n\t  if (scoef2) freearray (scoef2);\n\t  scoef1 = SISL_NULL;\n\t  scoef2 = SISL_NULL;\n       }\n\n     if (qc1) freeCurve (qc1);\n     if (qc2) freeCurve (qc2);\n     if (qc3) freeCurve (qc3);\n}\n"
  },
  {
    "path": "src/s1011.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1011.c,v 1.3 2001-03-19 15:58:40 afr Exp $\n *\n */\n\n\n#define S1011\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1011(double start_pos[], double top_pos[], double end_pos[],\n \t   double shape, int dim, SISLCurve **arc_seg, int *stat)\n#else\nvoid s1011(start_pos, top_pos, end_pos, shape, dim, arc_seg, stat)\n     double start_pos[];\n     double top_pos[];\n     double end_pos[];\n     double shape;\n     int    dim;\n     SISLCurve  **arc_seg;\n     int    *stat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To describe a conic arc as a NURBS. The arc is given by\n*              position at start, shoulder point and end, and a shape factor.\n*\n*\n* INPUT      : start_pos - Start point of segment\n*              top_pos   - Shoulder point of segment. This is the intersection\n*                          point of the tangents in start_pos and end_pos\n*              end_pos   - End point of segment\n*              shape     - Shape factor >= 0\n*                           shape < 0.5 a ellipse\n*                           shape = 0.5 a parabola\n*                           shape > 0.5 a hyperbola\n*                           shape >= 1  The start and end point lies on\n*                                       different branches of the hyperbola.\n*                                       We want a single arc segment, therefore\n*                                       if shape>=1, shape is put to 0.999999.\n*              dim       - The dimension of the curve to be produced\n*\n*\n*\n*\n* OUTPUT     :\n*              stat      - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*              arc_seg   - Pointer to the curve produced\n*\n* METHOD     : The conic is made as a rational B-spline curve according\n*              to the following formula:\n*\n*                     p0 (1-t)(1-t) + 2 s/(1-s) t(1-t) pt + tt p1\n*              p(t) = -------------------------------------------\n*                         (1-t)(1-t) + 2 s/(1-s) t(1-t) + tt\n*\n*              where p0 is the start point, pt is the shoulder point, p1 is\n*              the end point and s is the shape factor.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Johannes Kaasa, SI, Oslo, Norway, Jan. 93 (Based on s1385,\n*              written by Tor Dokken)\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov. 1994. Give error if\n*              shape < zero.\n*********************************************************************\n*/\n{\n  int kpos = 0;       /* Error position.         */\n  int ki;             /* Index in for loop.      */\n  int in = 3;         /* Number of coefficients. */\n  int ik = 3;         /* Order of the curve.     */\n  int rdim = dim + 1; /* Rational dimension.     */\n  double et[6];       /* Knot vector.            */\n  double rcoef[12];   /* Rational coefficients.  */\n  int kind = 4;       /* Rational Bezier curve.  */\n  double weight;      /* Rational weight.        */\n\n\n  /* Make sure we get a single arc segment and positive weights. */\n\n  if ( shape >= (DOUBLE)1.0 ) shape = (DOUBLE)0.9999999;\n  else if ( shape < (DOUBLE)0.0 )  goto err151;\n\n\n  /* Make the data needed for curve generation. */\n\n  for ( ki=0;  ki < ik;  ki++ )\n  {\n    et[ki]      = DZERO;\n    et[ik + ki] = (DOUBLE)1.0;\n  }\n\n  weight = shape/((DOUBLE)1.0 - shape);\n\n  for ( ki=0;  ki < dim;  ki++ )\n  {\n    rcoef[ki]          = start_pos[ki];\n    rcoef[rdim + ki]   = weight*top_pos[ki];\n    rcoef[2*rdim + ki] = end_pos[ki];\n  }\n  rcoef[dim] =          (DOUBLE)1.0;\n  rcoef[dim + rdim] =   weight;\n  rcoef[dim + 2*rdim] = (DOUBLE)1.0;\n\n  (*arc_seg) = newCurve(in, ik, et, rcoef, kind, dim, 1);\n  if ((*arc_seg) == SISL_NULL) goto err101;\n\n  *stat = 0;\n  goto out;\n\n\n  /* Error in curve allocation.  */\n\nerr101:\n  *stat = -101;\n  s6err(\"s1011\", *stat, kpos);\n  goto out;\n\n\n  /* Error in input parameters - shape is negative.  */\n\nerr151:\n  *stat = -151;\n  s6err(\"s1011\", *stat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1012.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1012.c,v 1.2 2001-03-19 15:58:40 afr Exp $\n *\n */\n\n\n#define S1012\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1012(double start_pos[], double axis_pos[], double axis_dir[],\n \t   double frequency, int numb_quad, int counter_clock, \n\t   SISLCurve **helix, int *stat)\n#else\nvoid s1012(start_pos, axis_pos, axis_dir, frequency, numb_quad, \n\t\tcounter_clock, helix, stat) \n     double start_pos[];\n     double axis_pos[];\n     double axis_dir[];\n     double frequency;\n     int numb_quad;\n     int counter_clock;\n     SISLCurve  **helix;\n     int    *stat;      \n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To describe a truncated helix  as a NURBS.\n*             \n*\n* INPUT      : start_pos     - Start position on the helix\n*              axis_pos      - Point on the helix axis\n*              axis_dir      - Direction of the helix axis\n*              frequency     - The length along the helix axis for one period \n*                              of revolution\n*              numb_quad     - Number of quadrants in the helix\n*              counter_clock - Flag for direction of revolution:\n*                              = 0 : clockwise\n*                              = 1 : counter_clockwise\n*\n*\n*\n* OUTPUT     : \n*              stat          - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*              helix         - Pointer to the helix produced\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-                                      \n* CALLS      : \n*\n* WRITTEN BY : Johannes Kaasa, SI, Oslo, Norway, Jan. 93\n*\n*********************************************************************\n*/\n{\n   int kstat;            /* Status variable.                 */\n   int kpos = 0;         /* Error position.                  */\n   int ki, kj;           /* Index in for loop.               */\n   int mod_count;        /* Modulo index.                    */\n   int in;               /* Number of vertices in the helix. */\n   int ik = 3;           /* Order of the helix.              */\n   int kind = 2;         /* Rational B-spline curve.         */\n   int dim = 3;          /* Dimension of geometry.           */\n   double *et = SISL_NULL;    /* Knot vector.                     */\n   double *rcoef = SISL_NULL; /* Vertices.                        */\n   double norm;          /* Norm of vector.                  */\n   double radius;        /* Radius of the helix.             */\n   double origo[3];      /* Local origo.                     */\n   double x_axis[3];     /* Normalized local x_axis.         */\n   double y_axis[3];     /* Normalized local y_axis.         */\n   double z_axis[3];     /* Normalized local z_axis.         */\n   double x_comp;        /* Component on x_axis.             */\n   double y_comp;        /* Component on y_axis.             */\n   double z_comp;        /* Component on z_axis.             */\n   double weight;        /* Rational weight.                 */\n   double w1;            /* Rational weight.                 */\n\n \n   weight = (double)1.0/sqrt(2.0);  \n   \n   /* Allocate space. */\n   \n   in = 1 + 2*numb_quad;\n   et = newarray(in + ik, DOUBLE);\n   rcoef = newarray(4*in, DOUBLE);\n   \n   /* Initiate knot vector. */\n   \n   for (ki = 0; ki < ik; ki++)\n      et[ki] = (double)0.;\n   for (ki = 0; ki < numb_quad; ki++)\n   {\n      et[3 + 2*ki]     = (1 + ki)*PIHALF;\n      et[3 + 2*ki + 1] = (1 + ki)*PIHALF;\n   }\n   et[ik + in - 1] = numb_quad*PIHALF;\n   \n   /* Initiate coefficient vector. */\n   \n   norm = s6norm(axis_dir, 3, z_axis, &kstat);\n   if (kstat < 0) goto error;\n\t\t  \n   s6diff(start_pos, axis_pos, 3, x_axis);\n   norm = s6scpr(x_axis, z_axis, 3);\n   for (ki = 0; ki < 3; ki++)\n   {\n      origo[ki] = axis_pos[ki] + norm*z_axis[ki];\n      x_axis[ki] = start_pos[ki] - origo[ki];\n   }\n   radius = s6norm(x_axis, 3, x_axis, &kstat);\n   \n   if (counter_clock == 0)\n      s6crss(x_axis, z_axis, y_axis);\n   else\n      s6crss(z_axis, x_axis, y_axis);\n      \n   mod_count = 0;\n   for (ki = 0; ki < in; ki++)\n   {\n      if (mod_count == 1 || mod_count == 3 \n\t  || mod_count == 5 || mod_count == 7)\n\t w1 = weight;\n      else\n         w1 = (double)1.;\n      \n      if (mod_count == 0 || mod_count == 1 || mod_count == 7)\n\t x_comp = radius;\n      else if (mod_count == 3 || mod_count == 4 || mod_count == 5)\n\t x_comp = - radius;\n      else\n         x_comp = (double)0.;\n\n      if (mod_count == 1 || mod_count == 2 || mod_count == 3)\n\t y_comp = radius;\n      else if (mod_count == 5 || mod_count == 6 || mod_count == 7)\n\t y_comp = - radius;\n      else\n         y_comp = (double)0.;\n\t \n      z_comp = ki*frequency/8;\n       \n      for (kj = 0; kj < 3; kj++)\n\trcoef[4*ki + kj] = w1*(origo[kj] + x_comp*x_axis[kj]\n\t\t\t+ y_comp*y_axis[kj] + z_comp*z_axis[kj]);\n      rcoef[4*ki + 3] = w1;\n      \n      mod_count++;\n      if (mod_count == 8) mod_count = 0;\n   }\n   \n   (*helix) = newCurve(in, ik, et, rcoef, kind, dim, 1);\n   if (et != SISL_NULL) freearray(et);\n   if (rcoef != SISL_NULL) freearray(rcoef);\n   if ((*helix) == SISL_NULL) goto err101;\n  \n   *stat = 0;\n   goto out;\n  \n   /* Error in curve allocation.  */\n  \n   err101: \n      *stat = -101;\n      s6err(\"s1012\",*stat,kpos);\n      goto out;\n      \n   /* Error in lower level routine. */\n      \n   error:\n      *stat = kstat;\n      s6err(\"s1012\", *stat, kpos);\n      goto out;\n    \n   out:  \n      return;\n}\n    \n"
  },
  {
    "path": "src/s1013.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1013.c,v 1.2 2001-03-19 15:58:40 afr Exp $\n *\n */\n\n\n#define S1013\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   s1013(SISLCurve *pcurve, double ang, double ang_tol,\n\t    double guess_par, double *iter_par, int *jstat)\n#else\n      void s1013(pcurve, ang, ang_tol, guess_par, iter_par, jstat)\n\t SISLCurve   *pcurve;\n\t double       ang;\n\t double       ang_tol;\n\t double       guess_par; \n\t double      *iter_par;\n\t int         *jstat;\n#endif\n/********************************************************************\n*                                                                   \n* PURPOSE    : Find a point on a 2-Dimensional B-spline curve that\n*              has a given direction.\n*\n*\n*\n* INPUT      : pcurve    - Pointer to the curve.\n*              ang       - The angle (in radians) describing the wanted direction.\n*              ang_tol   - The anular tolerance (in radians).\n*              guess_par - Start parameter value on the B-spl crv.\n*\n*\n* OUTPUT     : iter_par  - The found parameter value on the B-spl crv.\n*              jstat     - status messages  \n*                                = 2   : A minimum distanse found.\n*                                = 1   : Intersection found.\n*                                < 0   : error.\n*\n*\n* METHOD     : Convert the problem to a onedimention zero problem\n*              by making the first derivative of the curve and take\n*              set the ratio of the components equal to the angle.\n*              \n*\n*\n* REFERENCES :\n*\n*- \n* CALLS      : \n*\n* WRITTEN BY : Johannes Kaasa, SI, 92-03.\n*\n*********************************************************************\n*/                                                               \n{                                                                     \n  int kstat   = 0;             /* Local status variable.                       */\n  int kpos    = 0;             /* Position of error.                           */\n  int kdim    = 2;             /* Legal dimension.                             */\n  int ki      = 0;             /* Loop control.                                */\n  int derive  = 1;             /* The first derivative.                        */  \n  int kleft   = 0;             /* Knot navigator.                              */  \n  double zero = 0;             /* Value to iteration.                          */ \n  double si,co;                /* Sin and cosin to the angle.                  */\n  double *dim_one, *dim_two;   /* Pointers into the vertice array.             */\n  double iter_ang;             /* The error angle                              */\n  double sder[4];              /* Result from s1221.                           */\n  double help_arr[2];          /* Help array containing angle as direction     */\n  SISLCurve *testcurve = SISL_NULL; /* The curve to iterate on.                     */\n  SISLPoint *p1 = newPoint (&zero, 1, 0);\n  /* ------------------------------------------------------------------------- */\n  \n  /* Test input. ---------------------------------------------- */\n  if (!p1) goto err101;\n  if (pcurve->idim != kdim) goto err105;\n  \n  /* Find the ratio between the y and x direction. -------------*/\n  help_arr[0] = co = cos(ang);\n  help_arr[1] = si = sin(ang);\n  \n  /* Convert the problem. ------------------------------------- */\n  s1720(pcurve, derive, &testcurve, &kstat);\n  if (kstat < 0) goto error;\n  \n  testcurve->idim--;\n  dim_one = testcurve->ecoef;\n  dim_two = testcurve->ecoef;\n  for (ki = 0; ki < testcurve->in; ki++)\n    {\n       *dim_one = co*(*(dim_two + 1)) - si*(*dim_two);\n       dim_one++;\n       dim_two += 2;\n    }\n  \n  \n  /* Iteration. ---------------------------------------------- */\n  s1771(p1, testcurve, REL_COMP_RES, testcurve->et[testcurve->ik - 1],\n\ttestcurve->et[testcurve->in], guess_par, iter_par, &kstat);\n  if (kstat < 0) goto error;\n  \n  /* Analyse the result */\n  s1221(pcurve, derive=1, *iter_par, &kleft, sder, &kstat);\n  if (kstat < 0) goto error;\n\n  iter_ang = s6ang(sder+2, help_arr, kdim);\n  \n  if (iter_ang < ang_tol)   *jstat = 1;\n  else   *jstat = 2;\n\n  goto out;\n  \n\n  /* EXITS. ------------------------------------------------ */\n\n  /* Error in space allocation.  */\n err101: *jstat = -101;\n  s6err(\"s1013\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Dimension not equal to 2.  */\n err105: *jstat = -105;\n  s6err(\"s1013\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  error : *jstat = kstat;\n  s6err(\"s1013\",*jstat,kpos);\n  goto out;\n  \n out:\n  /* Free allocated space.  */\n  if (testcurve) freeCurve(testcurve);\n  if (p1)        freePoint(p1);\n \n  return;\n}                                               \n                                           \n                       \n"
  },
  {
    "path": "src/s1014.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1014.c,v 1.6 2001-03-19 15:58:40 afr Exp $\n *\n */\n#define S1014\n\n#include \"sislP.h\"\n\n/*\n*  Forward declarations.\n*  ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   c_a_f_s9corr(double [],double,double,double,double,double,double);\nstatic\nvoid\n   c_a_f_s9dir(double *,double *,double *,double [],double [],double [],int);\n#else\nstatic void c_a_f_s9corr();\nstatic void c_a_f_s9dir();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1014(SISLCurve *pc1,double circ_cen[],double circ_rad,\n\t   double aepsge,double eps1[],double eps2[],double aradius,\n\t   double *parpt1, double *parpt2, double center[],int *jstat)\n#else\nvoid s1014(pc1,circ_cen,circ_rad,aepsge,eps1,eps2,aradius,\n\t\t  parpt1,parpt2,center,jstat)\n     SISLCurve  *pc1;\n     double circ_cen[];\n     double circ_rad;\n     double aepsge;\n     double eps1[];\n     double eps2[];\n     double aradius;\n     double *parpt1;\n     double *parpt2;\n     double center[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To iterate to the start and end point of a fillet between\n*              a 2D curve and a circle. The center of the (circular) fillet\n*              is also calculated.\n*\n* INPUT      : pc1      - The first input curve.\n*              circ_cen - 2D center of the circle.\n*              circ_rad - Radius of the circle.\n*              aepsge   - Geometry resolution.\n*              eps1     - 2D point telling that the fillet should be put on\n*                         the side of curve 1 where eps1 is situated.\n*              eps2     - 2D point telling that the fillet should be put on the\n*                         side of the input circle where eps2 is situated.\n*              aradius  - The radius to be used on the fillet.\n*\n* INPUT/OUTPUT :\n*              parpt1   - Parameter value of the point on curve 1 where the\n*                         fillet starts. Input is a guess value for the\n*                         iteration.\n*              parpt2   - Parameter value of the point on the input circle where the\n*                         fillet ends. Input is a guess value for the iteration.\n*\n* OUTPUT     : center   - 2D center of the (circular) fillet.  Space must be\n*                         allocated outside the function.\n*              status   - Status:\n*                              = 1      : converged\n*                              = 2      : diverged\n*                              < 0      : error\n*\n* METHOD     :\n*\n* USE        :\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n*\n* WRITTEN BY : Johannes Kaasa, SI, April 1992.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov. 1994.  Clearified\n*              header and changed the function interface declaration of 'center'.\n*              Initialized 'p1' and 'kstat' and fixed memory leak from 'p1'.\n*\n*********************************************************************\n*/\n{\n\n  int kstat=0;        /* Status variable                                  */\n  int kpos=0;         /* Position of error                                */\n\n  SISLPoint *p1=SISL_NULL; /* SISLPoint form of eps1.                          */\n  double tpar1;       /* Test parameter on curve 1.                       */\n  int kder = 1;       /* Number of derivatives.                           */\n  int kleft1=0;       /* Pointer to the interval in the knot vector.      */\n  double derive[4];   /* Position and derivative on a curve.              */\n  double tdot;        /* Dot product of two vectors.                      */\n  double rad1;        /* Offset radius of curve 1.                        */\n  double rad2;        /* Offset radius of curve 2.                        */\n\n  int kdim = 2;       /* Dimension of the geometry.                       */\n  int knbit;          /* Number of iterations                             */\n  int kdir;           /* Changing direction.                              */\n  double tdelta1;     /* Parameter interval of the curves.                */\n  double tdelta2;     /* Parameter interval of the curves.                */\n  double tdist;       /* Distance between position and origo.             */\n  double td[2];       /* Distances between old and new parameter\n\t\t\t value in the two parameter directions.           */\n  double t1[2];       /* Distances between old and new parameter\n\t\t\t value in the two parameter directions.           */\n  double tdn[2];      /* Distances between old and new parameter\n\t\t\t value in the two parameter directions.           */\n  double tprev;       /* Previous difference between the curves.          */\n  double *sval1=SISL_NULL; /* Value ,first and second derivatie on curve 1     */\n  double *sval2;      /* Value ,first and second derivatie on curve 2     */\n  double *sdiff;      /* Difference between the curves                    */\n  double start1;      /* Start parameter of curve 1.                      */\n  double start2;      /* Start parameter of curve 2.                      */\n  double end1;        /* End parameter of curve 1.                        */\n  double end2;        /* End parameter of curve 2.                        */\n\n  /* Check dimensions */\n\n  if (pc1->idim != 2) goto err105;\n\n  start1 = pc1->et[pc1->ik - 1];\n  start2 = (double)0.0;\n  end1 = pc1->et[pc1->in];\n  end2 = TWOPI;\n\n  /* Calculate the offset radius of the curve. */\n\n  if (!(p1 = newPoint(eps1, 2, 0))) goto err101;\n  s1771(p1, pc1, REL_COMP_RES, start1, end1, *parpt1,\n\t&tpar1, &kstat);\n  if (kstat < 0) goto error;\n\n  s1221(pc1, kder, tpar1, &kleft1, derive, &kstat);\n  if (kstat < 0) goto error;\n\n  tdot = (eps1[0] - derive[0])*(-derive[3])\n                              + (eps1[1] - derive[1])*derive[2];\n  if (tdot > (double)0.)\n    rad1 = aradius;\n  else\n    rad1 = -aradius;\n\n  /* Calculate the offset radius of the circle. */\n\n  tdot = s6dist(eps2, circ_cen, kdim);\n  if (tdot > circ_rad)\n    rad2 = circ_rad + aradius;\n  else\n    rad2 = circ_rad - aradius;\n\n  /* Fetch endpoints and the intervals of parameter interval of curves.  */\n\n  tdelta1 = end1 - start1;\n  tdelta2 = end2 - start2;\n\n  /* Allocate local used memory */\n\n  sval1 = newarray((2*kder+5)*kdim,double);\n  if (sval1 == SISL_NULL) goto err101;\n\n  sval2 = sval1 + (kder+2)*kdim;\n  sdiff = sval2 + (kder+2)*kdim;\n\n  /* Initiate variables.  */\n\n  tprev = (double)HUGE;\n\n  /* Evaluate 0-1.st derivatives of curve and circle. */\n\n  ev_cv_off(pc1, kder, *parpt1, &kleft1, rad1, sval1, &kstat);\n  if (kstat < 0) goto error;\n\n  sval2[0] = circ_cen[0] + rad2*cos(*parpt2);\n  sval2[1] = circ_cen[1] + rad2*sin(*parpt2);\n  sval2[2] = - rad2*sin(*parpt2);\n  sval2[3] = rad2*cos(*parpt2);\n\n  /* Compute the distanse vector and value and the new step. */\n\n  c_a_f_s9dir(&tdist,td,td+1,sdiff,sval1,sval2,kdim);\n\n  /* Correct if we are not inside the parameter intervall. */\n\n  t1[0] = td[0];\n  t1[1] = td[1];\n  c_a_f_s9corr(t1,*parpt1,*parpt2,start1,end1,start2,end2);\n\n  /* Iterate to find the intersection point.  */\n\n  for (knbit = 0; knbit < 50; knbit++)\n    {\n      /* Evaluate 0-1.st derivatives of curve and circle. */\n\n       ev_cv_off(pc1, kder, *parpt1+t1[0], &kleft1, rad1, sval1, &kstat);\n      if (kstat < 0) goto error;\n\n      sval2[0] = circ_cen[0] + rad2*cos(*parpt2+t1[1]);\n      sval2[1] = circ_cen[1] + rad2*sin(*parpt2+t1[1]);\n      sval2[2] = - rad2*sin(*parpt2+t1[1]);\n      sval2[3] = rad2*cos(*parpt2+t1[1]);\n\n      /* Compute the distanse vector and value and the new step. */\n\n      c_a_f_s9dir(&tdist,tdn,tdn+1,sdiff,sval1,sval2,kdim);\n\n      /* Check if the direction of the step have change. */\n\n      kdir = (s6scpr(td,tdn,2) >= DZERO);     /* 0 if changed. */\n\n      /* Ordinary converging. */\n\n      if (tdist < tprev*(double)0.9 || kdir)\n\t{\n\t  *parpt1 += t1[0];\n\t  *parpt2 += t1[1];\n\n          td[0] = tdn[0];\n          td[1] = tdn[1];\n\n\t  /* Correct if we are not inside the parameter intervall. */\n\n\t  t1[0] = td[0];\n\t  t1[1] = td[1];\n\t  c_a_f_s9corr(t1,*parpt1,*parpt2,start1,end1,start2,end2);\n\n          if ( (fabs(t1[0]/tdelta1) <= REL_COMP_RES) &&\n\t      (fabs(t1[1]/tdelta2) <= REL_COMP_RES) ) break;\n\n          tprev = tdist;\n\t}\n\n      /* Not converging, corrigate and try again. */\n\n      else\n\t{\n          t1[0] /= (double)2;\n          t1[1] /= (double)2;\n          knbit--;\n\t}\n    }\n\n  /* Calculate the centerpoint. */\n\n  center[0] = (sval1[0] + sval2[0])/2.;\n  center[1] = (sval1[1] + sval2[1])/2.;\n\n  /* Iteration stopped, test if point founds found is within resolution */\n\n  if (tdist <= aepsge)\n    *jstat = 1;\n  else\n    *jstat = 2;\n\n  /* Iteration completed.  */\n\n\n  goto out;\n\n  /* Error in allocation */\n\n err101: *jstat = -101;\n  s6err(\"s1014\",*jstat,kpos);\n  goto out;\n\n  /* Dimension nmot equal to 2 */\n\n err105:\n  *jstat = -105;\n  s6err(\"s1014\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n  s6err(\"s1014\",*jstat,kpos);\n  goto out;\n\n out:\n  if (sval1 != SISL_NULL) freearray(sval1);\n  if (p1 != SISL_NULL ) freePoint(p1);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   c_a_f_s9corr(double gdn[],double acoef1,double acoef2,\n\t\t   double astart1,double aend1,double astart2,double aend2)\n#else\nstatic void c_a_f_s9corr(gdn,acoef1,acoef2,astart1,aend1,astart2,aend2)\n     double gdn[];\n     double acoef1;\n     double acoef2;\n     double astart1;\n     double aend1;\n     double astart2;\n     double aend2;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To be sure that we are inside the boorder of the\n*              parameter plan. If we are outside clipping is used\n*\t       to corrigate the step value.\n*\n*\n* INPUT      : acoef1  - Coeffisient in the first direction.\n*              acoef2  - Coeffisient in the second direction.\n*              astart1 - The lower boorder in first direction.\n*              aend1   - The higher boorder in first direction.\n*              astart2 - The lower boorder in second direction.\n*              aend2   - The higher boorder in second direction.\n*\n*\n*\n* INPUT/OUTPUT : gdn   - Old and new step value.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/\n{\n  if (acoef1 + gdn[0] < astart1)\n    gdn[0] = astart1 - acoef1;\n  else if (acoef1 + gdn[0] > aend1)\n    gdn[0] = aend1 - acoef1;\n\n  if (acoef2 + gdn[1] < astart2)\n    gdn[1] += TWOPI;\n  else if (acoef2 + gdn[1] > aend2)\n    gdn[1] -= TWOPI;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   c_a_f_s9dir(double *cdist,double *cdiff1,double *cdiff2,\n\t\t  double gdiff[],double eval1[],double eval2[],int idim)\n#else\nstatic void c_a_f_s9dir(cdist,cdiff1,cdiff2,gdiff,eval1,eval2,idim)\n     double *cdist;\n     double *cdiff1;\n     double *cdiff2;\n     double eval1[];\n     double eval2[];\n     double gdiff[];\n     int    idim;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To compute the distance vector and value beetween\n*\t       a points on the first curve and a point on the second\n*\t       curve. And to compute a next step on both curves.\n*\t       This is equivalent to the nearest way to the\n*\t       parameter plan in the tangent plan from a point in the\n*\t       distance surface between two curves.\n*\n*\n* INPUT      : eval1 - Value and derevative in first parameterdirection.\n*              eval2 - Value and derevative in second parameterdirection.\n*\t       idim  - Dimension of space the curves lie in.\n*\n*\n* OUTPUT     : gdiff   - Array to use when computing the differens vector.\n*\t       cdiff1  - Relative parameter value in intersection\n*                        point in first direction.\n*              cdiff2  - Relative parameter value in intersection\n*                        point in second direction.\n*              cdist   - The value to the point in the distance surface.\n*\n*\n* METHOD     : The method is to compute the parameter distance to the points\n*\t       on both tangents which is closest to each other.\n*\t       The differens vector beetween these points are orthogonal\n*\t       to both tangents. If the distance vector beetween the two\n*\t       points on the curve is \"diff\" and the two derevativ vectors\n*\t       are \"der1\" and \"der2\", and the two wanted parameter distance\n*\t       are \"dt1\" and \"dt2\", then we get the following system of\n*\t       equations:\n*\t\t <dt1*der1+dist-dt2*der2,der2> = 0\n*\t\t <dt1*der1+dist-dt2*der2,der1> = 0\n*\t       This is futher:\n*\n*\t\t | -<der1,der2>   <der2,der2> |  | dt1 |   | <dist,der2> |\n*\t\t |                            |  |     | = |             |\n*\t\t | -<der1,der1>   <der1,der2> |  | dt2 |   | <dist,der1> |\n*\n*\t       The solution of this matrix equation is the\n*\t       following function.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/\n{\n  int kstat;\t\t           /* Local status variable. */\n  register double tdet;\t\t   /* Determinant */\n  register double t1,t2,t3,t4,t5;  /* Variables in equation system */\n\n  /* Computing the different vector */\n\n  s6diff(eval1,eval2,idim,gdiff);\n\n  /* Computing the length of the different vector. */\n\n  *cdist = s6length(gdiff,idim,&kstat);\n\n  t1 =  s6scpr(eval1+idim,eval1+idim,idim);\n  t2 =  s6scpr(eval1+idim,eval2+idim,idim);\n  t3 =  s6scpr(eval2+idim,eval2+idim,idim);\n  t4 =  s6scpr(gdiff,eval1+idim,idim);\n  t5 =  s6scpr(gdiff,eval2+idim,idim);\n\n  /* Computing the determinant. */\n\n  tdet = t2*t2 - t1*t3;\n\n  if (DEQUAL(tdet,DZERO))\n    {\n      *cdiff1 = DZERO;\n      *cdiff2 = DZERO;\n    }\n  else\n    {\n      /* Using Cramer's rule to find the solution of the system. */\n\n      *cdiff1 =  (t4*t3 - t5*t2)/tdet;\n      *cdiff2 =  (t2*t4 - t1*t5)/tdet;\n    }\n}\n"
  },
  {
    "path": "src/s1015.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1015.c,v 1.4 2001-03-19 15:58:40 afr Exp $\n *\n */\n#define S1015\n\n#include \"sislP.h\"\n\n/*\n*  Forward declarations.\n*  ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\nc_c_f_s9corr(double [],double,double,double,double,double,double);\nstatic\nvoid\nc_c_f_s9dir(double *,double *,double *,double [],double [],double [],int);\n#else\nstatic void c_c_f_s9corr();\nstatic void c_c_f_s9dir();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      s1015(SISLCurve *pc1,SISLCurve *pc2,double aepsge,\n\t   double eps1[],double eps2[],double aradius,double *parpt1,\n\t   double *parpt2,double center[],int *jstat)\n#else\nvoid s1015(pc1,pc2,aepsge,eps1,eps2,aradius,parpt1,parpt2,\n           center,jstat)\n     SISLCurve  *pc1;\n     SISLCurve  *pc2;\n     double aepsge;\n     double eps1[];\n     double eps2[];\n     double aradius;\n     double *parpt1;\n     double *parpt2;\n     double center[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To iterate to the start and end point of a fillet between\n*              two 2D curves. The center of the (circular) fillet is also\n*              calculated.\n*\n* INPUT      : pc1    - The first 2D input curve.\n*              pc2    - The second 2D input curve.\n*              aepsge - Geometry resolution.\n*              eps1   - 2D point telling that the fillet should be put on\n*                       the side of curve 1 where eps1 is situated.\n*              eps2   - 2D point telling that the fillet should be put on the\n*                       side of curve 2 where eps2 is situated.\n*              aradius - The radius to be used on the fillet.\n*\n* INPUT/OUTPUT :\n*              parpt1 - Parameter value of the point on curve 1 where the\n*                       fillet starts. Input is a guess value for the iteration.\n*              parpt2 - Parameter value of the point on curve 2 where the\n*                       fillet ends. Input is a guess value for the iteration.\n*\n* OUTPUT     : center - 2D center of the (circular) fillet.  Space must be\n*                       allocated outside the function.\n*              status - Status:\n*                              = 1      : converged\n*                              = 2      : diverged\n*                              < 0      : error\n*\n* METHOD     :\n*\n* USE        :\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n*\n* WRITTEN BY : Johannes Kaasa, SI, April 1992.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov. 1994.  Clearified\n*              header and changed the function interface declaration of 'center'\n*              - must now be allocated outside the function (was memory overwrite).\n*              Initialized 'p1', 'p2' and 'kstat' and fixed memory leak from\n*              'p1' and 'p2'.\n*\n*********************************************************************\n*/\n{\n\n  int kstat=0;        /* Status variable                                  */\n  int kpos=0;         /* Position of error                                */\n\n  SISLPoint *p1=SISL_NULL; /* SISLPoint form of eps1.                          */\n  SISLPoint *p2=SISL_NULL; /* SISLPoint form of eps2.                          */\n  double tpar1;       /* Test parameter on curve 1.                       */\n  double tpar2;       /* Test parameter on curve 2.                       */\n  int kder = 1;       /* Number of derivatives.                           */\n  int kleft1=0;       /* Pointer to the interval in the knot vector.      */\n  int kleft2=0;       /* Pointer to the interval in the knot vector.      */\n  double derive[4];   /* Position and derivative on a curve.              */\n  double tdot;        /* Dot product of two vectors.                      */\n  double rad1;        /* Offset radius of curve 1.                        */\n  double rad2;        /* Offset radius of curve 2.                        */\n\n  int kdim = 2;       /* Dimension of the geometry.                       */\n  int knbit;          /* Number of iterations                             */\n  int kdir;           /* Changing direction.                              */\n  double tdelta1;     /* Parameter interval of the curves.                */\n  double tdelta2;     /* Parameter interval of the curves.                */\n  double tdist;       /* Distance between position and origo.             */\n  double td[2];       /* Distances between old and new parameter\n\t\t\t value in the two parameter directions.           */\n  double t1[2];       /* Distances between old and new parameter\n\t\t\t value in the two parameter directions.           */\n  double tdn[2];      /* Distances between old and new parameter\n\t\t\t value in the two parameter directions.           */\n  double tprev;       /* Previous difference between the curves.          */\n  double *sval1=SISL_NULL; /* Value ,first and second derivatie on curve 1     */\n  double *sval2;      /* Value ,first and second derivatie on curve 2     */\n  double *sdiff;      /* Difference between the curves                    */\n  double start1;      /* Start parameter of curve 1.                      */\n  double start2;      /* Start parameter of curve 2.                      */\n  double end1;        /* End parameter of curve 1.                        */\n  double end2;        /* End parameter of curve 2.                        */\n\n  /* Check dimensions */\n\n  if (pc1->idim != 2 || pc2->idim != 2) goto err105;\n\n  start1 = pc1->et[pc1->ik - 1];\n  start2 = pc2->et[pc2->ik - 1];\n  end1 = pc1->et[pc1->in];\n  end2 = pc2->et[pc2->in];\n\n  /* Calculate the offset radius of curve 1. */\n\n  if (!(p1 = newPoint(eps1, 2, 0))) goto err101;\n  s1771(p1, pc1, REL_COMP_RES, start1, end1, *parpt1,\n\t&tpar1, &kstat);\n  if (kstat < 0) goto error;\n\n  s1221(pc1, kder, tpar1, &kleft1, derive, &kstat);\n  if (kstat < 0) goto error;\n\n  tdot = (eps1[0] - derive[0])*(-derive[3])\n                              + (eps1[1] - derive[1])*derive[2];\n  if (tdot > (double)0.)\n    rad1 = aradius;\n  else\n    rad1 = -aradius;\n\n  /* Calculate the offset radius of curve 2. */\n\n  if (!(p2 = newPoint(eps2, 2, 0))) goto err101;\n  s1771(p2, pc2, REL_COMP_RES, start2, end2, *parpt2,\n\t&tpar2, &kstat);\n  if (kstat < 0) goto error;\n\n  s1221(pc2, kder, tpar2, &kleft2, derive, &kstat);\n  if (kstat < 0) goto error;\n\n  tdot = (eps2[0] - derive[0])*(-derive[3])\n                              + (eps2[1] - derive[1])*derive[2];\n  if (tdot > (double)0.)\n    rad2 = aradius;\n  else\n    rad2 = -aradius;\n\n  /* Fetch endpoints and the intervals of parameter interval of curves.  */\n\n  tdelta1 = end1 - start1;\n  tdelta2 = end2 - start2;\n\n  /* Allocate local used memory */\n\n  sval1 = newarray((2*kder+5)*kdim,double);\n  if (sval1 == SISL_NULL) goto err101;\n\n  sval2 = sval1 + (kder+2)*kdim;\n  sdiff = sval2 + (kder+2)*kdim;\n\n  /* Initiate variables.  */\n\n  tprev = (double)HUGE;\n\n  /* Evaluate 0-1.st derivatives of both curves */\n\n  ev_cv_off(pc1, kder, *parpt1, &kleft1, rad1, sval1, &kstat);\n  if (kstat < 0) goto error;\n\n  ev_cv_off(pc2, kder, *parpt2, &kleft2, rad2, sval2, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Compute the distanse vector and value and the new step. */\n\n  c_c_f_s9dir(&tdist,td,td+1,sdiff,sval1,sval2,kdim);\n\n  /* Correct if we are not inside the parameter intervall. */\n\n  t1[0] = td[0];\n  t1[1] = td[1];\n  c_c_f_s9corr(t1,*parpt1,*parpt2,start1,end1,start2,end2);\n\n  /* Iterate to find the intersection point.  */\n\n  for (knbit = 0; knbit < 50; knbit++)\n    {\n      /* Evaluate 0-1.st derivatives of both curves */\n\n       ev_cv_off(pc1, kder, *parpt1+t1[0], &kleft1, rad1, sval1, &kstat);\n      if (kstat < 0) goto error;\n\n      ev_cv_off(pc2, kder, *parpt2+t1[1], &kleft2, rad2, sval2, &kstat);\n      if (kstat < 0) goto error;\n\n      /* Compute the distanse vector and value and the new step. */\n\n      c_c_f_s9dir(&tdist,tdn,tdn+1,sdiff,sval1,sval2,kdim);\n\n      /* Check if the direction of the step have change. */\n\n      kdir = (s6scpr(td,tdn,2) >= DZERO);     /* 0 if changed. */\n\n      /* Ordinary converging. */\n\n      if (tdist < tprev*(double)0.9 || kdir)\n\t{\n\t  *parpt1 += t1[0];\n\t  *parpt2 += t1[1];\n\n          td[0] = tdn[0];\n          td[1] = tdn[1];\n\n\t  /* Correct if we are not inside the parameter intervall. */\n\n\t  t1[0] = td[0];\n\t  t1[1] = td[1];\n\t  c_c_f_s9corr(t1,*parpt1,*parpt2,start1,end1,start2,end2);\n\n          if ( (fabs(t1[0]/tdelta1) <= REL_COMP_RES) &&\n\t      (fabs(t1[1]/tdelta2) <= REL_COMP_RES) ) break;\n\n          tprev = tdist;\n\t}\n\n      /* Not converging, corrigate and try again. */\n\n      else\n\t{\n          t1[0] /= (double)2;\n          t1[1] /= (double)2;\n          knbit--;\n\t}\n    }\n\n  /* Calculate the centerpoint. */\n\n  center[0] = (sval1[0] + sval2[0])/2.;\n  center[1] = (sval1[1] + sval2[1])/2.;\n\n  /* Iteration stopped, test if point founds found is within resolution */\n\n  if (tdist <= aepsge)\n    *jstat = 1;\n  else\n    *jstat = 2;\n\n  /* Iteration completed.  */\n\n\n  goto out;\n\n  /* Error in allocation */\n\n err101: *jstat = -101;\n  s6err(\"s1015\",*jstat,kpos);\n  goto out;\n\n  /* Dimension nmot equal to 2 */\n\n err105:\n  *jstat = -105;\n  s6err(\"s1015\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n  s6err(\"s1015\",*jstat,kpos);\n  goto out;\n\n out:\n  if (sval1 != SISL_NULL) freearray(sval1);\n  if ( p1 != SISL_NULL )  freePoint(p1);\n  if ( p2 != SISL_NULL )  freePoint(p2);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   c_c_f_s9corr(double gdn[],double acoef1,double acoef2,\n\t\t   double astart1,double aend1,double astart2,double aend2)\n#else\nstatic void c_c_f_s9corr(gdn,acoef1,acoef2,astart1,aend1,astart2,aend2)\n     double gdn[];\n     double acoef1;\n     double acoef2;\n     double astart1;\n     double aend1;\n     double astart2;\n     double aend2;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To be sure that we are inside the boorder of the\n*              parameter plan. If we are outside clipping is used\n*\t       to corrigate the step value.\n*\n*\n* INPUT      : acoef1  - Coeffisient in the first direction.\n*              acoef2  - Coeffisient in the second direction.\n*              astart1 - The lower boorder in first direction.\n*              aend1   - The higher boorder in first direction.\n*              astart2 - The lower boorder in second direction.\n*              aend2   - The higher boorder in second direction.\n*\n*\n*\n* INPUT/OUTPUT : gdn   - Old and new step value.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/\n{\n  if (acoef1 + gdn[0] < astart1)\n    gdn[0] = astart1 - acoef1;\n  else if (acoef1 + gdn[0] > aend1)\n    gdn[0] = aend1 - acoef1;\n\n  if (acoef2 + gdn[1] < astart2)\n    gdn[1] = astart2 - acoef2;\n  else if (acoef2 + gdn[1] > aend2)\n    gdn[1] = aend2 - acoef2;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   c_c_f_s9dir(double *cdist,double *cdiff1,double *cdiff2,\n\t\t  double gdiff[],double eval1[],double eval2[],int idim)\n#else\nstatic void c_c_f_s9dir(cdist,cdiff1,cdiff2,gdiff,eval1,eval2,idim)\n     double *cdist;\n     double *cdiff1;\n     double *cdiff2;\n     double eval1[];\n     double eval2[];\n     double gdiff[];\n     int    idim;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To compute the distance vector and value beetween\n*\t       a points on the first curve and a point on the second\n*\t       curve. And to compute a next step on both curves.\n*\t       This is equivalent to the nearest way to the\n*\t       parameter plan in the tangent plan from a point in the\n*\t       distance surface between two curves.\n*\n*\n* INPUT      : eval1 - Value and derevative in first parameterdirection.\n*              eval2 - Value and derevative in second parameterdirection.\n*\t       idim  - Dimension of space the curves lie in.\n*\n*\n* OUTPUT     : gdiff   - Array to use when computing the differens vector.\n*\t       cdiff1  - Relative parameter value in intersection\n*                        point in first direction.\n*              cdiff2  - Relative parameter value in intersection\n*                        point in second direction.\n*              cdist   - The value to the point in the distance surface.\n*\n*\n* METHOD     : The method is to compute the parameter distance to the points\n*\t       on both tangents which is closest to each other.\n*\t       The differens vector beetween these points are orthogonal\n*\t       to both tangents. If the distance vector beetween the two\n*\t       points on the curve is \"diff\" and the two derevativ vectors\n*\t       are \"der1\" and \"der2\", and the two wanted parameter distance\n*\t       are \"dt1\" and \"dt2\", then we get the following system of\n*\t       equations:\n*\t\t <dt1*der1+dist-dt2*der2,der2> = 0\n*\t\t <dt1*der1+dist-dt2*der2,der1> = 0\n*\t       This is futher:\n*\n*\t\t | -<der1,der2>   <der2,der2> |  | dt1 |   | <dist,der2> |\n*\t\t |                            |  |     | = |             |\n*\t\t | -<der1,der1>   <der1,der2> |  | dt2 |   | <dist,der1> |\n*\n*\t       The solution of this matrix equation is the\n*\t       following function.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/\n{\n  int kstat;\t\t           /* Local status variable. */\n  register double tdet;\t\t   /* Determinant */\n  register double t1,t2,t3,t4,t5;  /* Variables in equation system */\n\n  /* Computing the different vector */\n\n  s6diff(eval1,eval2,idim,gdiff);\n\n  /* Computing the length of the different vector. */\n\n  *cdist = s6length(gdiff,idim,&kstat);\n\n  t1 =  s6scpr(eval1+idim,eval1+idim,idim);\n  t2 =  s6scpr(eval1+idim,eval2+idim,idim);\n  t3 =  s6scpr(eval2+idim,eval2+idim,idim);\n  t4 =  s6scpr(gdiff,eval1+idim,idim);\n  t5 =  s6scpr(gdiff,eval2+idim,idim);\n\n  /* Computing the determinant. */\n\n  tdet = t2*t2 - t1*t3;\n\n  if (DEQUAL(tdet,DZERO))\n    {\n      *cdiff1 = DZERO;\n      *cdiff2 = DZERO;\n    }\n  else\n    {\n      /* Using Cramer's rule to find the solution of the system. */\n\n      *cdiff1 =  (t4*t3 - t5*t2)/tdet;\n      *cdiff2 =  (t2*t4 - t1*t5)/tdet;\n    }\n}\n"
  },
  {
    "path": "src/s1016.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1016.c,v 1.3 2001-03-19 15:58:40 afr Exp $\n *\n */\n#define S1016\n\n#include \"sislP.h\"\n\n/*\n*  Forward declarations.\n*  ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   c_l_f_s9corr(double [],double,double,double);\nstatic\nvoid\n   c_l_f_s9dir(double *,double *,double *,double [],double [],double [],int);\n#else\nstatic void c_l_f_s9corr();\nstatic void c_l_f_s9dir();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      s1016(SISLCurve *pc1,double point[],double normal[],\n\t   double aepsge,double eps1[],double eps2[],double aradius,\n\t   double *parpt1,double *parpt2,double center[],int *jstat)\n#else\nvoid s1016(pc1,point,normal,aepsge,eps1,eps2,aradius,\n\t\t  parpt1,parpt2,center,jstat)\n     SISLCurve  *pc1;\n     double point[];\n     double normal[];\n     double aepsge;\n     double eps1[];\n     double eps2[];\n     double aradius;\n     double *parpt1;\n     double *parpt2;\n     double center[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To iterate to the start and end point of a fillet between\n*              a 2D curve and a 2D line. The center of the (circular) fillet\n*              is also calculated.\n*\n* INPUT      : pc1      - The 2D input curve.\n*              point    - 2D point on the line.\n*              normal   - 2D normal to the line.\n*              aepsge   - Geometry resolution.\n*              eps1     - 2D point telling that the fillet should be put on\n*                         the side of curve 1 where eps1 is situated.\n*              eps2     - 2D point telling that the fillet should be put on the\n*                         side of curve 2 where eps2 is situated.\n*              aradius  - The radius to be used on the fillet.\n*\n* INPUT/OUTPUT :\n*              parpt1   - Parameter value of the point on curve 1 where the\n*                         fillet starts. Input is a guess value for the\n*                         iteration.\n*              parpt2   - Parameter value of the point on the line where the\n*                         fillet ends. Input is a guess value for the iteration.\n*\n* OUTPUT     : center   - 2D center of the (circular) fillet.  Space must be\n*                         allocated outside the function.\n*              status   - Status:\n*                              = 1      : converged\n*                              = 2      : diverged\n*                              < 0      : error\n*\n* METHOD     :\n*\n* USE        :\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n*\n* WRITTEN BY : Johannes Kaasa, SI, April 1992.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov. 1994.  Clearified\n*              header and changed the function interface declaration of 'center'\n*              - must now be allocated outside the function (was memory overwrite).\n*              Initialized 'p1' and 'kstat' and fixed memory leak from 'p1'.\n*\n*********************************************************************\n*/\n{\n\n  int kstat=0;        /* Status variable                                  */\n  int kpos=0;         /* Position of error                                */\n\n  SISLPoint *p1=SISL_NULL; /* SISLPoint form of eps1.                          */\n  double tpar1;       /* Test parameter on curve 1.                       */\n  int kder = 1;       /* Number of derivatives.                           */\n  int kleft1=0;       /* Pointer to the interval in the knot vector.      */\n  double derive[4];   /* Position and derivative on a curve.              */\n  double tvec[2];     /* Distance vector.                                 */\n  double tdot;        /* Dot product of two vectors.                      */\n  double rad1;        /* Offset radius of curve 1.                        */\n  double rad2[2];     /* Offset vector of the line.                       */\n  double tang[2];     /* Tangent along the line.                          */\n\n  int kdim = 2;       /* Dimension of the geometry.                       */\n  int knbit;          /* Number of iterations                             */\n  int kdir;           /* Changing direction.                              */\n  double tdelta1;     /* Parameter interval of the curves.                */\n  double tdist;       /* Distance between position and origo.             */\n  double td[2];       /* Distances between old and new parameter\n\t\t\t value in the two parameter directions.           */\n  double t1[2];       /* Distances between old and new parameter\n\t\t\t value in the two parameter directions.           */\n  double tdn[2];      /* Distances between old and new parameter\n\t\t\t value in the two parameter directions.           */\n  double tprev;       /* Previous difference between the curves.          */\n  double *sval1=SISL_NULL; /* Value ,first and second derivatie on curve 1     */\n  double *sval2;      /* Value ,first and second derivatie on curve 2     */\n  double *sdiff;      /* Difference between the curves                    */\n  double start1;      /* Start parameter of curve 1.                      */\n  double end1;        /* End parameter of curve 1.                        */\n\n  /* Check dimensions */\n\n  if (pc1->idim != 2) goto err105;\n\n  start1 = pc1->et[pc1->ik - 1];\n  end1 = pc1->et[pc1->in];\n\n  /* Calculate the offset radius of the curve. */\n\n  if (!(p1 = newPoint(eps1, 2, 0))) goto err101;\n  s1771(p1, pc1, REL_COMP_RES, start1, end1, *parpt1,\n\t&tpar1, &kstat);\n  if (kstat < 0) goto error;\n\n  s1221(pc1, kder, tpar1, &kleft1, derive, &kstat);\n  if (kstat < 0) goto error;\n\n  tdot = (eps1[0] - derive[0])*(-derive[3])\n                              + (eps1[1] - derive[1])*derive[2];\n  if (tdot > (double)0.)\n    rad1 = aradius;\n  else\n    rad1 = -aradius;\n\n  /* Calculate the offset vector of the line. */\n\n  s6norm(normal, kdim, rad2, &kstat);\n  tang[0] = rad2[1];\n  tang[1] = -rad2[0];\n  if (kstat < 0) goto error;\n  s6diff(eps2, point, kdim, tvec);\n  tdot = s6scpr(tvec, normal, kdim);\n  if (tdot > (double)0.0)\n    {\n      rad2[0] *= aradius;\n      rad2[1] *= aradius;\n    }\n  else\n    {\n      rad2[0] *= -aradius;\n      rad2[1] *= -aradius;\n    }\n\n  /* Fetch endpoints and the intervals of parameter interval of curves.  */\n\n  tdelta1 = end1 - start1;\n\n  /* Allocate local used memory */\n\n  sval1 = newarray((2*kder+5)*kdim,double);\n  if (sval1 == SISL_NULL) goto err101;\n\n  sval2 = sval1 + (kder+2)*kdim;\n  sdiff = sval2 + (kder+2)*kdim;\n\n  /* Initiate variables.  */\n\n  tprev = (double)HUGE;\n\n  /* Evaluate 0-1.st derivatives of curve and circle. */\n\n  ev_cv_off(pc1, kder, *parpt1, &kleft1, rad1, sval1, &kstat);\n  if (kstat < 0) goto error;\n\n  sval2[0] = point[0] + rad2[0] + (*parpt2)*tang[0];\n  sval2[1] = point[1] + rad2[1] + (*parpt2)*tang[1];\n  sval2[2] = tang[0];\n  sval2[3] = tang[1];\n\n  /* Compute the distanse vector and value and the new step. */\n\n  c_l_f_s9dir(&tdist,td,td+1,sdiff,sval1,sval2,kdim);\n\n  /* Correct if we are not inside the parameter intervall. */\n\n  t1[0] = td[0];\n  t1[1] = td[1];\n  c_l_f_s9corr(t1,*parpt1,start1,end1);\n\n  /* Iterate to find the intersection point.  */\n\n  for (knbit = 0; knbit < 50; knbit++)\n    {\n      /* Evaluate 0-1.st derivatives of curve and circle. */\n\n       ev_cv_off(pc1, kder, *parpt1+t1[0], &kleft1, rad1, sval1, &kstat);\n      if (kstat < 0) goto error;\n\n      sval2[0] = point[0] + rad2[0] + (*parpt2+t1[1])*tang[0];\n      sval2[1] = point[1] + rad2[1] + (*parpt2+t1[1])*tang[1];\n      sval2[2] = tang[0];\n      sval2[3] = tang[1];\n\n      /* Compute the distanse vector and value and the new step. */\n\n      c_l_f_s9dir(&tdist,tdn,tdn+1,sdiff,sval1,sval2,kdim);\n\n      /* Check if the direction of the step have change. */\n\n      kdir = (s6scpr(td,tdn,2) >= DZERO);     /* 0 if changed. */\n\n      /* Ordinary converging. */\n\n      if (tdist < tprev*(double)0.9 || kdir)\n\t{\n\t  *parpt1 += t1[0];\n\t  *parpt2 += t1[1];\n\n          td[0] = tdn[0];\n          td[1] = tdn[1];\n\n\t  /* Correct if we are not inside the parameter intervall. */\n\n\t  t1[0] = td[0];\n\t  t1[1] = td[1];\n\t  c_l_f_s9corr(t1,*parpt1,start1,end1);\n\n          if ( (fabs(t1[0]/tdelta1) <= REL_COMP_RES) &&\n\t      (fabs(t1[1]) <= REL_COMP_RES) )  break;\n\n          tprev = tdist;\n\t}\n\n      /* Not converging, corrigate and try again. */\n\n      else\n\t{\n          t1[0] /= (double)2;\n          t1[1] /= (double)2;\n          knbit--;\n\t}\n    }\n\n  /* Calculate the centerpoint. */\n\n  center[0] = (sval1[0] + sval2[0])/2.;\n  center[1] = (sval1[1] + sval2[1])/2.;\n\n  /* Iteration stopped, test if point founds found is within resolution */\n\n  if (tdist <= aepsge)\n    *jstat = 1;\n  else\n    *jstat = 2;\n\n  /* Iteration completed.  */\n\n\n  goto out;\n\n  /* Error in allocation */\n\n err101: *jstat = -101;\n  s6err(\"s1016\",*jstat,kpos);\n  goto out;\n\n  /* Dimension nmot equal to 2 */\n\n err105:\n  *jstat = -105;\n  s6err(\"s1016\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n  s6err(\"s1016\",*jstat,kpos);\n  goto out;\n\n out:\n  if (sval1 != SISL_NULL) freearray(sval1);\n  if ( p1 != SISL_NULL )  freePoint(p1);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   c_l_f_s9corr(double gdn[],double acoef1,\n\t\t   double astart1,double aend1)\n#else\nstatic void c_l_f_s9corr(gdn,acoef1,astart1,aend1)\n     double gdn[];\n     double acoef1;\n     double astart1;\n     double aend1;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To be sure that we are inside the boorder of the\n*              parameter plan. If we are outside clipping is used\n*\t       to corrigate the step value.\n*\n*\n* INPUT      : acoef1  - Coeffisient in the first direction.\n*              astart1 - The lower boorder in first direction.\n*              aend1   - The higher boorder in first direction.\n*\n*\n*\n* INPUT/OUTPUT : gdn   - Old and new step value.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/\n{\n  if (acoef1 + *gdn < astart1)\n    *gdn = astart1 - acoef1;\n  else if (acoef1 + *gdn > aend1)\n    *gdn = aend1 - acoef1;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   c_l_f_s9dir(double *cdist,double *cdiff1,double *cdiff2,\n\t\t  double gdiff[],double eval1[],double eval2[],int idim)\n#else\nstatic void c_l_f_s9dir(cdist,cdiff1,cdiff2,gdiff,eval1,eval2,idim)\n     double *cdist;\n     double *cdiff1;\n     double *cdiff2;\n     double eval1[];\n     double eval2[];\n     double gdiff[];\n     int    idim;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To compute the distance vector and value beetween\n*\t       a points on the first curve and a point on the second\n*\t       curve. And to compute a next step on both curves.\n*\t       This is equivalent to the nearest way to the\n*\t       parameter plan in the tangent plan from a point in the\n*\t       distance surface between two curves.\n*\n*\n* INPUT      : eval1 - Value and derevative in first parameterdirection.\n*              eval2 - Value and derevative in second parameterdirection.\n*\t       idim  - Dimension of space the curves lie in.\n*\n*\n* OUTPUT     : gdiff   - Array to use when computing the differens vector.\n*\t       cdiff1  - Relative parameter value in intersection\n*                        point in first direction.\n*              cdiff2  - Relative parameter value in intersection\n*                        point in second direction.\n*              cdist   - The value to the point in the distance surface.\n*\n*\n* METHOD     : The method is to compute the parameter distance to the points\n*\t       on both tangents which is closest to each other.\n*\t       The differens vector beetween these points are orthogonal\n*\t       to both tangents. If the distance vector beetween the two\n*\t       points on the curve is \"diff\" and the two derevativ vectors\n*\t       are \"der1\" and \"der2\", and the two wanted parameter distance\n*\t       are \"dt1\" and \"dt2\", then we get the following system of\n*\t       equations:\n*\t\t <dt1*der1+dist-dt2*der2,der2> = 0\n*\t\t <dt1*der1+dist-dt2*der2,der1> = 0\n*\t       This is futher:\n*\n*\t\t | -<der1,der2>   <der2,der2> |  | dt1 |   | <dist,der2> |\n*\t\t |                            |  |     | = |             |\n*\t\t | -<der1,der1>   <der1,der2> |  | dt2 |   | <dist,der1> |\n*\n*\t       The solution of this matrix equation is the\n*\t       following function.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/\n{\n  int kstat;\t\t           /* Local status variable. */\n  register double tdet;\t\t   /* Determinant */\n  register double t1,t2,t3,t4,t5;  /* Variables in equation system */\n\n  /* Computing the different vector */\n\n  s6diff(eval1,eval2,idim,gdiff);\n\n  /* Computing the length of the different vector. */\n\n  *cdist = s6length(gdiff,idim,&kstat);\n\n  t1 =  s6scpr(eval1+idim,eval1+idim,idim);\n  t2 =  s6scpr(eval1+idim,eval2+idim,idim);\n  t3 =  s6scpr(eval2+idim,eval2+idim,idim);\n  t4 =  s6scpr(gdiff,eval1+idim,idim);\n  t5 =  s6scpr(gdiff,eval2+idim,idim);\n\n  /* Computing the determinant. */\n\n  tdet = t2*t2 - t1*t3;\n\n  if (DEQUAL(tdet,DZERO))\n    {\n      *cdiff1 = DZERO;\n      *cdiff2 = DZERO;\n    }\n  else\n    {\n      /* Using Cramer's rule to find the solution of the system. */\n\n      *cdiff1 =  (t4*t3 - t5*t2)/tdet;\n      *cdiff2 =  (t2*t4 - t1*t5)/tdet;\n    }\n}\n"
  },
  {
    "path": "src/s1017.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1017.c,v 1.4 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1017\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1017 (SISLCurve * pc, SISLCurve ** rc, double apar, int *jstat)\n#else\nvoid\ns1017 (pc, rc, apar, jstat)\n     int *jstat;\n     double apar;\n     SISLCurve *pc, **rc;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Insert a given knot into the description of\n*              a B-spline curve.\n* NOTE       : When the curve is periodic, the input parameter value\n*              must lie in the HALFOPEN [et[kk-1], et[kn), the function\n*              will automatically update the extra knots and\n*              coeffisients.\n*              rcnew->in is still eq to pc->in + 1!\n*\n*\n* INPUT      : pc        - SISLCurve to be refined.\n*              apar      - Parameter values of knot to be s1017ed.\n*\n*\n*\n* OUTPUT     : rc        - The new, refined curve.\n*              jstat     - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newCurve  - Allocate space for a new curve-object.\n*              freeCurve - Free space occupied by given curve-object.\n*              S1701.C   - Making the knot-s1017en-transformation matrix.\n*              s1017knots in periodic case.\n* WRITTEN BY : Arne Laksaa, SI, 88-11.\n* CHANGED BY : Ulf J. Krystad, SI, 92-01\n*              Treatment of periodic curves.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov. 1994.  Undefined\n*              symbol 's1017knots()' changed to 's1018()'. Closed ('cuopen'\n*              flag=0) and 'ikind' flag are now handled correctly. Fixed memory\n*              problem for rationals.  Cleaned up a bit.\n*\n**********************************************************************/\n{\n\n  int kstat;\t\t\t/* Local status variable.                     */\n  int kmy;\t\t\t/* An index to the knot-vector.               */\n  int kpl, kfi, kla;\t\t/* To posisjon elements in trans.-matrix.     */\n  int kk = pc->ik;\t\t/* Order of the input curve.                  */\n  int kn = pc->in;\t\t/* Number of the vertices in input curve.     */\n  int kdim = pc->idim;\t\t/* Dimension of the space in whice curve lies.*/\n  int kn1;\t\t\t/* Number of vertices in the new curve.       */\n  int kch;\t\t\t/* First vertice to be changes.               */\n  int knum;\t\t\t/* Number of knots less and equal than\n                                   the intersection point.                    */\n  int ki;\t\t\t/* Control variable in loop.                  */\n  int kj, kj1, kj2;\t\t/* Control variable in loop.                  */\n  double *s1;           \t/* Pointers used in loop.                     */\n  double *st = SISL_NULL;\t\t/* The first new knot-vector.                 */\n  double *salfa = SISL_NULL;\t\t/* A line of the trans.-matrix.               */\n  double *scoef = SISL_NULL;\t\t/* The first new vertice.                     */\n  double *sp;\t\t\t/* Help array for use in s1701.               */\n  double *ecoef;                /* Pointer to input curve ecoef/rcoef vector. */\n  SISLCurve *qc = SISL_NULL;\t\t/* Pointer to new curve-object.               */\n\n\n\n  /* Make sure the returned pointer is valid. */\n\n  *rc = SISL_NULL;\n\n\n  /* Check that we have a curve. */\n\n  if (!pc)\n    goto err150;\n\n\n  /* Find the number of vertices in the new curve. */\n\n  kn1 = kn + 1;\n\n  if ( kn1 <= 0 )\n    goto err150;\n\n\n\n  /* Periodicity treatment -------------------------- */\n  if (pc->cuopen == SISL_CRV_PERIODIC)\n    {\n      s1018(pc, &apar, 1, rc, &kstat);\n      if (kstat < 0)\n\tgoto err153;\n      goto out;\n    }\n\n\n\n  /* Check that the intersection point is an interior point. */\n\n  if (apar < *(pc->et) || apar > *(pc->et + kn + kk - 1))\n    goto err158;\n\n\n  /* Check if the curve is rational.  */\n\n  if (pc->ikind == 2 || pc->ikind == 4)\n  {\n    ecoef = pc->rcoef;\n    kdim++;\n  }\n  else\n    ecoef = pc->ecoef;\n\n\n  /* Allocate space for the kk elements which may not be zero in eache\n     line of the basic transformation matrix and for a help array of\n     kk elements.*/\n\n  if ((salfa = newarray (2 * kk, double)) == SISL_NULL)\n    goto err101;\n\n  sp = salfa + kk;\n\n  /* Find the number of the knots which is smaller or like\n     the intersection point.*/\n\n  s1 = pc->et;\n\n  if (apar > pc->et[0] && apar < pc->et[kn + kk - 1])\n    {\n      /* Using binary search*/\n      kj1 = 0;\n      kj2 = kk + kn - 1;\n      knum = (kj1 + kj2) / 2;\n      while (knum != kj1)\n\t{\n\t  if (s1[knum] < apar)\n\t    kj1 = knum;\n\t  else\n\t    kj2 = knum;\n\t  knum = (kj1 + kj2) / 2;\n\t}\n      knum++;\t\t\t/* The smaller knots. */\n\n      while (s1[knum] == apar)\n\t/* The knots that are equal to the intersection point. */\n\tknum++;\n    }\n  else if (apar == pc->et[0])\n    {\n      knum = 0;\n      while (s1[knum] == apar)\n\t/* The knots that are equal to the intersection point. */\n\tknum++;\n    }\n  else if (apar == pc->et[kn + kk - 1])\n    {\n      knum = 0;\n      while (s1[knum] < apar)\n\t/* The knots that are less than or equal to the intersection point. */\n\tknum++;\n    }\n\n\n\n  /* Allocating the new arrays to the new curve. */\n\n  if ((scoef = newarray (kn1 * kdim, double)) == SISL_NULL)\n    goto err101;\n  if ((st = newarray (kn1 + kk, double)) == SISL_NULL)\n    goto err101;\n\n\n  /* Copying the knotvectors, all but the intersection point from\n     the old curve to the new curves */\n\n  memcopy (st, pc->et, knum, double);\n  st[knum] = apar;\n  if (knum < kn + kk)\n    memcopy (st + knum + 1, pc->et + knum, kn + kk - knum, double);\n\n\n  /* Copying the coefisientvector to the new curve.  (Here 'ecoef' points\n     to 'pc->rcoef' or 'pc->ecoef' depening on if 'pc' is rational or not). */\n\n  kch = knum - kk + 1;\n\n  if (kch > 0)\n    memcopy (scoef, ecoef, kdim * kch, double);\n  if (knum < kn1)\n    memcopy (scoef + kdim * knum, ecoef + kdim * (knum - 1),\n\t     kdim * (kn1 - knum), double);\n\n\n  /* Updating the coefisientvectors the new curve.*/\n\n  /* Updating the first curve. */\n\n  for (ki = max (0, kch), kmy = 0, s1 = scoef + ki * kdim; ki < min (knum + 1, kn1); ki++)\n    {\n      /* Initialising:\n           ki = kch,        Index of the vertices we are going to\n                             change. Starting with kch, but if\n                             kch is negativ we start at zero.\n           s1=scoef1+ki*kdim,Pointer at the first vertice to\n                             change. */\n\n\n      /* Using the Oslo-algorithm to make a transformation-vector\n         from the old vertices to one new vertice. */\n\n      while (kmy < kn + kk && pc->et[kmy] <= st[ki])\n\tkmy++;\n\n      s1701 (ki, kmy - 1, kk, kn, &kpl, &kfi, &kla, st, pc->et, sp, salfa, &kstat);\n      if (kstat)\n\tgoto err153;\n\n\n      /* Compute the kdim vertices with the same \"index\". */\n\n      for (kj = 0; kj < kdim; kj++, s1++)\n\tfor (*s1 = 0, kj1 = kfi, kj2 = kfi + kpl; kj1 <= kla; kj1++, kj2++)\n\t  *s1 += salfa[kj2] * ecoef[kj1 * kdim + kj];\n    }\n\n\n\n  /* Allocating new curve-objects.*/\n\n\n  if ((qc = newCurve (kn1, kk, st, scoef, pc->ikind, pc->idim, 2)) == SISL_NULL)\n    goto err101;\n\n\n  /* Updating output. */\n\n  qc->cuopen = pc->cuopen;  /* Ok since only internal knots can be inserted. */\n\n  *rc = qc;\n\n  *jstat = 0;\n  goto out;\n\n\n  /* Error. Error in low level routine. */\n\nerr153:\n  *jstat = kstat;\n  goto outfree;\n\n\n  /* Error. No curve to s1017 a new knot.  */\n\nerr150:\n  *jstat = -150;\n  goto out;\n\n\n  /* Error. The intersection-point is outside the curve.  */\n\nerr158:\n  *jstat = -158;\n  goto out;\n\n\n  /* Error. Allocation error, not enough memory.  */\n\nerr101:\n  *jstat = -101;\n  goto outfree;\n\n\noutfree:\n  if (qc)\n    freeCurve (qc);\n  else\n    {\n      if (st)\n\tfreearray (st);\n      if (scoef)\n\tfreearray (scoef);\n    }\n\n  /* Free local used memory. */\n\nout:if (salfa)\n    freearray (salfa);\n}\n"
  },
  {
    "path": "src/s1018.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1018.c,v 1.3 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1018\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1018 (SISLCurve *pc, double epar[], int inpar,\n\t\t  SISLCurve **rcnew, int *jstat)\n#else\nvoid\ns1018 (pc, epar, inpar, rcnew, jstat)\n     SISLCurve *pc;\n     double epar[];\n     int inpar;\n     SISLCurve **rcnew;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Insert a given set of knots into the description of\n*              a B-spline curve.\n* NOTE       : When the curve is periodic, the input parameter values\n*              must lie in the HALFOPEN [et[kk-1], et[kn), the function\n*              will automatically update the extra knots and\n*              coeffisients.\n*              rcnew->in is still eq to pc->in + inpar !\n*\n* INPUT      : pc        - SISLCurve to be refined.\n*              epar      - Parameter values of knots to be inserted.\n*                          The values are stored in increasing order.\n*              inpar     - Number of parameter values in epar.\n*\n*\n*\n* OUTPUT     : rcnew     - The new, refined curve .\n*              jstat     - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newCurve  - Allocate space for a new curve-object.\n*              freeCurve - Free space occupied by given curve-object.\n*              S1701.C   - Making the knot-inserten-transformation matrix.\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-11.\n* CHANGED BY : Ulf J. Krystad, SI, 92-01\n*              Treatment of periodic curves.\n**********************************************************************/\n{\n  register int ki, ki2;  \t/* Control variable in loop.                */\n  register int kj, kj1, kj2;\t/* Control variable in loop.                */\n  register double *s1;\t\t/* Pointers used in loop.                     */\n  int kstat;\t\t\t/* Local status variable.                     */\n  int k1, k2, k3;\t\t/* Index to array of parameter values.        */\n  int kmy;\t\t\t/* An index to the knot-vector.               */\n  int kpl, kfi, kla;\t\t/* To posisjon elements in trans.-matrix.     */\n  int kk = pc->ik;\t\t/* Order of the input curve.                  */\n  int kn = pc->in;\t\t/* Number of the vertices in input curves.    */\n  int kdim = pc->idim;\t\t/* Dimensjon of the space in whice curve lies.*/\n  int kn1;\t\t\t/* Number of vertices in the new curve .      */\n  double tstart, tend;\t\t/* Endparameters of curve.                    */\n  double tpar;\t\t\t/* Parameter value of knot to insert.         */\n  double *st = SISL_NULL;\t\t/* The new knot-vector.                       */\n  double *sp = SISL_NULL;\t\t/* To use in s1701.c                          */\n  double *salfa = SISL_NULL;\t\t/* A line of the trans.-matrix.               */\n  double *scoef = SISL_NULL;\t\t/* The new vertices.                          */\n  double *coef = SISL_NULL;\t\t/* The old vertices.                          */\n  SISLCurve *q1 = SISL_NULL;\t\t/* Pointer to new curve-object.               */\n  /* Periodicity treatment --------------------------                         */\n  double *st2 = SISL_NULL;\t\t/* The new knot-vector.                    */\n  double *scoef2 = SISL_NULL;\t/* The new vertices.                       */\n  double t1;\t\t\t/* Start of knot vector                    */\n  double t2;\t\t\t/* Start of full basis part of knot vector */\n  double t3;\t\t\t/* End  of full basis part of knot vector  */\n  double t4;\t\t\t/* End of knot vector                      */\n  double tmod;\t\t\t/* t3 - t2, period size                    */\n  double mod_neg;\t\t/* parametervalue shifted tmod left        */\n  double mod_pos;\t\t/* parametervalue shifted tmod right       */\n  int no_neg, no_pos;\t\t/* Nmb of Xtra parval. to insert (lft,rght)*/\n  double *negpar = SISL_NULL;\t/* Array of parameter values shift lft  */\n  double *pospar = SISL_NULL;\t/* Array of parameter values shift rght */\n  double *pararr = SISL_NULL;\t/* Pointer to parameter array treated   */\n  double *periodarr = SISL_NULL;\t/* Total parameter array, periodic case*/\n  /* --------------------------------------------------------- */\n\n  /* Check that we have a curve to treat. */\n\n  if (!pc)\n    goto err150;\n  if (pc->ikind == 2 || pc->ikind == 4)\n    {\n      kdim++;\n      coef = pc->rcoef;\n    }\n  else\n    {\n      coef = pc->ecoef;\n    }\n\n\n  /* Periodicity treatment -------------------------- */\n  if (pc->cuopen == SISL_CRV_PERIODIC)\n    {\n       /* Get values in knotvector for start, start of full basis,\n\t  end of full basis, end. */\n      t1 = *(pc->et);\n      t2 = *(pc->et + kk - 1);\n      t3 = *(pc->et + kn);\n      t4 = *(pc->et + kn + kk - 1);\n      tmod = t3 - t2;\n\n      /* Check that the input parameter values lie in the legal parameter\n\t interval of the curve, ie in the HALFOPEN [et[kk-1], et[kn) */\n      for (k1 = 0; k1 < inpar; k1++)\n\tif (epar[k1] < t2 ||epar[k1] >= t3)\n\t   goto err158;\n\n      no_neg = 0;\n      no_pos = 0;\n      if ((negpar = newarray (inpar, double)) == SISL_NULL)\n\tgoto err101;\n      if ((pospar = newarray (inpar, double)) == SISL_NULL)\n\tgoto err101;\n\n\n      for (k1 = 0; k1 < inpar; k1++)\n\t{\n\t  mod_neg = epar[k1] - tmod;\n\t  mod_pos = epar[k1] + tmod;\n\t  if (mod_neg <= t2 &&\n\t      mod_neg > t1)\n\t    {\n\t      negpar[no_neg] = mod_neg;\n\t      no_neg++;\n\t    }\n\t    if (mod_pos >= t3 &&\n\t\tmod_pos <t4)\n\t    {\n\t       pospar[no_pos] = mod_pos;\n\t       no_pos++;\n\t    }\n\t}\n\n      if ((periodarr = newarray (inpar + no_neg + no_pos, double)) == SISL_NULL)\n\tgoto err101;\n      memcopy (periodarr, negpar, no_neg, double);\n      memcopy (periodarr + no_neg, epar, inpar, double);\n      memcopy (periodarr + no_neg + inpar, pospar, no_pos, double);\n      inpar += no_neg + no_pos;\n\n      pararr = periodarr;\n    }\n  else\n    pararr = epar;\n\n\n\n  /* Check that the input parameter values lie in the parameter\n     interval of the curve.  */\n\n  tstart = *(pc->et);\n  tend = *(pc->et + kn + kk - 1);\n  for (k1 = 0; k1 < inpar; k1++)\n    if (pararr[k1] < tstart || pararr[k1] > tend)\n      goto err158;\n\n  /* Allocate space for the kk elements which may not be zero in eache\n     line of the basic transformation matrix, and space for new knots\n     to use in s1701.c */\n\n  if ((salfa = newarray (kk, double)) == SISL_NULL)\n    goto err101;\n  if ((sp = newarray (kk, double)) == SISL_NULL)\n    goto err101;\n\n  /* Find the number of vertices in the new curve. */\n\n  kn1 = kn + inpar;\n\n  /* Allocating the new arrays to the new curve. */\n\n  if ((st = newarray (kn1 + kk, double)) == SISL_NULL)\n    goto err101;\n  if ((scoef = new0array (kn1 * kdim, double)) == SISL_NULL)\n    goto err101;\n\n  /* Making the new knotvectors. */\n\n  for (k2 = 0, k3 = 0, k1 = 0; k1 < inpar; k1++)\n    {\n      tpar = pararr[k1];\n      for (; k2 < kn + kk; k2++)\n\t{\n\t  if (pc->et[k2] <= tpar)\n\t    st[k3++] = pc->et[k2];\n\t  else\n\t    break;\n\t}\n      st[k3++] = tpar;\n    }\n  for (; k2 < kn + kk; k2++)\n    st[k3++] = pc->et[k2];\n\n  /* Updating the coefisientvector to the new curve.*/\n\n  for (s1 = scoef, ki = 0, kmy = 0; ki < kn1; ki++)\n    {\n      /* Here we compute a new line with line number ki of\n\t the knot inserten matrix. */\n\n      while (pc->et[kmy + 1] <= st[ki])\n\tkmy++;\n      s1701 (ki, kmy, kk, kn, &kpl, &kfi, &kla, st, pc->et, sp, salfa, &kstat);\n      if (kstat)\n\tgoto err153;\n\n      /* Compute the kdim vertices with the same \"index\". */\n\n      for (kj = 0; kj < kdim; kj++, s1++)\n\tfor (*s1 = 0, kj1 = kfi, kj2 = kfi + kpl; kj1 <= kla; kj1++, kj2++)\n\t  {\n\t    ki2 = kj1 * kdim + kj;\n\t    *s1 += salfa[kj2] * coef[ki2];\n\t  }\n    }\n\n  /* Periodicity treatment -------------------------- */\n\n  if (pc->cuopen == SISL_CRV_PERIODIC)\n    {\n      kn1 -= no_pos + no_neg;\n      /* Allocating the new arrays to the new curve. */\n\n      if ((st2 = newarray (kn1 + kk, double)) == SISL_NULL)\n\tgoto err101;\n      if ((scoef2 = new0array (kn1 * kdim, double)) == SISL_NULL)\n\tgoto err101;\n      memcopy (st2, st + no_neg, kn1 + kk, double);\n      memcopy (scoef2, scoef + no_neg * kdim, kn1 * kdim, double);\n\n      if (st)\n\tfreearray (st);\n      if (scoef)\n\tfreearray (scoef);\n\n      /* Allocating new curve-objects.*/\n\n      if ((q1 = newCurve(kn1,kk,st2,scoef2,pc->ikind,pc->idim,2)) == SISL_NULL)\n\tgoto err101;\n    }\n  else\n    {\n      /* Allocating new curve-objects.*/\n      if ((q1 = newCurve (kn1, kk, st, scoef, pc->ikind, pc->idim, 2)) == SISL_NULL)\n\tgoto err101;\n    }\n\n  q1->cuopen = pc->cuopen;\n\n  /* Updating output. */\n\n  *rcnew = q1;\n  *jstat = 0;\n  goto out;\n\n\n  /* Error. Subrutine error. */\n\nerr153:*jstat = kstat;\n  goto outfree;\n\n\n  /* Error. No curve to treat.  */\n\nerr150:*jstat = -150;\n  goto out;\n\n  /* Error. Parameter value to insert is outside the curve. */\n\nerr158:*jstat = -158;\n  goto out;\n\n  /* Error. Allocation error, not enough memory.  */\n\nerr101:*jstat = -101;\n  goto outfree;\n\n\noutfree:\n  if (q1)\n    freeCurve (q1);\n  else\n    {\n      if (st)\n\tfreearray (st);\n      if (scoef)\n\tfreearray (scoef);\n      if (st2)\n\tfreearray (st2);\n      if (scoef2)\n\tfreearray (scoef2);\n    }\n\n\n  /* Free local used memory. */\n\nout:if (salfa)\n    freearray (salfa);\n  if (sp)\n    freearray (sp);\n  if (periodarr)\n    freearray (periodarr);\n  if (pospar)\n    freearray (pospar);\n  if (negpar)\n    freearray (negpar);\n\n}\n"
  },
  {
    "path": "src/s1021.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1021.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1021\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1021(double bottom_pos[], double bottom_axis[], double ellipse_ratio, \n\t double axis_dir[], double height, SISLSurf **cyl, int *stat)\n#else\nvoid s1021(bottom_pos, bottom_axis, ellipse_ratio, axis_dir, \n\t      height, cyl, stat) \n     double bottom_pos[];\n     double bottom_axis[];\n     double ellipse_ratio;\n     double axis_dir[];\n     double height;\n     SISLSurf  **cyl;\n     int    *stat;      \n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To describe a truncated cylinder as a NURBS. The cylinder \n*              can be elliptic.\n*             \n*\n* INPUT      : bottom_pos    - Center point of the bottom\n*              bottom_axis   - One of the bottom axis (major or minor)\n*              ellipse_ratio - Ratio betwwen the other axis and bottom_axis\n*              axis_dir      - Direction of the cylinder axis\n*              height        - Height of the cone, can be negative.\n*\n*\n* OUTPUT     : \n*              stat          - status messages  \n*                                             > 0      : warning\n*                                             = 0      : ok\n*                                             < 0      : error\n*              cyl           - Pointer to the cylinder produced\n*\n* METHOD     : The cylinder is made as a rules surface between two NURBS ellipses.\n*\n*\n* REFERENCES :\n*\n*-                                      \n* CALLS      : \n*\n* WRITTEN BY : Johannes Kaasa, SI, Oslo, Norway, Jan. 93\n*\n*********************************************************************\n*/\n{\n   int kstat;                      /* Status variable.   */\n   int kpos=0;                     /* Position of error. */\n   double cone_angle = (double)0.; /* No conical slope.  */\n\n   s1022(bottom_pos, bottom_axis, ellipse_ratio, axis_dir, \n\t     cone_angle, height, cyl, &kstat);\n   if (kstat < 0) goto error;\n  \n   *stat = 0;\n   goto out;\n  \n   /* Error in lower level routine. */\n      \n   error:\n      *stat = kstat;\n      s6err(\"s1021\", *stat, kpos);\n      goto out;\n  \n   out:  \n      return;\n}\n    \n"
  },
  {
    "path": "src/s1022.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1022.c,v 1.3 2001-03-19 15:58:41 afr Exp $\n *\n */\n\n\n#define S1022\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1022(double bottom_pos[], double bottom_axis[], double ellipse_ratio,\n\t   double axis_dir[], double cone_angle, double height,\n\t   SISLSurf **cone, int *stat)\n#else\nvoid s1022(bottom_pos, bottom_axis, ellipse_ratio, axis_dir,\n\t       cone_angle, height, cone, stat)\n     double bottom_pos[];\n     double bottom_axis[];\n     double ellipse_ratio;\n     double axis_dir[];\n     double cone_angle;\n     double height;\n     SISLSurf  **cone;\n     int    *stat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To describe a truncated cone as a NURBS. The cone can be\n*              elliptic.\n*\n*\n* INPUT      : bottom_pos    - Center point of the bottom\n*              bottom_axis   - One of the bottom axis (major or minor)\n*              ellipse_ratio - Ratio betwwen the other axis and bottom_axis\n*              axis_dir      - Direction of the cone axis\n*              cone_angle    - Angle between axis_dir and the cone at the end\n*                              of bottom_axis, positive if the cone is sloping\n*                              inwards.\n*              height        - Height of the cone, can be negative.\n*\n*\n* OUTPUT     :\n*              stat          - status messages\n*                                             > 0      : warning\n*                                             = 0      : ok\n*                                             < 0      : error\n*              cone          - Pointer to the cone produced\n*\n* METHOD     : The conic is made as a rules surface between two NURBS ellipses.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Johannes Kaasa, SI, Oslo, Norway, Jan. 93\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov. 1994.  Added check\n*              on input parameters to avoid NaN.\n*\n*********************************************************************\n*/\n{\n  int kstat;           /* Status variable.                    */\n  int kpos=0;            /* Position of error.                  */\n  int ki;              /* Index in for loops.                 */\n  int in1 = 9;         /* Number of vertices around the cone. */\n  int in2 = 2;         /* Number of vertices along the cone.  */\n  int ik1 = 3;         /* Order around the cone.              */\n  int ik2 = 2;         /* Order along the cone.               */\n  double et1[12];      /* Knot vector around the cone.        */\n  double et2[4];       /* Knot vector along the cone.         */\n  double rcoef[72];    /* Coefficients of the cone.           */\n  int kind = 2;        /* Rational Bspline surface.           */\n  double b2_axis[3];   /* The second bottom axis.             */\n  double top_pos[3];   /* Center point of the top.            */\n  double t1_axis[3];   /* The first top axis.                 */\n  double t2_axis[3];   /* The second top axis.                */\n  double norm_axis[3]; /* axis_dir normalized.                */\n  double norm;         /* Vector norm.                        */\n  double weight;       /* Rational weight.                    */\n\n\n  /* Check input parameters. */\n\n  if ( ellipse_ratio == 0.0 )\n    goto err151;\n\n  (void) s6length(bottom_axis, 3, &kstat);\n  if (kstat == 0) goto err151;\n\n  (void) s6length(axis_dir, 3, &kstat);\n  if (kstat == 0) goto err151;\n\n\n  /* Make the knot vectors. */\n\n  for (ki = 0; ki < 12; ki++)\n  {\n    if (ki == 0 || ki == 1 || ki == 2)\n      et1[ki] = (double)0.0;\n    else if (ki == 3 || ki == 4)\n      et1[ki] = PIHALF;\n    else if (ki == 5 || ki == 6)\n      et1[ki] = PI;\n    else if (ki == 7 || ki == 8)\n      et1[ki] = THREEPIHALF;\n    else if (ki == 9 || ki == 10 || ki == 11)\n      et1[ki] = TWOPI;\n  }\n  for (ki = 0; ki < 4; ki++)\n  {\n    if (ki == 0 || ki == 1)\n      et2[ki] = (double)0.0;\n    else if (ki == 2 || ki == 3)\n      et2[ki] = fabs(height);\n  }\n\n  /* Make necessary vectors for the coefficients. */\n\n  norm = s6norm(axis_dir, 3, norm_axis, &kstat);\n  if (kstat < 0) goto error;\n  s6crss(norm_axis, bottom_axis, b2_axis);\n  for (ki = 0; ki < 3; ki++)\n    b2_axis[ki] *= ellipse_ratio;\n\n  for (ki = 0; ki < 3; ki++)\n    top_pos[ki] = bottom_pos[ki] + height*norm_axis[ki];\n\n  norm = s6length(bottom_axis, 3, &kstat);\n  if (kstat < 0) goto error;\n  norm = (double)1.0 - height*tan(cone_angle)/norm;\n  for (ki = 0; ki < 3; ki++)\n    t1_axis[ki] = norm*bottom_axis[ki];\n\n  s6crss(norm_axis, t1_axis, t2_axis);\n  for (ki = 0; ki < 3; ki++)\n    t2_axis[ki] *= ellipse_ratio;\n\n  /* Make the coefficients. */\n\n  weight = (double)1.0/sqrt(2.0);\n  for (ki = 0; ki < 3; ki++)\n  {\n    rcoef[ki] = bottom_pos[ki] + bottom_axis[ki];\n    rcoef[4 + ki] = weight*(bottom_pos[ki] + bottom_axis[ki] + b2_axis[ki]);\n    rcoef[8 + ki] = bottom_pos[ki] + b2_axis[ki];\n    rcoef[12 + ki] = weight*(bottom_pos[ki] - bottom_axis[ki] + b2_axis[ki]);\n    rcoef[16 + ki] = bottom_pos[ki] - bottom_axis[ki];\n    rcoef[20 + ki] = weight*(bottom_pos[ki] - bottom_axis[ki] - b2_axis[ki]);\n    rcoef[24 + ki] = bottom_pos[ki] - b2_axis[ki];\n    rcoef[28 + ki] = weight*(bottom_pos[ki] + bottom_axis[ki] - b2_axis[ki]);\n    rcoef[32 + ki] = rcoef[ki];\n\n    rcoef[36 + ki] = top_pos[ki] + t1_axis[ki];\n    rcoef[40 + ki] = weight*(top_pos[ki] + t1_axis[ki] + t2_axis[ki]);\n    rcoef[44 + ki] = top_pos[ki] + t2_axis[ki];\n    rcoef[48 + ki] = weight*(top_pos[ki] - t1_axis[ki] + t2_axis[ki]);\n    rcoef[52 + ki] = top_pos[ki] - t1_axis[ki];\n    rcoef[56 + ki] = weight*(top_pos[ki] - t1_axis[ki] - t2_axis[ki]);\n    rcoef[60 + ki] = top_pos[ki] - t2_axis[ki];\n    rcoef[64 + ki] = weight*(top_pos[ki] + t1_axis[ki] - t2_axis[ki]);\n    rcoef[68 + ki] = rcoef[36 + ki];\n  }\n  for (ki = 3; ki < 72; ki += 4)\n  {\n    if (ki == 3 || ki == 11 || ki == 19 || ki == 27 || ki == 35\n\t|| ki == 39 || ki == 47 || ki == 55 || ki == 63 || ki == 71)\n      rcoef[ki] = (double)1.0;\n    else\n      rcoef[ki] = weight;\n  }\n\n  (*cone) = newSurf(in1, in2, ik1, ik2, et1, et2, rcoef, kind, 3, 1);\n  if ((*cone) == SISL_NULL) goto err101;\n\n  *stat = 0;\n  goto out;\n\n\n  /* Error in curve allocation.  */\n\nerr101:\n  *stat = -101;\n  s6err(\"s1022\",*stat,kpos);\n  goto out;\n\n\n  /* Error in input parameters - ellipse_ratio is zero, bottom_axis or\n     axis_dir is of zero length.  */\n\nerr151:\n  *stat = -151;\n  s6err(\"s1022\", *stat, kpos);\n  goto out;\n\n\n  /* Error in lower level routine. */\n\nerror:\n  *stat = kstat;\n  s6err(\"s1022\", *stat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1023.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1023.c,v 1.3 2001-03-19 15:58:41 afr Exp $\n *\n */\n\n\n#define S1023\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1023(double center[], double axis[], double equator[], int latitude,\n\t  int longitude, SISLSurf **sphere, int *stat)\n#else\nvoid s1023(center, axis, equator, latitude, longitude, sphere, stat)\n     double center[];\n     double axis[];\n     double equator[];\n     int latitude;\n     int longitude;\n     SISLSurf  **sphere;\n     int    *stat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To describe octants of a sphere as a NURBS. This can also\n*              be used to describe the complete sphere.\n*\n*\n* INPUT      : center        - Center point of the sphere\n*              axis          - Axis of the sphere (towards the north pole)\n*              equator       - Vector from center to start point on the equator\n*              latitude      - Flag indicating number of octants in north/south\n*                              direction:\n*                              = 1 : Octants in the northern hemisphere\n*                              = 2 : Octants in both hemispheres\n*              longitude     - Flag indicating number of octants along the\n*                              equator:\n*                              = 1 : Octants in 1. quadrant\n*                              = 2 : Octants in 1. and 2. quadrant\n*                              = 3 : Octants in 1., 2. and 3. quadrant\n*                              = 4 : Octants in all quadrants\n*                              This is counted counter-clockwise from equator\n*\n*\n* OUTPUT     :\n*              stat          - status messages\n*                                             > 0      : warning\n*                                             = 0      : ok\n*                                             < 0      : error\n*              spher         - Pointer to the sphere produced\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Johannes Kaasa, SI, Oslo, Norway, Jan. 93\n* Revised by : Paal Fugelli and Johannes Kaasa, SINTEF, Oslo, Norway, 08-94.\n*\n*********************************************************************\n*/\n{\n   int kstat;            /* Status variable.                            */\n   int kpos=0;             /* Position of error.                          */\n   int ki, kj, kl;       /* Indexes in for loops.                       */\n   int in1;              /* Number of vertices along the longitude.     */\n   int in2;              /* Number of vertices along the latitude.      */\n   int ik1 = 3;          /* Order along the longitude.                  */\n   int ik2 = 3;          /* Order along the latitude.                   */\n   double *et1 = SISL_NULL;   /* Knot vector along the longitude.            */\n   double *et2 = SISL_NULL;   /* Knot vector along the latitude.             */\n   double *rcoef = SISL_NULL; /* Coefficients of the sphere.                 */\n   int kind = 2;         /* Rational Bspline surface.                   */\n   double weight;        /* Rational weight.                            */\n   double radius;        /* Radius of the sphere.                       */\n   double norm;          /* Length of vectors.                          */\n   double x_axis[3];     /* axis normalized with radius length.         */\n   double z_axis[3];     /* Radius vector normal to x_axis and equator. */\n   double w1, w2;        /* Rational weights in both directions.        */\n   double x_comp;        /* Component in local x direction.             */\n   double y_comp;        /* Component in local y direction.             */\n   double z_comp;        /* Component in local z direction.             */\n\n   /* Do necessary initiation and allocation. */\n\n   *sphere = SISL_NULL;\n   weight = (double)1.0/sqrt(2.0);\n   in1 = 1 + 2*latitude;\n   in2 = 1 + 2*longitude;\n\n   radius = s6length(equator, 3, &kstat);\n   if (kstat < 0) goto error;\n   norm = s6length(axis, 3, &kstat);\n   if (kstat < 0) goto error;\n   for (ki = 0; ki < 3; ki++)\n      x_axis[ki] = radius*axis[ki]/norm;\n   s6crss(x_axis, equator, z_axis);\n   norm = s6length(z_axis, 3, &kstat);\n   if (kstat < 0) goto error;\n   for (ki = 0; ki < 3; ki++)\n      z_axis[ki] = radius*z_axis[ki]/norm;\n\n   if((et1 = newarray(in1 + ik1, DOUBLE)) == SISL_NULL) goto err101;\n   if((et2 = newarray(in2 + ik2, DOUBLE)) == SISL_NULL) goto err101;\n   if((rcoef = newarray(4*in1*in2, DOUBLE)) == SISL_NULL) goto err101;\n\n   /* Initiate the knot vectors. */\n\n   for (ki = 0; ki < ik1; ki++)\n      et1[ki] = (double)0.;\n   for (ki = 0; ki < latitude; ki++)\n   {\n      et1[ik1 + 2*ki]     = (ki + 1)*PIHALF;\n      et1[ik1 + 2*ki + 1] = (ki + 1)*PIHALF;\n   }\n   et1[in1 + ik1 - 1] = latitude*PIHALF;\n\n   for (ki = 0; ki < ik2; ki++)\n      et2[ki] = (double)0.;\n   for (ki = 0; ki < longitude; ki++)\n   {\n      et2[ik2 + 2*ki]     = (ki + 1)*PIHALF;\n      et2[ik2 + 2*ki + 1] = (ki + 1)*PIHALF;\n   }\n   et2[in2 + ik2 - 1] = longitude*PIHALF;\n\n   /* Initiate the coefficient vector. */\n\n   for (ki = 0; ki < in2; ki++)\n   {\n      if (ki == 1 || ki == 3 || ki == 5 || ki == 7)\n\t w2 = weight;\n      else\n         w2 = (double)1.;\n\n      if (ki == 0 || ki == 1 || ki == 7 || ki == 8)\n\t y_comp = (double)1.;\n      else if (ki == 3 || ki == 4 || ki == 5)\n\t y_comp = - (double)1.;\n      else\n         y_comp = (double)0.;\n\n      if (ki == 1 || ki == 2 || ki == 3)\n\t z_comp = (double)1.;\n      else if (ki == 5 || ki == 6 || ki == 7)\n\t z_comp = - (double)1.;\n      else\n         z_comp = (double)0.;\n\n      for (kj = 0; kj < in1; kj++)\n      {\n\t if (kj == 1 || kj == 3)\n\t    w1 = weight;\n\t else\n\t    w1 = (double)1.;\n\n\t if (kj == 0 || kj == 1)\n\t    x_comp = (double)1.;\n\t else if (kj == 3 || kj == 4)\n\t    x_comp = - (double)1.;\n\t else\n\t    x_comp = (double)0.;\n\n\t w1 *= w2;\n\n         if (kj == 0 || kj == 4)\n\t {\n\t    for (kl = 0; kl < 3; kl++)\n\t       rcoef[4*(ki*in1 + kj) + kl] = w1*(center[kl] + x_comp*x_axis[kl]);\n         }\n\t else\n\t {\n\t    for (kl = 0; kl < 3; kl++)\n\t       rcoef[4*(ki*in1 + kj) + kl] =  w1*(center[kl] + x_comp*x_axis[kl]\n\t                        + y_comp*equator[kl] + z_comp*z_axis[kl]);\n\t }\n\t rcoef[4*(ki*in1 + kj) + 3] = w1;\n      }\n   }\n   (*sphere) = newSurf(in1, in2, ik1, ik2, et1, et2, rcoef, kind, 3, 1);\n   if ((*sphere) == SISL_NULL) goto err101;\n\n   if (et1 != SISL_NULL) freearray(et1);\n   if (et2 != SISL_NULL) freearray(et2);\n   if (rcoef != SISL_NULL) freearray(rcoef);\n\n   *stat = 0;\n   goto out;\n\n   /* Error in curve allocation.  */\n\n   err101:\n      *stat = -101;\n      s6err(\"s1023\",*stat,kpos);\n      goto out;\n\n   /* Error in lower level routine. */\n\n   error:\n      *stat = kstat;\n      s6err(\"s1023\", *stat, kpos);\n      goto out;\n\n   out:\n      return;\n}\n"
  },
  {
    "path": "src/s1024.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1024.c,v 1.3 2001-03-19 15:58:41 afr Exp $\n *\n */\n\n\n#define S1024\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1024(double center[], double axis[], double equator[], double minor_radius,\n          int start_minor, int end_minor, int numb_major, SISLSurf **torus,\n\t  int *stat)\n#else\nvoid s1024(center, axis, equator, minor_radius, start_minor, end_minor,\n              numb_major, torus, stat)\n     double center[];\n     double axis[];\n     double equator[];\n     double minor_radius;\n     int start_minor;\n     int end_minor;\n     int numb_major;\n     SISLSurf  **torus;\n     int    *stat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To describe octants of a torus as a NURBS. This can also\n*              be used to describe the complete torus.\n*\n*\n* INPUT      : center        - Center point of the torus\n*              axis          - Normal to the torus plane\n*              equator       - Vector from center to start point on the major\n*                              circle\n*              minor_radius  - Radius of the minor circle\n*              start_minor   - Start quadrant on the minor circle (1,2,3 or 4).\n*                              This is counted clockwise from the extremum in\n*                              the direction of axis\n*              end_minor     - End quadrant on the minor circle (1,2,3 or 4)\n*                              This is counted clockwise from the extremum in\n*                              the direction of axis\n*              numb_major    - Number of quadrants on the major circle\n*                              (1,2,3 or 4). This is counted counter-clockwise\n*                              from equator.\n*\n*\n* OUTPUT     :\n*              stat          - status messages\n*                                             > 0      : warning\n*                                             = 0      : ok\n*                                             < 0      : error\n*              torus         - Pointer to the torus produced\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Johannes Kaasa, SI, Oslo, Norway, Jan. 93\n* REVISED BY : Christophe Rene Birkeland, SINTEF, Oslo, May 1993\n*              (Testing on SISL_NULL-pointers atfer allocations)\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov, 1994. Added check on\n*              input parameters to avoid NaN results.\n*\n*********************************************************************\n*/\n{\n  int kstat;            /* Status variable.                               */\n  int kpos=0;           /* Position of error.                             */\n  int ki, kj, kl;       /* Indexes in for loops.                          */\n  int in1;              /* Number of vertices around the minor circle.    */\n  int in2;              /* Number of vertices around the major circle.    */\n  int ik1 = 3;          /* Order around the minor circle.                 */\n  int ik2 = 3;          /* Order around the major circle.                 */\n  double *et1 = SISL_NULL;   /* Knot vector around the minor circle.           */\n  double *et2 = SISL_NULL;   /* Knot vector around the major circle.           */\n  double *rcoef = SISL_NULL; /* Coefficients of the torus.                     */\n  int kind = 2;         /* Rational Bspline surface.                      */\n  double weight;        /* Rational weight.                               */\n  double major_radius;  /* Radius of the major circle.                    */\n  double norm;          /* Length of vectors.                             */\n  double x_axis[3];     /* Normalized equator.                            */\n  double y_axis[3];     /* Normal to equator in torus plane, normalized.  */\n  double z_axis[3];     /* axis normalized.                               */\n  double w1, w2;        /* Rational weights in both directions.           */\n  double x_comp;        /* Component in local x direction.                */\n  double y_comp;        /* Component in local y direction.                */\n  double z_comp;        /* Component in local z direction.                */\n  int start_coef;       /* Number of starting vertice in minor circle.    */\n  int end_coef;         /* Number of second last vertice in minor circle. */\n\n\n  /* Do necessary initiation and allocation. */\n\n  *torus = SISL_NULL;\n\n  if ( start_minor < 1  ||  start_minor > 4  ||\n       end_minor < 1  ||  end_minor > 4  ||\n       numb_major < 1  || numb_major > 4 )  goto err151;\n\n  start_coef = 2*(start_minor - 1);\n  end_coef   = 2*end_minor + 1;\n  weight = (DOUBLE)1.0/sqrt(2.0);\n  in1 = 1 + 2*(end_minor + 1 - start_minor);\n  in2 = 1 + 2*numb_major;\n\n  major_radius = s6length(equator, 3, &kstat);\n  if ( kstat < 0 ) goto error;\n  else if ( kstat == 0 ) goto err151;\n\n  for ( ki=0;  ki < 3;  ki++ )\n    x_axis[ki] = equator[ki]/major_radius;\n  norm = s6length(axis, 3, &kstat);\n  if ( kstat < 0 ) goto error;\n  else if ( kstat == 0 )  goto err151;\n\n  for ( ki=0;  ki < 3;  ki++ )\n    z_axis[ki] = axis[ki]/norm;\n  s6crss(z_axis, x_axis, y_axis);\n\n  if ( (et1 = newarray(in1 + ik1, DOUBLE)) == SISL_NULL ) goto err101;\n  if ( (et2 = newarray(in2 + ik2, DOUBLE)) == SISL_NULL ) goto err101;\n  if ( (rcoef = newarray(4*in1*in2, DOUBLE)) == SISL_NULL ) goto err101;\n\n  /* Initiate the knot vectors. */\n\n  for ( ki=0;  ki < ik1;  ki++ )\n    et1[ki] = (DOUBLE)0.;\n  for ( ki=0;  ki < (end_minor + 1 - start_minor);  ki++ )\n  {\n    et1[ik1 + 2*ki]     = (ki + 1)*PIHALF;\n    et1[ik1 + 2*ki + 1] = (ki + 1)*PIHALF;\n  }\n  et1[in1 + ik1 - 1] = (end_minor + 1 - start_minor)*PIHALF;\n\n  for ( ki=0;  ki < ik2;  ki++ )\n    et2[ki] = (DOUBLE)0.;\n  for ( ki=0;  ki < numb_major;  ki++ )\n  {\n    et2[ik2 + 2*ki]     = (ki + 1)*PIHALF;\n    et2[ik2 + 2*ki + 1] = (ki + 1)*PIHALF;\n  }\n  et2[in2 + ik2 - 1] = numb_major*PIHALF;\n\n  /* Initiate the coefficient vector. */\n\n  for ( ki=0;  ki < in2;  ki++ )\n  {\n    if ( ki == 1  ||  ki == 3  ||  ki == 5  ||  ki == 7 )\n      w2 = weight;\n    else\n      w2 = (DOUBLE)1.;\n\n    for ( kj=start_coef;  kj < end_coef;  kj++ )\n    {\n      if ( kj == 1  ||  kj == 3  ||  kj == 5  ||  kj == 7 )\n\tw1 = w2*weight;\n      else\n\tw1 = w2;\n\n      if ( ki == 0  ||  ki == 1  ||  ki == 7  ||  ki == 8 )\n      {\n\tif ( kj == 1  ||  kj == 2  ||  kj == 3 )\n\t  x_comp = major_radius + minor_radius;\n\telse if ( kj == 5  ||  kj == 6  ||  kj == 7 )\n\t  x_comp = major_radius - minor_radius;\n\telse\n\t  x_comp = major_radius;\n      }\n      else if ( ki == 3  ||  ki == 4  ||  ki == 5 )\n      {\n\tif ( kj == 1  ||  kj == 2  ||  kj == 3 )\n\t  x_comp = - major_radius - minor_radius;\n\telse if ( kj == 5  ||  kj == 6  ||  kj == 7 )\n\t  x_comp = - major_radius + minor_radius;\n\telse\n\t  x_comp = - major_radius;\n      }\n      else\n\tx_comp = (DOUBLE)0.;\n\n      if ( ki == 1  ||  ki == 2  ||  ki == 3 )\n      {\n\tif ( kj == 1  ||  kj == 2  ||  kj == 3 )\n\t  y_comp = major_radius + minor_radius;\n\telse if ( kj == 5  ||  kj == 6  ||  kj == 7 )\n\t  y_comp = major_radius - minor_radius;\n\telse\n\t  y_comp = major_radius;\n      }\n      else if ( ki == 5  ||  ki == 6  ||  ki == 7 )\n      {\n\tif ( kj == 1  ||  kj == 2  ||  kj == 3 )\n\t  y_comp = - major_radius - minor_radius;\n\telse if ( kj == 5  ||  kj == 6  ||  kj == 7 )\n\t  y_comp = - major_radius + minor_radius;\n\telse\n\t  y_comp = - major_radius;\n      }\n      else\n\ty_comp = (DOUBLE)0.;\n\n      if ( kj == 0  ||  kj == 1  ||  kj == 7  ||  kj == 8 )\n\tz_comp = minor_radius;\n      else if ( kj == 3  ||  kj == 4  ||  kj == 5 )\n\tz_comp = - minor_radius;\n      else\n\tz_comp = (DOUBLE)0.;\n\n      for ( kl=0;  kl < 3;  kl++ )\n\trcoef[4*(ki*in1 + kj - start_coef) + kl] =\n\t  w1*(center[kl] + x_comp*x_axis[kl] +\n\t      y_comp*y_axis[kl] + z_comp*z_axis[kl]);\n      rcoef[4*(ki*in1 + kj - start_coef) + 3] = w1;\n\n    }\n  }\n\n  (*torus) = newSurf(in1, in2, ik1, ik2, et1, et2, rcoef, kind, 3, 1);\n  if ( (*torus) == SISL_NULL ) goto err101;\n\n  *stat = 0;\n  goto out;\n\n\n  /* Error in curve allocation.  */\n\nerr101:\n  *stat = -101;\n  s6err(\"s1024\", *stat, kpos);\n  goto out;\n\n\n  /* Error in input parameters - ellipse_ratio is zero, bottom_axis or\n     axis_dir is of zero length.  */\n\nerr151:\n  *stat = -151;\n  s6err(\"s1024\", *stat, kpos);\n  goto out;\n\n\n  /* Error in lower level routine. */\n\nerror:\n  *stat = kstat;\n  s6err(\"s1024\", *stat, kpos);\n  goto out;\n\nout:\n\n  if ( et1 != SISL_NULL ) freearray(et1);\n  if ( et2 != SISL_NULL ) freearray(et2);\n  if ( rcoef != SISL_NULL ) freearray(rcoef);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1025.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1025.c,v 1.3 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1025\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1025 (SISLSurf * ps, double epar1[], int inpar1, double epar2[],\n\t    int inpar2, SISLSurf ** rsnew, int *jstat)\n#else\nvoid \ns1025 (ps, epar1, inpar1, epar2, inpar2, rsnew, jstat)\n     SISLSurf *ps;\n     double epar1[];\n     int inpar1;\n     double epar2[];\n     int inpar2;\n     SISLSurf **rsnew;\n     int *jstat;\n#endif\n/*\n********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Insert a given set of knots in each parameter direction\n*\t       into the description of a B-spline surface.\n* NOTE       : When the surf is periodic in one direction, the input\n*              parameter values in this direction\n*              must lie in the HALFOPEN [et[kk-1], et[kn), the function\n*              will automatically update the extra knots and\n*              coeffisients.\n*\n*\n*\n*\n* INPUT      : ps\t- Surface to be refined.\n*\t       epar1    - Knots to insert in 1. parameter direction.\n*   \t       inpar1   - Number of new knots in 1. par. dir.\n*\t       epar2    - Knots to insert in 2. parameter direction.\n*   \t       inpar2   - Number of new knots in 2. par. dir.\n*\n*\n*\n* OUTPUT     : rsnew\t- The new, refined surface.\n*              jstat\t- status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newSurf     - Allocate space for a new surface-object.\n*\t       newCurve    - Allocate space for a new curve-object.\n*\t       freeCurve   - Free space occupied by a curve-object.\n*              s1018       - Insert knots in a B-spline curve.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 01.91.\n* CHANGED BY : Ulf J. Krystad, SI, 92-01\n*              Treatment of periodic curves.\n*\n**********************************************************************/\n{\n  int kstat;\t\t\t/* Local status variable.\t\t*/\n  int kdim = ps->idim;\t\t/* Dimension of geometry space.        */\n  int kkind = ps->ikind;\t/* Kind of surface.                    */\n  int kn1;\t\t\t/* Number of vertices in 1. par. dir.  */\n  int kn2;\t\t\t/* Number of vertices in 2. par. dir.  */\n  double *st1;\t\t\t/* Knot vector in 1. par. dir.         */\n  double *st2;\t\t\t/* Knot vector in 2. par. dir.         */\n  double *scoef1 = SISL_NULL;\t/* Coefficients of input curve to\n\t\t\t           refinement in 1. par. dir.          */\n  double *scoef2 = SISL_NULL;\t/* Coefficients of refined surface.    */\n  double *scoef;\t\t/* Coefficients of refined surface.    */\n  SISLCurve *qc1 = SISL_NULL;\t/* Input curve to refinement in 1. par. dir.    */\n  SISLCurve *qc2 = SISL_NULL;\t/* Output curve from refinement in 1. par. dir. */\n  SISLCurve *qc3 = SISL_NULL;\t/* Output curve from refinement in 2. par. dir. */\n  double *oldcoef;           \t/* Pointer to vertices of old surf.                */\n\n\n  \n  if(kkind == 2 || kkind == 4)\n  {\n     oldcoef = ps->rcoef;\n     kdim++;\n  }\n  else\n  {\n     oldcoef = ps->ecoef;\n  }\n  \n  if (inpar1 > 0)\n  {\n     /* Insert knots in the first parameter direction of the\n\t surface. First express the surface as a curve.  */\n\n      if ((scoef1 = newarray (kdim * ps->in1 * ps->in2, double)) == SISL_NULL)\n\tgoto err101;\n\n      /* Change parameter directions of surface.  */\n\n      s6chpar (oldcoef, ps->in1, ps->in2, kdim, scoef1);\n\n      /* Create curve.  */\n\n      qc1 = newCurve (ps->in1, ps->ik1, ps->et1, scoef1,1, kdim * ps->in2, 0);\n      if (qc1 == SISL_NULL)\n\tgoto err101;\n\n      /* Set periodicity flag of curve.  */\n\t\n      qc1->cuopen = ps->cuopen_1;\n      \n      /* Insert knots into this curve.  */\n\n      s1018 (qc1, epar1, inpar1, &qc2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /* Change parameter directions of the coefficient array of\n         the refined curve.     */\n\n      if ((scoef2 = newarray (qc2->in *ps->in2 * kdim, DOUBLE)) == SISL_NULL)\n\tgoto err101;\n      s6chpar (qc2->ecoef, ps->in2, qc2->in, kdim, scoef2);\n\n      /* Set local parameters of refined surface. */\n\n      kn1 = qc2->in;\n      kn2 = ps->in2;\n      st1 = qc2->et;\n      st2 = ps->et2;\n\n      /* Free curve used as input to the knotinsertion for curves. */\n\n      if (qc1 != SISL_NULL)\n\tfreeCurve (qc1);\n      qc1 = SISL_NULL;\n    }\n  else\n    {\n      /* Set local parameters of input surface. */\n\n      kn1 = ps->in1;\n      kn2 = ps->in2;\n      st1 = ps->et1;\n      st2 = ps->et2;\n      scoef2 = oldcoef;\n    }\n\n  if (inpar2 > 0)\n    {\n      /* Insert knots into the second parameter direction of the\n\t surface. First express the surface as a curve.           */\n\n      if ((qc1 = newCurve (kn2, ps->ik2, st2, scoef2, 1, kn1 * kdim, 0))\n\t  == SISL_NULL)\n\tgoto err101;\n\n      /* Set periodicity flag of curve.  */\n      \n      qc1->cuopen = ps->cuopen_2;\n      \n      /* Insert knots into this curve.  */\n\n      s1018 (qc1, epar2, inpar2, &qc3, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /*\tSet local parameters of the refined surface. */\n\n      kn2 = qc3->in;\n      st2 = qc3->et;\n      scoef = qc3->ecoef;\n    }\n  else\n    scoef = scoef2;\n\n  /* Express result as a surface.  */\n\n  if ((*rsnew = newSurf (kn1, kn2, ps->ik1, ps->ik2, st1, st2,\n\t\t\t scoef, kkind, ps->idim, 1)) == SISL_NULL)\n    goto err101;\n\n  /* Copy periodicity flag from input surface.  */\n  \n  (*rsnew)->cuopen_1 = ps->cuopen_1;\n  (*rsnew)->cuopen_2 = ps->cuopen_2;\n  \n  /* Refinement performed.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation.  */\n\nerr101:*jstat = -101;\n  goto out;\n\n  /* Error in lower level routine.  */\n\nerror:*jstat = kstat;\n  goto out;\n\nout:\n  /* Free scratch occupied by local arrays and objects.  */\n\n  if (inpar1 > 0 && scoef1 != SISL_NULL)\n    freearray (scoef1);\n  if (inpar1 > 0 && scoef2 != SISL_NULL)\n    freearray (scoef2);\n  if (qc1 != SISL_NULL)\n    freeCurve (qc1);\n  if (qc2 != SISL_NULL)\n    freeCurve (qc2);\n  if (qc3 != SISL_NULL)\n    freeCurve (qc3);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1119.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1119.c,v 1.2 2001-03-19 15:58:41 afr Exp $\n *\n */\n\n\n#define S1119\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1119(double *ecoef,double *et1,double *et2,int ik1,int in1,int ik2,\n\t   int in2,int *jsimple,int *jind1,int *jind2,int *jstat)\n#else\nvoid s1119(ecoef,et1,et2,ik1,in1,ik2,in2,jsimple,jind1,jind2,jstat)\n     double *ecoef;\n     double *et1;\n     double *et2;\n     int    ik1;\n     int    in1;\n     int    ik2;\n     int    in2;\n     int    *jsimple;\n     int    *jind1;\n     int    *jind2;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Check if a one-dimensional surface can have only one\n*              single maximal-point.\n*\n*\n*\n* INPUT      : ecoef  - Vertices of surface.\n*              et1    - Knots, parameterdirection one.\n*              et2    - Knots, parameterdirection two.\n*              ik1    - Order of surface in first parameter direction.\n*              in1    - Number of vertices in first parameter direction.\n*              ik2    - Order of surface in second parameter direction.\n*              in2    - Number of vertices in second parameter direction.\n*\n*\n*\n* OUTPUT     : jsimple - Indicates if single case\n*                        = 0 : No interior max possible.\n*                        = 1 : Only one maximal point or curve possible.\n*                        = 2 : More than one maximal point possible. \n*              jind1   - Index to an interior knot with multiplicity ik1 in et1.\n*                        = 0 : No knot with interior multiplicity.\n*              jind1   - Index to an interior knot with multiplicity ik2 in et2.\n*                        = 0 : No knot with interior multiplicity.\n*              jstat   - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Count number of times the control-polygon changes\n*              direction in each parameter direction. If maximum\n*              times of changing is greater than one, this is not\n*              a simple case (possibility of several maxima).\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : UJK, SI, 89-06.\n*\n*********************************************************************\n*/\n{\n  int ki,kj;     /* Counters.                                          */\n  int ksimple;   /* Indicates if simple case.                          */\n  int ksimple1;  /* Indicates if simple case.                          */\n  int ksimple2;  /* Indicates if simple case.                          */\n  int ksign;     /* Number of direction changes in line/column.        */\n  int kconvex1;  /* Flag, if true, we have no interior min \n\t\t    in first direction.*/\n  int kconcav1;  /* Flag, if true, we have no interior max \n\t\t    in first direction.*/\n  int kconvex2;  /* Flag, if true, we have no interior min \n\t\t    in second direction.*/\n  int kconcav2;  /* Flag, if true, we have no interior max \n\t\t    in second direction.*/\n  int kbez;      /* Flagging for bezier case.                          */\n  double tfirst; /* First non-zero difference between two adjacent vertices. */\n  double tprev;  /* Previous difference between two adjacent vertices. */\n  double tdiff;  /* Current difference between two adjacent vertices.  */\n  double *s1;    /* Pointer used to traverse array of vertices.        */\n  \n  /* First we search for interior knotmultiplicity in \n     both parameter directions*/\n  *jind1    = 0;\n  ksimple1 = 1;\n  if (in1 > 1)\n    for (ki=ik1+1; ki<in1 && ksimple1; ki++) \n      {  \n\tif (et1[ki] == et1[ki+ik1-1]) \n\t  {\n\t    *jind1    = ki;\n\t    ksimple1  =  0;\n\t  }\n      }\n  \n  *jind2   = 0;\n  ksimple2 = 1;\n  if (in2 > 1)\n    for (ki=ik2+1; ki<in2 && ksimple2; ki++) \n      {  \n\tif (et2[ki] == et2[ki+ik2-1]) \n\t  {\n\t    *jind2    = ki;\n\t    ksimple2  =  0;\n\t  }\n      }\n  \n  \n  ksimple = ksimple1 && ksimple2;\n  kbez = (((ik1 == in1) && (ik2 == in2)) ? 1 : 0);\n  \n  /* Count number of direction changes in first parameter direction. */\n  /* Notify that we cannot accept equal coeffisient neighbours when \n     we are in a none-bezier case.                                   */\n  \n  kconcav1 = kconvex1 = 1;\n  \n  if (in1 > 1)\n    for (s1=ecoef,kj=0; kj<in2 && ksimple; kj++)\n      {\n\tksign = 0;\n\ttfirst = DZERO;\n\t\n\tfor (ki=0; ki<in1-1 && ksimple; ki++,s1++)\n\t  {\n\t    tdiff = *(s1+1) - *s1;\n\t    if (DEQUAL(tdiff,DZERO) )\n\t      { \n\t\tif (kbez == 0) ksimple = 0;\n\t      }\n\t    else if (DEQUAL(tfirst,DZERO) )\n\t      {\n\t\t/* First none-zero vector, save it. */\n\t\ttfirst = tdiff;\n\t\ttprev  = tdiff;\n\t      }\n\t    \n\t    else if (tprev*tdiff < DZERO)\n\t      {\n\t\ttprev = tdiff;\n\t\tksign++;\n\t\tif (ksign > 1) ksimple = 0;\n\t      }\n\t  }\n\t\n\t\n\tif (kbez == 0)\n\t  {\n\t    /* We permit status simple case only in bezier case. \n\t       However, if the surface is strictly concav in one \n\t       parameter direction, we have found \n\t       the max on the edges. */ \n\t    kconvex1 = 0;\n\t    kconcav1 = ((tfirst < DZERO) && kconcav1); \n\t  }\n\telse\n\t  {\n\t    \n\t    kconvex1 = (((ksign == 0) || \n\t\t\t (ksign == 1 && tfirst >= DZERO)) && kconvex1); \n\t    kconcav1 = (((ksign == 0) || \n\t\t\t (ksign == 1 && tfirst <= DZERO)) && kconcav1); \n\t  }\n\t\n\tksimple  = ((kconvex1 || kconcav1) && ksimple);\n\ts1++;\n\t\n      }\n  \n  /* Count number of direction changes in second parameter direction. */\n  kconcav2 = kconvex2 = 1;    \n  if (in2 > 1)\n    for (kj=0; kj<in1 && ksimple; kj++)\n      {\n\tksign = 0;\n\ttfirst = DZERO;\n\ts1 = ecoef + kj;\n\t\n\tfor (ki=0; ki<in2-1 && ksimple; ki++,s1+=in1)\n\t  {\n\t    tdiff = *(s1+in1) - *s1;\n\t    if (DEQUAL(tdiff,DZERO) )\n\t      { \n\t\tif (kbez == 0) ksimple = 0;\n\t      }\n\t    else if (DEQUAL(tfirst,DZERO) )\n\t      {\n\t\t/* First none-zero vector, save it. */\n\t\ttfirst = tdiff;\n\t\ttprev  = tdiff;\n\t      }\n\t    \n\t    else if (tprev*tdiff < DZERO)\n\t      {\n\t\ttprev = tdiff;\n\t\tksign++;\n\t\tif (ksign > 1) ksimple = 0;\n\t      }\n\t  }\n\t\n\tif (kbez == 0)\n\t  {\n\t    /* We permit status simple case only in bezier case. \n\t       However, if the surface is strictly concav in one \n\t       parameter direction, we have found \n\t       the max on the edges. */ \n\t    kconvex2 = 0;\n\t    kconcav2 = ((tfirst < DZERO) && kconcav2); \n\t  }\n\telse\n\t  {\n\t    \n\t    kconvex2 = (((ksign == 0) || \n\t\t\t (ksign == 1 && tfirst >= DZERO)) && kconvex2); \n\t    kconcav2 = (((ksign == 0) || \n\t\t\t (ksign == 1 && tfirst <= DZERO)) && kconcav2); \n\t  }\n\tksimple  = ((kconvex2 || kconcav2) && ksimple);\n      }\n  \n  /* Simple case test performed.  */\n  \n  if (ksimple)\n    {\n      if (kconvex1 && kconvex2)\n\t*jsimple = 1;\n      else\n\t*jsimple = 0;\t\n    }\n  else\n    *jsimple = 2;\n  *jstat = 0;\n  \n  return;\n}\n                              \n"
  },
  {
    "path": "src/s1161.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1161.c,v 1.2 2001-03-19 15:58:41 afr Exp $\n *\n */\n\n\n#define S1161\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1161(SISLObject *po1,double *cmax,double aepsge,SISLIntdat **pintdat,int *jstat)\n#else\nvoid s1161(po1,cmax,aepsge,pintdat,jstat)\n     SISLObject *po1;\n     double *cmax;\n     double aepsge;\n     SISLIntdat **pintdat;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all maximum points of an onedimentional object (of type \n*              point, curve or surface). The maximum points found has to\n*              be greater or equal to the level value cmax . \n*              In this rouine the outer edges/endpoints of the objects\n*               are treated.\n*\n*\n*\n* INPUT      : po1    - The object. \n*              aepsge - Geometry resolution.\n*\n*\n*\n* INPUT/OUTPUT:\n*              cmax   - The level value.\n*\n* OUTPUT     : pintdat - Maximum points  found. \n*              jstat  - status messages  \n*                                = 1 : Maximumpoints found equal to level value\n*                                = 2 : Maximumpoints found over level value\n*                                = 0 : no maximum \n*                                < 0 : error\n*\n*\n* METHOD     : This function is treating  point maximum. \n*              Otherwise it is computing edge/endpoint maximum  \n*              by recurson on the edges. \n*              The maxima in the inner of the object is found by\n*              calling another recursiv function.        \n* REFERENCES :\n*\n*-\n* CALLS      : s6err      - Gives error message.\n*              s1435      - Pick edge curve from a surface. \n*              s1438      - Pick endpoint from a curve.\n*              s1162      - Find the intersections in the inner of the objects.\n*              s1190      - A boxtest.\n*              s6idnpt    - Put a new intpt to given intdat.\n*              s6idput    - Put contence of one intdat in an other intdat.\n*              s6idlis    - Compute list elements from given intdat.\n*              s6idedg    - Uppdate an edge from given intdat.\n*              freeEdge   - Free space occupied by given edge.\n*              freePoint  - Free space occupied by given point.\n*              freeCurve  - Free space occupied by given curve.\n*              freeObject - Free space occupied by given object.\n*              freeIntdat - Free space occupied by given intdat.\n*              newEdge    - Create new edge-structure.\n*              newIntpt   - Create new maximum point-structure.\n*              newObject  - Create new object.\n*\n* WRITTEN BY : Ulf J. Krystad , 05.89.\n*\n*********************************************************************\n*/                                     \n{\n  int    klevel=0;     /* Parameter into s1162                   */\n  int    knum=0;       /* Parameter into s1162                   */\n  int    kpar;         /* Fixed parameter direction.             */\n  int    ki;           /* Counter.                               */    \n  int    kedge;        /* Number of edges.                       */\n  int idim  = 1;       /* Local dimension, always = 1            */\n  int kstat = 0;       /* Local status variable.                 */\n  int kpos  = 0;       /* Position of error.                     */\n  double tpar;         /* Help variable used for parameter value\n\t\t\t  and geometric distance.                */\n  SISLEdge   *qedge[2];        /* Edges for use in s1162().      */\n  SISLObject *qdum = SISL_NULL;     /* Dummy  pointer.                */\n  SISLObject *qob  = SISL_NULL;     /* Objects for use in recurson.   */\n  SISLIntdat *qintdat = SISL_NULL;  /* Intdat for use in recurson.    */\n  \n  qedge[0] = SISL_NULL;\n  qedge[1] = SISL_NULL;\n  \n  if (po1->iobj == SISLPOINT) \n    {\n      /* It's a point, treat the case here and return. */\n      \n      /* Control the dimension. */\n      if (po1->p1->idim != idim ) goto err106;\n      \n      /* Computing the distance beetween the point and level value. */\n      tpar = po1->p1->ecoef[0] - *cmax;\n      \n      if (fabs(tpar) <= aepsge)\n\t\n        /* The point is close enough to the level value to be a max. */\n\t*jstat = 1;         /* Mark maximum found. */\n      \n      else if (tpar > (double)0.0)\n\t{\n\t  \n\t  /* The point is greater than the level value . */\n\t  *jstat = 2;         /* Mark new maximum found. */\n\t  *cmax   = po1->p1->ecoef[0];\n\t}\n      \n      else \n\t\n\t*jstat = 0;         /* Mark no maximum found. */\n      \n      \n      if ( *jstat > 0 )\n\t{\n\t  SISLIntpt *qt;\n\t  \n\t  /* Add maximum  point. */\n\t  qt = newIntpt(0,cmax,DZERO);\n\t  if (qt == SISL_NULL) goto err101;\n\t  \n\t  /* Uppdate pintdat. */\n\t  s6idnpt(pintdat,&qt,1,&kstat);\n\t  if (kstat < 0) goto error;\n\t}\n      \n    }\n  \n  \n  else if (po1->iobj > SISLPOINT)\n    {\n      /* It's a higher order geometry, treat the edges here and\n\t use a recursiv function to treat the inner of the object       */\n      \n      \n      *jstat = 0;\n      /* Perform a boxtest */\n      s1190(po1,cmax,aepsge,&kstat);\n      if (kstat == 1) goto out;\n      \n      \n      /*Create a dummy object, to be used when calling \n\tthe intersection routines\n\ttreating two objects.*/\n      if ((qdum = newObject(SISLPOINT)) == SISL_NULL) goto err101;\n      \n      \n      \n      kedge  = 2 * po1->iobj;\n      kpar   = kedge/2;\n      \n      /* Create correct number of edges. */\n      if ((qedge[0] = newEdge(kedge)) == SISL_NULL) goto err101;\n      \n      \n      for (ki=0; ki<kedge; ki++)\n\t{\n\t  \n\t  /* Set  correct parameter direction to keep constant         */\n\t  kpar   = ((ki == kedge/2) ? kedge/2-1:kpar-1);\n\t  \n\t  /* Create one lower order helpobject */\n\t  if ((qob = newObject(po1->iobj - 1)) == SISL_NULL) goto err101;\t\n\t  \n\t  \n\t  if (po1->iobj == SISLCURVE)\n\t    \n\t    /* Pick out end point from a curve. */\n\t    s1438(po1->c1,ki,&(qob->p1),&tpar,&kstat);\n\t  \n\t  else if (po1->iobj == SISLSURFACE)\n\t    \n\t    /* Pick out edge curve from a surface. */\n\t    s1435(po1->s1,ki,&(qob->c1),&tpar,&kstat);\n\t  \n\t  else\n\t    /* Unknown higher order object . */\n\t    goto err121;\n\t  \n\t  if (kstat < 0) goto error;\n\t  \n\t  /* Recursiv computing of end maximum. */\n\t  s1161(qob,cmax,aepsge,&qintdat,&kstat);\n\t  if (kstat < 0) goto error;\n\t  \n\t  if (kstat == 2)\n\t    {\n\t      \n\t      /* New maximum found, delete old ones */\n\t      if (*pintdat != SISL_NULL)\n\t\t{\n\t\t  freeIntdat(*pintdat);\n\t\t  *pintdat = SISL_NULL;\n\t\t}\n\t      \n\t      if (qedge[0] != SISL_NULL)\n\t\t{\n\t\t  /*  Empty the edges */\n\t\t  freeEdge(qedge[0]);\n\t\t  if ((qedge[0] = newEdge(kedge)) == SISL_NULL) goto err101;\t      \n\t\t}\n\t      \n\t    }  \n\t  \n\t  \n\t  if (kstat)\n\t    {\n\t      /* Maximum found, add them to the list */\n\t      \n\t      *jstat = max(*jstat,kstat);         /* Mark maximum found. */\n\t      \n\t      /* Put maximum found on edges into pintdat. */\n\t      \n\t      /* Set parameter border values of object. */\n\t      s6idput(pintdat,qintdat,kpar,tpar,&kstat);\n\t      if (kstat < 0) goto error;\n\t      \n\t      /* Uppdate edge structure. */\n\t      s6idedg(po1,qdum,1,kpar+1,tpar,*pintdat,\n\t\t      &(qedge[0]->prpt[ki]),&(qedge[0]->ipoint),&kstat);\n\t      if (kstat < 0) goto error;\n\t    }\n\t  \n\t  if (qintdat != SISL_NULL) freeIntdat(qintdat);\n\t  qintdat = SISL_NULL;\n\t  freeObject(qob);\n\t}\t  \n      \n      \n      /* ---------------------------------------------------------------*/\n      /* Treat the inner of higher order objects. */ \n      \n      /* Before we enter internal maximum and subdivision we\n\t initiate pointers to top level objects. */\n      \n      if (po1->o1 == SISL_NULL) po1->o1 = po1;\n      \n      /* Find the maximums in the inner of the object.  */\n      s1162(po1,cmax,aepsge,pintdat,qedge,klevel,knum,&kstat);\n      if (kstat < 0)  goto error;\n      *jstat = max(*jstat,kstat);\n      \n      /* Organize the list in pintdat. */\n      s6idlis(po1,po1,pintdat,&kstat);\n      if (kstat < 0)  goto error;\n    }\n  \n  else \n    /* Unknown  object . */\n    goto err121;\n  \n  \n  goto out; \n  \n  \n  \n  /* -------------- ERROR HANDLING ----------------------------------------*/\n  \n  /* Error in space allocation.  */\n err101: *jstat = -101;\n  s6err(\"s1161\",*jstat,kpos);\n  goto out;\n  \n  /* Error. Dimensions conflicting.  */\n err106: *jstat = -106;\n  s6err(\"s1161\",*jstat,kpos);\n  goto out;\n  \n  /* Error. Kind of object does not exist.  */\n err121: *jstat = -121;\n  s6err(\"s1161\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower order routine.  */\n  error : *jstat = kstat;\n  s6err(\"s1161\",*jstat,kpos);\n  goto out;\n  \n out:\n  /* Free the edges used in s1162. */\n  if (qedge[0] != SISL_NULL) freeEdge(qedge[0]);\n  \n  /* Free the dummy object(point). */\n  if (qdum != SISL_NULL) freeObject(qdum);\n  \n}\n\n"
  },
  {
    "path": "src/s1162.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1162.c,v 1.3 2001-03-19 15:58:41 afr Exp $\n *\n */\n\n\n#define S1162\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void s1162_s9mic(SISLObject *,SISLObject *,SISLIntdat **,\n\t\t\tSISLEdge *[],int *);\nstatic void s1162_s9num(SISLObject *,int *,int *);\nstatic void s1162_s9edge(SISLObject *[],SISLObject *[],int,int,\n\t\t\t SISLIntdat *,SISLEdge *[],int *);\nstatic void s1162_s9con(SISLObject *,double *,double,SISLIntdat **,\n\t\t\tSISLEdge *[],int *,int *,int *);\nstatic void s1162_s9update(SISLObject *,double *,double,SISLIntdat **,\n\t\t\t   SISLEdge *[2],int *);\nstatic void s1162_s9div(SISLObject *,double *,double,int,int,int,\n\t\t\tSISLObject *[],SISLIntdat **,SISLEdge *[2],int,int *);\n#else\nstatic void s1162_s9mic();\nstatic void s1162_s9num();\nstatic void s1162_s9edge();\nstatic void s1162_s9con();\nstatic void s1162_s9update();\nstatic void s1162_s9div();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1162(SISLObject *po1,double *cmax,double aepsge,\n\t   SISLIntdat **pintdat,SISLEdge *vedge[2],\n\t   int ilevel,int inum,int *jstat)\n#else\nvoid s1162(po1,cmax,aepsge,pintdat,vedge,ilevel,inum,jstat)\n     SISLObject *po1;\n     double *cmax;\n     double aepsge;\n     SISLIntdat **pintdat;\n     SISLEdge   *vedge[2];\n     int    ilevel;\n     int    inum;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : SISLObject - object maximum. Treat the inner of the\n*              object.\n*\n*\n*\n* INPUT      : po1       - Pointer to  object\n*              aepsge    - Geometry resolution.\n*              vedge     - Pointers to structure of edge-maximums.\n*                          vedge[1] must be SISL_NULL\n*              ilevel    - Debt in recursion with inumb(>2) max. on the edges(if bezier case).\n*              inum      - Number of max. on the edges.\n*\n* INPUT/OUTPUT : pintdat - Pointer to maximum data.\n*                cmax    - Level value.\n*\n*\n* OUTPUT     : jstat     - status messages\n*                                   = 2 : maximum found equal to level value\n*                                   = 1 : maximum found over to level value\n*                                   = 0 : no maximum\n*                                   < 0 : error\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err      - Treating error situation.\n*              s1119      - Simple Case test for maximums.\n*              s1190      - Box test.\n*              s1791      - Test if possible to subdivide\n*              s1792      - Computing midpoint of parameter intervall.\n*              s1770      - Curve/curve iteration.\n*              s1770p     - Point/curve iteration.\n*              s1771      - Curve/surface iteration.\n*              s1771p     - Point/surface iteration.\n*              s1231      - Subdivide curve.\n*              s1711      - Subdivide surface.\n*              s1161      - Object/object maximum.\n*              s1435      - Pick an edge curve from a surface.\n*              s1438      - Pick an end point from a curve.\n*              s6idnpt    -\n*              s6idkpt    -\n*              s6idcpt    -\n*              s6idcon    -\n*              s6idput    -\n*              s6idedg    -\n*              s6idint    -\n*              newPoint   -\n*              newObject  -\n*              newIntpt   -\n*              newEdge    -\n*              newIntdat  -\n*              freeObject - Free space occupied by a given object\n*              freeCurve  -\n*              freeEdge   -\n*              freeIntdat -\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 89-05.\n*\n*********************************************************************\n*/\n{\n  int klevel;             /* Local - Debt in recursion with.    */\n  int knumedge;           /* Local - Number of max. on the edges*/\n  int kpos  = 0;          /* Position of error.                 */\n  int kstat = 0;          /* Local error status.                */\n  int ksimple = 0;        /* Local simple case status.          */\n  int kdiv  = 0;          /* Parameter direction of subdivsion. */\n  int knum;               /* Number of edges in subproblems.    */\n  int ki;                 /* Counter.                           */\n  int kind1,kind2;        /* Index two knots with multiplicity. */\n  SISLObject *uob1[4];        /* Pointers to subdivided object.     */\n  SISLObject *qdum;           /* Pointer to dummy object.           */\n  SISLEdge **uedge=SISL_NULL;      /* Pointer to array (to be allocated)\n\t\t\t\t    of edges to use in subproblems.    */\n  SISLIntpt *up[2];\n  SISLPtedge *qpt0,*qpt1;\n\n  /*Init*/\n  knumedge   = inum;\n  klevel     = ilevel;\n\n  for (ki=0;ki<4;ki++)  uob1[ki] = SISL_NULL;\n  if ((qdum = newObject(SISLPOINT)) == SISL_NULL) goto err101;\n\n  /* Initiate no maximum.*/\n  *jstat = 0;\n\n  /* Test if maximum is possible (perform box-test).  */\n  s1190(po1,cmax,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  /* We may have four different values on kstat.\n     kstat = 1 : The SISLbox is beyond level value.\n     kstat = 2 : The object is of constant value.\n     kstat = 3 : The object is beyond one of its corners.\n     kstat = 0 : No conclusion.*/\n\n  if (kstat == 1);\n\n  /* No max is possible */\n\n  else if (kstat == 2)\n    {\n      /* The geometry is of constant value. Since it is not taken by\n\t the SISLbox test and the edges already are treated in s1161,\n\t we just connect the point on the edges. */\n\n\n      if (vedge[0] != SISL_NULL && vedge[0]->iedge == 2)\n\t{\n\t  /* Only curves has to do connect */\n\n\t  qpt0=vedge[0]->prpt[0];\n\t  qpt1=vedge[0]->prpt[1];\n\t  if (qpt0 != SISL_NULL && qpt1 != SISL_NULL)\n\t    {\n\n\t      up[0] = qpt0->ppt;\n\t      up[1] = qpt1->ppt;\n\t      s6idcon(pintdat,&up[0],&up[1],&kstat);\n\t      if (kstat<0) goto error;\n\t    }\n\t}\n    }\n\n  else if (kstat == 3);\n\n\n  /* Maximum for the object is a corner value, it has been found\n     while treating the edges. */\n\n\n  else\n    {\n      /* Simple Case test (more than one maximum possible?)  */\n      if(po1->iobj ==SISLCURVE)\n\n\ts1119(po1->c1->ecoef,po1->c1->et,po1->c1->et,\n\t      po1->c1->ik,po1->c1->in,\n\t      1,1,&ksimple,&kind1,&kind2,&kstat);\n\n      else\n\ts1119(po1->s1->ecoef,po1->s1->et1,po1->s1->et2,\n\t      po1->s1->ik1,po1->s1->in1,\n\t      po1->s1->ik2,po1->s1->in2,&ksimple,&kind1,&kind2,&kstat);\n      if (kstat < 0) goto error;\n\n      /* We may have three different values on ksimple.\n\t ksimple = 0 : Not possible with interior max.\n\t ksimple = 1 : Simpel case\n\t ksimple = 2 : Not simpel case.*/\n\n      if (ksimple == 0)\n\t*jstat = 0;\n\n      else if (ksimple == 1)\n\t{\n\t  /* Simple Case, uppdate maximum list. */\n\n\t  s1162_s9update(po1,cmax,aepsge,pintdat,vedge,&kstat);\n\t  if (kstat < 0) goto error;\n\t  *jstat = kstat;\n\n\t}\n      else\n\t{\n\t  /* Check for interval maximum.*/\n\n\t  s1162_s9con(po1,cmax,aepsge,pintdat,vedge,&klevel,&knumedge,&kstat);\n\t  if (kstat < 0) goto error;\n\n\t  /* We may have two different values on kstat.\n\t     kstat = 0 : No intervall maximum.\n\t     kstat = 1 : More than 2 maximum found on the edges.\n\t                 (bezier case only).\n\t     kstat = 2 : Intervall maximum found.\n\t     kstat = 3 : Simple case  */\n\n\t  if (kstat == 3)\n\t    /* Simple Case, uppdate maximum list. */\n\t    {\n\n\t      s1162_s9update(po1,cmax,aepsge,pintdat,vedge,&kstat);\n\t      if (kstat < 0) goto error;\n\t      *jstat = kstat;\n\t    }\n\n\t  else if (kstat == 2)\n\n\t    *jstat = kstat;     /*Uppdating maximum found. */\n\n\t  else\n\t    {\n\t      /* Find number of possible subdivision directions.\n\t\t kdiv may have 4 difference values :\n\t\t kdiv = 0 : Subdivision not possible.\n\t\t kdiv = 1 : Subdivision in first parameter direction.\n\t\t kdiv = 2 : Subdivision in second parameter direction.\n\t\t kdiv = 3 : Subdivision in both parameter directions. */\n\n\t      s1162_s9num(po1,&kdiv,&kstat);\n\t      if (kstat < 0) goto error;\n\n\n\t      if(kdiv == 0)\n\t\t{\n\t\t  /* Microcase in parameter plane.*/\n\n\t\t  s1162_s9mic(po1,qdum,pintdat,vedge,&kstat);\n\t\t  if (kstat < 0) goto error;\n\t\t  else *jstat = kstat;\n\t\t}\n\t      else\n\t\t{\n\t\t  /* We do not have simpel case and it is possible to\n\t\t     subdivide. We therfor subdivide and uppdate the\n\t\t     edge maximum and then do a recurcive call\n\t\t     to treat the sub problems. Curves are subdivided\n\t\t     into two, surfaces into four. We can therfor get\n\t\t     up to four recursive calls.*/\n\n\t\t  /* Computing total number of subobjects in sub problems. */\n\t\t  knum = (kdiv<3 ? 2:4);\n\n\t\t  /***** Treating objects on sub problems. *****/\n\n\t\t  if (kdiv > 0) /* New objects for subdivision of po1. */\n\t\t    {\n\t\t      for (ki=0;ki<knum;ki++)\n\t\t\t{\n\t\t\t  if ((uob1[ki] = newObject(po1->iobj)) == SISL_NULL)\n\t\t\t    goto err101;\n\n\t\t\t  /*Initiate o1 pointer to point to top level object.*/\n\n\t\t\t  uob1[ki]->o1 = po1->o1;\n\t\t\t}\n\n\t\t      /* Subdivide the po1 object. */\n\n\t\t      s1162_s9div(po1,cmax,aepsge,kdiv,kind1,kind2,\n\t\t\t    uob1,pintdat,vedge,klevel,&kstat);\n\t\t      if (kstat < 0) goto error;\n\t\t      *jstat = max(*jstat,kstat);\n\n\t\t    }\n\n\t\t  /***** Treating edges on sub problems. *****/\n\n\n\t\t  /* Making array of pointers to edge object\n\t\t     to the sub problems. */\n\t\t  if ((uedge = new0array(2*knum,SISLEdge *)) == SISL_NULL)\n\t\t    goto err101;\n\n\t\t  /* Making new edge object to sub problems. */\n\t\t  for (ki=0; ki<2*knum; ki+=2)\n\t\t    {\n\n\t\t      if ((uedge[ki]   = newEdge(vedge[0]->iedge)) == SISL_NULL)\n\t\t\tgoto err101;\n\t\t      /* No edge for the dummy point: */\n\t\t      uedge[ki+1] = SISL_NULL;\n\n\t\t    }\n\n\n\t\t  /***** Recursion. *****/\n\t\t  for (ki=0;ki<knum;ki+=1)\n\t\t    {\n\n\t\t      /* Uppdate edge maximum on sub problems. */\n\t\t      s1162_s9edge(uob1+ki, &qdum, 1, 1, *pintdat,\n\t\t\t     uedge+2*ki, &kstat);\n\t\t      if (kstat < 0) goto error;\n\n\t\t      s1162(uob1[ki],cmax,aepsge,pintdat,\n\t\t\t    uedge+2*ki,klevel,knumedge,&kstat);\n\t\t      if (kstat < 0) goto error;\n\t\t      else *jstat = max(*jstat, kstat);\n\t\t    }\n\t\t}\n\t    }\n\t}\n    }\n\n  /* Intersections in the inner found.  */\n\n  goto out;\n\n  /* Error in space allocation.         */\n err101: *jstat = -101;\n  s6err(\"s1162\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.      */\n  error : *jstat = kstat;\n  s6err(\"s1162\",*jstat,kpos);\n  goto out;\n\n  /* Free the space that is  allocated. */\n\n out:\n  if (qdum != SISL_NULL) freeObject(qdum);\n\n  for (ki=0;ki<4;ki++)\n    if (uob1[ki] != SISL_NULL) freeObject(uob1[ki]);\n\n  if (uedge != SISL_NULL)\n    {\n       /* 26.10.92 UJK/ BEOrd13969 */\n       /* for (ki=0;ki<knum;ki++) */\n       for (ki=0;ki<2*knum;ki++)\n\t  if (uedge[ki] != SISL_NULL) freeEdge(uedge[ki]);\n\n      freearray(uedge);\n    }\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1162_s9mic(SISLObject *po1,SISLObject *po2,SISLIntdat **rintdat,SISLEdge *vedge[],int *jstat)\n#else\nstatic void s1162_s9mic(po1,po2,rintdat,vedge,jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntdat **rintdat;\n     SISLEdge   *vedge[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE     : Treat intersection when it is not possible to\n*               subdivide any futher, and it is not simple case.\n*\n*\n*\n* INPUT      : vedge[2] - SISLEdge intersection objects to the two\n*                         objects in intersection problem.\n*\n*\n*\n* OUTPUT     : rintdat - intersection data.\n*              jstat   - status messages\n*                               = 1     : Intersection found.\n*                               = 0     : Intersection not found.\n*                               < 0     : error.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-04.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;                 /* Position of error.                      */\n  int kstat=0;                  /* Local error status.                     */\n  int kpoint;                   /* Number of intpt on edges.               */\n  double *spar = SISL_NULL;          /* Array to store parameter values.        */\n  SISLIntpt **up = SISL_NULL;     /* Array of poiners to intersection point. */\n\n\n  /* Initiate to now new intersection point. */\n\n\n  *jstat = 0;\n\n\n  /* Compute number of intersection points on edges. */\n\n  if (vedge[0] == SISL_NULL )\n    kpoint = 0;\n  else\n    kpoint = vedge[0]->ipoint;\n\n  if (vedge[1] != SISL_NULL )\n    kpoint += vedge[1]->ipoint;\n\n\n  if (kpoint == 0 )\n    {\n      int kpar = 0;\n      SISLIntpt *qt;\n\n\n      /* There is not any intersection points on the edges.\n\t We therfor make one new intersection point with parameter\n\t values in senter of each object. */\n\n\n      /* Number of parameter values of object 1. */\n\n      if (po1->iobj == SISLCURVE) kpar = 1;\n      else if (po1->iobj == SISLSURFACE) kpar = 2;\n\n\n      /* Number of parameter values of object 2. */\n\n      if (po2->iobj == SISLCURVE) kpar++;\n      else if (po2->iobj == SISLSURFACE) kpar += 2;\n\n\n      /* Allocate array to store midpoint parameter values. */\n\n      if ((spar = newarray(kpar,double)) == SISL_NULL)\n\tgoto err101;\n\n\n      /* Compute midpoint parameter values. */\n\n      if (po1->iobj == SISLCURVE)\n\t{\n\t  spar[0] = (po1->c1->et[po1->c1->ik - 1] +\n\t\t     po1->c1->et[po1->c1->in])*(double)0.5;\n\t  kpar = 1;\n\t}\n      else if (po1->iobj == SISLSURFACE)\n\t{\n\t  spar[0] = (po1->s1->et1[po1->s1->ik1 - 1] +\n\t\t     po1->s1->et1[po1->s1->in1])*(double)0.5;\n\t  spar[1] = (po1->s1->et2[po1->s1->ik2 - 1] +\n\t\t     po1->s1->et2[po1->s1->in2])*(double)0.5;\n\t  kpar = 2;\n\t}\n\n      if (po2->iobj == SISLCURVE)\n\t{\n\t  spar[kpar] = (po2->c1->et[po2->c1->ik - 1] +\n\t\t\tpo2->c1->et[po2->c1->in])*(double)0.5;\n\t  kpar++;\n\t}\n      else if (po2->iobj == SISLSURFACE)\n\t{\n\t  spar[kpar] = (po2->s1->et1[po2->s1->ik1 - 1] +\n\t\t\tpo2->s1->et1[po2->s1->in1])*(double)0.5;\n\t  spar[kpar+1] = (po2->s1->et2[po2->s1->ik2 - 1] +\n\t\t\t  po2->s1->et2[po2->s1->in2])*(double)0.5;\n\t  kpar += 2;\n\t}\n\n      *jstat = 1;         /* Mark intersection found. */\n\n\n      /* Makeing intersection point. */\n\n      qt = newIntpt(kpar,spar,DZERO);\n      if (qt == SISL_NULL) goto err101;\n\n      /* Uppdating pintdat. */\n\n      s6idnpt(rintdat,&qt,1,&kstat);\n      if (kstat < 0) goto error;\n    }\n  else if (kpoint > 1)\n    {\n      int kn,kn1,ki,kj;\n      SISLPtedge *qpt;\n\n\n      /* We have more than one intersection point on the edges,\n\t we therfor conect these points to each other. */\n\n      /* Allacate array of pointers to these points. */\n\n      if ((up = newarray(kpoint,SISLIntpt *)) == SISL_NULL) goto err101;\n\n\n      /* Uppdate the array. */\n\n      for (kn=0,kn1=0; kn<2; kn++)\n\tif (vedge[kn] != SISL_NULL && vedge[kn]->ipoint > 0)\n\t  for(kj=0; kj<vedge[kn]->iedge; kj++)\n\t    for(qpt=vedge[kn]->prpt[kj]; qpt != SISL_NULL; qpt=qpt->pnext,kn1++)\n\t      up[kn1] = qpt->ppt;\n\n\n      /* Connect the points to each other. */\n\n      for (ki=1; ki<kpoint; ki++)\n\t{\n\t  s6idcon(rintdat,&up[ki-1],&up[ki],&kstat);\n\t  if (kstat<0) goto error;\n\t}\n    }\n\n  goto out;\n\n  /* Error in space allocation.         */\n\n err101: *jstat = -101;\n  s6err(\"s1162_s9mic\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.      */\n\n  error : *jstat = kstat;\n  s6err(\"s1162_s9mic\",*jstat,kpos);\n  goto out;\n\n out: if (spar != SISL_NULL) freearray(spar);\n  if (up != SISL_NULL)   freearray(up);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1162_s9num(SISLObject *po,int *jdiv,int *jstat)\n#else\nstatic void s1162_s9num(po,jdiv,jstat)\n     SISLObject *po;\n     int    *jdiv;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find number of possible subdivisions of an object.\n*\n*\n*\n* INPUT      : po     - SISLObject to subdevide.\n*\n*\n*\n* OUTPUT     : jdiv   - Possible subdivisions of object.\n*                         = 0     : No subdivision.\n*                         = 1     : Subdivision in first parameter direction.\n*                         = 2     : Subdivision in second parameter direction.\n*                         = 3     : Subdivision in both parameter direction.\n*              jstat  - status messages\n*                         = 0     : no error.\n*                         < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-04.\n* Revised BY : Christophe Rene Birkeland, SINTEF Oslo, May 93\n*              *jstat = 0    initialization\n*\n*********************************************************************\n*/\n{\n  *jstat = 0;\n  if (po->iobj == SISLPOINT)                             *jdiv = 0;\n  else if (po->iobj == SISLCURVE)\n    {\n      if(s1791(po->c1->et,po->c1->ik,po->c1->in))    *jdiv = 1;\n      else                                           *jdiv = 0;\n    }\n  else if (po->iobj == SISLSURFACE)\n    {\n      if(s1791(po->s1->et1,po->s1->ik1,po->s1->in1)) *jdiv = 1;\n      else                                           *jdiv = 0;\n\n      if(s1791(po->s1->et2,po->s1->ik2,po->s1->in2)) *jdiv += 2;\n    }\n  else\n    {\n\n      /* Error. Kind of object does not exist.  */\n\n      *jstat = -121;\n      s6err(\"s1162_s9num\",*jstat,0);\n    }\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1162_s9edge(SISLObject *vob1[],SISLObject *vob2[],\n\t\t   int iobj1,int iobj2,SISLIntdat *pintdat,SISLEdge *wedge[],int *jstat)\n#else\nstatic void s1162_s9edge(vob1,vob2,iobj1,iobj2,pintdat,wedge,jstat)\n     SISLObject  *vob1[];\n     SISLObject  *vob2[];\n     int     iobj1;\n     int     iobj2;\n     SISLIntdat  *pintdat;\n     SISLEdge    *wedge[];\n     int     *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE     : Uppdate edge structure. It may be up to four object\n*               in vob1 and vob2, and wedge may therfor contain\n*               seexteen elements to be uppdated.\n*\n*\n*\n* INPUT      : vob1[]  - Array of pointers to first objects.\n*              vob2[]  - Array of pointers to second objects.\n*              iobj1   - Number of elements in vob1.\n*              iobj2   - Number of elements in vob2.\n*              pintdat - intersection data.\n*\n*\n*\n* OUTPUT     : wedge[] - SISLEdge structures to uppdate.\n*              jstat   - status messages\n*                               = 0     : OK!\n*                               < 0     : error.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-05.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;                 /* Position of error.       */\n  int kstat=0;                  /* Local error status.      */\n  int ki1,ki2,kj,kn;            /* Counters.                */\n  int kedg;                     /* Number of edges.         */\n  int kpar;                     /* Parameter number.        */\n  double tpar;                  /* Parameter value at edge. */\n\n\n  for (kn=0,ki1=0; ki1<iobj1; ki1++)\n    for (ki2=0; ki2<iobj2; ki2++,kn+=2)\n      {\n        kedg = (vob1[ki1]->iobj == SISLPOINT ?0:(vob1[ki1]->iobj == SISLCURVE ?2:4));\n\n\tfor (kj=0; kj<kedg; kj++)\n\t  {\n\t    if (vob1[ki1]->iobj == SISLCURVE)\n\t      {\n\t\ttpar = (kj == 0 ? vob1[ki1]->c1->et[vob1[ki1]->c1->ik-1] :\n\t\t\tvob1[ki1]->c1->et[vob1[ki1]->c1->in]);\n\t\tkpar = 1;\n\t      }\n\t    else if (kj == 0)\n\t      {\n\t\ttpar = vob1[ki1]->s1->et2[vob1[ki1]->s1->ik2-1];\n\t\tkpar = 2;\n\t      }\n\t    else if (kj == 1)\n\t      {\n\t\ttpar = vob1[ki1]->s1->et1[vob1[ki1]->s1->in1];\n\t\tkpar = 1;\n\t      }\n\t    else if (kj == 2)\n\t      {\n\t\ttpar = vob1[ki1]->s1->et2[vob1[ki1]->s1->in2];\n\t\tkpar = 2;\n\t      }\n\t    else\n\t      {\n\t\ttpar = vob1[ki1]->s1->et1[vob1[ki1]->s1->ik1-1];\n\t\tkpar = 1;\n\t      }\n\n\n\t    s6idedg(vob1[ki1],vob2[ki2],1,kpar,tpar,pintdat,\n\t\t    &(wedge[kn]->prpt[kj]),&(wedge[kn]->ipoint),&kstat);\n\t    if (kstat < 0) goto error;\n\t  }\n\n        kedg = (vob2[ki2]->iobj == SISLPOINT ?0:(vob2[ki2]->iobj == SISLCURVE ?2:4));\n\n\tfor (kj=0; kj<kedg; kj++)\n\t  {\n\t    if (vob2[ki2]->iobj == SISLCURVE)\n\t      {\n\t\ttpar = (kj == 0 ? vob2[ki2]->c1->et[vob2[ki2]->c1->ik-1] :\n\t\t\tvob2[ki2]->c1->et[vob2[ki2]->c1->in]);\n\t\tkpar = 1;\n\t      }\n\t    else if (kj == 0)\n\t      {\n\t\ttpar = vob2[ki2]->s1->et2[vob2[ki2]->s1->ik2-1];\n\t\tkpar = 2;\n\t      }\n\t    else if (kj == 1)\n\t      {\n\t\ttpar = vob2[ki2]->s1->et1[vob2[ki2]->s1->in1];\n\t\tkpar = 1;\n\t      }\n\t    else if (kj == 2)\n\t      {\n\t\ttpar = vob2[ki2]->s1->et2[vob2[ki2]->s1->in2];\n\t\tkpar = 2;\n\t      }\n\t    else\n\t      {\n\t\ttpar = vob2[ki2]->s1->et1[vob2[ki2]->s1->ik1-1];\n\t\tkpar = 1;\n\t      }\n\n\n\t    s6idedg(vob1[ki1],vob2[ki2],2,kpar,tpar,pintdat,\n\t\t    &(wedge[kn+1]->prpt[kj]),&(wedge[kn+1]->ipoint),&kstat);\n\t    if (kstat < 0) goto error;\n\t  }\n      }\n\n  *jstat = 0;\n\n  goto out;\n\n  /* Error in lower level routine.      */\n\n  error : *jstat = kstat;\n  s6err(\"s1162_s9edge\",*jstat,kpos);\n  goto out;\n\n out: ;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1162_s9con(SISLObject *po1,double *cmax,double aepsge,SISLIntdat **pintdat,\n\t\t  SISLEdge *vedge[],int *jlevel,int *jnum,int *jstat)\n#else\nstatic void s1162_s9con(po1,cmax,aepsge,pintdat,vedge,jlevel,jnum,jstat)\n     SISLObject *po1;\n     double *cmax;\n     double aepsge;\n     SISLIntdat **pintdat;\n     SISLEdge   *vedge[];\n     int    *jlevel;\n     int    *jnum;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Check if we are able to connect the maxpoints of the object\n*              found on the edges.\n*\n*\n*\n* INPUT      : po1      - The first SISLObject to check.\n*              cmax     - The max value found.\n*              aepsge   - Geometrical resolution.\n*              vedge[]  - SISLEdge intersection.\n*\n*\n* INPUT/OUTPUT:pintdat  - Intersection data.\n*              jlevel    - Debt in recursion with inumb(>2) max. on the edges(if bezier case).\n*              jnum      - Number of max. on the edges.\n*\n*\n* OUTPUT     :\n*              jstat    - status messages\n*                           = 3     : Simple Case.\n*                           = 2     : Connection done.\n*                           = 1     : Level value set to one or increased by one.\n*                           = 0     : Level value set to zero.\n*                           < 0     : error\n*\n*\n* METHOD     : When  - object is a surface\n*                    - the surf is a bezier patch\n*                    - the patch has three (or more) max on the edges\n*              If jlevel = 4 and number of max on the edges are equal to jnum,\n*                      we connect the points treating one of them as singulear.\n*              If jlevel in {1,2,3} and number of max\n*              on the edges are equal to jnum,\n*              we increase the jlevel by one.\n*              If jlevel is 0 we set jlevel to one and\n*              jnum to number of max on edge.\n*              If jnum not equal to number of max on edge,\n*              we set jlevel to one and\n*              jnum to number of max on edge..\n*\n*              If the number of points on the edge is > 10, we do nothing.\n* REFERENCES :\n*\n*\n* WRITTEN BY : Ulf J Krystad, SI, 89-05.\n*\n*********************************************************************\n*/\n{\n  SISLIntpt  *qintpt,*up[10];\n  SISLPtedge *qpt;\n\n  int kstat;      /* Local status.                */\n/*guen  int kpos;   */   /* Local status counter.        */\n/*guen changed into:*/\n  int kpos = 0;   /* Local status counter.        */\n  int kk1;        /* Local SURFACE attribute.     */\n  int kk2;        /* Local SURFACE attribute.     */\n  int kn1;        /* Local SURFACE attribute.     */\n  int kn2;        /* Local SURFACE attribute.     */\n  int ki,kj;      /* Local counter.               */\n  int kfound;     /* Local flag in loop.          */\n  int knum   = 0; /* Local number of max on edge. */\n  int klevel = 0; /* Local level.                 */\n  int kleft1 = 0; /* Local input parameter s1421  */\n  int kleft2 = 0; /* Local input parameter s1421  */\n  int kder   = 1; /* Local input parameter s1421  */\n\n  double spar[2];  /* Parameter value              */\n  double spar1[2]; /* Parameter value              */\n  double smidle[2];/* middle parameter value       */\n  double *sval=SISL_NULL;/*  Values from s1421.          */\n  double *snorm=SISL_NULL;/* Values from s1421.         */\n\n\n  kstat = 0;\n\n  if (po1->iobj == SISLSURFACE)\n    {\n      if ((po1->s1->in1 == po1->s1->ik1) && (po1->s1->in2 == po1->s1->ik2))\n\t/* Bezier case for surface */\n\t{\n\n\t  /*-------------------------------------------------------*/\n\t  /* Count number of max on the edges. */\n\t  kk1 = po1->s1->ik1;\n\t  kk2 = po1->s1->ik2;\n\t  kn1 = po1->s1->in1;\n\t  kn2 = po1->s1->in2;\n\n\t  for (kj=0,knum=0;kj<vedge[0]->iedge;kj++)\n\t    {\n\t      qpt = vedge[0]->prpt[kj];\n\t      while(qpt != SISL_NULL)\n\t\t{\n\t\t  qintpt = qpt->ppt;\n\t\t  for (ki=0,kfound=0;ki<knum && kfound == 0;ki++)\n\t\t    if (qintpt == up[ki]) kfound = 1;\n\n\t\t  if (kfound == 0)\n\t\t    {\n\t\t      if (knum > 9) goto out;\n\t\t      up[knum]=qintpt;\n\t\t      knum++;\n\t\t    }\n\n\t\t  qpt = qpt->pnext;\n\t\t}\n\n\t    }\n\n\t  /*---------------------------------------------------------*/\n\n\t  if (knum > 0 )\n\t    /* Number of max on the edges more than 1. */\n\t    {\n\t      klevel = *jlevel;\n\n\t      if (klevel == 0 || knum !=*jnum)\n\t\t/* No continuation of suspected singulear point,\n\t\t   start a new one. */\n\t\t{\n\t\t  kstat = 1;\n\t\t  klevel = 1;\n\t\t}\n\t      else if (klevel < 2)\n\t\t/* Continuation of suspected singulear point. */\n\t\t{\n\t\t  kstat = 1;\n\t\t  klevel += 1;\n\t\t}\n\t      else if (knum < 2 )\n\t\t/* Simple Case */\n\t\t{\n\t\t  kstat = 3;\n\t\t  klevel += 1;\n\t\t}\n\t      else\n\t\t{\n\n\t\t  /*--------------------------------------------------*/\n\t\t  /* Connection case. */\n\n\t\t  /* Allocate local used memory */\n\n\t\t  sval = newarray(4,double);\n\t\t  if (sval == SISL_NULL) goto err101;\n\t\t  snorm = sval + 3;\n\n\t\t  for (kj=0;kj<knum-1;kj++)\n\t\t    {\n\t\t      spar[0] = up[kj]->epar[0];\n\t\t      spar[1] = up[kj]->epar[1];\n\n\t\t      for (ki=kj+1;ki<knum;ki++)\n\t\t\t{\n\t\t\t  /* First we linearize. */\n\t\t\t  spar1[0] = up[ki]->epar[0];\n\t\t\t  spar1[1] = up[ki]->epar[1];\n\t\t\t  smidle[0] = (spar[0] + spar1[0])/(double)2.0;\n\t\t\t  smidle[1] = (spar[1] + spar1[1])/(double)2.0;\n\n\t\t\t  /* Evaluate 0-1.st derivatives of surface */\n\n\t\t\t  s1421(po1->s1,kder,smidle,&kleft1,&kleft2,\n\t\t\t\tsval,snorm,&kstat);\n\t\t\t  if (kstat < 0) goto error;\n\t\t\t  if (fabs(sval[0]-*cmax) < aepsge)\n\t\t\t    {\n\t\t\t      /* Connect. */\n\t\t\t      s6idcon(pintdat,&up[kj],&up[ki],&kstat);\n\t\t\t      if (kstat<0) goto error;\n\t\t\t    }\n\n\t\t\t}\n\t\t    }\n\n\n\t\t  kstat = 2;\n\t\t  /*------------------------------------------*/\n\n\n\t\t}\n\t    }\n\t}\n    }\n\n  goto out;\n\n  /* Error in allocation */\n err101: kstat = -101;\n  s6err(\"s1162_s9con\",kstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n  error : s6err(\"s1162_s9con\",kstat,kpos);\n  goto out;\n\n out:    if (sval != SISL_NULL) freearray(sval);\n  *jlevel = klevel;\n  *jnum   = knum;\n  *jstat  = kstat;\n\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1162_s9update(SISLObject *po1,double *cmax,double aepsge,\n\t\t     SISLIntdat **pintdat,SISLEdge *vedge[2],int *jstat)\n#else\nstatic void s1162_s9update(po1,cmax,aepsge,pintdat,vedge,jstat)\n     SISLObject *po1;\n     double *cmax;\n     double aepsge;\n     SISLIntdat **pintdat;\n     SISLEdge   *vedge[2];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To find an inner maxima in an object when\n*              it has no more then one.\n*\n* INPUT      : po1      - The object.\n*              aepsge   - Geometry resolution.\n*              vedge    - Pointer to edge maximum.\n*\n*\n* INPUT/OUTPUT : cmax  - The level value.\n*\n* OUTPUT     : pintdat  - Maximum data.\n*              jstat    - Status messages\n*                          = 2     : New maximum found inside edges.\n*                          = 1     : Maximum found inside object.\n*                          = 0     : no maximum found.\n*                          < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 89-05.\n*\n*********************************************************************\n*/\n{\n  int i, kj, ki;      /* Counters.                          */\n  int kpos = 0;       /* Position of error.                 */\n  int kstat= 0;       /* Local status                       */\n  int kk1, kk2, kn1, kn2; /* Local number of knots and vertices.     */\n  int kmax, kind1, kind2; /* Indexes of the maximum vertice.         */\n  int kleft = 0;          /* Used in s1221 .                         */\n  int kleft2 = 0;         /* Used in s1424 .                         */\n  int kconn  = 0;         /* Connection flag.                        */\n  int knum  = 0;          /* Number of max on the edge.              */\n  int kfound = 0;         /* Flag.                                   */\n\n  double tstart, tend;       /* Start, end values for curve parameter.    */\n  double sstart[2], send[2]; /* Start, end values for surface parameter.  */\n  double tpar;               /* The parameter vallue for\n\t\t\t\tsubdivision of a curve.    */\n  double spar[2];            /* The parameter vallue for subdivision\n\t\t\t\tof a surface.  */\n  double tmax, tmin;         /* Local max and min value for the\n\t\t\t\tvertices of object. */\n  double tval;               /* The value of the geometry at the found point.*/\n\n\n  SISLObject *qop=SISL_NULL,*qcuo = SISL_NULL;/* Help pointers        */\n  SISLIntdat *qintdat=SISL_NULL;         /* Local max data.      */\n  SISLIntdat *qintdat1=SISL_NULL;        /* Local for double upgrading. */\n  SISLIntpt  *qintpt,*up[3];\n  SISLPtedge *qpt;\n\n  /* Init */\n  *jstat = 0;\n  if (po1 == SISL_NULL || po1->iobj == SISLPOINT) goto out;\n  if ((qop = newObject(SISLPOINT)) == SISL_NULL) goto err101;\n\n  if (po1->iobj == SISLCURVE)\n    {\n      kk1   = po1->c1->ik;\n      kn1   = po1->c1->in;\n      kmax  = po1->c1->pbox->imax;\n      tmax  = po1->c1->pbox->emax[0];\n      tmin  = po1->c1->pbox->emin[0];\n\n      tstart = po1->c1->et[kk1-1];\n      tend   = po1->c1->et[kn1];\n\n      /* Try to find an inner ekstremal point by iteration. */\n\n\n      /* First get a good starting point for the iteration. */\n      tpar = 0;\n      for (i=kmax+1;i<kmax+kk1;i++)\n\ttpar += po1->c1->et[i];\n\n      tpar /= kk1 - 1;\n\n      s1252(po1->c1,aepsge,tpar,&tpar,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Test if the found point is at start or end. */\n      if(DEQUAL(tpar,tstart)  || DEQUAL(tpar,tend)) goto out;\n\n\n      /* Evaluate curve at parameter value. */\n      kleft = 0;\n      s1221(po1->o1->c1,0,tpar,&kleft,&tval,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Here we are ready to examine if we really found a new max point.*/\n      if ((qop->p1 = newPoint(&tval,1,1)) == SISL_NULL) goto err101;\n\n      s1161(qop,cmax,aepsge,&qintdat,&kstat);\n      if (kstat < 0) goto error;\n\n      if (kstat == 2)\n\t/* New maximum found, delete old ones */\n\tif (*pintdat != SISL_NULL)\n\t  {\n\t    freeIntdat(*pintdat);\n\t    *pintdat = SISL_NULL;\n\t  }\n\n      if ( kstat )\n\t{\n\t  /* Maximum found, add it to the list */\n\t  *jstat = max(*jstat,kstat);         /* Mark maximum found. */\n\n\t  /* Set parameter parameter value of curve. */\n\t  s6idput(pintdat,qintdat,0,tpar,&kstat);\n\t  if (kstat < 0) goto error;\n\t}\n\n    }\n  else if (po1->iobj == SISLSURFACE)\n    {\n\n\n      kk1   = po1->s1->ik1;\n      kn1   = po1->s1->in1;\n      kk2   = po1->s1->ik2;\n      kn2   = po1->s1->in2;\n      kmax = po1->s1->pbox->imax;\n      tmax = po1->s1->pbox->emax[0];\n      tmin = po1->s1->pbox->emin[0];\n\n      sstart[0] = po1->s1->et1[kk1-1];\n      sstart[1] = po1->s1->et2[kk2-1];\n\n      send[0]   = po1->s1->et1[kn1];\n      send[1]   = po1->s1->et2[kn2];\n\n\n      /* Get the two dimensional index of the greatest vertice. */\n      kind2 = kmax/kk1;\n      kind1 = kmax - kind2*kk1;\n\n\n      /*-----------------------------------------------------------*/\n      /* Count number of max on the edges. */\n\n      for (kj=0,knum=0;kj<vedge[0]->iedge&&knum<3;kj++)\n\t{\n\t  qpt = vedge[0]->prpt[kj];\n\t  while(qpt != SISL_NULL && knum<3)\n\t    {\n\t      qintpt = qpt->ppt;\n\t      for (ki=0,kfound=0;ki<knum && kfound == 0;ki++)\n\t\tif (qintpt == up[ki]) kfound = 1;\n\n\t      if (kfound == 0)\n\t\t{\n\t\t  up[knum]=qintpt;\n\t\t  knum++;\n\t\t}\n\n\t      qpt = qpt->pnext;\n\t    }\n\n\t}\n\n      /* Try if connection is possible.*/\n      if (knum == 2)\n\t{\n\t  /* if on same edge, they are be connected before\n\t     (when in simple case.)*/\n\t  if ((DEQUAL(up[0]->epar[0],sstart[0]) &&\n\t       DEQUAL(up[1]->epar[0],sstart[0]))||\n\t      (DEQUAL(up[0]->epar[0],send[0])   &&\n\t       DEQUAL(up[1]->epar[0],send[0]))  ||\n\t      (DEQUAL(up[0]->epar[1],sstart[1]) &&\n\t       DEQUAL(up[1]->epar[1],sstart[1]))||\n\t      (DEQUAL(up[0]->epar[1],send[1])   &&\n\t       DEQUAL(up[1]->epar[1],send[1])))\n\t    kconn = 0;\n\n\t  else\n\t    {\n\t      /* Pick out two curves between the parameter\n\t\t value on the edges. */\n\t      kconn = 0;\n\t      ki = 0;\n\t      if (fabs(up[0]->epar[0]-up[1]->epar[0]) <\n\t\t  fabs(up[0]->epar[1]-up[1]->epar[1]))\n\t\tki =1;\n\n\t      tpar = (double)0.25*up[0]->epar[ki] +\n\t\t     (double)0.75*up[1]->epar[ki];\n\t      if ((qcuo = newObject(SISLCURVE)) == SISL_NULL) goto err101;\n\t      if (ki==0)\n\t\ts1437(po1->s1,tpar,&(qcuo->c1),&kstat);\n\t      else\n\t\ts1436(po1->s1,tpar,&(qcuo->c1),&kstat);\n\t      if (kstat < 0) goto error;\n\n\t      s1161(qcuo,cmax,aepsge,&qintdat,&kstat);\n\t      if (kstat < 0) goto error;\n\n\t      if (kstat == 1)\n\t\t{\n\t\t  freeCurve(qcuo->c1);\n\t\t  qcuo->c1 = SISL_NULL;\n\n\t\t  tpar = (double)0.75*up[0]->epar[ki] +\n\t\t         (double)0.25*up[1]->epar[ki];\n\t\t  if (ki==0)\n\t\t    s1437(po1->s1,tpar,&(qcuo->c1),&kstat);\n\t\t  else\n\t\t    s1436(po1->s1,tpar,&(qcuo->c1),&kstat);\n\t\t  if (kstat < 0) goto error;\n\n\t\t  s1161(qcuo,cmax,aepsge,&qintdat,&kstat);\n\t\t  if (kstat < 0) goto error;\n\n\t\t  if (kstat == 1)\n\t\t    {\n\t\t      /* Connect. */\n\t\t      kconn = 1;\n\t\t      s6idcon(pintdat,&up[0],&up[1],&kstat);\n\t\t      if (kstat<0) goto error;\n\t\t    }\n\t\t}\n\t    }\n\t}\n\n\n      if (kconn == 0)\n\t{\n\t  /* No connection is done. */\n\n\t  /* Try to find an inner ekstremal point by iteration. */\n\n\t  /* First get a good starting point for the iteration. */\n\t  spar[0] = 0;\n\t  for (i=kind1+1;i<kind1+kk1;i++)\n\t    spar[0] += po1->s1->et1[i];\n\n\t  spar[0] /= kk1 - 1;\n\n\t  spar[1] = 0;\n\t  for (i=kind2+1;i<kind2+kk2;i++)\n\t    spar[1] += po1->s1->et2[i];\n\n\t  spar[1] /= kk2 - 1;\n\n\n\t  /* Create a point greater than the surface */\n\t  if ((qop->p1 = newPoint(&tmax,1,1)) == SISL_NULL) goto err101;\n\n\t  /* Iterate using aepsge=tmax-tmin to ensure covergence. */\n\t  s1173(qop->p1,po1->o1->s1,aepsge,sstart,send,spar,spar,&kstat);\n\t  if (kstat < 0) goto error;\n\n\t  /* Test if the found point is at start or end. */\n\t  if(DEQUAL(spar[0],sstart[0])  ||\n\t     DEQUAL(spar[0],send[0])    ||\n\t     DEQUAL(spar[1],sstart[1])  ||\n\t     DEQUAL(spar[1],send[1])) goto out;\n\n\t  /* Evaluate surface at parameter value. */\n\t  kleft  = 0;\n\t  kleft2 = 0;\n\t  s1424(po1->o1->s1,0,0,spar,&kleft,&kleft2,&tval,&kstat);\n\t  if (kstat < 0) goto error;\n\n\t  /* Here we are ready to examine if we really found a max point.*/\n\t  freePoint(qop->p1);\n\t  qop->p1 = SISL_NULL;\n\t  if ((qop->p1 = newPoint(&tval,1,1)) == SISL_NULL) goto err101;\n\n\t  s1161(qop,cmax,aepsge,&qintdat,&kstat);\n\t  if (kstat < 0) goto error;\n\n\t  if (kstat == 2)\n\t    /* New maximum found, delete old ones */\n\t    if (*pintdat != SISL_NULL)\n\t      {\n\t\tfreeIntdat(*pintdat);\n\t\t*pintdat = SISL_NULL;\n\t      }\n\n\t  if ( kstat )\n\t    {\n\t      /* Maximum found, add them to the list */\n\n\t      *jstat = max(*jstat,kstat);  /* Mark maximum found. */\n\n\t      /* Special treatment for putting two\n\t\t new parameters into pintdat from qintdat. */\n\t      s6idput(&qintdat1,qintdat,0,spar[0],&kstat);\n\t      if (kstat < 0) goto error;\n\t      s6idput(pintdat,qintdat1,1,spar[1],&kstat);\n\t      if (kstat < 0) goto error;\n\n\t    }\n\t}\n    }\n\n\n  goto out;\n\n  /* -------------------ERROR SECTION----------------------------*/\n\n  /* Error in space allocation.  */\n err101: *jstat = -101;\n  s6err(\"s1162_s9update\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n  error : *jstat = kstat;\n\n out:\n  if (qcuo != SISL_NULL)\n    {\n      if (qcuo->c1 != SISL_NULL)\n\t{\n\t  freeCurve(qcuo->c1);\n\t  qcuo->c1 = SISL_NULL;\n\t}\n      freeObject(qcuo);\n      qcuo = SISL_NULL;\n    }\n\n  if (qop != SISL_NULL)\n    {\n      if (qop->p1 != SISL_NULL)\n\t{\n\t  freePoint(qop->p1);\n\t  qop->p1 = SISL_NULL;\n\t}\n      freeObject(qop);\n      qop = SISL_NULL;\n    }\n  if (qintdat != SISL_NULL)\n    {\n      freeIntdat(qintdat);\n      qintdat = SISL_NULL;\n    }\n  if (qintdat1 != SISL_NULL)\n    {\n      freeIntdat(qintdat1);\n      qintdat1 = SISL_NULL;\n    }\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1162_s9div(SISLObject *po1,double *cmax,double aepsge,int idiv,int iind1,\n\t\t  int iind2,SISLObject *wob[],SISLIntdat **pintdat,SISLEdge *vedge[2],\n\t\t  int ilevel,int *jstat)\n#else\nstatic void s1162_s9div(po1,cmax,aepsge,idiv,iind1,iind2,\n\t\t  wob,pintdat,vedge,ilevel,jstat)\n     SISLObject *po1;\n     double *cmax;\n     double aepsge;\n     int    idiv;\n     int    iind1;\n     int    iind2;\n     SISLObject *wob[];\n     SISLIntdat **pintdat;\n     SISLEdge   *vedge[2];\n     int    ilevel;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Subdivide an object possible.\n*\n*\n*\n* INPUT      : po1      - The object to subdivide.\n*              aepsge   - Geometry resolution.\n*              idiv     - Subdivision direction.\n*                          = 0     : No subdivision.\n*\t\t           = 1     : Subdivision in first parameter\n*                                                          direction.\n*\t\t           = 2     : Subdivision in second parameter\n*                                                          direction.\n*\t\t           = 3     : Subdivision in first and second\n*                                                parameter direction.\n*\n*             iind1     - Index to first interior knot multiplicity in\n*                         first parameter direction.\n*             iind2     - Index to first interior knot multiplicity in\n*                         second parameter direction.\n*             ilevel    - If > 0  we subdivide in middlepoint.(SISLSurface only)\n*              vedge    - Pointer to edge maximum.\n*\n* INPUT/OUTPUT : cmax  - The level value.\n*\n* OUTPUT     : pintdat  - Maximum data.\n*              wob[]    - Pointers to the subdivided objects.\n*              jstat    - Status messages\n*                          = 2     : New maximum found on new edges.\n*                          = 1     : Maximum found on new edges.\n*                          = 0     : no maximum found.\n*                          < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 89-05.\n* REVISED BY : Paal Fugelli, SINTEF, Oslo, 94-07. Fixed memory leaks.\n*\n*********************************************************************\n*/\n{\n\n  SISLPtedge *qpt;\n\n  int ki, kj,i; /* Counters.                                           */\n  int kpos = 0; /* Position of error.                                  */\n  int kstat= 0; /* Local status                                        */\n  int kk1, kk2, kn1, kn2; /* Local number of knots and vertices.       */\n  int kmax, kind1, kind2; /* Indexes of the maximum vertice.           */\n  double tstart, tend;    /* Start,end and middle values for curve parameter.*/\n  double sstart[2], send[2],tmidle;/* Start, end values for surface parameter*/\n  double tpar, tparold;  /* The parameter vallue for subdivision curve.*/\n  double spar[2],sparold[2]; /* The parameter vallue for subdivision\n\t\t\t\tof a surface.  */\n  double *tmax, *tmin;/* Local max and min value for the vertices of object.*/\n  double sdiff[2];    /* The length of parameter intervall for surface.      */\n  double smin[2];     /* The lower allowed limit in the prameter intervall\n\t\t\t for subdividing a surface.      */\n  double smax[2];    /* The upper allowed limit in the prameter intervall\n\t\t\tfor subdividing a surface.      */\n  SISLSurf *qs1=SISL_NULL;  /* Help pointers while subdividing        */\n  SISLSurf *qs2=SISL_NULL;  /* Help pointers while subdividing        */\n  SISLObject *qop = SISL_NULL;/* Help pointers while subdividing      */\n  SISLObject *qoc = SISL_NULL;/* Help pointers while subdividing      */\n  SISLIntdat *qintdat=SISL_NULL;/* Local max data for the new edges.  */\n\n\n\n  /* Init */\n  *jstat = 0;\n  if ((qop = newObject(SISLPOINT)) == SISL_NULL) goto err101;\n\n  if (po1 == SISL_NULL || po1->iobj == SISLPOINT)\n    /* Nothing to do. */\n    ;\n  else if (po1->iobj == SISLCURVE)\n    {\n      kk1   = po1->c1->ik;\n      kn1   = po1->c1->in;\n      kmax  = po1->c1->pbox->imax;\n      tmax  = po1->c1->pbox->emax;\n      tmin  = po1->c1->pbox->emin;\n\n      tstart = po1->c1->et[kk1-1];\n      tend   = po1->c1->et[kn1];\n\n      /* If we got problems with subdiv in max points, remove as comment: */\n      /*   kmax = 0;  */\n\n\n      /* ------------------Determination of sudiv parameter value-----------*/\n      if (iind1 != 0)\n\t/* We subdivide in an interior knot with multiplicity. */\n\ttpar = po1->c1->et[iind1];\n\n      else if (kmax == 0 || kmax == kn1-1)\n\t/*The greatest coeff is the first or last, divide in middlepoint. */\n\ttpar = s1792(po1->c1->et,kk1, kn1);\n\n\n      else\n\t/* Try to find an inner subdivision (ekstremal) point by iteration. */\n\t{\n\n\t  /* First get a good starting point for the iteration. */\n\t  tpar = 0;\n\t  for (i=kmax+1;i<kmax+kk1;i++)\n\t    tpar += po1->c1->et[i];\n\n\t  tpar /= kk1 - 1;\n\t  tparold = tpar;\n\n\t  /*Iterate using Newton. */\n\t  s1252(po1->c1,aepsge,tpar,&tpar,&kstat);\n\t  if (kstat < 0) goto error;\n\n\t  /* Test if the found point is at start or end. */\n\t  if(DEQUAL(tpar,tstart)  || DEQUAL(tpar,tend))\n\t    /*Try Schoenbergs approximation to max vertice. */\n\t    {\n\t      tpar = tparold;\n\n\t      if(DEQUAL(tpar,tstart)  || DEQUAL(tpar,tend))\n\t\t/*Divide in middlepoint. */\n\t\ttpar = s1792(po1->c1->et,kk1,kn1);\n\t    }\n\t}\n      /* ------------------Subdivision -------------------------------- */\n\n      /* Subdivide the curve at the given parameter value. */\n      s1231(po1->c1,tpar,&(wob[0]->c1),&(wob[1]->c1),&kstat);\n      if (kstat < 0) goto error;\n\n\n      /* Pick out end point from a curve. */\n      s1438(wob[0]->c1,1,&(qop->p1),&tpar,&kstat);\n      if (kstat < 0) goto error;\n\n\n      /* Examin if the subdividing point is a max. */\n      s1161(qop,cmax,aepsge,&qintdat,&kstat);\n      if (kstat < 0) goto error;\n\n      if (kstat == 2)\n\t/* New maximum found, delete old ones */\n\tif (*pintdat != SISL_NULL)\n\t  {\n\n\t    freeIntdat(*pintdat);\n\t    *pintdat = SISL_NULL;\n\t  }\n\n      if (kstat)\n\t{\n\t  /* Maximum found, add them to the list */\n\n\t  *jstat = max(*jstat,kstat);         /* Mark maximum found. */\n\n\t  /* Put maximum found on edges into pintdat. */\n\n\t  /* Set parameter border values of object. */\n\t  s6idput(pintdat,qintdat,0,tpar,&kstat);\n\t  if (kstat < 0) goto error;\n\n\t  if (qintdat != SISL_NULL)\n\t    {\n\t      freeIntdat(qintdat);\n\t      qintdat = SISL_NULL;\n\t    }\n\t}\n    }\n  else if (po1->iobj == SISLSURFACE)\n    {\n      kk1   = po1->s1->ik1;\n      kn1   = po1->s1->in1;\n      kk2   = po1->s1->ik2;\n      kn2   = po1->s1->in2;\n      kmax = po1->s1->pbox->imax;\n      tmax = po1->s1->pbox->emax;\n      tmin = po1->s1->pbox->emin;\n\n      sstart[0] = po1->s1->et1[kk1-1];\n      sstart[1] = po1->s1->et2[kk2-1];\n\n      send[0]   = po1->s1->et1[kn1];\n      send[1]   = po1->s1->et2[kn2];\n\n      sdiff[0] = send[0] - sstart[0];\n      sdiff[1] = send[1] - sstart[1];\n      smin[0]  = sstart[0] + (double)0.01*sdiff[0];\n      smin[1]  = sstart[1] + (double)0.01*sdiff[1];\n      smax[0]  = send[0] - (double)0.01*sdiff[0];\n      smax[1]  = send[1] - (double)0.01*sdiff[0];\n\n      kind2 = kmax/kn1;\n      kind1 = kmax - kind2*kn1;\n\n\n      /* If we got problems with subdiv in max points, remove as comment: */\n      /*  kind1 = 0; */\n\n      /* ------------------Determination of sudiv parameter value-------*/\n      if (iind1 != 0 || iind2 != 0 || ilevel > 0)\n\t{\n\t  if (ilevel > 0)\n\t    /* We are forced to subdivide in middlepoint. */\n\t    {\n\t      spar[0] = s1792(po1->s1->et1,kk1, kn1);\n\t      spar[1] = s1792(po1->s1->et2,kk2, kn2);\n\t    }\n\n\t  else\n\t    /*We have knot multiplicity at least in one parameter direction.\n\t      Subdivide in interior knot multiplicity. If the other parameter\n\t      direction is without multiplicities, subdivide in middlepoint.*/\n\t    {\n\t      if (iind1 != 0)\n\t\tspar[0] = po1->s1->et1[iind1];\n\t      else\n\t\tspar[0] = s1792(po1->s1->et1,kk1, kn1);\n\n\t      if (iind2 != 0 )\n\t\tspar[1] = po1->s1->et2[iind2];\n\t      else\n\t\tspar[1] = s1792(po1->s1->et2,kk2, kn2);\n\t    }\n\t}\n\n\n      else if (kind1 == 0 || kind1 == kn1-1 || kind2 == 0 || kind2 == kn2-1)\n\t{\n\n\t  /*The greatest coeff is on the edge.\n\t    Examin the edge for max and divide\n\t    in these parameter values. If more than one max,\n\t    use the one closest to the middlepoint*/\n\n\t  tmidle = s1792(po1->s1->et1,kk1, kn1);\n\t  spar[0] = sstart[0];\n\n\t  for (kj=0;kj<3;kj+=2)\n\t    {\n\t      qpt = vedge[0]->prpt[kj];\n\t      while (qpt != SISL_NULL)\n\t\t{\n\t\t  if (fabs(qpt->ppt->epar[0] - tmidle) <\n\t\t      fabs(spar[0] - tmidle))\n\t\t    spar[0] = qpt->ppt->epar[0];\n\t\t  qpt = qpt->pnext;\n\t\t}\n\t    }\n\t  if (DEQUAL(spar[0],sstart[0])  || DEQUAL(spar[0],send[0]))\n\t    spar[0] = tmidle;\n\n\t  tmidle = s1792(po1->s1->et2,kk2, kn2);\n\t  spar[1] = sstart[1];\n\n\t  for (kj=1;kj<4;kj+=2)\n\t    {\n\t      qpt = vedge[0]->prpt[kj];\n\t      while (qpt != SISL_NULL)\n\t\t{\n\t\t  if (fabs(qpt->ppt->epar[0] - tmidle) <\n\t\t      fabs(spar[1] - tmidle))\n\t\t    spar[1] = qpt->ppt->epar[1];\n\t\t  qpt = qpt->pnext;\n\t\t}\n\t    }\n\t  if (DEQUAL(spar[1],sstart[1])  || DEQUAL(spar[1],send[1]))\n\t    spar[1] = tmidle;\n\t}\n\n\n      else\n\t/* Try to find an inner subdivision (ekstremal) point by iteration. */\n\t{\n\n\t  /* First get a good starting point for the iteration. */\n\t  spar[0] = 0;\n\t  for (i=kind1+1;i<kind1+kk1;i++)\n\t    spar[0] += po1->s1->et1[i];\n\n\t  spar[0] /= kk1 - 1;\n\t  sparold[0] = spar[0];\n\n\t  spar[1] = 0;\n\t  for (i=kind2+1;i<kind2+kk2;i++)\n\t    spar[1] += po1->s1->et2[i];\n\n\t  spar[1] /= kk2 - 1;\n\t  sparold[1] = spar[1];\n\n\n\t  /* Create a point greater than the surface */\n\t  if ((qop->p1 = newPoint(tmax,1,1)) == SISL_NULL) goto err101;\n\n\t  /* Iterate using Newton. */\n\t  s1173(qop->p1,po1->o1->s1,aepsge,sstart,send,spar,spar,&kstat);\n\t  freePoint(qop->p1);\n\t  qop->p1 = SISL_NULL;\n\t  if (kstat < 0) goto error;\n\n\t  /* Test if the found point is near one edge. */\n\t  if(spar[0] < smin[0] ||spar[0] > smax[0]\n\t     || spar[1] < smin[1] ||spar[1] > smax[1])\n\t    {\n\t      /*Try Schoenberg. */\n\t      spar[0] = sparold[0];\n\t      spar[1] = sparold[1];\n\n\t      if(spar[0] < smin[0] ||spar[0] > smax[0]\n\t\t || spar[1] < smin[1] ||spar[1] > smax[1])\n\t\t{\n\t\t  /*Divide in middlepoint. */\n\t\t  spar[0] = s1792(po1->s1->et1,kk1,kn1);\n\t\t  spar[1] = s1792(po1->s1->et2,kk2,kn2);\n\t\t}\n\t    }\n\n\n\t}\n\n\n      /* ------------------Subdivision ------------------------------*/\n      /* Now we have found the parameters for subdivision, divide! */\n\n      if ((qoc = newObject(SISLCURVE)) == SISL_NULL)\n\tgoto err101;\n\n      for (ki=0; ki<(idiv<3 ? 1:3); ki++)\n\t{\n\n\t  if (idiv == 1)\n\t    {\n\t      s1711(po1->s1,1,spar[0],&(wob[0]->s1),&(wob[1]->s1),&kstat);\n\t      if (kstat < 0) goto error;\n\n\t      /* Pick out edge curve from a surface. */\n\n\t      s1435(wob[0]->s1,1,&(qoc->c1),spar,&kstat);\n\t      if (kstat < 0) goto error;\n\t    }\n\t  else if (idiv == 2)\n\t    {\n\t      s1711(po1->s1,2,spar[1],&(wob[0]->s1),&(wob[1]->s1),&kstat);\n\t      if (kstat < 0) goto error;\n\n\t      /* Pick out edge curve from a surface. */\n\n\t      s1435(wob[0]->s1,2,&(qoc->c1),spar+1,&kstat);\n\t      if (kstat < 0) goto error;\n\t    }\n\t  else if (ki == 0)\n\t    {\n\t      s1711(po1->s1,1,spar[0],&qs1,&qs2,&kstat);\n\t      if (kstat < 0) goto error;\n\n\t      /* Pick out edge curve from a surface. */\n\n\t      s1435(qs1,1,&(qoc->c1),spar,&kstat);\n\t      if (kstat < 0) goto error;\n\t    }\n\t  else if (ki == 1)\n\t    {\n\t      s1711(qs1,2,spar[1],&(wob[0]->s1),&(wob[1]->s1),&kstat);\n\t      if (kstat < 0) goto error;\n\n\t      /* Pick out edge curve from a surface. */\n\n\t      s1435(wob[0]->s1,2,&(qoc->c1),spar+1,&kstat);\n\t      if (kstat < 0) goto error;\n\t    }\n\t  else   /* if (ki == 2) */\n\t    {\n\t      s1711(qs2,2,spar[1],&(wob[2]->s1),&(wob[3]->s1),&kstat);\n\t      if (kstat < 0) goto error;\n\n\t      /* Pick out edge curve from a surface. */\n\n\t      s1435(wob[2]->s1,2,&(qoc->c1),spar+1,&kstat);\n\t      if (kstat < 0) goto error;\n\t    }\n\n\n\t  /* Examine the new edge for max. */\n\n\t  s1161(qoc, cmax, aepsge, &qintdat, &kstat);\n\t  if (kstat < 0) goto error;\n\n\t  freeCurve(qoc->c1);\n\t  qoc->c1 = SISL_NULL;\n\n\n\t  if (kstat == 2)\n\t    /* New maximum found, delete old ones */\n\t    if (*pintdat != SISL_NULL)\n\t      {\n\t\tfreeIntdat(*pintdat);\n\t\t*pintdat = SISL_NULL;\n\t      }\n\n\t  if (kstat)\n\t    {\n\t      /* Maximum found, add them to the list */\n\n\t      *jstat = max(kstat,*jstat);         /* Mark maximum found. */\n\n\t      /* Put maximum found on edges into pintdat. */\n\n\t      /* Test if we can pick the second subdivision parameter\n\t\t from a max on subdiv curve.*/\n\t      if(ki==0 && qintdat->vpoint[0]->epar[0] > smin[1]\n\t\t && qintdat->vpoint[0]->epar[0] < smax[1] )\n\t\tspar[1]=qintdat->vpoint[0]->epar[0];\n\n\n\t      /* Set parameter border values of object. */\n\t      s6idput(pintdat,qintdat,(ki==0 ? 0:1),spar[(ki==0 ? 0:1)],&kstat);\n\t      if (kstat < 0) goto error;\n\n\t      if (qintdat != SISL_NULL)\n\t\t{\n\t\t  freeIntdat(qintdat);\n\t\t  qintdat = SISL_NULL;\n\t\t}\n\n\t    }\n\n\t  /* End of for (ki=/..............) */\n\t}\n\n    }\n  goto out;\n\n  /* -------------------ERROR SECTION------------------------------------*/\n\n  /* Error in space allocation.  */\n err101: *jstat = -101;\n  s6err(\"s1162_s9div\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n  error : *jstat = kstat;\n  s6err(\"s1162_s9div\",*jstat,kpos);\n  goto out;\n  /* -------------------END OF ERROR SECTION----------------------------*/\n\n out:\n  if (qop != SISL_NULL) freeObject(qop);\n  if (qoc != SISL_NULL) freeObject(qoc);\n  if (qs1 != SISL_NULL) freeSurf(qs1);  /* PFU 15/07-94 */\n  if (qs2 != SISL_NULL) freeSurf(qs2);  /* PFU 15/07-94 */\n}\n"
  },
  {
    "path": "src/s1172.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1172.c,v 1.3 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1172\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n#if defined(SISLNEEDPROTOTYPES)\nstatic void s1172_s9corr(double *,double,double,double);\nstatic void s1172_s9dir(double *,double []);\n#else\nstatic void s1172_s9corr();\nstatic void s1172_s9dir();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1172(SISLCurve *pcurve,double astart,\n     double aend, double anext, double *cpos,int *jstat)\n#else\nvoid s1172(pcurve,astart,aend,anext,cpos,jstat)\n     SISLCurve        *pcurve;\n     double       astart;\n     double       aend;\n     double       anext;\n     double       *cpos;\n     int          *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Newton iteration on a onedimensional curve.\n*              The function finds a local extremum.\n*\n*\n* INPUT      : pcurve   - Pointer to the curve.\n*              astart   - Start values of parameter intervall.\n*              aend     - End value of parameter intervall.\n*              anext    - Parameter start value for iteration.\n*\n*\n* OUTPUT     : cpos    - Parameter value of the found extremum.\n*              jstat   - status messages  \n*                                = 1   : Extremum found.\n*                                = 0   : Extremum NOT found.\n*                                < 0   : error.\n*\n*\n* METHOD     : Newton iteration in one parameter direction.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Ulf J. Krystad, SI, OCTOBER 1990\n* CORRECTED BY:  Ulf J. Krystad, SI, AUGUST 1991\n*********************************************************************\n*/                       \n{                        \n  int kstat = 0;            /* Local status variable.                      */\n  int kpos = 0;             /* Position of error.                          */\n  int kleft=0;              /* Variables used in the evaluator.            */\n  int kder=3;               /* Order of derivatives to be calulated        */\n  int knbit;                /* Number of iterations                        */\n  int kdir;                 /* Changing direction.                         */\n  double tdelta;            /* Parameter intervals of the Curve.        */\n  double tdist;             /* Euclidian norm of derivative vector         */\n  double tprev;             /* Previous Euclidian norm of derivative vector*/\n  double td,t1,tdn;         /* Distances between old and new parameter\n\t\t\t       value in the two parameter directions.      */\n  double sval[4];           /* Value ,first and second derivatiev of Curve.*/ \n  double tnext;             /* Parameter values                            */\n  double tol = (double)1000.0*REL_COMP_RES; /* Singularity tolerance      */\n  /* --------------------------------------------------------------------- */\n  \n  /* Test input.  */\n  if (pcurve->idim != 1) goto err106;\n  \n  /* Fetch endpoints and the interval of parameter interval of curves.  */\n  \n  tdelta = pcurve->et[pcurve->in] - pcurve->et[pcurve->ik - 1];\n  \n  /* Evaluate 0-2.st derivatives of curve */\n  s1221(pcurve,kder,anext,&kleft,sval,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Get Euclidian norm of derivative */\n  tprev = fabs(sval[1]);\n  \n  /* Compute the Newton stepdistanse vector. */\n  s1172_s9dir(&td,sval);\n  \n  /* Adjust if we are not inside the parameter intervall. */\n  t1 = td;\n  s1172_s9corr(&t1,anext,astart,aend);\n  \n  /* Iterate to find the intersection point.  */\n  \n  for (knbit = 0; knbit < 50; knbit++)\n    {\n      /* Evaluate 0-3.st derivatives of curve */\n      \n      tnext = anext + t1;\n      \n      s1221(pcurve,kder,tnext,&kleft,sval,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Get Euclidian norm of derivative */\n      tdist = fabs(sval[1]);\n  \n      /* Compute the Newton stepdistanse vector. */\n      s1172_s9dir(&tdn,sval);\n      \n      /* Check if the direction of the step have change. */\n      \n      kdir = (td*tdn >= DZERO);     /* 0 if changed. */\n      \n      if (tdist <= tprev || kdir)\n\t{\n\t  /* Ordinary converging. */\n      \n          anext += t1;\n\n          td = t1 = tdn;\n\t  \n\t  /* Adjust if we are not inside the parameter intervall. */\n\t  s1172_s9corr(&t1,anext,astart,aend);\n\t  \n\t  \n          if (fabs(t1/tdelta) <= REL_COMP_RES)\n\t    {\n\t      anext += t1;\n\t      break;\n\t    }\n\t  \n          tprev = tdist;\n\t}\n      \n      else\n\t{\n\t  /* Not converging, half step length try again. */\n      \n          t1 /= (double)2;\n\t  /*         knbit--;  */\n\t}\n    }\n  \n  /* Iteration stopped, test if point is extremum */\n  \n  if (tdist <= tol)\n    *jstat = 1;\n  else\n    *jstat = 0;\n\n \n  /* Test if the iteration is close to a knot */\n  if (fabs(anext - pcurve->et[kleft])/tdelta < tol)\n    anext = pcurve->et[kleft];\n  else if (fabs(anext - pcurve->et[kleft+1])/tdelta < tol)\n    anext = pcurve->et[kleft+1];\n\n  /* Uppdate output.  */\n  *cpos = anext;\n  \n  /* Iteration completed.  */\n  goto out;\n  \n /* --------------------------------------------------------------------- */ \n  /* Error in input. Dimension not equal to 1 */\n err106: *jstat = -106;\n  s6err(\"s1172\",*jstat,kpos);\n  goto out;                  \n  \n  /* Error in lower level routine.  */\n  error : *jstat = kstat;\n  s6err(\"s1172\",*jstat,kpos);\n  goto out;                  \n  \n out:;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1172_s9corr(double *cd, double acoef,double astart,double aend)\n#else\nstatic void s1172_s9corr(cd,acoef,astart,aend)\n     double *cd;\n     double acoef;\n     double astart;\n     double aend;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To be sure that we are inside the boorder of the\n*              parameter plan. If we are outside clipping is used\n*\t       to corrigate the step value.\n*\n*\n* INPUT      : acoef   - Parameter value to clipp\n*              astart  - The lower boorder\n*              aend    - The higher boorder\n*\n*\n*\n* INPUT/OUTPUT : cd    - Old and new step value.\n*\n*\n* METHOD     : We are cutting a line.\n*\t       In this case we always know that the startpoint of\n*\t       the line is inside the rectangel, and we may therfor\n*\t       use a simple kind of clipping.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/                       \n{\n  if (acoef + *cd < astart)  *cd = astart - acoef;\n  else if (acoef + *cd > aend) *cd = aend - acoef;  \n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1172_s9dir(double *cdiff,double evals[])\n#else\nstatic void s1172_s9dir(cdiff,evals)\n     double *cdiff;\n     double evals[];\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the step according to a Newton scheme\n*              for finding an extremal to a one dimensional curve.\n*\n*\n* INPUT      : evals - Value and derivatives in point on curve.\n*              \n*\n* OUTPUT     : cdiff  - Parameter increment in first direction.\n*            \n*\n*\n* METHOD     : This is a one dimensional case. We want to find x such that\n*\n*                    x : S'(x) = 0      \n*\n*              Using Taylor we get:\n*                  \n*                    x : S'+dxS''+0.5 dxdxS''' = 0\n*\n*\t       The solution of this equation is the\n*\t       following function.\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Ulf J. Krystad, SI, OCTOBER 1990\n*\n*********************************************************************\n*/                       \n{                        \n   double a,b,c,d,d1,d2;\n\n   a = evals[3];\n   b = evals[2];\n   c = b*b - 2.0*a*evals[1];\n   \n   if (fabs(b) > DZERO)  d = -evals[1]/b;\n   else                  d = 0.0;\n   \n   \n   if (c < DZERO)                    *cdiff = d;\n   else if (fabs(a) > DZERO)\n   {\n      c = sqrt(c);\n      d1 = (-b + c)/a;\n      d2 = (-b - c)/a;\n      if (DEQUAL(b,c))               *cdiff = d;\n      else\n\tif (fabs(d1-d) < fabs(d2-d)) *cdiff = d1;\n      else                           *cdiff = d2;\n   }\n   else                              *cdiff = d;\n}\n\n"
  },
  {
    "path": "src/s1173.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1173.c,v 1.2 2001-03-19 15:58:42 afr Exp $\n *\n */\n\n\n#define S1173\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n#if defined(SISLNEEDPROTOTYPES)\nstatic void s1173_s9dir(double *,double *,double *,double [],double [],\n\t\t\tdouble [],double);\nstatic void s1173_s9corr(double [],double,double,double,double,double,double);\nstatic double s1173_s9del(double *,double *,double *,int);\n#else\nstatic void s1173_s9dir();\nstatic void s1173_s9corr();\nstatic double s1173_s9del();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1173(SISLPoint *ppoint, SISLSurf *psurf, double aepsge,double estart[],\n     double eend[], double enext[], double gpos[],int *jstat)\n#else\nvoid s1173(ppoint,psurf,aepsge,estart,eend,enext,gpos,jstat)\n     SISLPoint *ppoint;\n     SISLSurf  *psurf;\n     double       aepsge;\n     double       estart[];\n     double       eend[];\n     double       enext[];\n     double       gpos[];\n     int          *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Newton iteration on the distance function between\n*              a onedimensional surface and a level value (point).\n*              The function finds a closest point(maximum) or an\n*              intersection point.\n*\n*\n* INPUT      : ppoint   - Pointer to the point(level value) in.\n*              psurface - Pointer to the surface.\n*              aepsge   - Geometry resolution.\n*              estart   - Start values of parameter intervalls.\n*              eend     - End value of parameter intervalls.\n*\n*\n*\n* OUTPUT     : gpos    - Parameter values of the surface in intersection\n*                        or closest point( maximum).\n*              jstat   - status messages  \n*                                = 2   : A minimum distanse found.\n*                                = 1   : Intersection found.\n*                                < 0   : error.\n*\n*\n* METHOD     : Newton iteration in two parameter direction.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Ulf J. Krystad, SI, JUNE 1989\n*\n*********************************************************************\n*/                       \n{                        \n  int kstat = 0;            /* Local status variable.                      */\n  int kpos = 0;             /* Position of error.                          */\n  int kleft1=0;             /* Variables used in the evaluator.            */\n  int kleft2=0;             /* Variables used in the evaluator.            */\n  int kder=2;               /* Order of derivatives to be calulated        */\n  int kdim=1;               /* Dimension of space the surface lies in      */\n  int knbit;                /* Number of iterations                        */\n  int kdir;                 /* Changing direction.                         */\n  double tdelta[2];         /* Parameter intervals of the surface.         */\n  double tdist;             /* Distance between position and origo.        */\n  double td[2],t1[2],tdn[2];/* Distances between old and new parameter\n\t\t\t       value in the tree parameter directions.     */\n  double tprev;             /* Previous difference between the curves.     */\n  double *sval =SISL_NULL;       /* Value ,first and second derivatiev of surf. */ \n  double *sdiff;            /* Difference between the point and the surf.  */\n  double *snorm;            /* Normal vector of the surface, dummy.        */\n  double snext[2];          /* Parameter values                            */\n  \n  /* Test input.  */\n  \n  if (ppoint->idim != psurf->idim) goto err106;\n  if (ppoint->idim != kdim) goto err106;\n  \n  /* Fetch endpoints and the intervals of parameter interval of curves.  */\n  \n  tdelta[0] = psurf->et1[psurf->in1] - psurf->et1[psurf->ik1 - 1];\n  tdelta[1] = psurf->et2[psurf->in2] - psurf->et2[psurf->ik2 - 1];\n  \n  \n  /* Allocate local used memory */\n  \n  sval = newarray(8*kdim,double);\n  if (sval == SISL_NULL) goto err101;\n  \n  sdiff = sval + 6*kdim;\n  snorm = sdiff + kdim;\n  \n  /* Initiate variables.  */\n  \n  tprev = (double)HUGE;\n  \n  \n  /* Evaluate 0-1.st derivatives of surface */\n  \n  s1421(psurf,kder,enext,&kleft1,&kleft2,sval,snorm,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Compute the distanse vector and value and the new step. */\n  \n  s1173_s9dir(&tdist,td,td+1,sdiff,ppoint->ecoef,sval,aepsge);\n  \n  \n  /* Correct if we are not inside the parameter intervall. */\n  \n  \n  t1[0] = td[0];\n  t1[1] = td[1];\n  s1173_s9corr(t1,enext[0],enext[1],estart[0],eend[0],estart[1],eend[1]);\n  \n  \n  /* Iterate to find the intersection point.  */\n  \n  for (knbit = 0; knbit < 50; knbit++)\n    {\n      /* Evaluate 0-1.st derivatives of surface */\n      \n      snext[0] = enext[0] + t1[0];\n      snext[1] = enext[1] + t1[1];\n      \n      s1421(psurf,kder,snext,&kleft1,&kleft2,sval,snorm,&kstat);\n      if (kstat < 0) goto error;\n      \n      \n      /* Compute the distanse vector and value and the new step. */\n      \n      s1173_s9dir(&tdist,tdn,tdn+1,sdiff,ppoint->ecoef,sval,aepsge);\n      \n      \n      /* Check if the direction of the step have change. */\n      \n      kdir = (s6scpr(td,tdn,2) >= DZERO);     /* 0 if changed. */\n      \n      \n      /* Ordinary converging. */\n      \n      if (tdist <= tprev || kdir)\n\t{\n          enext[0] += t1[0];\n          enext[1] += t1[1];\n\t  \n          td[0] = t1[0] = tdn[0];\n          td[1] = t1[1] = tdn[1];\n\t  \n\t  /* Correct if we are not inside the parameter intervall. */\n\t  \n\t  s1173_s9corr(t1,enext[0],enext[1],estart[0],eend[0],estart[1],eend[1]);\n\t  \n\t  \n          if ( (fabs(t1[0]/tdelta[0]) <= REL_COMP_RES) &&\n\t      (fabs(t1[1]/tdelta[1]) <= REL_COMP_RES)) break;\n\t  \n          tprev = tdist;\n\t}\n      \n      /* Not converging, corrigate and try again. */\n      \n      else\n\t{\n          t1[0] /= (double)2;\n          t1[1] /= (double)2;\n\t}\n    }\n  \n  /* Iteration stopped, test if point is within resolution */\n  \n  if (tdist <= aepsge)\n    *jstat = 1;\n  else\n    *jstat = 2;\n  \n  /* Test if the iteration is close to a knot */\n  if (DEQUAL(enext[0],psurf->et1[kleft1]))\n    gpos[0] = psurf->et1[kleft1];\n  else if (DEQUAL(enext[0],psurf->et1[kleft1+1]))\n    gpos[0] = psurf->et1[kleft1+1];\n  else\n    gpos[0] = enext[0];\n  \n  if (DEQUAL(enext[1],psurf->et2[kleft2]))\n    gpos[1] = psurf->et2[kleft2];\n  else if (DEQUAL(enext[1],psurf->et2[kleft2+1]))\n    gpos[1] = psurf->et2[kleft2+1];\n  else\n    gpos[1] = enext[1];\n  \n  \n  /* Iteration completed.  */\n  \n  \n  goto out;\n  \n  \n  /* Error in allocation */\n  \n err101: *jstat = -101;\n  s6err(\"s1173\",*jstat,kpos);\n  goto out;                  \n  \n  /* Error in input. Conflicting dimensions.  */\n  \n err106: *jstat = -106;\n  s6err(\"s1173\",*jstat,kpos);\n  goto out;                  \n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"s1173\",*jstat,kpos);\n  goto out;                  \n  \n out:    if (sval != SISL_NULL) freearray(sval);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1173_s9corr(double gd[], double acoef1,double acoef2,double astart1,\n\t\t   double aend1,double astart2, double aend2)\n#else\nstatic void s1173_s9corr(gd,acoef1,acoef2,astart1,aend1,astart2,aend2)\n     double gd[];\n     double acoef1;\n     double acoef2;\n     double astart1;\n     double aend1;\n     double astart2;\n     double aend2;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To be sure that we are inside the boorder of the\n*              parameter plan. If we are outside clipping is used\n*\t       to corrigate the step value.\n*\n*\n* INPUT      : acoef1  - Coeffisient in the first direction.\n*              acoef2  - Coeffisient in the second direction.\n*              astart1 - The lower boorder in first direction.\n*              aend1   - The higher boorder in first direction.\n*              estart2 - The lower boorder in second direction.\n*              eend2   - The higher boorder in second direction.\n*\n*\n*\n* INPUT/OUTPUT : gd    - Old and new step value.\n*\n*\n* METHOD     : We are cutting a line inside a rectangle.\n*\t       In this case we always know that the startpoint of\n*\t       the line is inside the rectangel, and we may therfor\n*\t       use a simple kind of clipping.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/                       \n{\n  if (acoef1 + gd[0] < astart1)  gd[0] = astart1 - acoef1;\n  else if (acoef1 + gd[0] > aend1) gd[0] = aend1 - acoef1;\n  \n  if (acoef2 + gd[1] < astart2)  gd[1] = astart2 - acoef2;\n  else if (acoef2 + gd[1] > aend2) gd[1] = aend2 - acoef2;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1173_s9dir(double *cdist, double *cdiff1, double *cdiff2,\n\t\t  double gdiff[], double evalp[], double evals[], double aepsge)\n#else\nstatic void s1173_s9dir(cdist,cdiff1,cdiff2,gdiff,evalp,evals,aepsge)\n     double *cdist;\n     double *cdiff1;\n     double *cdiff2;\n     double gdiff[];\n     double evalp[];\n     double evals[];\n     double aepsge;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the distance vector and value beetween\n*\t       a point and a point on a surface.\n*\t       And to compute a next step on both parameter direction\n*\n*\n* INPUT      : evalp - Value in point.\n*              evals - Value and derivatives in point on surface.\n*              aepsge  - The geometry resolution.\n*\n* OUTPUT     : gdiff   - Array to use when computing the differens vector.\n*\t       cdiff1  - Relative parameter value in intersection \n*                        point in first direction.\n*              cdiff2  - Relative parameter value in intersection \n*                        point in second direction.\n*              cdist   - The value to the point in the distance surface.\n*\n*\n* METHOD     : This is a one dimensional case. We want to minimize\n*\n*                   min <(point - S(x,y),point - S(x,y)>\n*                    x,y\n*\n*              This is equivalent to     \n*\n*                    x,y : (point-S(x,y))Sx(x,y) = 0      \n*                          (point-S(x,y))Sy(x,y) = 0      \n*\n*              Using Taylor we get:\n*                  \n*                    x,y : (point-S-DxSx-DySy)(Sx+DxSxx+DySxy) =0\n*                          (point-S-DxSx-DySy)(Sy+DySyy+DxSxy) =0\n*\n*              If we neglect the Dx**2,Dy**2 and Dx*Dy parts, we get:\n*\n*   x,y: [(point-S)Sxx - Sx**2]Dx + [(point-S)Sxy - Sx*Sy]Dy = - (point-S)Sx \n*        [(point-S)Syy - Sy**2]Dy + [(point-S)Sxy - Sx*Sy]Dx = - (point-S)Sy \n*\n*\t       The solution of this matrix equation is the\n*\t       following function.\n*              If, however, the matrix is singular, \n*              we estimate Dx and Dy separately\n*              by Newton iteration in one variable. \n*              We combine these two increments\n*              by convexcombination to get the minimum distance to move(!=0)\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Ulf J. Krystad, SI, June 1989\n*\n*********************************************************************\n*/                       \n{                        \n  int kstat=0;\t\t      /* Local status variable.                    */\n  double tdiv;\t\t      /* Determinant                               */\n  double ta11,ta12,ta21,ta22; /* The matrix                  \t\t   */\n  double tmax;                /* The largest value in matrix               */\n  double tb1,tb2;             /* The right hand side.                      */\n  double tval,tderx,tderxx;   /* Function and deriv. \n\t\t\t\t values in one-dimentional case */\n  double tdery,tderyy;\n  double tderxy;\n  double tdeltax,tdeltay;   /* Locals for the step value to be determined. */\n  double ttemp;             /* Temporary value. */\n  \n  if (aepsge < 0) kstat=1;\n  \n  /* Computing the different vector */\n  s6diff(evalp,evals,1,gdiff);\n  \n  /* Computing the length of the different vector. */\n  *cdist = s6length(gdiff,1,&kstat);\n  \n  /* Init */\n  tval   = evals[0];\n  tderx  = evals[1];\n  tdery  = evals[2];\n  tderxx = evals[3];\n  tderxy = evals[4];\n  tderyy = evals[5];\n  tdeltax = DZERO;\n  tdeltay = DZERO;\n  *cdiff1  = DZERO;\n  *cdiff2  = DZERO;\n  \n  \n  /* Building the matrix. */\n  \n  ta11 = (gdiff[0]*tderxx - tderx*tderx);\n  ta12 = (gdiff[0]*tderxy - tderx*tdery);\n  ta21 = (gdiff[0]*tderxy - tderx*tdery);\n  ta22 = (gdiff[0]*tderyy - tdery*tdery);\n  tb1  = -gdiff[0]*tderx;\n  tb2  = -gdiff[0]*tdery;\n  \n  if (DEQUAL(tb1,DZERO) && DEQUAL(tb2,DZERO))\n    {\n      /* Finished, we have found a max. */\n    }\n  else\n    {\n      tdiv    = ta11*ta22 - ta21*ta12;\n      tmax = max(fabs(ta11),max(fabs(ta12),max(fabs(ta21),fabs(ta22))));\n      \n      if (fabs(tdiv) > tmax*REL_COMP_RES)\n\t{\n\t  /* The matrix is ok, solve the system using Cramers rule. */\n\t  tdeltax = tb1*ta22 - tb2*ta12;    \n\t  tdeltay = ta11*tb2 - ta21*tb1;\n\t  tdeltax /= tdiv;\n\t  tdeltay /= tdiv;\n\t}\n      else\n\t{\n\t  /* The matrix is nearly singular, \n\t     use Newton on each parameter direction*/\n\t  tdeltax = s1173_s9del(gdiff,&tderx,&tderxx,1);\n\t  tdeltay = s1173_s9del(gdiff,&tdery,&tderyy,1);\n\t  \n\t  \n\t  if (fabs(tdeltax) < REL_COMP_RES || fabs(tdeltay) < REL_COMP_RES )\n\t    /* If one is very small, we use them as they are. */\n\t    ;\n\t  else\n\t    {\n\t      /* Use the shortest step; min (1-k)Dx + kDy */\n\t      ttemp   = tdeltay*tdeltax/(tdeltax*tdeltax + tdeltay*tdeltay);\n\t      tdeltax = tdeltay*ttemp;\n\t      tdeltay = tdeltax*ttemp;\n\t      \n\t    }\n\t  \n\t} \n    }  \n  \n  *cdiff1  = tdeltax;\n  *cdiff2  = tdeltay;\n  \n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic double\ns1173_s9del(double *eco, double *eco1, double *eco2, int idim)\n#else\nstatic double s1173_s9del(eco,eco1,eco2,idim)\n     double *eco;\n     double *eco1;\n     double *eco2;\n     int    idim;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the distance on the parameter line to a point\n*            on the curve on which the tangent is orthogonal to the\n*            difference vector from this point on the curve to the\n*            point in the space.\n*\n*\n* INPUT      : eco   - The differens vector beetween the point and the\n*                      current posision on the curve.\n*              eco1  - The first derevative vector in the  current posision\n*                      on the curve.\n*              eco2  - The second derevative vector in the  current posision\n*                      on the curve.\n*              idim  - Dimension of space the vectors lie in.\n*\n*\n* OUTPUT     : s1173_s9del - The computed parameter distance.\n*\n*\n* METHOD     : We have to find the parameter distance \"dt\" from\n*              the equation:\n*                <ecoef-dt*ecoef1,ecoef1+dt*ecoef2> = 0.\n*              This may be written:\n*                  <ecoef,ecoef1> + <ecoef,ecoef2>*dt\n*                - <ecoef1,ecoef1>*dt + <ecoef1,ecoef2>*dt*dt = 0\n*              The following function is the solution of this second\n*              degree equation. We are always using the solution\n*              with the smallest absolute value.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Mar 1989\n*\n*********************************************************************\n*/                       \n{\n  double t1,t2,t3,t4,t5,t6;   /* Constants in equation.                 */\n  \n  t1 =  s6scpr(eco,eco1,idim);\n  t3 =  s6scpr(eco1,eco1,idim);\n  t2 =  t3 - s6scpr(eco,eco2,idim);\n  t4 =  -(double)2 * s6scpr(eco1,eco2,idim);\n  \n  \n  \n  if (DEQUAL(t4,DZERO))    /* The second degree part is degenerated. */\n    {\n      if (DEQUAL(t2,DZERO)) \n\t{\n          if (DEQUAL(t3,DZERO))            return DZERO;\n          else                             return (t1/t3);\n\t}\n      else                                  return (t1/t2);\n    }\n  else                /* An ordinary second degree equation.    */\n    {\n      t5 = t2*t2 - (double)2*t4*t1;\n      if (t5 < DZERO)                       return (t1/t3);\n      else\n\t{\n          t6 = sqrt(t5);\n          t5 = (t2 + t6)/t4;\n          t6 = (t2 - t6)/t4;\n\t  t1 *= t3;\n\t  \n\t  \n          /* We have two solutions and we want to use the one\n\t     with the same sign as we get while using an other\n\t     metode t1/t3. If both solutions have the same\n\t     sign we use the one with smallest value. */\n\t  \n          if (t1 < DZERO)\n\t    {\n\t      if (t5 <= DZERO && t6 <= DZERO)\n\t\t{\n\t\t  if (t5 > t6)             return t5;\n\t          else                     return t6;\n\t\t}\n\t      else if (t5 <= DZERO)        return t5;\n\t      else if (t6 <= DZERO)        return t6;\n              else                         return min(t5,t6);\n\t    }\n\t  else if (t1 > DZERO)\n\t    {\n\t      if (t5 >= DZERO && t6 >= DZERO)\n\t\t{\n\t\t  if (t5 < t6)             return t5;\n\t          else                     return t6;\n\t\t}\n\t      else if (t5 >= DZERO)        return t5;\n\t      else if (t6 >= DZERO)        return t6;\n              else                         return max(t5,t6);\n\t    }\n\t  else                             return min(fabs(t5),fabs(t6));\n\t}\n    }\n}\n\n\n\n\n\n\n\n\n\n\n\n\n"
  },
  {
    "path": "src/s1174.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1174.c,v 1.5 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1174\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n#if defined(SISLNEEDPROTOTYPES)\nstatic void s1174_s9corr(double [],double,double,double,double,double,double);\nstatic void s1174_s9dir(double *,double *,double []);\n#else\nstatic void s1174_s9corr();\nstatic void s1174_s9dir();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1174(SISLSurf *psurf,double estart[],\n     double eend[], double enext[], double gpos[],int *jstat)\n#else\nvoid s1174(psurf,estart,eend,enext,gpos,jstat)\n     SISLSurf         *psurf;\n     double       estart[];\n     double       eend[];\n     double       enext[];\n     double       gpos[];\n     int          *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Newton iteration on a onedimensional surface.\n*              The function finds a local extremum.\n*\n*\n* INPUT      : psurface - Pointer to the surface.\n*              estart   - Start values of parameter intervalls.\n*              eend     - End value of parameter intervalls.\n*              enext    - Parameter start value for iteration.\n*\n*\n* OUTPUT     : gpos    - Parameter values of the found extremum.\n*              jstat   - status messages\n*                                = 1   : Extremum found.\n*                                = 0   : Extremum NOT found.\n*                                < 0   : error.\n*\n*\n* METHOD     : Newton iteration in two parameter direction.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Ulf J. Krystad, SI, OCTOBER 1990\n* Changed by : Per OEyvind Hvidsten, SINTEF, 11-94\n*              Added an initialization of tdist.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;            /* Local status variable.                      */\n  int kpos = 0;             /* Position of error.                          */\n  int kleft1=0;             /* Variables used in the evaluator.            */\n  int kleft2=0;             /* Variables used in the evaluator.            */\n  int kder=2;               /* Order of derivatives to be calulated        */\n  int knbit;                /* Number of iterations                        */\n  int kdir;                 /* Changing direction.                         */\n  double tdelta[2];         /* Parameter intervals of the surface.         */\n  double tdist = 0.0;       /* Euclidian norm of derivative vector         */\n  double tprev;             /* Previous Euclidian norm of derivative vector*/\n  double td[2],t1[2],tdn[2];/* Distances between old and new parameter\n\t\t\t       value in the two parameter directions.      */\n  double sval[7];           /* Value ,first and second derivatiev of surf. */\n  double *snorm=sval+7;     /* Normal vector of the surface, dummy.        */\n  double snext[2];          /* Parameter values                            */\n  double tol = (double)10000.0*REL_COMP_RES; /* Singularity tolerance        */\n  /* --------------------------------------------------------------------- */\n\n  /* Test input.  */\n  if (psurf->idim != 1) goto err106;\n\n  /* Fetch endpoints and the intervals of parameter interval of curves.  */\n\n  tdelta[0] = psurf->et1[psurf->in1] - psurf->et1[psurf->ik1 - 1];\n  tdelta[1] = psurf->et2[psurf->in2] - psurf->et2[psurf->ik2 - 1];\n\n\n  /* Initiate variables.  */\n  gpos[0] = enext[0];\n  gpos[1] = enext[1];\n\n  /* Evaluate 0-2.st derivatives of surface */\n  s1421(psurf,kder,gpos,&kleft1,&kleft2,sval,snorm,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Get Euclidian norm of derivative vector */\n  tprev = sqrt(sval[1]*sval[1] + sval[2]*sval[2]);\n\n  /* Compute the Newton stepdistanse vector. */\n  s1174_s9dir(td,td+1,sval);\n\n  if ( (fabs(td[0]/tdelta[0]) <= REL_COMP_RES) &&\n      (fabs(td[1]/tdelta[1]) <= REL_COMP_RES))\n     goto stop_it;\n\n  /* Adjust if we are not inside the parameter intervall. */\n  t1[0] = td[0];\n  t1[1] = td[1];\n  s1174_s9corr(t1,gpos[0],gpos[1],estart[0],eend[0],estart[1],eend[1]);\n\n  /* Iterate to find the intersection point.  */\n\n  for (knbit = 0; knbit < 50; knbit++)\n    {\n      /* Evaluate 0-2.st derivatives of surface */\n\n      snext[0] = gpos[0] + t1[0];\n      snext[1] = gpos[1] + t1[1];\n\n      s1421(psurf,kder,snext,&kleft1,&kleft2,sval,snorm,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Get Euclidian norm of derivative vector */\n      tdist = sqrt(sval[1]*sval[1] + sval[2]*sval[2]);\n\n      /* Compute the Newton stepdistanse vector. */\n      s1174_s9dir(tdn,tdn+1,sval);\n\n      /* Check if the direction of the step have change. */\n\n      kdir = (s6scpr(td,tdn,2) >= DZERO);     /* 0 if changed. */\n\n      if (tdist <= tprev || kdir)\n\t{\n\t  /* Ordinary converging. */\n\n          gpos[0] += t1[0];\n          gpos[1] += t1[1];\n\n          td[0] = t1[0] = tdn[0];\n          td[1] = t1[1] = tdn[1];\n\n\t  /* Adjust if we are not inside the parameter intervall. */\n\t  s1174_s9corr(t1,gpos[0],gpos[1],estart[0],eend[0],estart[1],eend[1]);\n\n\n          if ( (fabs(t1[0]/tdelta[0]) <= REL_COMP_RES) &&\n\t      (fabs(t1[1]/tdelta[1]) <= REL_COMP_RES))\n\t    {\n\t      gpos[0] += t1[0];\n\t      gpos[1] += t1[1];\n\n\t      break;\n\t    }\n\n          tprev = tdist;\n\t}\n\n      else\n\t{\n\t  /* Not converging, half step length try again. */\n\n          t1[0] /= (double)2;\n          t1[1] /= (double)2;\n\t  /*         knbit--;  */\n\t}\n    }\n\n  /* Iteration stopped, test if point is extremum */\n\n  stop_it:\n\n  if (tdist <= tol)\n    *jstat = 1;\n  else\n    *jstat = 0;\n\n\n  /* Test if the iteration is close to a knot */\n  if (fabs(gpos[0] - psurf->et1[kleft1])/tdelta[0] < tol)\n    gpos[0] = psurf->et1[kleft1];\n  else if (fabs(gpos[0] - psurf->et1[kleft1+1])/tdelta[0] < tol)\n    gpos[0] = psurf->et1[kleft1+1];\n\n  if (fabs(gpos[1] - psurf->et2[kleft2])/tdelta[1] < tol)\n    gpos[1] = psurf->et2[kleft2];\n  else if (fabs(gpos[1] - psurf->et2[kleft2+1])/tdelta[1] < tol)\n    gpos[1] = psurf->et2[kleft2+1];\n\n  /* Iteration completed.  */\n  goto out;\n\n /* --------------------------------------------------------------------- */\n  /* Error in input. Dimension not equal to 1 */\n err106: *jstat = -106;\n  s6err(\"s1174\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n  error : *jstat = kstat;\n  s6err(\"s1174\",*jstat,kpos);\n  goto out;\n\n out:;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1174_s9corr(double gd[], double acoef1,double acoef2,double astart1,\n\t\t   double aend1,double astart2, double aend2)\n#else\nstatic void s1174_s9corr(gd,acoef1,acoef2,astart1,aend1,astart2,aend2)\n     double gd[];\n     double acoef1;\n     double acoef2;\n     double astart1;\n     double aend1;\n     double astart2;\n     double aend2;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To be sure that we are inside the boorder of the\n*              parameter plan. If we are outside clipping is used\n*\t       to corrigate the step value.\n*\n*\n* INPUT      : acoef1  - Coeffisient in the first direction.\n*              acoef2  - Coeffisient in the second direction.\n*              astart1 - The lower boorder in first direction.\n*              aend1   - The higher boorder in first direction.\n*              estart2 - The lower boorder in second direction.\n*              eend2   - The higher boorder in second direction.\n*\n*\n*\n* INPUT/OUTPUT : gd    - Old and new step value.\n*\n*\n* METHOD     : We are cutting a line inside a rectangle.\n*\t       In this case we always know that the startpoint of\n*\t       the line is inside the rectangel, and we may therfor\n*\t       use a simple kind of clipping.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/\n{\n  if (acoef1 + gd[0] < astart1)  gd[0] = astart1 - acoef1;\n  else if (acoef1 + gd[0] > aend1) gd[0] = aend1 - acoef1;\n\n  if (acoef2 + gd[1] < astart2)  gd[1] = astart2 - acoef2;\n  else if (acoef2 + gd[1] > aend2) gd[1] = aend2 - acoef2;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1174_s9dir(double *cdiff1, double *cdiff2,double evals[])\n#else\nstatic void s1174_s9dir(cdiff1,cdiff2,evals)\n     double *cdiff1;\n     double *cdiff2;\n     double evals[];\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To compute the step according to a Newton scheme\n*              for finding an extremal to a one dimensional surface.\n*\n*\n* INPUT      : evals - Value and derivatives in point on surface.\n*\n*\n* OUTPUT     : cdiff1  - Parameter increment in first direction.\n*              cdiff2  - Parameter increment in second direction.\n*\n*\n*\n* METHOD     : This is a one dimensional case. We want to find x,y such that\n*\n*                    x,y : Sx(x,y) = 0\n*                          Sy(x,y) = 0\n*\n*              Using Taylor we get:\n*\n*                    x,y : Sx+DxSxx+DySxy =0\n*                          Sy+DySyy+DxSxy =0\n*\n*                    x,y: SxxDx + SxyDy = - Sx\n*                         SyyDy + SxyDx = - Sy\n*\n*\t       The solution of this matrix equation is the\n*\t       following function.\n*              No effort is done if the matrix is singular,\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Ulf J. Krystad, SI, OCTOBER 1990\n*\n*********************************************************************\n*/\n{\n  double tdiv;\t\t      /* Determinant                               */\n  double ta11,ta12,ta21,ta22; /* The matrix                  \t\t   */\n  double tmax;                /* The largest value in matrix               */\n  double tb1,tb2;             /* The right hand side.                      */\n  double tderx,tderxx;        /* Derivatives                               */\n  double tdery,tderyy;\n  double tderxy;\n  double tdeltax,tdeltay;   /* Locals for the step value to be determined. */\n  /* --------------------------------------------------------------------- */\n\n  /* Init */\n  tderx  = evals[1];\n  tdery  = evals[2];\n  tderxx = evals[3];\n  tderxy = evals[4];\n  tderyy = evals[5];\n  tdeltax = DZERO;\n  tdeltay = DZERO;\n  *cdiff1  = DZERO;\n  *cdiff2  = DZERO;\n\n\n  /* Building the matrix. */\n\n  ta11 = tderxx;\n  ta12 = tderxy;\n  ta21 = tderxy;\n  ta22 = tderyy;\n  tb1  = -tderx;\n  tb2  = -tdery;\n\n  tmax = max(fabs(ta11),max(fabs(ta12),max(fabs(ta21),fabs(ta22))));\n\n  if (DEQUAL(tb1+tmax,tmax) && DEQUAL(tb2+tmax,tmax))\n    {\n      /* Finished, we have found a max. */\n    }\n  else\n    {\n      tdiv    = ta11*ta22 - ta21*ta12;\n      if (fabs(tdiv) > MAX(tmax*REL_COMP_RES,REL_COMP_RES))\n\t{\n\t  /* The matrix is ok, solve the system using Cramers rule. */\n\t  tdeltax = tb1*ta22 - tb2*ta12;\n\t  tdeltay = ta11*tb2 - ta21*tb1;\n\t  tdeltax /= tdiv;\n\t  tdeltay /= tdiv;\n\t}\n      else if (max (fabs(ta11),fabs(ta22)) > REL_COMP_RES)\n\t{\n\t   if (fabs(ta11) > fabs(ta22))\n\t     tdeltax = tb1/ta11;\n\t   else\n\t     tdeltay = tb2/ta22;\n\t}\n\n    }\n\n  *cdiff1  = tdeltax;\n  *cdiff2  = tdeltay;\n\n}\n"
  },
  {
    "path": "src/s1190.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1190.c,v 1.2 2001-03-19 15:58:42 afr Exp $\n *\n */\n\n\n#define S1190\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1190(SISLObject *po1, double *cmax, double aepsge,int *jstat)\n#else\nvoid s1190(po1,cmax,aepsge,jstat)\n     SISLObject *po1;\n     double        *cmax;\n     double        aepsge;\n     int           *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Perform a box-test on the one-dimensional object po1 \n*              versus the level value cmax;\n*\n*\n* INPUT      : po1    - The object.\n*              cmax   - The level value.\n*\t       aepsge - Geometry resolution.\n*                                                                     \n*\n* OUTPUT     : jstat  - status messages  \n\n*                            = 3      : Only touching in corner(s).\n*                            = 2      : The object is constant.\n*                            = 1      : No overlap.\n*\t\t\t     = 0      : Boxmax  > level value.\n*                            < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 89-05.\n*\n*********************************************************************\n*/                                     \n{\n  int kstat = 0;        /* Local status error.                        */\n  int kpos = 0;         /* Position of error.                         */\n  int kcorn = 0;        /* Number of corners in object.               */\n  int li[4];\t        /* Contains the indexes of the corners.       */\n  int kbez = 0;         /* Flag to mark bezier curve or patch.        */\n  int kdim;\t        /* Dimension of space.\t\t\t      */\n  int in1,in2;\t        /* Local number of vertices.     \t      */\n  int i1;\t        /* Counter.                     \t      */\n  int kmax;             /* Index for the largest value of \n\t\t\t   the vertices of the object*/\n  double *tmin1,*tmax1; /* Smallest and largest value of \n\t\t\t   the vertices of the object*/\n  double scorn[4];      /* The corner values of the object*/\n  \n  \n  *jstat = 0;  \n  \n  /* Check kind of first object. */\n  \n  if (po1->iobj == SISLPOINT)\n    {\n      kcorn = 0;\n      /* Fetch dimention of the object. */\n      \n      if((kdim = po1->p1->idim) != 1) goto err105;;\n      \n      \n      /* Check if the SISLbox have been computed. */\n      \n      if (po1->p1->pbox == SISL_NULL)\n\t{\n\t  /* If not compute a box. */\n\t  \n\t  s1192(po1,aepsge,&kstat);\n\t  if (kstat<0) goto error;\n\t}\n      \n      /* Fetch the SISLbox boarder. */\n      \n      kmax  = po1->p1->pbox->imax;      \n      tmax1 = po1->p1->pbox->emax;\n      tmin1 = po1->p1->pbox->emin;\n    }\n  else\n    if (po1->iobj == SISLCURVE)\n      {\n\t/* Fetch dimention of the object. */\n\t\n\tif((kdim = po1->c1->idim) != 1) goto err105;;\n\t\n\t/* Fetch corners. */\n\t\n\tkcorn = 2;\n\tli[0] = 0;\n\tli[1] = po1->c1->in - 1;\n\tscorn[0] = po1->c1->ecoef[li[0]];\n\tscorn[1] = po1->c1->ecoef[li[1]];\n\t\n\t/* Check if we have a bezier curve. */\n\t\n\tif (po1->c1->in == po1->c1->ik) kbez = 1;\n\t\n\t/* Check if the SISLbox have been computed. */\n\t\n\tif (po1->c1->pbox == SISL_NULL)\n\t  {\n\t    /* If not compute a box. */\n\t    \n\t    s1192(po1,aepsge,&kstat);\n\t    if (kstat<0) goto error;\n\t  }\n\t\n\t/* Fetch the SISLbox boarder. */\n\tkmax  = po1->c1->pbox->imax;      \t\n\ttmax1 = po1->c1->pbox->emax;\n\ttmin1 = po1->c1->pbox->emin;\n      }\n    else\n      if (po1->iobj == SISLSURFACE)\n\t{\n\t  /* Fetch dimention of the object. */\n\t  \n\t  if((kdim = po1->s1->idim) != 1) goto err105;;\n\t  \n\t  \n\t  kcorn = 4;\n\t  in1   = po1->s1->in1;\n\t  in2   = po1->s1->in2;\n\t  li[0] = 0;\n\t  li[1] = in1 - 1;\n\t  li[2] = in1*(in2 - 1);\n\t  li[3] = in1*in2-1;\n\t  scorn[0] = po1->s1->ecoef[li[0]];\n\t  scorn[1] = po1->s1->ecoef[li[1]];\n\t  scorn[2] = po1->s1->ecoef[li[2]];\n\t  scorn[3] = po1->s1->ecoef[li[3]];\n\t  \n\t  /* Check if we have a bezier patch. */\n\t  \n\t  if (po1->s1->in1 == po1->s1->ik1 &&\n\t      po1->s1->in2 == po1->s1->ik2)    kbez = 1;\n\t  \n\t  /* Check if the SISLbox have been computed. */\n\t  \n\t  if (po1->s1->pbox == SISL_NULL)\n\t    {\n\t      /* If not compute a box. */\n\t      \n\t      s1192(po1,aepsge,&kstat);\n\t      if (kstat<0) goto error;\n\t    }\n\t  \n\t  /* Fetch the SISLbox boarder. */\n\t  kmax  = po1->s1->pbox->imax;\t  \n\t  tmax1 = po1->s1->pbox->emax;\n\t  tmin1 = po1->s1->pbox->emin;\n\t}\n      else  goto err121;\n  \n  \n  /* Now we've got the box, do the test: */\n  \n  if (*cmax - *tmax1 > aepsge)\n    *jstat = 1;         /* The object is beyond level value. */\n  \n  else if (*tmax1 - *tmin1 < aepsge)\n    *jstat = 2;         /* The object is of constant value. */ \n  \n  else\n    /* if (kbez)*/\n    {\n      /*check for corner max. */\n      for (i1=0; i1<kcorn; i1++)\n\tif (fabs(scorn[i1] - *tmax1) < aepsge)\n\t  {\n\t    \n\t    *jstat = 3;         /* Only corner touching possible.*/\n\t    break;\n\t    \n\t  }\n    }\n  /*  \n    else */\n  /*check for absolute corner max. */\n  /*    for (i1=0; i1<kcorn; i1++)\n\tif (kmax == li[i1])\n\t{\n\t\n\t*jstat = 3;    */     /* Only corner touching possible.*/\n  /*\t  break;\n\t  \n\t  }\n\t  \n\t  */  \n  \n  /* Box-test performed. */\n  goto out;\n\n  /* Dimensions not equal one. */\n  \n err105: *jstat = -105;\n  s6err(\"s1190\",*jstat,kpos);\n  goto out;\n  \n  /* Kind of object does not exist. */\n  \n err121: *jstat = -121;\n  s6err(\"s1190\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine. */\n  \n error:  *jstat = kstat;\n  s6err(\"s1190\",*jstat,kpos);\n  goto out;\n  \n out:\treturn;\n}\n\n\n\n\n\n"
  },
  {
    "path": "src/s1192.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1192.c,v 1.2 2001-03-19 15:58:42 afr Exp $\n *\n */\n\n\n#define S1192\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n#if defined(SISLNEEDPROTOTYPES)\nstatic void s1192_s9mbox(double [],int,int,double,double *,double *,\n\t\t\t int *,int *);\n#else\nstatic void s1192_s9mbox();\n#endif\n\f  \n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1192(SISLObject *po,double aepsge,int *jstat)\n#else\nvoid s1192(po,aepsge,jstat)\n     SISLObject *po;\n     double aepsge;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make a SISLbox on the control-polygons given by\n*              ecoef to the object. If dimension is 2 then one\n*\t       SISLbox rotated 45 degree is also made. If dimension\n*\t       is 3 then one SISLbox roteted 45 degree around each\n*\t       main axes, in all 4 boxes is made.\n*\n*\n*\n* INPUT      : po     - SISLObject to treat.\n*              aepsge - Geometry resolution.\n*\n* OUTPUT     : jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                                                                     \n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Ulf J. krystad, SI, 89-06.\n*\n*********************************************************************\n*/                                     \n{\n  int kpos = 0;                        /* Position of error.   */\n  \n  \n  if (po -> iobj == SISLPOINT)\n    {\n      if (po->p1->idim != 1) goto err105;\n      \n      if (po->p1->pbox == SISL_NULL)\n\t{\n\t  if ((po->p1->pbox = newbox(po->p1->idim))==SISL_NULL)\n\t    goto err101;\n\t  \n\t  s1192_s9mbox(po->p1->ecoef,1,1,aepsge,\n\t\t po->p1->pbox->emax,po->p1->pbox->emin,\n\t\t &po->p1->pbox->imax,&po->p1->pbox->imin);\n\t  \n\t  \n\t}\n    }\n  else\n    if (po -> iobj == SISLCURVE)\n      {\n\tif (po->c1->idim != 1) goto err105;\n\tif (po->c1->pbox == SISL_NULL)\n\t  {\n\t    if ((po->c1->pbox = newbox(po->c1->idim))==SISL_NULL)\n\t      goto err101;\n\t    \n\t    s1192_s9mbox(po->c1->ecoef,po->c1->in,1,aepsge,\n\t\t   po->c1->pbox->emax,po->c1->pbox->emin,\n\t\t   &po->c1->pbox->imax,&po->c1->pbox->imin);\n\t    \n\t  }\n      }\n    else\n      if (po -> iobj == SISLSURFACE)\n\t{\n\t  if (po->s1->idim != 1) goto err105;\n\t  if (po->s1->pbox == SISL_NULL)\n\t    {\n\t      if ((po->s1->pbox = newbox(po->s1->idim))==SISL_NULL)\n\t\tgoto err101;\n\t      \n\t      s1192_s9mbox(po->s1->ecoef,po->s1->in1,po->s1->in2,aepsge,\n\t\t     po->s1->pbox->emax,po->s1->pbox->emin,\n\t\t     &po->s1->pbox->imax,&po->s1->pbox->imin);\n\t    }\n\t}\n  \n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1192\",*jstat,kpos);\n  goto out;\n  \n  /* Dimension not equal one.  */\n  \n err105: *jstat = -105;\n  s6err(\"s1192\",*jstat,kpos);\n  goto out;\n  \n out: ;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1192_s9mbox(double ecoef[], int in1,int in2,double aepsge,\n\t\t   double *cmax, double *cmin,int *jmax,int *jmin)\n#else\nstatic void s1192_s9mbox(ecoef,in1,in2,aepsge,cmax,cmin,jmax,jmin)\n     double ecoef[];\n     int    in1;\n     int    in2;\n     double aepsge;\n     double *cmax;\n     double *cmin;\n     int    *jmin;\n     int    *jmax;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make a SISLbox on the control-polygons given by\n*              ecoef to the object, one-dimensional case.\n*\n*\n* INPUT      : ecoef  - Control-polygon.\n*              in1    - Number of vertices in control-polygon 1. direction.\n*              in2    - Number of vertices in control-polygon 2. direction.\n*              aepsge - The geometry resolution.\n*                                                                     \n*\n* OUTPUT     : cmax   - Maximum value of the box.\n*\t       cmin   - Minimum value of the box.\n*\t       jmax   - The ecoef index of the maximum value.\n*\t       jmin   - The ecoef index of the minimum value.\n*                       NB : If jmin,jmax has the value of a corner, it is \n*                       guaranteed that no inner vertice is close(within aepsge)\n*                       to the max (min) value.\n\n*\n* METHOD     : We treat the corners and the inner points separately and get\n*              the result by comparing max(min) corners to ditto inners.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 89-06.\n*\n*********************************************************************\n*/                                     \n{\n  int ki,kj,li[4];         /* Counters.  */\n  int icorn;               /* Number of corners in object.  */\n  int kmin, kmax;          /* Index for max and min corner value.  */\n  double tmin, tmax;       /* Max and min corner value.  */\n  \n  /* Compute the indexes of the (up to four) corners. */\n  li[0] = 0;\n  li[1] = in1 -1;\n  li[2] = in1*(in2 - 1);\n  li[3] = in1*in2 - 1;\n  \n  /* Set number of corners. \n     for point, curve, surface. */\n  if(in1 == 1)\n    {\n      if(in2 == 1) \n\ticorn = 0;\n      else\n\ticorn = 2;\n    }\n  else\n    icorn = 4;\n  \n  /* Now find the max and min corner. */\n  tmax = tmin = ecoef[li[0]];\n  kmin = kmax = 0;\n  \n  for (ki = 1; ki < icorn; ki++)\n    {\n      if (ecoef[li[ki]] > tmax)\n\t{\n\t  tmax = ecoef[li[ki]];\n\t  kmax = li[ki];\n\t}\n      \n      if (ecoef[li[ki]] < tmin)\n\t{\n\t  tmin = ecoef[li[ki]];\n\t  kmin = li[ki];\n\t}\n    }\n  \n  /* Now find the max and min for the inner of the object. */\n  *cmax = tmax - (double)1000.0;\n  *jmax = -1;\n  *cmin = tmin + (double)1000.0;\n  *jmin = -1;\n  \n  for (ki = 0; ki < icorn - 1; ki++)\n    for (kj = li[ki] + 1; kj < li[ki + 1]; kj++)\n      {\n\tif (ecoef[kj] > *cmax)\n\t  {\n\t    *cmax = ecoef[kj];\n\t    *jmax = kj;\n\t  }\n\t\n\tif (ecoef[kj] < *cmin)\n\t  {\n\t    *cmin = ecoef[kj];\n\t    *jmin = kj;\n\t  }\n      }\n  \n  \n  /* At last compare the corner values against the interior ones */\n  \n  if (tmax > *cmax + aepsge)\n    { \n      *cmax = tmax;\n      *jmax = kmax;\n    }\n  \n  if (tmin < *cmin - aepsge)\n    { \n      *cmin = tmin;\n      *jmin = kmin;\n    }\n}\n"
  },
  {
    "path": "src/s1219.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1219.c,v 1.2 2000-05-23 08:44:05 vsk Exp $\n *\n */\n\n\n#define S1219\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1219(double *et,int ik,int in,int *ileft,double ax,int *jstat)\n#else\nvoid s1219(et,ik,in,ileft,ax,jstat)\n     double *et;\n     int    ik;\n     int    in;\n     int    *ileft;\n     double ax;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To localize the point ax in the array et.\n*              The output ileft should satisfy the relations\n*                          \n*                    et[ileft] <= ax < et[ileft+1].\n* \n*              There are two exceptions to this. If (ax >= et[in])\n*              then ileft should be in-1 (this corresponds to extending\n*              the polynomial piece between et[in-1] and et[in] to the\n*              right of the natural parameter interval.\n*              Similarly, if (ax < et[ik-1]) then ileft should still be\n*              ik-1.\n*\n*\n*\n* INPUT      : et     - Double array of dimension [in+ik] containing\n*                       the knot vector.\n*              ik     - The polynomial order of the B-splines associated\n*                       with et.\n*              in     - The dimension of the spline space associated with\n*                       the knot vector et.\n*              ax     - The point at which the B-spline values and derivatives\n*                       are to be computed.\n*\n*                \n*\n* INPUT/OUTPUT : ileft - Pointer to the interval in the knot vector\n*                       where ax is located, check the relations above.\n*              jstat  - Status messages  \n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : The aim is to do as little work as possible in the cases\n*              where ileft has the right or almost the right value.\n*              First of all we make sure that ileft has a legal value\n*              (a value in the range ik-1 to in-1). Then we check\n*              if the current value is OK.\n*              If it is not we check that ax is in the interior of et\n*              or if the right value is obtained by either increasing\n*              or decreasing ileft by 1. If the right value still has\n*              not been found we do a binary search.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Knut Moerken, University of Oslo, August 1988.\n*\n*********************************************************************\n*/                                     \n{\n  int kpos=0;         /* The position of the error.                      */\n  int kleft;          /* Local version of ileft to avoid the pointer.    */\n  \n  /* Check the input. */\n  \n  if (ik < 1) goto err110;\n  \n  if (in < ik) goto err111;\n  \n  if (et[ik-1] == et[ik] || et[in-1] == et[in]) goto err112;\n  \n  /* Make sure that kleft is in the legal range. */\n  \n  kleft = min(max(ik-1,*ileft),in-1);\n  \n  /* Check if the current value of kleft is acceptable. */\n  \n  if (et[kleft] <= ax && ax < et[kleft+1]) ;\n  \n  /* Check if ax is outside (et[ik-1],et[in]). */\n  \n  else if (ax >= et[in-1])\n    kleft = in - 1;\n  else if (ax <= et[ik-1])\n    kleft = ik - 1;\n  \n  /* Check if it is sufficient to increase or decrease kleft by one. */\n  \n  else if (et[kleft+1] <= ax && ax < et[kleft+2])\n    kleft += 1;\n  else if (kleft > 0 && et[kleft-1] <= ax && ax < et[kleft])\n    kleft -= 1;\n  \n  /* Last resort - a binary search. */\n  else\n    {\n      \n      /* kmin and kmax gives the upper and lower limits on the possible values\n\t of kleft.                                                       */\n      \n      int kmin,kmax;\n      \n      kmin = ik - 1; kmax = in - 1;\n      kleft = (kmin+kmax)/2;\n      \n      while (ax < et[kleft] || et[kleft+1] <= ax)\n\t{\n\t  if (ax < et[kleft])\n\t    kmax = kleft;\n\t  else\n\t    kmin = kleft;\n\t  \n\t  kleft = (kmin+kmax)/2;\n\t}\n    }\n  \n  *ileft = kleft;\n  \n  /* Successful computations.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Polynomial order less than 1. */\n err110: *jstat = -110;\n  s6err(\"s1219\",*jstat,kpos);\n  goto out;\n  \n  /* Fewer B-splines than the order. */\n err111: *jstat = -111;\n  s6err(\"s1219\",*jstat,kpos);\n  goto out;\n  \n  /* Error in knot vector.\n     (The first or last interval of the knot vector is empty.) */\n err112: *jstat = -112;\n  s6err(\"s1219\",*jstat,kpos);\n  goto out;\n  \n out: return;\n}\n"
  },
  {
    "path": "src/s1220.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1220.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1220\n#include \"sislP.h\"\n \n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1220(double *et,int ik,int in,int *ileft,\n\t   double ax,int ider,double ebder[],int *jstat)\n#else\nvoid s1220(et,ik,in,ileft,ax,ider,ebder,jstat)\n     double *et;\n     int    ik;\n     int    in;\n     int    *ileft;\n     double ax;\n     int    ider;\n     double ebder[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the value and ider first derivatives of the\n*              ik (possibly) nonzero B-splines associated with the knot\n*              vector et at the point ax.\n*\n*\n*\n* INPUT      : et     - Double array of dimension [in+ik] containing\n*                       the knot vector.\n*              ik     - The polynomial order of the B-splines associated\n*                       with et.\n*              in     - The dimension of the spline space associated with\n*                       the knot vector et.\n*              ax     - The point at which the B-spline values and derivatives\n*                       are to be computed.\n*              ider   - The number of derivatives to be computed.\n*                       < 0 : Error.\n*                       = 0 : Compute position.\n*                       = 1 : Compute position and first derivative.\n*                       etc.\n*\n*                \n*\n* INPUT/OUTPUT : ileft - Pointer to the interval in the knot vector\n*                        where ax is located. The relation\n*                          \n*                          et[ileft] <= ax < et[ileft+1]\n* \n*                        should hold. (If ax == et[in] then ileft should\n*                        be in-1.)\n*                        If ileft does not have the right value upon\n*                        entry to the routine, its value will be changed\n*                        to the value satisfying the above condition.\n*\n*\n*\n* OUTPUT     : ebder  - Double array of dimension [ik*(ider+1)] containing\n*                       values of the ik nonzero B-splines and their\n*                       derivatives at the point ax. These numbers are stored\n*                       in the following order:\n*                       First the 0-ider derivatives of the first nonzero\n*                       B-splines at ax and so on. In other words, if ebder\n*                       is considered as a two dimensional array its\n*                       declaration in C would be ebder[ik,ider+1].\n*              jstat  - Status messages  \n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : It is well known that at a given point there are at most\n*              ik nonzero B-splines. If ileft satisfies the condition\n*              above, these B-splines, at the point ax, are\n*\n*                    B(ileft-ik+1),B(ileft-ik+2),...,B(ileft).\n*\n*              The number ileft is therefore determined at the beginning\n*              of the routine.\n*              To compute the values and derivatives of these B-splines,\n*              the fundamental recurrence relations (k=ik, t=et, x=ax)\n*\n*                 B(i,k)(x)=(x-t(i))*Q(i,k-1)(x) + (t(i+k)-x)*Q(i+1,k-1)(x) (1)\n*\n*              and\n*\n*                DB(i,k)(x)=(k-1)*(Q(i,k-1)(x) - Q(i+1,k-1)(x))             (2)\n*\n*              are used. Here\n*\n*                             / B(i,k)(x)/(t(i+k)-t(i)),    if t(i) < t(i+k);\n*                  Q(i,k)(x)=/\n*                            \\\n*                             \\           0,                otherwise;\n*\n*\n*                            / 1,           if t(i) <= x < t(i+k);\n*                 B(i,1)(x)=/\n*                           \\\n*                            \\ 0,           otherwise;\n*\n*              and DB(i,k)(x) denotes differentiation with respect to x.\n*              (This makes the B-splines continuous from the right; note that\n*              at the right hand end of the parameter value, at et[in],\n*              ileft is still in-1 so that at that point the B-splines\n*              are left continuous which is common practice.)\n*              From (2) one obtains\n*\n*               D(r)B(i,k)(x)=(k-1)*(D(r-1)Q(i,k-1)(x) - D(r-1)Q(i+1,k-1)(x)),\n*\n*              (D(r) denotes r-fold differentation). From this it follows that\n*              the r'th derivative of a B-spline is a linear combination\n*              of B-splines of order k-r for r<k and zero for larger values\n*              of r. Therefore, to compute the r'th derivative of all the\n*              nonzero B-splines at x one starts with the one B-spline of\n*              order 1 that is nonzero at x, namely B(ileft,1).\n*              By using (1) the two B-splines of order 2 that are nonzero\n*              at x are obtained, B(ileft-1,2) and B(ileft,2).\n*              Continuing in this way one can compute the value of the k-r\n*              B-splines of order k-r that are nonzero at x.\n*              At this point one switches to (2) and obtains first the first\n*              derivative of all the nonzero B-splines of order k-r+1 at x,\n*              B(ileft-k+r,k-r+1),...,B(ileft,k-r+1), then the second\n*              derivative of all the nonzero B-splines of order k-r+2 at x.\n*              Applying (2) repeatedly in this fashion one eventually\n*              obtains the r'th derivative of the k nonzero B-splines of order\n*              k at x,\n*\n*                D(r)B(ileft-k+1,k),D(r)B(ileft-k+2,k),....,D(r)B(ileft,k).\n*\n*              Now the objective in this routine is not only to compute\n*              the r'th derivative of all the nonzero B-splines for\n*              one particular value of r, but for all r with 0 <= r <= ider.\n*              With the above in mind, a natural way to do this is to start\n*              with the one nonzero B-spline of order 1 and then apply (1)\n*              k-ider-1 times to obtain all the nonzero B-splines of order\n*              k-ider. During the next iteration both (1) and (2) are applied\n*              to these B-spline values to obtain the values and first\n*              derivatives of the nonzero B-splines of order k-ider+1.\n*              In the next iteration (2) is applied to both the 0'th and\n*              1'st derivatives to obtain the 1'st and 2'nd derivatives of\n*              all nonzero derivatives of order k-ider+2, and (1) is applied\n*              to the 0'th derivative to obtain the value of all nonzero\n*              B-splines of order k-ider+2.\n*              Continuing this process ider-2 more times one ends up with\n*              the desired derivatives.\n*\n*              All these computations are performed in ebder and the author\n*              finds it easiest to think of (the one dimensional array) ebder\n*              as a two dimensional array of dimension [ider+1,ik]\n*              (ider+1 rows and ik columns).\n*          NB! If one conforms with C's view of two dimensional arrays, then\n*              ebder would be of dimension [ik,ider+1] (first come the\n*              ider+1 derivatives of the first nonzero B-spline and so on).\n*\n*              One then starts with the one nonzero B-spline of order 1 in\n*              the lower right corner of ebder and then while applying (1)\n*              fills in the last row of ebder from the right.\n*              After k-ider-1 iterations the last k-ider elements of the last\n*              row will be filled in with values of the k-ider nonzero\n*              B-splines of order k-ider. These values are then copied up\n*              to the second but last row and during the next iteration\n*              (1) is applied to this row and (2) to the bottom row.\n*              Then the second but last row is copied up to the third but\n*              last row and (1) is applied to this row and (2) to the two\n*              bottom rows. This is then repeated until ebder is filled\n*              with the B-spline values in the first row, the first derivatives\n*              in the second row and so on.\n*\n*              Note that (1) may be rewritten as\n*\n*             B(i,k)(x) = w(i)(x)*B(i,k-1)(x) + (1-w(i+1)(x))*B(i+1,k-1)(x) (3)\n*\n*              where\n*\n*                           / (x-t(i))/(t(i+k-1)-t(i)), if t(i) < t(i+k);\n*                  w(i)(x)=/\n*                          \\\n*                           \\            0,             otherwise.\n*\n*              Note also that if et[ileft] <= x < et[ileft+1], then for\n*              the nonzero B-splines B(ileft-k+1),...,B(ileft) the denominator\n*              in the definition of w(i) is always nonzero. Since this\n*              denominator is the same number as the one that divides\n*              B(i,k-1) in (2), it is evident that with a correct knot vector,\n*              no division by zero can occur.\n*\n* REFERENCES : Any work on elementary B-spline theory.\n*\n*-\n* CALLS      : s1219 - Determine the value of ileft for the given ax.\n*\n* WRITTEN BY : Knut Moerken, University of Oslo, August 1988.\n* REWISED BY : Vibeke Skytt, SI, 11.92.  Avoid memory error with order 1.\n*\n*********************************************************************\n*/                                     \n{\n  int kstat=0;        /* Local status variable.                          */\n  int kpos=0;         /* The position of the error.                      */\n  int kdeg;           /* Convenience variable which is set to ik-1.      */\n  int kleft;          /* Local version of ileft in order to avoid\n\t\t\t the pointer.                                    */\n  int ki,kj,ks;       /* Control variables in for loops and for stepping\n\t\t\t through arrays.                                 */\n  int ki1,ki2,kjh;    /* Control variables in for loops and for stepping\n\t\t\t through arrays.                                 */\n  int kder;           /* Local version of ider. All derivatives of order\n\t\t\t higher than ik-1 are zero so\n\t\t\t kder=min(ik-1,ider).                            */\n  double td1,td2;     /* These variables are used to store the inverse of\n\t\t\t the number that divides B(i,k-1) and B(i+1,k-1)\n\t\t\t in (2) above.                                   */\n  double tw1,tw2;     /* These variabels are used to store the factors\n\t\t\t multiplying B(i,k-1) and B(i+1,k-1) in (1)\n\t\t\t above.                                          */\n  double ts1,ts2;     /* These variables are similar to td1 and td2 except\n\t\t\t that they will also contain the appropriate\n\t\t\t integer factor stemming from (2).               */\n  double tt,tth;      /* Auxiliary variables used to avoid unnecessary\n\t\t\t look ups in the knot vector.                    */\n  /* Check the input. */                                       \n  \n  if (ider < 0) goto err178;\n  \n  /* Find the right value of ileft and check input. */\n  \n  s1219(et,ik,in,ileft,ax,&kstat);\n  \n  if (kstat < 0) goto error;\n  \n  /* Initialize. */\n  \n  kleft = *ileft;\n  kdeg = ik - 1;\n  kder = min(ik-1,ider);\n  \n  /* The fact that kder can be less than ider causes some problems.\n     If kder < ider we know that ebder in the end should be a (kder+1)xik\n     matrix augmented with ider-kder rows of zeros at the bottom.\n     Since we store the matrix column by column, care must be taken to\n     access the entries correctly.\n     In the comments below ebder will usually be considered to be a\n     (kder+1)xik matrix.\n     ki2 is set to point to the last element of ebder (the lower right entry\n     of the matrix, cf. above), and this element is set to one\n     (this is the lower right corner of the (kder+1)*ik part of ebder). */\n  \n  ki2 = (ik-1)*(ider+1) + kder;\n  ebder[ki2] = (double)1.0;\n  \n  if (ik == 1)\n  {\n     /* VSK. Constant. Task is done.  */\n     \n     *jstat = 0;\n     goto out;\n  }\n  \n  /* Get ready for the main iteration loop where (1) and/or (2) are applied\n     each time. In these iterations ki1 will run through the entries of ebder\n     to be computed, starting at the upper left corner and running down the\n     rows.\n     ki2 will follow ki1 but be one row ahead of ki1 to take care of the second\n     term in (1) and (2).\n     Note that when accessing the entries of ebder the convention is\n     used that the pointer to the entry has to be incremented first.\n     ki1 is therefore initialized to point to the element before the first\n     element to be computed in the first iteration (the second but \n     last diagonal element of ebder).\n     If (ider == ik-1) then we first have to copy up the last row and\n     initialize ki1 to point to the entry above the second but last diagonal\n     element of ebder.                                                       */\n  \n  ki1 = ki2 - ider - 2;\n  if (kder == kdeg)\n    {\n      ebder[ki2-1] = (double)1.0;\n      ki1 -= 1;\n    }\n  \n  /* ki2 should be one row ahead of ki1 and each row has ider+1 entries. */\n  \n  ki2 = ki1 + ider + 1;\n  \n  /* Iterate and apply (1) and/or (2) each time. ks counts the degree of the\n     B-splines whose values and derivaties are to be computed in this\n     iteration.                                                          */\n  \n  for(ks=1; ks<ik; ks++)\n    {\n      \n      /* In (1) and (2) the denominators that divide B(i,k-1) and B(i+1,k-1)\n\t are on the form (t(i+k-1)-t(i)). Below kj is used as the (i) index\n\t and kjh as the (i+k-1) index. It is the alternative form (3) of\n\t (1) that is used below and tw2 is used as 1-w(i+1) and tw1 as\n\t w(i).\n\t For the first nonzero B-spline of degree ks, the first term in\n\t (1) and (2) is zero.\n\t kj is initialized to point to the first knot that gives a contribution\n\t during this iteration and kjh to point to `t(kj+ks)=t(kleft+1)'.\n\t If (t(kjh)-t(kj)) <= 0.0 there must be an error in the knot vector. */\n      \n      kj = kleft - ks + 1;\n      kjh = kleft + 1;\n      tt = et[kjh++];\n      tth = tt - et[kj];\n      if (tth <= (double)0.0) goto err112;\n      td2 = (double)1.0/tth;\n      tw2 = (tt-ax)*td2;\n      \n      ebder[++ki1] = tw2*ebder[++ki2];\n      \n      /* Check to see if there is either copying or differentiation to do. */\n      \n      if (ks >= kdeg-kder && kder > 0)\n\t{\n\t  /* Copy the first element of the row up to the previous\n\t     unless it is the last iteration.                     */\n\t  \n\t  if (ks < kdeg)\n\t    ebder[ki1-1] = ebder[ki1];\n\t  \n\t  /* Apply (2) to the rest of this column. Remember that this\n\t     is the first nonzero column of ebder so the first term in (2)\n\t     is zero.                                                     */\n\t  \n\t  ts2 = ks*td2;\n\t  for (ki=0; ki<ks-kdeg+kder; ki++)\n\t    ebder[++ki1] = -ts2*ebder[++ki2];\n\t  \n\t  /* Step to the top of the next column (the last time ebder\n\t     is full and there is no stepping to do (unless kder <ider). */\n\t  \n\t  ki1 += ider - kder + kdeg - ks;\n\t  ki2 = ki1 + ider + 1;\n\t}\n      else\n\t{\n\t  \n\t  /* If there was no copying or differentiation to be done\n\t     we just step to the top of the next column. This step is zero\n\t     if there are no derivatives to be computed.                  */\n\t  \n\t  ki1 += ider;\n\t  ki2 += ider;\n\t}\n      \n      /*  Loop through the ks-1 middle columns of ebder. */\n      \n      for (kj=kleft-ks+2; kj<=kleft; kj++)\n\t{\n\t  \n\t  /* Compute the denominators and weights (w(i+1)) to be used.\n\t     See the comments above for more details.                  */\n\t  \n\t  tt = et[kjh++];\n\t  tth = tt - et[kj];\n\t  if (tth <= (double)0.0) goto err112;\n\t  td1 = td2; td2 = (double)1.0/tth;\n\t  tw1 = (double)1.0 - tw2; tw2 = (tt-ax)*td2;\n\t  \n\t  ki1 += 1;\n\t  ebder[ki1] = tw1*ebder[ki1] + tw2*ebder[++ki2];\n\t  \n\t  /* Check if there is copying and differentiation to be done. */\n\t  \n\t  if (ks >= kdeg-kder && kder > 0)\n\t    {\n\t      \n\t      /* Copy unless it is the last iteration. */\n\t      \n\t      if (ks < kdeg)\n\t\tebder[ki1-1] = ebder[ki1];\n\t      \n\t      /* Do the differentiation. */\n\t      \n\t      ts1 = ts2; ts2 = ks*td2;\n\t      for (ki=0; ki<ks-kdeg+kder; ki++)\n\t\t{\n\t\t  ki1 += 1;\n\t\t  ebder[ki1] = ts1*ebder[ki1] - ts2*ebder[++ki2];\n\t\t}\n\t      \n\t      /* Jump to the next column. */\n\t      \n\t      ki1 += ider - kder + kdeg - ks;\n\t      ki2 = ki1 + ider + 1;\n\t    }\n\t  else\n\t    {\n\t      \n\t      /* Jump to the next column. */\n\t      \n\t      ki1 += ider;\n\t      ki2 += ider;\n\t    }\n\t}\n      \n      /* Compute the last column of ebder. Remember that now the last term\n\t in (1) and (2) is zero, so there is no new td2 or tw2 to compute. */\n      \n      td1 = td2;\n      tw1 = (double)1.0 - tw2;\n      \n      ki1 += 1;\n      ebder[ki1] = tw1*ebder[ki1];\n      \n      /* Check if there is copying or differentiation to do. */\n      \n      if (ks >= kdeg-kder && kder > 0)\n\t{\n\t  \n\t  /* Copy. */\n\t  \n\t  if (ks < kdeg)\n\t    ebder[ki1-1] = ebder[ki1];\n\t  \n\t  /* Differentiate. */\n\t  \n\t  ts1 = ts2;\n\t  for (ki=0; ki<ks-kdeg+kder; ki++)\n\t    {\n\t      ki1 += 1;\n\t      ebder[ki1] = ts1*ebder[ki1];\n\t    }\n\t  \n\t  /* Move ki1 back to the first nonzero element of the last column.\n\t     Each column now has ks-kdeg+kder+2 nonzero elements.         */\n\t  \n\t  ki1 -= ks - kdeg + kder + 1;\n\t}\n      \n      /* Move ki1 from the first element of the last column to the element\n\t prior to the first nonzero element in the first column.\n\t ki2 is as usual one column ahead of ki1.                          */\n      \n      ki1 -= (ks+1)*(ider+1) + 1;\n      ki2 = ki1 + ider + 1;\n    }\n  \n  /* Set the remaining derivatives to zero. */\n  \n  for (ki=kder+1; ki<=ider; ki++)\n    {\n      ki1 = ki;\n      for (kj=0; kj<ik; kj++)\n\t{\n\t  ebder[ki1] = (double)0.0;\n\t  ki1 += ider + 1;\n\t}\n    }\n  \n  /* Successful computations.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error in knot vector.\n     (The first or last interval of the knot vector is empty\n     or it is decreasing or has to high multiplicity.)      */\n err112: *jstat = -112;\n  s6err(\"s1220\",*jstat,kpos);\n  goto out;\n  \n  /* Illegal derivative requested. */\n err178: *jstat = -178;\n  s6err(\"s1220\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n error:  *jstat = kstat;\n  s6err(\"s1220\",*jstat,kpos);\n  goto out;\n  \n out: return;\n}\n"
  },
  {
    "path": "src/s1221.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1221.c,v 1.3 2001-03-19 15:58:42 afr Exp $\n *\n */\n\n\n#define S1221\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1221(SISLCurve *pc1,int ider,double ax,int *ileft,double eder[],int *jstat)\n#else\nvoid s1221(pc1,ider,ax,ileft,eder,jstat)\n     SISLCurve *pc1;\n     int ider;\n     double ax;\n     int *ileft;\n     double eder[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To compute the value and ider first derivatives of the\n*              NURBS curve pointed to by pc1, at the point with\n*              parameter value ax.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve for which position\n*                       and derivatives are to be computed.\n*              ider   - The number of derivatives to compute.\n*                       < 0 : Error.\n*                       = 0 : Compute position.\n*                       = 1 : Compute position and first derivative.\n*                       etc.\n*              ax     - The parameter value at which to compute\n*                       position and derivatives.\n*\n*\n*\n* INPUT/OUTPUT : ileft - Pointer to the interval in the knot vector\n*                        where ax is located. If et is the knot vector,\n*                        the relation\n*\n*                          et[ileft] <= ax < et[ileft+1]\n*\n*                        should hold. (If ax == et[in] then ileft should\n*                        be in-1. Here in is the number of NURBS\n*                        coefficients.)\n*                        If ileft does not have the right value upon\n*                        entry to the routine, its value will be changed\n*                        to the value satisfying the above condition.\n*\n*\n*\n* OUTPUT     : eder   - Double array of dimension [(ider+1)*idim]\n*                       containing the position and derivative vectors.\n*                       (idim is the number of components of each B-spline\n*                       coefficient, i.e. the dimension of the Euclidean\n*                       space in which the curve lies.)\n*                       These vectors are stored in the following order:\n*                       First the idim components of the position vector,\n*                       then the idim components of the tangent vector,\n*                       then the idim components of the second derivative\n*                       vector, and so on.\n*                       (The C declaration of eder as a two dimensional array\n*                       would therefore be eder[ider+1,idim].)\n*              jstat  - Status messages\n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : Suppose that the given curve is of the form\n*\n*                   f(x) = sum(i) c(i) B(i,k)(x)\n*\n*              where c are the B-spline coefficients and B(i,k)(x) the\n*              B-splines accociated with the knot vector et.\n*              (For idim > 1 this is a vector equation with idim\n*              components; however, the B-spline is not a vector.)\n*              It is known that for a given value of x there are at most\n*              k (the order of the splines) nonzero B-splines.\n*              If ileft has the correct value these B-splines will be\n*\n*              B(ileft-k+1,k),B(ileft+k+2,k),...,B(ileft,k).\n*\n*              The position and derivatives are computed by\n*              first computing the values and derivatives of all the\n*              B-splines at x, and then multiplying and summing.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1220    - Computes B-spline values and derivatives at\n*                         a given point.\n*              s6err    - Error handling routine\n*              s6ratder - Make derivative of rational expression\n*\n* WRITTEN BY : Knut Moerken, University of Oslo, August 1988.\n* REVISED BY : Tor Dokken, SI, Oslo, Norway, January 1989\n* MODIFIED BY : Mike Floater, SI, Oslo, Norway, January 1991 for rational case.\n* MODIFIED BY : Mike Floater, SI, Oslo, Norway, April 1991 free arrays.\n* REVISED BY : Johannes Kaasa, SI, Aug. 92 (In case of NURBS, the maximum\n*              derivative is not set equal to the order).\n*\n*********************************************************************\n*/\n{\n  int kstat=0;        /* Local status variable.                          */\n  int kpos=0;         /* The position of the error.                      */\n  int kn;             /* The number of B-splines, i.e., the dimension of\n\t\t\t the spline space associated with the knot\n\t\t\t vector.                                         */\n  int kk;             /* The polynomial order of the curve.              */\n  int kdim;           /* The dimension of the space in which the curve\n\t\t\t lies. Equivalently, the number of components\n\t\t\t of each B-spline coefficient.                   */\n  int kleft;          /* Local version of ileft which is used in order to\n\t\t\t avoid the pointer.                              */\n  int kder;           /* Local version of ider. Since derivatives of order\n\t\t\t higher than kk-1 are all zero, we set\n\t\t\t kder = min(kk-1,ider).                          */\n  int kind;           /* Type of curve                                   */\n  int ki,kj,kih,kjh;  /* Control variables in for loops and for stepping\n\t\t\t through arrays.                                 */\n  int kl,kl1,kl2;     /* Control variables in for loops and for stepping\n\t\t\t through arrays.                                 */\n  double *st;         /* Pointer to the first element of the knot vector\n\t\t\t of the curve. The knot vector has [kn+kk]\n\t\t\t elements.                                       */\n  double *scoef;      /* Pointer to the first element of the curve's\n\t\t\t B-spline coefficients. This is assumed to be an\n\t\t\t array with [kn*kdim] elements stored in the\n\t\t\t following order:\n\t\t\t First the kdim components of the first B-spline\n\t\t\t coefficient, then the kdim components of the\n\t\t\t second B-spline coefficient and so on.          */\n  double tt;          /* Dummy variable used for holding an array element\n\t\t\t in a for loop.                                  */\n  double *ebder=SISL_NULL; /* Pointer to an array of dimension [kk*(ider+1)]\n\t\t       which will contain the values and ider first derivatives\n\t\t\t of the kk nonzero B-splines at ax.\n\t\t\t These are stored in the following order:\n\t\t\t First the value, 1. derivative etc. of the\n\t\t\t first nonzero B-spline, then the same for the\n\t\t\t second nonzero B-spline and so on.              */\n  double *sder=SISL_NULL;  /* Pointer to array used for storage of points, if\n\t\t\t non rational sder points to eder, if rational sder\n\t\t\t has to be allocated to make room for the homogenous\n\t\t\t coordinate */\n\n  /* Copy curve attributes to local parameters.  */\n\n  kn = pc1 -> in;\n  kk = pc1 -> ik;\n  st = pc1 -> et;\n  kdim = pc1 -> idim;\n  kind = pc1 ->ikind;\n\n  if (kind == 2 || kind == 4)\n    {\n      scoef = pc1 -> rcoef;\n      kdim +=1;\n      sder = newarray(kdim*(ider+1),DOUBLE);\n      if (sder==SISL_NULL) goto err101;\n    }\n  else\n    {\n      scoef = pc1 -> ecoef;\n      sder = eder;\n    }\n\n  /* Check the input. */\n\n  if (kdim < 1) goto err102;\n\n  if (kk < 1) goto err110;\n\n  if (kn < kk) goto err111;\n\n  if (st[kk-1] == st[kk] || st[kn-1] == st[kn]) goto err112;\n\n  if (ider < 0) goto err178;\n\n  if (pc1->ikind == 1 || pc1->ikind == 3)\n    kder = min(kk-1,ider);\n  else\n    kder = ider;\n\n  /* Allocate space for B-spline values and derivatives. */\n\n  ebder = newarray(kk*(kder+1),double);\n  if (ebder == SISL_NULL) goto err101;\n\n  /* Set all the elements of sder to 0. */\n\n  for (ki=0; ki<(ider+1)*kdim; ki++) sder[ki] = DZERO;\n\n  /* Compute the values and derivatives of the nonzero B-splines and\n     update ileft if necessary.                                      */\n\n  s1220(st,kk,kn,ileft,ax,kder,ebder,&kstat);\n\n  if (kstat < 0) goto error;\n\n  kleft = *ileft;\n\n  /* Multiply together as indicated above. */\n\n  /* ki steps through the appropriate kk B-spline coefficients while kih steps\n     through the B-spline value and derivatives for the B-spline given by ki.*/\n\n  kih = 0;\n  for (ki=kleft-kk+1; ki<=kleft; ki++)\n    {\n\n      /* kj counts through the kder+1 derivatives to be computed.\n\t kjh steps through sder once for each ki to accumulate the contribution\n\t from the different B-splines.\n\t kl1 points to the first component of B-spline coefficient no. ki. */\n\n      kjh = 0; kl1 = kdim*ki;\n      for (kj=0; kj<=kder; kj++)\n\t{\n\n\t  /* The value of the B-spline derivative is stored in tt while\n\t     kl2 steps through the idim components of this B-spline\n\t     coefficient. */\n\n\t  tt = ebder[kih++]; kl2 = kl1;\n\t  for (kl=0; kl<kdim; kl++,kjh++,kl2++)\n\t    {\n\t      sder[kjh] += scoef[kl2]*tt;\n\t    }\n\t}\n    }\n\n  /* Free memory. */\n\n  /* If rational curve calculate the derivatives based on derivatives in\n     homogenous coordinates */\n\n  if (kind == 2 || kind == 4)\n    {\n      s6ratder(sder,pc1->idim,ider,eder,&kstat);\n      if (kstat<0) goto error;\n      freearray(sder);\n    }\n\n  freearray(ebder);\n\n  /* Successful computations.  */\n\n  *jstat = 0;\n  goto out;\n\n/* Not enough memory. */\n err101: *jstat = -101;\n         s6err(\"s1221\",*jstat,kpos);\n         goto out;\n\n/* kdim less than 1. */\n err102: *jstat = -102;\n         s6err(\"s1221\",*jstat,kpos);\n         goto out;\n\n/* Polynomial order less than 1. */\n err110: *jstat = -110;\n         s6err(\"s1221\",*jstat,kpos);\n         goto out;\n\n/* Fewer B-splines than the order. */\n err111: *jstat = -111;\n         s6err(\"s1221\",*jstat,kpos);\n         goto out;\n\n/* Error in knot vector.\n   (The first or last interval of the knot vector is empty.) */\n err112: *jstat = -112;\n         s6err(\"s1221\",*jstat,kpos);\n         goto out;\n\n/* Illegal derivative requested. */\n err178: *jstat = -178;\n         s6err(\"s1221\",*jstat,kpos);\n         goto out;\n\n/* Error in lower level routine.  */\n\n error:  *jstat = kstat;\n         s6err(\"s1221\",*jstat,kpos);\n         goto out;\n\nout: return;\n}\n"
  },
  {
    "path": "src/s1222.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1222.c,v 1.5 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1222\n\n#include \"sislP.h\"\n \n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   s1222(double et[], int ik, int in, int ibase, \n\t   double ax, int ider, double ebder[], int *jstat)\n#else\nvoid s1222(et, ik, in, ibase, ax, ider, ebder, jstat)\n     double et[];\n     int    ik;\n     int    in;\n     int    ibase;\n     double ax;\n     int    ider;\n     double ebder[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the value and ider first derivatives of the\n*              B-spline base function starting at et[ibase], associated\n*              with the knot vector et at the point ax.\n*              REMARK: THE OUTPUT ARRAY MUST HAVE DIMENSION IK*(IDER + 1),\n*                      BECAUSE OF INTERNAL USE !!!!!!!!!!!!!!!!!!!!!!\n*\n*\n*\n* INPUT      : et     - Double array of dimension [in+ik] containing\n*                       the knot vector.\n*              ik     - The polynomial order of the B-splines associated\n*                       with et.\n*              in     - The dimension of the spline space associated with\n*                       the knot vector et.\n*              ibase  - The B-spline base function to evaluate (starting at\n*                       et[ibase]).\n*              ax     - The point at which the B-spline value and derivatives\n*                       are to be computed.\n*              ider   - The number of derivatives to be computed.\n*                       < 0 : Error.\n*                       = 0 : Compute position.\n*                       = 1 : Compute position and first derivative.\n*                       etc.\n*\n*                \n*\n* OUTPUT     : ebder  - Double array of containing value of the B-splines and \n*                       its derivatives at the point ax. These numbers are \n*                       stored in the following order:\n*                       Position, 1. derivative, ... .\n*                       REMARK: THIS ARRAY MUST HAVE DIMENSION IK*(IDER + 1),\n*                               BECAUSE OF INTERNAL USE !!!!!!!!!!!!!!!!!!!!!!\n*              jstat  - Status messages  \n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : This is based on s1220, bit with all unneccessary calculations\n*              removed (we calculate only a band of the recursion triangle).\n*\n* CALLS      : \n*\n* WRITTEN BY : Johannes Kaasa, SINTEF, October 1995.\n*\n*********************************************************************\n*/                                     \n{\n   int kpos=0;          /* The position of the error.                      */\n   int ki, kj, kl;      /* Index in for loop.                              */\n   int degree;          /* Degree of the basis function, ik - 1.           */\n   int numb_places;     /* Number of places, position and derivatives.     */\n   int offset;          /* Basis function offset, kleft - ibase.           */\n   int pre_deriv;       /* Columns before derivatives are calculated.      */\n   int startA;          /* Start value in for loops.                       */\n   int stopA;           /* End value in for loops.                         */\n   int indexA;          /* Array index.                                    */\n   int indexB;          /* Array index.                                    */\n   int kder;            /* Local version of ider. All derivatives of order\n\t\t\t   higher than ik-1 are zero so\n\t\t\t   kder = min(ik-1,ider).                          */\n   int kleft;           /* Pointer to the interval in the knot vector\n                           where ax is located.                            */\n   int idx1;            /* Array index.                                    */\n   int lknot, rknot;    /* Support limits in the knot array.               */\n   double width;        /* Width of knot support.                          */ \n   double td1, td2;     /* Denominators in the weight ratios.              */\n   double tw1, tw2;     /* The weight ratios.                              */\n   double ts1, ts2;     /* Variants of td1 and td2 for derivatives.        */\n\n   *jstat = 0;\n  \n   /* Initiation. */\n  \n   degree = ik - 1;\n  \n   /* Check the knot vector. */\n  \n   if (in < ik || ik < 1 || ibase < 0 || ibase > (in - 1))\n      goto err112;\n   \n   /* Check number of derivatives. */\n   \n   if (ider < 0)\n      goto err178;\n  \n   /* Find the position of the evaluation point. */\n   \n   if ((ax < et[ibase] && et[ibase] > et[ik - 1])\n       || (ax > et[ibase + ik] && et[ibase + ik] < et[in]))\n   {\n      stopA = ik*(ider + 1);\n      for (ki = 0; ki < stopA; ki++)\n\t ebder[ki] = 0.;\n      goto out;\n   }\n   else\n   {\n      for (kleft = max(ibase, ik - 1); kleft < (ibase + ik); kleft++)\n      {\n\t if (ax < et[kleft + 1] || kleft == (in - 1))\n\t    break;\n      }\n   }\n   offset = kleft - ibase;\n   \n   kder = min(degree, ider);\n   numb_places = kder + 1;\n   pre_deriv = degree - kder;\n   \n   /* Start the order iteration for initial positions. */\n   \n   ebder[0] = 1.;\n   \n   for (ki = 1; ki < ik; ki++)\n   {\n      \n      startA = min(offset + 1, ki);\n      stopA  = max(0, (offset - ik + ki));\n      \n      /* Compute the first basis function. */\n      \n      lknot = kleft - startA + 1;\n      rknot = lknot + ki;\n      width = et[rknot] - et[lknot];\n      if (width < REL_PAR_RES)\n\t goto err112;\n      td2 = (double)1./width;\n      tw2 = (et[rknot] - ax)*td2;\n      ts2 = ki*td2;\n      \n      indexB = numb_places*startA;\n      indexA = indexB - numb_places;\n      \n      if (ki < (offset + 1))\n      {\n\t \n\t /* Inside area of calculation. */\n\t \n\t ebder[indexB] = tw2*ebder[indexA];\n\t \n\t /* If necessary calculate derivatives. */\n\t \n\t if (ki > pre_deriv && kder > 0)\n\t {\n\t    for (kl = 1; kl < (ki - pre_deriv + 1); kl++)\n\t       ebder[indexB + kl] = - ts2*ebder[indexA + kl - 1];\n\t    \n\t }\n\t \n      }\n      \n      lknot++;\n      rknot++;\n      indexB = indexA;\n      indexA -= numb_places;\n     \n      /* Go through the interior basis functions. */\n      \n      for (kj = (startA - 1); kj > stopA; kj--)\n      {\n\t \n\t width = et[rknot] - et[lknot];\n\t if (width < REL_PAR_RES)\n\t    goto err112;\n\t td1 = td2;\n\t td2 = (double)1./width;\n\t tw1 = (double)1. - tw2;\n\t tw2 = (et[rknot] - ax)*td2;\n\t \n\t /* If necessary calculate derivatives. */\n\t \n\t if (ki > pre_deriv && kder > 0)\n\t {\n\t    ts1 = ts2;\n\t    ts2 = ki*td2;\n\t    for (kl = (ki - pre_deriv); kl > 0; kl--)\n\t       ebder[indexB + kl] = ts1*ebder[indexB + kl - 1] \n\t\t  - ts2*ebder[indexA + kl - 1];\n\t    \n\t }\n\t \n\t /* Position. */\n\t \n\t ebder[indexB] = tw1*ebder[indexB] + tw2*ebder[indexA];\n\t \n\t indexB = indexA;\n\t indexA -= numb_places;\n\t lknot++;\n\t rknot++;\n      }\n      \n      /* Compute the last basis function. */\n      \n      if (ki < (ik - offset))\n      {\n\t \n\t /* Inside area of calculation. */\n\t \n\t tw1 = (double)1. - tw2;\n\t \n\t /* If necessary calculate derivatives. */\n\t \n\t if (ki > pre_deriv && kder > 0)\n\t {\n\t    ts1 = ts2;\n\t    for (kl = (ki - pre_deriv); kl > 0; kl--)\n\t       ebder[indexB + kl] = ts1*ebder[indexB + kl - 1]; \n\t    \n\t }\n\t \n\t /* Position. */\n\t \n\t ebder[indexB] = tw1*ebder[indexB];\n\t \n      }\n      \n   }\n   \n   /* Copy out the result. */\n   \n   idx1 = offset*numb_places;\n   for (ki = 0; ki < numb_places; ki++)\n      ebder[ki] = ebder[idx1 + ki];\n   \n   stopA = ik*(ider + 1);\n   for ( ; ki < stopA; ki++)\n      ebder[ki] = 0.;\n   \n   /* Successful computations.  */\n   \n   goto out;\n   \n   /* Error in knot vector (something wrong in kleft calculation, \n      we must have et[kleft] < et[kleft + 1]). */\n   \n   err112: \n      *jstat = -112;\n   s6err(\"s1222\",*jstat,kpos);\n   goto out;\n   \n   /* Illegal derivative requested. */\n   \n   err178: \n      *jstat = -178;\n   s6err(\"s1222\",*jstat,kpos);\n   goto out;\n\n\n   out: \n      return;\n}\n"
  },
  {
    "path": "src/s1223.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1223.c,v 1.5 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1223\n\n#include \"sislP.h\"\n \n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   s1223(double et1[], double et2[], int ik1, int ik2, int in1, int in2, \n\t int ibase1, int ibase2, double par[], int ider1, int ider2, \n\t double ebder[], int *jstat)\n#else\nvoid s1223(et1, et2, ik1, ik2, in1, in2, ibase1, ibase2, par, ider1, ider2, \n\t   ebder, jstat)\n     double et1[];\n     double et2[];\n     int    ik1;\n     int    ik2;\n     int    in1;\n     int    in2;\n     int    ibase1;\n     int    ibase2;\n     double par[];\n     int    ider1;\n     int    ider2;\n     double ebder[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the value and derivatives of the tensor product\n*              B-spline base function starting at (et1[ibase1], et2[ibase2]), \n*              associated with the knot vectors et1 and et2, at the point par.\n*\n*\n*\n* INPUT      : et1    - Double array of dimension [in1+ik1] containing\n*                       the knot vector in the first parameter direction.\n*              et2    - Double array of dimension [in2+ik2] containing\n*                       the knot vector in the second parameter direction.\n*              ik1    - The polynomial order of the B-splines associated\n*                       with et1.\n*              ik2    - The polynomial order of the B-splines associated\n*                       with et2.\n*              in1    - The dimension of the spline space associated with\n*                       the knot vector et1.\n*              in2    - The dimension of the spline space associated with\n*                       the knot vector et2.\n*              ibase1 - The B-spline base function to evaluate (starting at\n*                       et1[ibase1]), in the first parameter direction.\n*              ibase2 - The B-spline base function to evaluate (starting at\n*                       et2[ibase2]), in the second parameter direction.\n*              par    - The point at which the tensor product B-spline value \n*                       and derivatives are to be computed.\n*              ider1  - The number of derivatives to be computed in the first \n*                       parameter direction.\n*                       < 0 : Error.\n*                       = 0 : Compute position.\n*                       = 1 : Compute position and first derivative.\n*                       etc.\n*              ider2  - The number of derivatives to be computed in the second \n*                       parameter direction.\n*                       < 0 : Error.\n*                       = 0 : Compute position.\n*                       = 1 : Compute position and first derivative.\n*                       etc.\n*\n*                \n*\n* OUTPUT     : ebder  - Double array containing value of the tensor product\n*                       B-spline and its derivatives at the point par. \n*                       These numbers are stored as rows from the following\n*                       matrix:\n*                       /                                                 \\\n*                       | B1(u)B2(v)  DB1(u)B2(v)  ... D(ider1)B1(u)B2(v) |\n*                       | B1(u)DB2(v) DB1(u)DB2(v) ...                    |\n*                                                 .\n*                                                 .\n*                       | B1(u)D(ider2)B2(v) ...                          |\n*                       \\                                                 /\n*                       The array has dimension (ider1 + 1)*(ider2 + 1).\n*              jstat  - Status messages  \n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : \n*\n* CALLS      : \n*\n* WRITTEN BY : Johannes Kaasa, SINTEF, October 1995.\n*\n*********************************************************************\n*/                                     \n{\n   int kstat=0;          /* Local status variable.                        */\n   int kpos=0;           /* The position of the error.                    */\n   int ki, kj, kl;       /* Index in for loop.                            */\n   int kder1, kder2;     /* Number of derivatives.                        */\n   int knumb1;           /* Necessary size of sder1.                      */\n   int knumb2;           /* Necessary size of sder2.                      */\n   double sdum1[100];    /* Fixed utility array.                          */\n   double sdum2[100];    /* Fixed utility array.                          */\n   double *sder1 = SISL_NULL; /* Evaluation in the first parameter direction.  */\n   double *sder2 = SISL_NULL; /* Evaluation in the second parameter direction. */\n   \n\n   /* Establish the number of derivatives. */\n   \n   kder1 = min(ik1 - 1, ider1);\n   kder2 = min(ik2 - 1, ider2);\n   \n   /* If necessary allocate space for the evaluation in each \n      parameter direction.                                   */\n   \n   knumb1 = ik1*(kder1 + 1);\n   knumb2 = ik2*(kder2 + 1);\n   \n   if (knumb1 > 100)\n   {\n      if ((sder1 = newarray(knumb1, double)) == SISL_NULL)\n\t goto err101;\n   }\n   else\n      sder1 = &sdum1[0];\n   \n   if (knumb2 > 100)\n   {\n      if ((sder2 = newarray(knumb2, double)) == SISL_NULL)\n\t goto err101;\n   }\n   else\n      sder2 = &sdum2[0];\n   \n   /* Compute the value and derivatives in the first parameter direction. */\n   \n   s1222(et1, ik1, in1, ibase1, par[0], kder1, sder1, &kstat);\n   if (kstat < 0) goto error;\n\n   /* Compute the value and derivatives in the second parameter direction. */\n   \n   s1222(et2, ik2, in2, ibase2, par[1], kder2, sder2, &kstat);\n   if (kstat < 0) goto error;\n   \n   /* Multiply together. */\n   \n   for (ki = 0, kl = 0; ki < (kder2 + 1); ki++)\n   {\n      for (kj = 0; kj < (kder1 + 1); kj++, kl++)\n      {\n\t ebder[kl] = sder1[kj]*sder2[ki];\n      }\n      for ( ; kj < (ider1 + 1); kj++, kl++)\n      {\n\t ebder[kl] = 0.;\n      }\n   }\n      \n   for ( ; ki < (ider2 + 1); ki++)\n   {\n      for (kj = 0; kj < (ider1 + 1); kj++, kl++)\n      {\n\t ebder[kl] = 0.;\n      }\n   }\n   \n   /* Successful computations.  */\n   \n   goto out;\n   \n   /* Not enough memory. */\n   \n   err101: \n      *jstat = -101;\n   s6err(\"s1223\",*jstat,kpos);\n   goto out;\n   \n   /* Error in lower level routine.  */\n   \n   error:  \n      *jstat = kstat;\n   s6err(\"s1223\",*jstat,kpos);\n   goto out;\n   \n   out: \n      if (knumb1 > 100 && sder1 != SISL_NULL) freearray(sder1);\n      if (knumb2 > 100 && sder2 != SISL_NULL) freearray(sder2);\n      \n      return;\n}\n"
  },
  {
    "path": "src/s1224.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1224.c,v 1.3 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1224\n\n#include \"sislP.h\"\n \n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   s1224(double et1[], double et2[], int ik1, int ik2, int in1, int in2, \n\t int ibase1, int ibase2, double par[], int ider, \n\t double ebder[], int *jstat)\n#else\nvoid s1224(et1, et2, ik1, ik2, in1, in2, ibase1, ibase2, par, ider, \n\t   ebder, jstat)\n     double et1[];\n     double et2[];\n     int    ik1;\n     int    ik2;\n     int    in1;\n     int    in2;\n     int    ibase1;\n     int    ibase2;\n     double par[];\n     int    ider;\n     double ebder[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the value and derivatives of the tensor product\n*              B-spline base function starting at (et1[ibase1], et2[ibase2]), \n*              associated with the knot vectors et1 and et2, at the point par.\n*\n*\n*\n* INPUT      : et1    - Double array of dimension [in1+ik1] containing\n*                       the knot vector in the first parameter direction.\n*              et2    - Double array of dimension [in2+ik2] containing\n*                       the knot vector in the second parameter direction.\n*              ik1    - The polynomial order of the B-splines associated\n*                       with et1.\n*              ik2    - The polynomial order of the B-splines associated\n*                       with et2.\n*              in1    - The dimension of the spline space associated with\n*                       the knot vector et1.\n*              in2    - The dimension of the spline space associated with\n*                       the knot vector et2.\n*              ibase1 - The B-spline base function to evaluate (starting at\n*                       et1[ibase1]), in the first parameter direction.\n*              ibase2 - The B-spline base function to evaluate (starting at\n*                       et2[ibase2]), in the second parameter direction.\n*              par    - The point at which the tensor product B-spline value \n*                       and derivatives are to be computed.\n*              ider  - The number of derivatives to be computed.\n*                       < 0 : Error.\n*                       = 0 : Compute position.\n*                       = 1 : Compute position and first derivative.\n*                       etc.\n*                \n*\n* OUTPUT     : ebder  - Double array containing value of the tensor product\n*                       B-spline and its derivatives at the point par. \n*                       The sequence is position, first derivative in first\n*                       parameter direction, first derivative in second\n*                       parameter direction, (2,0) derivative, (1,1) derivative,\n*                       (0,2) derivative etc.\n*                       The array has dimension (ider + 1)*(ider + 2)/2.\n*              jstat  - Status messages  \n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : \n*\n* CALLS      : \n*\n* WRITTEN BY : Johannes Kaasa, SINTEF, November 1995.\n*\n*********************************************************************\n*/                                     \n{\n   int kstat=0;          /* Local status variable.                        */\n   int kpos=0;           /* The position of the error.                    */\n   int ki, kj, kl, kn;   /* Index in for loop.                            */\n   int knumb1;           /* Necessary size of sder1.                      */\n   int knumb2;           /* Necessary size of sder2.                      */\n   double sdum1[100];    /* Fixed utility array.                          */\n   double sdum2[100];    /* Fixed utility array.                          */\n   double *sder1 = SISL_NULL; /* Evaluation in the first parameter direction.  */\n   double *sder2 = SISL_NULL; /* Evaluation in the second parameter direction. */\n   \n\n   /* If necessary allocate space for the evaluation in each \n      parameter direction.                                   */\n   \n   knumb1 = ik1*(ider + 1);\n   knumb2 = ik2*(ider + 1);\n   \n   if (knumb1 > 100)\n   {\n      if ((sder1 = newarray(knumb1, double)) == SISL_NULL)\n\t goto err101;\n   }\n   else\n      sder1 = &sdum1[0];\n   \n   if (knumb2 > 100)\n   {\n      if ((sder2 = newarray(knumb2, double)) == SISL_NULL)\n\t goto err101;\n   }\n   else\n      sder2 = &sdum2[0];\n   \n   /* Compute the value and derivatives in the first parameter direction. */\n   \n   s1222(et1, ik1, in1, ibase1, par[0], ider, sder1, &kstat);\n   if (kstat < 0) goto error;\n\n   /* Compute the value and derivatives in the second parameter direction. */\n   \n   s1222(et2, ik2, in2, ibase2, par[1], ider, sder2, &kstat);\n   if (kstat < 0) goto error;\n   \n   /* Multiply together. */\n   \n   for (ki = 0, kl = 0; ki < (ider + 1); ki++)\n   {\n      for (kj = ki, kn = 0; kj > -1; kj--, kn++, kl++)\n\t ebder[kl] = sder1[kj]*sder2[kn];\n   }\n   \n   /* Successful computations.  */\n   \n   goto out;\n   \n   /* Not enough memory. */\n   \n   err101: \n      *jstat = -101;\n   s6err(\"s1224\",*jstat,kpos);\n   goto out;\n   \n   /* Error in lower level routine.  */\n   \n   error:  \n      *jstat = kstat;\n   s6err(\"s1224\",*jstat,kpos);\n   goto out;\n   \n   out: \n      if (knumb1 > 100 && sder1 != SISL_NULL) freearray(sder1);\n      if (knumb2 > 100 && sder2 != SISL_NULL) freearray(sder2);\n      \n      return;\n}\n"
  },
  {
    "path": "src/s1225.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1225.c,v 1.3 2001-03-19 15:58:42 afr Exp $\n *\n */\n\n\n#define S1225\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1225(SISLCurve *curve,int der,double parvalue,int *leftknot,\n      double derive[],double curvature[], double *radius_of_curvature,\n      int *jstat)\n#else\nvoid s1225(curve,der,parvalue,leftknot,derive,curvature,\n\t   radius_of_curvature,jstat)\n     SISLCurve  *curve;\n     int    der;\n     double parvalue;\n     int    *leftknot;\n     double derive[];\n     double curvature[];\n     double *radius_of_curvature;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate position, first derivative, curvature and radius of\n*              curvature of a curve at a given parameter value, from the\n*              left hand side.\n*\n*\n*\n* INPUT      : curve    - Pointer to the curve for which position\n*                       and derivatives are to be computed.\n*              der      - The number of derivatives to compute.\n*                       < 0 : Error.\n*                       = 0 : Compute position.\n*                       = 1 : Compute position and first derivative.\n*                       etc.\n*              parvalue - The parameter value at which to compute\n*                       position and derivatives.\n*\n*\n*\n* INPUT/OUTPUT : leftknot - Pointer to the interval in the knot vector\n*                        where ax is located. If et is the knot vector,\n*                        the relation\n*\n*                          et[ileft] < parvalue <= et[ileft+1]\n*\n*                        should hold. (If parvalue == et[ik-1] then ileft\n*                        should be ik-1. Here in is the number of B-spline\n*                        coefficients.)\n*                        If ileft does not have the right value upon\n*                        entry to the routine, its value will be changed\n*                        to the value satisfying the above condition.\n*\n*\n*\n* OUTPUT     : derive   - Double array of dimension [(ider+1)*idim]\n*                       containing the position and derivative vectors.\n*                       (idim is the number of components of each B-spline\n*                       coefficient, i.e. the dimension of the Euclidean\n*                       space in which the curve lies.)\n*                       These vectors are stored in the following order:\n*                       First the idim components of the position vector,\n*                       then the idim components of the tangent vector,\n*                       then the idim components of the second derivative\n*                       vector, and so on.\n*                       (The C declaration of eder as a two dimensional array\n*                       would therefore be eder[ider+1,idim].)\n*              curvature - Array of dimension idim\n*              radius_of_curvature -  A radius of curvature =-1, indicates\n*                       that the radius of curvature is infinit.\n*              jstat  - Status messages\n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : The derivatives are evaluated from the left hand\n*              side by  s1227\n*              The curvature and the radius of curvature are evaluated\n*              by s1307\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1227, s1307\n*\n* WRITTEN BY : Cathrine Tegnander\n* MODIFIED BY :\n* REVISED BY :\n*\n*********************************************************************\n*/\n{\n  int ider=2;                 /* minimum number of derivatives needed to\n                                 calculated the curvature */\n  int kdim = curve -> idim;   /* copy curve attribute to local parameter */\n  int kstat=0;                /* local status variable */\n  int kpos = 0;               /* local error position  */\n  int iknot = 0;              /* local version of leftknot */\n  double *iderive = SISL_NULL;     /* pointer to array used to store the position\n                                 and the first and second derivatives  */\n  double *egeo = SISL_NULL;        /* pointer to store curvature and radius of\n                                 curvature */\n\n  iderive= newarray(3*kdim,DOUBLE);\n  if (iderive == SISL_NULL)\n    goto err101;\n  egeo= newarray(3*kdim+1,DOUBLE);\n  if (egeo == SISL_NULL)\n    goto err101;\n\n\n\n  /* Evaluate the derivatives */\n    if (der<2)\n      {\n\ts1227(curve,ider,parvalue,&iknot,iderive,&kstat);\n\tif (kstat<0) goto error;\n\n\t/* Copy position */\n\tmemcopy(derive,iderive,(der+1)*kdim,DOUBLE);\n      }\n  else\n    {\n      s1227(curve,der,parvalue,&iknot,derive,&kstat);\n      if (kstat<0) goto error;\n\n      \t/* Copy position */\n\tmemcopy(iderive,derive,3*kdim,DOUBLE);\n    }\n    *leftknot = iknot;\n\n  /* Evaluate the curvature and the radius_of_curvature */\n  s1307(iderive,kdim,egeo,&kstat);\n  if (kstat<0) goto error;\n\n  /* Copy position */\n  memcopy(curvature,egeo+kdim*2,kdim,DOUBLE);\n\n  *radius_of_curvature = egeo[kdim*3];\n\n  /* Free memory */\n freearray(iderive);\n freearray(egeo);\n\n /* Successful computations.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation */\n err101:\n  *jstat = -101;\n  s6err(\"s1226\",*jstat,kpos);\n\n\n  /* Error in lower level routine.  */\n\n error:  *jstat = kstat;\n  s6err(\"S1227\",*jstat,kpos);\n  goto out;\n\n out: return;\n\n}\n"
  },
  {
    "path": "src/s1226.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1226.c,v 1.4 2001-03-19 15:58:42 afr Exp $\n *\n */\n\n\n#define S1226\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1226(SISLCurve *curve,int der,double parvalue,int *leftknot,\n      double derive[],double curvature[], double *radius_of_curvature,\n      int *jstat)\n#else\nvoid s1226(curve,der,parvalue,leftknot,derive,curvature,\n\t   radius_of_curvature,jstat)\n     SISLCurve  *curve;\n     int    der;\n     double parvalue;\n     int    *leftknot;\n     double derive[];\n     double curvature[];\n     double *radius_of_curvature;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate position, first derivative, curvature and radius of\n*              curvature of a curve at a given parameter value, from the\n*              right hand side.\n*\n*\n*\n* INPUT      : curve    - Pointer to the curve for which position\n*                       and derivatives are to be computed.\n*              der      - The number of derivatives to compute.\n*                       < 0 : Error.\n*                       = 0 : Compute position.\n*                       = 1 : Compute position and first derivative.\n*                       etc.\n*              parvalue - The parameter value at which to compute\n*                       position and derivatives.\n*\n*\n*\n* INPUT/OUTPUT : leftknot - Pointer to the interval in the knot vector\n*                        where ax is located. If et is the knot vector,\n*                        the relation\n*\n*                          et[ileft] < parvalue <= et[ileft+1]\n*\n*                        should hold. (If parvalue == et[ik-1] then ileft\n*                        should be ik-1. Here in is the number of B-spline\n*                        coefficients.)\n*                        If ileft does not have the right value upon\n*                        entry to the routine, its value will be changed\n*                        to the value satisfying the above condition.\n*\n*\n*\n* OUTPUT     : derive   - Double array of dimension [(ider+1)*idim]\n*                       containing the position and derivative vectors.\n*                       (idim is the number of components of each B-spline\n*                       coefficient, i.e. the dimension of the Euclidean\n*                       space in which the curve lies.)\n*                       These vectors are stored in the following order:\n*                       First the idim components of the position vector,\n*                       then the idim components of the tangent vector,\n*                       then the idim components of the second derivative\n*                       vector, and so on.\n*                       (The C declaration of eder as a two dimensional array\n*                       would therefore be eder[ider+1,idim].)\n*              curvature - Array of dimension idim\n*              radius_of_curvature -  A radius of curvature =-1, indicates\n*                       that the radius of curvature is infinit.\n*              jstat  - Status messages\n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : The derivatives are evaluated from the right hand\n*              side by  s1221\n*              The curvature and the radius of curvature are evaluated\n*              by s1307\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1221, s1307\n*\n* WRITTEN BY : Cathrine Tegnander\n* MODIFIED BY :\n* REVISED BY :\n*\n*********************************************************************\n*/\n{\n  int ider=2;                 /* minimum number of derivatives needed to\n                                 calculated the curvature */\n  int kdim = curve -> idim;   /* copy curve attribute to local parameter */\n  int kstat=0;                /* local status variable */\n  int kpos = 0;               /* local error position  */\n  int iknot = 0;              /* local version of leftknot */\n  double *iderive = SISL_NULL;     /* pointer to array used to store the position\n                                 and the first and second derivatives  */\n  double *egeo = SISL_NULL;        /* pointer to store curvature and radius of\n                                 curvature */\n\n  iderive= newarray(3*kdim,DOUBLE);\n  if (iderive == SISL_NULL)\n    goto err101;\n  egeo= newarray(3*kdim+1,DOUBLE);\n  if (egeo == SISL_NULL)\n    goto err101;\n\n\n  /* Evaluate the derivatives */\n    if (der<2)\n      {\n\ts1221(curve,ider,parvalue,&iknot,iderive,&kstat);\n\tif (kstat<0) goto error;\n\n\t/* Copy position */\n\tmemcopy(derive,iderive,(der+1)*kdim,DOUBLE);\n      }\n  else\n    {\n      s1221(curve,der,parvalue,&iknot,derive,&kstat);\n      if (kstat<0) goto error;\n\n      \t/* Copy position */\n\tmemcopy(iderive,derive,3*kdim,DOUBLE);\n    }\n    *leftknot = iknot;\n\n  /* Evaluate the curvature and the radius_of_curvature */\n  s1307(iderive,kdim,egeo,&kstat);\n  if (kstat<0) goto error;\n\n  /* Copy position */\n  memcopy(curvature,egeo+kdim*2,kdim,DOUBLE);\n\n  *radius_of_curvature = egeo[kdim*3];\n\n  /* Free memory */\n freearray(iderive);\n freearray(egeo);\n\n /* Successful computations.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation */\n err101:\n  *jstat = -101;\n  s6err(\"s1226\",*jstat,kpos);\n\n  /* Error in lower level routine.  */\n\n error:  *jstat = kstat;\n  s6err(\"S1226\",*jstat,kpos);\n  goto out;\n\n out: return;\n\n}\n"
  },
  {
    "path": "src/s1227.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1227.c,v 1.2 2001-03-19 15:58:42 afr Exp $\n *\n */\n\n\n#define S1227\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1227(SISLCurve *pc1,int ider,double ax,int *ileft,double eder[],int *jstat)\n#else\nvoid s1227(pc1,ider,ax,ileft,eder,jstat)\n     SISLCurve  *pc1;\n     int    ider;\n     double ax;\n     int    *ileft;\n     double eder[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the value and ider first derivatives of the\n*              B-spline curve pointed to by pc1, at the point with\n*              parameter value ax from the left hand side.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve for which position\n*                       and derivatives are to be computed.\n*              ider   - The number of derivatives to compute.\n*                       < 0 : Error.\n*                       = 0 : Compute position.\n*                       = 1 : Compute position and first derivative.\n*                       etc.\n*              ax     - The parameter value at which to compute\n*                       position and derivatives.\n*\n*                \n*\n* INPUT/OUTPUT : ileft - Pointer to the interval in the knot vector\n*                        where ax is located. If et is the knot vector,\n*                        the relation\n*                          \n*                          et[ileft] < ax <= et[ileft+1]\n* \n*                        should hold. (If ax == et[ik-1] then ileft should\n*                        be ik-1. Here in is the number of B-spline\n*                        coefficients.)\n*                        If ileft does not have the right value upon\n*                        entry to the routine, its value will be changed\n*                        to the value satisfying the above condition.\n*\n*\n*\n* OUTPUT     : eder   - Double array of dimension [(ider+1)*idim]\n*                       containing the position and derivative vectors.\n*                       (idim is the number of components of each B-spline\n*                       coefficient, i.e. the dimension of the Euclidean\n*                       space in which the curve lies.)\n*                       These vectors are stored in the following order:\n*                       First the idim components of the position vector,\n*                       then the idim components of the tangent vector,\n*                       then the idim components of the second derivative\n*                       vector, and so on.\n*                       (The C declaration of eder as a two dimensional array\n*                       would therefore be eder[ider+1,idim].)\n*              jstat  - Status messages  \n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : First we find if the parameter ax is at a knot value, if\n*              so we artificially shortens the curve to end at this value.\n*              Then the traditional calculation from the right hand side\n*              can be used.\n*\n*              Suppose that the given curve is of the form\n*\n*                   f(x) = sum(i) c(i) B(i,k)(x)\n*\n*              where c are the B-spline coefficients and B(i,k)(x) the\n*              B-splines accociated with the knot vector et.\n*              (For idim > 1 this is a vector equation with idim\n*              components; however, the B-spline is not a vector.)\n*              It is known that for a given value of x there are at most\n*              k (the order of the splines) nonzero B-splines.\n*              If ileft has the correct value these B-splines will be\n*\n*              B(ileft-k+1,k),B(ileft+k+2,k),...,B(ileft,k).\n*\n*              The position and derivatives are computed by\n*              first computing the values and derivatives of all the\n*              B-splines at x, and then multiplying and summing.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : compbder - Computes B-spline values and derivatives at\n*                         a given point.\n*\n* WRITTEN BY : Knut Moerken, University of Oslo, August 1988.\n* MODIFIED BY : Mike Floater, SI, Oslo, Norway, April 1991 for rational case.\n* REVISED BY : Johannes Kaasa, SI, Aug. 92 (In case of NURBS the maximum\n*              derivative is not set equal order).\n*\n*********************************************************************\n*/                                     \n{\n  int kind;           /* Type of curve                                   */\n  int kstat=0;        /* Local status variable.                          */\n  int kpos=0;         /* The position of the error.                      */\n  int kn;             /* The number of B-splines, i.e., the dimension of\n\t\t\t the spline space associated with the knot\n\t\t\t vector.                                         */\n  int kk;             /* The polynomial order of the curve.              */\n  int kmult;          /* Multiplicity of knot value                      */\n  int kdim;           /* The dimension of the space in which the curve\n\t\t\t lies. Equivalently, the number of components\n\t\t\t of each B-spline coefficient.                   */\n  int kleft=0;        /* Local version of ileft which is used in order to\n\t\t\t avoid the pointer.                              */\n  int kder;           /* Local version of ider. Since derivatives of order\n\t\t\t higher than kk-1 are all zero, we set\n\t\t\t kder = min(kk-1,ider).                          */\n  int ki,kj,kih,kjh;  /* Control variables in for loops and for stepping\n\t\t\t through arrays.                                 */\n  int kl,kl1,kl2;     /* Control variables in for loops and for stepping\n\t\t\t through arrays.                                 */\n  double *st;         /* Pointer to the first element of the knot vector\n\t\t\t of the curve. The knot vector has [kn+kk]\n\t\t\t elements.                                       */\n  double *scoef;      /* Pointer to the first element of the curve's\n\t\t\t B-spline coefficients. This is assumed to be an\n\t\t\t array with [kn*kdim] elements stored in the\n\t\t\t following order:\n\t\t\t First the kdim components of the first B-spline\n\t\t\t coefficient, then the kdim components of the\n\t\t\t second B-spline coefficient and so on.          */\n  double tt;          /* Dummy variable used for holding an array element\n\t\t\t in a for loop.                                  */\n  double *ebder=SISL_NULL; /* Pointer to an array of dimension [kk*(ider+1)]\n\t\t       which will contain the values and ider first derivatives\n\t\t\t of the kk nonzero B-splines at ax.\n\t\t\t These are stored in the following order:\n\t\t\t First the value, 1. derivative etc. of the\n\t\t\t first nonzero B-spline, then the same for the\n\t\t\t second nonzero B-spline and so on.              */\n  double *sder=SISL_NULL;  /* Pointer to array used for storage of points, if\n\t\t\t non rational sder points to eder, if rational sder\n\t\t\t has to be allocated to make room for the homogenous\n\t\t\t coordinate */\n  \n  /* Copy curve attributes to local parameters.  */\n  \n  kn = pc1 -> in;\n  kk = pc1 -> ik;\n  st = pc1 -> et;\n  scoef = pc1 -> ecoef;\n  kdim = pc1 -> idim;\n  kind = pc1 ->ikind;\n  \n  if (kind == 2 || kind == 4)\n    {\n      scoef = pc1 -> rcoef;\n      kdim +=1;\n      sder = newarray(kdim*(ider+1),DOUBLE); \n      if (sder==SISL_NULL) goto err101;\n    }\n  else\n    {\n      scoef = pc1 -> ecoef;\n      sder = eder;  \n    }\n  \n  /* Check the input. */\n  \n  if (kdim < 1) goto err102;\n  \n  if (kk < 1) goto err110;\n  \n  if (kn < kk) goto err111;\n  \n  /* Find in which interval ax lies */\n  \n  s1219(st,kk,kn,&kleft,ax,&kstat);\n  if (kstat<0) goto error;\n  \n  /* To force the derivative to be taken from the left we artificially\n     shorten the curve if ax==st[kleft]  */\n  \n  kmult = s6knotmult(st,kk,kn,&kleft,ax,&kstat);\n  if (kstat < 0) goto error;\n  \n  \n  if (ax == st[kleft] && kleft > kk-1) kn = kleft-kmult+1;\n  if (st[kk-1] == st[kk] || st[kn-1] == st[kn]) goto err112;\n  \n  if (ider < 0) goto err178;\n  \n  if (pc1->ikind == 1 || pc1->ikind == 3)\n    kder = min(kk-1,ider);\n  else\n    kder = ider;\n  \n  /* Allocate space for B-spline values and derivatives. */\n  \n  ebder = newarray(kk*(kder+1),DOUBLE);\n  if (ebder == SISL_NULL) goto err101;\n  \n  /* Set all the elements of sder to 0. */\n  \n  for (ki=0; ki<(ider+1)*kdim; ki++) sder[ki] = (double)0.0;\n  \n  /* Compute the values and derivatives of the nonzero B-splines and\n     update ileft if necessary.                                      */\n  \n  s1220(st,kk,kn,ileft,ax,kder,ebder,&kstat);\n  \n  if (kstat < 0) goto error;\n  \n  kleft = *ileft;\n  \n  /* Multiply together as indicated above. */\n  \n  /* ki steps through the appropriate kk B-spline coefficients while kih steps\n     through the B-spline value and derivatives for the B-spline given by ki.*/\n  \n  kih = 0;\n  for (ki=kleft-kk+1; ki<=kleft; ki++)\n    {\n      \n      /* kj counts through the kder+1 derivatives to be computed.\n\t kjh steps through sder once for each ki to accumulate the contribution\n\t from the different B-splines.\n\t kl1 points to the first component of B-spline coefficient no. ki. */\n      \n      kjh = 0; kl1 = kdim*ki;\n      for (kj=0; kj<=kder; kj++)\n\t{\n\t  \n\t  /* The value of the B-spline derivative is stored in tt while\n\t     kl2 steps through the idim components of this B-spline\n\t     coefficient.                                                */\n\t  \n\t  tt = ebder[kih++]; kl2 = kl1;\n\t  for (kl=0; kl<kdim; kl++,kjh++,kl2++)\n\t    {\n\t      sder[kjh] += scoef[kl2]*tt;\n\t    }\n\t}\n    }\n  \n  /* Free memory. */\n  \n  /* If rational curve calculate the derivatives based on derivatives in\n     homogenous coordinates */\n  \n  if (kind == 2 || kind == 4)\n    {\n      s6ratder(sder,pc1->idim,ider,eder,&kstat);\n      if (kstat<0) goto error;\n      freearray(sder);\n    }\n  \n  freearray(ebder);\n  \n  /* Successful computations.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Not enough memory. */\n err101: *jstat = -101;\n  s6err(\"S1227\",*jstat,kpos);\n  goto out;\n  \n  /* kdim less than 1. */\n err102: *jstat = -102;\n  s6err(\"S1227\",*jstat,kpos);\n  goto out;\n  \n  /* Polynomial order less than 1. */\n err110: *jstat = -110;\n  s6err(\"S1227\",*jstat,kpos);\n  goto out;\n  \n  /* Fewer B-splines than the order. */\n err111: *jstat = -111;\n  s6err(\"S1227\",*jstat,kpos);\n  goto out;\n  \n  /* Error in knot vector.\n     (The first or last interval of the knot vector is empty.) */\n err112: *jstat = -112;\n  s6err(\"S1227\",*jstat,kpos);\n  goto out;\n  \n  /* Illegal derivative requested. */\n err178: *jstat = -178;\n  s6err(\"S1227\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n error:  *jstat = kstat;\n  s6err(\"S1227\",*jstat,kpos);\n  goto out;\n  \n out: return;\n}\n"
  },
  {
    "path": "src/s1231.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1231.c,v 1.2 2001-03-19 15:58:42 afr Exp $\n *\n */\n\n\n#define S1231\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1231(SISLCurve *pc1,double apar,SISLCurve **rcnew1,SISLCurve **rcnew2,int *jstat)\n#else\nvoid s1231(pc1,apar,rcnew1,rcnew2,jstat)\n     SISLCurve  *pc1;\n     double apar;\n     SISLCurve  **rcnew1;\n     SISLCurve  **rcnew2;\n     int    *jstat;\n#endif\n/*\n********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Subdivide a B-spline curve at a given parameter-value.\n*              NOTE: When the curve is periodic (ie. cuopen is\n*                    set to SISL_CRV_PERIODIC and open basis\n*                    with order-mult repeated knots and coeffic.)\n*                    this function will return only ONE curve\n*                    through rcnew1. This curve is the same\n*                    geometric curve as pc1, but is represented on\n*                    a closed basis with start and end at pc(apar).\n*                    Cuopen is set to SISL_CRV_CLOSED.\n*                    jstat equals 2 when this occurs.\n*\n*\n*\n* INPUT      : pc1      - SISLCurve to subdivide.\n*              apar     - Parameter-value at which to subdivide.\n*\n*\n*\n* OUTPUT     : rcnew1    - First part of the subdivided curve.\n*              rcnew2    - Second part of the subdivided curve.\n*                          If the parameter value is at the end of a\n*                          curve SISL_NULL pointers might be returned\n*              jstat     - status messages\n*                                         = 2      : pc1 periodic, rcnew2=SISL_NULL\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Inserting knots at the subdividing-point until\n*              we have a ktuple-knot. Then we may separate the\n*              curve into two parts.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newCurve  - Allocate space for a new curve-object.\n*              freeCurve - Free space occupied by given curve-object.\n*              S1700.C   - Making the knot-inserten-transformation matrix.\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-06.\n* MODIFIED BY : Mike Floater, SI, 90-12. Subdivide rational curves.\n* MODIFIED BY : Ulf J. Krystad, SI, 92-01. Subdivide periodic crvs.\n* MODIFIED BY : Arne Laksaa, SI, 92-09. Move apar to closest knot\n*\t\tif it is close to a knot. Using D(N)EQUAL().\n*\n*\n**********************************************************************/\n{\n  int kstat;              /* Local status variable.                     */\n  int kpos=0;             /* Position of error.                         */\n  int kmy;                /* An index to the knot-vector.               */\n  int kv,kv1;             /* Number of knots we have to insert.         */\n  int kpl,kfi,kla;        /* To posisjon elements in trans.-matrix.     */\n  int kk=pc1->ik;         /* Order of the input curve.                  */\n  int kn=pc1->in;         /* Number of the vertices in input curves.    */\n  int kdim=pc1->idim;     /* Dimensjon of the space in whice curve lies.*/\n  int kind=pc1->ikind;    /* Type of curve pc1 is.                      */\n  int kn1,kn2;            /* Number of vertices in the new curves.      */\n  int knum;               /* Number of knots less and equal than\n\t\t\t     the intersection point.                    */\n  int ki,ki1;             /* Control variable in loop.                  */\n  int kj,kj1,kj2;         /* Control variable in loop.                  */\n  int newkind=1;          /* Type of curve the subcurves are            */\n  double *s1,*s2,*s3,*s4; /* Pointers used in loop.                     */\n  double *st1=SISL_NULL;       /* The first new knot-vector.                 */\n  double *st2=SISL_NULL;       /* The second new knot-vector.                */\n  double *salfa=SISL_NULL;     /* A line of the trans.-matrix.               */\n  double *scoef;          /* Pointer to vertices.                       */\n  double *scoef1=SISL_NULL;    /* The first new vertice.                     */\n  double *scoef2=SISL_NULL;    /* The second new vertice.                    */\n  SISLCurve *q1=SISL_NULL;     /* Pointer to new curve-object.               */\n  SISLCurve *q2=SISL_NULL;     /* Pointer to new curve-object.               */\n  int incr;\t\t  /* No of extra knots copied during periodicity*/\n  int mu;\t\t  /* Multiplisity at the k'th knot              */\n  int kleft = kk-1;\t  /* Knot navigator                             */\n  double delta;           /* Period size in knot array.                 */\n  double salfa_local[5];  /* Local help array.\t\t\t        */\n  \n  *rcnew1 = SISL_NULL;\n  *rcnew2 = SISL_NULL;\n  \n  \n /* if pc1 is rational, do subdivision in homogeneous coordinates */\n /* just need to set up correct dim and kind for the new curves at end of routine */\n  if(kind == 2 || kind == 4)\n  {\n     scoef = pc1->rcoef;\n     kdim++;\n     newkind++;\n  }\n  else\n  {\n     scoef = pc1->ecoef;\n  }\n  \n  /* Check that we have a curve to subdivide. */\n  \n  if (!pc1) goto err150;\n  \n  /* Periodic curve treatment, UJK jan 92--------------------------------- */\n  if (pc1->cuopen == SISL_CRV_PERIODIC)\n  {\n     delta = (pc1->et[kn] - pc1->et[kk - 1]);\n     \n     /* Check that the intersection point is an interior point. */\n     if (apar < *(pc1->et) || apar > *(pc1->et + kn + kk - 1))\n\tgoto err158;\n     \n     /* If inside the knot vector, but outside well define\n\tintervall, we shift the parameter value one period. */\n     if (apar < *(pc1->et + kk - 1))\n\tapar += delta;\n     if (apar > *(pc1->et + kn))\n\tapar -= delta;\n     \n     /* Now we create a new curve that is a copy of pc1,\n\tbut with the period repeated once,\n\tthis allows us to pick a whole period. */\n     \n     /* Get multiplisity at start of full basis interval */\n     mu = s6knotmult(pc1->et, kk, kn, &kleft, pc1->et[kk-1], &kstat);\n     if (kstat < 0) goto err153;\n     if (mu >= kk) goto errinp;\n     \n     /* Copy ----------------------------------- */\n     incr = kn - kk + mu;\n     if ((scoef1 = newarray ((kn + incr) * kdim, double)) == SISL_NULL)\n\tgoto err101;\n     if ((st1 = newarray (kn + kk + incr, double)) == SISL_NULL)\n\tgoto err101;\n     \n     memcopy (scoef1, pc1->ecoef, kn * kdim, double);\n     memcopy (st1, pc1->et, kn + kk, double);\n     memcopy (scoef1 + kn * kdim, pc1->ecoef + (kk - mu) * kdim, \n\t      incr * kdim, double);\n     \n     \n     for (ki = 0; ki < incr; ki++)\n\tst1[kn + kk + ki] = st1[kn + kk + ki - 1] +\n\t   (st1[2*kk - mu + ki] - st1[2*kk - mu + ki - 1]);\n     if ((q1 = newCurve (kn + incr, kk, st1, scoef1,\n\t\t\t newkind, pc1->idim, 2)) == SISL_NULL)\n\tgoto err101;\n     q1->cuopen = SISL_CRV_OPEN;\n     \n     /* Pick part (one period)------------------ */\n     s1712 (q1, apar, apar + delta,\n\t    rcnew1, &kstat);\n     if (kstat < 0)\n\tgoto err153;\n     freeCurve (q1);\n     if (*rcnew1)\n\t(*rcnew1)->cuopen = SISL_CRV_CLOSED;\n     \n     /* Finished, exit */\n     *jstat = 2;\n     goto out;\n     \n  }\n  \n  /* End of periodic curve treatment, UJK jan 92------------- */\n\n\t    \n  /* Check that the intersection point is an interior point. */\n  /* Changed by UJK */\n  /*if (apar <= *(pc1->et) || apar >= *(pc1->et+kn+kk-1)) goto err158; */\n  if ((apar < pc1->et[kk - 1] || DEQUAL(apar, pc1->et[kk - 1]))||\n      (apar > pc1->et[kn] || DEQUAL(apar, pc1->et[kn])))\n    goto err158;\n  \n  \n  /* Allocate space for the kk elements which may not be zero in eache\n     line of the basic transformation matrix.*/\n  \n  if (kk > 5)\n  {\n     if ((salfa = newarray (kk, double)) == SISL_NULL)\tgoto err101;\n  }\n  else salfa = salfa_local;\n  \n  \n  /* Find the number of the knots which is smaller or like\n     the intersection point, and how many knots we have to insert.*/\n  \n  s1 = pc1->et;\n  kv = kk;     /* The maximum number of knots we may have to insert. */\n  \n  /* Using binear search*/\n  kj1=0;\n  kj2=kk+kn-1;\n  knum = (kj1+kj2)/2;\n  while (knum != kj1)\n  {\n     if ((s1[knum] < apar) && DNEQUAL (s1[knum], apar))\n\tkj1=knum; else kj2=knum;\n     knum = (kj1+kj2)/2;\n  }\n  knum++;           /* The smaller knots. */\n  \n  while (DEQUAL (s1[knum], apar))\n     /* The knots thats like the intersection point. */\n  { \n     apar = s1[knum];\n     knum++; \n     kv--;\n  }\n  \n  \n  /* Find the number of vertices in the two new curves. */\n  \n  kn1 = knum + kv - kk;\n  kn2 = kn + kk - knum;\n  \n  \n  \n  /* Allocating the new arrays to the two new curves. */\n  \n  if (kn1>0)\n  {\n     if ((scoef1=newarray(kn1*kdim,double))==SISL_NULL) goto err101;\n     if ((st1=newarray(kn1+kk,double))==SISL_NULL) goto err101;\n  }\n  if (kn2>0)\n  {\n     if ((scoef2=newarray(kn2*kdim,double))==SISL_NULL) goto err101;\n     if ((st2=newarray(kn2+kk,double))==SISL_NULL) goto err101;\n  }\n  \n  \n  /* Copying the knotvectors, all but the intersection point from\n     the old curve to the new curves */\n  \n  memcopy(st1,pc1->et,kn1,double);\n  memcopy(st2+kk,pc1->et+knum,kn2,double);\n  \n  \n  /* Updating the knotvectors by inserting a k-touple knot in\n     the intersection point at each curve.*/\n  \n  for(s2=st1+kn1,s3=st2,s4=s3+kk; s3<s4; s2++,s3++) *s2 = *s3 = apar;\n  \n  \n  /* Copying the coefisientvectors to the new curves.*/\n  \n  memcopy(scoef1,scoef,kdim*kn1,double);\n  memcopy(scoef2,scoef+kdim*(knum-kk),kdim*kn2,double);\n  \n  \n  /* Updating the coefisientvectors to the new curves.*/\n  \n  /* Updating the first curve. */\n  knum -= kk - 1;\n  for (ki=max(0,knum),kv1=max(0,-knum),s1=scoef1+ki*kdim; ki<kn1; ki++)\n  {\n     /* Initialising:\n\tknum = knum-kk+1, Index of the first vertice to change.\n\tki = knum,        Index of the vertices we are going to\n\tchange. Starting with knum, but if\n\tknum is negativ we start at zero.\n\tkv1 = 0,          Number if new knots between index ki\n\tand ki+kk. We are starting one below\n\tbecase we are counting up before using\n\tit. If knum is negativ we are not\n\tstarting at zero but at -knum.\n\ts1=scoef1+ki*kdim,SISLPointer at the first vertice to\n\tchange. */\n     \n     \n     /* Using the Oslo-algorithm to make a transformation-vector\n\tfrom the old vertices to one new vertice. */\n     \n     kmy=ki;\n     s1700(kmy,kk,kn,++kv1,&kpl,&kfi,&kla,pc1->et,apar,salfa,&kstat);\n     if (kstat) goto err153;\n     \n     \n     /* Compute the kdim vertices with the same \"index\". */\n     \n     for (kj=0; kj<kdim; kj++,s1++)\n\tfor (*s1=0,kj1=kfi,kj2=kfi+kpl; kj1<=kla; kj1++,kj2++)\n\t   *s1 += salfa[kj2] * scoef[kj1*kdim+kj];\n  }\n  \n  /* And the second curve. */\n  \n  for (ki1=min(kn1+kv-1,kn+kv),s1=scoef2; ki<ki1; ki++)\n  {\n     /* Initialising:\n\tki1 = kn1+kv-1,   the index of the vertice next to the\n\tlast vertice we have to change.\n\tIf we do not have so many vertices,\n\twe have to use the index next to the\n\tlast vertice we have, kn+kv.\n\ts1=scoef2         Pointer at the first vertice to\n\tchange. */\n     \n     \n     /* Using the Oslo-algorithm to make a transformation-vector\n\tfrom the old vertices to one new vertice. */\n     \n     s1700(kmy,kk,kn,kv1--,&kpl,&kfi,&kla,pc1->et,apar,salfa,&kstat);\n     if (kstat) goto err153;\n     \n     \n     /* Compute the kdim vertices with the same \"index\". */\n     \n     for (kj=0; kj<kdim; kj++,s1++)\n\tfor (*s1=0,kj1=kfi,kj2=kfi+kpl; kj1<=kla; kj1++,kj2++)\n\t   *s1 += salfa[kj2] * scoef[kj1*kdim+kj];\n  }\n  \n  \n  /* Allocating new curve-objects.*/\n  /* use pc1->idim rather than kdim in case pc1 is rational  */\n  \n  if (kn1>0)\n     if ((q1=newCurve(kn1,kk,st1,scoef1,newkind,pc1->idim,2)) == SISL_NULL)\n\t\t\t\t\t\t\t\tgoto err101;\n  if (kn2>0)\n     if ((q2=newCurve(kn2,kk,st2,scoef2,newkind,pc1->idim,2)) == SISL_NULL)\n\t\t\t\t\t\t\t\tgoto err101;\n  \n  \n  /* Updating output. */\n  \n  *rcnew1 = q1;\n  *rcnew2 = q2;\n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error. Error in low level routine. */\n  \nerr153:\n     *jstat = kstat;\n  goto outfree;\n  \n  \n  /* Error. Error in input */\nerrinp:\n     *jstat = -154;\n  goto outfree;\n  \n  /* Error. No curve to subdivide.  */\nerr150:\n     *jstat = -150;\n  s6err(\"s1231\",*jstat,kpos);\n  goto out;\n  \n  \n  /* Error. The parameter value is outside the curve.  */\n  \nerr158:\n     *jstat = -158;\n  s6err(\"s1231\",*jstat,kpos);\n  goto out;\n  \n  \n  /* Error. Allocation error, not enough memory.  */\n  \nerr101:\n     *jstat = -101;\n  s6err(\"s1231\",*jstat,kpos);\n  goto outfree;\n  \n  \noutfree:\n   if(q1) freeCurve(q1);\n   if(q2) freeCurve(q2);   \n   \n   /* Free local used memory. */\n   \nout:\n   if(!q1)\n   {\n      if (st1) freearray(st1);\n      if (scoef1) freearray(scoef1);\n   }\n   \n   if(!q2)\n   {\n      if (st2) freearray(st2);\n      if (scoef2) freearray(scoef2);\n   }\n   \n   if (kk > 5 && salfa)\n      freearray (salfa);\n   return;\n}\n"
  },
  {
    "path": "src/s1232.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1232.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1232\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1232(double et1[],int in,int ik,\n\t   double afak1,double afak2,double et2[],int *jstat)\n#else\nvoid s1232(et1,in,ik,afak1,afak2,et2,jstat)\n     double et1[];\n     int    in;\n     int    ik;\n     double afak1;\n     double afak2;\n     double et2[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Produce a knot vector that is stretched in the start\n*              and/or end compared to an input knot vector.\n*\n*\n*\n* INPUT      : et1    - Original knot vector.\n*              in     - Number of vertices of the curve which the\n*                       knot vector belongs to.\n*              ik     - Order of the curve which the knot vector\n*                       belongs to.\n*              afak1  - How much the new knot vector is to be stretched\n*                       at the start compared with the original one. \n*                       afak1 >= 0. The parameter interval is extended \n*                       afak1 times the length of the parameter interval\n*                       in the start of the interval.\n*              afak2  - How much the new knot vector is to be stretched\n*                       at the end compared with the original one. \n*                       afak2 >= 0.\n*\n*\n*\n* OUTPUT     : et2    - The stretched knot vector.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Replace the ik first and last knots with knots at the\n*              new endpoints of the knot vector. The interior knots are\n*              left unchanged.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n*\n*********************************************************************\n*/                   \n{\n  int kpos = 0;   /* Position of error.                */\n  int ki;         /* Counter.                          */\n  double tleng;   /* Length of parameter interval.     */\n  double tstart;  /* New start value of knot vector.   */\n  double tend;    /* New end value of knot vector.     */\n  \n  /* Test input.  */\n  \n  if (ik < 1) goto err110;\n  if (in < ik) goto err111;\n  \n  /* Test if knot vector degenerated.  */\n  \n  tleng = et1[in] - et1[ik-1];\n  if (tleng <= (double)0.0) goto err112;  \n  \n  /* Copy input knot vector to output knot vector.   */\n  \n  memcopy(et2,et1,in+ik,double);\n  \n  if (afak1 > (double)0.0)\n    {\n      \n      /* Extend basis at start of curve.  */\n      \n      tstart = et1[ik-1] - tleng*afak1;\n      for (ki=0; ki<ik; ki++) et2[ki] = tstart;\n    }\n  \n  if (afak2 > (double)0.0)\n    {\n      \n      /* Extend basis at end of curve.  */\n      \n      tend = et1[in] + tleng*afak2;\n      for (ki=in; ki<in+ik; ki++) et2[ki] = tend;\n    }\n  \n  /* New knot vector produced.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in input. Order less than 1.  */\n  \n err110: *jstat = -110;\n  s6err(\"s1232\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Number of vertices less than order.  */\n  \n err111: *jstat = -111;\n  s6err(\"s1232\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Knot vector degenerated.  */\n  \n err112: *jstat = -112;\n  s6err(\"s1232\",*jstat,kpos);\n  goto out;\n  \n out: return;\n}\n"
  },
  {
    "path": "src/s1233.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1233.c,v 1.4 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1233\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1233(SISLCurve *pc,double afak1,double afak2,SISLCurve **rc,int *jstat)\n#else\nvoid s1233(pc,afak1,afak2,rc,jstat)\n     SISLCurve  *pc;\n     double     afak1;\n     double     afak2;\n     SISLCurve  **rc;\n     int    \t*jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To extend a B-spline curve (i.e. NOT rationals) at the start\n*              and/or the end of the curve by continuing the polynomial\n*              behaviour of the curve.\n*\n* INPUT      : pc     - Pointer to the curve that will be extended.\n*              afak1  - How much the curve is to be stretched at the\n*                       start of the curve. The length of the stretched\n*                       curve will be equal to (1+afak1) times the\n*                       input curve. afak1 >= 0 and will be set to 0 if\n*                       negative.\n*              afak2  - How much the curve is to be stretched at the\n*                       end of the curve. The length of the stretched\n*                       curve will be equal to (1+afak2) times the\n*                       input curve. afak2 >= 0 and will be set to 0 if\n*                       negative.\n*\n* OUTPUT     : rc     - Pointer to the extended curve.\n*              jstat  - status messages\n*                       > 0      : warning\n*                       = 1      : Stretching factors less than 0 - readjusted\n*                                  factor(s) have been used.\n*                       = 0      : ok\n*                       < 0      : error\n*\n* METHOD     : 1. The new knot vector is made\n*              2. The transformation matrix for the ik first vertices between\n*                 the new and the old knot vector is made.\n*              3. The transformation matrix is inverted and used to update the\n*                 ik first vertices.\n*              4. The transformation matrix for the ik last vertices between\n*                 the new and the old knot vector is made.\n*              5. The transformation matrix is inverted and used to update the\n*                 ik last vertices.\n*              6. The knot vector is updated.\n*-\n* CALLS      : make_cv_kreg,s1219,s1701,s6lufacp,s6lusolp,s6err.\n*\n* Written by : Paal Fugelli, SINTEF, Oslo, Norway, Sept-1992. Adapted from\n*              a FORTRAN based s1233() written by Vibeke Skytt and s1333_cyclic()\n*              written by Tor Dokken.\n*\n*********************************************************************\n*/\n{\n  double *ext = SISL_NULL;                     /* Extended version of knot vector */\n  double *smatrix = SISL_NULL;                 /* Matrix converting between basises */\n  double *salloc = SISL_NULL;                  /* Matrix for memory allocation */\n  double *salfa = SISL_NULL;                   /* The values of a discrete B-spline\n                                             calculation */\n  double *spek = SISL_NULL;                    /* Pointer used in traversing arrays */\n  double *sb = SISL_NULL;                      /* Right hand side of equation */\n  double *sfrom, *sto;\n  double *sp;                             /* Help array for s1701 */\n  double *stx = SISL_NULL;                     /* Knot vector after insertion of knots\n                                             at start */\n  int    *mpiv=SISL_NULL;                      /* Pointer to pivotation array */\n  SISLCurve *kreg;                        /* k-regular curve */\n\n  double *st = SISL_NULL;                      /* Internal version of et */\n  double *scoef = SISL_NULL;                   /* Copy of the vertices of the surface */\n  int    kdim = pc->idim;\n  int    kk = pc->ik;\n  int    kn = pc->in;\n\n  double tlen;                            /* Length of curve parameterization */\n  double tstart;                          /* New start knot value */\n  double tend;                            /* New end knot value */\n  int    ki, kj;\n  int    knst;\n  int    knstx;\n  int    kleft = 0;\n  int    kpl, kfi, kla;\n\n  int    kstat;                           /* Error status from lower level */\n  int    kpos = 0;\n\n\n\n  /* Ensure reasonable return value */\n  *rc = SISL_NULL;\n\n\n  /* Test input */\n\n  if ( kk < 1 ) goto err110;\n\n  if ( kn < kk ) goto err111;\n\n  if ( afak1 < DZERO || afak2 < DZERO )\n  {\n    /* Warning - so correct the factor(s) */\n    *jstat = 1;\n\n    if ( afak1 < DZERO ) afak1 = DZERO;\n    if ( afak2 < DZERO ) afak2 = DZERO;\n  }\n\n\n  /* Ensure k-regular curve */\n\n  make_cv_kreg(pc, &kreg, &kstat);\n  if ( kstat < 0 ) goto error;\n\n\n  /* Alloocate array for pivotation vector */\n\n  mpiv = new0array(2*kk, INT);\n  if ( mpiv == SISL_NULL ) goto err101;\n\n  /* Allocate space (en bloc) for the local vectors */\n\n  salloc = new0array(3*kn + 9*kk + 4*kk*kk + kdim*kn, DOUBLE);\n  if ( salloc == SISL_NULL ) goto err101;\n\n  ext = salloc;                    /* Size kn+kk */\n  smatrix = ext + kn + kk;         /* Max size 4*kk*kk */\n  salfa = smatrix + 4*kk*kk;       /* Size kk */\n  scoef = salfa + kk;              /* Size kdim*kn */\n  sb    = scoef + kdim*kn;         /* Size 2*kk */\n  sp    = sb + 2*kk;               /* Size kk */\n  st    = sp + kk;                 /* Size kn + 2*kk */\n  stx   = st + kn + 2*kk;          /* Size kn + kk */\n\n\n\n  /* Copy knots and vertices, to avoid destruction of curve */\n\n  memcopy(ext, kreg->et, kn + kk, DOUBLE);\n  memcopy(scoef, kreg->ecoef, kdim*kn, DOUBLE);\n\n\n  /* Make extended knot vector */\n\n  tlen = ext[kn] - ext[kk-1];\n\n  if ( afak1 > DZERO )\n  {\n    /* Extend the basis at the start of the curve */\n\n    tstart = ext[kk-1] - tlen*afak1;\n    for ( ki = 0; ki < kk; ki++ )  ext[ki] = tstart;\n  }\n\n  if ( afak2 > DZERO )\n  {\n    /* Extend the basis at the end of the curve */\n\n    tend = ext[kn] + tlen*afak2;\n    for ( ki = kn; ki < kn+kk; ki++ )  ext[ki] = tend;\n  }\n\n\n  /* s1701 expects et to be a refinement of ext, thus we have to make a new\n     version of e1 with the extra kk new knots before the start and after the\n     end and one intermediate version with only kk at the start */\n\n  memcopy(st, ext, kk - 1, DOUBLE);\n  memcopy(st + kk - 1, kreg->et, kn + kk, DOUBLE);\n  memcopy(st + 2*kk - 1 + kn, ext + kn + 1, kk - 1, DOUBLE);\n  knst = kn + 2*(kk - 1);\n\n  memcopy(stx, ext ,kn, DOUBLE);\n  memcopy(stx + kn, st + kk - 1 + kn, 2*kk - 1, DOUBLE);\n  knstx = kn + kk - 1;\n\n  /* STEP 2 Make matrix going between bases, only the kk first and last knots\n     are to be changed.  */\n\n\n  /* Now we have two cases. We know that only the kk+1 first and kk+1\n     last vertices are to be changed. However 2*(kk+1) might be equal to kn.\n     Thus we have to change all vertices if kn<=2*(kk+1) */\n\n\n  /* Make two steps one for the start and one for the end of the curve */\n\n\n  /* Make matrix for the kk first vertices */\n\n  for ( ki=kk-1, spek=smatrix; ki < 2*kk-1; ki++, spek+=kk )\n  {\n    /* we use kn instead of knstx since s1219 expects et[in-1] != et[in], we only\n       address vertices at the start so this does not matter */\n\n    s1219(stx, kk, kn, &kleft, st[ki], &kstat);\n    if ( kstat < 0 ) goto error;\n\n    s1701(ki, kleft, kk, knstx, &kpl, &kfi, &kla, st, stx, sp, salfa, &kstat);\n    if( kstat < 0 ) goto error;\n\n    /* Copy the discrete B-splines into the right position */\n\n    memcopy(spek + kfi, salfa + kpl + kfi, kla - kfi + 1, DOUBLE);\n  }\n\n\n\n  /* Do the factorisation of the matrix */\n\n  s6lufacp(smatrix, mpiv, kk, &kstat);\n  if ( kstat < 0 ) goto error;\n\n  /* The vertices in the curve are ordered in the sequence\n     (x1,y1,z1),..,(xi,yi,zi), i=1,..,in.\n     The only vertices affected by this backsubstitution is the kk first.\n     We want to treat the back substitution as idim(=3) backsubstitutions.\n     Thus we have to copy the proper parts of the vertices into a temporary\n     array. Do backsubstitution and copy back into the curve object */\n\n\n  for ( ki=0; ki < kdim; ki++ )\n  {\n    for ( kj=0,sfrom=(kreg->ecoef)+ki,sto=sb; kj < kk; kj++,sfrom+=kdim,sto++ )\n      *sto = *sfrom;\n\n    /* sb now contains the parts of vertices to be backsubsituted */\n\n    s6lusolp(smatrix, sb, mpiv, kk, &kstat);\n    if ( kstat < 0 ) goto error;\n\n    /* Copy the backsubsituted vertices back into scoef */\n\n    for ( kj=0,sto=scoef+ki,sfrom=sb;  kj < kk; kj++,sfrom++,sto+=kdim )\n      *sto = *sfrom;\n  }\n\n\n  /* Make matrix for the kk last vertices */\n\n  for ( ki=0,spek=smatrix; ki < kk*kk; ki++,spek++ ) *spek = DZERO;\n\n\n  for ( ki=kn-kk,spek=smatrix; ki < kn; ki++,spek+=kk )\n  {\n    s1219(ext, kk, kn, &kleft, stx[ki], &kstat);\n    if ( kstat < 0 ) goto error;\n\n    s1701(ki, kleft, kk, kn, &kpl, &kfi, &kla, stx, ext, sp, salfa, &kstat);\n    if ( kstat < 0 ) goto error;\n\n    /* Copy the discrete B-splines into the right position */\n\n    memcopy(spek+kfi-(kn-kk), salfa+kpl+kfi, kla-kfi+1, DOUBLE);\n  }\n\n\n  /* Do the factorisation of the matrix */\n\n  s6lufacp(smatrix, mpiv, kk, &kstat);\n  if ( kstat < 0 ) goto error;\n\n  /* The vertices in the curve are ordered in the sequence\n     (x1,y1,z1),..,(xi,yi,zi), i=1,..,in1. The only vertices\n     affected by this backsubstitution is the kk-1 last rows.\n     We want to treat the back substitution as idim(=3) backsubstitutions.\n     Thus we have to copy the proper parts of the vertices into a temporary\n     array. Do backsubstitution and copy back into the surface object */\n\n  for ( ki=0; ki < kdim; ki++ )\n  {\n    for ( kj=0,sfrom=scoef+kdim*(kn-kk)+ki,sto=sb; kj < kk; kj++,sfrom+=kdim,sto++ )\n      *sto = *sfrom;\n\n    /* sb now contains the vertices to be backsubsituted */\n\n    s6lusolp(smatrix, sb, mpiv, kk, &kstat);\n    if ( kstat < 0 ) goto error;\n\n    /* Copy the backsubsituted vertices back into scoef */\n\n    for ( kj=0,sto=scoef+kdim*(kn-kk)+ki,sfrom=sb; kj < kk; kj++,sto+=kdim,sfrom++ )\n      *sto = *sfrom;\n  }\n\n\n  /* Copy knots and vertices into the surface object */\n\n  memcopy(kreg->ecoef, scoef, kdim*kn, DOUBLE);\n  memcopy(kreg->et, ext, kn+kk, DOUBLE);\n\n  /* Set periodicity flag */\n  kreg->cuopen = SISL_CRV_OPEN;\n\n\n  /* Task done */\n\n  *rc = kreg;\n\n  *jstat = 0;\n  goto out;\n\n\n  /* Error in allocation. */\n\n err101:\n  *jstat = -101;\n  s6err(\"s1233\",*jstat,kpos);\n  goto out;\n\n\n  /* Error in curve description - order less than 1 */\n\n err110:\n  *jstat = -110;\n  s6err(\"s1233\",*jstat,kpos);\n  goto out;\n\n\n  /* Error in curve desctiption - number of vertices is less than the order */\n\n err111:\n  *jstat = -111;\n  s6err(\"s1233\",*jstat,kpos);\n  goto out;\n\n\n  /* Error in lower level routine.  */\n\n error:\n  *jstat = kstat;\n  s6err(\"s1233\",*jstat,kpos);\n  goto out;\n\n\n out:\n\n  /* Free allocated scratch  */\n\n  if (salloc != SISL_NULL) freearray(salloc);\n  if (mpiv != SISL_NULL) freearray(mpiv);\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s1235.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1235.c,v 1.3 2001-03-19 15:58:42 afr Exp $\n *\n */\n\n\n#define S1235\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1235(double et[],int in,int ik,int *jnbreak,double **gbreak,int *jstat)\n#else\nvoid s1235(et,in,ik,jnbreak,gbreak,jstat)\n     double et[];\n     int    in;\n     int    ik;\n     int    *jnbreak;\n     double **gbreak;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find break points in a knot vector. The first and last\n*              parameter values are break values.\n*\n*\n*\n* INPUT      : et     - Knot vector to find break points in.\n*              in     - Number of vertices of the curve corresponding\n*                       to the knot vector.\n*              ik     - Order of the curve corresponding to et.\n*\n*\n*\n* OUTPUT     : jnbreak - Number of break points found.\n*              gbreak  - Array containing parameter values of break points.\n*              jstat   - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The knot vector has a break point at a knot if the \n*              multiplicity of the knot is ik-1.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n* REVISED BY : Vibeke Skytt, SINTEF, 9801. Correction in loop counter\n*                                          for the periodic case.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;   /* Position of error.                    */\n  int kj;         /* Counter.                              */\n  int kbreak;     /* Current number of break points found. */\n  int kmult;      /* Multiplisity of current knot.         */\n  double tprev;   /* Value of previous knot.               */\n  double *sbreak; /* Pointer into break point array.       */\n  double *st;     /* Pointer into knot vector.             */\n  \n  /* Allocate space for an array that is at least as great as the\n     number of break points.                                       */\n  \n  *gbreak = SISL_NULL;\n  if ((*gbreak = newarray(in+2,double)) == SISL_NULL) goto err101;\n  \n  /* Set local pointer to and counter of break points.  */\n  \n  sbreak = *gbreak;\n  kbreak = 0;\n  \n  /* Find break point in start of parameter interval and internal breaks. */\n  \n  tprev = et[ik-1];\n  kmult = ik - 1;\n  for (st=et+ik,kj=ik; kj<in; st++,kj++)\n    {\n      \n      if (*st == tprev) kmult++;\n      else\n\t{\n\t  if (kmult >= ik-1)\n\t    {\n\t      \n\t      /* New break point found.  */\n\t      \n\t      *(sbreak++) = tprev;\n\t      kbreak++;\n\t    }\n\t  tprev = *st;\n\t  kmult = 1;\n\t}\n    }\n  \n  /* Find break point in end of interval.  */\n  \n  if (et[in] != tprev && kmult >= ik-1)\n    {\n      \n      /* Remember last internal break point.  */\n      \n      *(sbreak++) = tprev;\n      kbreak++;\n    }\n  *(sbreak++) = et[in];\n  kbreak++;\n  \n  /* Reduce break point array to correct size.  */\n  \n  if (kbreak < in+2)\n    if ((*gbreak = increasearray(*gbreak,kbreak,double)) == SISL_NULL) goto err101;\n  \n  /* Break points found.  */\n  \n  *jnbreak = kbreak;\n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: \n  *jstat = -101;\n  s6err(\"s1235\",*jstat,kpos);\n  goto out;\n  \n out: \n  return;\n}\n"
  },
  {
    "path": "src/s1236.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1236.c,v 1.2 2001-03-19 15:58:42 afr Exp $\n *\n */\n\n\n#define S1236\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1236(double et[],int in,int ik,int inpar,double epar[],int *jstat)\n#else\nvoid s1236(et,in,ik,inpar,epar,jstat)\n     double et[];\n     int    in;\n     int    ik;\n     int    inpar;\n     double epar[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To find the constant parameter values to be used in\n*              surface/curve drawing.\n*\n*\n*\n* INPUT      : et     - Knot vector.\n*              in     - Number of vertices corresponding to et.\n*              ik     - Order corresponding to et.\n*              inpar  - Number of constant parameter values wanted.\n*\n*\n*\n* OUTPUT     : epar   - Array containing constant parameter values.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1235 - Calculate break points of the knot vector.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;   /* Local status variable.                             */\n  int kpos = 0;    /* Position of error.                                 */\n  int ki,kj;       /* Counters.                                          */\n  int kpar;        /* Remaining number of parameter values to be set\n\t\t      at non-break points.                               */\n  int knumb;       /* Number of parameter values between two break points.*/\n  int knbreak = 0; /* Number of break points.                            */\n  double tend;     /* Value of the end of the parameter interval.        */\n  double tlast;    /* Value of last break point.                         */\n  double tval;     /* Value of current break point.                      */\n  double tdist;    /* Distance between two parameter values.             */\n  double *spar;    /* Pointer used to traverse epar.                     */\n  double *sbreak = SISL_NULL;  /* Array containing break points.              */\n  \n  /* Test input.  */\n  \n  if (ik < 1) goto err110;\n  if (in < ik) goto err111;\n  \n  /* Find break points, including endpoints of the parameter interval. */\n  \n  s1235(et,in,ik,&knbreak,&sbreak,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Find number of constant parameter values not at break points. */\n  \n  kpar = inpar - knbreak;\n  \n  /* Adjust number of constant parameter values if the number of break point\n     is greater than the number of parameter values wanted.  */\n\n  if (kpar < 0)\n    {\n      sbreak[1] = sbreak[knbreak-1];\n      knbreak = 2;\n      kpar = inpar - 2;\n    }\n  \n  /* Set first parameter value and end of parameter interval.  */\n  \n  spar = epar;\n  tlast = *spar = sbreak[0];\n  tend = sbreak[knbreak-1];\n  \n  for (spar++,ki=1; ki<knbreak; ki++)\n    {\n      \n      /* Set constant parameter values between two break points.  */\n      \n      tval = sbreak[ki];\n      tdist = tval - tlast;\n      knumb = (int)(kpar*tdist/(tend-tlast));\n      \n      /* Remaining non-break point parameter values to be set.  */\n      \n      kpar -= knumb;\n      \n      /* Distance between parameter values. */\n      \n      tdist /= (knumb + 1);\n      \n      /* Set parameter values.  */\n      \n      for (kj=0; kj<knumb; kj++) *(spar++) = tlast + (kj+1)*tdist;\n      \n      /* Set parameter value at break point. */\n      \n      *(spar++) = tval;\n      tlast = tval;\n    }\n  \n  /* Parameter values found. */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in input. Order less than one.  */\n  \n err110: *jstat = -110;\n  s6err(\"s1236\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Number of vertices less than order.  */\n  \n err111: *jstat = -111;\n  s6err(\"s1236\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"s1236\",*jstat,kpos);\n  goto out;\n  \n out:\n  \n  /* Free space occupied by local array.  */\n  \n  if (sbreak != SISL_NULL) freearray(sbreak);\n  \n  return;\n}\n"
  },
  {
    "path": "src/s1237.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1237.c,v 1.2 2001-03-19 15:58:42 afr Exp $\n *\n */\n\n\n#define S1237\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1237(SISLSurf *psurf,int inmb1,int inmb2,double aepscu,int *jstat)\n#else\nvoid s1237(psurf,inmb1,inmb2,aepscu,jstat)\n     SISLSurf *psurf;\n     int         inmb1;\n     int         inmb2;\n     double      aepscu;\n     int         *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Draw constant parameter lines in a B-spline surface.\n*\n*\n*\n* INPUT      : psurf  - Pointer to the surface.\n*              inmb1  - Number of constant parameter lines to be drawn\n*                       in first parameter direction.\n*              inmb2  - Number of constant parameter lines to be drawn\n*                       in second parameter direction.\n*              aepscu - The maximal distance allowed between the curves\n*                       drawn and the surface.\n*\n*\n*\n* OUTPUT     : \n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1236  - Find constant parameter values where a curve\n*                       will be drawn.\n*              s1436  - Pick curve with constant second parameter from\n*                       surface.\n*              s1437  - Pick curve with constant first parameter from\n*                       surface.\n*              s1605  - Approximate curve with a sequence of straight lines.\n*              s6drawseq - Draw a sequence of straight lines.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;           /* Local status variable.               */\n  int kpos = 0;            /* Position of error.                   */\n  int ki;                  /* Counter.                             */\n  int knbpnt;              /* Number of points in line sequence.   */\n  double *spar1 = SISL_NULL;    /* Values of constant parameter curves\n\t\t\t      in first parameter direction.        */\n  double *spar2 = SISL_NULL;    /* Values of constant parameter curves\n\t\t\t      in second parameter direction.       */\n  double *spoint = SISL_NULL;   /* Sequence of straight lines \n\t\t\t      approximating a curve.               */\n  SISLCurve *qc = SISL_NULL;        /* Constant parameter curve.            */\n  \n  /* Test dimension of surface.  */\n  \n  if (psurf -> idim != 3) goto err104;\n  \n  /* Allocate space for arrays containing constant parameter values. */\n  \n  if ((spar1 = newarray(inmb1,double)) == SISL_NULL) goto err101;\n  if ((spar2 = newarray(inmb2,double)) == SISL_NULL) goto err101;\n  \n  /* Find parameter values to be used to make curves with constant\n     parameter values in second direction.                         */\n  \n  s1236(psurf->et2,psurf->in2,psurf->ik2,inmb2,spar2,&kstat);\n  if (kstat < 0) goto error;\n  \n  for (ki=0; ki<inmb2; ki++)\n    {\n      \n      /* Pick curve with constant second parameter direction. */\n      \n      s1436(psurf,spar2[ki],&qc,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Approximate the curve by a sequence of straight lines. */\n      \n      s1605(qc,aepscu,&spoint,&knbpnt,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Draw the curve as a sequence of straight lines.  */\n      \n      s6drawseq(spoint,knbpnt);\n      \n      /* Prepare for next curve to draw.  */\n      \n      if (qc != SISL_NULL) freeCurve(qc);   qc = SISL_NULL;\n      if (spoint != SISL_NULL) freearray(spoint);  spoint = SISL_NULL;\n    }\n  \n  /* Find parameter values to be used to make curves with constant \n     parameter values in first direction.                          */\n  \n  s1236(psurf->et1,psurf->in1,psurf->ik1,inmb1,spar1,&kstat);\n  if (kstat < 0) goto error;\n  \n  for (ki=0; ki<inmb1; ki++)\n    {\n      \n      /* Pick curve with constant first parameter direction.  */\n      \n      s1437(psurf,spar1[ki],&qc,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Approximate the curve by a sequence of straight lines. */\n      \n      s1605(qc,aepscu,&spoint,&knbpnt,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Draw the curve as a sequence of straight lines.  */\n      \n      s6drawseq(spoint,knbpnt);\n      \n      /* Prepare for next curve to draw.  */\n      \n      if (qc != SISL_NULL) freeCurve(qc);   qc = SISL_NULL;\n      if (spoint != SISL_NULL) freearray(spoint);  spoint = SISL_NULL;\n    }\n  \n  /* The surface is drawn.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1237\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Dimension not equal to 3.  */\n  \n err104: *jstat = -104;\n  s6err(\"s1237\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine. */\n  \n  error : *jstat = kstat;\n  s6err(\"s1237\",*jstat,kpos);\n  goto out;\n  \n out:\n  \n  /* Free space occupied by local arrays etc.  */\n  \n  if (spar1 != SISL_NULL) freearray(spar1);\n  if (spar2 != SISL_NULL) freearray(spar2);\n  if (spoint != SISL_NULL) freearray(spoint);\n  if (qc != SISL_NULL) freeCurve(qc);\n  \n  return;\n}\n"
  },
  {
    "path": "src/s1238.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1238.c,v 1.2 2001-03-19 15:58:42 afr Exp $\n *\n */\n\n\n#define S1238\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1238(SISLSurf *psurf,SISLCurve *pcurve,int inmb1,int inmb2,\n\t   double aepsco,double aepscu,int *jstat)\n#else\nvoid s1238(psurf,pcurve,inmb1,inmb2,aepsco,aepscu,jstat)\n     SISLSurf   *psurf;\n     SISLCurve  *pcurve;\n     int    inmb1;\n     int    inmb2;\n     double aepsco;\n     double aepscu;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Draw constant parameter lines in a B-spline surface\n*              that is limited by a closed B-spline curve lying in \n*              the parameter plane.\n*\n*\n*\n* INPUT      : psurf  - Pointer to the surface.\n*              pcurve - SISLCurve limiting the part of the surface that\n*                       is to be drawn.\n*              inmb1  - Number of constant parameter lines to be drawn\n*                       in first parameter direction.\n*              inmb2  - Number of constant parameter lines to be drawn\n*                       in second parameter direction.\n*              aepsco - Computer resolution.\n*              aepscu - The maximal distance allowed between the curves\n*                       drawn and the surface.\n*\n*\n*\n* OUTPUT     : \n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1236  - Find constant parameter values where a curve\n*                       will be drawn.\n*              s1239  - Pick segments of curve that lies within the\n*                       curve pcurve.\n*              s1436  - Pick curve with constant second parameter from\n*                       surface.\n*              s1437  - Pick curve with constant first parameter from\n*                       surface.\n*              s1605  - Approximate curve with a sequence of straight lines.\n*              s6drawseq - Draw a sequence of straight lines.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;           /* Local status variable.               */\n  int kpos = 0;            /* Position of error.                   */\n  int ki,kj;               /* Counters.                            */\n  int knbpnt;              /* Number of points in line sequence.   */\n  int kmax = 20;           /* Maximum number of curves to draw \n\t\t\t      along one parameter line.            */\n  int kcurve = 0;          /* Number of curves along one parameter\n\t\t\t      line.                                */\n  double *spar1 = SISL_NULL;    /* Values of constant parameter curves\n\t\t\t      in first parameter direction.        */\n  double *spar2 = SISL_NULL;    /* Values of constant parameter curves\n\t\t\t      in second parameter direction.       */\n  double *spoint = SISL_NULL;   /* Sequence of straight lines \n\t\t\t      approximating a curve.               */\n  SISLCurve *qc = SISL_NULL; /* Constant parameter curve.            */\n  SISLCurve *uc[20];    /* Constant parameter curves.           */\n  \n  for (ki=0; ki<20; ki++) uc[ki] = SISL_NULL;\n  \n  /* Test dimension of curve and surface.  */\n  \n  if (pcurve -> idim != 2) goto err108;\n  if (psurf -> idim != 3) goto err104;\n  \n  /* Test if the limiting curve is closed.  */\n  \n  s1364(pcurve,aepscu,&kstat);\n  if (kstat < 0) goto error;\n  if (kstat != 1) goto err114;\n  \n  /* Allocate space for arrays containing constant parameter values. */\n  \n  if ((spar1 = newarray(inmb1,double)) == SISL_NULL) goto err101;\n  if ((spar2 = newarray(inmb2,double)) == SISL_NULL) goto err101;\n  \n  /* Find parameter values to be used to make curves with constant\n     parameter values in second direction.                         */\n  \n  s1236(psurf->et2,psurf->in2,psurf->ik2,inmb2,spar2,&kstat);\n  if (kstat < 0) goto error;\n  \n  for (ki=0; ki<inmb2; ki++)\n    {\n      \n      /* Pick curve with constant second parameter direction. */\n      \n      s1436(psurf,spar2[ki],&qc,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Pick the part of the curves that lie within the curve pcurve. */\n      \n      s1239(qc,1,spar2[ki],pcurve,aepsco,aepscu,uc,kmax,&kcurve,&kstat);\n      if (kstat < 0) goto error;\n      \n      for (kj=0; kj<kcurve; kj++)\n\t{\n\t  \n\t  /* Approximate the curve by a sequence of straight lines. */\n\t  \n\t  s1605(uc[kj],aepscu,&spoint,&knbpnt,&kstat);\n\t  if (kstat < 0) goto error;\n\t  \n\t  /* Draw the curve as a sequence of straight lines.  */\n\t  \n\t  s6drawseq(spoint,knbpnt);\n\t  \n\t  /* Prepare for next curve to draw.  */\n\t  \n\t  if (uc[kj] != SISL_NULL) freeCurve(uc[kj]);   uc[kj] = SISL_NULL;\n\t  if (spoint != SISL_NULL) freearray(spoint);  spoint = SISL_NULL;\n\t}\n      kcurve = 0;\n      if (qc != SISL_NULL) freeCurve(qc);   qc = SISL_NULL;\n    }\n  \n  /* Find parameter values to be used to make curves with constant \n     parameter values in first direction.                          */\n  \n  s1236(psurf->et1,psurf->in1,psurf->ik1,inmb1,spar1,&kstat);\n  if (kstat < 0) goto error;\n  \n  for (ki=0; ki<inmb1; ki++)\n    {\n      \n      /* Pick curve with constant first parameter direction.  */\n      \n      s1437(psurf,spar1[ki],&qc,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Pick the part of the curves that lie within the curve pcurve. */\n      \n      s1239(qc,0,spar1[ki],pcurve,aepsco,aepscu,uc,kmax,&kcurve,&kstat);\n      if (kstat < 0) goto error;\n      \n      for (kj=0; kj<kcurve; kj++)\n\t{\n\t  \n\t  /* Approximate the curve by a sequence of straight lines. */\n\t  \n\t  s1605(uc[kj],aepscu,&spoint,&knbpnt,&kstat);\n\t  if (kstat < 0) goto error;\n\t  \n\t  /* Draw the curve as a sequence of straight lines.  */\n\t  \n\t  s6drawseq(spoint,knbpnt);\n\t  \n\t  /* Prepare for next curve to draw.  */\n\t  \n\t  if (uc[kj] != SISL_NULL) freeCurve(uc[kj]);   uc[kj] = SISL_NULL;\n\t  if (spoint != SISL_NULL) freearray(spoint);  spoint = SISL_NULL;\n\t}\n      kcurve = 0;\n      if (qc != SISL_NULL) freeCurve(qc);  qc = SISL_NULL;\n    }\n  \n  /* The surface is drawn.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1238\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Dimension not equal to 3.  */\n  \n err104: *jstat = -104;\n  s6err(\"s1238\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Dimension not equal to 2.  */\n  \n err108: *jstat = -108;\n  s6err(\"s1238\",*jstat,kpos);\n  goto out;\n  \n  /* Error in curve-description. Open curve when close expected.  */\n  \n err114: *jstat = -114;\n  s6err(\"s1238\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine. */\n  \n  error : *jstat = kstat;\n  s6err(\"s1238\",*jstat,kpos);\n  goto out;\n  \n out:\n  \n  /* Free space occupied by local arrays etc.  */\n  \n  if (spar1 != SISL_NULL) freearray(spar1);\n  if (spar2 != SISL_NULL) freearray(spar2);\n  if (spoint != SISL_NULL) freearray(spoint);\n  if (qc != SISL_NULL) freeCurve(qc);\n  \n  return;\n}\n"
  },
  {
    "path": "src/s1239.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1239.c,v 1.3 2001-03-19 15:58:43 afr Exp $\n *\n */\n\n\n#define S1239\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n#if defined(SISLNEEDPROTOTYPES)\nstatic void s1239_s9sort(double [],int [],int);\n#else\nstatic void s1239_s9sort();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1239(SISLCurve *pcpar,int ipar,double apar,SISLCurve *pcurve,double aepsco,\n\t   double aepsge,SISLCurve **vpartc,int imax,int *jpartc,int *jstat)\n#else\nvoid s1239(pcpar,ipar,apar,pcurve,aepsco,aepsge,vpartc,imax,jpartc,jstat)\n     SISLCurve  *pcpar;\n     int    ipar;\n     double apar;\n     SISLCurve  *pcurve;\n     double aepsco;\n     double aepsge;\n     SISLCurve  **vpartc;\n     int    imax;\n     int    *jpartc;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Fetch the parts of the constant parameter curve pcpar\n*              that lies within the closed curve pcurve. Used in\n*              drawing constant parameter lines of a surface limited\n*              by a closed B-spline curve.\n*\n*\n*\n* INPUT      : pcpar  - Constant parameter curve in a surface.\n*              ipar   - Constant parameter direction of the surface\n*                       where the curve lies. ipar=0 or ipar=1.\n*              apar   - Constant parameeter value of the curve\n*                       corresponding to the surface.\n*              pcurve - The closed curve that the wanted curve-\n*                       segments lie within.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              imax   - Maximum number of curve-segments that can be\n*                       stored.\n*\n*\n*\n* OUTPUT     : vpartc - Array containing curve-segments lying within\n*                       pcurve.\n*              jpartc - Number of curve-segments in wpartc.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1221,s1227,s1710,s1712,s1850,freeCurve,s1239_s9sort.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n* Changed by : Per OEyvind Hvidsten, SINTEF, 94-11.\n*              Added free(spt), thus removing a memory leak.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;      /* Local status variable.                            */\n  int kpos = 0;       /* Position of error.                                */\n  int ki,kj;          /* Counters.                                         */\n  int kpt;            /* Number of intersection points found.              */\n  int kcrv;           /* Number of intersection curves found.              */\n  int kleft = 0;      /* Parameter used in curve evaluation.               */\n  int kder = 1;       /* Number of derivatives of curve to evaluate.       */\n  int kpar = 0;       /* Number of times the closed curve crosses the\n\t\t\t parameter interval of constant parameter curve.   */\n  int *linter = SISL_NULL; /* Indicates kind of intersection point.\n\t\t\t = 0 : The point does not belong to an interval.\n\t\t\t = 1 : Belongs to an interval that touches line.\n\t\t\t = 2 : Belongs to an interval that crosses line.   */\n  int kinter;         /* Code for one element of linter.                   */\n  int kpartc = 0;     /* Counter of curves to return.                      */\n  double tzero = (double)0.0;   /* Zero.                                   */\n  double tstart,tend; /* End-parameters of constant parameter curve.       */\n  double tclstart,tclend; /* End-parameters of closed curve.               */\n  double t1,t2;       /* Help variables.                                   */\n  double tchange;     /* Help varaible.                                    */\n  double spoint[2];   /* SISLPoint on straight line describing the parameter\n\t\t\t interval of the constant parameter curve.         */\n  double snorm[2];    /* Normal to straight line.                          */\n  double *spt = SISL_NULL; /* Intersection points between curve and line.       */\n  double sder1[4];    /* Position and derivative of curve.                 */\n  double sder2[4];    /* Position and derivative of curve.                 */\n  double *spar = SISL_NULL;      /* Points where pcurve crosses the parameter\n\t\t\t       interval of pcpar.                          */\n  SISLIntcurve **ucrv;   /* Intersection curves between pcurve and line.*/\n  SISLCurve *qc1 = SISL_NULL; /* First part of subdivided curve.             */\n  SISLCurve *qc2 = SISL_NULL; /* Second part of subdivided curve.            */\n\n  /* Test input.  */\n\n  if (pcurve -> idim != 2) goto err108;\n\n  /* Fetch ends of parameter interval of closed curve. */\n\n  tclstart = *(pcurve->et + pcurve->ik - 1);\n  tclend   = *(pcurve->et + pcurve->in);\n\n  /* Describe the parameter interval of the constant parameter curve\n     as a straight line. First fetch endpoints of interval.           */\n\n  tstart = *(pcpar->et + pcpar->ik - 1);\n  tend = *(pcpar->et + pcpar->in);\n\n  if (ipar == 0)\n    {\n      spoint[0] = apar;  spoint[1] = tstart;\n      snorm[0] = tend-tstart;   snorm[1] = tzero;\n    }\n  else\n    {\n      spoint[0] = tstart;    spoint[1] = apar;\n      snorm[0] = tzero;       snorm[1] = tend-tstart;\n    }\n\n  /* Find all intersection between this straight line and the curve pcurve.*/\n\n  s1850(pcurve,spoint,snorm,2,aepsco,aepsge,&kpt,&spt,&kcrv,&ucrv,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Make sure that only one end-point of the closed curve is represented.*/\n\n  for (kj=0,ki=0; ki<kpt; ki++)\n    {\n      if (s6equal(spt[ki],tclstart,(double)1.0) ||\n\t  s6equal(spt[ki],tclend,(double)1.0))\n\t{\n\t  if (kj == 0) kj++;\n\t  else\n\t    {\n\t      for (kj=ki+1; kj<kpt; kj++) spt[kj-1] = spt[kj];\n\t      kpt--;\n\t    }\n\t}\n    }\n\n  /* Allocate space for curve interval information.  */\n\n  if (kpt+2*kcrv > 0)\n    {\n      if ((spar = newarray(kpt+2*kcrv,double)) == SISL_NULL) goto err101;\n      if ((linter = new0array(kpt+2*kcrv,int)) == SISL_NULL) goto err101;\n    }\n\n  /* Discuss intersection intervals.  */\n\n  for (ki=0; ki<kcrv; ki++)\n    {\n\n      /* Fetch parameters of endpoints of interval.  */\n\n      t1 = *((*(ucrv+ki))->epar1);\n      t2 = *((*(ucrv+ki))->epar1 + (*(ucrv+ki))->ipoint - 1);\n      if (t2 < t1)\n\t{\n\t  tchange = t1;  t1 = t2;  t2 = tchange;\n\t}\n\n      /* Evaluate curve in endpoints.  */\n\n      s1227(pcurve,kder,t1,&kleft,sder1,&kstat);\n      if (kstat < 0) goto error;\n\n      s1221(pcurve,kder,t2,&kleft,sder2,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Test if the curve crosses the constant parameter line during\n\t the interval.                                                 */\n\n      if (sder1[2+ipar]*sder2[2+ipar] > tzero)\n\tkinter = 2;    /* The curve crosses the straight line.  */\n      else kinter = 1;  /* The curve only touch the straight line.  */\n\n      /* Get endpoints of the part of the intersection interval that lies\n\t inside the parameter interval of the constant parameter curve.   */\n\n      t1 = MAX(MIN(sder1[1-ipar],sder2[1-ipar]),tstart);\n      t2 = MIN(MAX(sder1[1-ipar],sder2[1-ipar]),tend);\n\n      /* Remember endpoints of interval.  */\n\n      linter[kpar] = kinter;   spar[kpar++] = t1;\n      if (kpar == imax) goto err190;\n      linter[kpar] = kinter;   spar[kpar++] = t2;\n      if (kpar == imax) goto err190;\n    }\n\n  /* Discuss intersection points.  */\n\n  for (ki=0; ki<kpt; ki++)\n    {\n\n      /* Compute position and right derivative in point.  */\n\n      s1221(pcurve,kder,spt[ki],&kleft,sder1,&kstat);\n      if (kstat < 0) goto error;\n\n      if (!(s6equal(spt[ki],tclstart,(double)1.0) ||\n\t    s6equal(spt[ki],tclend,(double)1.0)))\n\t{\n\n\t  /* The point is not an end-point. Compute position and left\n\t     derivative in point.                                      */\n\n\t  s1227(pcurve,kder,spt[ki],&kleft,sder2,&kstat);\n\t  if (kstat < 0) goto error;\n\t}\n      else\n\t{\n\n\t  /* Evaluate curve in the other end-point.  */\n\n\t  t1 = (s6equal(spt[ki],tclstart,(double)1.0)) ? tclend : tclstart;\n\t  s1221(pcurve,kder,t1,&kleft,sder2,&kstat);\n\t  if (kstat < 0) goto error;\n\t}\n\n      if (DEQUAL(sder1[2]*sder2[3] - sder1[3]*sder2[2],(double)0.0))\n\t{\n\n\t  /* The derivative of pcurve is continuous in the point. */\n\n\t  if (DEQUAL(sder1[2+ipar],(double)0.0))\n\t    {\n\n\t      /* Possible touching point. Subdivide the curve in the point. */\n\n\t      s1710(pcurve,spt[ki],&qc1,&qc2,&kstat);\n\t      if (kstat < 0) goto error;\n\n\t      /* Test if the curve crosses the constant parameter line.  */\n\n\t      t1 = apar;  kj = 0;\n\t      while (qc1 && DEQUAL(t1,apar))\n\t\t{\n\t\t  kj++;\n\t\t  t1 = *(qc1->ecoef+2*(qc1->in-kj-1)+ipar);\n\t\t}\n\n\t      t2 = apar;  kj = 0;\n\t      while (qc2 && DEQUAL(t2,apar))\n\t\t{\n\t\t  kj++;\n\t\t  t2 = *(qc2->ecoef+2*kj+ipar);\n\t\t}\n\n\t      /* Free curve-parts generated at subdivision.  */\n\n\t      if (qc1 != SISL_NULL) freeCurve(qc1);  qc1 = SISL_NULL;\n\t      if (qc2 != SISL_NULL) freeCurve(qc2);  qc2 = SISL_NULL;\n\t    }\n\n\t  if (DNEQUAL(sder1[2+ipar],(double)0.0) ||\n\t      (t1-apar)*(t2-apar) < (double)0.0)\n\t    {\n\n\t      /* The curve crosses the parameter line.  */\n\n\t      t1 = sder1[1-ipar];\n\t      if (t1 < tstart) t1 = tstart;\n\t      else if (t1 > tend) t1 = tend;\n\n\t      /* Remember point.  */\n\n\t      spar[kpar++] = t1;\n\t      if (kpar == imax) goto err190;\n\t    }\n\t}\n      else\n\t{\n\n\t  /* Derivative discontinuous in point. Test if the curve crosses\n\t     the constant parameter line.                                 */\n\n\t  if (sder1[2+ipar]*sder2[2+ipar] > (double)0.0)\n\t    {\n\n\t      /* The curve crosses the line. */\n\n\t      t1 = sder1[1-ipar];\n\t      if (t1 < tstart) t1 = tstart;\n\t      else if (t1 > tend) t1 = tend;\n\n\t      /* Remember point.  */\n\n\t      spar[kpar++] = t1;\n\t      if (kpar == imax) goto err190;\n\t    }\n\t}\n    }\n\n  /* Sort the arrays spar and linter.  */\n\n  s1239_s9sort(spar,linter,kpar);\n\n  /* Pick the curve-segments that is to be returned from this routine. */\n\n  ki = 0;\n  while (ki < kpar-1)\n    {\n\n      /* Find index of end of curve-segment.  */\n\n      kj = ki + (linter[ki] == 0 && linter[ki+1] > 0) + 1;\n      while (kj < kpar-1 && ((ki < kj-1 && linter[kj] == 1) ||\n\t\t\t     (ki == kj-1 && linter[kj] == 2))) kj += ((linter[kj+1] > 0) + 1);\n      kj = MIN(kj,kpar-1);\n\n      if (DNEQUAL(spar[kj],spar[ki]))\n\t{\n\n\t  /* Pick the part of the constant parameter curve lying between\n\t     spar[ki] and spar[kj].                                       */\n\n\t  s1712(pcpar,spar[ki],spar[kj],vpartc+kpartc,&kstat);\n\t  if (kstat < 0) goto error;\n\n\t  /* Prepare for next curve segment.  */\n\n\t  ki = kj + 1;\n\t  kpartc++;\n\t}\n      else ki = kj + 1;\n    }\n\n  /* Wanted curve-segments picked.  */\n\n  *jpartc = kpartc;\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;\n  s6err(\"s1239\",*jstat,kpos);\n  goto out;\n\n  /* Error in input. Dimension not equal to 2.  */\n\n err108: *jstat = -108;\n  s6err(\"s1239\",*jstat,kpos);\n  goto out;\n\n  /* Error in storing curves. Array too small.  */\n\n err190: *jstat = -190;\n  s6err(\"s1239\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n  s6err(\"s1239\",*jstat,kpos);\n  goto out;\n\n out:\n\n  /* Free space occupied by local arrays.  */\n\n  if (spt != SISL_NULL) free(spt);\n  if (spar != SISL_NULL) freearray(spar);\n  if (linter != SISL_NULL) freearray(linter);\n\n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1239_s9sort(double epar[],int nint[],int ipar)\n#else\nstatic void s1239_s9sort(epar,nint,ipar)\n     double epar[];\n     int    nint[];\n     int    ipar;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Sort the array epar and change nint correspondingly.\n*\n*\n*\n* INPUT      : ipar   - Number of elements in the arrays epar and nint.\n*\n*\n* INPUT/OUTPUT : epar  - Array to be sorted.\n*                nint  - Array where the elements corresponds to the\n*                        elements of epar.\n*\n*********************************************************************\n*/\n{\n  int ki,kj;      /* Counters.                                          */\n  int kchange;    /* Help variable used to change two elements of nint. */\n  double tchange; /* Help variable used to change two elements of epar. */\n\n  for (ki=0; ki<ipar; ki++)\n    for (kj=ki+1; kj<ipar; kj++)\n      if (epar[kj] < epar[ki])\n\t{\n\t  tchange = epar[ki];  epar[ki] = epar[kj];  epar[kj] = tchange;\n\t  kchange = nint[ki];  nint[ki] = nint[kj];  nint[kj] = kchange;\n\t}\n\n  return;\n}\n"
  },
  {
    "path": "src/s1240.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1240.c,v 1.2 2001-03-19 15:58:43 afr Exp $\n *\n */\n\n\n#define S1240\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1240(SISLCurve *pcurve,double aepsge,double *clength,int *jstat)\n#else\nvoid s1240(pcurve,aepsge,clength,jstat)\n     SISLCurve  *pcurve;\n     double aepsge;\n     double *clength;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Calculate the length of a B-spline curve. The length\n*              calculated will not deviate more than (aepsge/the\n*              length calculated) from the real length of the curve.\n*\n*\n*\n* INPUT      : pcurve - Pointer to curve.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : clength - The length of the curve.\n*              jstat   - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6dist,s1251,make_cv_kreg.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;  /* Local status variable.                          */\n  int kpos = 0;   /* Position of error.                              */\n  int ki;         /* Counter.                                        */\n  int kdim;       /* Dimension of the space in which the curve lies. */\n  int kn;         /* Number of vertices of curve.                    */\n  int kcalc;      /* Indicates if correct length of curve is found.  */\n  double tlength; /* Length of curve.                                */\n  double tprev;   /* Previous length of curve calculated.            */\n  double teps;    /* Local tolerance.                                */\n  double *s1;     /* Pointer used to traverse real array.            */\n  SISLCurve *qc=SISL_NULL;  /* k-regular local curve.                     */\n  \n  if (pcurve->cuopen == SISL_CRV_PERIODIC)\n    {\n       /* Make curve k-regular. */\n       \n       make_cv_kreg(pcurve,&qc,&kstat);\n       if (kstat < 0) goto error;\n    }\n  else qc = pcurve;\n       \n  /* Copy curve information to local parameters. */\n  \n  kdim = qc -> idim;\n  kn   = qc -> in;\n  \n  /* Calculate length of control polygon.  */\n  \n  tlength = 0;\n  for (ki=1,s1=qc->ecoef+kdim; ki<kn; ki++,s1+=kdim)\n    tlength += s6dist(s1-kdim,s1,kdim);\n  \n  /* Set up local tolerance.  */\n  \n  teps = aepsge*100;\n  \n  kcalc = 0;\n  while (kcalc == 0)\n    {\n      teps = teps/2.0;\n      tprev = tlength;\n      \n      /* Compute length of curve.  */\n      \n      s1251(qc,teps,&tlength,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Test if the error is within the tolerance. */\n      \n      if (fabs(tprev-tlength)/MAX(tprev,tlength) < aepsge) kcalc = 1;\n      \n    }\n  \n  /* Length of curve calculated. */\n  \n  *clength = tlength;\n  *jstat = 0;\n  goto out;\n  \n  /* Error in lower level routine. */\n  \n  error : *jstat = kstat;\n  s6err(\"s1240\",*jstat,kpos);\n  goto out;\n  \n out: \n    \n    /* Free local curve.  */\n    \n    if (qc != SISL_NULL && qc != pcurve) freeCurve(qc);\n    \n    return;\n}\n\n"
  },
  {
    "path": "src/s1241.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1241.c,v 1.4 2001-03-19 15:58:43 afr Exp $\n *\n */\n\n\n#define S1241\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1241(SISLCurve *pcurve, double point[], int dim, double epsge,\n      double *area, int *stat)\n#else\nvoid s1241(pcurve, point, dim, epsge, area, stat)\n     SISLCurve  *pcurve;\n     double     point[];\n     int        dim;\n     double     epsge;\n     double     *area;\n     int        *stat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To calculate the area between a 2D curve and a 2D point.\n*              When the curve is rotating counter-clockwise around the\n*              point, the area contribution is positive.\n*              When the curve is rotating clockwise around the point,\n*              the area contribution is negative.\n*              If the curve is closed or periodic, the area calculated\n*              is independent of where the point is situated.\n*              The area is calculated exactly for B-spline curves, for\n*              NURBS the result is an approximation.\n*              This routine will only perform if the order of the curve is\n*              less than 7 (can easily be extended).\n*\n* INPUT      : pcurve - The 2D curve.\n*              point  - The reference point.\n*              dim    - Dimension of geometry (must be 2).\n*              epsge  - Absolute geometrical tolerance.\n*\n*\n* OUTPUT     : area   - Calculated length.\n*              stat   - Status messages\n*                       = 0 : OK.\n*                       < 0 : Error.\n*                       > 0 : Warning.\n*\n*\n* METHOD     : The area calculation can be obtained by a sum of integrations:\n*              area = Sum(i)Sum(j)(c_x(i)*c_y(j)*(Integral of)(N(i)*dN(j)/dt))\n*                     - (c_x(in-1)*c_y(in-1) - c_x(0)*c_y(0))/2,\n*              where c_x and c_y are the x and y components of the curve\n*              coefficients with regard to the input point, and N(i) is the\n*              i'th basis function.\n*              The integration is performed by use of Gauss quadrature.\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Johannes Kaasa, SINTEF, Oslo, Norway, 12-94.\n*\n*********************************************************************\n*/\n{\n   int ki, kj;                    /* Index in for loops.              */\n   int pos = 0;                   /* Position of error.               */\n   int start;                     /* Start index.                     */\n   int stop;                      /* Stop index.                      */\n   double max;                    /* Maximum step length.             */\n   double cord_lenght;            /* Cord lenght.                     */\n   double offset_tol;             /* Offset tolerance.                */\n   double knot_span;              /* Span of knot subinterval.        */\n   double first_intgr;            /* First integration.               */\n   double second_intgr;           /* Second integration.              */\n   double dummy[3];               /* Dummy array.                     */\n   double* x_comp = SISL_NULL;         /* x-component of the coordinates.  */\n   double* y_comp = SISL_NULL;         /* y-component of the coordinates.  */\n   SISLCurve* non_rat_crv = SISL_NULL; /* Local non-rational curve.        */\n   SISLCurve* non_per_crv = SISL_NULL; /* Local non-periodic curve.        */\n   SISLCurve* local_crv = SISL_NULL;   /* Local curve (do not deallocate). */\n\n\n\n   /* Check input. */\n\n   if (pcurve->idim != 2 || dim != 2)\n      goto err106;\n\n   /* Make local coordinates. Make sure the curve is k-regular, and\n      non-rational.                                                   */\n\n   if (pcurve->ikind == 2 || pcurve->ikind == 4)\n   {\n      /* The offset tolerance is made a bit ad hoc. */\n\n      cord_lenght = 0.0;\n      for (ki = 1, kj = 2; ki < pcurve->in; ki++, kj += 2)\n\t cord_lenght += sqrt((pcurve->ecoef[kj] - pcurve->ecoef[kj - 2])*\n\t\t\t     (pcurve->ecoef[kj] - pcurve->ecoef[kj - 2]) +\n\t\t\t     (pcurve->ecoef[kj + 1] - pcurve->ecoef[kj - 1])*\n\t\t\t     (pcurve->ecoef[kj + 1] - pcurve->ecoef[kj - 1]));\n      if (cord_lenght < REL_COMP_RES)\n\t goto err106;\n      offset_tol = epsge/cord_lenght;\n\n      max = 0.0;\n      s1360(pcurve, 0.0, offset_tol, dummy, max, dim, &non_rat_crv, stat);\n      if (*stat < 0) goto error;\n      local_crv = non_rat_crv;\n   }\n   else\n      local_crv = pcurve;\n\n   if (local_crv->cuopen == SISL_CRV_PERIODIC )\n   {\n      s1712 (local_crv, local_crv->et[local_crv->ik - 1],\n\t     local_crv->et[local_crv->in], &non_per_crv, stat);\n      if (*stat < 0) goto error;\n\n      local_crv = non_per_crv;\n   }\n\n   x_comp = newarray(local_crv->in, double);\n   y_comp = newarray(local_crv->in, double);\n\n   for (ki = 0, kj = 0; ki < local_crv->in; ki++, kj += 2)\n   {\n      x_comp[ki] = local_crv->ecoef[kj]     - point[0];\n      y_comp[ki] = local_crv->ecoef[kj + 1] - point[1];\n   }\n\n   /* Add up the contributions */\n\n   *area = 0.;\n\n   /* The outer loop runs along x. */\n\n   for (ki = 0; ki < local_crv->in; ki++)\n   {\n      start = max(ki - (local_crv->ik - 1), 0);\n      stop  = min(ki + (local_crv->ik - 1) + 1, local_crv->in);\n\n      /* The inner loop runs along y. */\n\n      for (kj = start; kj < stop; kj++)\n      {\n\n\t /* Do the Gauss quadrature. */\n\n\t knot_span = local_crv->et[kj + local_crv->ik - 1] -\n\t    local_crv->et[kj];\n\t if (kj > 0 && knot_span > REL_COMP_RES)\n\t {\n\t    s1244(local_crv->et, local_crv->ik, local_crv->ik,\n\t\t  local_crv->ik - 1, local_crv->in, ki, kj,\n\t\t  &first_intgr, stat);\n\t    if (*stat < 0) goto error;\n\n\t    first_intgr *= (local_crv->ik - 1)/knot_span;\n\t }\n\t else\n\t    first_intgr = 0.0;\n\n\t knot_span = local_crv->et[kj + local_crv->ik] -\n\t    local_crv->et[kj + 1];\n\t if (kj < (local_crv->in - 1) && knot_span > REL_COMP_RES)\n\t {\n\t    s1244(local_crv->et, local_crv->ik, local_crv->ik,\n\t\t  local_crv->ik - 1, local_crv->in, ki, kj + 1,\n\t\t  &second_intgr, stat);\n\t    if (*stat < 0) goto error;\n\n\t    second_intgr *= (local_crv->ik - 1)/knot_span;\n\t }\n\t else\n\t    second_intgr = 0.0;\n\n\t *area += x_comp[ki]*y_comp[kj]*(first_intgr - second_intgr);\n      }\n   }\n\n   /* Add the residue. */\n\n   *area += (x_comp[0]*y_comp[0] - x_comp[local_crv->in - 1]*\n\t     y_comp[local_crv->in - 1])/2.;\n\n   goto out;\n\n   /* Error in input. */\n\n  err106:\n   *stat = -106;\n   s6err(\"s1241\",*stat,pos);\n   goto out;\n\n   /* Error in lower level function */\n\n  error:\n   s6err(\"s1241\", *stat, pos);\n   goto out;\n\n  out:\n   if (non_rat_crv != SISL_NULL) freeCurve(non_rat_crv);\n   if (non_per_crv != SISL_NULL) freeCurve(non_per_crv);\n   if (x_comp != SISL_NULL) freearray(x_comp);\n   if (y_comp != SISL_NULL) freearray(y_comp);\n\n   return;\n}\n"
  },
  {
    "path": "src/s1243.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1243.c,v 1.3 2001-03-19 15:58:43 afr Exp $\n *\n */\n\n\n#define S1243\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1243(SISLCurve *pcurve, double point[], int dim, double epsge,\n      double weight[], double *area, double *moment, int *stat)\n#else\nvoid s1243(pcurve, point, dim, epsge, weight, area, moment, stat)\n     SISLCurve  *pcurve;\n     double     point[];\n     int        dim;\n     double     epsge;\n     double     weight[];\n     double     *area;\n     double     *moment;\n     int        *stat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To calculate the weight point and rotational momentum of\n*              an area between a 2D curve and a 2D point. The area is\n*              also calculated.\n*              When the curve is rotating counter-clockwise around the\n*              point, the area contribution is positive.\n*              When the curve is rotating clockwise around the point,\n*              the area contribution is negative.\n*              OBSERVE: FOR CALCULATION OF AREA ONLY, USE s1241().\n*\n* INPUT      : pcurve - The 2D curve.\n*              point  - The reference point.\n*              dim    - Dimension of geometry (must be 2).\n*              epsge  - Absolute geometrical tolerance.\n*\n*\n* OUTPUT     : weight - Weight point.\n*              area   - Area.\n*              moment - Rotational momentum.\n*              stat   - Status messages\n*                       = 0 : OK.\n*                       < 0 : Error.\n*                       > 0 : Warning.\n*\n*\n* METHOD     :\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Johannes Kaasa, SINTEF, Oslo, Norway, 12-94.\n*\n*********************************************************************\n*/\n{\n   int ki, kj;                    /* Index in for loops.              */\n   int pos = 0;                   /* Position of error.               */\n   int numb_seg;                  /* Number of segments.              */\n   int depth;                     /* Depth of recursion.              */\n   double cord_lenght;            /* Cord lenght.                     */\n   double offset_tol;             /* Offset tolerance.                */\n   double max;                    /* Maximum step length.             */\n   double local_tol;              /* Local tolerance.                 */\n   double prev_area;              /* Previous area.                   */\n   double bez_area;               /* Bezier area.                     */\n   double bez_moment;             /* Bezier moment.                   */\n   double dummy[3];               /* Dummy array.                     */\n   double bez_weight[2];          /* Bezier weight point.             */\n   SISLCurve* non_rat_crv = SISL_NULL; /* Local non-rational curve.        */\n   SISLCurve* local_crv = SISL_NULL;   /* Local curve (do not deallocate). */\n   SISLCurve* non_per_crv = SISL_NULL; /* Local non-periodic curve.        */\n   SISLCurve* bez_crv = SISL_NULL;     /* Bezier convertion of curve.      */\n\n\n   /* Check input. */\n\n   if (pcurve->idim != 2 || dim != 2)\n      goto err106;\n   if (pcurve->ik < 1)\n      goto err106;\n   if ((epsge - 0.0) < REL_COMP_RES)\n      goto err106;\n\n   /* Make sure the curve is k-regular, and non-rational. */\n\n   if (pcurve->ikind == 2 || pcurve->ikind == 4)\n   {\n      /* The offset tolerance is made a bit ad hoc. */\n\n      cord_lenght = 0.0;\n      for (ki = 1, kj = 2; ki < pcurve->in; ki++, kj += 2)\n\t cord_lenght += sqrt((pcurve->ecoef[kj] - pcurve->ecoef[kj - 2])*\n\t\t\t     (pcurve->ecoef[kj] - pcurve->ecoef[kj - 2]) +\n\t\t\t     (pcurve->ecoef[kj + 1] - pcurve->ecoef[kj - 1])*\n\t\t\t     (pcurve->ecoef[kj + 1] - pcurve->ecoef[kj - 1]));\n      if (cord_lenght < REL_COMP_RES)\n\t goto err106;\n      offset_tol = epsge/cord_lenght;\n\n      max = 0.0;\n      s1360(pcurve, 0.0, offset_tol, dummy, max, dim, &non_rat_crv, stat);\n      if (*stat < 0) goto error;\n      local_crv = non_rat_crv;\n   }\n   else\n      local_crv = pcurve;\n\n   if (local_crv->cuopen == SISL_CRV_PERIODIC )\n   {\n      s1712 (local_crv, local_crv->et[local_crv->ik - 1],\n\t     local_crv->et[local_crv->in], &non_per_crv, stat);\n      if (*stat < 0) goto error;\n\n      local_crv = non_per_crv;\n   }\n\n   /* Convert the curve to Bezier segments. */\n\n   s1730(local_crv, &bez_crv, stat);\n   if (*stat < 0) goto error;\n\n   /* Find number of segments. */\n\n   numb_seg = bez_crv->in/bez_crv->ik;\n\n   /* Make a loop with regard to tolerance. */\n\n   local_tol = max(0.1, 10.1*epsge);\n   prev_area = 0.0;\n   *area = -1.0;\n\n   while (fabs(prev_area - *area) > epsge && local_tol > epsge)\n   {\n\n      local_tol *= 0.1;\n      prev_area = *area;\n\n      /* Do calculations for each segment. */\n\n      weight[0] = 0.0;\n      weight[1] = 0.0;\n      *area     = 0.0;\n      *moment   = 0.0;\n\n      for (ki = 0; ki < numb_seg; ki++)\n      {\n\t depth = 1;\n\t s1245(&(bez_crv->ecoef[ki*bez_crv->ik*bez_crv->idim]), bez_crv->ik,\n\t       bez_crv->idim, point, local_tol, depth, bez_weight, &bez_area,\n\t       &bez_moment, stat);\n\t if (*stat < 0) goto error;\n\n\t weight[0] += bez_weight[0];\n\t weight[1] += bez_weight[1];\n\t *area += bez_area;\n\t *moment += bez_moment;\n      }\n\n      if (fabs(*area) > REL_COMP_RES)\n      {\n         weight[0] /= *area;\n         weight[1] /= *area;\n      }\n   }\n\n   goto out;\n\n   /* Error in input. */\n\n  err106:\n   *stat = -106;\n   s6err(\"s1243\",*stat,pos);\n   goto out;\n\n   /* Error in lower level function */\n\n  error:\n   s6err(\"s1243\", *stat, pos);\n   goto out;\n\n  out:\n   if (non_rat_crv != SISL_NULL) freeCurve(non_rat_crv);\n   if (non_per_crv != SISL_NULL) freeCurve(non_per_crv);\n   if (bez_crv != SISL_NULL) freeCurve(bez_crv);\n\n   return;\n}\n"
  },
  {
    "path": "src/s1244.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1244.c,v 1.1 1995-01-03 09:49:21 pfu Exp $\n *\n */\n\n\n#define S1244\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1244(double knots[], int knot_reg, int first_order, int second_order, \n      int in, int first_index, int second_index, double *integral, int *stat)\n#else\nvoid s1244(knots, knot_reg, first_order, second_order, in, first_index, \n\t   second_index, integral, stat)\n     double knots[];\n     int knot_reg;\n     int first_order; \n     int second_order;\n     int in;\n     int first_index;\n     int second_index; \n     double *integral; \n     int *stat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To integrate the product of two B-spline basis functions.\n*              The order of the functions may be different, but they are\n*              defined on the same knot vector.\n*              This routine will only perform if\n*              (first_order + second_order) < 12 (can easily be extended).\n*\n* INPUT      : knots    - The common knot vector.\n*              knot_reg - k-regularity of the knot vector.\n*              first_order  - Order of the first basis.\n*              second_order - Order of the second basis.\n*              in       - Dimension of the spline space.\n*              first_index  - Start knot index of the first basis.\n*              second_index - Start knot index of the second basis.\n*\n*\n* OUTPUT     : integral - The resulting integral.\n*              stat     - Status messages  \n*                         = 0 : OK.\n*                         < 0 : Error.\n*                         > 0 : Warning.\n*\n*                                  \n* METHOD     : The integration is performed in sequence on each knot \n*              subinterval, by use of Gauss quadrature.\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Johannes Kaasa, SINTEF, Oslo, Norway, 12-94.\n*\n*********************************************************************\n*/\n{\n   int ki, kj;            /* Index in for loops.                */\n   int pos = 0;           /* Position of error.                 */\n   int start_knot;        /* Start knot for non-zero integrand. */ \n   int end_knot;          /* End knot for non-zero integrand.   */ \n   int degree;            /* Polynomial degree of the product.  */\n   int numb_pnt;          /* Number of evaluation points.       */\n   int first_sup;         /* Superfluous knot regularity.       */\n   int second_sup;        /* Superfluous knot regularity.       */\n   int left;              /* Pointer into knot vector.          */\n   double par;            /* Parameter value.                   */\n   double sub_integral;   /* Integral on a knot subinterval.    */\n   double scale;          /* Scaling factor.                    */\n   double nodes[5];       /* Nodes in Gauss integration.        */\n   double weights[5];     /* Weights in Gauss integration.      */\n   double first_der[12];  /* Evaluation of basis functions.     */\n   double second_der[12]; /* Evaluation of basis functions.     */\n\n\n   /* Initiation. */\n   \n   first_sup  = knot_reg - first_order;\n   second_sup = knot_reg - second_order;\n   if (first_sup < 0 || second_sup < 0)\n      goto err106;\n   \n   *integral = 0.0;\n   \n   start_knot = max(first_index, second_index);\n   end_knot = min(first_index + first_order, second_index + second_order);\n   if (start_knot >= end_knot)\n      goto out;\n   \n   degree = first_order + second_order - 2;\n   numb_pnt = (int) ceil((degree + 1.)/2.);\n   numb_pnt = max(numb_pnt, 2);\n   if (numb_pnt > 5)\n      goto err106;\n   \n   /* Make a table of Gauss nodes and weights. */\n   \n   if (numb_pnt == 2)\n   {\n      nodes[0] = - 0.5773502691;\n      nodes[1] = 0.5773502691;\n      \n      weights[0] = 1.0;\n      weights[1] = 1.0;\n   }\n   else if (numb_pnt == 3)\n   {\n      nodes[0] = - 0.7745966692;\n      nodes[1] = 0.0;\n      nodes[2] = 0.7745966692;\n      \n      weights[0] = 0.5555555555;\n      weights[1] = 0.8888888888;\n      weights[2] = 0.5555555555;\n   } \n   else if (numb_pnt == 4)\n   {\n      nodes[0] = - 0.8611363115;\n      nodes[1] = - 0.3399810435;\n      nodes[2] = 0.3399810435;\n      nodes[3] = 0.8611363115;\n      \n      weights[0] = 0.3478548451;\n      weights[1] = 0.6521451548;\n      weights[2] = 0.6521451548;\n      weights[3] = 0.3478548451;\n   }\n   else\n   {\n      nodes[0] = - 0.9061798459;\n      nodes[1] = - 0.5384693101;\n      nodes[2] = 0.0;\n      nodes[3] = 0.5384693101;\n      nodes[4] = 0.9061798459;\n      \n      weights[0] = 0.2369268850;\n      weights[1] = 0.4786286704;\n      weights[2] = 0.5688888888;\n      weights[3] = 0.4786286704;\n      weights[4] = 0.2369268850;\n   }\n   \n   /* Go through each of the knot subintervals. */\n\n   for (ki = start_knot; ki < end_knot; ki++)\n   {\n      if ((knots[ki + 1] - knots[ki]) < REL_COMP_RES)\n\t continue;\n      \n      sub_integral = 0.0;\n      scale = (knots[ki + 1] - knots[ki])/2.;\n      for (kj = 0; kj < numb_pnt; kj++)\n      {\n\t par = knots[ki] + (nodes[kj] + 1)*scale;\n\t \n\t left = ki - first_sup;\n\t s1220(&knots[first_sup], first_order, in - first_sup,\n\t       &left, par, 0, first_der, stat);\n\t if (*stat < 0) goto error;\n\t left = ki - second_sup;\n\t s1220(&knots[second_sup], second_order, in - second_sup,\n\t       &left, par, 0, second_der, stat);\n\t if (*stat < 0) goto error;\n\t \n\t sub_integral += weights[kj]*\n\t    first_der[first_order - (ki + 1 - first_index)]*\n\t    second_der[second_order - (ki + 1 - second_index)];\n      }\n      \n      /* Add the contribution from this interval. */\n      \n      *integral += sub_integral*scale;\n   }\n   \n   goto out;\n     \n   /* Error, too high order in input. */\n  \n  err106: \n   *stat = -106;\n   s6err(\"s1244\", *stat, pos);\n   goto out;     \n     \n   /* Error in lower level function */\n     \n  error:\n   s6err(\"s1244\", *stat, pos);\n   goto out;\n     \n  out:\n     \n   return;\n}\n"
  },
  {
    "path": "src/s1245.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1245.c,v 1.2 2001-03-19 15:58:43 afr Exp $\n *\n */\n\n\n#define S1245\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1245(double coef[], int ik, int dim, double point[], \n      double local_tol, int depth, double weight[], double *area, \n      double *moment, int *stat)\n#else\nvoid s1245(coef, ik, dim, point, local_tol, depth, weight, area, moment, stat)\n     double     coef[];\n     int        ik;\n     int        dim;\n     double     point[];\n     double     local_tol;\n     int        depth;\n     double     weight[];\n     double     *area;\n     double     *moment;\n     int        *stat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate the weight point and rotational momentum of\n*              an area between a 2D Bezier segment and a 2D point. The area \n*              is also calculated.\n*              When the curve is rotating counter-clockwise around the\n*              point, the area contribution is positive.\n*              When the curve is rotating clockwise around the point,\n*              the area contribution is negative.\n*\n* INPUT      : coef   - Coefficients of the Bezier segment.\n*              ik     - Order of the segment in question.\n*              dim    - Dimension of geometry (must be 2).\n*              point  - The reference point.\n*              local_tol- The current tolerance.\n*              depth  - Depth of recursion.\n*\n*\n* OUTPUT     : weight - Weight point.\n*              area   - Area.\n*              moment - Rotational momentum.\n*              stat   - Status messages  \n*                       = 0 : OK.\n*                       < 0 : Error.\n*                       > 0 : Warning.\n*\n*                                  \n* METHOD     : \n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Johannes Kaasa, SINTEF, Oslo, Norway, 12-94.\n*\n*********************************************************************\n*/\n{\n   int ki, kj;                /* Index in for loop.         */\n   int pos = 0;               /* Position of error.         */\n   int index;                 /* Array index.               */\n   double add_area;           /* Addition to area.          */\n   double add_moment;         /* Addition to area.          */\n   double left_area;          /* Left area in recursion.    */\n   double right_area;         /* Right area in recursion.   */\n   double left_moment;        /* Left moment in recursion.  */\n   double right_moment;       /* Right moment in recursion. */\n   double vec1[2];            /* Utility vector.            */\n   double vec2[2];            /* Utility vector.            */\n   double vec3[2];            /* Utility vector.            */\n   double vec4[2];            /* Utility vector.            */\n   double left_weight[2];     /* Left weight in recursion.  */\n   double right_weight[2];    /* right weight in recursion. */\n   double* left_coef = SISL_NULL;  /* Left coefficients.         */\n   double* right_coef = SISL_NULL; /* Left coefficients.         */\n\n\n   /* Check input. */\n\n   if (dim != 2)\n      goto err106;\n   \n   /* Check if this is a straight line. */\n\n   if (ik < 3)\n   {\n      \n      /* Straight line. */\n      \n      for (ki = 0; ki < 2; ki++)\n      {\n\t vec1[ki] = coef[ki] - point[ki];\n         vec2[ki] = coef[2*(ik - 1) + ki] - point[ki];\n\t vec3[ki] = (coef[ki] + coef[2*(ik - 1) + ki] + point[ki])/3.;\n\t vec4[ki] = coef[2*(ik - 1) + ki] - coef[ki]; \n      }\n\n      *area = (vec1[0]*vec2[1] - vec1[1]*vec2[0])/2.;\n      *moment = ((vec1[0]*vec1[0] + vec1[1]*vec1[1])/4. +\n\t\t (vec1[0]*vec4[0] + vec1[1]*vec4[1])/4. +\n\t\t (vec4[0]*vec4[0] + vec4[1]*vec4[1])/12.)/\n\t         fabs(vec1[0]*vec4[1] - vec1[1]*vec4[0]);\n      if (*area < 0)\n\t *moment = - (*moment);\n      \n      weight[0] = (*area)*vec3[0];\n      weight[1] = (*area)*vec3[1];\n   }\n   else\n   {\n      \n      /* Not straight line. */\n      \n      *area = 0.0;\n      *moment = 0.0;\n      weight[0] = 0.0;\n      weight[1] = 0.0;\n\n      /* Do a calculation on all the coefficients. */\n\n      for (ki = 1; ki < ik; ki++)\n      {\n\n\t for (kj = 0; kj < 2; kj++)\n         {\n\t    vec1[kj] = coef[2*(ki - 1) + kj] - point[kj];\n            vec2[kj] = coef[2*ki + kj] - point[kj];\n    \t    vec3[kj] = (coef[2*(ki - 1) + kj] + coef[2*ki + kj] +\n\t\t\tpoint[kj])/3.;\n\t    vec4[kj] = coef[2*ki + kj] - coef[2*(ki - 1) + kj]; \n         }\n\n         add_area = (vec1[0]*vec2[1] - vec1[1]*vec2[0]);\n         add_moment = ((vec1[0]*vec1[0] + vec1[1]*vec1[1])/4. +\n\t\t (vec1[0]*vec4[0] + vec1[1]*vec4[1])/4. +\n\t\t (vec4[0]*vec4[0] + vec4[1]*vec4[1])/12.)/\n\t         fabs(vec1[0]*vec4[1] - vec1[1]*vec4[0]);\n         if (add_area < 0)\n\t    add_moment = - add_moment;\n      \n         weight[0] += add_area*vec3[0];\n         weight[1] += add_area*vec3[1];\t\n\t *area += add_area;\n\t *moment += add_moment;\n      }\n      \n      /* Do a calculation on the first and last coefficient. */\n      \n      for (kj = 0; kj < 2; kj++)\n      {\n\t vec1[kj] = coef[kj] - point[kj];\n         vec2[kj] = coef[2*(ik - 1) + kj] - point[kj];\n    \t vec3[kj] = (coef[kj] + coef[2*(ik - 1) + kj] + point[kj])/3.;\n\t vec4[kj] = coef[2*(ik - 1) + kj] - coef[kj]; \n      }\n\n      add_area = (vec1[0]*vec2[1] - vec1[1]*vec2[0]);\n      add_moment = ((vec1[0]*vec1[0] + vec1[1]*vec1[1])/4. +\n\t\t (vec1[0]*vec4[0] + vec1[1]*vec4[1])/4. +\n\t\t (vec4[0]*vec4[0] + vec4[1]*vec4[1])/12.)/\n\t         fabs(vec1[0]*vec4[1] - vec1[1]*vec4[0]);\n      if (add_area < 0)\n\t add_moment = - add_moment;\n      \n      weight[0] += add_area*vec3[0];\n      weight[1] += add_area*vec3[1];\t\n      *area += add_area;\n      *moment += add_moment;  \n      \n      /* Check the deviation between them. */\n      \n      if (fabs(*area) < REL_COMP_RES)\n      {\n\t \n\t /* No contribution. */\n\t \n\t weight[0] = 0.0;\n\t weight[1] = 0.0;\n\t *area = 0.0;\n\t *moment = 0.0;\n      }\n      \n      else if (fabs(2*add_area - *area)/fabs(*area) < local_tol || depth > 20)\n      {\n\t \n\t /* Good enough. */\n\t \n\t weight[0] /= 4.;\n\t weight[1] /= 4.;\n\t *area /= 4.;\n\t *moment /= 2.;\n      }\n      \n      else\n      {\n\t \n\t /* Not good enough, we have to subdivide. */\n\t \n\t left_coef = newarray(2*ik, double);\n\t right_coef = newarray(2*ik, double);\n\t \n\t for (ki = 0; ki < 2*ik; ki++)\n\t {\n\t    left_coef[ki] = coef[ki]; \n\t    right_coef[ki] = coef[ki];\n\t }\n\t \n\t for (ki = 1; ki < ik; ki++)\n\t {\n\t    for (kj = ki; kj < ik; kj++)\n\t    {\n\t       index = 2*(ik - kj + ki - 1);\n\t       left_coef[index] = (left_coef[index] + left_coef[index - 2])/2.;\n\t       index++;\n\t       left_coef[index] = (left_coef[index] + left_coef[index - 2])/2.;\n\t    }\n\t }\n\t \n\t for (ki = 1; ki < ik; ki++)\n\t {\n\t    for (kj = 0 ; kj < (ik - ki); kj++)\n\t    {\n\t       index = 2*kj;\n\t       right_coef[index] = (right_coef[index] + \n\t\t\t\t    right_coef[index + 2])/2.;\n\t       index++;\n\t       right_coef[index] = (right_coef[index] + \n\t\t\t\t    right_coef[index + 2])/2.;\n\t    }\n\t }\n\t \n\t /* Make a recursion. */\n\t \n\t s1245(left_coef, ik, dim, point, local_tol, (depth + 1), left_weight, \n\t       &left_area, &left_moment, stat);\n\t if (*stat < 0) goto error;\n\t \n\t s1245(right_coef, ik, dim, point, local_tol, (depth + 1), right_weight, \n\t       &right_area, &right_moment, stat);\n\t if (*stat < 0) goto error;\n\t \n\t weight[0] = left_weight[0] + right_weight[0];\n\t weight[1] = left_weight[1] + right_weight[1];\n\t *area = left_area + right_area;\n\t *moment = (left_moment + right_moment)/4.;\n\t \n\t if (left_coef != SISL_NULL) freearray(left_coef);\n\t if (right_coef != SISL_NULL) freearray(right_coef);\n      }\n      \n   }\n\n   goto out;\n     \n   /* Error in input. */\n  \n  err106: \n   *stat = -106;\n   s6err(\"s1245\",*stat,pos);\n   goto out;     \n     \n   /* Error in lower level function */\n     \n  error:\n   s6err(\"s1245\", *stat, pos);\n   goto out;\n     \n  out:\n   return;\n}\n\n\n\n"
  },
  {
    "path": "src/s1251.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1251.c,v 1.3 2001-03-19 15:58:43 afr Exp $\n *\n */\n\n#define S1251\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1251(SISLCurve *pcurve,double aepsco,double *clength,int *jstat)\n#else\nvoid s1251(pcurve,aepsco,clength,jstat)\n     SISLCurve  *pcurve;\n     double aepsco;\n     double *clength;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Calculate the length of a B-spline curve. The length\n*              calculated will not deviate more than aepsco from the\n*              real length of the curve.\n*\n*\n*\n* INPUT      : pcurve - Pointer to curve.\n*              aepsco - Computer resolution.\n*\n*\n*\n* OUTPUT     : clength - The length of the curve.\n*              jstat   - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6dist,s1251,s1710,freeCurve.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n* CHANGED BY : Vibeke Skytt, SINTEF Oslo, 95-05. Introduced stop criterion\n*                            on absolute lenght of the curve, and subdivided\n*                            initially into Bezier curves.\n* CORRECTED BY : Ulf J Krystad, SINTEF Oslo, 96-03. Corrected no of bez seg.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;            /* Local status variable.                      */\n  int kpos = 0;             /* Position of error.                          */\n  int ki;                   /* Counter.                                    */\n  int kn;                   /* Number of vertices of curve.                */\n  int kk;                   /* Order of curve.                             */\n  int kdim;                 /* Dimension of the space in which the curve lies.*/\n  int knbez;                /* Number of Bezier segments of curve.         */\n  double tpol = (double)0.0;/* Length of control polygon.                  */\n  double tdist =(double)0.0;/* Distance between first and last vertex.     */\n  double tdum;              /* Help variable.                              */\n  double tmid;              /* Midpoint of parameter interval of curve.    */\n  double tlength1,tlength2; /* Length of sub-curves.                       */\n  double *s1;               /* Pointer used to traverse coefficient array. */\n  SISLCurve *qc1 = SISL_NULL;        /* First sub-curve.                            */\n  SISLCurve *qc2 = SISL_NULL;        /* Second sub-curve.                           */\n\n  /* Copy properties of curve to local parameters. */\n\n  kn = pcurve -> in;\n  kk = pcurve -> ik;\n  kdim = pcurve -> idim;\n\n  /* Calculate length of control polygon. */\n\n  for (ki=1,s1=pcurve->ecoef+kdim; ki<kn; ki++,s1+=kdim)\n    tpol += s6dist(s1-kdim,s1,kdim);\n\n  /* Calculate distance from first to last vertex.  */\n\n  tdist = s6dist(pcurve->ecoef,pcurve->ecoef+(kn-1)*kdim,kdim);\n\n  /* Test if the length of the curve can be approximated by the\n     distance from the first to the last vertex.                */\n\n  if (DEQUAL(tpol + tdist,(double)0.0)) tdum = (double)0.0;\n  else tdum = (tpol - tdist)/(tpol + tdist);\n\n  if (tdum < aepsco)\n\n    /* The length of the curve is found.  */\n\n    *clength = tdist;\n  else if ((tdist <= REL_COMP_RES && tpol <= (double)10*REL_COMP_RES) ||\n\t   tpol-tdist <= REL_COMP_RES)\n\n     /* Do not subdivide any further. */\n\n     *clength = (double)0.5*(tdist+tpol);\n  else if (pcurve->ik == pcurve->in)\n    {\n\n      /* Subdivide the curve at the midpoint. */\n\n      tmid = ((double)0.5)*(*(pcurve->et+pcurve->ik-1) + *(pcurve->et+kn));\n\n      s1710(pcurve,tmid,&qc1,&qc2,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Compute length of first sub-curve. */\n\n      if (qc1)\n\t{\n\t  s1251(qc1,aepsco,&tlength1,&kstat);\n\t  if (kstat < 0) goto error;\n\t}\n      else\n\ttlength1 = 0.0;\n\n      /* Compute length of second sub-curve.  */\n\n      if (qc2)\n\t{\n\t  s1251(qc2,aepsco,&tlength2,&kstat);\n\t  if (kstat < 0) goto error;\n\t}\n      else\n\ttlength2 = 0.0;\n\n      *clength = tlength1 + tlength2;\n    }\n  else\n  {\n     /* Make a sequence of Bezier curves. */\n\n     s1730(pcurve, &qc1, &kstat);\n     if (kstat < 0) goto error;\n\n     /* Pick next Bezier curve and compute the length of the curve. */\n\n     /* UJK, 960329, ref BEOrd29367 */\n     /* knbez = qc1->in/kk - 1;     */\n\n     knbez = qc1->in/kk;\n\n     tlength1 = DZERO;\n     for (ki=0; ki<knbez; ki++)\n     {\n\t/* Represent the current segment as a curve. */\n\n\tif (qc1->ikind == 1 || qc1->ikind == 3)\n\t   qc2 = newCurve(kk, kk, qc1->et+ki*kk, qc1->ecoef+ki*kk*kdim,\n\t\t\t  qc1->ikind, kdim, 0);\n\telse\n\t   qc2 = newCurve(kk, kk, qc1->et+ki*kk, qc1->rcoef+ki*kk*(kdim+1),\n\t\t\t  qc1->ikind, kdim, 0);\n\n\tif (qc2 == SISL_NULL) goto err101;\n\n      /* Compute length of the current sub-curve.  */\n\n      s1251(qc2,aepsco,&tlength2,&kstat);\n      if (kstat < 0) goto error;\n\n      tlength1 += tlength2;\n\n      if (qc2 != SISL_NULL) freeCurve(qc2);\n      qc2 = SISL_NULL;\n     }\n\n     *clength = tlength1;\n  }\n\n  /* Length of curve found.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation. */\n\n  err101: *jstat = -101;\n  s6err(\"s1251\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n  s6err(\"s1251\",*jstat,kpos);\n  goto out;\n\n out:\n\n  /* Free space occupied by sub-curves.  */\n\n  if (qc1 != SISL_NULL) freeCurve(qc1);\n  if (qc2 != SISL_NULL) freeCurve(qc2);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1252.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1252.c,v 1.3 2001-03-19 15:58:43 afr Exp $\n *\n */\n\n\n#define S1252\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n#if defined (SISLNEEDPROTOTYPES)\nstatic void s1252_s6corr(double *,double,double [],int,int,int *,int *);\nstatic void s1252_s6dir(double *,double,double [],double,double);\n#else\nstatic void s1252_s6corr();\nstatic void s1252_s6dir();\n#endif\n\f\n#if defined (SISLNEEDPROTOTYPES)\nvoid\n\n     s1252(SISLCurve *pcurve,double aepsge,double astart,double *cpos,int *jstat)\n#else\nvoid s1252(pcurve,aepsge,astart,cpos,jstat)\n     SISLCurve  *pcurve;\n     double aepsge;\n     double astart;\n     double *cpos;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Newton iteration to a local maximum on a function\n*              in one variable.\n*\n* INPUT      : pcurve  - Pointer to the first curve in the intersection.\n*              aepsge  - Geometry resolution.\n*              astart  - Start value of the first curve to the iteration.\n*\n*\n*\n* OUTPUT     : cpos    - Parameter value of of first curve in intersection\n*                        point.\n*              jstat   - status messages\n*                                = 2   : Divergence or approximative\n*                                        intersection found.\n*                                = 1   : Intersection found.\n*                                < 0   : error.\n*\n*\n* METHOD     : Newton iteration in one parameter direction.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1221 - Evaluate expression of curve in given\n*                         parameter values.\n*\n* WRITTEN BY : Tor Dokken, SI, Mars 1989\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;        /* Local status variable.                          */\n  int kpos = 0;         /* Position of error.                              */\n  int kleft=0;          /* Variables used in the evaluator.                */\n  int kder=3;           /* Order of derivatives to be calulated            */\n  int kdim;             /* Dimension of space the curves lie in            */\n  int knbit;            /* Number of iterations                            */\n  int kn,kk;            /* Number of vertices and order                    */\n  int kdir=1;           /* Direction of derivative to be calculated        */\n  double tstart,tend;   /* Ends of parameter interval of first curve.      */\n  double tdelta;        /* Parameter interval of the curves.               */\n  double tdist=DZERO;   /* Distance between position and origo.            */\n  double td;        \t/* Distances between old and new parameter value   */\n  double tnext;         /* Parameter-value of expression in first curve.   */\n  double tprev;         /* Previous difference between the curves.         */\n  double sval[4];       /* Value ,first and second derivative on function  */\n  double *st;           /* Knot vector                                     */\n  double ref;           /* Refferance value for equality test.             */\n\n  /* Test input.  */\n\n  if (pcurve->idim != 1) goto err106;\n\n  kdim = pcurve -> idim;\n\n  /* Fetch endpoints and the intervals of parameter interval of curves.  */\n\n  st = pcurve->et;\n  kn = pcurve->in;\n  kk = pcurve->ik;\n\n  tstart = *(pcurve->et + pcurve->ik - 1);\n  tend   = *(pcurve->et + pcurve->in);\n  tdelta = tend - tstart;\n  if (tdelta == DZERO) tdelta = fabs(tend);\n  if (tdelta == DZERO) tdelta = (double)1.0;\n\n  /* Initiate variables.  */\n\n  tnext = astart;\n\n  /* Evaluate 0-1.st derivatives of function */\n\n  s1221(pcurve,kder,tnext,&kleft,sval,&kstat);\n  if (kstat < 0) goto error;\n\n  tprev = sval[0];\n\n  /* Evaluate step */\n\n  s1252_s6dir(&td,tnext,sval,tstart,tend);\n\n  /* Correct if we not are inside the parameter intervall. */\n\n  s1252_s6corr(&td,tnext,st,kn,kk,&kleft,&kdir);\n\n  /* Iterate to find the intersection point.  */\n\n  for (knbit = 0; knbit < 20; knbit++)\n    {\n\n      /* If the tnext is a break point test if it is a local maximum */\n\n      if (kdir == -2 || kdir == 2)\n\t{\n\t  double tder1,tder2;\n\t  /* Break point, test if local maximum */\n\n\t  s1221(pcurve,kder,tnext,&kleft,sval,&kstat);\n\t  if (kstat < 0) goto error;\n\t  tder2 = sval[1];\n\n\t  s1227(pcurve,kder,tnext,&kleft,sval,&kstat);\n\t  if (kstat < 0) goto error;\n\t  tder1 = sval[1];\n\n\t  /*    Test if top point */\n\n\t  if (tder1>=DZERO && tder2<=DZERO) break;\n\n\t  /*    Not a top point */\n\t}\n\n\n      /* Evaluate 0-1.st derivatives of both curves, dependent of the\n\t sign of td we calculate derivatives from the right or the left */\n\n      if (kdir>=1)\n\t{\n\t  s1221(pcurve,kder,tnext+td,&kleft,sval,&kstat);\n\t  if (kstat < 0) goto error;\n\t}\n      else\n\t{\n\t  s1227(pcurve,kder,tnext+td,&kleft,sval,&kstat);\n\t  if (kstat < 0) goto error;\n\t}\n\n        tdist = sval[0];\n        if (fabs(tdist) < (double)1.0) ref = (double)2.0;\n\telse                           ref = DZERO;\n\n        if (tdist >= tprev || DEQUAL(ref+tdist,ref+tprev))\n\t{\n\t   tnext += td;\n\n\t   /* Evaluate step */\n\t   s1252_s6dir(&td,tnext,sval,tstart,tend);\n\t   s1252_s6corr(&td,tnext,st,kn,kk,&kleft,&kdir);\n\n\t   if (fabs(td/tdelta) <= REL_COMP_RES) break;\n\n\t   tprev = tdist;\n\n\t}\n\n      /* Not converging, correct and try again. */\n\n      else\n\t{\n\n\t  td /= (double)2;\n\t  if (fabs(td/tdelta) <= REL_COMP_RES) break;\n\t}\n\n\n    }\n\n\n  /* Iteration stopped, test if point founds found is within resolution */\n\n  if (tdist <= aepsge)\n    *jstat = 1;\n  else\n    *jstat = 2;\n\n  /*ujk,july 89:*/\n  /* Test if the iteration is close to a knot */\n  if (DEQUAL(tnext,pcurve->et[kleft]))\n    *cpos = pcurve->et[kleft];\n  else if (DEQUAL(tnext,pcurve->et[kleft+1]))\n    *cpos = pcurve->et[kleft+1];\n  else\n    *cpos = tnext;\n\n  /* Iteration completed.  */\n\n  goto out;\n\n\n  /* Error in input. Conflicting dimensions.  */\n\n err106: *jstat = -106;\n  s6err(\"S1252\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n  s6err(\"S1252\",*jstat,kpos);\n  goto out;\n\n out:;\n}\n\f\n#if defined (SISLNEEDPROTOTYPES)\nstatic void\n   s1252_s6corr(double *gdn,double acoef,double et[],\n\t\tint in,int ik,int *ileft,int *jdir)\n#else\nstatic void s1252_s6corr(gdn,acoef,et,in,ik,ileft,jdir)\n     double *gdn;\n     double acoef;\n     double et[];\n     int    in;\n     int    ik;\n     int    *ileft;\n     int    *jdir;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Adjust the step to not cross knot values or out\n*              of the curve\n*\n*\n* INPUT      : acoef   - Current parameter value\n*              st      - knots\n*              in      - number of vertices\n*              ik      - polynomial order\n*\n* INPUT/OUTPUT :\n*              ileft - Pointer to the interval in the knot vector\n*                       where ax is located, check the relations above.\n*\n*\n* OUTPUT     : gdn     - Old and new step value.\n*              jdir    - Direction of derivative to be calculated\n*                         -2 Negative direction acoef at break point\n*                         -1 Negative direction\n*                         +1 Positive direction\n*                         +2 Positive direction acoef at break point\n*\n* METHOD     : We are making the step keep inside the parameter interval.\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n*\n* WRITTEN BY : Tor Dokken, SI, Mars 1989\n*\n*********************************************************************\n*/\n{\n  int kmult,kstat;\n\n  /* Make sure the point is inside the interval */\n\n  *gdn = MAX(et[ik-1]-acoef,*gdn);\n  *gdn = MIN(et[in]  -acoef,*gdn);\n\n  if (acoef+*gdn<et[*ileft] && acoef>et[*ileft])\n    {\n      *gdn = MAX(et[*ileft]-acoef,*gdn);\n    }\n\n  else if(acoef<et[*ileft+1] && acoef+*gdn>et[*ileft+1])\n    {\n      /*  We cross a knot value */\n\n      *gdn = MIN(et[*ileft+1]-acoef,*gdn);\n    }\n\n  /* Make sure that we calculate the left or right handed derivatives */\n\n  if (*gdn>=0)\n    {\n      *jdir = 1;\n    }\n  else\n    {\n      *jdir = -1;\n    }\n\n  kmult = s6knotmult(et,ik,in,ileft,acoef,&kstat);\n\n  if (acoef==et[*ileft])\n    {\n\n      if(kmult>ik-2)\n        {\n\t  if (*jdir == -1)\n            {\n\t      *jdir = -2;\n            }\n\t  else\n            {\n\t      *jdir =  2;\n            }\n        }\n    }\n}\n\f\n#if defined (SISLNEEDPROTOTYPES)\nstatic void\n  s1252_s6dir(double *cdiff,double acoef,double eval[],double astart,\n\t      double aend)\n#else\nstatic void s1252_s6dir(cdiff,acoef,eval,astart,aend)\n     double *cdiff;\n     double acoef;\n     double eval[];\n     double astart;\n     double aend;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To compute the next iteration step\n*\n* INPUT      : eval    - Value and derivative\n*              astart  - The lower interval end\n*              aend    - The higher interval end\n*\n*\n* OUTPUT     : cdiff   - Iteration step\n*-\n*\n* WRITTEN BY : Tor Dokken, SI, Mars 1989\n*\n*********************************************************************\n*/\n{\n  double t1,t2,t3,t4,t5,t6;   /* Constants in equation.                    */\n  double tmax;                /* Max values in equation.                   */\n  double ttol=(double)1e-10;  /* Relative tolerance in equation.           */\n\n  /* Dummy statements to avoid warning. */\n  t1=acoef;\n  t2=astart;\n  t3=aend;\n\n\n  t1 =  eval[1];\n  t2 =  eval[2];\n  t3 =  eval[3]/(double)2.0;\n\n  tmax  = max(fabs(t1),fabs(t2));\n  tmax  = max(fabs(t3),tmax);\n\n  if (DEQUAL(tmax,DZERO))                    *cdiff = DZERO;\n  else if (fabs(t3)/tmax < ttol) /* The second degree part is degenerated. */\n\t{\n          if (fabs(t2) == DZERO )      *cdiff = DZERO;\n\t  else                        *cdiff = (-t1/t2);\n\t}\n  else\n\t{\n          /* An ordinary second degree equation.    */\n\t   t4 = t2*t2 - (double)4*t3*t1;\n\t   if (t4 < DZERO)\n\t    {\n\t      /* Use linear equation. */\n\t      if (fabs(t2) == DZERO )      *cdiff = DZERO;\n              else                        *cdiff = (-t1/t2);\n      \t    }\n\n           else\n\t    {\n\t       t6 = sqrt(t4);\n\t       t5 = (-t2 + t6)/((double)2*t3);\n\t       t6 = (-t2 - t6)/((double)2*t3);\n\t       t4 = min(fabs(t5),fabs(t6));\n\n               /* We have two solutions and we want to use the one\n\t          with the one with smallest value. */\n\n               if (t4 == DZERO)\n                {\n\t          /* Use linear equation. */\n\t          if (fabs(t2) == DZERO )      *cdiff = DZERO;\n                  else                        *cdiff = (-t1/t2);\n\t        }\n               else if (fabs(t5) <= fabs(t6))  *cdiff = t5;\n               else                            *cdiff = t6;\n             }\n\t}\n}\n"
  },
  {
    "path": "src/s1291.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S1291\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1291(double cvder[], double sfder[], int idim, double cvder2[], \n      int *jstat)\n#else\n  void s1291(cvder, sfder, idim, cvder2, jstat)\n     double cvder[];\n     double sfder[];\n     int idim;\n     double cvder2[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate position first and second derivative of\n*              the projection of a curve in a surface to a corresponding\n*              curve\n*\n*\n*\n* INPUT      : cvder   - 0-2 order derivatives of the corresponding curve\n*              sfder   - 0-2 order derivatives of surface. \n*                        The sequence is position, first derivative in first\n*                        parameter direction, first derivative in second\n*                        parameter direction, (2,0) derivative, (1,1)\n*                        derivative, (0,2) derivative and normal. (21 numbers)\n*                        Compatible with output of s1421\n*              idim    - Dimension of geometry space, expected to be 2 or 3\n*\n* OUTPUT     : cvder2  - 0-2 order derivatives of curve in surface\n*              jstat  - status messages  \n*                         = 0      : ok\n*                         < 0      : error\n*\n* METHOD     : The 0-2 order derivatives of the parameter curve in the\n*              surface is computed by projection. Then the derivatives\n*              of the surface curve is computed using the chain rule\n*\n*\n* REFERENCES : \n*-\n*              \n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 02.2018\n*\n*********************************************************************\n*/\n{\n  int ki;                     /* Counter                            */\n  double *f_t = cvder+idim;  /* 1. derivative, curve               */\n  double *f_tt = f_t+idim;  /* 2. derivative, curve               */\n  double *s_u = sfder+idim;  /* Partial derivative, 1. par. dir surface */\n  double *s_v = s_u+idim;   /* Partial derivative, 2. par. dir surface */\n  double *s_uu = s_v+idim;  /* 2. order partial derivative, 1. par. dir. */\n  double *s_uv = s_uu+idim; /* Mixed 2. order derivative          */\n  double *s_vv = s_uv+idim; /* 2. order partial derivative, 2. par. dir. */\n  double susu, susv, svsv, suft, svft;  /* Scalar products between 1.\n\t\t\t\t\t   order derivatives               */\n  double tdiv;                /* Divisor in equation solutions             */\n  double c1 = 0.0, c2 = 0.0;  /* 1. order derivative of curve in \n\t\t\t\t parameter domain                   */\n  double c3 = 0.0, c4 = 0.0;  /* 1. order derivative of curve in \n\t\t\t\t parameter domain                   */\n  double v1[3], v2[3];        /* Help vectors in computations       */\n  double t2u, t2v;            /* Scalar products                    */\n\n  /* Check input */\n  if (idim != 2 && idim != 3)\n    goto err105;\n\n  /* Compute 1. order derivative with respect to the parameter domain curve */\n  susu = s6scpr(s_u, s_u, idim);\n  susv = s6scpr(s_u, s_v, idim);\n  svsv = s6scpr(s_v, s_v, idim);\n  suft = s6scpr(s_u, f_t, idim);\n  svft = s6scpr(s_v, f_t, idim);\n  tdiv = susv*susv - susu*svsv;\n  if (fabs(tdiv) < REL_PAR_RES)\n    {\n      if (fabs(susu) < REL_PAR_RES && fabs(svsv) < REL_PAR_RES)\n\t{\n\t  c2 = s6scpr(f_t, f_t, idim)/svsv;\n\t  if (s6scpr(s_v, f_t, idim) < 0.0)\n\t    c2 *= -1.0;\n\t}\n      else\n\t{\n\t  c1 = s6scpr(f_t, f_t, idim)/susu;\n\t  if (s6scpr(s_u, f_t, idim) < 0.0)\n\t    c1 *= -1.0;\n\t}\n    }\n  else\n    {\n      c1 = (svft*susv - suft*svsv)/tdiv;\n      c2 = (suft*susv - svft*susu)/tdiv;\n    }\n\n  /* Compute 2. order derivative with respect to the parameter domain curve */\n  for (ki=0; ki<idim; ++ki)\n    {\n      v1[ki] = s_uu[ki]*c1*c1 + 2*s_uv[ki]*c1*c2 + s_vv[ki]*c2*c2;\n      v2[ki] = f_tt[ki] - v1[ki];\n    }\n  \n  t2u = s6scpr(v2, s_u, idim);\n  t2v = s6scpr(v2, s_v, idim);\n  if (fabs(tdiv) >= REL_PAR_RES)\n    {\n      c3 = (t2u*susv - t2v*svsv)/tdiv;\n      c4 = (t2u*susv - t2v*susu)/tdiv;\n    }\n\n  /* Compute derivatives with respect to the surface curve */\n  for (ki=0; ki<idim; ++ki)\n    {\n      cvder2[ki] = sfder[ki];\n      cvder2[idim+ki] = s_u[ki]*c1 + s_v[ki]*c2;\n      cvder2[2*idim+ki] = s_uu[ki]*c1*c1 + s_u[ki]*c3 + s_vv[ki]*c2*c2 +\n\ts_v[ki]*c4 + 2*s_uv[ki]*c1*c2;\n    }\n\n  goto out;\n\n err105:\n  *jstat = -105;\n  goto out;\n\n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1301.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1301.c,v 1.2 2001-03-19 15:58:43 afr Exp $\n *\n */\n\n\n#define S1301\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1301(double areler,double angle,int idim,SISLCurve **pc,int *jstat)\n#else\nvoid s1301(areler,angle,idim,pc,jstat)\n     double areler;\n     double angle;\n     int    idim;\n     SISLCurve  **pc;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To create a B-spline curve approximating a circular\n*              arc defined by radius=1 and the input angle. The\n*              arc will start in the point (1,0) in the xy-plane\n*              and the rotational direction is positive. If the opening\n*              angle is less than TWOPI then a k-regular basis is made,\n*              if the opening angle describes a full circle then a cyclic\n*              basis with double knots are made.\n*                \n*\n*             \n*\n* INPUT      : areler - The relative error the circular arc is to be\n*                       produced within.\n*              angle  - The angle defining how much of the circle is\n*                       to be made (in radians)\n*              idim   - The dimension of the curve to be produced\n*\n*\n*\n*\n* OUTPUT     : \n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*              pc     - Pointer to the curve produced\n*\n* METHOD     : First the number of polynomial segment to be produced\n*              are found by using an error estimat formula\n*              The tangent lengths of the interpolation points are\n*              determined. Finally the actual knot vector and and\n*              vertices are made.\n*\n*\n* REFERENCES :\n*\n*-                                      \n* CALLS      : pow, cos, sin. sqrt, fabs, newCurve\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, May 1988\n* Reviced by : Tor Dokken, SI, Oslo, Norway, April 1992 Introduction of cyclic basis.\n*\n*********************************************************************\n*/\n{\n  int    kant;           /* Number of segments                     */\n  int    kl;             /* Pointer into array                     */\n  int    kj;             /* Pointer into array                     */\n  int    ki;             /* Control variable in loop               */\n  int    kn;             /* Number of vertice                      */\n  int    kk = 4;         /* Polynomial order of curve              */\n  int    kpos = 1;       /* Position of error                      */\n  int    kstart,kstop;   /* Loop control variable                  */\n  double tangle;         /* Absolute value of angle                */\n  double talfa;          /* Variable used for different angles     */\n  double tcos,tsin;      /*Varable used for cos and sin of talfa   */\n  double *st = SISL_NULL;     /* Pointer to knot vecttor                */\n  double *scoef = SISL_NULL;  /* Pointer to vertex array                */\n  double ta,tb,tc;       /* Temporary variables                    */\n  double tl;             /* Length of tangents                     */\n  double tconst;         /* Internal constant                      */\n  \n  /* Check that the relative error wanted is positive */\n  if (areler<=(double)0.0) goto err120;\n  \n  /* Check that the dimesnion given is greater or equal to two */\n  if (idim<2) goto err103; \n  \n  /* Make first the curve as if the angle is only positive */\n  \n  tangle = fabs(angle);\n  \n  /*  If the absolute value of the rotation angle is greater than 2*PI\n   *  then make the angle to 2*PI and update angle to have absolute\n   *  value 2*PI \n   */\n  \n  \n  if (tangle >= TWOPI)\n    {\n      tangle = TWOPI;\n    }\n  \n  /*  Estimat the opening angle of the segments based on the error \n   *   formula. */                                                  \n  ta = (double)1.0/(double)6.0;\n  talfa = PI*pow(areler,ta)/((double)0.4879);\n  \n  /*   Find number of segments actually to be produced */\n  \n  kant = (int) ((tangle/talfa)+1);\n  \n  /*   Calculate actual angle to be used\n   *   ---------------------------------\n   */\n  \n  talfa = tangle/kant;\n  tcos = cos(talfa);\n  tsin = sin(talfa);\n  \n  /*  Calculate length of tangents   \n   *  tconst = (3-2sqrt(2))**1/3 + (3+2sqrt(2))**1/3 - 0.5 \n   */\n  \n  tconst = (double)1.85530139760811990992528773586425;\n  ta     = (double)0.6*tconst - (double)0.9*tcos;\n  tb     = ((double)0.4*tconst+(double)1.8)*tsin;\n  tc     = ((double)0.4*tconst+(double)1.0)*tcos -\n    (double)0.4*tconst - (double)1.0;\n  tl     = (-tb+sqrt(tb*tb-(double)4.0*ta*tc))/((double)2.0*ta);\n  \n  /*   Allocate space for vertices and knot vector; */\n  \n  kn = 2*kant + 2;\n  scoef = newarray(kn*idim,DOUBLE);\n  st    = newarray(kn+kk,DOUBLE);                       \n  if (scoef == SISL_NULL || st == SISL_NULL) goto err101;\n  \n  \n  /*   Calculate vertices and make knots. */\n  \n  kl = 0;\n  kj = 2;\n  \n  /*   Initate the whole vertex array to zero. */\n  \n  kstop = idim*kn;\n  for (ki=0;ki<kstop;ki++)\n    {\n      scoef[ki] = (double)0.0;\n    }\n  \n  /* If the opening angle is less than TWOPI the two first and two lastrcle is\n   *                       to be made (in radians)\n   vertices and knots are to be made in a special way to give a k-regular basis */\n  \n  if (tangle >= TWOPI)\n    {\n      st[0] = (double)-1;  \n      st[1] = (double)-1;\n      kstart = 0;\n      kstop = kant + 1;\n      \n      /* Next knot is to be made at index 2 */\n      \n      kj=2;\n      \n    }\n  \n  else\n    {\n      \n      \n      /* Make the two first vertices, and four first knots */\n      \n      tcos = (double)1.0;\n      tsin = (double)0.0;\n      scoef[0] = (double)1.0;\n      scoef[1] = (double)0.0;\n      scoef[idim] = (double)1.0;\n      scoef[idim+1] = tl;\n      st[0] = (double)0.0;  \n      st[1] = (double)0.0;\n      st[2] = (double)0.0;\n      st[3] = (double)0.0;\n      kstart = 1;\n      kstop = kant;\n      \n      /* Next knot is to be made at index 2 */\n      \n      kj = 4;\n      \n    }  \n  /* Make internal vertices, remember that only double knots exist */\n  \n  for (ki=kstart;ki<kstop;ki++)\n    {\n      kl = 2*ki*idim;\n      talfa = ki*tangle/kant;\n      \n      /* To make a stable calculation of the sin and cos values, we use\n       * arguments only in the interval [0,PI] \n       */\n      \n      \n      tcos = cos(talfa);\n      tsin = sin(talfa);\n      \n      /*\n\tif (talfa<=PIHALF)\n        {\n        tcos = cos(talfa);\n        tsin = sin(talfa);\n        }\n\telse if ( talfa<=PI)\n        {\n        talfa = PI - talfa;\n        tcos = -cos(talfa);\n        tsin = sin(talfa);\n        }\n\telse if (talfa<=THREEPIHALF)\n        {\n        talfa = talfa - PI;\n        tcos = -cos(talfa);\n        tsin = -sin(talfa);\n        }\n\telse\n        {\n        talfa = TWOPI - talfa;\n        tcos = cos(talfa);\n        tsin = -sin(talfa);\n        }                      \n\t*/\n      scoef[kl]        = tcos + tl*tsin;\n      scoef[kl+1]      = tsin - tl*tcos;\n      scoef[kl+idim]   = tcos - tl*tsin;\n      scoef[kl+idim+1] = tsin + tl*tcos;\n      st[kj++] = ki;\n      st[kj++] = ki;\n    }                     \n  \n  if (tangle >= TWOPI)\n    {\n      st[kn+2] = kant+1;\n      st[kn+3] = kant+1;\n      \n      \n      /*  Make sure that the two first and to last vertices correspond */\n      \n      ki = (kn-2)*idim;\n      scoef[ki] = scoef[0];\n      scoef[ki+1] = scoef[1];\n      scoef[ki+2] = scoef[2];\n      scoef[ki+3] = scoef[3];\n      \n      \n    }\n  else\n    {\n      \n      /*   Make two last vertices and four last knots  */\n      \n      tcos = cos(tangle);\n      tsin = sin(tangle);\n      kl = 2*kant*idim;;\n      scoef[kl]        = tcos + tl*tsin;\n      scoef[kl+1]      = tsin - tl*tcos;\n      scoef[kl+idim]   = tcos;\n      scoef[kl+idim+1] = tsin;\n      st[kn]   = kant;\n      st[kn+1] = kant;\n      st[kn+2] = kant;\n      st[kn+3] = kant;\n    }\n  \n  \n  /* If negative rotation angle make opposite sign of y-variable */\n  \n  if (angle<(double)0.0)\n    {\n      kl = 1;\n      for (ki=0;ki<kn;ki++)\n\t{\n\t  scoef[kl] = -scoef[kl];\n\t  kl+=idim;\n\t}\n    }\n  \n  /* Make curve, copy input arrays */\n  \n  *pc = newCurve(kn,kk,st,scoef,1,idim,1);\n  if (*pc == SISL_NULL) goto err101;\n\n  if (tangle >= TWOPI)\n    (*pc)->cuopen = SISL_CRV_PERIODIC;\n  \n  /* Normal circle segment made */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1301\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input, negative relative tolerance given */\n  \n err120: *jstat = -120;\n  s6err(\"s1301\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input, dimension less than 2 given */\n  \n err103: *jstat = -103;\n  s6err(\"s1301\",*jstat,kpos);\n  goto out;\n  \n  /* Free allocated arrays */\n out:\n  \n  if (st != SISL_NULL)    freearray(st);\n  if (scoef != SISL_NULL) freearray(scoef);\n  \n  return;\n  \n}\n    \n"
  },
  {
    "path": "src/s1302.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1302.c,v 1.2 2001-03-19 15:58:43 afr Exp $\n *\n */\n\n\n#define S1302\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1302(SISLCurve *pc,double aepsge,double angle,double ep[],double eaxis[],\n\t   SISLSurf **rs,int *jstat)\n#else\nvoid s1302(pc,aepsge,angle,ep,eaxis,rs,jstat)\n     SISLCurve  *pc;\n     double aepsge;\n     double angle;\n     double ep[];\n     double eaxis[];\n     SISLSurf   **rs;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To create a B-spline rotational surface by rotating\n*              the curve *pc around the axisdefined by e}[] and eaxis[]\n*              the given angle. The maximal deviation between the true\n*              rotational surface and the generated surface allowed \n*              is controlled by aepsge.\n*             \n*\n* INPUT      : pc     - Pointer to curve to be rotated\n*              aepsge - Maximal deviation allowed between true rotational\n*                       surface and generated surface.\n*              angle  - The rotational angle. Counter clockwise around axis.\n*                       If the absolute value of the angle is greater than\n*                       2 PI then a rotational surface closed in the\n*                       rotation direction is made.\n*              ep     - SISLPoint on rotational axis\n*              eaxis  - Direction of rotational axis\n*\n*\n* OUTPUT     : \n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*              rs     - Pointer to the surface produced\n*\n* METHOD     : First the maximal distance between the curve and the\n*              rotational axis is determined. Then by comparing this\n*              with aepsge the allowed relative error is found. This\n*              relative error and the rotational angle is used for\n*              generating a normalized circle segment spanning the\n*              actual angle. This circle is then translated to generate\n*              the actual rows of control vertices of the surface\n*\n* REFERENCES :\n*\n*-                                      \n* CALLS      : s6norm, s6scpr, s1301, s6rotax, s6mvec,\n*              newSurf, test_cyclic_knots, s6err\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. 24. May 1988\n* REVISED BY : Christophe Birkeland, SI, Oslo, Norway. 13. August 1992\n*              (Generates Nurbs-surface if aepsge = 0)\n* REVISED BY : Christophe Rene Birkeland, SINTEF, Oslo, May 1993.\n*              (jstat = kstat after call to s1520)\n*********************************************************************\n*/\n{\n  double *st1;            /* Pointer to knot vector of circle segment   */\n  double *scoef1;         /* Pointer to vertices of circle segment      */\n  int    kn1;             /* Number of vertice of circle segment        */\n  int    kk1;             /* Order of circle segment                    */\n  double *st2;            /* Pointer to knot vector of input curve      */\n  double *scoef2;         /* Pointer to vertices of input curve         */\n  int    kn2;             /* Number of vertice of input curve           */\n  int    kk2;             /* Order of input curve                       */\n  int    kdim;            /* Dimension of space in which curve lies     */\n  double sdiff[3];        /* Array for storing differences              */\n  double saxis[3];        /* Array for storing nomalize eaxis           */\n  int    kl;              /* Pointer into array                         */\n  int    kj;              /* Control variable in loop                   */\n  int    ki;              /* Control variable in loop                   */\n  double tlength;         /* Variable used for length calculation       */\n  double tmaxl;           /* Variable used for accumulating max lengths */\n  double treler;          /* Variable used for relative error           */\n  double *sucof=SISL_NULL;     /* Pointer to vertex array for surface        */\n  SISLCurve *pnorm=SISL_NULL;  /* Pointer to normalized circle segment       */\n  double smat[16];        /* Transformation matrix                      */\n  int    kstat;           /* Status variable                            */\n  double tfak;            /* Value of cross product                     */\n  double *srow;           /* Pointer to row of vertices in surface      */\n  \n  int    kpos = 1;       /* Position of error                     */\n  \n\n  /* If aepsge = 0.0, a nurbs surface is generated  */\n  \n  if (aepsge < REL_COMP_RES)\n  {\n     s1520(pc,angle,ep,eaxis,rs,&kstat);\n     if (kstat < 0)\n\tgoto error;\n     *jstat = kstat;\n     goto out;\n  }\n\t     \n     \n  /* Make local pointers to description of curve */\n  \n  st2    = pc -> et;\n  scoef2 = pc -> ecoef;\n  kn2    = pc -> in;\n  kk2    = pc -> ik;\n  kdim  = pc -> idim;\n  \n  /* The routine is only working for dimension=3 */\n  \n  if (kdim != 3) goto err104;\n  \n  \n  /* Normalize axis direction */                \n  (void)s6norm(eaxis,kdim,saxis,&kstat);\n  if (kstat<0) goto error;\n  \n  \n  /* Find maximal distance between axis and vertices of curve */\n  \n  tmaxl = (double)0.0;\n  \n  for (ki=0;ki<kn2;ki++)\n    {\n      \n      /*  Make difference between vertex and point on axis */\n      kl = ki*kdim;\n      for (kj=0;kj<3;kj++)\n        {\n\t  sdiff[kj] = scoef2[kl] - ep[kj];\n\t  kl++;\n        }\n      tfak = s6scpr(sdiff,saxis,kdim);\n      \n      /*  Find vector normal to axis going to vertex by subtracing the\n       *   component of the difference vector along the axis                */\n      for (kj=0;kj<3;kj++)\n        {\n\t  sdiff[kj] = sdiff[kj] - tfak*saxis[kj];\n        }\n      \n      /*  Find length of this vector */\n      tlength = s6norm(sdiff,kdim,sdiff,&kstat);\n      if (kstat<0) goto error;\n      tmaxl = MAX(tmaxl,tlength);\n    }\n  \n  /* Calculate relative error, if this is <=0 then the whole curve\n   *  lies on the axis. */\n  \n  if (tmaxl <= (double)0.0) goto err127;\n  treler = aepsge/tmaxl;\n  \n  \n  /* Calculate normalized circle */\n  \n  s1301(treler,angle,kdim,&pnorm,&kstat);\n  if (kstat<0) goto error;\n  \n  /* Make local variables for curve description */\n  \n  st1    = pnorm -> et;\n  scoef1 = pnorm -> ecoef;\n  kn1    = pnorm -> in;\n  kk1    = pnorm -> ik;\n  \n  /* Allocate vertex array for surface */\n  sucof = newarray(kn1*kn2*kdim,DOUBLE);\n  if (sucof == SISL_NULL) goto err101;\n  \n  /* Make the surface vertices circle segment by circle segment */\n  \n  for (ki=0;ki<kn2;ki++)\n    {\n      \n      /*  Make transformation matrix for first vertex on curve to be rotated */\n      \n      s6rotax(ep,eaxis,&scoef2[ki*kdim],smat,&kstat);\n      if (kstat<0) goto error;\n      \n      /*  Transform the vertices of this row into right position */\n      \n      srow = sucof + ki*3*kn1;\n      s6mvec(smat,scoef1,kn1,srow);\n    }    \n  \n  /* Create the surface */\n  \n  *rs =  newSurf(kn1,kn2,kk1,kk2,st1,st2,sucof,1,kdim,1);\n  \n  /* Check if the surface is cyclic in the first parameter direction. */\n  \n  test_cyclic_knots(st1,kn1,kk1,&kstat);\n  if (kstat < 0) goto error;\n  if (kstat == 2) (*rs)->cuopen_1 = SISL_SURF_PERIODIC;\n  \n  /* Copy periodicity flag from curve in second parameter direction. */\n  \n  (*rs)->cuopen_2 = pc->cuopen;\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1302\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input, dimension not equal to 3 */\n  \n err104: *jstat = -104;\n  s6err(\"s1302\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input, whole curve lies on axis */\n  \n err127: *jstat = -127;\n  s6err(\"s1302\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;     \n  s6err(\"s1302\",*jstat,kpos);\n  goto out;\n  \n  \n out:\n  \n  /* Free allocated arrays */\n  \n  if (sucof != SISL_NULL) freearray(sucof);\n  if (pnorm != SISL_NULL) freeCurve(pnorm);\n  \n  return;\n}\n"
  },
  {
    "path": "src/s1303.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1303.c,v 1.4 1994-08-23 09:18:08 pfu Exp $\n *\n */\n#define S1303\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1303(double epstrt[],double aepsge,double angle,double epcent[],\n\t   double eaxis[],int idim,SISLCurve **rc,int *jstat)\n#else\nvoid s1303(epstrt,aepsge,angle,epcent,eaxis,idim,rc,jstat)\n     double epstrt[];\n     double aepsge;\n     double angle;\n     double epcent[];\n     double eaxis[];\n     int    idim;\n     SISLCurve  **rc;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To create a B-spline approximating a circular arc\n*              around the axis defined by the center point epcent[],\n*              the axis eaxis[] a start point epstrt[] and rotational\n*              angle. The maximal deviation between the true\n*              circular arc and the approximation to the arc\n*              is controlled by aepsge.\n*\n*\n* INPUT      : epstrt - Start point of circular arc\n*              aepsge - Maximal deviation allowed between true circular arc\n*                       and generated curve.\n*              angle  - The rotational angle. Counter clockwise around axis.\n*                       If the rotational angle is outside <-PI,+PI> then\n*                       a closed curve is produced.\n*              epcent - SISLPoint of axis of circle\n*              eaxis  - Normal vector to plane of circle\n*              idim   - The dimension of the space (=3)\n*\n* OUTPUT     :\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*              rc     - Pointer to circle approximation produced.\n*                       NB! rc is declared as point to a curve pointer!\n*                           Use & in front of actual parameter if it\n*                           declared as pointer to curve.\n*\n* METHOD     : First the maximal distance between the curve and the\n*              rotational axis is determined. Then by comparing this\n*              with aepsge the allowed relative error is found. This\n*              relative error and the rotational angle is used for\n*              generating a normalized circle segment spanning the\n*              actual angle. This circle is then translated to generate\n*              the actual rows of control vertices of the surface\n*\n* EXAMPLE OF USE:\n*              SISLCurve *qr;\n*              int    kstat;\n*              .\n*              .\n*              s1303(ep,aepsge,angle,epcnet,eaxis,idim,&qr,&kstat);\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6norm, s6scpr, s1301,s6rotax, s6mvec, s6err\n*\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. 24. May 1988\n* REVISED BY : J. Kaasa, SI, Aug. 92 (Made a proper handling of 2D circles).\n* Revised by : Paal Fugelli, SINTEF Oslo, Norway, 23/08-1994. Added handling of\n*              kstat after call to s1301().\n*\n*********************************************************************\n*/\n{\n  double *scoef1;         /* Pointer to vertices of circle segment      */\n  int    kn1;             /* Number of vertice of circle segment        */\n  double sdiff[3];        /* Array for storing differences              */\n  double saxis[3];        /* Array for storing normalized eaxis         */\n  int    kj;              /* Control variable in loop                   */\n  double tlength;         /* Variable used for length calculation       */\n  double treler;          /* Variable used for relative error           */\n  double smat[16];        /* Transformation matrix                      */\n  int    kstat;           /* Status variable                            */\n  double tfak;            /* Value of cross product                     */\n  int    kpos = 1;        /* Possition of error                         */\n\n  double tdum;            /* Intermediate storing facility              */\n  int    klimit;          /* Limit in for loop                          */\n\n\n  /* The routine is only working for dimension 2 & 3 */\n\n  if (idim != 2 && idim != 3) goto err104;\n\n  if (idim == 2)\n  {\n     /* Make difference between start point and point on axis */\n\n     s6diff(epstrt, epcent, idim, sdiff);\n\n     /* Find length of this vector, which is the radius of the circle */\n\n     tlength = s6length(sdiff,idim,&kstat);\n  }\n\n  else if (idim == 3)\n  {\n     /* Normalize axis direction */\n\n     (void)s6norm(eaxis,idim,saxis,&kstat);\n\n     /* Find distance between axis and start point of circle */\n\n     /* Make difference between start point and point on axis */\n\n     s6diff(epstrt, epcent, idim, sdiff);\n     tfak = s6scpr(sdiff,saxis,idim);\n\n     /* Find vector normal to axis going to vertex by subtracing the\n     component of the difference vector along the axis */\n\n     for (kj=0;kj<3;kj++)\n       {\n         sdiff[kj] = sdiff[kj] - tfak*saxis[kj];\n       }\n\n     /* Find length of this vector, which is the radius of the circle */\n\n     tlength = s6length(sdiff,idim,&kstat);\n  }\n\n  /* Calculate relative error. If relative error  <= 0, the whole curve\n  lies on the axis  */\n\n  if (tlength <= (double)0.0) goto err127;\n  treler = aepsge/tlength;\n\n\n  /* Calculate normalized circle */\n\n  s1301(treler,angle,idim,rc,&kstat);\n  if (kstat < 0)  goto error;\n\n  /* Make local variables for curve description */\n\n  scoef1 = (*rc) -> ecoef;\n  kn1    = (*rc) -> in;\n\n\n  if (idim == 2)\n  {\n\n     /* Transform the circle approx into the right position. */\n\n     klimit = idim*kn1;\n     for (kj = 0; kj < klimit; kj += 2)\n     {\n\ttdum = epcent[0] + scoef1[kj]*sdiff[0] - scoef1[kj + 1]*sdiff[1];\n\tscoef1[kj + 1] = epcent[1] + scoef1[kj + 1]*sdiff[0]\n\t   + scoef1[kj]*sdiff[1];\n\tscoef1[kj] = tdum;\n     }\n  }\n\n  else if (idim == 3)\n  {\n\n     /* Transform the circle approx into the right position, first make\n     transformation matrix */\n\n     s6rotax(epcent,saxis,epstrt,smat,&kstat);\n\n     /* Transform the vertices into right position */\n\n     s6mvec(smat,scoef1,kn1,scoef1);\n  }\n\n  *jstat = 0;\n  goto out;\n\n\n  /* Error in input, dimension not equal to 3 */\n\n err104:\n  *jstat = -104;\n  s6err(\"s1303\",*jstat,kpos);\n  goto out;\n\n  /* Error in input, point lies on axis */\n\n err127:\n  *jstat = -127;\n  s6err(\"s1303\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine. */\n\n error:\n  *jstat = kstat;\n  s6err(\"s1303\", *jstat, kpos);\n  goto out;\n\n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1304.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1304.c,v 1.2 2001-03-19 15:58:43 afr Exp $\n *\n */\n\n\n#define S1304\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1304(double ep[],double eq[],double eparp[],double eparq[],double egeo3d[],\n\t   double egeop[],double egeoq[],int *jstat)\n#else\nvoid s1304(ep,eq,eparp,eparq,egeo3d,egeop,egeoq,jstat)\n     double ep[];\n     double eq[];\n     double eparp[];\n     double eparq[];\n     double egeo3d[];\n     double egeop[];\n     double egeoq[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate the radius of curvature at the intersection\n*              point between two curves. The first and second derivatives\n*              of the intersection point in the two surfaces are give as\n*              input. All coordinates are assumed to be in 3-D.\n*\n*\n*\n* INPUT      : ep      - 0-2 order derivatives of first surface.\n*                        The sequence is position, first derivative in first\n*                        parameter direction, first derivative in second\n*                        parameter direction, (2,0) derivative, (1,1)\n*                        derivative, (0,2) derivative and normal. (21 numbers)\n*                        Compatible with output of s1421\n*              eq      - 0-2 order derivatives of second surface. Same\n*                        sequence as ep.\n*              eparp   - Parameter pair in first surface of point\n*              eparq   - Parameter pair in second surface of point\n*\n* OUTPUT     : \n*              jstat  - status messages  \n*                         = 1      : Curvature radius infinit\n*                         = 0      : ok, curvature radius\n*                         < 0      : error\n*              egeo3d - 3-D geometry description of the intersection. The\n*                       array contains: position, unit tangent, curvature\n*                       and radius of curvature. (A total of 10 numbers)\n*                       A radius of curvature =-1, indicates that the radius\n*                       of curvature is infinit.\n*              egeop  - Description of the intersection in the parameter plane\n*                       of the first surface. The array contains: position,\n*                       unit tangent, curvature and radius of curvature.\n*                       (A total of 7 numbers)\n*              egeoq  - Description of the intersection in the parameter plane\n*                       of the second surface. The array contains: position,\n*                       unit tangent, curvature and radius of curvature.\n*                       (A total of 7 numbers)\n*\n* METHOD     : First the most lineary independent selection of 3 vectors\n*              from the derivative vectors are found. Then equation systems\n*              are made to determine the derivatives of the parameter values\n*              with respect to the parameter value not present in the\n*              selection of the three vectors. Then the double derivatives\n*              of the parameter direction are found. This information is used\n*              for expressing the 3-D tangent, curvature and the radius\n*              of curvature of the intersection point in question.\n*              Corresponding values in both parameter planes are also found.\n*\n*\n* REFERENCES : \n*-\n* CALLS      : s6norm,s6scpr,sqrt,fabs,s6length,s6crss\n*              \n*\n* WRITTEN BY : Tor Dokken, SI, Oslo , Norway, 30 May 1988\n*\n*********************************************************************\n*/\n{\n  int kdim = 3;           /* Dimension of 3-D space                      */\n  int k2dim = 2;          /* Dimension of the parameter planes           */\n  int kstat = 0;          /* Local status variable                       */\n  int ki;                 /* Control variable in loop                    */\n  double snpu[3];         /* Nomalized version of epu                    */\n  double snpv[3];         /* Nomalized version of epv                    */\n  double spn[3];          /* Vector snpu x snpv                          */\n  double snqs[3];         /* Nomalized version of eqs                    */\n  double snqt[3];         /* Nomalized version of eqt                    */\n  double sqn[3];          /* Vector snqs x snqt                          */\n  double sright[3];       /* Right hand side when finding s\"             */\n  double sdc[3];          /* Derivative of intersection curve by w       */\n  double sddc[3];         /* Second Derivative of intersection curve by w*/\n  double *sqs;            /* Pointer to first row of matrix              */\n  double *sqt;            /* Pointer to second row of matrix             */\n  double *spu;            /* Pointer to third row of matrix              */\n  double *spw;            /* Pointer to fourth row of matrix             */\n  double *spuu;           /* Pointer to renamed (2,0)-derivative         */\n  double *spuw;           /* Pointer to renamed (1,1)-derivative         */\n  double *spww;           /* Pointer to renamed (0,2)-derivative         */\n  double *sqss;           /* Pointer to renamed (2,0)-derivative         */\n  double *sqst;           /* Pointer to renamed (1,1)-derivative         */\n  double *sqtt;           /* Pointer to renamed (0,2)-derivative         */\n  double tt;              /* Value of det(snpu,snpv,snqs)                */\n  double ts;              /* Value of det(snpu,snpv,snqt)                */\n  double tv;              /* Value of det(snqs,snqt,snpu)                */\n  double tu;              /* Value of det(snqs,snqt,snpv)                */\n  double tlpu;            /* Length of epu                               */\n  double tlpv;            /* Length of epv                               */\n  double tlqs;            /* Length of eqs                               */\n  double tlqt;            /* Length of eqt                               */\n  double tmax1;           /* Variable used for maximal value             */\n  double tmax2;           /* Variable used for maximal value             */\n  double tdum;            /* Dummy variable                              */\n  double tdom;            /* The denominator in an equation              */\n  double tds;             /* ds/dw                                       */\n  double tdt;             /* dt/dw                                       */\n  double tdu;             /* du/dw                                       */\n  double tddu;            /* ddu/dwdw                                    */\n  double tdds;            /* dds/dwdw                                    */\n  double tddt;            /* ddt/dwdw                                    */\n  double twds;            /* ds/dw after renaming variable second time   */\n  double twdt;            /* dt/dw after renaming variable second time   */\n  double twdds;           /* dds/dwdw after renaming variable second time*/\n  double twddt;           /* ddt/dwdw after renaming variable second time*/\n  double twdu;            /* du/dw after renaming variable second time   */\n  double twdv;            /* dv/dw after renaming variable second time   */\n  double twddu;           /* ddu/dwdw after renaming variable second time*/\n  double twddv;           /* ddv/dwdw after renaming variable second time*/\n  \n  \n  /* Get input values into output. */\n  egeoq[0] = eparq[0];\n  egeoq[1] = eparq[1];\n  egeop[0] = eparp[0];\n  egeop[1] = eparp[1];\n  \n  for (ki=2;ki<7;ki++)\n    {\n      egeop[ki] = DZERO;\n      egeoq[ki] = DZERO;\n    }\n  \n  /* Make position of intersection */\n  \n  for (ki=0;ki<3;ki++)\n    {\n      egeo3d[ki] = (double)0.5 * (ep[ki]+eq[ki]);\n    }\n  \n  for (ki=3;ki<10;ki++) egeo3d[ki] = DZERO;\n  \n  \n  /* Nomalize derivative vectors */\n  \n  tlpu = s6norm(ep+3,kdim,snpu,&kstat);\n  tlpv = s6norm(ep+6,kdim,snpv,&kstat);\n  tlqs = s6norm(eq+3,kdim,snqs,&kstat);\n  tlqt = s6norm(eq+6,kdim,snqt,&kstat);\n  \n  /* Make normal vector for both derivative pairs */\n  \n  s6crss(snpu,snpv,spn);\n  s6crss(snqs,snqt,sqn);                                 \n  \n  /* Make four scalar product to decide which of the 3 vectors snpu, snpv, \n   * snqs, snqt spans the 3-D space best. (Have the biggest determinant)\n   * Remember (axb)c = det(a,b,c). The naming convention is that the\n   * name of the variable not present on the left hand side is used for\n   * the naming of the determinants. The determinants tt, ts, tu and tv tells\n   * which direction is most linearly dependent on the other directions  \n   */\n  \n  tt = fabs(s6scpr(spn,snqs,kdim));\n  ts = fabs(s6scpr(spn,snqt,kdim));\n  tv = fabs(s6scpr(sqn,snpu,kdim));\n  tu = fabs(s6scpr(sqn,snpv,kdim));\n  \n  /* We want to use the parameter direction names s, t and u on the left\n   * hand side of the equation system, thus we want to express all derivatives\n   * of the curve as functions of a new parameter  value w, which is chosen\n   * to be the parameter direction with partial first derivative most\n   * lineary dependent of the other parameter directions \n   */\n  \n  tmax1 = MAX(tt,ts);\n  tmax2 = MAX(tv,tu);\n  \n  if (tmax1 > tmax2)\n    {\n      \n      /*  The s or t variable should not be used on the left hand side of\n       *  the equation system                                                \n       */\n      \n      if (ts>tt) \n        {\n\t  \n\t  /*  The s variable should not be used on the left hand side of the \n\t   *  equation system\n\t   *  The renaming of variables is as follows s->w, t->u, u->s, v->t \n\t   */\n\t  \n\t  spu  = eq+6;\n\t  spw  = eq+3;\n\t  spuu = eq+15;\n\t  spuw = eq+12;\n\t  spww = eq+9;\n\t  sqs  = ep+3;\n\t  sqt  = ep+6;\n\t  sqss = ep+9;\n\t  sqst = ep+12;\n\t  sqtt = ep+15;\n        }\n      else\n        {\n\t  \n\t  /* The t variable should not be used on the left hand side of the \n\t   * equation system\n\t   *  The renaming of variables is as follows s->u, t->w, u->s, v->t \n\t   */\n\t  \n\t  spu  = eq+3;\n\t  spw  = eq+6;\n\t  spuu = eq+9;\n\t  spuw = eq+12;\n\t  spww = eq+15;\n\t  sqs  = ep+3;\n\t  sqt  = ep+6;\n\t  sqss = ep+9;\n\t  sqst = ep+12;\n\t  sqtt = ep+15;\n        }\n    }\n  else\n    {\n      \n      /* The u or v variable should not be used on the left hand side of\n       * the equation system                                                \n       */\n      \n      if (tu>tv)\n\t\n        {\n\t  \n\t  /* The u variable should not be used on the left hand side of the\n\t   * equation system.\n\t   * The renaming of variables is as follows s->s, t->t, u->w, v->u\n\t   */\n\t  \n\t  spu  = ep+6;\n\t  spw  = ep+3;\n\t  spuu = ep+15;\n\t  spuw = ep+12;\n\t  spww = ep+9;\n\t  sqs  = eq+3;\n\t  sqt  = eq+6;\n\t  sqss = eq+9;\n\t  sqst = eq+12;\n\t  sqtt = eq+15;\n\t  \n        }\n      \n      else\n\t\n        {\n\t  /* The v variable should not be used on the left hand side of the\n\t   * equation system.\n\t   * The renaming of variables is as follows s->s, t->t, u->u, v->w \n\t   */\n\t  \n\t  spu  = ep+3;\n\t  spw  = ep+6;\n\t  spuu = ep+9;\n\t  spuw = ep+12;\n\t  spww = ep+15;\n\t  sqs  = eq+3;\n\t  sqt  = eq+6;\n\t  sqss = eq+9;\n\t  sqst = eq+12;\n\t  sqtt = eq+15;\n\t  \n        }\n    }\n  \n  /* Now we can solve the equation systems for finding\n   *  ds/dw, dt/dw and du/dw and afterwards for\n   *  dds/(dwdw), ddt/(dwdw) and ddu/(dwdw), using Cramers Rule.\n   *\n   *  This equation system is derived in the following way:\n   *  Our problem is defined as P(u,w) - Q(s,t) = 0. By taking the derivative\n   *  of this equation with repsect to w, we get:\n   *\n   *  dP(u,w) du   dP(u,w)   dQ(s,t) ds   dQ(s,t) dt\n   *  ------- -- + ------- - ------- -- - ------- -- = 0\n   *  du      dw   dw        ds      dw   dt      dw    \n   *\n   *  By using a simplified notation this can be written:\n   *\n   *  P u' + P  - Q s' - Q t' = 0\n   *   u      w    s      t\n   *\n   *  We can thus set up the equation system:\n   *\n   *              s'\n   *  (Q  Q -P ) (t') = P\n   *    s t   u   u'     w\n   * \n   *\n   *\n   *  By making one futher derivative we get an equation systen for s\",t\" and\n   *  u\".\n   *\n   *               s\"         2                       2                   2\n   *  (Q  Q  -P ) (t\") = P  u'  + 2P  u' + P   - Q  s'  - 2Q  s't' - Q  t' \n   *    s  t   u   u\"     uu        uw      ww    ss        st        tt\n   *\n   *\n   */\n  \n  /* Prepare normal vectors for determinants */\n  \n  s6crss(spu,spw,spn);\n  s6crss(sqs,sqt,sqn);\n  \n  tdom =  -s6scpr(sqn,spu,kdim);\n  \n  if (DEQUAL(tdom,(double)0.0)) goto war101;\n  \n  /*  Lineary dependent vectors on left hand side if tdom = 0.0 */\n  \n  tds = -s6scpr(spn,sqt,kdim)/tdom;\n  tdt =  s6scpr(spn,sqs,kdim)/tdom;\n  tdu =  s6scpr(sqn,spw,kdim)/tdom;\n  \n  for (ki=0;ki<3;ki++)\n    {\n      sright[ki] = (spuu[ki]*tdu + (double)2.0*spuw[ki])*tdu + spww[ki]\n\t           - (sqss[ki]*tds + sqst[ki]*tdt)*tds\n\t           - (sqtt[ki]*tdt + sqst[ki]*tds)*tdt;\n    }\n  \n  /* Calculate second derivatives of parameter direction with respect to\n   * the w-direction \n   */\n  \n  tddu = s6scpr(sqn,sright,kdim)/tdom;\n  \n  /* Use sqn for temporary storage of cross products */\n  \n  s6crss(sright,sqt,sqn);\n  tdds = -s6scpr(sqn,spu,kdim)/tdom;\n  s6crss(sqs,sright,sqn);\n  tddt = -s6scpr(sqn,spu,kdim)/tdom;\n  \n  /* We will now express the intersection curve locally as a function\n   *  of the w-parameter.\n   *\n   *  c(w) = p(u(w),w)\n   *\n   *  This gives the derivative\n   *                         \n   *   \n   *  c' = P u' + P                                                   \n   *        u      w\n   *\n   *  And the second derivative\n   *\n   *            2\n   *  c\" = P  u'  + 2P  u' + P   + P u\"\n   *        uu        uw      ww    u\n   *\n   *  The curvature vector is defined as the derivative of the unit tangent\n   *  vector with respect to the arc length a(w):\n   *\n   *         d         d    c'(w)    dw   d    c'(w)      da\n   *  k(a) = -- T(a) = -- ---------- -- = -- ---------- / --\n   *         da        dw sqrt(c'c') da   dw sqrt(c'c')   dw\n   *\n   *\n   *         d       c'(w)                c\"        c' (c'c'')\n   *         -- ----------------- =   ---------- - ------------- \n   *         dw sqrt(c'(w) c'(w))     sqrt(c'c')   sqrt(c'c')**3\n   *\n   *\n   *\n   *         da\n   *         -- = sqrt(c'c')\n   *         dw \n   */\n  for (ki=0;ki<3;ki++)\n    {\n      sdc[ki] = spu[ki]*tdu + spw[ki];                \n      sddc[ki] = (spuu[ki]*tdu+(double)2.0*spuw[ki])*tdu +\n\tspu[ki]*tddu + spww[ki];\n    }\n  \n  /* To simplify futher calculations we want to normalize the tangent vector\n   *  and correspondingly divide the second derivative by the tangent length\n   */\n  \n  tlpu = s6norm(sdc,kdim,egeo3d+3,&kstat);\n  \n  if (DEQUAL(tlpu,(double)0.0)) goto war101;\n  \n  for (ki=0;ki<3;ki++)\n    {\n      sddc[ki] = sddc[ki]/tlpu;\n    }\n  \n  /* Make curvature vector */\n  \n  tdum = s6scpr(sddc,egeo3d+3,kdim);\n  for (ki=0;ki<3;ki++)\n    {\n      egeo3d[ki+6] = (sddc[ki] - egeo3d[ki+3]*tdum)/tlpu;\n    }\n  \n  /* TO CALCULATE UNIT TANGENT CURVATURE AND RADIUS OF CURVATURE OF THE\n   * INTERSECTION POINT IN THE PARAMETER PLANES OF THE TWO SURFACES, WE\n   * NOW WANT TO CALCULATE THE TRUE VALUES OF ds/dw, dt/dw, dds/dw,\n   * ddt/dwdw, du/dw, dv/dw, ddu/dwdw, ddv/dwdw, where w is the parameter\n   * direction we have chosen the other directions to be expressed in.\n   * THUS UNDO the changing of parameter directions \n   */\n  \n  if (tmax1 > tmax2)\n    {\n      \n      /* First and second row of the surface were originally interchanged\n       * Thus change sequence of these back again \n       */ \n      \n      if (ts>tt) \n        {\n\t  /* We used the following renaming of variables:\n\t   * s->w, t->u, u->s, v->t, now express the behavior in the parameter\n\t   * plane with the original ordering \n\t   */\n\t  \n\t  twds  = (double)1.0;\n\t  twdt  = tdu;\n\t  twdds = (double)0.0;\n\t  twddt = tddu;\n\t  twdu  = tds;\n\t  twdv  = tdt;\n\t  twddu = tdds;\n\t  twddv = tddt;\n\t  \n        }\n      else\n        {\n\t  \n\t  /* We used the following renaming of variables:\n\t   * s->u, t->w, u->s, v->t, now express the behavior in the parameter\n\t   * plane with the original ordering \n\t   */\n\t  \n\t  /* The renaming of variables is as follows s->v, t->u, u->s, v->t */\n\t  \n\t  twds  = tdu;\n\t  twdt  = (double)1.0;\n\t  twdds = tddu;\n\t  twddt = (double)0.0;\n\t  twdu  = tds;\n\t  twdv  = tdt;\n\t  twddu = tdds;\n\t  twddv = tddt;\n\t  \n        }\n    }\n  else\n    {\n      \n      /*  Keep the sequence of surfaces */\n      \n      if (tu>tv)\n\t\n        {\n\t  \n\t  /* We used the following renaming of variables:\n\t   * s->s, t->t, u->w, v->u, now express the behavior in the parameter\n\t   * plane with the original ordering \n\t   */\n\t  \n\t  twds  = tds;\n\t  twdt  = tdt;\n\t  twdds = tdds;\n\t  twddt = tddt;\n\t  twdu  = (double)1.0;\n\t  twdv  = tdu;\n\t  twddu = (double)0.0;\n\t  twddv = tddu;\n\t  \n        }                  \n      \n      else\n\t\n        {\n\t  \n\t  /* We used the following renaming of variables:\n\t   * s->s, t->t, u->u, v->w, now express the behavior in the parameter\n\t   * plane with the original ordering */\n\t  \n\t  twds  = tds;\n\t  twdt  = tdt;\n\t  twdds = tdds;\n\t  twddt = tddt;\n\t  twdu  = tdu;\n\t  twdv  = (double)1.0;\n\t  twddu = tddu;\n\t  twddv = (double)0.0;\n\t  \n        }\n    }\n  \n  /* Now the variable twds, twdt, twdu, twdv contains derivatives of the\n   * parameter directions with respect to the w-variable. Correspondingly\n   * the second derivatives with respect to w are contained in twdds, twddt,\n   * twddu and twddv.\n   *\n   * THE UNIT TANGENT, CURVATURE VECTOR AND RADIUS OF CURVATURE CAN NOW\n   * BE CALCULATED IN BOTH PARAMETER PLANES                                \n   */\n  \n  /* Make description of intersection curve in \n   * parameter plane of first patch\n   */\n  \n  \n  tdum = sqrt(twdu*twdu + twdv*twdv);\n  if (DEQUAL(tdum,(double)0.0))\n    {\n      egeop[2] = (double)0.0;\n      egeop[3] = (double)0.0;\n      egeop[4] = (double)0.0;\n      egeop[5] = (double)0.0;\n      egeop[6] = (double)0.0;\n    }\n  else\n    {\n      \n      /* Make unit tangent        */\n      \n      egeop[2] = twdu/tdum;\n      egeop[3] = twdv/tdum;\n      \n      /* Make curvature vector    */\n      \n      tdom = egeop[2]*twddu + egeop[3]*twddv;\n      egeop[4] = (twddu/tdum - egeop[2]*tdom/tdum)/tdum;\n      egeop[5] = (twddv/tdum - egeop[3]*tdom/tdum)/tdum;\n    }\n  \n  /* Make radius of curvature in parameter plane 1 */\n  \n  tdum = s6length(egeop+4,k2dim,&kstat);\n  if (DNEQUAL(tdum,(double)0.0))\n    {\n      egeop[6] = (double)1.0/tdum;\n    }\n  else\n    {\n      egeop[6] = (double)-1.0;\n    }\n  \n  /* Make description of intersection curve in parameter \n   * plane of second patch\n   */\n  tdum = sqrt(twds*twds + twdt*twdt);\n  if (DEQUAL(tdum,(double)0.0))\n    {\n      egeoq[2] = (double)0.0;\n      egeoq[3] = (double)0.0;\n      egeoq[4] = (double)0.0;\n      egeoq[5] = (double)0.0;\n      egeoq[6] = (double)0.0;\n    }\n  else\n    {\n      \n      /* Make unit tangent  */\n      \n      egeoq[2] = twds/tdum;\n      egeoq[3] = twdt/tdum;\n      \n      /* Make curvature vector */\n      \n      tdom     = egeoq[2]*twdds + egeoq[3]*twddt;\n      egeoq[4] = (twdds/tdum - egeoq[2]*tdom/tdum)/tdum;\n      egeoq[5] = (twddt/tdum - egeoq[3]*tdom/tdum)/tdum;\n    }\n  \n  /* Make radius of curvature in parameter plane 2 */\n  \n  tdum = s6length(egeoq+4,k2dim,&kstat);\n  if (DNEQUAL(tdum,(double)0.0))\n    {\n      egeoq[6] = (double)1.0/tdum;\n    }\n  else\n    {\n      egeoq[6] = (double)-1.0;\n    }\n  \n  /* Make 3-D radius of curvature */\n  \n  tdum = s6length(egeo3d+6,kdim,&kstat);\n  \n  if (DNEQUAL(tdum,(double)0.0))\n    {\n      egeo3d[9] = (double)1.0/tdum;\n    }\n  else\n    {\n      egeo3d[9] = (double)-1.0;\n      goto war101;\n    }\n  \n  \n  *jstat = 0;\n  goto out;\n  \n  /* Infinit radius of curvature */\n  \n war101: *jstat=1;\n  goto out;\n  \n out:\n  return;\n}\n                    \n"
  },
  {
    "path": "src/s1305.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1305.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1305\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1305(double epar1[],double epar2[],double eval1[],double eval2[],\n\t   int *jbound,double gpar[],int *jstat)\n#else\nvoid s1305(epar1,epar2,eval1,eval2,jbound,gpar,jstat)\n     double epar1[];\n     double epar2[];\n     double eval1[];\n     double eval2[];\n     int    *jbound;\n     double gpar[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To find if there is an intersection between epar1 and\n*              epar2 with the 2-D SISLbox desribed by eval1[0]:eval1[1]\n*              in the first parameter direction and eval2[0]:eval2[1]\n*              in the second parameter direction. If there is an\n*              intersection find the intersection closest to the point that is\n*              outside the area.\n*\n* INPUT      : epar1  - First parameter pair\n*              epar2  - Second parameter pair\n*              eval1  - Interval in first parameter direction\n*              eval2  - Interval in second parameter direction\n*\n*\n* OUTPUT     : gpar   - Parameter pair of intersection\n*              jbound - Indicator telling along which boundary\n*                       we have an intersection\n*                       = 0      :  no intersection\n*                       = 1      : intersection along u=eval1[0]\n*                       = 2      : intersection along v=eval2[1]\n*                       = 3      : intersection along u=eval1[1]\n*                       = 4      : intersection along v=eval2[0]\n*              jstat  - status messages  \n*                       = 0      : Line outside no intersection\n*                       = 1      : Line inside  no intersection\n*                       = 2      : epar2 outside, epar1 inside, step out\n*                       = 3      : epar1 outside, epar2 inside, step in\n*                       = 4      : epar2 outside, epar1 on boundary\n*                       < 0      : error         \n*\n*                                  \n* METHOD     : \n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 4-August-1988\n* Revised by : Tor Dokken, SI, Oslo, Norway, Mars-1989\n*              Improved clipping of long steps               \n* Revised by : UJK, SI, Oslo, Norway, Oct-1992\n*              Noise treatment.\n*********************************************************************\n*/\n{\n  int    kstat;          /* Local status variable                            */\n  int    kins1;          /* epar1 inside/outside SISLbox                         */\n  int    kins2;          /* epar2 inside/outside SISLbox                         */\n  double tdom;           /* Denominator of last intersection point           */\n  double tfak1,tfak2;    /* Distance to straight line                        */\n  double tcdist=HUGE;    /* Current distance                                 */\n  double tpdist=HUGE;    /* Previous distance                                */\n  double simpli[5];      /* Corners of the parameter area pu into the\n\t\t\t    implicit equation of the line through epar1 and\n\t\t\t    epar2.                                           */\n  double snorm[2];       /* Normal vector                                    */\n  double stemp[2];       /* Candidate point                                  */\n  double *outside=epar1; /* Pointer to the point that is outside;            */\n  *jbound = 0;\n  \n  /* Test if both ends are inside */\n  \n  kins1 = kins2 = 0; \n  \n  if (eval1[0] <= epar1[0] && epar1[0] <= eval1[1] &&\n      eval2[0] <= epar1[1] && epar1[1] <= eval2[1]) kins1 = 1;\n  \n  if( eval1[0] <= epar2[0] && epar2[0] <= eval1[1] &&\n     eval2[0] <= epar2[1] && epar2[1] <= eval2[1]) kins2 = 1;\n  \n  if (kins1==1 && kins2==1) goto war01;\n  \n  if (kins1) outside = epar2;\n  \n  /* Test if we step from the boundary and out */\n  \n  if ((eval1[0] == epar1[0] && epar2[0] < eval1[0]) ||\n      (epar1[0] == eval1[1] && eval1[1] < epar2[0]) ||\n      (eval2[0] == epar1[1] && epar2[1] < eval2[0]) ||\n      (epar1[1] == eval2[1] && eval2[1] < epar2[1])    ) goto war04;\n  \n  /* Test if both ends are to the left, right, below or above */\n  \n  if ( (epar1[0] < eval1[0] && epar2[0] < eval1[0]) ||\n      (eval1[1] < epar1[0] && eval1[1] < epar2[0]) ||\n      (epar1[1] < eval2[0] && epar2[1] < eval2[0]) ||\n      (eval2[1] < epar1[1] && eval2[1] < epar2[1])   ) goto war00;\n  \n  /* Make normal vector of line though epar1 and epar2 */\n  \n  snorm[0] = -(epar2[1] - epar1[1]);\n  snorm[1] =   epar2[0] - epar1[0];\n  \n  (void)s6norm(snorm,2,snorm,&kstat);\n  \n  /* Put corners of parameter area into the implicit equation of the straight\n     line */\n  \n  simpli[0] = (eval1[0]-epar1[0])*snorm[0] + (eval2[0]-epar1[1])*snorm[1];  \n  simpli[1] = (eval1[0]-epar1[0])*snorm[0] + (eval2[1]-epar1[1])*snorm[1];  \n  simpli[2] = (eval1[1]-epar1[0])*snorm[0] + (eval2[1]-epar1[1])*snorm[1];  \n  simpli[3] = (eval1[1]-epar1[0])*snorm[0] + (eval2[0]-epar1[1])*snorm[1];  \n  simpli[4] = simpli[0];\n  \n  /* If simpli[0:3] all have the same sign, the straight line is outside */\n  \n  if ((simpli[0]>(double)0.0 && simpli[1]>(double)0.0 && \n       simpli[2]>(double)0.0 && simpli[3]>(double)0.0) ||\n      (simpli[0]<(double)0.0 && simpli[1]<(double)0.0 && \n       simpli[2]<(double)0.0 && simpli[3]<(double)0.0)   ) goto war00;\n  \n  /* Treate intersections with left boundary */\n  \n  if (simpli[0]*simpli[1] <= (double)0.0 && epar1[0] != eval1[0])\n    {\n      /*  Intersection along left boundary */\n      \n      tfak1 = fabs(simpli[0]);\n      tfak2 = fabs(simpli[1]);\n      tdom  = tfak1 + tfak2;\n      \n      if (DNEQUAL(tdom,(double)0.0))\n        {\n\t  /* The straight line and the left boundary does not coinside */\n\t  \n\t  stemp[0] = eval1[0];\n\t  stemp[1] = (tfak2*eval2[0] + tfak1*eval2[1])/tdom;\n\t  tcdist   = s6dist(stemp, outside,2);\n\t  if (*jbound == 0 || tcdist < tpdist)\n            {\n\t      /* New point closer than previous intersection point */\n\t      \n\t      gpar[0] = stemp[0];\n\t      gpar[1] = stemp[1];\n\t      *jbound  = 1;\n\t      tpdist  = tcdist;\n            }\n        }\n    }\n  \n  /* Treate intersections with upper boundary */                       \n  \n  if (simpli[1]*simpli[2] <= (double)0.0 && epar1[1] != eval2[1])\n    {\n      /* Intersection along upper boundary */\n      \n      tfak1 = fabs(simpli[1]);\n      tfak2 = fabs(simpli[2]);\n      tdom  = tfak1 + tfak2;\n      if (DNEQUAL(tdom,(double)0.0))\n        {\n\t  /* The straight line and the upper boundary does not coinside */\n\t  \n\t  stemp[0] = (tfak2*eval1[0] + tfak1*eval1[1])/tdom;\n\t  stemp[1] = eval2[1];\n\t  tcdist   = s6dist(stemp, outside,2);\n\t  \n\t  if (*jbound == 0 || tcdist < tpdist)\n            {\n\t      /* New point closer than previous intersection point */   \n\t      \n\t      gpar[0] = stemp[0];\n\t      gpar[1] = stemp[1];\n\t      *jbound  = 2;\n\t      tpdist  = tcdist;\n            }\n        }\n    }\n  \n  /* Treate intersections with right boundary */\n  \n  if (simpli[2]*simpli[3] <= (double)0.0 && epar1[0] != eval1[1])\n    {\n      /* Intersection along right boundary */\n      \n      tfak1 = fabs(simpli[2]);\n      tfak2 = fabs(simpli[3]);\n      tdom  = tfak1 + tfak2;\n      if (DNEQUAL(tdom,(double)0.0))\n        {\n\t  /* The straight line and the right boundary does not coinside */\n\t  \n\t  stemp[0] = eval1[1];\n\t  stemp[1] = (tfak2*eval2[1] + tfak1*eval2[0])/tdom;\n\t  tcdist   = s6dist(stemp, outside,2);\n\t  \n\t  if (*jbound == 0 || tcdist < tpdist)\n            {\n\t      /* New point closer than previous intersection point */\n\t      \n\t      gpar[0] = stemp[0];\n\t      gpar[1] = stemp[1];\n\t      *jbound  = 3;\n\t      tpdist  = tcdist;\n            }\n        }\n    }\n  \n  /* Treate intersections with lower boundary */\n  \n  if (simpli[3]*simpli[4] <= (double)0.0 && epar1[1] != eval2[0])\n    {\n      /* Intersection along lower boundary */\n      \n      tfak1 = fabs(simpli[3]);\n      tfak2 = fabs(simpli[4]);\n      tdom  = tfak1 + tfak2;\n      if (DNEQUAL(tdom,(double)0.0))\n        {\n\t  /* The straight line and the lower boundary does not coinside */\n\t  \n\t  stemp[0] = (tfak2*eval1[1] + tfak1*eval1[0])/tdom;\n\t  stemp[1] = eval2[0];\n\t  tcdist   = s6dist(stemp, outside,2);\n\t  \n\t  if (*jbound == 0 || tcdist < tpdist)\n            {\n\t      /* New point closer than previous intersection point */   \n\t      \n\t      gpar[0] = stemp[0];\n\t      gpar[1] = stemp[1];\n\t      *jbound = 4;\n\t      tpdist  = tcdist;\n            }\n        }\n    }\n  \n  if (kins1 == 1)\n    goto war02; \n  \n  if (kins2 == 1 || *jbound != 0) goto war03; \n  \n  goto war05;\n  \n  /* Line outside */\n  \n war00:\n  *jstat = 0;\n  goto out;                                                                      \n  \n  /* Line inside */                          \n  \n war01:\n  *jstat = 1;\n  goto out;\n  \n  /* epar1 inside epar2 outside */\n war02:\n  *jstat = 2;\n  goto out;\n  \n  /* epar2 inside epar1 outside */\n war03:\n  *jstat = 3;\n  goto out;\n  \n  /* epar1 on boundary, epar2 outside */\n war04:\n  *jstat = 4;\n  goto out;\n  \n  /* Special error */\n war05:\n  *jstat = 5;\n  goto out;\n  \n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1306.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1306.c,v 1.2 2001-03-19 15:58:43 afr Exp $\n *\n */\n\n\n#define S1306\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1306(double ep[],double eparp[],double eimpli[],int ideg,\n\t   double egeo3d[],double egeop[],int *jstat)\n#else\nvoid s1306(ep,eparp,eimpli,ideg,egeo3d,egeop,jstat)\n     double ep[];\n     double eparp[];\n     double eimpli[];\n     int    ideg;\n     double egeo3d[];\n     double egeop[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate the radius of curvature at the intersection\n*              point between a B-spline surface and an implicit represented\n*              surface. The first and second derivatives\n*              of the intersection point in the B-spline surface are give as\n*              input. All coordinates are assumed to be in 3-D.\n*\n*\n*\n* INPUT      : ep     - 0-2 order derivatives of B-spline surface.\n*                       For ideg=1,2 and 1001 the sequence is position,\n*                       first derivative in first parameter direction,\n*                       first derivative in second parameter direction,\n*                       (2,0) derivative, (1,1) derivative, (0,2) derivative\n*                       and normal. (21 numbers)\n*                       For ideg=1003,1004,1005 the second derivatives are followed\n*                       by the third derivatives and the normal (33 numbers)\n*                       Compatible with output of s1421\n*              eparp  - Parameter pair in B-spline surface of point\n*              eimpli - Description of the implicit surface\n*              ideg   - The degree of the implicit surface\n*                        ideg=1:    Plane              \n*                        ideg=2;    Quadric surface\n*                        ideg=1001: Torus surface\n*                        ideg=1003: Silhouette line parallel projection\n*                        ideg=1004: Silhouette line perspective projection\n*                        ideg=1005: Silhouette line circular projection\n*\n*\n* OUTPUT     : \n*              jstat  - status messages\n*                         = 11     : Fuzzy singular intersection point found\n*                         = 10     : Singular intersection point found\n*                         = 2      : Singular intersection point found\n*                         = 1      : Curvature radius infinit\n*                         = 0      : ok, curvature radius\n*                         < 0      : error\n*              egeo3d - 3-D geometry description of the intersection. The\n*                       array contains: position, unit tangent, curvature\n*                       and radius of curvature. (A total of 10 numbers)\n*                       A radius of curvature =-1, indicates that the radius\n*                       of curvature is infinit.\n*              egeop  - Description of the intersection in the parameter plane\n*                       of the B-spline surface. The array contains: position,\n*                       unit tangent, curvature and radius of curvature.\n*                       (A total of 7 numbers)\n*\n* METHOD     : We put the parametric surface into the implicit equation\n*              and get a function f(s,t)=0. By assuming that u and v are\n*              function s of a variable u we get:\n*\n*                f(s(u),y(u)) = 0\n*\n*              By making the derivative with respect to u we get:\n*\n*                f s  + f t  = 0\n*                 s u    t u    \n*\n*              By assuming that u=s or u=t, we get one derivative equal\n*              to 1, and the other can be calculated. By taking one more\n*              derivative with respect to u we get:\n*\n*                    2                           2\n*                f  s  + 2 f  s t  + f s   + f  t  + f t   = 0.\n*                 ss u      st u u    s uu    tt u    t uu\n*\n*              Since s=u or t=u we know that one of the double derivatives\n*              is zero and the other can be caluclated.\n*\n*              Based on these derivatives in the parameter plane the\n*              derivatives of the intersection curve with respect to u can\n*              be calculated, and futher on the actual curvature of the\n*              intersection curve at the input point.\n*\n*              In the case that both f = 0 and f = 0 the second equation\n*                                     s         t\n*              can be used for calculating s  and t\n*                                           u      u.\n*\n* USE:         This function is only working in 3-D\n*\n* REFERENCES : \n*-\n* CALLS      : s6scpr,fabs,s1307,s6err\n*              \n*\n* WRITTEN BY : Tor Dokken, SI, Oslo , Norway, 30 May 1988\n* Revised by : Tor Dokken, SI, Oslo, March 1989.\n*              Initiating tangent etc. to 0 when singular point found\n* Revised by : Mike Floater, SI, 1991-01\n*                   Add perspective and circular silhouettes (ideg=1004,ideg=1005)\n*\n*********************************************************************\n*/\n{\n  int fuzzy_sing = FALSE;\n  int sing = FALSE;\n  int kstat = 0;          /* Local status variable                       */\n  int ki,kj,kl;           /* Control variables in loop                   */\n  int kpos = 0;           /* Position of error                           */\n  int ksize;              /* Number of doubles for storage of derivateves\n\t\t\t     and normal vector */      \n  int ksizem3;            /* ksize - 3                                   */\n  double *sps;            /* Pointer to dP/ds                            */\n  double *spt;            /* Pointer to dP/dt                            */\n  double *spss;           /* Pointer to ddP/(dsds)                       */\n  double *spst;           /* Pointer to ddP/(dsdt)                       */\n  double *sptt;           /* Pointer to ddP/(dtdt)                       */\n  double tfs,tft,tfss;    /* Derivatives of parametric surface put into  */\n  double tfst,tftt;       /* the implicit equation                       */\n  double tsu,ttu,tsuu,ttuu;/* Derivatives of parameter direction         */\n  double sder[6];         /* Derivatives of parametric surface           */\n  double snorm[3];        /* Normal vector of implicit surface at ep     */\n  double sp[9];           /* Points, first and second deriv. of intcur   */\n  \n  \n  /* If ideg=1,2 or 1001 then only derivatives up to second order\n     are calculated, then 18 doubles for derivatives and 3 for the\n     normal vector are to be used for calculation of points in the\n     spline surface. For ideg=1003,1004,1005 we have a silhouette curve and\n     derivatives up to the third are to be calculated,\n     thus 30 +3 a total of 33 doubles are to be calculated */\n  \n  if (ideg==1003 || ideg==1004 || ideg==1005)\n    {\n      ksize = 33;\n    }\n  else\n    {\n      ksize = 21;\n    }\n  ksizem3 = ksize -3;\n  \n  /* Calculated derivatives of the parametric surface put into the implicit\n     surface at the point ep */\n  \n  s1331(ep,eimpli,ideg,2,sder,snorm,&kstat);\n  if (kstat<0) goto error;\n  \n  tfs  = sder[1];\n  tft  = sder[2];\n  tfss = sder[3];\n  tfst = sder[4];\n  tftt = sder[5];\n  \n  \n  /* Calculate ds/du and dt/du */\n  /* UJK, aug.92 */\n  \n  /* if (DEQUAL(tfs,(double)0.0) && \n      DEQUAL(tft,(double)0.0) ) */\n\n  /* UJK, 13.08.93, save suzzy singular information. */\n  if (fabs(tfs) < 0.000001 && \n      fabs(tft) < 0.000001) fuzzy_sing = TRUE;\n  else\n     fuzzy_sing = FALSE;\n  \n  if (DEQUAL((double)1.0 + tfs,(double)1.0) && \n      DEQUAL((double)1.0 + tft,(double)1.0) )\n    {\n      double tdum1,tdum2,tafss,tafst,taftt;\n      \n      /* Singular point found, copy position and derivative value of input to\n\t output, if not second order derivatives uniqely describes a tangent*/\n      \n      memcopy(egeo3d,ep,3,DOUBLE);\n      memcopy(egeop,eparp,2,DOUBLE);\n      \n      tafss = fabs(tfss);\n      tafst = fabs(tfst);\n      taftt = fabs(tftt);\n      \n      tdum1 = tfst*tfst - tfss*tftt;\n      tdum2 = MAX(tafss,taftt);\n      tdum2 = MAX(tafst,tdum2);\n      \n      for (ki=3 ; ki<10 ; ki++) egeo3d[ki] = DZERO;\n      for (ki=2 ; ki<7  ; ki++) egeop[ki]  = DZERO;\n      \n      if (DEQUAL(tdum2+tdum1,tdum2) &&\n\t  (DNEQUAL(tafss+tafst,tafst) || DNEQUAL(taftt+tafst,tafst)) )\n        {\n\t  /* A unique tangent can be calculated */\n\t  \n\t  if (tafss>taftt)\n            {\n\t      tsu = -tfst/tfss;\n\t      ttu = 1;\n            }\n\t  else\n            {\n\t      tsu = 1;\n\t      ttu = -tfst/tftt;\n            }\n\t  tsuu = 0.0;\n\t  ttuu = 0.0;\n\t  /* Flag singular case */\n\t  sing = TRUE;\n\t}\n      else\n        {\n\t  /* A tangent can not be calulated */\n\t  goto war02;\n        }\n    }\n  else\n    {\n      /* A noneisngular point found */\n      if (fabs(tfs) > fabs(tft))\n\t{\n\t  /*  Use u=t */\n\t  \n\t  tsu = -tft/tfs;\n\t  ttu = (double)1.0;   \n\t  \n\t  tsuu = -(tfss*tsu*tsu + (double)2.0*tfst*tsu*ttu + tftt*ttu*ttu)/tfs;\n\t  ttuu = (double)0.0;\n\t}\n      else\n\t{ \n\t  /*  Use u=t */\n\t  \n\t  tsu = (double)1.0;\n\t  ttu = -tfs/tft;  \n\t  \n\t  tsuu = (double)0.0;\n\t  ttuu = -(tfss*tsu*tsu + (double)2.0*tfst*tsu*ttu + tftt*ttu*ttu)/tft;\n\t}\n    }\n  \n  /* The calculation of the derivatives of one parameter direction with\n     respect to the other is dependent on the degree of the implicit equation*/\n  \n  /* Set local pointers */\n  \n  sps = ep + 3;\n  spt = ep + 6;\n  spss = ep + 9;\n  spst = ep + 12;\n  sptt = ep + 15;\n  \n  /* Make description of intersection point in 3-D including\n     curvature and radius of curvature, first make description of\n     intersection point in parameter plane */\n  \n  /* We will now express the intersection curve locally as a function\n   *  of a w-parameter.                                              \n   *\n   *  c(w) = p(s(w),t(w))\n   *\n   *  This gives the derivative\n   *                         \n   *   \n   *  c' = P s' + P t'                                                      \n   *        s      t\n   *\n   *  And the second derivative\n   *\n   *            2                   2\n   *  c\" = P  s'  + 2P  s't' + P  t' + P s\" + P t\"\n   *        ss        st        tt      s      t  \n   */\n  \n  for (ki=0,kj=3,kl=6 ; ki<3 ; ki++,kj++,kl++)\n    {\n      \n      /*  Copy position */\n      \n      sp[ki] = ep[ki];\n      \n      /*  Make tangent  */\n      \n      sp[kj] = sps[ki]*tsu + spt[ki]*ttu;\n      \n      /*  Make curvature */\n      \n      sp[kl] = spss[ki]*tsu*tsu + (double)2.0*spst[ki]*tsu*ttu + \n\tsptt[ki]*ttu*ttu + sps[ki]*tsuu + spt[ki]*ttuu;\n    }\n  \n  /* Make 3-D curvature and radius of curvature */\n  \n  s1307(sp,3,egeo3d,&kstat);\n  if (kstat < 0 )goto error;\n  \n  /* Make description of intersection point in parameter plane including\n     curvature and radius of curvature, first make description of\n     intersection point in parameter plane */\n  \n  sp[0] = eparp[0];\n  sp[1] = eparp[1];\n  sp[2] = tsu;\n  sp[3] = ttu;\n  sp[4] = tsuu;\n  sp[5] = ttuu;\n  \n  s1307(sp,2,egeop,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Everyting is ok */\n  \n  *jstat = 0;\n  goto out;\n  \n  \n  /* SISLPoint lying on torus axis */\n  \n war02: *jstat=2;\n  goto out;\n  \n  /* Error in lower level function */\n error:\n  *jstat = kstat;\n  s6err(\"s1306\",*jstat,kpos);\n  goto out;\n  \n out: \n    if (sing && *jstat>=0) *jstat = 10;\n    else if (fuzzy_sing && *jstat>=0) *jstat = 11;\n  return;\n}\n"
  },
  {
    "path": "src/s1307.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1307.c,v 1.2 2001-03-19 15:58:43 afr Exp $\n *\n */\n#define S1307\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1307(double ep[],int idim,double egeo[],int *jstat)\n#else\nvoid s1307(ep,idim,egeo,jstat)\n     double ep[];\n     int    idim;\n     double egeo[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate the unit tangent,curvature and radius of\n*              curvature of a curve at a point.\n*\n* INPUT      : ep     - Position, first and second derivative of the\n*                       curve with respect to some parametrization \n*                       at the point. (3*idim doubles)\n*              idim   - Dimension of the space the curve lies in\n*\n*\n* OUTPUT     : \n*              jstat  - status messages  \n*                         = 1      : Curvature radius infinit\n*                         = 0      : ok, curvature radius\n*                         < 0      : error\n*              egeo   - 3-D geometry description of the intersection. The\n*                       array contains: position, unit tangent, curvature\n*                       and radius of curvature. (A total of 3*idim + 1\n*                       doubles). A radius of curvature =-1, indicates\n*                       that the radius of curvature is infinit.\n*\n* METHOD     : We convert the description of the derivatives to an\n*              arc length parametrization. In this parametrization\n*              the second derivative is the same as the curvature vector.\n*              The radius of curvature is the invers of the length of this\n*              curvature vector.\n*\n* REFERENCES : \n*-\n* CALLS      : s6scp,s6norm,s6length\n*              \n*\n* WRITTEN BY : Tor Dokken, SI, Oslo , Norway, 3 July 1988\n* Revised by : Tor Dokken, SI, Oslo , Norway, March 1989\n*              Corrected use of maximal radius of curvature.\n*\n*********************************************************************\n*/\n{\n  int k2dim=2*idim;   /* The dimension *2, Start of double derivative*/\n  int kstat;          /* Local status variable                       */\n  int ki,kj;          /* Variables in loop                           */\n  double tlength;     /* Length of first derivative vector           */\n  double tdum;        /* Dummy variable                              */\n  \n  /* Let c = c(w) be a parameterized curve.\n   *  The curvature vector is defined as the derivative of the unit tangent\n   *  vector with respect to the arc length a. If we don't have an arclength\n   *  parametrization then this parametrization can be written as a function\n   *  of the arc length w = w(a). By using the kernel rule for differentiation\n   *  we get:\n   *\n   *         d            d       dw   d    c'(w)    dw   d    c'(w)      da\n   *  k(a) = -- T(w(a)) = -- T(w) -- = -- ---------- -- = -- ---------- / --\n   *         da           dw      da   dw sqrt(c'c') da   dw sqrt(c'c')   dw\n   *\n   *\n   *         d       c'(w)                c\"        c' (c'c'')\n   *         -- ----------------- =   ---------- - ------------- \n   *         dw sqrt(c'(w) c'(w))     sqrt(c'c')   sqrt(c'c')**3\n   *\n   *\n   *\n   *         da\n   *         -- = sqrt(c'c')\n   *         dw \n   */\n  \n  /* Copy position */\n  \n  memcopy(egeo,ep,idim,DOUBLE);\n  \n  /* First we normalize the tangent vector */\n  \n  tlength = s6norm(ep+idim,idim,egeo+idim,&kstat);\n  \n  if (DEQUAL(tlength,(double)0.0)) goto war101;\n  \n  /* Make curvature vector */\n  \n  tdum = s6scpr(ep+k2dim,egeo+idim,idim)/tlength;\n  \n  for (ki=idim,kj=k2dim;ki<k2dim;ki++,kj++)\n    {\n      egeo[kj] = (ep[kj]/tlength - egeo[ki]*tdum)/tlength;\n    }\n  \n  /* Make radius of curvature */\n  \n  tdum = s6length(egeo+k2dim,idim,&kstat);\n  \n  if (tdum!=DZERO && ((double)1.0/tdum) > MAXIMAL_RADIUS_OF_CURVATURE) \n    goto war101;\n  \n  if (DNEQUAL(tdum,(double)0.0))\n    {\n      egeo[3*idim] = (double)1.0/tdum;\n    }\n  else\n    {\n      goto war101;\n    }\n  \n  /* Everyting is ok */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Infinit radius of curvature */\n  \n war101: *jstat=1;\n  egeo[3*idim] = (double)-1.0;\n  goto out;\n  \n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1308.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1308.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1308\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1308(double ep[],int idim,double eimpli[],int ideg,double enorm[],int *jstat)\n#else\nvoid s1308(ep,idim,eimpli,ideg,enorm,jstat)\n     double ep[];\n     int    idim;\n     double eimpli[];\n     int    ideg;\n     double enorm[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate the normal vector at point in an implicit\n*              function.\n*\n* INPUT      : ep     - The coordinates of the point\n*              idim   - The dimension of the space\n*              eimpli - Description of the implicit surface\n*              ideg   - The degree of the implicit surface\n*                        ideg=1: Plane\n*                        ideg=2; Quadric surface\n*              \n*\n* OUTPUT:      enorm  - The normal vector\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : For degree=1 the 3 first component of eimpli is the\n*              normal vector. For ideg=2:                     T\n*              The surface can be represented as  (X ,1)A(X,1) where A is\n*              a matrix (idim+1xidim+1) representing eimpli, and X a point.\n*              Assume that X is parameterized with respect to some parameters\n*              X = X(s,...). If we take the derivative of X with respect\n*              to s, we get a tangent in the surface.\n*\n*              dX/ds A X = 0. Thus the expression AX is a normal to\n*              the implicit function. The idim first components of \n*              AX is the acutal normal\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : \n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 3. July 1988\n*\n*********************************************************************\n*/\n{            \n  int ki,kj,kl;       /* Variables in loop                           */\n  int kdimp1=idim+1;  /* Dimension + 1                               */\n  int kpos=0;         /* Position of error                           */\n  int kstat=0;        /* Local error                                 */\n  double tsum;        /* Dummy variable                              */\n  \n  if (ideg != 1 && ideg !=2 && ideg != 1001) goto err175; \n  \n  if (ideg == 1)\n    {\n      /*  First degree implicit surface normal vector is eimpli[0:idim-1] */\n      memcopy(enorm,eimpli,idim,DOUBLE);\n    }\n  else if (ideg==2)\n    {\n      \n      /* Calculate the matrix product */\n      \n      for (ki=0;ki<idim;ki++)\n        {\n\t  tsum = eimpli[idim*kdimp1+ki];\n\t  for (kj=0,kl=ki ; kj<idim ; kj++,kl+=kdimp1)\n            {\n\t      tsum +=(eimpli[kl]*ep[kj]);\n            }\n\t  enorm[ki] = tsum;\n        }\n    }\n  else if (ideg==1001)\n    {  \n      /*  Torus surface */\n      \n      double *scentr;  /* The center of the torus */\n      double *snorm;   /* The normal of the torus symmetry plane */\n      double tbigr;    /* The big radius of the torus */ \n      double tsmalr;   /* The small radius of the torus */\n      double sdum1[3]; /* Temporary storage for point */\n      double sdum2[3]; /* Temporary storage for point */\n      double tproj;    /* Projection of vector onto snorm */\n      \n      \n      scentr = eimpli;\n      snorm  = eimpli+3;\n      tbigr  = *(eimpli+6);\n      tsmalr = *(eimpli+7);\n      \n      /*  Find projection of vector from torus center on to torus axis */\n      s6diff(ep,scentr,3,sdum1);\n      tproj = s6scpr(sdum1,snorm,3);\n      \n      /*  Project vector from torus center to ep onto torus plane */\n      for (ki=0;ki<3;ki++)\n        sdum2[ki] = sdum1[ki] - tproj*snorm[ki];\n      (void)s6norm(sdum2,3,sdum2,&kstat);\n      if (kstat<0) goto error;\n      \n      /*  Find vector from torus circle to ep */\n      for (ki=0;ki<3;ki++)\n        sdum1[ki] = sdum1[ki] - tbigr*sdum2[ki];\n      \n      /*  Normalize this vector */\n      (void)s6norm(sdum1,3,enorm,&kstat);\n      if (kstat<0) goto error;\n    }\n  \n  *jstat = 0;\n  goto out;\n  \n  /* IDEG NOT 1 OR 2 */\n err175:\n  *jstat = -175;\n  s6err(\"s1308\",*jstat,kpos);\n  goto out;\n  \n  \n  /* Error in lower leve function */\n error:\n  *jstat = kstat;\n  s6err(\"s1308\",*jstat,kpos);\n  goto out;\n  \n out:\n  return;\n}\n                                                                              \n"
  },
  {
    "path": "src/s1309.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1309.c,v 1.3 2001-03-19 15:58:43 afr Exp $\n *\n */\n#define S1309\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\ndouble\ns1309(double epnt[],double edir[],double eimpli[],int ideg,int *jstat)\n#else\ndouble s1309(epnt,edir,eimpli,ideg,jstat)\n     double epnt[];\n     double edir[];\n     double eimpli[];\n     int    ideg;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To find the shortest distance between a point and the\n*              projection of the point along a direction vector on to\n*              an implicit represented surface. The distance will\n*              have a sign, positive if the projection is along the\n*              direction of the direction vector, else it is negative.\n*              For torus surfaces the projection direction is not\n*              used: The closest point is calculated and the distance to\n*              this returned.\n*              If ideg==1003,1004,1005, the the difference between PI/2 and the\n*              angle between the two vectors which whose scalar product\n*              wants to be as close as possible to zero, is found.\n*\n* INPUT      : epnt   - The point to be projected\n*              edir   - Projection direction. Not used if ideg==1003,1004,1005\n*              eimpli - Description of implicit surface\n*              ideg   - Degree of implicit surface\n*                        ideg=1:    Plane\n*                        ideg=2;    Quadric surface\n*                        ideg=1001: Torus surface\n*                        ideg=1003: Silhouette line parallel projection\n*                        ideg=1004: Silhouette line perspective projection\n*                        ideg=1005: Silhouette line circular projection\n*\n*\n* OUTPUT     : s1309  - The distance, positive if along positive direction\n*                       of edir, negative if along negative direction of\n*                       edir.\n*                       If ideg==1003,1004,1005, the the difference between PI/2 and the\n*                       angle between the two vectors which whose scalar product\n*                       wants to be as close as possible to zero, is found (in radians).\n*              jstat  - status messages\n*                       = 0      : ok, iteration converged\n*                       < 0      : error\n*\n*\n* METHOD     :\n*\n* USE        : The function can be used for preparing the calculation\n*              of the projected point by adding the product of the distance\n*              and the normalized versions of edir to epnt.\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 4-July-1988\n* Revised by : Mike Floater, SI, 1991-01\n*              Improved the routine for parallel silhouettes (ideg=1003) and\n*              added perspective and circular silhouettes (ideg=1004,ideg=1005)\n* Changed by : Per OEyvind Hvidsten, SINTEF, 11-94.\n*              Added initialization of tcurdst in declaration.\n*\n*********************************************************************\n*/\n{\n  double sdir[3];         /* Normilized direction vector          */\n  double tb1=0.0,ta11=0.0,ta12=0.0;   /* Dummy variables          */\n  double tsum,t1,t2,tdum1;/* Dummy variables                      */\n  double tcurdst=0.0;     /* The distance                         */\n  double sq[4];           /* Array used for temporary results     */\n  int ksize;              /* Number of doubles for storage of derivatives\n\t\t\t     and normal vector */\n  int ksizem3;            /* ksize - 3                                      */\n  int    kstat;           /* Local status variable                */\n  int    kdim=3;          /* Dimesnon of 3-D space                */\n  int    ki,kj,kl,kp;     /* Control variables in loop            */\n  int    kpos=1;          /* Position of error                    */\n\n\n\n  /* If ideg=1,2 or 1001 then only derivatives up to second order\n     are calculated, then 18 doubles for derivatives and 3 for the\n     normal vector are to be used for calculation of points in the\n     spline surface. For ideg=1003,1004,1005 we have a silhouette curve and\n     derivatives up to the third are to be calculated,\n     thus 30 +3 a total of 33 doubles are to be calculated */\n\n  if (ideg==1003 || ideg==1004 || ideg==1005)\n    {\n      ksize = 33;\n    }\n  else\n    {\n      ksize = 21;\n    }\n\n  ksizem3 = ksize -3;\n  (void)s6norm(edir,kdim,sdir,&kstat);\n  if (kstat < 0) goto error;\n\n  if (ideg==1)\n    {\n      /* Put parametric representation of projection line into\n\t implicit equation of plane */\n      tb1  = s6scpr(eimpli,epnt,kdim);\n      ta11 = s6scpr(eimpli,sdir,kdim);\n      if( ta11 == (double)0.0) goto war02;\n      tcurdst = -(eimpli[3]+tb1)/ta11;\n    }\n  else if (ideg==2)\n    {\n\n      /*  Find distance from the new point to the implicit surface, by\n\t  intersecting  the straight line throught the point and with\n\t  sdir as normalized direction vector, normalized version of 3\n\t  first coordinates of sq the implicit surface and P0 = (P,1).\n\n\t  This problem can be written:\n\n\t  T                T    2                    T\n\t  P0 A P0  + 2 t P0 A sdir  + t  (sdir,0) A (sdir,0)  = 0\n\n\t  T\n\t  We have to calulate calculate  tb1=P0 A P  and qs=P0 A, thus:\n\t  T    2                    T\n\t  tb1 + 2 t sq sdir  + t  (sdir,0) A (sdir,0)  = 0\n\n\t  Thus the first step is to calculate qs = A (P,1)\n\t  */\n      for (ki=0;ki<4;ki++)\n        {\n\t  tsum = eimpli[12+ki];\n\t  for (kj=0,kl=ki ; kj<3 ; kj++,kl+=4)\n            {\n\t      tsum +=(eimpli[kl]*epnt[kj]);\n            }\n\t  sq[ki] = tsum;\n        }\n\n      tb1  = s6scpr(epnt,sq,kdim) + sq[3];\n\n      ta11 = (double)2.0*s6scpr(sq,sdir,kdim);\n\n      ta12 = (double)0.0;\n      for (ki=0,kl=0;ki<3;ki++,kl+=4)\n        {\n\t  kp = kl;\n\t  for (kj=0;kj<3;kj++,kp++)\n            {\n\t      ta12 += sdir[ki]*eimpli[kp]*sdir[kj];\n            }\n        }\n\n      /*  Now our equation system is:\n\t  2\n\t  ta12 t  + ta11 t + tb1 = 0\n\n\t  we want the root with the smallest absolute value:\n\t  2\n\t  t = (-ta11 +/- sqrt(ta11 -4ta12 tb1))/(2ta12)\n\t  */\n      if (DNEQUAL(ta12,(double)0.0))\n        {\n\t  tdum1 = ta11*ta11 - (double)4.0*ta12*tb1;\n\t  if (tdum1 < DZERO) goto war02;\n\t  tdum1 = sqrt(tdum1);\n\t  t1 = (-ta11 + tdum1)/((double)2.0*ta12);\n\t  t2 = (-ta11 - tdum1)/((double)2.0*ta12);\n\t  if (fabs(t1)<fabs(t2))\n            {\n\t      tcurdst = t1;\n            }\n\t  else\n            {\n\t      tcurdst = t2;\n            }\n        }\n      else if(DNEQUAL(ta11,(double)0.0))\n        {\n\t  tcurdst = tb1/ta11;\n        }\n      else\n        {\n\t  /*      Unsolvable system */\n\t  goto war02;\n        }\n    }\n  else if (ideg==1001)\n    {\n      /*  Torus surface */\n\n      double *scentr;  /* The center of the torus */\n      double *snorm;   /* The normal of the torus symmetry plane */\n      double tbigr;    /* The big radius of the torus */\n      double tsmalr;   /* The small radius of the torus */\n      double sdum1[3]; /* Temporary storage for point */\n      double sdum2[3]; /* Temporary storage for point */\n      double tproj;    /* Projection of vector onto snorm */\n\n\n      scentr = eimpli;\n      snorm  = eimpli+3;\n      tbigr  = *(eimpli+6);\n      tsmalr = *(eimpli+7);\n\n      /*  Find projection of vector from torus center on to torus axis */\n      s6diff(epnt,scentr,kdim,sdum1);\n      tproj = s6scpr(sdum1,snorm,kdim);\n\n      /*  Project vector from torus center to epnt onto torus plane */\n      for (ki=0;ki<kdim;ki++)\n        sdum2[ki] = sdum1[ki] - tproj*snorm[ki];\n      (void)s6norm(sdum2,kdim,sdum2,&kstat);\n      if (kstat<0) goto error;\n\n      /*  Find vector from torus circle to epnt */\n      for (ki=0;ki<kdim;ki++)\n        sdum1[ki] = sdum1[ki] - tbigr*sdum2[ki];\n\n      /*  Find length of this vector and compare with tsmalr */\n\n      tcurdst = fabs(s6length(sdum1,kdim,&kstat)-tsmalr);\n      if (kstat<0) goto error;\n    }\n  else if (ideg==1003)\n    {\n      /*  Silhouette line/curve */\n\n      double sdum1[3]; /* Temporary storage for point */\n\n      (void)s6norm(epnt+ksizem3,kdim,sdum1,&kstat);\n      if (kstat<0) goto error;\n\n      /*  eimpli[0,1,2] is assumed to, be normalized */\n\n      t1 = s6scpr(sdum1,eimpli,kdim);\n\n      /*  t1 now contains the cosine of the angle between the view direction\n\t  and the normal vector. This is Equal to sin of PI/2 minus the angle\n\t  between the vectors, thus the actual angle can be calulated */\n\n      tcurdst = asin(t1);\n      tcurdst = fabs(tcurdst);\n    }\n\n  else if (ideg==1004)\n    {\n      /*  Perspective silhouette line/curve */\n\n      double sdum1[3],sdum2[3]; /* Temporary storage for point */\n\n      s6diff(epnt,eimpli,kdim,sdum1);\n      (void)s6norm(sdum1,kdim,sdum2,&kstat);\n      /* OK if sdum1 is zero -- tcurdst will be zero as well  */\n      (void)s6norm(epnt+ksizem3,kdim,sdum1,&kstat);\n\n\n      t1 = s6scpr(sdum1,sdum2,kdim);\n\n      /*  t1 now contains the cosine of the angle between the direction of the\n          point epnt relative to the eyepoint E (in eimpli)\n\t  and the normal vector. This is Equal to sin of PI/2 minus the angle\n\t  between the vectors, thus the actual angle can be calulated */\n\n      tcurdst = asin(t1);\n      tcurdst = fabs(tcurdst);\n    }\n\n  else if (ideg==1005)\n    {\n      /*  Circular silhouette line/curve */\n\n      double sdum1[3],sdum2[3]; /* Temporary storage for point */\n      double *bvec=eimpli+3;\n\n      s6diff(epnt,eimpli,kdim,sdum1);\n      s6crss(epnt+ksizem3,sdum1,sdum2);\n      (void)s6norm(sdum2,kdim,sdum1,&kstat);\n      /* OK if sdum2 is zero -- tcurdst will be zero as well  */\n\n      /*  bvec  = eimpli[3,4,5] is assumed to, be normalized */\n\n      t1 = s6scpr(sdum1,bvec,kdim);\n\n      /*  t1 now contains the cosine of the angle between\n          (the cross product of the normal vector and the direction of the\n          point epnt relative to the point Q (in eimpli))\n\t  and the direction vector B. This is Equal to sin of PI/2 minus the angle\n\t  between the vectors, thus the actual angle can be calulated */\n\n      tcurdst = asin(t1);\n      tcurdst = fabs(tcurdst);\n    }\n\n  *jstat = 0;\n  goto out;\n\n  /* Projection not possible */\n war02: *jstat = 2;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n  s6err(\"s1309\",*jstat,kpos);\n  goto out;\n\n out:\n  return(tcurdst);\n}\n"
  },
  {
    "path": "src/s1310.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1310.c,v 1.8 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1310\n\n#include \"sislP.h\"\n/*\n * Forward declarations.\n * ---------------------\n */\n#if defined(SISLNEEDPROTOTYPES)\nstatic  void s1310_s9constline(SISLSurf *,SISLSurf *,SISLIntcurve *,\n                               double,int,int,int *);\n#else\nstatic  void s1310_s9constline();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1310(SISLSurf *psurf1,SISLSurf *psurf2,SISLIntcurve *pinter,\n      double aepsge,double amax,int icur,int igraph,int *jstat)\n#else\n  void s1310(psurf1,psurf2,pinter,aepsge,amax,icur,igraph,jstat)\n     SISLSurf     *psurf1;\n     SISLSurf     *psurf2;\n     SISLIntcurve *pinter;\n     double   aepsge;\n     double   amax;\n     int      icur;\n     int      igraph;\n     int      *jstat;\n#endif\n     /*\n\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To march an intersection curve between two B-splines\n*              surfaces. The intersection curve is described by guide\n*              parameter pairs in an intersection curve object.\n*\n*\n*\n* INPUT      : psurf1 - Pointer to first surface\n*              psurf2 - Pointer to second surface\n*              pinter - Pointer to intersection curve.\n*                       The guide parameter pairs refered by the object are\n*                       used for guiding the marching.\n*              aepsge - Absolute tolerance\n*              amax   - Not used.\n*              icur   - Indicator telling if a 3-D curve is to be made\n*                        0 - Don't make 3-D curve\n*                        1 - Make 3-D curve\n*                        2 - Make 3-D curve and curves in parameter plane\n*              igraph - Indicator telling if the curve is to be outputted\n*                       through function calls:\n*                        0 - don't output curve through function call\n*                        1 - output as straight line segments through s1line\n*\n*\n*\n* OUTPUT     : pinter - Pointer to intersection curve. The routine\n*                       adds intersection curve and curve in the parameter\n*                       planes to the SISLIntcurve object according to the\n*                       values of i3Dcur and iplane\n*                       If these curves have already been generated in the\n*                       topology part of the intersections, they will first\n*                       be free'ed.  This makes it possible to generate\n*                       curves for both parameter planes if required.\n*                       The geometry will have been generated in the case when\n*                       the intersection curve represents a constant parameter\n*                       line in the parmeter plane of the surface.\n\n*              jstat  - status messages\n*                         = 3      : Iteration stopped due to singular\n*                                    point or degenerate surface. A part\n*                                    of intersection curve may have been\n*                                    traced out. If no curve is traced out\n*                                    the curve pointers in the Intcurve\n*                                    object point to SISL_NULL.\n*                         = 0      : ok\n*                         < 0      : error\n*                         = -185   : No points produced on intersection curve.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 30 june 1988\n* Revised by : Tor Dokken, SI, Oslo, Norway, 24-feb-1989\n*              Handles degenerate points\n* Revised by : Tor Dokken, SI, Oslo, Norway, 03-April-1988\n*              Maximal step length calculation, new strategy around\n*              singular points, error correction\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Dec. 1994.  Added check for\n*              SISL_NULL 'pinter' and to avoid re-generating the geometry when it has\n*              already been generated in the topology part (constant curve, type 9).\n*              This fixes memory problems.\n*\n*********************************************************************\n*/\n{\n  int ki,kj,kl;            /* Control variables in for loops            */\n  int kcont;               /* Stop condition for loop                   */\n  int kk,kn;               /* Dummy variables                           */\n  int kstpch;              /* Status of iteration step                  */\n  int kpoint;              /* Number of points in guide curve           */\n  int kpar1;               /* Number of parameter direction in 1st. obj */\n  int kpar2;               /* Number of parameter direction in 2nd. obj */\n  int kpar;                /* Indicater tellin if s1359 shall make\n\t\t\t      parametrization or use parametrization\n\t\t\t      in spar                                   */\n  int ktype;               /* Type of intersection curve                */\n  int klfu=0;              /* Pointers into knot vectors                */\n  int klfv=0;              /* Pointers into knot vectors                */\n  int klfs=0;              /* Pointers into knot vectors                */\n  int klft=0;              /* Pointers into knot vectors                */\n  int kder = 2;            /* Calculate up to second derivatives        */\n  int kdim = 3;            /* The dimension of the space we work in     */\n  int kfirst = 0;          /* Indicator telling if first guide point\n\t\t\t      degenerate */\n  int klast = 0;           /* Indicator telling if last guide point\n\t\t\t      degenerate */\n  int kpos = 0;            /* Position of error                         */\n  int kstat,kstat1;        /* Status variable returned form routine     */\n  int kmaxinf=0;           /* Number of entries object that can be stored\n\t\t\t      in s3dinf, sp1inf, sp2inf                 */\n  int knbinf=0;            /* Number of entries stored so far on s3dinf,\n\t\t\t      sp1inf and sp2inf                         */\n  int kstart;              /* Start point for iteration among guide pnts*/\n  int kguide;              /* Current guide point                       */\n  int kdir;                /* March direction                           */\n  int kgdir;               /* Direction we march guide point vector     */\n  int krem,krem1,krem2;    /* REmember status of boundary crossing      */\n  int kbound;              /* Whci boundary is crossed                  */\n  int koutside_resolution; /* Flag telling if current seg. outside res. */\n  int kdiv=0;              /* Flag telling if iteration diverged        */\n  double tlnorm=DZERO;     /* Length of normal vector                   */\n  double tltan1=DZERO;     /* Length of tangents                        */\n  double tltan2=DZERO;     /* Length of tangents                        */\n  double tang1,tang2;      /* Angles                                    */\n  double tdang1,tdang2,tdang3,tdang4;   /* Angles between intersection\n\t\t\t\t\t   curve tangent and partial derivative */\n  double tdminang;         /* Minimum angle between intersection point on \n\t\t\t      boundary and boundary tangent             */\n  double *sdminang=SISL_NULL;  /* Remember minimum angles               */\n  int knb1=0;              /* Remember number of points after marching\n\t\t\t      in first marching direction               */\n  int kgd1=0;              /* Remeber last guide point used in first\n\t\t\t      marching direction                        */\n  double *scorpnt=SISL_NULL;    /* Corrected marching points                 */\n  double *scorpr1=SISL_NULL;    /* Corrected marching parameter values in ps1*/\n  double *scorpr2=SISL_NULL;    /* Corrected marching parameter values in ps2*/\n  double smidd[6];         /* Description of midpoint and tangent of\n\t\t\t      current Bezier segment                    */\n  double tcurstep;         /* Current step length                       */\n  double tdist;            /* Error at middle of current Bezier segement*/\n  double tang;             /* Angle error at midpoint Bezier segement   */\n  double tnew;             /* Candidate for new step length             */\n  double tfak;             /* How much is the step length to be reduced */\n  double *start;           /* Pointer to start of current segment       */\n  double *st;              /* Pointer to knot vector                    */\n  double tstep;            /* Iteration step length                     */\n  double tmax;             /* Local maximal step length                 */\n  double tstartstp;        /* Start step length                         */\n  double trad;             /* Radius of curvature                       */\n  double spar1[2];         /* Parameter pair of current point surface 1 */\n  double spar2[2];         /* Parameter pair of current point surface 2 */\n  double sparmid1[2];      /* Parameter values at middle of Bezier segm */\n  double sparmid2[2];      /* Parameter values at middle of Bezier segm */\n  double sipar1[2];        /* Parameter pair iteration point surface  1 */\n  double sipar2[2];        /* Parameter pair iteration point surface 2  */\n  double simiddpnt[10];    /* Middle point and tangent of segment       */\n  double simiddpar1[7];    /* Parameter value at middle point of segment*/\n  double simiddpar2[7];    /* Parameter value at middle point of segment*/\n  double startg[3];        /* Tangent of start point of iteration       */\n  double *sgpar1=SISL_NULL;     /* Parameter pairs of guide point in surf 1  */\n  double *sgpar2=SISL_NULL;     /* Parameter pairs of guide point in surf 2  */\n  double *sgpara=SISL_NULL;     /* Parameter pairs of guide point in surf 1  */\n  double *sgparb=SISL_NULL;     /* Parameter pairs of guide point in surf 2  */\n  double *sgd1 = SISL_NULL;     /* 0-2 derivative of guide point + normal\n\t\t\t\t   of first object                           */\n  double *sgd2 = SISL_NULL;     /* 0-2 derivative of guide point + normal\n\t\t\t\t   of second object                          */\n  double spnt1[21];        /* Info on current point in first surface    */\n  double spnt2[21];        /* Info on current point in second surface   */\n  double sipnt1[21];       /* Info on iteration point in first surface  */\n  double sipnt2[21];       /* Info on iteration point in second surface */\n                           /* For spnt1, spnt2, sipnt1, sipnt2,         */\n                           /* the information is stored 3-tuppels       */\n                           /* in the following sequence                 */\n                           /* Position, (1,0)-der, (0,1)-der,           */\n                           /* (2,0)-der, (1,1)-der (0,2)-der and normal */\n                           /* This is compatible with output of s1421   */\n  double spntend1[21];     /* End values of candidate end point in surf1*/\n  double spntend2[21];     /* End values of candidate end point in surf1*/\n  double sparend1[2];      /* Parameter value at candidate end point    */\n  double sparend2[2];      /* Parameter value at candidate end point    */\n  double *snxt1;           /* SISLPoint in psurf1 we have accepted          */\n  double *snxt2;           /* SISLPoint in psurf2 we have accepted          */\n  double *snxp1;           /* Parameter value belonging to snxt1        */\n  double *snxp2;           /* Parameter value belonging to snxt2        */\n  double *s3dinf=SISL_NULL;     /* Pointer to array used for storing 3-D position\n\t\t\t\t   tangent, curvature and radius of curvature found\n\t\t\t\t   during the marching process */\n  double *sp1inf=SISL_NULL;     /* Pointer to array used for storing position\n\t\t\t\t   tangent, curvature and radius of curvature found\n\t\t\t\t   in the first parameter plane during the\n\t\t\t\t   marching process */\n  double *sp2inf=SISL_NULL;     /* Pointer to array used for storing position\n\t\t\t\t   tangent, curvature and radius of curvature found\n\t\t\t\t   in the first parameter plane during the\n\t\t\t\t   marching process */\n  double *spar=SISL_NULL;       /* Parametrization of points                 */\n  double sval1[2];         /* Limits of parameter plane in first SISLdir    */\n  double sval2[2];         /* Limits of parameter plane in second SISLdir   */\n  double sval3[2];         /* Limits of parameter plane in third SISLdir    */\n  double sval4[2];         /* Limits of parameter plane in fourth SISLdir   */\n  double tref1,tref2;      /* Reference values for knot vectors         */\n  double tref3,tref4;      /* Reference values for knot vectors         */\n  double start1[21];       /* Description of start point in psurf1      */\n  double start2[21];       /* Description of start point in psurf1      */\n  double stpar1[2];        /* Parameter pair belonging to start1        */\n  double stpar2[2];        /* Parameter pair belonging to start2        */\n  double sdum1[3],sdum2[3];/* Dummy vectors                             */\n  double tdum,tdump1,tdump2;/*Dummy variable                            */\n  double *sp1=SISL_NULL;        /* Pointer used when moving information      */\n  double *sp2=SISL_NULL;        /* Pointer used when moving information      */\n  double stdum[10];        /* Dummy array used when moving information  */\n  double *stang;           /* Pointer to tangent of current point       */\n  double *stangp1;         /* Pointer to tangent of current point in pp1*/\n  double *stangp2;         /* Pointer to tangent of current point in pp2*/\n  double *spoint;          /* Pointer to current point                  */\n  double t1distgd,t2distgd;/* Distances to guide points                 */\n  SISLCurve *q3dcur=SISL_NULL;/* Pointer to 3-D curve                     */\n  SISLCurve *qp1cur=SISL_NULL;/* Pointer to curve in first parameter plane*/\n  SISLCurve *qp2cur=SISL_NULL;/* Pointer to curve in 2.nd  parameter plane*/\n  double aepsge2 = aepsge;    /* Local tolerance                          */\n\n  *jstat = 0;\n\n  if ( pinter == SISL_NULL )  \n    goto err150;\n\n\n  /* Check if the geometry already has been generated in the topology part.\n     This will be the case if the geometry is along a constant parameter line.\n     Freeing the geometry her makes it possible to generate curves for both\n     parameter planes if required (the pointers will be set to SISL_NULL further\n     down, i.e. would cause a memory leak if they weren't free'ed here. */\n\n  if (pinter->itype == 9)\n    {\n      if (pinter->pgeom)  freeCurve(pinter->pgeom);\n      if (pinter->ppar1)  freeCurve(pinter->ppar1);\n      if (pinter->ppar2)  freeCurve(pinter->ppar2);\n    }\n\n\n  /* Make maximal step length based on box-size of surface */\n\n  sh1992su(psurf1,0,aepsge,&kstat);\n  if (kstat < 0) \n    goto error;\n\n  tmax = MAX(psurf1->pbox->e2max[0][0] - psurf1->pbox->e2min[0][0],\n\t     psurf1->pbox->e2max[0][1] - psurf1->pbox->e2min[0][1]);\n  tmax = MAX(tmax,psurf1->pbox->e2max[0][2] - psurf1->pbox->e2min[0][2]);\n\n  sh1992su(psurf2,0,aepsge,&kstat);\n  if (kstat < 0) \n    goto error;\n\n  tmax = MAX(tmax,psurf2->pbox->e2max[0][0] - psurf2->pbox->e2min[0][0]);\n  tmax = MAX(tmax,psurf2->pbox->e2max[0][1] - psurf2->pbox->e2min[0][1]);\n  tmax = MAX(tmax,psurf2->pbox->e2max[0][2] - psurf2->pbox->e2min[0][2]);\n\n  if (amax>DZERO) \n    tmax = MIN(tmax,amax);\n\n  /* Find a none singular start point for the marching process */\n\n  kpoint = pinter->ipoint;\n  kpar1  = pinter->ipar1;\n  kpar2  = pinter->ipar2;\n  sgpara = pinter->epar1;\n  sgparb = pinter->epar2;\n  ktype  = pinter->itype;\n\n\n  /* To support closed curve the first guide point must be copied after\n     the last guide point */\n\n  if((sgpar1=newarray(2*kpoint+2,DOUBLE)) == SISL_NULL) goto err101;\n  if((sgpar2=newarray(2*kpoint+2,DOUBLE)) == SISL_NULL) goto err101;\n  memcopy(sgpar1,sgpara,2*kpoint,DOUBLE);\n  memcopy(sgpar2,sgparb,2*kpoint,DOUBLE);\n\n  if (ktype ==2 || ktype == 3)\n    {\n      /*Closed curve copy first guide point to end of string of guide points */\n      memcopy(sgpar1+2*kpoint,sgpara,2,DOUBLE);\n      memcopy(sgpar2+2*kpoint,sgparb,2,DOUBLE);\n      kpoint = kpoint + 1;\n    }\n\n  /* Initiate pointers to intersection curve and intersection curve in\n     parameter plane */\n\n  pinter -> pgeom = SISL_NULL;\n  pinter -> ppar1 = SISL_NULL;\n  pinter -> ppar2 = SISL_NULL;\n\n  /* Initiate parameter direction boundaries */\n\n  kk    = psurf1 -> ik1;\n  kn    = psurf1 -> in1;\n  st    = psurf1 -> et1;\n  sval1[0] = st[kk-1];\n  sval1[1] = st[kn];\n  tref1 = (double)3.0*MAX(fabs(*sval1),fabs(*(sval1+1)));\n  kk    = psurf1 -> ik2;\n  kn    = psurf1 -> in2;\n  st    = psurf1 -> et2;\n  sval2[0] = st[kk-1];\n  sval2[1] = st[kn];\n  tref2 = (double)3.0*MAX(fabs(*sval2),fabs(*(sval2+1)));\n  kk    = psurf2 -> ik1;\n  kn    = psurf2 -> in1;\n  st    = psurf2 -> et1;\n  sval3[0] = st[kk-1];\n  sval3[1] = st[kn];\n  tref3 = (double)3.0*MAX(fabs(*sval3),fabs(*(sval3+1)));\n  kk    = psurf2 -> ik2;\n  kn    = psurf2 -> in2;\n  st    = psurf2 -> et2;\n  sval4[0] = st[kk-1];\n  sval4[1] = st[kn];\n  tref4 = (double)3.0*MAX(fabs(*sval4),fabs(*(sval4+1)));\n\n\n\n  /* Test the both objects have 2 parameter directions */\n\n  if (kpar1 != 2 || kpar2 != 2) \n    goto err123;\n\n  /*THE POINTS , TANGENT, CURVATURE AND RADIUS OF CURVATURE FOUND DURING\n    THE MARCHING PROCESS SHOULD ALL BE STORED IN ARRAYS. ALLOCATE ONE ARRAY\n    FOR 3-D INFORMATION , ONE ARRAY FOR INFORMATION IN FIRST PARAMETER PLANE\n    AND ONE ARRAY FOR INFORMATION IN SECOND PARAMETER PLANE. THESE ARRAYS\n    ARE GIVEN AN INITIAL CAPACITY OF STORING 100 POINTS WITH OTHER INFORMATION.\n    IF THEY ARE TO SHORT THEY WILL BE REALLOCATED AT A LATER STAGE.\n\n    SINCE THE STEPPING WILL GO IN BOTH DIRECTIONS WE WILL HAVE TO TURN THE\n    INFORMATION FOUND WHEN MARCHING IN NEGATIVE DIRECTION, SO THAT IT CAN\n    BE COMBINED WITH THE INFORMATION FOUND WHEN WE ARE MARCHING IN POSITVE\n    DIRECTION.\n  */\n\n  kmaxinf = 100;\n  s3dinf = newarray(10*kmaxinf,DOUBLE);\n  if (s3dinf == SISL_NULL) goto err101;\n  sp1inf = newarray(7*kmaxinf,DOUBLE);\n  if (sp1inf == SISL_NULL) goto err101;\n  sp2inf = newarray(7*kmaxinf,DOUBLE);\n  if (sp2inf == SISL_NULL) goto err101;\n\n\n\n  /* Evaluate 0-1-2nd. derivative + normal of all guide points in both\n     surfaces, first allocate arrays for storing the information */\n\n  sgd1 = newarray(21*kpoint,DOUBLE);\n  if (sgd1==SISL_NULL) goto err101;\n  sgd2 = newarray(21*kpoint,DOUBLE);\n  if (sgd2==SISL_NULL) goto err101;\n\n  sdminang = newarray(kpoint,DOUBLE);\n  if (sdminang==SISL_NULL) \n    goto err101;\n\n   kpos = 5;\n\n  /* Initiate kstart to point at no point */\n\n  kstart = 0;\n\n  for (ki=0,kj=0,kl=0 ; ki<kpoint ; ki++,kj+=2,kl+=21)\n    {\n      s1421(psurf1,kder,&sgpar1[kj],&klfu,&klfv,&sgd1[kl],&sgd1[kl+18],&kstat);\n      if (kstat<0) goto error;\n\n      /*  Find length of normal vector and tangent vectors */\n\n      tlnorm = s6length(&sgd1[kl+18],kdim,&kstat);\n      tltan1 = s6length(&sgd1[kl+ 3],kdim,&kstat);\n      tltan2 = s6length(&sgd1[kl+ 6],kdim,&kstat);\n\n      /* The cross product satisifes the following conditions:\n\t length(axb) = length(a) length(b) sin(angle(a,b)).\n\t Thus the angle between the two vectors can be found, close to 0\n\t sin(a) is a good approximation of a */\n\n      if (tlnorm == DZERO || tltan1 ==DZERO || tltan2 == DZERO)\n        tang1 = DZERO;\n      else\n        tang1 = tlnorm/(tltan1*tltan2);\n\n      s1421(psurf2,kder,&sgpar2[kj],&klfs,&klft,&sgd2[kl],&sgd2[kl+18],&kstat);\n      if (kstat<0) goto error;\n\n      /*  Find length of normal vector and tangent vectors */\n\n      tlnorm = s6length(&sgd2[kl+18],kdim,&kstat);\n      tltan1 = s6length(&sgd2[kl+ 3],kdim,&kstat);\n      tltan2 = s6length(&sgd2[kl+ 6],kdim,&kstat);\n\n      /*  The cross product satisifes the follwing conditions:\n\t  length(axb) = length(a) length(b) sin(angle(a,b)).\n\t  Thus the angle between the two vectors can be found, close to 0\n\t  sin(a) is a good approximation of a */\n\n      if (tlnorm == DZERO || tltan1 ==DZERO || tltan2 == DZERO)\n        tang2 = DZERO;\n      else\n        tang2 = tlnorm/(tltan1*tltan2);\n\n\n      if (tang1 >= ANGULAR_TOLERANCE && tang2 >= ANGULAR_TOLERANCE)\n        {\n\t  /* Make tangent of intersection curve */\n\n\t  s6crss(&sgd1[kl+18],&sgd2[kl+18],sdum1);\n\n\t  tlnorm = s6length(sdum1,kdim,&kstat);\n\n\t  /* Compute angle between tangent and partial derivatives */\n\t  tdang1 = s6ang(sdum1, sgd1+kl+3, kdim);\n\t  tdang2 = s6ang(sdum1, sgd1+kl+6, kdim);\n\t  tdang3 = s6ang(sdum1, sgd2+kl+3, kdim);\n\t  tdang4 = s6ang(sdum1, sgd2+kl+6, kdim);\n\t  tdminang = HUGE;\n\t  if (sgpar1[kj] == sval1[0] || sgpar1[kj] == sval1[1])\n\t    tdminang = min(tdminang, tdang2);\n\t  if (sgpar1[kj+1] == sval2[0] || sgpar1[kj+1] == sval2[1])\n\t    tdminang = min(tdminang, tdang1);\n\t  if (sgpar2[kj] == sval3[0] || sgpar2[kj] == sval3[1])\n\t    tdminang = min(tdminang, tdang4);\n\t  if (sgpar2[kj+1] == sval4[0] || sval4[1])\n\t    tdminang = min(tdminang, tdang2);\n\t  sdminang[ki] = (tlnorm != DZERO) ? tdminang : 0.0;\n\n\t  /* Remember if start, internal or end point */\n\n\t  if (tlnorm != DZERO)\n\t    {\n\t      if (ki == 0)\n\t\tkfirst = 1;\n\t      else if (ki == kpoint-1)\n\t\tklast = kpoint;\n\t      else\n\t\tkstart = ki+1;\n\t    }\n        }\n    }\n\n  /* If necessary, modify start point to avoid an intersection curve that \n     is tangential to the boundary of a surface */\n  if (kpoint > 2 && kstart > 0 && sdminang[kstart-1] < 5.0*ANGULAR_TOLERANCE)\n    {\n      /* Check internal points */\n      for (ki=kfirst; ki<klast-1; ++ki)\n\t{\n\t  if (sdminang[ki] >= 5.0*ANGULAR_TOLERANCE)\n\t    {\n\t      kstart = ki+1;\n\t      break;\n\t    }\n\t}\n\n      if (sdminang[kstart-1] < 5.0*ANGULAR_TOLERANCE)\n\t{\n\t  /* Check endpoints */\n\t  if (sdminang[kfirst-1] >= 5.0*ANGULAR_TOLERANCE)\n\t    kstart = kfirst;\n\t  else if (sdminang[klast-1] >= 5.0*ANGULAR_TOLERANCE)\n\t    kstart = klast;\n\t  else\n\t    {\n\t      /* Maximalize the minimum angle */\n\t      kstart = kfirst;\n\t      for (ki=kfirst; ki<klast; ++ki)\n\t\tif (sdminang[ki] > sdminang[kstart-1])\n\t\t  kstart = ki + 1;\n\t    }\n\t}\n    }\n\n  /* Check if only degenerate points or singularities exist on the\n     intersection curve */\n\n  if (kstart == 0)\n    {\n      /*  No internal nondegenerate point exits, start marching from first\n\t  or last point if possible */\n\n      if (kfirst != 0 && ktype != 5 && ktype != 7) kstart = kfirst;\n      else if (klast != 0 && ktype != 6 &&\n\t       ktype != 7 && ktype != 3) kstart = klast;\n      else if (kfirst != 0) kstart = kfirst;\n      else if (klast != 0) kstart = klast;\n      else goto interpolate;\n    }\n\n\n  /* To speed up the marching process when many guide points are given,\n     remove guide points that are not at the start, end or the start point */\n\n  if (kpoint >2 && (kstart==1 || kstart==kpoint) )\n    {\n      /*  No internal guide point necessary, copy last point to second point */\n      memcopy(sgd1+21,sgd1+21*(kpoint-1),21,DOUBLE);\n      memcopy(sgpar1+2,sgpar1+2*(kpoint-1),2,DOUBLE);\n      memcopy(sgd2+21,sgd2+21*(kpoint-1),21,DOUBLE);\n      memcopy(sgpar2+2,sgpar2+2*(kpoint-1),2,DOUBLE);\n\n      if (kstart ==  kpoint) kstart = 2;\n      kpoint = 2;\n    }\n  else if (kpoint>2)\n    {\n      /*  Internal guide point exists, copy this to second position and\n\t  copy end point to third position */\n\n      /* memcopy(sgd1+21,sgd1+21*(kstart-1),21,DOUBLE); */\n      /* memcopy(sgpar1+2,sgpar1+2*(kstart-1),2,DOUBLE); */\n      /* memcopy(sgd2+21,sgd2+21*(kstart-1),21,DOUBLE); */\n      /* memcopy(sgpar2+2,sgpar2+2*(kstart-1),2,DOUBLE); */\n\n      /* memcopy(sgd1+2*21,sgd1+21*(kpoint-1),21,DOUBLE); */\n      /* memcopy(sgpar1+4,sgpar1+2*(kpoint-1),2,DOUBLE); */\n      /* memcopy(sgd2+2*21,sgd2+21*(kpoint-1),21,DOUBLE); */\n      /* memcopy(sgpar2+4,sgpar2+2*(kpoint-1),2,DOUBLE); */\n\n      memmove(sgd1+21,sgd1+21*(kstart-1),21*sizeof(double));\n      memmove(sgpar1+2,sgpar1+2*(kstart-1),2*sizeof(double));\n      memmove(sgd2+21,sgd2+21*(kstart-1),21*sizeof(double));\n      memmove(sgpar2+2,sgpar2+2*(kstart-1),2*sizeof(double));\n\n      memmove(sgd1+2*21,sgd1+21*(kpoint-1),21*sizeof(double));\n      memmove(sgpar1+4,sgpar1+2*(kpoint-1),2*sizeof(double));\n      memmove(sgd2+2*21,sgd2+21*(kpoint-1),21*sizeof(double));\n      memmove(sgpar2+4,sgpar2+2*(kpoint-1),2*sizeof(double));\n\n      kpoint = 3;\n      kstart = 2;\n    }\n\n  /* Remember description of start point in both surfaces,\n     copy point indicated by kstart into spnt1,spnt2,spar1,spar2 */\n\n  memcopy(spnt1,sgd1+21*(kstart-1),21,DOUBLE);\n  memcopy(spnt2,sgd2+21*(kstart-1),21,DOUBLE);\n  memcopy(spar1,sgpar1+2*(kstart-1),2,DOUBLE);\n  memcopy(spar2,sgpar2+2*(kstart-1),2,DOUBLE);\n\n  /* Make position, unit tangent, curvature and radius of curvature for\n     start point of iteration, store them in the arrays just allocated */\n\n  kpos = 10;\n  s1304(spnt1,spnt2,spar1,spar2,s3dinf,sp1inf,sp2inf,&kstat);\n\n  if (kstat<0) \n    goto error;\n\n  /* Remember start tangent */\n\n  memcopy(startg,s3dinf+3,3,DOUBLE);\n\n\n  /* Iterate intersection point down to the intersection curve */\n\n  tstep = DZERO;\n  s9iterate(s3dinf,spnt1,spnt2,spar1,spar2,psurf1,psurf2,tstep,\n\t    aepsge,sipnt1,sipnt2,sipar1,sipar2,&kstat);\n  if (kstat < 0) \n    goto error;\n\n  /* VSK 0417. Check if the intersection point is still inside the surface\n     parameter domains. */\n  if (sipar1[0] < sval1[0] || sipar1[0] > sval1[1] ||\n      sipar1[1] < sval2[0] || sipar1[1] > sval2[1] ||\n      sipar2[0] < sval3[0] || sipar2[0] > sval3[1] ||\n      sipar2[1] < sval4[0] || sipar2[1] > sval4[1])\n    {\n      kstat = 3;  /* Do not use iterated point */\n      aepsge2 = max(aepsge2,\n\t\t    max(s6dist(spnt1,sipnt1,3), s6dist(spnt2,sipnt2,3)));\n    }\n\n  /* Copy result of iteration into spnt1,spnt2,spar1,spar2 */\n\n\n  if (kstat==0 &&\n      (s6dist(spnt1,sipnt1,3) > aepsge || s6dist(spnt2,sipnt2,3) > aepsge))\n    {\n      /*  Copy result of iteration of convergence to no singular point */\n\n      memcopy(spnt1,sipnt1,21,DOUBLE);\n      memcopy(spnt2,sipnt2,21,DOUBLE);\n      memcopy(spar1,sipar1,2,DOUBLE);\n      memcopy(spar2,sipar2,2,DOUBLE);\n    }\n\n  if (kstat==0)\n    {\n      memcopy(start1,sipnt1,21,DOUBLE);\n      memcopy(start2,sipnt2,21,DOUBLE);\n      memcopy(stpar1,sipar1,2,DOUBLE);\n      memcopy(stpar2,sipar2,2,DOUBLE);\n    }\n  else\n    {\n      memcopy(start1,spnt1,21,DOUBLE);\n      memcopy(start2,spnt2,21,DOUBLE);\n      memcopy(stpar1,spar1,2,DOUBLE);\n      memcopy(stpar2,spar2,2,DOUBLE);\n    }\n\n  /* Make position, unit tangent, curvature and radius of curvature for\n     start point of iteration, store them in the arrays just allocated */\n\n  kpos = 10;\n  s1304(start1,start2,stpar1,stpar2,s3dinf,sp1inf,sp2inf,&kstat);\n\n  if (kstat<0) \n    goto error;\n\n  /* Test if singular point reached */\n\n  if (kstat == 2) \n    goto war03;\n\n  /* Remember that start point is already stored */\n\n  knbinf = 1;\n\n  /* Make step length based on 3-D radius of curvature, tolerances and\n     maks step length */\n\n  kpos = 20;\n  tstep = s1311(s3dinf[9],aepsge,tmax,&kstat);\n  if (kstat<0) \n    goto error;\n  tstartstp = tstep;\n\n  /* STEP IN BOTH DIRECTIONS FROM THE FOUND START POINT */\n\n  /* Indicate that direction in guide point array not determined */\n\n  kguide = kstart;\n  kgdir = 0;\n\n  for (kdir=1;kdir<3;kdir++)\n    {\n\n      if (kdir == 2)\n        {\n\t  /* Remember result of marching in first direction */\n\n\t  knb1 = knbinf;\n\t  kgd1 = kguide;\n\n\t  /* If the previous step direction made no points then knbinf==0. To\n\t     enable the marching we start from the same start point as the\n\t     previous step direction, thus in this case knbinf should be 1. */\n\n\t  knbinf = MAX(1,knbinf);\n\n\t  /* We now step in the second step direction. Turn the sequence of\n\t     the points found as well as change tangent directions */\n\n\t  /* First interchange 3-D info */\n\n\t  for (sp1=s3dinf,sp2=s3dinf+10*(knbinf-1) ; sp1<sp2 ; sp1+=10,sp2-=10)\n            {\n\t      memcopy(stdum,sp1,  10,DOUBLE);\n\t      memcopy(sp1  ,sp2,  10,DOUBLE);\n\t      memcopy(sp2  ,stdum,10,DOUBLE);\n            }\n\n\t  for (sp1=s3dinf+3;sp1<s3dinf+10*knbinf;sp1+=10)\n            {\n\t      sp1[0] = - sp1[0];\n\t      sp1[1] = - sp1[1];\n\t      sp1[2] = - sp1[2];\n            }\n\n\t  /* Then interchange info in first parameter plane */\n\n\t  for (sp1=sp1inf,sp2=sp1inf+7*(knbinf-1) ; sp1<sp2 ; sp1+=7,sp2-=7)\n            {\n\t      memcopy(stdum,sp1  ,7,DOUBLE);\n\t      memcopy(sp1  ,sp2  ,7,DOUBLE);\n\t      memcopy(sp2  ,stdum,7,DOUBLE);\n            }\n\n\t  for (sp1=sp1inf+2;sp1<sp1inf+7*knbinf;sp1+=7)\n            {\n\t      sp1[0] = - sp1[0];\n\t      sp1[1] = - sp1[1];\n\t      sp1[2] = - sp1[2];\n            }\n\n\t  /* Then interchange info in second parameter plane */\n\n\t  for (sp1=sp2inf,sp2=sp2inf+7*(knbinf-1) ; sp1<sp2 ; sp1+=7,sp2-=7)\n            {\n\t      memcopy(stdum,sp1  ,7,DOUBLE);\n\t      memcopy(sp1  ,sp2  ,7,DOUBLE);\n\t      memcopy(sp2  ,stdum,7,DOUBLE);\n            }\n\n\t  for (sp1=sp2inf+2;sp1<sp2inf+7*knbinf;sp1+=7)\n            {\n\t      sp1[0] = - sp1[0];\n\t      sp1[1] = - sp1[1];\n\t      sp1[2] = - sp1[2];\n            }\n\n\t  /* Turn direction of remembered start tangent */\n\n\t  for (ki=0;ki<3;ki++)\n\t    startg[ki] = -startg[ki];\n\n\n\t  /* Update spnt1, spnt2, spar1 and spar2 to\n\t     have the start point values */\n\n\t  memcopy(spnt1,start1,21,DOUBLE);\n\t  memcopy(spnt2,start2,21,DOUBLE);\n\t  memcopy(spar1,stpar1,2,DOUBLE);\n\t  memcopy(spar2,stpar2,2,DOUBLE);\n\n\t  /* Turn the direction we march the guide point vector,\n\t     and set current guide point to kstart */\n\n\t  kgdir  = -kgdir;\n\t  kguide = kstart;\n\n\t  /* Update step length */\n\n\t  tstep = tstartstp;\n        }\n\n      kpos = 30;\n\n      /* Step direction ok, perform marching until stop condition reached */\n\n      kcont = 1;\n\n      while (kcont)\n        {\n\n\n\t  /* We must make sure that we are not stepping past a guide point.\n\t   * Thus if we get close to a guide point, make sure that we step\n\t   * through this. The direction we travers the guide point array\n\t   * might not have been determined yet. Thus we have to test in\n\t   * both directions in guide point array.\n\t   *\n\t   * Remember how we step in the varaible kstpch:\n\t   *       kstpch = -1 : Try to step to previous guide point\n\t   *       kstpch =  0 : Try not to step through guide point\n\t   *       kstpch =  1 : Try to step to next guide point\n\t   *       kstpch =  3 : Step to start point and stop marching\n\t   *       kstpch =  4 : Don't step through guide point, candidate\n\t   *                     end point of segement found in iteration loop\n\t   */\n\n\n\t  kstpch = 0;\n\t  stang = s3dinf + 10*(knbinf-1) + 3;\n\t  stangp1 = sp1inf + 7*(knbinf-1) + 2;\n\t  stangp2 = sp2inf + 7*(knbinf-1) + 2;\n\n\t  if (kgdir >=0)\n            {\n\n\t      /* We are stepping in positive direction in guide point vector\n\t       * calculate distance to next guide point. If the guide point\n\t       * is lying closer than the step length to the current point\n\t       * we should step directly to this point provided that the cross\n\t       * product of the normal vectors at current point and at the\n\t       * guide point have the same direction, e.g. that their scalar\n\t       * product is positiv\n\t       */\n\n\t      t1distgd = (double)2.0*tstep;\n\t      if (kguide < kpoint)\n                {\n\t\t  /* Decide if we should step through the guide point */\n\n\t\t  kpos = 40;\n\t\t  t1distgd = s9adstep(spnt1,spar1,spnt2,spar2,&sgd1[kguide*21],\n\t\t\t\t      &sgpar1[kguide*2],&sgd2[kguide*21],\n\t\t\t\t      &sgpar2[kguide*2],stang,\n\t\t\t\t      stangp1,stangp2,tstep,&kstat);\n\t\t  if (kstat<0) \n\t\t    goto error;\n\t\t  if (kstat == 1)\n                    {\n\t\t      /* Step through guide point remember this */\n\n\t\t      kstpch = 1;\n\t\t      snxt1 = sgd1 + 21*kguide;\n\t\t      snxt2 = sgd2 + 21*kguide;\n\t\t      snxp1 = sgpar1 + 2*kguide;\n\t\t      snxp2 = sgpar2 + 2*kguide;\n                      tstep = MIN(tstep,t1distgd);\n\t\t    }\n                }\n            }\n\n\t  if (kgdir <=0)\n            {\n\n\t      /* We are stepping in negative direction in guide point vector\n\t       * calculate distance to previous guide point. If the guide point\n\t       * is lying closer than the step length to the current point\n\t       * we should step directly to this point provided that the cross\n\t       * product of the normal vectors at current point and at the\n\t       * guide point have the same direction, e.g. that their scalar\n\t       * product is positiv\n\t       */\n\n\t      if (1 < kguide)\n                {\n\t\t  /* Decide if we should step through the guide point */\n\n\t\t  kpos = 50;\n\t\t  t2distgd = s9adstep(spnt1,spar1,spnt2,spar2,\n\t\t\t\t      &sgd1[(kguide-2)*21],&sgpar1[(kguide-2)*2],\n\t\t\t\t      &sgd2[(kguide-2)*21],&sgpar2[(kguide-2)*2],\n\t\t\t\t      stang,stangp1,stangp2,tstep,&kstat);\n\n\t\t  if (kstat<0) \n\t\t    goto error;\n\t\t  if ((kstat == 1 &&kstpch == 0) ||\n\t\t      (kstat == 1 && kstpch == 1 && t2distgd < t1distgd))\n                    {\n\t\t      /* Step through guide point remember this */\n\n\t\t      kstpch = -1;\n\t\t      snxt1 = sgd1 + 21*(kguide-2);\n\t\t      snxt2 = sgd2 + 21*(kguide-2);\n\t\t      snxp1 = sgpar1 + 2*(kguide-2);\n\t\t      snxp2 = sgpar2 + 2*(kguide-2);\n                      tstep = MIN(tstep,t2distgd);\n                    }\n                }\n            }\n\n\t  /* Check if we step through the start point, should only be necessary\n\t     if at least 3 points found in this marching direction */\n\n\t  if ((kdir==1 && knbinf>3) || (kdir==2 && knbinf>knb1+2))\n            {\n\t      kpos = 60;\n\t      tdum = s9adstep(spnt1,spar1,spnt2,spar2,start1,stpar1,start2,\n\t\t\t      stpar2,stang,stangp1,stangp2,tstep,&kstat);\n\t      if (kstat<0) \n\t\tgoto error;\n\t      if (kstat == 1)\n\t\t{\n\t\t  /* Step to start point remember this */\n\n\t\t  kstpch = 3;\n\t\t  snxt1 = start1;\n\t\t  snxt2 = start2;\n\t\t  snxp1 = stpar1;\n\t\t  snxp2 = stpar2;\n                  tstep = MIN(tstep,tdum);\n\n\t\t}\n\t    }\n\n\t  /* At this stage kstpch=0 if we have not reached a guide point or\n\t     if we have not reached the start point of the iteration.\n\n\t     Now we want to find a Bezier segement that is lying within the\n\t     geometric tolerance that is approximating the intersection curve.\n\t     If a guide point is reached (kstpch=-1 or 1), then we have a\n\t     candidate for the end point of the Bezier segement. If the start\n\t     point is reached (kstpch=3) then we also have a candidate\n\t     end point for the segment.\n\n\t     The next loop use kstpch to indicate if we have a candidate\n\t     end point for the segment:\n\n\t     kstpch==0  :  No candidate end point exists\n\t     kstpch!=0  :  Candidate end point exists\n\n\n\t     To indicate if the segement is within the resolution we\n\t     use koutside_resolution:\n\n\t     koutside_resolution==0 : Segment outside resolution\n\t     koutside_resolution!=0 : Segment inside resolution\n\t  */\n\n\t  koutside_resolution = 0;\n\n\n\t  /* Make sure that there is enough space for one more point */\n\n\t  if (knbinf>=kmaxinf)\n            {\n\t      kmaxinf = kmaxinf + 100;\n\t      s3dinf = increasearray(s3dinf,((3*kdim+1)*kmaxinf),DOUBLE);\n\t      if (s3dinf==SISL_NULL) goto err101;\n\t      sp1inf = increasearray(sp1inf,7*kmaxinf,DOUBLE);\n\t      if (sp1inf==SISL_NULL) goto err101;\n\t      sp2inf = increasearray(sp2inf,7*kmaxinf,DOUBLE);\n\t      if (sp2inf==SISL_NULL) goto err101;\n            }\n\n\n\t  /*Make description of candidate endpoint if it exists and store it */\n\n\t  if (kstpch != 0)\n            {\n\t      s1304(snxt1,snxt2,snxp1,snxp2,s3dinf+10*knbinf,\n\t\t    sp1inf+7*knbinf,sp2inf+7*knbinf,&kstat);\n\t      if (kstat<0) \n\t\tgoto error;\n\n\t      /* It is allowed to jump on to a singular point\n\t\t Make sure that the tangents of previous and the new point\n\t\t point in the same direction */\n\n\t      if (knbinf>0)\n\t\ttdum = s6scpr(s3dinf+10*(knbinf-1)+3,\n\t\t\t      s3dinf+10*knbinf+3,kdim);\n\t      else\n\t\ttdum = s6scpr(startg,s3dinf+3,kdim);\n\n\n\t      if (tdum < DZERO)\n                {\n\t\t  /* Change tangent direction 3-D and in parameter plane */\n\t\t  sp1 = s3dinf + 10*knbinf + 3;\n\t\t  sp1[0] = -sp1[0];\n\t\t  sp1[1] = -sp1[1];\n\t\t  sp1[2] = -sp1[2];\n\t\t  sp1 = sp1inf + 7*knbinf + 2;\n\t\t  sp1[0] = -sp1[0];\n\t\t  sp1[1] = -sp1[1];\n\t\t  sp1 = sp2inf + 7*knbinf + 2;\n\t\t  sp1[0] = -sp1[0];\n\t\t  sp1[1] = -sp1[1];\n                }\n\n\t      /* Copy the candidate point to spntend1, spntend2,sparend1\n\t\t and sparend2 */\n\n\t      memcopy(spntend1,snxt1,21,DOUBLE);\n\t      memcopy(sparend1,snxp1,2,DOUBLE);\n\t      memcopy(spntend2,snxt2,21,DOUBLE);\n\t      memcopy(sparend2,snxp2,2,DOUBLE);\n            }\n\n\n\t  while (kstpch == 0 || koutside_resolution == 0)\n            {\n\t      if (kstpch!=0)\n                {\n\t\t  /* Candidate end point exist, iterate to find point close\n\t\t     to the midpoint of the Bezier segement */\n\n\n\t\t  /* Decide if Hermit shape acceptable and find position and\n\t\t     tangent at midpoint of segment */\n\n\t\t  start = s3dinf + 10*(knbinf-1);\n\n\t\t  s1361(start,start+10,3,smidd,smidd+3,&kstat);\n\t\t  if (kstat<0) \n\t\t    goto error;\n\n\t\t  tcurstep = DZERO;\n\t\t  spoint = smidd;\n                }\n\t      else\n                {\n\n\t\t  /* Iterate to find end point of segment */\n\n\t\t  /* ITERATE by intersecting the two surface and the plane\n\t\t     defined by current point (s3dinf), the tangent (s3dinf+3)\n\t\t     and the step length */\n\n\t\t  spoint = s3dinf + 10*(knbinf-1);\n\t\t  tcurstep = tstep;\n                }\n\n\t      /* Perform the actual iteration */\n\n\t      kpos = 70;\n\t      s9iterate(spoint,spnt1,spnt2,spar1,spar2,psurf1,psurf2,tcurstep,\n\t\t\taepsge,sipnt1,sipnt2,sipar1,sipar2,&kstat);\n\t      if (kstat < 0) \n\t\tgoto error;\n\n\t      /* VSK 0417. Check if the intersection point is still inside \n\t\t the surface parameter domains. */\n\t      if (kstat == 0 && DEQUAL(tstep, DZERO) &&\n\t\t  (sipar1[0] < sval1[0] || sipar1[0] > sval1[1] ||\n\t\t  sipar1[1] < sval2[0] || sipar1[1] > sval2[1] ||\n\t\t  sipar2[0] < sval3[0] || sipar2[0] > sval3[1] ||\n\t\t   sipar2[1] < sval4[0] || sipar2[1] > sval4[1]))\n\t\t{\n\t\t  kstat = 3;  // Do not use iterated point\n\t\t  aepsge2 = max(aepsge2,\n\t\t\t\tmax(s6dist(spnt1,sipnt1,3), s6dist(spnt2,sipnt2,3)));\n\t\t}\n\n\t      /* Initiate distance between midpoint and iteration point\n\t\t to -1 to enable detection of divergence */\n\n\t      tdist = (double)-1.0;\n\n\t      /* Check if iteration has converged */\n\n\t      if (kstat == 2)\n                {\n\t\t  /* Iteration has diverged, half step length if possible,\n\t\t     find new endpoint of segement. */\n\n\t\t  kstpch = 0;\n\t\t  koutside_resolution = 0;\n                }\n\t      else if(kstat == 1 && kstpch != 0)\n                {\n\t\t  /* The point found is closer to the input point than\n\t\t     the relative computer resolution or is a singular point.\n\t\t     We stop the marching in this direction here\n\t\t     Half step length if possible, find new endpoint of\n\t\t     segement. */\n\n\t\t  kstpch = 0;\n\t\t  koutside_resolution = 0;\n                }\n\t      else if (kstpch!=0)\n                {\n\n\n\t\t  /* Make description of intersection point */\n\n\t\t  s1304(sipnt1,sipnt2,sipar1,sipar2,simiddpnt,simiddpar1,\n\t\t\tsimiddpar2,&kstat);\n\t\t  if (kstat<0) goto error;\n\n\n\t\t  if (kstat != 2)\n                    {\n\t\t      /* We iterated to find midpoint of segment, test if\n\t\t\t it is within resolution */\n\n\t\t      tdist = s6dist(simiddpnt,smidd,3);\n\t\t      tang  = s6ang(simiddpnt+3,smidd+3,3);\n                    }\n\n\t\t  /* If point is singular or not within resolution a new\n\t\t     Hermit segment has to be made */\n\n\t\t  if (kstat == 2 || (fabs(tdist) > aepsge2 ||\n\t\t\t\t     (fabs(tang) > ANGULAR_TOLERANCE &&\n\t\t\t\t      tstep      > aepsge2)))\n                    {\n\t\t      kstpch = 0;\n\t\t      koutside_resolution = 0;\n                    }\n\t\t  else\n                    {\n\t\t      /*Segment within tolerance.\n\t\t\tCheck that the relationship between the two surfaces\n\t\t\thas not been interchanged, by making the cross product\n\t\t\tof the normal vectors in current point and the point\n\t\t\tfound by iteration. Then make the scalar product of\n\t\t\tthese vectors. If the scalar product is negative then\n\t\t\twe have either jumped to another branch or passed a\n\t\t\tsingularity,iterprete this as the iteration has diverged\n\t\t\tIn addition we don't want the direction of the tangents\n\t\t\tchange to much. We set a limit of approximately PI/3\n\t\t\tMake normal vectors in implicit surface for both points\n\t\t\tMake also sure that the curve in the parameter plane\n\t\t\tdoes not turn more than 90 degrees.\n\t\t\tby testing on a cosin value of 0.5\n\t\t      */\n\n\t\t      s6crss(spnt1+18,spnt2+18,sdum1);\n\t\t      (void)s6norm(sdum1,kdim,sdum1,&kstat);\n\t\t      if (kstat < 0) \n\t\t\tgoto error;\n\n\t\t      s6crss(spntend1+18,spntend2+18,sdum2);\n\t\t      (void)s6norm(sdum2,kdim,sdum2,&kstat);\n\t\t      if (kstat < 0) \n\t\t\tgoto error;\n\n\t\t      tdum = s6scpr(sdum1,sdum2,kdim);\n\n                      s6diff(sipar1,spar1,2,sdum1);\n                      tdump1 = s6scpr(sdum1,sp1inf+7*(knbinf-1)+2,2);\n\n                      s6diff(sipar2,spar2,2,sdum1);\n                      tdump2 = s6scpr(sdum1,sp2inf+7*(knbinf-1)+2,2);\n\n\t\t      if (tdum == DZERO)\n                        {\n\t\t\t  double tl1,tl2;\n\n\t\t\t  /* If one of the tangents have zero length,\n\t\t\t     accept segment */\n\n\t\t\t  tl1 = s6length(sdum1,kdim,&kstat);\n\t\t\t  tl2 = s6length(sdum2,kdim,&kstat);\n\n\t\t\t  if (tl1 == DZERO || tl2 == DZERO)\n\t\t\t    koutside_resolution = 1;\n\t\t\t  else\n                            {\n\t\t\t      /* Find new end point of segment */\n\n\t\t\t      koutside_resolution = 0;\n\t\t\t      kstpch = 0;\n                            }\n\n                        }\n\t\t      else if (tdum <= (double)0.5 || tdump1 <= DZERO\n                               || tdump2 <= DZERO)\n                        {\n\t\t\t  /*Find new end point of segment */\n\n\t\t\t  koutside_resolution = 0;\n\t\t\t  kstpch = 0;\n                        }\n\t\t      else\n                        {\n\t\t\t  koutside_resolution = 1;\n                        }\n                    }\n                }\n\t      else\n                {\n\t\t  if (kstat != 3)\n\t\t    {\n\t\t      /* We iterated to find end point of segment,\n\t\t\t update pointer */\n\n\t\t      memcopy(spntend1,sipnt1,21,DOUBLE);\n\t\t      memcopy(sparend1,sipar1,2,DOUBLE);\n\t\t      memcopy(spntend2,sipnt2,21,DOUBLE);\n\t\t      memcopy(sparend2,sipar2,2,DOUBLE);\n\n\t\t      s1304(sipnt1,sipnt2,sipar1,sipar2,s3dinf+10*knbinf,\n\t\t\t    sp1inf+7*knbinf,sp2inf+7*knbinf,&kstat);\n\t\t      if (kstat<0) \n\t\t\tgoto error;\n\t\t    }\n\n\t\t  /* Make sure that the tangents of previous and the new point\n\t\t     point in the same direction, singular end point allowed' */\n\n\t\t  if (knbinf>0)\n\t\t    tdum = s6scpr(s3dinf+10*(knbinf-1)+3,\n\t\t\t\t  s3dinf+10*knbinf+3,kdim);\n\t\t  else\n\t\t    tdum = s6scpr(startg,s3dinf+3,kdim);\n\n\n\t\t  if (tdum < DZERO)\n                    {\n\t\t      /* Change tangent direction 3-D and in parameter plane */\n\n\t\t      sp1 = s3dinf + 10*knbinf + 3;\n\t\t      sp1[0] = -sp1[0];\n\t\t      sp1[1] = -sp1[1];\n\t\t      sp1[2] = -sp1[2];\n\t\t      sp1 = sp1inf + 7*knbinf + 2;\n\t\t      sp1[0] = -sp1[0];\n\t\t      sp1[1] = -sp1[1];\n\t\t      sp1 = sp2inf + 7*knbinf + 2;\n\t\t      sp1[0] = -sp1[0];\n\t\t      sp1[1] = -sp1[1];\n                    }\n\t\t  /* Indicate that end point accepted */\n\n\t\t  kstpch = 4;\n\t\t  koutside_resolution = 0;\n                }\n\t      /* It the segment is acceptable clip to the boundary */\n\n\t      if (kstpch != 0 && koutside_resolution == 1)\n\t\t{\n\n\t\t  /* Check if the curve between the start and end point\n\t\t     cross the boundary */\n\n\t\t  memcopy(sparmid1,sipar1,2,double);\n\t\t  memcopy(sparmid2,sipar2,2,double);\n\n\t\t  s1330(spar1,spar2,sparend1,sparend2,sval1,sval2,sval3,sval4,\n\t\t\t&kbound,sipar1,sipar2,&kstat);\n\t\t  if (kstat<0) \n\t\t    goto error;\n\n\n\t\t  /* In case of kstat==4 (we go from the boundary and out)\n\t\t     or kstat==0 and the start is within computer resolution\n\t\t     from the boundary, make sure that the tangent points out\n\t\t     in both parameter planes.\n\t\t     If not set status to 1 e.g, we are inside the patch */\n\n\t\t  if(kstat==0 || kstat==4)\n\t\t    {\n\t\t      /* Set pointer to tangents at start point */\n\t\t      ki = 7*(knbinf-1)+2;\n\n\t\t      if(((DEQUAL(spar1[1]+tref2,sval2[0]+tref2) &&\n\t\t\t   sp1inf[ki+1]>DZERO) ||\n\t\t\t  (DEQUAL(spar1[1]+tref2,sval2[1]+tref2) &&\n\t\t\t   sp1inf[ki+1]<DZERO) ||\n\t\t\t  (DEQUAL(spar1[0]+tref1,sval1[0]+tref1) &&\n\t\t\t   sp1inf[ki  ]>DZERO) ||\n\t\t\t  (DEQUAL(spar1[0]+tref1,sval1[1]+tref1) &&\n\t\t\t   sp1inf[ki  ]<DZERO)\n\t\t\t  ) &&\n\t\t\t ((DEQUAL(spar2[1]+tref4,sval3[0]+tref4) &&\n\t\t\t   sp2inf[ki+1]>DZERO) ||\n\t\t\t  (DEQUAL(spar2[1]+tref4,sval3[1]+tref4) &&\n\t\t\t   sp2inf[ki+1]<DZERO) ||\n\t\t\t  (DEQUAL(spar2[0]+tref3,sval2[0]+tref3) &&\n\t\t\t   sp2inf[ki  ]>DZERO) ||\n\t\t\t  (DEQUAL(spar2[0]+tref3,sval2[1]+tref3) &&\n\t\t\t   sp2inf[ki  ]<DZERO)))\n\t\t\tkstat = 1;\n\t\t    }\n\t\t  krem1 = kstat;\n\n\t\t  /* Check if the curve between the start and midpoint cross\n\t\t     the boundary */\n\n\t\t  s1330(spar1,spar2,sparmid1,sparmid2,sval1,sval2,sval3,sval4,\n\t\t\t&kbound,sipar1,sipar2,&kstat);\n\t\t  if (kstat<0) \n\t\t    goto error;\n\n\t\t  krem2 = kstat;\n\n\t\t  /* We now have the following cases:\n\t\t     kstat == 0 :\n\t\t     Line between (spar1,spar2) and (sparend1,sparend2)\n\t\t     outside. If this happens when kdir=1, then\n\t\t     just forget the start point. If it happens\n\t\t     when kdir=2, then we just stop the marching.\n\t\t     kstat == 1 : Line between epar1 and epar2 inside.\n\t\t     Continue iteration.\n\t\t     kstat == 2 : We step out of the patch. Clip to the edge\n\t\t     of the patch. Update start point.\n\t\t     kstat == 3 : We step into the patch. Clip to the edge\n\t\t     of the patch. Update endpoint\n\t\t     kstat == 4 : We go from the boundary and out. Try next\n\t\t     iteration direction.\n\t\t  */\n\n\t\t  if (krem1 == 0 || krem2 == 0)\n\t\t    {\n\t\t      if (kdir==1) \n\t\t\tknbinf--;\n\t\t      goto nextdir;\n\t\t    }\n\t\t  else if ((krem1 !=1 || krem2 !=1) &&\n\t\t\t   krem1 != 4 && krem2 != 4)\n\t\t    {\n\n\t\t      /* If we clip to the boundary,\n\t\t\t forget any guide point identified */\n\n\t\t      kstat1 = 0;\n\t\t      if (krem2 == 2 || krem2 == 3)\n\t\t\t{\n\t\t\t  s9clipit(spar1,spar2,sparmid1,sparmid2,psurf1,psurf2,\n\t\t\t\t   sval1,sval2,sval3,sval4,aepsge,\n\t\t\t\t   sipnt1,sipnt2,sipar1,sipar2,&kstat);\n\t\t\t  if (kstat<0) \n\t\t\t    goto error;\n\t\t\t  if (krem2==3 && kstat==1) \n\t\t\t    kstpch = 4;\n\t\t\t  kstat1 = kstat;\n\t\t\t  krem = krem2;\n\t\t\t}\n\t\t      if (kstat1 !=1 && (krem1 == 2 || krem1 == 3))\n\t\t\t{\n\t\t\t  s9clipit(spar1,spar2,sparend1,sparend2,psurf1,psurf2,\n\t\t\t\t   sval1,sval2,sval3,sval4,aepsge,\n\t\t\t\t   sipnt1,sipnt2,sipar1,sipar2,&kstat);\n\t\t\t  if (kstat<0) \n\t\t\t    goto error;\n\t\t\t  if (krem1==3 && kstat==1) \n\t\t\t    kstpch = 4;\n\t\t\t  kstat1 = kstat;\n\t\t\t  krem = krem1;\n\t\t\t}\n\n\t\t      if (kstat1 == 1)\n\t\t\t{\n\t\t\t  /*Check that the relationship between the two\n\t\t\t    surfaces has not been interchanged,\n\t\t\t    by making the cross product\n\t\t\t    of the normal vectors in current point and\n\t\t\t    the point found by iteration.\n\t\t\t    Then make the scalar product of these vectors.\n\t\t\t    If the scalar product is negative then\n\t\t\t    we have either jumped to another branch or passed a\n\t\t\t    singularity, iterprete this as the iteration\n\t\t\t    has diverged.\n\t\t\t    In addition we don't want the direction of the\n\t\t\t    tangents change to much. We set a limit of\n\t\t\t    approximately PI/3 by testing on a\n\t\t\t    cosin value of 0.5\n\t\t\t    Make normal vectors in implicit surface for both\n\t\t\t    points Make also sure that the curves in the\n\t\t\t    parameter plane does not turn more than 90 degrees.\n\t\t\t  */\n\n\t\t\t  s6crss(spnt1+18,spnt2+18,sdum1);\n\t\t\t  (void)s6norm(sdum1,kdim,sdum1,&kstat);\n\t\t\t  if (kstat < 0) \n\t\t\t    goto error;\n\n\t\t\t  s6crss(sipnt1+18,sipnt2+18,sdum2);\n\t\t\t  (void)s6norm(sdum2,kdim,sdum2,&kstat);\n\t\t\t  if (kstat < 0)\n\t\t\t    goto error;\n\n\t\t\t  tdum = s6scpr(sdum1,sdum2,kdim);\n\n\t\t\t  /*Check that sipar1 lies on the same side of spar1 as\n\t\t\t    the tangent at spar1 */\n\n\t\t\t  s6diff(sipar1,spar1,2,sdum1);\n\t\t\t  tdump1 = s6scpr(sdum1,sp1inf+7*(knbinf-1)+2,2);\n\n\t\t\t  s6diff(sipar2,spar2,2,sdum1);\n\t\t\t  tdump2 = s6scpr(sdum1,sp2inf+7*(knbinf-1)+2,2);\n\t\t\t}\n\n\t\t      /* An intersection point has only been\n\t\t\t found when kstat==1 */\n\n\t\t      if ( kstat1==1 && tdump1 >= DZERO &&\n\t\t\t   tdump1 >= DZERO && tdum > (double)0.5)\n\n\t\t\t{\n\t\t\t  /* If krem=3 we step into the patch,\n\t\t\t     if krem=2 we step\n\t\t\t     out of the patch */\n\n\t\t\t  if (krem==2 || krem==3)\n\t\t\t    {\n\t\t\t      /* If krem==3 we step into the patch, make new\n\t\t\t\t start point of segment */\n\n\t\t\t      if (krem==3) \n\t\t\t\tknbinf--;\n\n\t\t\t      memcopy(spntend1,sipnt1,21,DOUBLE);\n\t\t\t      memcopy(sparend1,sipar1,2,DOUBLE);\n\t\t\t      memcopy(spntend2,sipnt2,21,DOUBLE);\n\t\t\t      memcopy(sparend2,sipar2,2,DOUBLE);\n\n\t\t\t      s1304(sipnt1,sipnt2,sipar1,sipar2,\n\t\t\t\t    s3dinf+10*knbinf,\n\t\t\t\t    sp1inf+7*knbinf,\n\t\t\t\t    sp2inf+7*knbinf,&kstat);\n\t\t\t      if (kstat<0) \n\t\t\t\tgoto error;\n\n\t\t\t      /* Make sure that the tangents of previous\n\t\t\t\t and the new point\n\t\t\t\t point in the same direction */\n\n\t\t\t      if (knbinf>0)\n\t\t\t\ttdum = s6scpr(s3dinf+10*(knbinf-1)+3,\n\t\t\t\t\t      s3dinf+10*knbinf+3,kdim);\n\t\t\t      else\n\t\t\t\ttdum = s6scpr(startg,s3dinf+3,kdim);\n\n\n\t\t\t      if (tdum < DZERO)\n\t\t\t\t{\n\t\t\t\t  /* Change tangent direction 3-D and in\n\t\t\t\t     parameter plane */\n\n\t\t\t\t  sp1 = s3dinf + 10*knbinf + 3;\n\t\t\t\t  sp1[0] = -sp1[0];\n\t\t\t\t  sp1[1] = -sp1[1];\n\t\t\t\t  sp1[2] = -sp1[2];\n\t\t\t\t  sp1 = sp1inf + 7*knbinf + 2;\n\t\t\t\t  sp1[0] = -sp1[0];\n\t\t\t\t  sp1[1] = -sp1[1];\n\t\t\t\t  sp1 = sp2inf + 7*knbinf + 2;\n\t\t\t\t  sp1[0] = -sp1[0];\n\t\t\t\t  sp1[1] = -sp1[1];\n\t\t\t\t}\n\n\t\t\t      /* If the new end point tangent points out go to\n\t\t\t\t next direction */\n\n\t\t\t      ki = 7*knbinf;\n\t\t\t      if((sp1inf[ki+1] <= sval2[0] &&\n\t\t\t\t  sp1inf[ki+3] < DZERO) ||\n\t\t\t\t (sp1inf[ki+1] >= sval2[1] &&\n\t\t\t\t  sp1inf[ki+3] > DZERO) ||\n\t\t\t\t (sp1inf[ki  ] <= sval1[0] &&\n\t\t\t\t  sp1inf[ki+2] < DZERO) ||\n\t\t\t\t (sp1inf[ki  ] >= sval1[1] &&\n\t\t\t\t  sp1inf[ki+2] > DZERO) ||\n\t\t\t\t (sp2inf[ki+1] <= sval4[0] &&\n\t\t\t\t  sp2inf[ki+3] < DZERO) ||\n\t\t\t\t (sp2inf[ki+1] >= sval4[1] &&\n\t\t\t\t  sp2inf[ki+3] > DZERO) ||\n\t\t\t\t (sp2inf[ki  ] <= sval3[0] &&\n\t\t\t\t  sp2inf[ki+2] < DZERO) ||\n\t\t\t\t (sp2inf[ki  ] >= sval3[1] &&\n\t\t\t\t  sp2inf[ki+2] > DZERO))\n\t\t\t\t{\n\t\t\t\t  knbinf++;\n\t\t\t\t  goto nextdir;\n\t\t\t\t}\n\t\t\t      else if (krem == 2 &&\n\t\t\t\t       ((sp1inf[ki+1] <= sval2[0] &&\n\t\t\t\t\t sp1inf[ki+3] >= DZERO) ||\n\t\t\t\t\t(sp1inf[ki+1] >= sval2[1] &&\n\t\t\t\t\t sp1inf[ki+3] <= DZERO) ||\n\t\t\t\t\t(sp1inf[ki  ] <= sval1[0] &&\n\t\t\t\t\t sp1inf[ki+2] >= DZERO) ||\n\t\t\t\t\t(sp1inf[ki  ] >= sval1[1] &&\n\t\t\t\t\t sp1inf[ki+2] <= DZERO) ||\n\t\t\t\t\t(sp2inf[ki+1] <= sval4[0] &&\n\t\t\t\t\t sp2inf[ki+3] >= DZERO) ||\n\t\t\t\t\t(sp2inf[ki+1] >= sval4[1] &&\n\t\t\t\t\t sp2inf[ki+3] <= DZERO) ||\n\t\t\t\t\t(sp2inf[ki  ] <= sval3[0] &&\n\t\t\t\t\t sp2inf[ki+2] >= DZERO) ||\n\t\t\t\t\t(sp2inf[ki  ] >= sval3[1] &&\n\t\t\t\t\t sp2inf[ki+2] <= DZERO)))\n\t\t\t\t{\n\t\t\t\t  /* We were marching out of the patch\n\t\t\t\t     but the tangent\n\t\t\t\t     is pointing in half step length */\n\t\t\t\t  kstpch = 0;\n\t\t\t\t}\n\n\n\n\t\t\t    }\n\t\t\t}\n\t\t      else\n\t\t\t{\n\t\t\t  /* Divergence or point on wrong side in the parameter\n\t\t\t     plane or 3-d */\n\t\t\t  kstpch = 0;\n\t\t\t  koutside_resolution = 0;\n\t\t\t}\n\t\t    }\n\t\t  else if (kstat==4)\n\t\t    goto nextdir;\n\t\t}\n\n\t      /* Update step length if new endpoint is to be found */\n\n\t      if (kstpch==0)\n                {\n\t\t  if (tdist<DZERO)\n                    {\n\t\t      tnew = tstep/(double)10.0;\n                    }\n\t\t  else\n                    {\n\t\t      tfak = MAX(tdist/aepsge2,(double)1.0);\n\t\t      tfak = (double)2.0*pow(tfak,ONE_FOURTH);\n\t\t      tnew = MIN(tstep/(double)2.0,tstep/tfak);\n                    }\n\t\t  if (DEQUAL(tmax+tnew,tmax+tstep)) goto nextdir;\n\t\t  tstep = tnew;\n                }\n            }\n\n\t  /* If kstpch= -1,1,3 or 4 then a point is accepted and\n\t     snxt1 points to the position and derivatives\n\t     of the accepted point. */\n\n\n\t  /* Update number of intersection points */\n\n\t  knbinf++;\n\n\t  /* Copy point and parameter pair descriptions */\n\n\t  memcopy(spnt1,spntend1,21,DOUBLE);\n\t  memcopy(spar1,sparend1,2,DOUBLE);\n\t  memcopy(spnt2,spntend2,21,DOUBLE);\n\t  memcopy(spar2,sparend2,2,DOUBLE);\n\n\t  /* Update guide point pointers */\n\n\n\t  if (kstpch ==  1)\n            {\n\t      kguide++;\n\t      kgdir   = 1;\n\n\t      /* Test if end of guide point array reached */\n\n\t      if (kguide >= kpoint) \n\t\tgoto nextdir;\n\n            }\n\t  if (kstpch == -1)\n            {\n\t      kguide--;\n\t      kgdir   = -1;\n\n\t      /* Test if start of guide point array reached */\n\n\t      if (1 >= kguide) \n\t\tgoto nextdir;\n            }\n\n\t  /* Make new radius of curvature */\n\n\t  trad = *(s3dinf + 10*knbinf - 1);\n\t  tstep = s1311(trad,aepsge,tmax,&kstat);\n\t  if (kstat<0) \n\t    goto error;\n\n\t  /* Test if start point reached, e.g. that the curve is closed */\n\n\t  if (kstpch == 3)\n            {\n\t      /* Closed curve found */\n\n\t      goto finished;\n            }\n\n\n\t  /*  End while loop */\n        }\n\n    nextdir:;\n\n      /*  End two step directions */\n    }\n\n finished:\n\n  /* In certain cases too many marched point may be found. These cases are:\n\n     - Open curve and start of marching first guide point\n     - Open curve and start of marching last guide point\n     - Closed curve and this found in second marching direction\n\n     In these cases some of the found points have to be discarded */\n\n  scorpnt = s3dinf;\n  scorpr1 = sp1inf;\n  scorpr2 = sp2inf;\n\n  if (knb1 < 1)\n    knb1 = 1;  /* To avoid picking up random points */\n  if (kstpch !=3 && kpoint>1)\n    {\n\n      /*  Open curve */\n\n      if ( (kstart==1 && kgd1 == kpoint) ||\n\t   (kstart==kpoint && kgd1==1)      )\n        {\n\t  /* First marching direction traced curve */\n\n\t  knbinf = knb1;\n        }\n      else if ( (kstart==1 && kguide==kpoint) ||\n\t\t(kstart==kpoint && kguide==1)    )\n        {\n\t  /* Second marching direction traced curve */\n\n\t  scorpnt = scorpnt + 10*(knb1-1);\n\t  scorpr1 = scorpr1 +  7*(knb1-1);\n\t  scorpr2 = scorpr2 +  7*(knb1-1);\n\t  knbinf  = knbinf - knb1 + 1;\n        }\n    }\n  else if (kpoint>1)\n    {\n      /*  Closed curve, correct if result of second marching direction */\n\n      if (kdir != 1)\n        {\n\t  /* Second marching direction, disc ard result of first direction */\n\n\t  scorpnt = scorpnt + 10*(knb1-1);\n\t  scorpr1 = scorpr1 +  7*(knb1-1);\n\t  scorpr2 = scorpr2 +  7*(knb1-1);\n\t  knbinf  = knbinf - knb1 + 1;\n        }\n    }\n\n interpolate:\n\n  if (pinter->itype == 9)\n    {\n      /* VSK, 1208. When we already know the curve, it does not make\n\t sense to approximate it. Besides, if the constant parameter curve\n\t lies at the outer boundary of the surface, the marching is\n\t inreliable. Preferably, the marching points should not be\n\t computed in this case, but I don't want to do too much changes\n\t with such old code. */\n\n      s1310_s9constline(psurf1,psurf2,pinter,aepsge,icur,igraph,&kstat);\n      if (kstat<0) \n\tgoto error;\n      if (kstat==0) \n\tgoto err185;\n    }\n  else if (knbinf>1)\n    {\n      if (igraph == 1 && knbinf > 1)\n\t{\n\t  /* Output curve through s6line and s6move */\n\n\t  s6move(scorpnt);\n\t  for (ki=1,sp1=scorpnt+10;ki<knbinf;ki++,sp1+=10)\n\t    s6line(sp1);\n\t}\n\n      /* A curve is traced out only if at least two points are found */\n\n      if (icur > 0 && knbinf > 1)\n\t{\n\n\t  /*  Make 3-D representation of intersection curve */\n\n\t  kpar = 0;\n\n\t  spar = newarray(knbinf,DOUBLE);\n\t  if (spar == SISL_NULL) goto err101;\n\t  s1359(scorpnt,aepsge,kdim,knbinf,kpar,spar,&q3dcur,&kstat);\n\t  if (kstat < 0) \n\t    goto error;\n\n\t  /*  Set pointer in intcurve object to 3-D curve */\n\n\t  pinter -> pgeom = q3dcur;\n\n\t  if (icur == 2)\n\t    {\n\t      /* Make curves in parameter planes */\n\n\t      kdim = 2;\n\t      kpar = 1;\n\t      s1359(scorpr1,aepsge,kdim,knbinf,kpar,spar,&qp1cur,&kstat);\n\t      if (kstat < 0) \n\t\tgoto error;\n\n\n\t      s1359(scorpr2,aepsge,kdim,knbinf,kpar,spar,&qp2cur,&kstat);\n\t      if (kstat < 0) \n\t\tgoto error;\n\n\t      /* Set pointers in intcurve object to curves in parameter plane*/\n\n\t      pinter -> ppar1 = qp1cur;\n\t      pinter -> ppar2 = qp2cur;\n\t    }\n\t}\n    }\n  else if (pinter->ipoint > 1)\n    {\n      /* If no points produced on intersection curve */\n\n      s1310_s9constline(psurf1,psurf2,pinter,aepsge,icur,igraph,&kstat);\n      if (kstat<0) \n\tgoto error;\n      if (kstat==0) \n\tgoto err185;\n    }\n  else\n    goto err185;\n\n  if (kdiv == 1) \n    goto war03;\n  *jstat = 0;\n\n  goto out;\n\n  /* Iteration can not continue */\n war03:  *jstat = 3;\n  goto out;\n\n  /* Error in space allocation */\n err101: *jstat = -101;\n  s6err(\"s1310\",*jstat,kpos);\n  goto out;\n\n\n  /* Error in surface description parameter direction does not exist */\n err123: *jstat = -123;\n  s6err(\"s1310\",*jstat,kpos);\n  goto out;\n\n\n  /* Error - SISL_NULL pointer was given */\n err150 :\n  *jstat = -150;\n  s6err(\"s1310\",*jstat,kpos);\n  goto out;\n\n  /* Only degenerate or singular guide points */\n err185: *jstat = -185;\n  goto out;\n\n  /* Error in lower leve function */\n error:\n  *jstat = kstat;\n  s6err(\"s1310\",*jstat,kpos);\n  goto out;\n\n out:\n\n  /* Free allocated space */\n\n  if (sgd1   != SISL_NULL) freearray(sgd1);\n  if (sgd2   != SISL_NULL) freearray(sgd2);\n  if (s3dinf != SISL_NULL) freearray(s3dinf);\n  if (sp1inf != SISL_NULL) freearray(sp1inf);\n  if (sp2inf != SISL_NULL) freearray(sp2inf);\n  if (spar   != SISL_NULL) freearray(spar);\n  if (sgpar1 != SISL_NULL) freearray(sgpar1);\n  if (sgpar2 != SISL_NULL) freearray(sgpar2);\n  if (sdminang != SISL_NULL) freearray(sdminang);\n\n\n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void s1310_s9constline(SISLSurf *ps1,SISLSurf *ps2,SISLIntcurve *pintcr,\n\t\t\t      double aepsge,int icur,int igraph,int *jstat)\n#else\n  static void s1310_s9constline(ps1,ps2,pintcr,aepsge,icur,igraph,jstat)\n     SISLSurf     *ps1;\n     SISLSurf     *ps2;\n     SISLIntcurve *pintcr;\n     double   aepsge;\n     int      icur;\n     int      igraph;\n     int      *jstat;\n#endif\n     /*\n*********************************************************************\n*\n* PURPOSE    : To check if the parameter pairs describe an intersection\n*              curve that is a constant parameter line in the parameter\n*              plane of a surface and to produce the description of\n*              the curve according to the specifications.\n*\n*\n* INPUT      : ps1    - Pointer to first surface.\n*              ps2    - Pointer to second surface.\n*              aepsge - Geometry resolution.\n*              icur   - Indicator telling if a 3-D curve is to be made\n*                        0 - Don't make 3-D curve\n*                        1 - Make 3-D curve\n*                        2 - Make 3-D curve and curves in parameter plane\n*              igraph - Indicator telling if the curve is to be outputted\n*                       through function calls:\n*                        0 - don't output curve through function call\n*                        1 - output as straight line segments through\n*                            s6move and s6line\n*\n*\n*\n* INPUT/OUTPUT:pintcr - The intersection curve. When comming as input\n*                       only parameter values in the parameter plane\n*                       exist. When comming as output the 3-D geometry\n*                       and possibly the curve in the parameter plane\n*                       of the surface are added.\n*\n* OUTPUT:      jstat  - status messages\n*                         = 1      : Constant parameter line is intersection\n*                         = 0      : No intersection along constant parameter\n*                                    line.\n*                         < 0      : error\n*\n*\n* METHOD     :\n* REFERENCES :\n*\n*\n*-\n* CALLS      :\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 2. July 1989\n*\n*********************************************************************\n*/\n{\n  /*int kguide1,kguide2,kguide3,kguide4;*/ /* Pointers to guide points       */\n  int kguide[4];\n  /*int kderc=2;         Number of derivatives to be claculated on curve */\n  int kders=1;        /* Number of derivatives to be calculated on surface*/\n  int ki,kj,kl;            /* Control variables in for loops            */\n  int kix1, kix2;\n  int kk,kn,kk1,kn1,kk2,kn2;/* Orders and numbers of knots               */\n  int       kk3,kn3,kk4,kn4;/* Orders and numbers of knots               */\n  int kpoint;              /* Number of points in guide curve           */\n  int kleft = 0;           /* Pointer into knot vector                  */\n  int kpar1;               /* Number of parameter direction in 1st. obj */\n  int kpar2;               /* Number of parameter direction in 2st. obj */\n  int ktype;               /* Type of intersection curve                */\n  int kpos=0;              /* Position of error                         */\n  int kstat;               /* Status variable returned form routine     */\n  int kdir=0;              /* constant parameter line direction         */\n  int kdir2;\n  int knbpnt;              /* Number of points on constant parameter line */\n  int kleft1=0,kleft2=0;   /* Pointers into knot vectors                */\n  int kstop;               /* Stop value in loop                        */\n  double *sp=SISL_NULL;         /* Array for storage of points in\n\t\t\t\t   parameter plane */\n  double *sv=SISL_NULL;         /* Array for storage of tangents in\n\t\t\t\t   parameter plane*/\n  double *spar=SISL_NULL;       /* Array for storage of parameter values     */\n  double *stp,*stv,*stpar; /* Pointers to sp,sv and spar                */\n  double tdistp,tdistc;    /* Distances between points                  */\n  double tfak;             /* Scaling factor                            */\n  double sstart[4];        /* Lower boundary of parameter intervals     */\n  double send[4];          /* Upper bounadry of parameter intervals     */\n  double snext[3];         /* Existing iteration point on  surface      */\n  /* double tmax1,tmin1;      /\\* Minimum and maximum of 1.rst comp of */\n  /* \t\t\t      guide points *\\/ */\n  /* double tmax2,tmin2;      /\\* Minimum and maximum of 2.nd. comp of */\n  /* \t\t\t      guide points *\\/ */\n  /* double tmax3,tmin3;      /\\* Minimum and maximum of 3.rd. comp of */\n  /* \t\t\t      guide points *\\/ */\n  /* double tmax4,tmin4;      /\\* Minimum and maximum of 4.th  comp of */\n  /* \t\t\t      guide points *\\/ */\n  double tminx[4], tmaxx[4];\n  double tmax;             /* Maximum 3-D SISLbox side                      */\n  double tdist,tang;       /* Distance and angle error                  */\n  double *st,*st1,*st2;    /* Pointers to knot vectors                  */\n  double     *st3,*st4;    /* Pointers to knot vectors                  */\n  double *spoint;          /* Pointer to points on constant parameter line */\n  double *sp1;             /* Pointer into array                        */\n  /* double tsize1,tsize2;    /\\* Length of knot intervals                  *\\/ */\n  /* double tsize3,tsize4;    /\\* Length of knot intervals                  *\\/ */\n  double tsize[4];\n  double sval1[2];         /* Limits of parameter plane in first SISLdir    */\n  double sval2[2];         /* Limits of parameter plane in second SISLdir   */\n  double sval3[2];         /* Limits of parameter plane in third SISLdir    */\n  double sval4[2];         /* Limits of parameter plane in fourth SISLdir   */\n  double sderc[6];         /* SISLPoint and derivative on curve             */\n  double sders[9];         /* SISLPoint and derivative on curve             */\n  double snorm[3];         /* Normal on implicit surface                */\n  double tsumold,tsum,tval;/* Parameter values                    */\n  double ta11,ta12,ta22;   /* Coefficients in equation system           */\n  double tb1,tb2,tdom;     /* Left side of eq.syst. and determinant     */\n  double t1,t2;            /* Derivatives in parameter plane            */\n  double *sgpar1=SISL_NULL;     /* Parameter pairs of guide point in surf 1  */\n  double *sgpar2=SISL_NULL;     /* Parameter pairs of guide point in surf 2  */\n  SISLCurve *qc1=SISL_NULL;  /* Pointer to 3-D curve                     */\n  SISLCurve *qc2=SISL_NULL;  /* Pointer to 3-D curve                     */\n\n  SISLCurve *qp1cur=SISL_NULL;/* Pointer to curve in first parameter plane*/\n  SISLCurve *qp2cur=SISL_NULL;/* Pointer to curve in second parameter plane*/\n  SISLSurf  *qsurf =SISL_NULL;\n  SISLPoint *qpoint=SISL_NULL;\n  int turned_dir = 0;         /* If the constant parameter curve is turned */\n  int computed = 0;\n\n\n  /* Make maximal step length based on box-size of surface */\n\n  sh1992su(ps1,0,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  tmax = MAX(ps1->pbox->e2max[0][0] - ps1->pbox->e2min[0][0],\n\t     ps1->pbox->e2max[0][1] - ps1->pbox->e2min[0][1]);\n  tmax = MAX(tmax,ps1->pbox->e2max[0][2] - ps1->pbox->e2min[0][2]);\n\n  sh1992su(ps2,0,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  tmax = MAX(tmax,ps1->pbox->e2max[0][0] - ps1->pbox->e2min[0][0]);\n  tmax = MAX(tmax,ps1->pbox->e2max[0][1] - ps1->pbox->e2min[0][1]);\n  tmax = MAX(tmax,ps1->pbox->e2max[0][2] - ps1->pbox->e2min[0][2]);\n\n  /* Find a none singular start point for the marching process */\n\n  kpoint = pintcr->ipoint;\n  kpar1  = pintcr->ipar1;\n  kpar2  = pintcr->ipar2;\n  sgpar1 = pintcr->epar1;\n  sgpar2 = pintcr->epar2;\n  ktype  = pintcr->itype;\n\n\n  /* Initiate pointers to intersection curve and intersection curve in\n     parameter plane */\n\n  pintcr -> pgeom = SISL_NULL;\n  pintcr -> ppar1 = SISL_NULL;\n  pintcr -> ppar2 = SISL_NULL;\n\n\n\n  /* Test that both objects has 2 parameter direction */\n\n  if (kpar1 == 2 && kpar2 == 2)\n    {\n      /*  Everything is ok */\n      ;\n    }\n  else\n    {\n      goto err123;\n    }\n\n\n  /* Run through the parameter pairs to decide if a constant parameter line\n     is possible */\n\n  /* tmax1 = tmin1 = sgpar1[0]; */\n  /* tmax2 = tmin2 = sgpar1[1]; */\n  /* tmax3 = tmin3 = sgpar2[0]; */\n  /* tmax4 = tmin4 = sgpar2[1]; */\n  tmaxx[0] = tminx[0] = sgpar1[0];\n  tmaxx[1] = tminx[1] = sgpar1[1];\n  tmaxx[2] = tminx[2] = sgpar2[0];\n  tmaxx[3] = tminx[3] = sgpar2[1];\n\n\n  /* Remember which guide point have minimum value in a specific parameter\n     direction */\n\n  kguide[0] = kguide[1] = kguide[2] = kguide[3] = 0;\n\n  for (ki=1,kj=2,kl=3 ; ki < kpoint ; ki++,kj+=2,kl+=2)\n    {\n      if (tminx[0]>sgpar1[kj])\n        {\n\t  tminx[0] = sgpar1[kj];\n\t  kguide[0] = ki;\n        }\n      if (tminx[1]>sgpar1[kl])\n        {\n\t  tminx[1] = sgpar1[kl];\n\t  kguide[1] = ki;\n        }\n      if (tminx[2]>sgpar2[kj])\n        {\n\t  tminx[2] = sgpar2[kj];\n\t  kguide[2] = ki;\n        }\n      if (tminx[3]>sgpar2[kl])\n        {\n\t  tminx[3] = sgpar2[kl];\n\t  kguide[3] = ki;\n        }\n      tmaxx[0] = MAX(tmaxx[0],sgpar1[kj]);\n      tmaxx[1] = MAX(tmaxx[1],sgpar1[kl]);\n      tmaxx[2] = MAX(tmaxx[2],sgpar2[kj]);\n      tmaxx[3] = MAX(tmaxx[3],sgpar2[kl]);\n    }\n\n  /* Initiate parameter direction boundaries */\n  kk1    = ps1 -> ik1;\n  kn1    = ps1 -> in1;\n  st1    = ps1 -> et1;\n  sval1[0] = st1[kk1-1];\n  sval1[1] = st1[kn1];\n  kk2    = ps1 -> ik2;\n  kn2    = ps1 -> in2;\n  st2    = ps1 -> et2;\n  sval2[0] = st2[kk2-1];\n  sval2[1] = st2[kn2];\n\n  /* Initiate parameter direction boundaries */\n  kk3    = ps2 -> ik1;\n  kn3    = ps2 -> in1;\n  st3    = ps2 -> et1;\n  sval3[0] = st3[kk3-1];\n  sval3[1] = st3[kn3];\n  kk4    = ps2 -> ik2;\n  kn4    = ps2 -> in2;\n  st4    = ps2 -> et2;\n  sval4[0] = st4[kk4-1];\n  sval4[1] = st4[kn4];\n\n  tsize[0] = st1[kn1] - st1[kk1-1];\n  tsize[1] = st2[kn2] - st2[kk2-1];\n  tsize[2] = st3[kn3] - st3[kk3-1];\n  tsize[3] = st4[kn4] - st4[kk4-1];\n\n  /* Check if constant parameter value within tolerance */\n\n  for (kdir=1; kdir<=4; ++kdir)\n    {\n      if (DEQUAL((tminx[kdir-1]+tsize[kdir-1]),(tmaxx[kdir-1]+tsize[kdir-1])) )\n\t{\n\t  /* Intersection possible constant parameter line with first parameter\n\t     constant value constant.\n\n\t     1. Pick out curve from surface\n\t     2. Pick out relevant part of curve */\n\n\n\t  if (kdir == 1 || kdir == 3)\n\t    s1437((kdir<=2) ? ps1 : ps2, \n\t\t  ((tminx[kdir-1]+tmaxx[kdir-1])/(double)2.0), &qc1, &kstat);\n\t  else\n\t    s1436((kdir<=2) ? ps1 : ps2, \n\t\t  ((tminx[kdir-1]+tmaxx[kdir-1])/(double)2.0), &qc1, &kstat);\n\n\t  if (kstat < 0) goto error;\n\n\t  kdir2 = (kdir <= 2) ? ((kdir == 1) ? 2 : 1) :\n\t    ((kdir == 3) ? 4 : 3);\n\t  s1712(qc1,tminx[kdir2-1],tmaxx[kdir2-1],&qc2,&kstat);\n\t  if (kstat < 0) goto error;\n\n\t  if ((kdir <= 2 &&\n\t       pintcr->epar1[2*(pintcr->ipoint-1) + 1] < pintcr->epar1[1]) ||\n\t      (kdir > 2 &&\n\t       pintcr->epar2[2*(pintcr->ipoint-1) + 1] < pintcr->epar2[1]))\n\t    {\n\t      s1706(qc2);\n\t      turned_dir = 1;\n\t    }\n      \n\n\t  /* Copy start point of iteration in surface */\n\n\t  memcopy(snext,(kdir <= 2) ? sgpar2+2*kguide[kdir-1] :\n\t\t  sgpar1+2*kguide[kdir-1], 2, DOUBLE);\n\t}\n      else\n\tcontinue;\n\n      st = qc2 -> et;\n      kk = qc2 -> ik;\n      kn = qc2 -> in;\n\n      /* Set boundaries of surface to be iterated in */\n\n      if (kdir==3 || kdir ==4)\n\t{\n\t  sstart[0] = sval1[0];\n\t  sstart[1] = sval2[0];\n\t  send[0]   = sval1[1];\n\t  send[1]   = sval2[1];\n\t  qsurf = ps1;\n\n\t}\n      else\n\t{\n\t  sstart[0] = sval3[0];\n\t  sstart[1] = sval4[0];\n\t  send[0]   = sval3[1];\n\t  send[1]   = sval4[1];\n\t  qsurf = ps2;\n\t}\n\n      /* Allocate array for storage of points, tangents and parameter values of\n\t curve in the parameter plane of the surface we test */\n\n      if ((sp=newarray(4*kn,DOUBLE)) == SISL_NULL) goto err101;\n      if ((sv=newarray(4*kn,DOUBLE)) == SISL_NULL) goto err101;\n      if ((spar=newarray(2*kn,DOUBLE)) == SISL_NULL) goto err101;\n\n\n      /* Run through 2*kn points of the curve and check that they lie in the\n\t implicit surface by calculating the 2*kn points. */\n\n      tsumold = st[kk-1];\n\n      for (ki=0,stp=sp,stv=sv,stpar=spar ; ki <kn ; ki++)\n\t{\n\t  if (kk>1)\n\t    {\n\t      /* Make parameter value to use for calculation of curve point */\n\n\t      for (kl=1,kj=ki+1,tsum=DZERO ; kl<kk ; kl++)\n\t\ttsum += st[kj++];\n\n\t      tsum = tsum/(double)(kk-1);\n\t    }\n\t  else\n\t    tsum = st[ki];\n\n\t  tval = (tsum+tsumold)/(double)2.0;\n\n\t  for (kj=0 ; kj<2 ; kj++,stp+=2,stv+=2,stpar++)\n\t    {\n\n\t      /* Calculate point on curve */\n\n\t      s1221(qc2,1,tval,&kleft,sderc,&kstat);\n\t      if (kstat < 0) goto error;\n\n\t      /* Remember the parameter value */\n\n\t      *stpar = tval;\n\n\t      /* Find closest point on surface to sderc */\n\n\t      qpoint = newPoint(sderc,3,0);\n\t      if (qpoint==SISL_NULL) \n\t\tgoto err101;\n\n\t      /* Calculate closest point to surface */\n\n\t      s1773(qpoint,qsurf,aepsge,sstart,send,snext,stp,&kstat);\n\t      if(kstat<0) \n\t\tgoto error;\n\n\t      freePoint(qpoint);\n\n\t      /* Calculate point and derivatives in surface */\n\n\t      s1421(qsurf,kders,stp,&kleft1,&kleft2,sders,snorm,&kstat);\n\n\t      if (kstat<0) \n\t\tgoto error;\n\n\t      /* Find tangent of curve in parameter plane */\n\n\t      ta11 = s6scpr(sders+3,sders+3,3);\n\t      ta12 = s6scpr(sders+3,sders+6,3);\n\t      ta22 = s6scpr(sders+6,sders+6,3);\n\t      tb1  = s6scpr(sders+3,sderc+3,3);\n\t      tb2  = s6scpr(sders+6,sderc+3,3);\n\n\t      tdom = ta11*ta22 - ta12*ta12;\n\t      if (tdom != DZERO)\n\t\t{\n\t\t  t1 = (ta22*tb1-ta12*tb2)/tdom;\n\t\t  t2 = (ta11*tb2-ta12*tb1)/tdom;\n\n\t\t  tdom = sqrt(t1*t1+t2*t2);\n\t\t  if (tdom != DZERO)\n\t\t    {\n\t\t      t1 /= tdom;\n\t\t      t2 /= tdom;\n\t\t    }\n\t\t}\n\t      else\n\t\tt1 = t2 = DZERO;\n\n\t      /* Remember the tangent */\n\n\t      *stv     = t1;\n\t      *(stv+1) = t2;\n\n\n\t      /*Both the position of the two points should be within the relative\n\t\tcomputer resolution for the point to be accepted.\n\t\tCorrespondingly the direction of the intersection curve and the\n\t\tconstant parameter line should be within the computer\n\t\tresolution to be accepted. */\n\n\t      tdist = s6dist(sders,sderc,3);\n\t      if (tdist > aepsge)\n\t\tbreak;\n\n\t      /* if (DNEQUAL(tdist+tmax,tmax)) */\n\t      /*   goto war00; */\n\n\t      /* Distance within tolerance, check that the angle between surface\n\t\t normal and curve tangent is PIHALF, if both these vectors have a\n\t\t nonzero length. */\n\n\t      if (s6length(snorm,3,&kstat) != DZERO &&\n\t\t  s6length(sderc+3,3,&kstat) != DZERO  )\n\t\t{\n\t\t  tang = s6ang(snorm,sderc+3,3);\n\t\t  if (DNEQUAL(fabs(tang),PIHALF) ) goto war00;\n\t\t}\n\t      tval = tsum;\n\n\t      /* Remember start point of iteration */\n\n\t      memcopy(snext,stp,2,DOUBLE);\n\t    }\n\t  tsumold = tsum;\n\t}\n      if (ki < kn)\n\tcontinue;\n\n\n      /* Intersection curve along constant parameter line, make right actions\n\t concerning drawing and/or creation of the curve */\n\n      if (igraph == 1)\n\t{\n\t  /* Draw curve, first break into straight line segments */\n\n\t  s1605(qc2,aepsge,&spoint,&knbpnt,&kstat);\n\t  if (kstat < 0) goto error;\n\n\t  if (knbpnt>1)\n\t    {\n\t      /* Draw curve */\n\n\t      s6move(spoint);\n\t      for (ki=1,sp1=spoint+3 ; ki<knbpnt ; ki++,sp1+=3)\n\t\ts6line(sp1);\n\t    }\n\t  freearray(spoint);\n\t}\n\n      if (icur >= 1)\n\t{\n\t  /* Set pointer to 3-D curve */\n\n\t  if (turned_dir)\n\t    s1706(qc2);\n\t  pintcr -> pgeom = qc2;\n\t  qc2 = SISL_NULL;\n\t}\n\n      if (icur == 2)\n\t{\n\t  /* Make curves in parameter planes */\n\n\t  double svert[4],sknot[4];\n\n\n\t  /* Adjust the tangent lengths to match distance between adjacent points,\n\t     remember that first and second points are equal and that first point\n\t     is not used futher on */\n\n\t  tdistp = s6dist(sp+2,sp+4,2);\n\t  *(sv+2) *= tdistp;\n\t  *(sv+3) *= tdistp;\n\n\t  for (ki=2,stp=sp+4,stv=sv+4,kstop=kn+kn-1 ; ki < kstop ;\n\t       ki++,stp+=2,stv+=2)\n\t    {\n\t      tdistc = s6dist(stp,stp+2,2);\n\t      tfak = (tdistp+tdistc)/(double)2.0;\n\t      *stv     *= tfak,\n\t\t*(stv+1) *= tfak;\n\t      tdistp = tdistc;\n\t    }\n\t  *stv     *= tdistp;\n\t  *(stv+1) *= tdistp;\n\n\n\t  /* The first parameter pair is doubly represented */\n\n\t  stp = sp+2;\n\t  stv = sv+2;\n\t  stpar = spar+1;\n\n\t  kix1 = kdir % 2;\n\t  kix2 = 1 - kix1;\n\t  svert[kix2] = svert[kix2+2] = \n\t    (tminx[kdir-1]+tmaxx[kdir-1])/(double)2.0;\n\t  svert[kix1] = (turned_dir) ? tmaxx[kdir2-1] : tminx[kdir2-1];\n\t  svert[kix1+2] = (turned_dir) ? tminx[kdir2-1] : tmaxx[kdir2-1];\n\t  sknot[0] = sknot[1] = tminx[kdir2-1];\n\t  sknot[2] = sknot[3] = tmaxx[kdir2-1];\n\t  if (kdir <= 2)\n\t    {\n\t      qp1cur = newCurve(2,2,sknot,svert,1,2,1);\n\t      if (qp1cur==SISL_NULL) goto err101;\n\t      s1379(stp,stv,stpar,2*kn-1,2,&qp2cur,&kstat);\n\t    }\n\t  else\n\t    {\n\t      qp2cur = newCurve(2,2,sknot,svert,1,2,1);\n\t      if (qp2cur==SISL_NULL) goto err101;\n\t      s1379(stp,stv,stpar,2*kn-1,2,&qp1cur,&kstat);\n\t    }\n\t  if (kstat<0) \n\t    goto error;\n\n\t  if (turned_dir)\n\t    s1706(qp2cur);\n\n\t  pintcr -> ppar1 = qp1cur;\n\t  pintcr -> ppar2 = qp2cur;\n\t}\n      computed = 1;\n      break;  /* Curve approximated */\n    }\n\n\n  if (!computed)\n    goto war00;\n\n  *jstat = 1;\n  goto out;\n\n  /* Iteration can not continue */\n war00:  *jstat = 0;\n  goto out;\n\n\n  /* Error in space allocation */\n err101: *jstat = -101;\n  s6err(\"s1310_s9constline\",*jstat,kpos);\n  goto out;\n\n  /* Error in surface description parameter direction does not exist */\n err123: *jstat = -123;\n  s6err(\"s1310_s9constline\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower leve function */\n error:\n  *jstat = kstat;\n  s6err(\"s1310_s9constline\",*jstat,kpos);\n  goto out;\n\n out:;\n  if (qc1 != SISL_NULL) freeCurve(qc1);\n  if (qc2 != SISL_NULL) freeCurve(qc2);\n  if (sp  != SISL_NULL) freearray(sp);\n  if (sv  != SISL_NULL) freearray(sv);\n  if (spar  != SISL_NULL) freearray(spar);\n}\n"
  },
  {
    "path": "src/s1311.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1311.c,v 1.3 2001-03-19 15:58:44 afr Exp $\n *\n */\n\n\n#define S1311\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\ndouble\ns1311(double arad,double aepsge,double amax,int *jstat)\n#else\ndouble s1311(arad,aepsge,amax,jstat)\n\t     double arad;\n\t     double aepsge;\n\t     double amax;\n\t     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To make the step lenth in the iteration procedure based\n*              on radius of curvature and an absolute tolerance\n*\n*\n*\n* INPUT      : arad   - Radius of curvature\n*              aepsge - Absolute tolerance describing the deviation between\n*                       the circle of curvature and an Hermite approximation\n*                       to the circle\n*              amax   - Upper bound of absolute value of coordinates.\n*                       If amax = 0.0 is ignored and amax < 0.0 causes error.\n*\n* OUTPUT     : s1311  - Actual step length to be employed\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : First a formula giving the angle of the circle segment\n*              to be approximated by an Hermit curve within a tolerance\n*              is used. Then the arc length of this circular piece is\n*              calculated. We make sure that the step length is maximum\n*              half the radius of curvature.\n*              Two special cases might occure:\n*               - Radius of curvature 0\n*               - Radius of curvature infinit\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY :\n*\n*********************************************************************\n*/\n{\n  int    kpos=1;            /* Position of error                 */\n  double tstep;             /* Preliminary value for step length */\n  double t1sixth;           /* The value of 1/6                  */\n  double talfa;             /* Angle                             */\n\n  if (amax < DZERO) goto err177;\n\n  if (aepsge < DZERO) goto err120;\n\n  if (arad > DZERO)\n    {\n      t1sixth = (double)1.0/(double)6.0;\n      /*  Estimat the opening angle of the segments based on the error\n       *   formula. */\n      talfa = PI*pow(aepsge/arad,t1sixth)/((double)0.4879);\n\n      /*  Estimate step length equal to curve length of this circular arc,\n       *   We limit the step length to half the radius of curvature  */\n\n      tstep = MIN(fabs(talfa*arad),fabs(arad/(double)2.0));\n    }\n  else if (DEQUAL(arad,DZERO))\n    {\n      /*  Radius of curvature is zero */\n      tstep = (double)100.0*aepsge;\n    }\n\n  else\n    {\n      /*  Infinit radius of curvatur  */\n      tstep = amax;\n    }\n\n  if ( amax > DZERO && amax < tstep )\n    tstep = MAX(amax,aepsge);\n\n  tstep = MAX(tstep,aepsge);\n\n  *jstat = 0;\n  goto out;\n\n/* Negative tolerance */\n\nerr120: *jstat = -120;\n        s6err(\"s1311\",*jstat,kpos);\ngoto out;\n\n/* Maximal step length zero are less than geometry tolerance */\n\nerr177: *jstat = -177;\n        s6err(\"s1311\",*jstat,kpos);\ngoto out;\n\nout:\nreturn(tstep);\n}\n"
  },
  {
    "path": "src/s1312.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1312.c,v 1.2 2001-03-19 15:58:44 afr Exp $\n *\n */\n\n\n#define S1312\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1312(double egeo[],int idim,int inbinf,int ipar,double epar[],\n\t   SISLCurve **rcurve,int *jstat)\n#else\nvoid s1312(egeo,idim,inbinf,ipar,epar,rcurve,jstat)\n     double egeo[];\n     int    idim;\n     int    inbinf;\n     int    ipar;\n     double epar[];\n     SISLCurve  **rcurve;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To represent the curve described in egeo as\n*              an Hermit curve on a B-spline format.\n*\n*\n* INPUT      : egeo   - The geometry of the point to be interpolated\n*                       The sequence of the information for each point\n*                       is: position, unit tangent, curvature vector\n*                           and radius of curvature.\n*                       When the dimension is 2 this is 7 doubles\n*                       When the dimension is 3 this is 10 doubles\n*                       Total size of egeo is thus:\n*                        idim=2 :  7*inbinf doubles\n*                        idim=3 : 10*inbinf doubles\n*              idim   - Dimension of the spcae the points lie in\n*                       only 2 and 3 is legal\n*              inbinf - Number of points\n*              ipar   - Array telling if input parametrization (in epar)\n*                       is to be used:\n*                        ipar = 0 : Don't use input parametrization\n*                        ipar = 1 : Use input parametrization\n*\n* INPUT/OUTPUT:\n*              epar   - Parametrization of the points. ipar determines\n*                       if this is input or output\n*\n* OUTPUT     : rcurve - The curve produced\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, OSLO, Norway, 30. June 1988\n*\n*********************************************************************\n*/\n{\n  int kn;             /* Number of vertices                                 */\n  int kk = 4;         /* Order of b-spline basis                            */\n  int knt;            /* Number of knots produced so far                    */\n  int kvert;          /* Pointer to first free variable in vertex array     */\n  int kpos =1;        /* Position of error                                  */\n  int kstat;          /* Local status variable                              */\n  int ki,kj;          /* Running variables in loop                          */\n  int kv1,kv2,kv3;    /* Running variables in loop                          */\n  int kincre;         /* Number of doubles for each point in egeo           */\n  double *sprevp;     /* Pointer to position at start of current segment    */\n  double *sprevt;     /* Pointer to tangent  at start of current segment    */\n  double *sprevc;     /* Pointer to curvature at start of current segment   */\n  double *sprevr;     /* Pointer to radius of curvature start current segment*/\n  double snprevt[3];  /* Nomralized version of sprevc                       */\n  double *scurp;      /* Pointer to position at end   of current segment    */\n  double *scurt;      /* Pointer to tangent  at end   of current segment    */\n  double *scurc;      /* Pointer to curvature at end   of current segment   */\n  double *scurr;      /* Pointer to radius of curvature end  current segment*/\n  double sncurt[3];   /* Normalized version of scurc                        */\n  double tcos;        /* Description of angle                               */\n  double tl1,tl2;     /* Tangent lengths                                    */\n  double tangle;      /* Arcus cosinus if tcos                              */\n  double tdist;       /* Distance between start and end of current segment  */\n  double tpar;        /* Parameter value at end of segment                  */\n  double *st = SISL_NULL;  /* Pointer to knot vector                             */\n  double *scoef=SISL_NULL; /* Pointer to vertices                                */\n  \n  /* Allocate space for knots and vertices */\n  \n  if (idim != 2 && idim != 3) goto err105;\n  \n  if (idim==2)\n    kincre = 7;\n  else\n    kincre = 10;\n  \n  kn = 3*(inbinf-1) + 1;\n  scoef = newarray(idim*kn,DOUBLE);\n  if (scoef == SISL_NULL) goto err101;\n  \n  st = newarray(kk+kn,DOUBLE);\n  if (st == SISL_NULL) goto err101;\n  \n  /* Make four first knots */\n  if (ipar==0)\n      epar[0] = DZERO;\n  \n  st[0] = epar[0];\n  st[1] = epar[0];\n  st[2] = epar[0];\n  st[3] = epar[0];\n  \n  /* Make first vertex */\n  memcopy(scoef,egeo,idim,DOUBLE);\n  \n  \n  /* Set pointers to start point, tangent, curvature and radius of curvature */\n  \n  sprevp = egeo;\n  sprevt = sprevp + idim;\n  sprevc = sprevt + idim;\n  sprevr = sprevc + idim;\n  \n  /* Normalize curvature vector at start */\n  \n  (void)s6norm(sprevt,idim,snprevt,&kstat);\n  \n  for (ki=1,knt=4,kvert=idim;ki<inbinf;ki++)\n    {\n      \n      /* For each pair of adjacent points in egeo make an Hermit segment */\n      \n      /* Set pointers position, tangent, curvature and radius of end of\n\t current segment segment */\n      \n      scurp = sprevp + kincre;\n      scurt = sprevt + kincre;\n      scurc = sprevc + kincre;\n      scurr = sprevr + kincre;\n      \n      /*  Normalize curvature vector at end of segment */\n      \n      (void)s6norm(scurt,idim,sncurt,&kstat);\n      \n      /* Make cosine of angle between tangent vectors by making the scalar\n\t product of the normalized versions of the two vectors */\n      \n      tcos = s6scpr(snprevt,sncurt,idim);\n      \n      /* Find the actual angle by making the arcus tangens of this value */\n      \n      if (tcos >= DZERO)             \n\ttcos = MIN((double)1.0,tcos);\n      else\n\ttcos = MAX((double)-1.0,tcos);\n      \n      tangle = fabs(acos(tcos));\n      \n      if (tangle < ANGULAR_TOLERANCE) tangle = DZERO;\n      \n      tdist = s6dist(sprevp,scurp,idim);\n      \n      /*  Make tangent length of start of segment */\n      \n      if (tangle == DZERO || *sprevr <= DZERO)\n        {\n\t  /* Parallel tangents or infinit radius of curvature use 1/3 of\n\t     the distance between the points as tangent length          */\n\t  tl1 = tdist/(double)3.0;\n        }\n      else\n        {\n\t  /* Base tangent length on radius of curvature and opening angle */\n\t  tl1 = s1325(*sprevr,tangle);\n        }\n      \n      /*  Make tangent length of end of segment */\n      \n      if (DEQUAL(tangle,DZERO) || *scurr < DZERO)\n        {\n\t  /* Parallel tangents or infinit radius of curvature use 1/3 of\n\t     the distance between the points as tangent length          */\n\t  tl2 = tdist/(double)3.0;\n        }\n      else\n        {\n\t  /* Base tangent length on radius of curvature and opening angle */\n\t  tl2 = s1325(*scurr,tangle);\n        }\n      \n      /* Make sure that the tangent does not explode due to numeric errors,\n\t and make a controlled tangent when the radius is zero or almost zero*/\n      \n      if ( tl1 > tdist) tl1 = tdist/(double)3.0;\n      if ( tl2 > tdist) tl2 = tdist/(double)3.0;\n      \n      /* We want to have a parametrization that is as close as possible to an\n\t arc length parametrization */                                             \n      \n      \n      if (ipar==0)\n        {\n\t  /* Make parametrization of segment by making an average of arc of a\n\t     circle with radius sprevr and scurr spanning an angle tangle.\n\t     If one or both radius infinit use the distance between the \n\t     points */\n\t  \n\t  if (DNEQUAL(*sprevr,(double)-1.0) && \n\t      DNEQUAL(*scurr,(double)-1.0))\n            {\n\t      tpar = (double)0.5*tangle*(*sprevr+*scurr);\n            }\n\t  else if (DNEQUAL(*sprevr,(double)-1.0) && \n\t\t   DEQUAL(*scurr,(double)-1.0))\n            {\n\t      tpar = (double)0.5*(*sprevr*tangle + tdist);\n            }\n\t  else if (DEQUAL(*sprevr,(double)-1.0) && \n\t\t   DNEQUAL(*scurr,(double)-1.0))\n            {\n\t      tpar = (double)0.5*(tdist + tangle*(*scurr));\n            }\n\t  else\n            {\n\t      tpar =  tdist;\n            }\n\t  \n\t  tpar = MAX(tpar,tdist);\n\t  \n\t  if (DEQUAL((epar[ki-1]+tpar),epar[ki-1]))\n            {\n\t      tpar = fabs(epar[ki-1])*(double)0.1;\n            }\n\t  \n\t  if (DEQUAL(tpar,DZERO))\n            {\n\t      tpar = (double)1.0;\n            }\n\t  \n\t  epar[ki] = epar[ki-1] + tpar;\n\t  \n        }\n      \n      /*  Make 3 new knots */\n      st[knt]   = epar[ki];\n      st[knt+1] = epar[ki];\n      st[knt+2] = epar[ki];\n      \n      /*  Make 3 new vertices of segment */\n      \n      for (kj=0,kv1=kvert,kv2=kv1+idim,kv3=kv2+idim ; kj<idim ;\n\t   kj++,kv1++,kv2++,kv3++)\n        {\n\t  scoef[kv1] = sprevp[kj] + tl1*sprevt[kj];\n\t  scoef[kv2] = scurp[kj]  - tl2*scurt[kj];\n\t  scoef[kv3] = scurp[kj];\n        }\n      \n      /*  Update pointers */\n      sprevp = scurp;\n      sprevt = scurt;\n      sprevc = scurc;\n      sprevr = scurr;\n      for (kj=0;kj<idim;kj++) snprevt[kj] = sncurt[kj];\n      \n      /*  Only update number of vertices if epar[ki-1] != epar[ki] */ \n      \n      if (DNEQUAL(epar[ki-1],epar[ki]))\n        {\n\t  kvert+=(3*idim);\n\t  knt+=3;\n        }\n    }\n  \n  /* Insert last knot */\n  \n  st[kn+kk-1] = st[kn+kk-2];\n  \n  /* Update number of vertices */\n  \n  kn = kvert/idim;\n  \n  \n  /* Make the curve */\n  \n  kpos = 1;\n  *rcurve = SISL_NULL;\n  *rcurve = newCurve(kn,kk,st,scoef,1,idim,1);\n  if (*rcurve == SISL_NULL) goto err101;\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1312\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input, negative relative tolerance given */\n  \n err105: *jstat = -105;\n  s6err(\"s1312\",*jstat,kpos);\n  goto out;\n  \n  /* Free allocated arrays */\n out:\n  \n  \n  if (st != SISL_NULL)    freearray(st);\n  if (scoef != SISL_NULL) freearray(scoef);\n  \n  \n  return;\n}\n"
  },
  {
    "path": "src/s1313.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1313.c,v 1.12 2005-12-09 14:08:45 afr Exp $\n *\n */\n\n\n#define S1313\n\n#include \"sislP.h\"\n\n/*\n * Forward declarations.\n * ---------------------\n */\n#if defined(SISLNEEDPROTOTYPES)\nstatic void s1313_s9constline(SISLSurf *,double [],int,double,\n\t\t\t      SISLIntcurve *,int,int,int *);\n#else\nstatic void s1313_s9constline();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1313(SISLSurf *ps1,double eimpli[],int ideg,double aepsco,double aepsge,\n      double amax,SISLIntcurve *pintcr,int icur,int igraph,int *jstat)\n#else\n     void s1313(ps1,eimpli,ideg,aepsco,aepsge,amax,pintcr,icur,igraph,jstat)\n     SISLSurf     *ps1;\n     double   eimpli[];\n     int      ideg;\n     double   aepsco;\n     double   aepsge;\n     double   amax;\n     SISLIntcurve *pintcr;\n     int      icur;\n     int      igraph;\n     int      *jstat;\n#endif\n     /*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To march an intersection curve described by parameter pairs\n*              in the intersection curve, a B-spline surface and an\n*              implicit surface.\n*\n*\n* INPUT      : ps1    - Pointer to surface.\n*              eimpli - Description of the implicit surface\n*              ideg   - The degree of the implicit surface\n*                        ideg=1: Plane\n*                        ideg=2; Quadric surface\n*                        ideg=1001: Torus surface\n*                        ideg=1003: Silhouette line parallel projection\n*                        ideg=1004: Silhouette line perspective projection\n*                        ideg=1005: Silhouette line circular projection\n*              aepsco - Not used.\n*              aepsge - Geometry resolution.\n*              amax   - Not used.\n*              icur   - Indicator telling if a 3-D curve is to be made\n*                        0 - Don't make 3-D curve\n*                        1 - Make 3-D curve\n*                        2 - Make 3-D curve and curves in parameter plane\n*              igraph - Indicator telling if the curve is to be outputted\n*                       through function calls:\n*                        0 - don't output curve through function call\n*                        1 - output as straight line segments through\n*                            s6move and s6line\n*\n*\n*\n* INPUT/OUTPUT:pintcr - The intersection curve. When comming as input\n*                       only parameter values in the parameter plane\n*                       exist. When comming as output the 3-D geometry\n*                       and possibly the curve in the parameter plane\n*                       of the surface are added.\n*                       If the curves has already been generated in the\n*                       topology part of the intersections, nothing will\n*                       be done (i.e. not required).  This will be the\n*                       case when the intersection curve represents a\n*                       constant parameter line in the parmeter plane\n*                       of the surface.\n*\n* OUTPUT:      jstat  - status messages\n*                         = 3      : Iteration stopped due to singular\n*                                    point or degenerate surface. A part\n*                                    of intersection curve may have been\n*                                    traced out. If no curve is traced out\n*                                    the curve pointers in the Intcurve\n*                                    object point to SISL_NULL.\n*                         = 3      : Marching not succeded\n*                         = 0      : ok\n*                         < 0      : error\n*                         = -185   : No points produced on intersection curve.\n*\n*\n* METHOD     :\n* REFERENCES :\n*\n* HOW TO EXTEND THIS FUNCTION TO TREAT NEW PROBLEMS.\n*\n* This function is built as a general function for treating the combination\n* of an implicit description and a parametric surface, when introducing\n* new problems to be solved this structure can be utilized:\n*\n* 1. Define the implicit degree of the problem. If it is a special problem\n*    utilize ideg>1000.\n* 2. Determine how many derivatives have to be calculated to support the\n*    function. For ideg=1,2,1001 derivatives up two have been calculated.\n*    for ideg=1003,1004,1005, derivatives up to and including 3 have been calculated.\n*    The number of derivatives influence the local variables kder, ksize,\n*    ksizem3 that are found in the functions:\n*     s1306,s1309,s1313,s1331,s9clipimp,s9iterimp,s9adsimp,s9boundimp\n*\n* 3. The function s1309 branch on itype to decide the distance in the\n*    current iteration step. This function has to be updated to support\n*    the new type of problem. For ideg=1,2 and 1001 this function\n*    currently calculates distance. For ideg=1003,1004,1005 it calculates an angle.\n*\n* 4. The function s1331 that calculates derivatives of the combination of\n*    the implicit problem and the surface have to support the new problem\n*\n* 5. Look also into s9iterimp and s9boundimp to update the convergence\n*    branching on problem type.\n*\n*\n*-\n* CALLS      :\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 2. July 1988\n* Revised by : Tor Dokken, SI, Oslo, Norway, 22. January 1988,\n*               Test for degeneracy and singularities included\n* Revised by : Tor Dokken, SI, Oslo, Norway, March 1989\n*              Automatic generation of maximal step length, improved\n*              marching close to singularities\n* Revised by : Correction of error testing\n* Revised by : Mike Floater, SI, 1991-01\n*                   Improved the routine for parallel silhouettes (ideg=1003) and\n*                   added perspective and circular silhouettes (ideg=1004,ideg=1005)\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Dec. 1994.  Added check for\n*              SISL_NULL 'pintcr' and to avoid re-generating the geometry when it has\n*              already been generated in the topology part (constant curve, type 9).\n*              This fixes memory problems.\n*\n*********************************************************************\n*/\n{\n  int ki,kj,kl;            /* Control variables in for loops            */\n  int kcont;               /* Stop condition for loop                   */\n  int kk,kn;               /* Dummy variables                           */\n  int kstpch;              /* Status of iteration step                  */\n  int kpoint;              /* Number of points in guide curve           */\n  int kpar1;               /* Number of parameter direction in 1st. obj */\n  int kpar2;               /* Number of parameter direction in 2st. obj */\n  int kpar;                /* Indicater tellin if S1359 shall make\n\t\t\t      parametrization or use parametrization\n\t\t\t      in spar                                   */\n  int ktype;               /* Type of intersection curve                */\n  int klfu=0;              /* Pointers into knot vectors                */\n  int klfv=0;              /* Pointers into knot vectors                */\n  int kder = 2;            /* Calculate up to second derivatives        */\n  int kdim = 3;            /* The dimension of the space we work in     */\n  int kfirst = 0;          /* Indicator telling if first guide point degenerate */\n  int klast = 0;           /* Indicator telling if last guide point degenerate */\n  int kpos = 0;            /* Position of error                         */\n  int kstat,kstat1;        /* Status variable returned form routine     */\n  int kmaxinf=0;           /* Number of entries object that can be stored\n\t\t\t      in s3dinf, sp1inf, sp2inf                 */\n  int knbinf=0;            /* Number of entries stored so far on s3dinf,\n\t\t\t      sp1inf and sp2inf                         */\n  int kstart;              /* Start point for iteration among guide pnts*/\n  int kguide;              /* Current guide point                       */\n  int kdir;                /* March direction                           */\n  int kgdir;               /* Direction we march guide point vector     */\n  int krem,krem1,krem2;    /* Remember if we step in or out of patch    */\n  int kbound;              /* Dummy variiable                           */\n  int koutside_resolution; /* Flag telling if current seg. outside res. */\n  int ksize;               /* Number of doubles for storage of derivateves\n\t\t\t      and normal vector */\n  int ksizem3;             /* ksize - 3                                 */\n  int kdiv=0;              /* Flag remembering if iteration diverged    */\n  int knb1=0;              /* Remember number of points after marching\n\t\t\t      in first marching direction               */\n  int kgd1=0;              /* Remeber last guide point used in first\n\t\t\t      marching direction                        */\n  double *scorpnt=SISL_NULL;    /* Corrected marching points                 */\n  double *scorpar=SISL_NULL;    /* Corrected marching parameter values       */\n  double smidd[6];         /* Description of midpoint and tangent of\n\t\t\t      current Bezier segment                    */\n  double tcurstep;         /* Current step length                       */\n  double tdist;            /* Error at middle of current Bezier segement*/\n  double tang;             /* Angle error at midpoint Bezier segement   */\n  double tnew;             /* Candidate for new step length             */\n  double tfak;             /* How much is the step length to be reduced */\n  double *start;           /* Pointer to start of current segment       */\n  double *st;              /* Pointer to knot vector                    */\n  double sval1[2];         /* Limits of parameter plane in first SISLdir    */\n  double tref1,tref2;      /* Reference values for knot vectors         */\n  double sval2[2];         /* Limits of parameter plane in second SISLdir   */\n  double tstep;            /* Iteration step length                     */\n  double tmax;             /* Local maximal step length                 */\n  double tstartstp;        /* Start step length                         */\n  double trad;             /* Radius of curvature                       */\n  double tval[6];             /* Dummy array in s1331                  */\n  double *spar=SISL_NULL;       /* Parametrization of points in Hermit interp*/\n  double spar1[2];         /* Parameter pair of current point surface 1 */\n  double spar2[2];         /* Parameter pair of boundarypoint surface 1 */\n  double siparmid[2];      /* Parameter value at middle of Bezier segment*/\n  double sipar1[2];        /* Parameter pair iteration point surface  1 */\n  double simiddpnt[10];    /* Middle point and tangent of segment       */\n  double simiddpar[7];     /* Parameter value at middle point of segment*/\n  double *sgpar1=SISL_NULL;     /* Parameter pairs of guide point in surf 1  */\n  double *sgpar2=SISL_NULL;     /* Parameter pairs of guide point in surf 2  */\n  double *sgpar=SISL_NULL;      /* guide points used                         */\n  double *sgd1 = SISL_NULL;     /* 0-2 derivative of guide point + normal\n\t\t\t\t   of first object                           */\n  double spnt1[33];        /* Info on current point in first surface    */\n  double spnt2[33];        /* Info on boundary point in first surface   */\n  double sipnt1[33];       /* Info on iteration point in first surface  */\n  /* For spnt1, sipnt1, the                    */\n  /* information is stored 3-tuppels in the    */\n  /* following sequence                        */\n  /* Position, (1,0)-der, (0,1)-der,           */\n  /* (2,0)-der, (1,1)-der, (0,2)-der and normal*/\n  /* This is compatible with output of s1421   */\n  double snorm1[3];        /* Normal vector of implicit surface         */\n  double snorm2[3];        /* Normal vector of implicit surface         */\n  double startg[3];        /* Start tangent of iteration                */\n\n  double *snxt1;           /* SISLPoint in ps1 we have accepted          */\n  double *snxp1;           /* Parameter value belonging to snxt1        */\n  double *s3dinf=SISL_NULL;     /* Pointer to array used for storing 3-D position\n\t\t\t\t   tangent, curvature and radius of curvature found\n\t\t\t\t   during the marching process if possible */\n  double *sp1inf=SISL_NULL;     /* Pointer to array used for storing position\n\t\t\t\t   tangent, curvature and radius of curvature found\n\t\t\t\t   in the first parameter plane during the\n\t\t\t\t   marching process */\n  double start1[33];       /* Description of start point in ps1      */\n  double stpar1[2];        /* Parameter pair belonging to start1        */\n  double sdum1[3],sdum2[3];/* Dummy vectors                             */\n  double tdum,tdump;       /* Dummy variable                            */\n  double *sp1=SISL_NULL;        /* Pointer used when moving information      */\n  double *sp2=SISL_NULL;        /* Pointer used when moving information      */\n  double stdum[10];        /* Dummy array used when moving information  */\n  double *stang;           /* Pointer to tangent of current point       */\n  double *sptang;          /* Pointer to tangent in parameter plane     */\n  double *spoint;          /* Pointer to current point                  */\n  double t1distgd,t2distgd;/* Distances to guide points                 */\n  double tlnorm;           /* Length of normal vector                   */\n  double tltan1,tltan2;    /* Tangent lengths                           */\n  SISLCurve *q3dcur=SISL_NULL;/* Pointer to 3-D curve                     */\n  SISLCurve *qp1cur=SISL_NULL;/* Pointer to curve in first parameter plane*/\n  double sdiffcur[3];        /* Difference between current and previous point found */\n  double sdiffprev[3];        /* Difference between previous point and the one before that */\n\n\n  *jstat = 0;\n\n  if (pintcr == SISL_NULL)  goto err150;\n\n\n  /* Check if the geometry already has been generated in the topology part.\n     This will be the case if the geometry is along a constant parameter line. */\n\n  if (pintcr->itype == 9)  goto out;\n\n\n\n  /* Make maximal step length based on box-size of surface */\n\n  sh1992su(ps1,0,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  tmax = MAX(ps1->pbox->e2max[0][0] - ps1->pbox->e2min[0][0],\n\t     ps1->pbox->e2max[0][1] - ps1->pbox->e2min[0][1]);\n  tmax = MAX(tmax,ps1->pbox->e2max[0][2] - ps1->pbox->e2min[0][2]);\n\n  if (amax>DZERO) tmax = MIN(tmax,amax);\n\n\n  /* If ideg=1,2 or 1001 then only derivatives up to second order\n     are calculated, then 18 doubles for derivatives and 3 for the\n     normal vector are to be used for calculation of points in the\n     spline surface. For ideg=1003,1004,1005 we have a silhouette curve and\n     derivatives up to the third are to be calculated,\n     thus 30 +3 a total of 33 doubles are to be calculated */\n\n  if (ideg==1003 || ideg==1004 || ideg==1005)\n    {\n      kder = 3;\n      ksize = 33;\n    }\n  else\n    {\n      ksize = 21;\n      kder =2;\n    }\n  ksizem3 = ksize -3;\n\n\n  /* Find a none singular start point for the marching process */\n\n  kpoint = pintcr->ipoint;\n  kpar1  = pintcr->ipar1;\n  kpar2  = pintcr->ipar2;\n  sgpar1 = pintcr->epar1;\n  sgpar2 = pintcr->epar2;\n  ktype  = pintcr->itype;\n\n\n  /* Initiate pointers to intersection curve and intersection curve in\n     parameter plane */\n\n  pintcr -> pgeom = SISL_NULL;\n  pintcr -> ppar1 = SISL_NULL;\n  pintcr -> ppar2 = SISL_NULL;\n\n\n  /* Initiate parameter direction boundaries */\n  kk    = ps1 -> ik1;\n  kn    = ps1 -> in1;\n  st    = ps1 -> et1;\n  sval1[0] = st[kk-1];\n  sval1[1] = st[kn];\n  tref1 = (double)3.0*MAX(fabs(*sval1),fabs(*(sval1+1)));\n  kk    = ps1 -> ik2;\n  kn    = ps1 -> in2;\n  st    = ps1 -> et2;\n  sval2[0] = st[kk-1];\n  sval2[1] = st[kn];\n  tref2 = (double)3.0*MAX(fabs(*sval2),fabs(*(sval2+1)));\n\n  /* Test that first object has 2 parameter direction and second object 0*/\n\n  if (kpar1 == 2 && kpar2 == 0)\n    {\n      /*  Everithing is ok */\n      ;\n    }\n  else if (kpar1 == 0 && kpar2 == 2)\n    {\n      sgpar1 = sgpar2;\n    }\n  else\n    {\n      goto err123;\n    }\n\n  /* To support closed curve the first guide point must be copied after\n     the last guide point */\n\n  if((sgpar=newarray(2*kpoint+2,DOUBLE)) == SISL_NULL) goto err101;\n  memcopy(sgpar,sgpar1,2*kpoint,DOUBLE);\n  if (ktype ==2 || ktype == 3)\n    {\n      /* Closed curve copy first guide point to end of string of guide points */\n      memcopy(sgpar+2*kpoint,sgpar1,2,DOUBLE);\n      kpoint = kpoint + 1;\n    }\n\n  /* THE POINTS , TANGENT, CURVATURE AND RADIUS OF CURVATURE FOUND DURING\n   *  THE MARCHING PROCESS SHOULD ALL BE STORED IN ARRAYS. ALLOCATE ONE ARRAY\n   *  FOR 3-D INFORMATION AND ONE ARRAY FOR INFORMATION IN THE PARAMETER PLANE.\n   *  THESE ARRAYS ARE GIVEN AN INITIAL CAPACITY OF STORING 100 POINTS WITH\n   *  OTHER INFORMATION.\n   *  IF THEY ARE TOO SHORT THEY WILL BE REALLOCATED AT A LATER STAGE.\n   *\n   *  SINCE THE MARCHING WILL GO IN BOTH DIRECTIONS WE WILL HAVE TO TURN THE\n   *  INFORMATION FOUND WHEN MARCHING IN NEGATIVE DIRECTION, SO THAT IT CAN\n   *  BE COMBINED WITH THE INFORMATION FOUND WHEN WE ARE MARCHING IN POSITVE\n   *  DIRECTION.\n   */\n\n  kmaxinf = 100;\n  s3dinf = newarray(10*kmaxinf,DOUBLE);\n  if (s3dinf == SISL_NULL) goto err101;\n  sp1inf = newarray(7*kmaxinf,DOUBLE);\n  if (sp1inf == SISL_NULL) goto err101;\n\n  /* Evaluate 0-1-2nd. derivative + normal of all guide points in the surface,\n     first allocate arrays for storing the information, check that the points\n     have a defined normal, and that the combination of the implicit surface\n     and the surface defines a tangent direction in the curve */\n\n  sgd1 = newarray(ksize*kpoint,DOUBLE);\n  if (sgd1==SISL_NULL) goto err101;\n\n  kpos = 5;\n\n  /* Initiate kstart to point at no point */\n\n  kstart = 0;\n\n  for (ki=0,kj=0,kl=0 ; ki<kpoint ; ki++,kj+=2,kl+=ksize)\n    {\n      s1421(ps1,kder,&sgpar[kj],&klfu,&klfv,&sgd1[kl],&sgd1[kl+ksizem3],&kstat);\n      if (kstat<0) goto error;\n\n\n\n      if (ideg == 1003 || ideg == 1004 || ideg == 1005)\n\t{\n\t  /*  Find length of normal vector and tangent vectors */\n\n\t  tlnorm = s6length(&sgd1[kl+ksizem3],kdim,&kstat);\n\t  tltan1 = s6length(&sgd1[kl+kdim],kdim,&kstat);\n\t  tltan2 = s6length(&sgd1[kl+kdim+kdim],kdim,&kstat);\n\n\t  /*  The cross product satisifes the follwing conditions:\n\t      length(axb) = length(a) length(b) sin(angle(a,b)).\n\t      Thus the angle between the two vectors can be found, close to 0\n\t      sin(a) is a good approximation of a\n\t  */\n\t  if (tlnorm == (double)0.0 || tltan1 ==(double)0.0 || tltan2 == (double)0.0)\n\t    tang = (double)0.0;\n\t  else\n\t    tang = tlnorm/(tltan1*tltan2);\n\n\t  /* Silhouette line calculation no normal can be found in implicit surface\n\t     accept point as candidate start point if tang greater tha angular\n\t     resolution */\n\n\t  if (tang >= ANGULAR_TOLERANCE) kstart = ki+1;\n\t}\n      else\n\t{\n\t  /* Make direction of intersection curve */\n\n\t  s1306(&sgd1[kl],&sgpar[kj],eimpli,ideg,s3dinf,sp1inf,&kstat);\n\t  if (kstat < 0) goto error;\n\n\n\t  /* Remember if start, internal or end point */\n\n\t  if (kstat != 2)\n\t    {\n\t      if (ki == 0) kfirst = 1;\n\t      else if (ki == kpoint-1) klast = kpoint;\n\t      else  kstart = ki+1;\n\t    }\n\t}\n    }\n\n  /* Check if only degenerate points or singularities exist on the\n     intersection curve */\n\n  if (kstart == 0)\n    {\n      /*  No internal nondegenerate point exits, start marching from first\n\t  or last point if possible */\n      if (kfirst != 0 && ktype != 5 && ktype != 7) kstart = kfirst;\n      else if (klast != 0 && ktype != 6 &&\n\t       ktype != 7 && ktype != 3) kstart = klast;\n      else if (kfirst != 0) kstart = kfirst;\n      else if (klast != 0) kstart = klast;\n      else goto interpolate;\n    }\n\n  /* To speed up the marching process when many guide points are given,\n     remove guide points that are not at the start, end or the start point */\n\n  if (kpoint >2 && (kstart==1 || kstart==kpoint) )\n    {\n      /*  No internal guide point necessary, copy last point\n\t  to second point */\n\n      memcopy(sgd1+ksize,sgd1+ksize*(kpoint-1),ksize,DOUBLE);\n      memcopy(sgpar+2,sgpar+2*(kpoint-1),2,DOUBLE);\n\n      if (kstart ==  kpoint) kstart = 2;\n      kpoint = 2;\n    }\n  else if (kpoint>2)\n    {\n      /*Internal guide point exists, copy this to second position and\n\tcopy end point to third position */\n\n      memcopy(sgd1+ksize,sgd1+ksize*(kstart-1),ksize,DOUBLE);\n      memcopy(sgpar+2,sgpar+2*(kstart-1),2,DOUBLE);\n\n      memcopy(sgd1+2*ksize,sgd1+ksize*(kpoint-1),ksize,DOUBLE);\n      memcopy(sgpar+4,sgpar+2*(kpoint-1),2,DOUBLE);\n\n      kpoint = 3;\n      kstart = 2;\n    }\n\n\n\n  /* Remember description of start point in both surfaces,\n   *  copy point indicated by kstart into spnt1,spar1 */\n\n  memcopy(spnt1,sgd1+ksize*(kstart-1),ksize,DOUBLE);\n  memcopy(spar1,sgpar+2*(kstart-1),2,DOUBLE);\n\n  /* Make position, unit tangent, curvature and radius of curvature for\n   *  start point of iteration, store them in the arrays just allocated */\n\n  kpos = 10;\n  s1306(spnt1,spar1,eimpli,ideg,s3dinf,sp1inf,&kstat);\n\n  if (kstat<0) goto error;\n\n  /* Test if singular point reached */\n\n  if (kstat == 2) goto war03;\n\n  /* Remember start tangent */\n  memcopy(startg,s3dinf+3,3,DOUBLE);\n\n\n  /* Iterate intersection point down to the intersection curve */\n\n  tstep = DZERO;\n  s9iterimp(s3dinf,spnt1,spar1,ps1,eimpli,ideg,tstep,\n\t    aepsge,sipnt1,sipar1,&kstat);\n  if (kstat < 0) goto error;\n\n  if (kstat==0 && s6dist(spnt1,sipnt1,3) > aepsge)\n    {\n\n      /* Nonsingular point found and adjustment greater than aepsge,\n\t copy result of iteration into spnt1,spar1 */\n\n      memcopy(spnt1,sipnt1,ksize,DOUBLE);\n      memcopy(spar1,sipar1,2,DOUBLE);\n    }\n\n  /* Remember start point */\n\n  if (kstat==0)\n    {\n      memcopy(start1,sipnt1,ksize,DOUBLE);\n      memcopy(stpar1,sipar1,2,DOUBLE);\n    }\n  else\n    {\n      memcopy(start1,spnt1,ksize,DOUBLE);\n      memcopy(stpar1,spar1,2,DOUBLE);\n    }\n\n  /* Make position, unit tangent, curvature and radius of curvature for\n     start point of iteration, store them in the arrays just allocated */\n\n  kpos = 10;\n  s1306(start1,stpar1,eimpli,ideg,s3dinf,sp1inf,&kstat);\n\n  if (kstat<0) goto error;\n\n\n  /* Test if singular point reached */\n\n  if (kstat == 2) goto war03;\n\n  /* Remember that start point is already stored */\n\n  knbinf = 1;\n\n  /* Make step length based on 3-D radius of curvature, tolerances and\n     maks step length */\n\n  kpos = 20;\n  tstep = s1311(s3dinf[9],aepsge,tmax,&kstat);\n  if (kstat<0) goto error;\n  tstartstp = tstep;\n\n  /* STEP IN BOTH DIRECTIONS FROM THE FOUND START POINT */\n\n  /* Indicate that direction in guide point array not determined */\n  kguide = kstart;\n  kgdir = 0;\n\n  for (kdir=1;kdir<3;kdir++)\n    {\n\n      if (kdir == 2)\n\t{\n\n\t  /* Remember result of marching in first direction */\n\n\t  knb1 = knbinf;\n\t  kgd1 = kguide;\n\n\n\t  /* If the previous step direction made no points then knbinf==0. To\n\t     enable the marching we start from the same start point as the\n\t     previous step direction, thus in this case knbinf should be 1. */\n\n\t  knbinf = MAX(1,knbinf);\n\n\t  /* We now step in the second step direction. Turn the sequence of\n\t     the points found as well as change tangent directions */\n\n\t  /* First interchange 3-D info */\n\n\t  for (sp1=s3dinf,sp2=s3dinf+10*(knbinf-1) ; sp1<sp2 ; sp1+=10,sp2-=10)\n\t    {\n\t      memcopy(stdum,sp1,  10,DOUBLE);\n\t      memcopy(sp1  ,sp2,  10,DOUBLE);\n\t      memcopy(sp2  ,stdum,10,DOUBLE);\n\t    }\n\n\t  for (sp1=s3dinf+3;sp1<s3dinf+10*knbinf;sp1+=10)\n\t    {\n\t      sp1[0] = - sp1[0];\n\t      sp1[1] = - sp1[1];\n\t      sp1[2] = - sp1[2];\n\t    }\n\n\t  /* Then interchange info in parameter plane */\n\n\t  for (sp1=sp1inf,sp2=sp1inf+7*(knbinf-1) ; sp1<sp2 ; sp1+=7,sp2-=7)\n\t    {\n\t      memcopy(stdum,sp1  ,7,DOUBLE);\n\t      memcopy(sp1  ,sp2  ,7,DOUBLE);\n\t      memcopy(sp2  ,stdum,7,DOUBLE);\n\t    }\n\n\t  for (sp1=sp1inf+2;sp1<sp1inf+7*knbinf;sp1+=7)\n\t    {\n\t      sp1[0] = - sp1[0];\n\t      sp1[1] = - sp1[1];\n/* \t      sp1[2] = - sp1[2]; */\n\t    }\n\n\t  /* Turn direction of remembered start tangent */\n\n\t  for (ki=0;ki<3;ki++)\n\t    startg[ki] = -startg[ki];\n\n\n\t  /* Update spnt1 and  spar1 to have the start point values */\n\n\t  memcopy(spnt1,start1,ksize,DOUBLE);\n\t  memcopy(spar1,stpar1,2,DOUBLE);\n\n\t  /* Turn the direction we march the guide point vector, and set current\n\t     guide point to kstart */\n\n\t  kgdir  = -kgdir;\n\t  kguide = kstart;\n\n\t  /*      Update step length */\n\t  tstep = tstartstp;\n\t}\n\n\n      stang = s3dinf + 10*(knbinf-1) + 3;\n      kpos = 30;\n\n      /* Step direction ok, perform marching until stop condition reached */\n\n      kcont = 1;\n\n      while (kcont)\n\t{\n\n\t  /* We must make sure that we are not stepping past a guide point.\n\t   * Thus if we get close to a guide point, make sure that we step\n\t   * through this. The direction we travers the guide point array\n\t   * might not have been determined yet. Thus we have to test in\n\t   * both directions in guide point array.\n\t   *\n\t   * Remember how we step in the varaible kstpch:\n\t   *   kstpch = -1 : Try to step to previous guide point\n\t   *   kstpch =  0 : Try not to step through guide point\n\t   *   kstpch =  1 : Try to step to next guide point\n\t   *   kstpch =  3 : Step to start point and stop marching\n\t   *   kstpch =  4 : Don't step through guide point, candidate\n\t   *                 end point of segement found in iteration loop\n\t   */\n\n\n\t  kstpch = 0;\n\t  stang = s3dinf + 10*(knbinf-1) + 3;\n\t  sptang = sp1inf + 7*(knbinf-1) + 2;\n\t  if (kgdir >=0)\n\t    {\n\n\t      /*  We are stepping in positive direction in guide point vector\n\t       *  calculate distance to next guide point. If the guide point\n\t       *  is lying closer than the step length to the current point\n\t       *  we should step directly to this point provided that the cross\n\t       *  product of the normal vectors at current point and at the\n\t       *  guide point have the same direction, e.g. that their scalar\n\t       *  product is positiv                          */\n\n\t      t1distgd = (double)2.0*tstep;\n\t      if (kguide < kpoint)\n\t\t{\n\t\t  /* Decide if we should step through the guide point */\n\n\t\t  kpos = 40;\n\t\t  t1distgd = s9adsimp(spnt1,spar1,eimpli,ideg,\n\t\t\t\t      &sgd1[kguide*ksize],\n\t\t\t\t      &sgpar[kguide*2],\n\t\t\t\t      stang,sptang,tstep,&kstat);\n\t\t  if (kstat < 0) goto error;\n\t\t  if (kstat == 1)\n\t\t    {\n\t\t      /* Step through guide point remember this */\n\n\t\t      kstpch = 1;\n\t\t      snxt1 = sgd1 + ksize*kguide;\n\t\t      snxp1 = sgpar + 2*kguide;\n\t\t      tstep = MIN(tstep,t1distgd);\n\t\t    }\n\t\t}\n\t    }\n\n\t  if (kgdir <=0)\n\t    {\n\n\t      /* We are stepping in negative direction in guide point vector\n\t       * calculate distance to previous guide point. If the guide point\n\t       * is lying closer than the step length to the current point\n\t       * we should step directly to this point provided that the cross\n\t       * product of the normal vectors at current point and at the\n\t       * guide point have the same direction, e.g. that their scalar\n\t       * product is positiv                          */\n\n\t      if (1 < kguide)\n\t\t{\n\t\t  /* Decide if we should step through the guide point */\n\n\t\t  kpos = 50;\n\t\t  t2distgd = s9adsimp(spnt1,spar1,eimpli,ideg,\n\t\t\t\t      &sgd1[(kguide-2)*ksize],&sgpar[2*kguide-4],\n\t\t\t\t      stang,sptang,tstep,&kstat);\n\t\t  if (kstat<0) goto error;\n\t\t  if ((kstat == 1 &&kstpch == 0) ||\n\t\t      (kstat == 1 && kstpch == 1 && t2distgd < t1distgd))\n\t\t    {\n\t\t      /* Step through guide point remember this */\n\n\t\t      kstpch = -1;\n\t\t      snxt1 = sgd1 + ksize*(kguide-2);\n\t\t      snxp1 = sgpar + 2*(kguide-2);\n\t\t      tstep = MIN(tstep,t2distgd);\n\t\t    }\n\t\t}\n\t    }\n\n\t  /* Check if we step through the start point. Should only be done if at least\n\t     three points found in this marching direction, a full closed curve will\n\t     require 6 segments. */\n\t  if ((kdir==1 && knbinf>3) || (kdir==2 && knbinf>knb1+3))\n\t    {\n\n\t      kpos = 60;\n\t      tdum = s9adsimp(spnt1,spar1,eimpli,ideg,start1,stpar1,stang,sptang,\n\t\t\t      tstep,&kstat);\n\t      if (kstat < 0) goto error;\n\t      if (kstat == 1)\n\t\t{\n\t\t  /* Step to start point remember this */\n\n\t\t  kstpch = 3;\n\t\t  snxt1 = start1;\n\t\t  snxp1 = stpar1;\n\t\t  tstep = MIN(tstep,tdum);\n\t\t}\n\t    }\n\n\n\t  /* At this stage kstpch=0 if we have not reached a guide point or\n\t     if we have not reached the start point of the iteration.\n\n\t     Now we want to find a Bezier segement that is lying within the\n\t     geometric tolerance that is approximating the intersection curve.\n\t     If a guide point is reached (kstpch=-1 or 1), then we have a\n\t     candidate for the end point of the Bezier segement. If the start\n\t     point is reached (kstpch=3) then we also have a candidate end point\n\t     for the segment.\n\n\t     The next loop use kstpch to indicate if we have a candidate\n\t     end point for the segment:\n\n\t     kstpch==0  :  No candidate end point exists\n\t     kstpch!=0  :  Candidate end point exists\n\n\n\t     To indicate if the segement is within the resolution we\n\t     use koutside_resolution:\n\n\t     koutside_resolution==0 : Segment outside resolution\n\t     koutside_resolution!=0 : Segment inside resolution\n\t  */\n\n\t  koutside_resolution = 0;\n\n\t  /* Make sure that there is enough space for one more point */\n\t  if (knbinf>=kmaxinf)\n\t    {\n\t      kmaxinf = kmaxinf + 100;\n\t      s3dinf = increasearray(s3dinf,((3*kdim+1)*kmaxinf),DOUBLE);\n\t      if (s3dinf==SISL_NULL) goto err101;\n\t      sp1inf = increasearray(sp1inf,7*kmaxinf,DOUBLE);\n\t      if (sp1inf==SISL_NULL) goto err101;\n\t    }\n\n\t  /* Make description of candidate endpoint if it exists and store it */\n\n\t  if (kstpch != 0)\n\t    {\n\t      s1306(snxt1,snxp1,eimpli,ideg,s3dinf+10*knbinf,\n\t\t    sp1inf+7*knbinf,&kstat);\n\t      if (kstat<0) goto error;\n\n\t      /* It is allowed to jump on to a singular point */\n\n\t      /* Make sure that the tangents of previous and the\n\t\t candidate end point point in the same direction */\n\n\t      if (knbinf>0)\n\t\ttdum = s6scpr(s3dinf+10*(knbinf-1)+3,\n\t\t\t      s3dinf+10*knbinf+3,kdim);\n\t      else\n\t\ttdum = s6scpr(startg,s3dinf+3,kdim);\n\n\n\t      if (tdum < DZERO)\n\t\t{\n\t\t  /* Change tangent direction 3-D and in parameter plane */\n\t\t  sp1 = s3dinf + 10*knbinf + 3;\n\t\t  sp1[0] = -sp1[0];\n\t\t  sp1[1] = -sp1[1];\n\t\t  sp1[2] = -sp1[2];\n\t\t  sp1 = sp1inf + 7*knbinf + 2;\n\t\t  sp1[0] = -sp1[0];\n\t\t  sp1[1] = -sp1[1];\n\t\t}\n\n\t      /* Copy the candidate point to spnt2 and spar2 */\n\n\t      memcopy(spnt2,snxt1,ksize,DOUBLE);\n\t      memcopy(spar2,snxp1,2,DOUBLE);\n\t    }\n\n\t  while (kstpch == 0 || koutside_resolution == 0)\n\t    {\n\t      spoint = s3dinf + 10*(knbinf-1);  // To avoid confusing valgrind\n\t      if (kstpch!=0)\n\t\t{\n\t\t  /* Candidate end point exist, iterate to find point close\n\t\t     to the midpoint of the Bezier segement */\n\n\n\t\t  /* Decide if Hermit shape acceptable and find position and\n\t\t     tangent at midpoint of segment */\n\n\t\t  start = s3dinf + 10*(knbinf-1);\n\n\t\t  s1361(start,start+10,3,smidd,smidd+3,&kstat);\n\t\t  if (kstat<0) goto error;\n\n\t\t  tcurstep = DZERO;\n\t\t  spoint = smidd;\n\t\t}\n\t      else\n\t\t{\n\n\t\t  /* Iterate to find end point of segment */\n\n\t\t  /* ITERATE by intersecting the two surface and the plane\n\t\t   * defined by current point (s3dinf), the tangent (s3dinf+3)\n\t\t   * and the step length */\n\n\t\t  spoint = s3dinf + 10*(knbinf-1);\n\t\t  tcurstep = tstep;\n\t\t}\n\n\t      /*  Perform the actual iteration */\n\n\t      kpos = 70;\n\t      s9iterimp(spoint,spnt1,spar1,ps1,eimpli,ideg,tcurstep,\n\t\t\taepsge,sipnt1,sipar1,&kstat);\n\t      if (kstat < 0) goto error;\n\n\t      /*             Initiate distance between midpoint and iteration point\n\t\t\t     to -1 to enable detection of divergence */\n\n\t      tdist = -1;\n\n\t      /*  Check if iteration has converged        */\n\n\t      if (kstat == 2)\n\t\t{\n\t\t  /*  Iteration has diverged, half step length if possible,\n\t\t      find new endpoint of segement. */\n\n\t\t  kstpch = 0;\n\t\t  koutside_resolution = 0;\n\t\t}\n\t      else if(kstat == 1 && kstpch != 0)\n\t\t{\n\t\t  /* The point found is closer to the input point than\n\t\t     the relative computer resolution or is a singular point.\n\t\t     Half step length if possible, find new endpoint of\n\t\t     segement. */\n\n\t\t  kstpch = 0;\n\t\t  koutside_resolution = 0;\n\t\t}\n\t      else if (kstpch!=0)\n\t\t{\n\n\n\t\t  /*  Make description of intersection point */\n\n\t\t  s1306(sipnt1,sipar1,eimpli,ideg,simiddpnt,simiddpar,&kstat);\n\t\t  if (kstat<0) goto error;\n\n\t\t  if (kstat != 2)\n\t\t    {\n\t\t      /* We iterated to find midpoint of segment, test if\n\t\t\t it is within resolution */\n\n\t\t      tdist = s6dist(simiddpnt,smidd,3);\n\t\t      tang  = s6ang(simiddpnt+3,smidd+3,3);\n\t\t    }\n\n\t\t  /* If point is singular or not within resolution a new\n\t\t     Hermit segment has to be made */\n\n\t\t  if (kstat == 2 || (fabs(tdist) > aepsge ||\n\t\t\t\t     (fabs(tang) > ANGULAR_TOLERANCE && tstep>aepsge)))\n\t\t    {\n\t\t      kstpch = 0;\n\t\t      koutside_resolution = 0;\n\t\t    }\n\t\t  else\n\t\t    {\n\t\t      /* Segment within tolerance.\n\t\t       * Check that the relationship between the two surfaces\n\t\t       * has not been interchanged, by making the cross product\n\t\t       * of the normal vectors in current point and the point\n\t\t       * found by iteration. Then make the scalar product of\n\t\t       * these vectors. If the scalar product is negative then\n\t\t       * we have either jumped to another branch or passed a\n\t\t       * singularity, iterprete this as the iteration has diverged\n\t\t       * In addition we don't want the direction of the tangents\n\t\t       * change to much. We set a limit of approximately 41 degrees\n\t\t       * by testing on a cosin value of 0.75\n\t\t       * Make normal vectors in implicit surface for both points\n\t\t       * Make also sure that the curve in the parameter plane\n\t\t       * does not turn more than 90 degrees.\n\t\t       */\n\n\t\t      s1331(spnt1,eimpli,ideg,-1,tval,snorm1,&kstat);\n\t\t      if (kstat < 0) goto error;\n\t\t      s1331(spnt2,eimpli,ideg,-1,tval,snorm2,&kstat);\n\t\t      if (kstat < 0) goto error;\n\n\t\t      if(ideg == 1003 || ideg == 1004 || ideg == 1005)\n\t\t\t{\n\t\t\t  tdum = s6scpr(snorm1,snorm2,kdim);\n\t\t\t}\n\t\t      else\n\t\t\t{\n\t\t\t  s6crss(spnt1+ksizem3,snorm1,sdum1);\n\t\t\t  (void)s6norm(sdum1,kdim,sdum1,&kstat);\n\t\t\t  if (kstat < 0) goto error;\n\t\t\t  s6crss(sipnt1+ksizem3,snorm2,sdum2);\n\t\t\t  (void)s6norm(sdum2,kdim,sdum2,&kstat);\n\t\t\t  if (kstat < 0) goto error;\n\t\t\t  tdum = s6scpr(sdum1,sdum2,kdim);\n\t\t\t}\n\n\t\t      s6diff(spar2,spar1,2,sdum1);\n\t\t      tdump = s6scpr(sdum1,sp1inf+7*(knbinf-1)+2,2);\n\t\t      /* The test below was added to detect the case when the\n\t\t\t normal of the parametric surface turns */\n\t\t      if(s6scpr(spnt1+ksizem3,sipnt1+ksizem3,kdim) < 0.0)\n\t\t\t{\n\t\t\t  tdum = -tdum;\n\t\t\t}\n\t\t      if (tdum == DZERO)\n\t\t\t{\n\t\t\t  double tl1,tl2;\n\n\t\t\t  /* If one of the tangents have zero length, accept\n\t\t\t     segment */\n\n\t\t\t  tl1 = s6length(sdum1,kdim,&kstat);\n\t\t\t  tl2 = s6length(sdum2,kdim,&kstat);\n\n\t\t\t  if (tl1 == DZERO || tl2 == DZERO)\n\t\t\t    koutside_resolution = 1;\n\t\t\t  else\n\t\t\t    {\n\t\t\t      /* Find new end point of segment */\n\t\t\t      koutside_resolution = 0;\n\t\t\t      kstpch = 0;\n\t\t\t    }\n\n\t\t\t}\n\t\t      /*else if (tdum <= (double)0.75 || tdump <= (double)0.0)*/\n\t\t      else if (tdum <= (double)0.75 || tdump <= -REL_PAR_RES)\n\t\t\t{\n\t\t\t  /* Find new end point of segment */\n\t\t\t  koutside_resolution = 0;\n\t\t\t  kstpch = 0;\n\t\t\t}\n\t\t      else\n\t\t\t{\n\t\t\t  koutside_resolution = 1;\n\t\t\t}\n\t\t    }\n\t\t}\n\t      else\n\t\t{\n\t\t  /* We iterated to find end point of segment, update pointer */\n\n\t\t  memcopy(spnt2,sipnt1,ksize,DOUBLE);\n\t\t  memcopy(spar2,sipar1,2,DOUBLE);\n\n\t\t  s1306(sipnt1,sipar1,eimpli,ideg,s3dinf+10*knbinf,\n\t\t\tsp1inf+7*knbinf,&kstat);\n\t\t  if (kstat<0) goto error;\n\n\t\t  /* Make sure that the tangents of previous and the new point\n\t\t     point in the same direction, singular end point allowed */\n\n\t\t  if (knbinf>0)\n\t\t    tdum = s6scpr(s3dinf+10*(knbinf-1)+3,\n\t\t\t\t  s3dinf+10*knbinf+3,kdim);\n\t\t  else\n\t\t    tdum = s6scpr(startg,s3dinf+3,kdim);\n\n\n\t\t  if (tdum < DZERO)\n\t\t    {\n\t\t      /* Change tangent direction 3-D and in parameter plane */\n\t\t      sp1 = s3dinf + 10*knbinf + 3;\n\t\t      sp1[0] = -sp1[0];\n\t\t      sp1[1] = -sp1[1];\n\t\t      sp1[2] = -sp1[2];\n\t\t      sp1 = sp1inf + 7*knbinf + 2;\n\t\t      sp1[0] = -sp1[0];\n\t\t      sp1[1] = -sp1[1];\n\t\t    }\n\n\t\t  /* Indicate that end point accepted */\n\n\t\t  kstpch = 4;\n\t\t  koutside_resolution = 0;\n\t\t}\n\n\t      /* If the segment is accepted. check if we cross the\n\t\t boundary of the patch  */\n\n\t      if (kstpch !=0 && koutside_resolution == 1)\n\t\t{\n\n\t\t  /*               Check if curve between start and endpoint cross the\n\t\t\t\t   boundary */\n\n\t\t  memcopy(siparmid,sipar1,2,double);\n\n\t\t  s1305(spar1,spar2,sval1,sval2,&kbound,sipar1,&kstat);\n\t\t  if (kstat<0) goto error;\n\n\n\t\t  if(kstat==0 || kstat==4)\n\t\t    {\n\t\t      /* Set pointer to tangents at start point */\n\t\t      ki = 7*(knbinf-1)+2;\n\n\t\t      if( (DEQUAL(spar1[1]+tref2,sval2[0]+tref2) && sp1inf[ki+1]>DZERO) ||\n\t\t\t  (DEQUAL(spar1[1]+tref2,sval2[1]+tref2) && sp1inf[ki+1]<DZERO) ||\n\t\t\t  (DEQUAL(spar1[0]+tref1,sval1[0]+tref1) && sp1inf[ki]>DZERO) ||\n\t\t\t  (DEQUAL(spar1[0]+tref1,sval1[1]+tref1) && sp1inf[ki]<DZERO)\n\n\t\t\t  )\n\t\t\tkstat = 1;\n\t\t    }\n\t\t  krem1 = kstat;\n\n\n\n\t\t  /*               Check if curve between start and  midd point cross the\n\t\t\t\t   boundary */\n\n\t\t  s1305(spar1,siparmid,sval1,sval2,&kbound,sipar1,&kstat);\n\t\t  if (kstat<0) goto error;\n\t\t  krem2 = kstat;\n\n\t\t  /* We now have the following cases:\n\t\t     kstat == 0 : Line between epar1 and epar2 outside,\n\t\t     If this happens when kdir=1, then\n\t\t     just forget the start point. If it happens\n\t\t     when kdir=2, then we just stop the marching.\n\t\t     kstat == 1 : Line between epar1 and epar2 inside.\n\t\t     Continue iteration.\n\t\t     kstat == 2 : We step out of the patch. Clip to the edge\n\t\t     of the patch. Update start point.\n\t\t     kstat == 3 : We step into the patch. Clip to the edge\n\t\t     of the patch. Update endpoint\n\t\t     kstat == 4 : We go from the boundary and out. Try next\n\t\t     iteration direction.\n\n\t\t  */\n\t\t  if (krem1==0 || krem2==0)\n\t\t    {\n\t\t      if (kdir==1) knbinf--;\n\t\t      goto nextdir;\n\t\t    }\n\t\t  else if ((krem1 !=1 || krem2 !=1) && krem1 != 4 && krem2 !=4)\n\t\t    {\n\n\t\t      /* If we clip to the boundary, forget any guide point\n\t\t\t identified. The actual action is dependent on which\n\t\t\t of the points spar2 or sipar1 indicates the crossing */\n\n\t\t      kstat1 = 0;\n\t\t      if (krem2==2 || krem2==3)\n\t\t\t{\n\t\t\t  s9clipimp(spar1,siparmid,ps1,eimpli,ideg,sval1,sval2,\n\t\t\t\t    aepsge,sipnt1,sipar1,&kstat);\n\t\t\t  if (kstat<0) goto error;\n\t\t\t  if (krem2==3 && kstat==1) kstpch = 4;\n\t\t\t  kstat1 = kstat;\n\t\t\t  krem = krem2;\n\t\t\t}\n\t\t      if (kstat1 != 1 && (krem1 ==2 || krem1==3))\n\t\t\t{\n\t\t\t  s9clipimp(spar1,spar2,ps1,eimpli,ideg,sval1,sval2,\n\t\t\t\t    aepsge,sipnt1,sipar1,&kstat);\n\t\t\t  if (kstat<0) goto error;\n\t\t\t  if (krem1==3 && kstat==1) kstpch = 4;\n\t\t\t  kstat1 = kstat;\n\t\t\t  krem = krem1;\n\t\t\t}\n\n\t\t      if (kstat1 == 1)\n\t\t\t{\n\t\t\t  /* Check that the relationship between the two surfaces\n\t\t\t   * has not been interchanged, by making the cross product\n\t\t\t   * of the normal vectors in current point and the point\n\t\t\t   * found by iteration. Then make the scalar product of\n\t\t\t   * these vectors. If the scalar product is negative then\n\t\t\t   * we have either jumped to another branch or passed a\n\t\t\t   * singularity, iterprete this as the iteration has diverged\n\t\t\t   * In addition we don't want the direction of the tangents\n\t\t\t   * change to much. We set a limit of approximately 41 degrees\n\t\t\t   * by testing on a cosin value of 0.75\n\t\t\t   * Make normal vectors in implicit surface for both points\n\t\t\t   * Make also sure that the curve in the parameter plane\n\t\t\t   * does not turn more than 90 degrees.\n\t\t\t   */\n\n\t\t\t  s1331(spnt1,eimpli,ideg,-1,tval,snorm1,&kstat);\n\t\t\t  if (kstat < 0) goto error;\n\t\t\t  s1331(sipnt1,eimpli,ideg,-1,tval,snorm2,&kstat);\n\t\t\t  if (kstat < 0) goto error;\n\n\t\t\t  if(ideg == 1003 || ideg == 1004 || ideg == 1005)\n\t\t\t    {\n\t\t\t      tdum = s6scpr(snorm1,snorm2,kdim);\n\t\t\t    }\n\t\t\t  else\n\t\t\t    {\n\t\t\t      s6crss(spnt1+ksizem3,snorm1,sdum1);\n\t\t\t      (void)s6norm(sdum1,kdim,sdum1,&kstat);\n\t\t\t      if (kstat < 0) goto error;\n\t\t\t      s6crss(sipnt1+ksizem3,snorm2,sdum2);\n\t\t\t      (void)s6norm(sdum2,kdim,sdum2,&kstat);\n\t\t\t      if (kstat < 0) goto error;\n\n\t\t\t      tdum = s6scpr(sdum1,sdum2,kdim);\n\t\t\t    }\n\n\n\t\t\t  /* Check that sipar1 lies on the same side of spar1 as\n\t\t\t     the tangent at spar1 */\n\n\t\t\t  s6diff(sipar1,spar1,2,sdum1);\n\t\t\t  tdump = s6scpr(sdum1,sp1inf+7*(knbinf-1)+2,2);\n\t\t\t  /* The test below was added to detect the case when the\n\t\t\t     normal of the parametric surface turns */\n\t\t\t  if(s6scpr(spnt1+ksizem3,sipnt1+ksizem3,kdim) < 0.0)\n\t\t\t    {\n\t\t\t      tdum = -tdum;\n\t\t\t    }\n\t\t\t}\n\n\t\t      /* An intersection point has only been found when kstat==1\n\t\t       */\n\t\t      if (kstat1==1 && tdump >= (double)0.0 && tdum > (double)0.75)\n\t\t\t{\n\t\t\t  /* If krem=3 we step into the patch, if krem=2 we step\n\t\t\t     out of the patch */\n\n\t\t\t  if (krem==2 || krem==3)\n\t\t\t    {\n\t\t\t      /* Since we clip, set kstpch=0, no guide point reached */\n\n\t\t\t      /* If krem==3 we step into the patch, make new\n\t\t\t\t start point of segment */\n\n\t\t\t      if (krem==3) knbinf--;\n\n\t\t\t      memcopy(spnt2,sipnt1,ksize,DOUBLE);\n\t\t\t      memcopy(spar2,sipar1,2,DOUBLE);\n\n\t\t\t      s1306(sipnt1,sipar1,eimpli,ideg,s3dinf+10*knbinf,\n\t\t\t\t    sp1inf+7*knbinf,&kstat);\n\t\t\t      if (kstat<0) goto error;\n\n\n\t\t\t      /* Make sure that the tangents of previous and the new point\n\t\t\t\t point in the same direction */\n\n\t\t\t      if (knbinf>0)\n\t\t\t\ttdum = s6scpr(s3dinf+10*(knbinf-1)+3,\n\t\t\t\t\t      s3dinf+10*knbinf+3,kdim);\n\t\t\t      else\n\t\t\t\ttdum = s6scpr(startg,s3dinf+3,kdim);\n\n\n\t\t\t      if (tdum < DZERO)\n\t\t\t\t{\n\t\t\t\t  /* Change tangent direction 3-D and in\n\t\t\t\t     parameter plane\n\t\t\t\t  */\n\t\t\t\t  sp1 = s3dinf + 10*knbinf + 3;\n\t\t\t\t  sp1[0] = -sp1[0];\n\t\t\t\t  sp1[1] = -sp1[1];\n\t\t\t\t  sp1[2] = -sp1[2];\n\t\t\t\t  sp1 = sp1inf + 7*knbinf + 2;\n\t\t\t\t  sp1[0] = -sp1[0];\n\t\t\t\t  sp1[1] = -sp1[1];\n\t\t\t\t}\n\n\t\t\t      /* If the new end point tangent points out go\n\t\t\t\t to next direction */\n\n\t\t\t      ki = 7*knbinf;\n\t\t\t      if( (sp1inf[ki+1] <= sval2[0] && sp1inf[ki+3] < DZERO) ||\n\t\t\t\t  (sp1inf[ki+1] >= sval2[1] && sp1inf[ki+3] > DZERO) ||\n\t\t\t\t  (sp1inf[ki  ] <= sval1[0] && sp1inf[ki+2] < DZERO) ||\n\t\t\t\t  (sp1inf[ki  ] >= sval1[1] && sp1inf[ki+2] > DZERO)   )\n\t\t\t\t{\n\t\t\t\t  knbinf++;\n\t\t\t\t  goto nextdir;\n\t\t\t\t}\n\t\t\t      else if(krem == 2 &&\n\t\t\t\t      ((sp1inf[ki+1] <= sval2[0] && sp1inf[ki+3] >= DZERO) ||\n\t\t\t\t       (sp1inf[ki+1] >= sval2[1] && sp1inf[ki+3] <= DZERO) ||\n\t\t\t\t       (sp1inf[ki  ] <= sval1[0] && sp1inf[ki+2] >= DZERO) ||\n\t\t\t\t       (sp1inf[ki  ] >= sval1[1] && sp1inf[ki+2] <=DZERO)    ))\n\t\t\t\t{\n\t\t\t\t  /* We were marching out ou the patch, but the tangent\n\t\t\t\t     points in, half step length */\n\t\t\t\t  kstpch = 0;\n\t\t\t\t}\n\n\n\n\t\t\t    }\n\t\t\t}\n\n\t\t      else\n\t\t\t{\n\t\t\t  /* Divergence or point on wrong side in the parameter\n\t\t\t     plane or 3-d */\n\t\t\t  kstpch = 0;\n\t\t\t  koutside_resolution = 0;\n\t\t\t}\n\t\t    }\n\t\t  else if (krem1==4 || krem2==4)\n\t\t    goto nextdir;\n\n\t\t}\n\n\t      /* Update step length if new endpoint is to be found */\n\n\t      if (kstpch==0)\n\t\t{\n\t\t  if (tdist<DZERO)\n\t\t    {\n\t\t      tnew = tstep/(double)10.0;\n\t\t    }\n\t\t  else\n\t\t    {\n\t\t      tfak = MAX(tdist/aepsge,(double)1.0);\n\t\t      tfak = (double)2.0*pow(tfak,ONE_FOURTH);\n\t\t      tnew = MIN(tstep/(double)2.0,tstep/tfak);\n\t\t    }\n\t\t  if (DEQUAL(tmax+tnew,tmax+tstep)) goto nextdir;\n\t\t  tstep = tnew;\n\t\t}\n\t    }\n\n\t  /* If kstpch= -1,1,3 or 4 then a point is accepted and\n\t   * snxt1 points to the position and derivatives\n\t   * of the accepted point. */\n\n\t  /* If we have accepted a segment pointing in the opposite\n\t   * direction of the previous segment, something very wrong\n\t   * has happened, and we go out with an error. */\n\t  if (knbinf >= 2)\n\t    {\n\t      s6diff(s3dinf + 10*knbinf, s3dinf + 10*(knbinf - 1), kdim, sdiffcur);\n\t      s6diff(s3dinf + 10*(knbinf-1), s3dinf + 10*(knbinf - 2), kdim, sdiffprev);\n\t      if (s6scpr(sdiffcur, sdiffprev ,kdim) < DZERO)\n\t\t{\n\t\t  /* We have a problem with degeneracy, quit now. */\n\t\t  goto war03;\n\t\t}\n\t      /* printf(\"%7.13f\\n\", s6scpr(sdiffcur, sdiffprev ,kdim)); */\n\t    }\n\n\t  /* Update number of intersection points */\n\n\t  knbinf++;\n\n\t  /* Copy point and parameter pair descriptions */\n\n\t  memcopy(spnt1,spnt2,ksize,DOUBLE);\n\t  memcopy(spar1,spar2,2,DOUBLE);\n\n\t  /* Update guide point pointers */\n\n\t  if (kstpch ==  1)\n\t    {\n\t      kguide++;\n\t      kgdir   = 1;\n\n\t      /* Test if end of guide point array reached */\n\n\t      if (kguide >= kpoint) goto nextdir;\n\n\t    }\n\t  if (kstpch == -1)\n\t    {\n\t      kguide--;\n\t      kgdir   = -1;\n\n\t      /* Test if start of guide point array reached */\n\n\t      if (1 >= kguide) goto nextdir;\n\t    }\n\n\t  /* Make new radius of curvature */\n\n\t  trad = *(s3dinf + 10*knbinf - 1);\n\t  tstep = s1311(trad,aepsge,tmax,&kstat);\n\t  if (kstat<0) goto error;\n\n\t  /* Test if start point reached, e.g. that the curve is closed */\n\n\t  if (kstpch == 3)\n\t    {\n\t      /*             Closed curve found */\n\t      goto finished;\n\t    }\n\n\n\t  /*         End while loop */\n\t}\n      /* End inside */\n      /* INSIDE TEST REMOVED BECAUSE OF CHANGED STRATEGY\n\t }\n      */\n    nextdir:;\n      /* End two step directions */\n    }\n\n finished:\n\n  /* In certain cases too many marched point may be found. These cases are:\n\n  - Open curve and start of marching first guide point\n  - Open curve and start of marching last guide point\n  - Closed curve and this found in second marching direction\n\n  In these cases some of the found points have to be discarded */\n\n  scorpnt = s3dinf;\n  scorpar = sp1inf;\n\n  if (kstpch !=3 && kpoint>1)\n    {\n\n      /*  Open curve */\n\n      if ( (kstart==1 && kgd1 == kpoint) ||\n\t   (kstart==kpoint && kgd1==1)      )\n\t{\n\t  /*  First marching direction traced curve */\n\n\t  knbinf = knb1;\n\t}\n      else if ( (kstart==1 && kguide==kpoint) ||\n\t\t(kstart==kpoint && kguide==1)    )\n\t{\n\t  /* Second marching direction traced curve */\n\n\t  scorpnt = scorpnt + 10*(knb1-1);\n\t  scorpar = scorpar +  7*(knb1-1);\n\t  knbinf  = knbinf - knb1 + 1;\n\t}\n    }\n  else if (kpoint>1)\n    {\n      /*  Closed curve, correct if result of second marching direction */\n\n      if (kdir != 1)\n\t{\n\t  /* Second marching direction, disc ard result of first direction */\n\n\t  scorpnt = scorpnt + 10*(knb1-1);\n\t  scorpar = scorpar +  7*(knb1-1);\n\t  knbinf  = knbinf - knb1 + 1;\n\t}\n    }\n\n  /* A curve is traced out only if at least two points are found, if less\n     points found try to pick out constant parameter line */\n\n interpolate:\n\n  if (knbinf>1)\n    {\n      if (igraph == 1 && knbinf > 1)\n\t{\n\t  /*  Output curve through s6line and s6move */\n\n\t  s6move(scorpnt);\n\t  for (ki=1,sp1=scorpnt+10;ki<knbinf;ki++,sp1+=10)\n\t    s6line(sp1);\n\t}\n\n      if (icur > 0 && knbinf >1)\n\t{\n\n\t  /*  Make 3-D representation of intersection curve */\n\n\t  kpar = 0;\n\n\t  /*  We allocate space for parametrization array */\n\n\n\t  spar = newarray(knbinf,DOUBLE);\n\t  if (spar == SISL_NULL) goto err101;\n\n\t  s1359(scorpnt,aepsge,kdim,knbinf,kpar,spar,&q3dcur,&kstat);\n\t  if (kstat < 0) goto error;\n\n\t  /*  Set pointer in intcurve object to 3-D curve */\n\t  pintcr -> pgeom = q3dcur;\n\n\t  if (icur == 2)\n\t    {\n\t      /* Make curve in parameter plane */\n\n\t      kdim = 2;\n\t      kpar = 1;\n\t      s1359(scorpar,aepsge,kdim,knbinf,kpar,spar,&qp1cur,&kstat);\n\t      if (kstat < 0) goto error;\n\n\n\t      /* Set pointersin intcurve object to curves in parameter plane */\n\t      if (kpar1 ==2)\n\t\t{\n\t\t  pintcr -> ppar1 = qp1cur;\n\t\t}\n\t      else\n\t\t{\n\t\t  pintcr -> ppar2 = qp1cur;\n\t\t}\n\t    }\n\t}\n    }\n  /*  Dont use s9constline for the silhouette curves -- it won't work! */\n  else if(pintcr->ipoint > 1 && ideg < 1003)\n    {\n\n      /* If no points produced on intersection curve */\n\n      s1313_s9constline(ps1,eimpli,ideg,aepsge,pintcr,\n\t\t\ticur,igraph,&kstat);\n      if (kstat<0) goto error;\n      if (kstat==0) goto err185;\n    }\n  else\n    goto err185;\n\n  if (kdiv==1) goto war03;\n  *jstat = 0;\n\n  goto out;\n\n  /* Iteration can not continue */\n war03:  *jstat = 3;\n  goto out;\n\n  /* Error in space allocation */\n err101: *jstat = -101;\n  s6err(\"s1313\",*jstat,kpos);\n  goto out;\n\n  /* Error in surface description parameter direction does not exist */\n err123: *jstat = -123;\n  s6err(\"s1313\",*jstat,kpos);\n  goto out;\n\n\n  /* Error - SISL_NULL pointer was given */\n  err150 :\n    *jstat = -150;\n  s6err(\"s1313\",*jstat,kpos);\n  goto out;\n\n\n  /* Only degenerate or singular guide points */\n err185: *jstat = -185;\n  goto out;\n\n\n  /* Error in lower leve function */\n error:\n  *jstat = kstat;\n  s6err(\"s1313\",*jstat,kpos);\n  goto out;\n\n out:\n\n  /* Free allocated space */\n\n  if (sgpar  != SISL_NULL) freearray(sgpar);\n  if (sgd1   != SISL_NULL) freearray(sgd1);\n  if (s3dinf != SISL_NULL) freearray(s3dinf);\n  if (sp1inf != SISL_NULL) freearray(sp1inf);\n  if (spar   != SISL_NULL) freearray(spar);\n\n\n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1313_s9constline(SISLSurf *ps1,double eimpli[],int ideg,\n\t\t  double aepsge,SISLIntcurve *pintcr,int icur,\n\t\t  int igraph,int *jstat)\n#else\n     static void s1313_s9constline(ps1,eimpli,ideg,aepsge,pintcr,\n\t\t\t\t   icur,igraph,jstat)\n     SISLSurf     *ps1;\n     double   eimpli[];\n     int      ideg;\n     double   aepsge;\n     SISLIntcurve *pintcr;\n     int      icur;\n     int      igraph;\n     int      *jstat;\n#endif\n     /*\n*********************************************************************\n*\n* PURPOSE    : To check if the parameter pairs describe an intersection\n*              curve that is a constant parameter line in the parameter\n*              plane of a surface and to produce the description of\n*              the curve according to the specifications.\n*              DO NOT USE IT FOR SILHOUETTE CURVES -- IT WON'T WORK!\n*\n*\n* INPUT      : ps1    - Pointer to surface.\n*              eimpli - Description of the implicit surface\n*              ideg   - The degree of the implicit surface\n*                        ideg=1: Plane\n*                        ideg=2; Quadric surface\n*                        ideg=1001: Torus surface\n*                        ideg=1003: Silhouette line parallel projection\n*                        ideg=1004: Silhouette line perspective projection\n*                        ideg=1005: Silhouette line circular projection\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              amax   - Maximal allowed step length. Not used.\n*              icur   - Indicator telling if a 3-D curve is to be made\n*                        0 - Don't make 3-D curve\n*                        1 - Make 3-D curve\n*                        2 - Make 3-D curve and curves in parameter plane\n*              igraph - Indicator telling if the curve is to be outputted\n*                       through function calls:\n*                        0 - don't output curve through function call\n*                        1 - output as straight line segments through\n*                            s6move and s6line\n*\n*\n*\n* INPUT/OUTPUT:pintcr - The intersection curve. When comming as input\n*                       only parameter values in the parameter plane\n*                       exist. When comming as output the 3-D geometry\n*                       and possibly the curve in the parameter plane\n*                       of the surface are added.\n*\n* OUTPUT:      jstat  - status messages\n*                         = 1      : Constant parameter line is intersection\n*                         = 0      : No intersection along constant parameter\n*                                    line.\n*                         < 0      : error\n*\n*\n* METHOD     :\n* REFERENCES :\n*\n*\n*-\n* CALLS      :\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 2. July 1989\n* Revised by : Mike Floater, SI, 1991-01\n*                Tried to add perspective and circular silhouettes (ideg=1004,ideg=1005)\n*                but more work is needed. After improving s1313, s1309, and s1331\n*                for all silhouette\n*                types -- ideg=1003,1004,1005 this routine is no longer\n*                useable even for ideg=1003. The problem is that there is not\n*                enough information in qc2 and its first derivative for the\n*                calls to s1331 and s1309. Perhaps the solution is to write a\n*                new routine specially for silhouette curve intersections.\n*                Until this problem is fixed S1313_S9CONSTLINE MUST NOT BE\n*                CALLED WHEN ideg=1003, ideg=1004, ideg=1005 (see s1313).\n*\n*********************************************************************\n*/\n{\n  int ki,kj,kl;            /* Control variables in for loops            */\n  int kk,kn,kk1,kn1,kk2,kn2;/* Orders and numbers of knots               */\n  int kpoint;              /* Number of points in guide curve           */\n  int kleft = 0;           /* Pointer into knot vector                  */\n  int kpar1;               /* Number of parameter direction in 1st. obj */\n  int kpar2;               /* Number of parameter direction in 2st. obj */\n  int ktype;               /* Type of intersection curve                */\n  int kpos=0;              /* Position of error                         */\n  int kstat;               /* Status variable returned form routine     */\n  int kdir=0;              /* constant parameter line direction         */\n  int knbpnt;              /* Number of points on constant parameter line */\n  double tmax1,tmin1;      /* Minimum and maximum of first comp of guide points */\n  double tmax2,tmin2;      /* Minimum and maximum of first comp of guide points */\n  double tmax;             /* Maximum 3-D SISLbox side                      */\n  double tdist,tang;       /* Distance and angle error                  */\n  double *st,*st1,*st2;    /* Pointers to knot vectors                  */\n  double *spoint;          /* Pointer to points on constant parameter line */\n  double *sp1;             /* Pointer into array                        */\n  double tsize1,tsize2;    /* Length of knot intervals                  */\n  double sval1[2];         /* Limits of parameter plane in first SISLdir    */\n  double sval2[2];         /* Limits of parameter plane in second SISLdir   */\n  double sder[6];          /* SISLPoint and derivative on curve             */\n  double sider[3];         /* SISLPoint on implicit surface                 */\n  double snorm[3];         /* Normal on implicit surface                */\n  double tsumold,tsum,tval;/* Parameter values                    */\n  double *sgpar1=SISL_NULL;     /* Parameter pairs of guide point in surf 1  */\n  double *sgpar2=SISL_NULL;     /* Parameter pairs of guide point in surf 2  */\n  SISLCurve *qc1=SISL_NULL;         /* Pointer to 3-D curve                     */\n  SISLCurve *qc2=SISL_NULL;         /* Pointer to 3-D curve                     */\n\n  SISLCurve *qp1cur=SISL_NULL;      /* Pointer to curve in first parameter plane*/\n\n\n\n  /* Make maximal step length based on box-size of surface */\n\n  sh1992su(ps1,0,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  tmax = MAX(ps1->pbox->e2max[0][0] - ps1->pbox->e2min[0][0],\n\t     ps1->pbox->e2max[0][1] - ps1->pbox->e2min[0][1]);\n  tmax = MAX(tmax,ps1->pbox->e2max[0][2] - ps1->pbox->e2min[0][2]);\n\n  /* Find a none singular start point for the marching process */\n\n  kpoint = pintcr->ipoint;\n  kpar1  = pintcr->ipar1;\n  kpar2  = pintcr->ipar2;\n  sgpar1 = pintcr->epar1;\n  sgpar2 = pintcr->epar2;\n  ktype  = pintcr->itype;\n\n\n  /* Initiate pointers to intersection curve and intersection curve in\n     parameter plane */\n\n  pintcr -> pgeom = SISL_NULL;\n  pintcr -> ppar1 = SISL_NULL;\n  pintcr -> ppar2 = SISL_NULL;\n\n\n  /* Initiate parameter direction boundaries */\n  kk1    = ps1 -> ik1;\n  kn1    = ps1 -> in1;\n  st1    = ps1 -> et1;\n  sval1[0] = st1[kk1-1];\n  sval1[1] = st1[kn1];\n  kk2    = ps1 -> ik2;\n  kn2    = ps1 -> in2;\n  st2    = ps1 -> et2;\n  sval2[0] = st2[kk2-1];\n  sval2[1] = st2[kn2];\n\n\n  /* Test that first object has 2 parameter\n     direction and second object 0 */\n\n  if (kpar1 == 2 && kpar2 == 0)\n    {\n      /*  Everithing is ok */\n      ;\n    }\n  else if (kpar1 == 0 && kpar2 == 2)\n    {\n      sgpar1 = sgpar2;\n    }\n  else\n    {\n      goto err123;\n    }\n\n\n  /* Run through the parameter pairs to decide if a constant parameter line\n     is possible */\n\n  tmax1 = tmin1 = sgpar1[0];\n  tmax2 = tmin2 = sgpar1[1];\n\n  for (ki=1,kj=2,kl=3 ; ki < kpoint ; ki++,kj+=2,kl+=2)\n    {\n      tmin1 = MIN(tmin1,sgpar1[kj]);\n      tmax1 = MAX(tmax1,sgpar1[kj]);\n      tmin2 = MIN(tmin2,sgpar1[kl]);\n      tmax2 = MAX(tmax2,sgpar1[kl]);\n    }\n\n  tsize1 = st1[kn1] - st1[kk1-1];\n  tsize2 = st2[kn2] - st2[kk2-1];\n\n  /* Check if constant parameter value within tolerance */\n\n  if (DEQUAL((tmin1+tsize1),(tmax1+tsize1)) )\n    {\n      /*  Intersection possible constant parameter line with first parameter\n\t  constant value constant.\n\n\t  1. Pick out curve from surface\n\t  2. Pick out relevant part of curve */\n\n      kdir = 1;\n\n      s1437(ps1,(tmin1+tmax1)/2.0,&qc1,&kstat);\n      if (kstat < 0) goto error;\n\n      s1712(qc1,tmin2,tmax2,&qc2,&kstat);\n      if (kstat < 0) goto error;\n    }\n  else if (DEQUAL((tmin2+tsize2),(tmax2+tsize2)) )\n    {\n      /*  Intersection possible constant parameter line with first parameter\n\t  constant value constant.\n\n\t  1. Pick out curve from surface\n\t  2. Pick out relevant part of curve */\n\n      kdir = 2;\n\n      s1436(ps1,(tmin2+tmax2)/2.0,&qc1,&kstat);\n      if (kstat < 0) goto error;\n\n      s1712(qc1,tmin1,tmax1,&qc2,&kstat);\n      if (kstat < 0) goto error;\n    }\n  else\n    goto war00;\n\n  st = qc2 -> et;\n  kk = qc2 -> ik;\n  kn = qc2 -> in;\n\n  /* Run through 2*kn points of the curve and check that they lie in the\n     implicit surface by calculating the 2*kn points. */\n\n  tsumold = st[kk-1];\n\n  for (ki=0 ; ki <kn ; ki++)\n    {\n      if (kk>1)\n\t{\n\t  /* Make parameter value to use for calculation of curve point */\n\n\t  for (kl=1,kj=ki+1,tsum=(double)0.0 ; kl<kk ; kl++)\n\t    tsum += st[kj++];\n\n\t  tsum = tsum/(kk-1);\n\t}\n      else\n\ttsum = st[ki];\n\n      tval = tsum;\n\n      for (kj=0 ; kj<2 ; kj++)\n\t{\n\t  /* Calculate point on curve */\n\n\t  s1221(qc2,1,tval,&kleft,sder,&kstat);\n\t  if (kstat < 0) goto error;\n\n\t  /* Calculate normal to implicit surface */\n\n\t  s1331(sder,eimpli,ideg,-1,sider,snorm,&kstat);\n\t  if (kstat < 0) goto error;\n\n\t  /* Project point onto implicit surface */\n\n\t  tdist = fabs(s1309(sder,snorm,eimpli,ideg,&kstat));\n\t  if (kstat<0) goto error;\n\t  if (kstat==2) goto war00;\n\n\t  /* Both the position of the two points should be within the relative\n\t     computer resolution for the point to be accepted. Correspondingly the\n\t     direction of the intersection curve and the constant parameter line\n\t     should be within the computer resolution to be accepted. */\n\n\t  if (DNEQUAL(tdist+tmax,tmax))\n\t    goto war00;\n\n\t  /* Distance within tolerance, check that the angle between surface\n\t     normal and curve tangent is PIHALF, if both these vectors have a\n\t     nonzero length. */\n\n\t  if (s6length(snorm,3,&kstat) != (double)0.0 &&\n\t      s6length(sder+3,3,&kstat) != (double)0.0  )\n\t    {\n\t      tang = s6ang(snorm,sder+3,3);\n\t      if (DNEQUAL(fabs(tang),PIHALF) ) goto war00;\n\t    }\n\t  tval = (tsumold+tsum)/(double)2.0;\n\t}\n      tsumold = tsum;\n    }\n\n  /* Intersection curve along constant parameter line, make right actions\n     concerning drawing and/or creation of the curve */\n\n  if (igraph == 1)\n    {\n      /* Draw curve, first break into straight line segments */\n\n      s1605(qc2,aepsge,&spoint,&knbpnt,&kstat);\n      if (kstat < 0) goto error;\n\n      if (knbpnt>1)\n\t{\n\t  /* Draw curve */\n\n\t  s6move(spoint);\n\t  for (ki=1,sp1=spoint+3 ; ki<knbpnt ; ki++,sp1+=3)\n\t    s6line(sp1);\n\t}\n      freearray(spoint);\n    }\n\n  if (icur >= 1)\n    {\n      /* Set pointer to 3-D curve */\n\n      pintcr -> pgeom = qc2;\n      qc2 = SISL_NULL;\n    }\n\n  if (icur == 2)\n    {\n      /* Make curve in parameter plane */\n\n      double svert[4],sknot[4];\n\n      if (kdir==1)\n\t{\n\t  svert[0] = svert[2] = (tmin1+tmax1)/(double)2.0;\n\t  svert[1] = tmin2;\n\t  svert[3] = tmax2;\n\t  sknot[0] = sknot[1] = tmin2;\n\t  sknot[2] = sknot[3] = tmax2;\n\t}\n      else\n\t{\n\t  svert[0] = tmin1;\n\t  svert[2] = tmax1;\n\t  svert[1] = svert[3] = (tmin2+tmax2)/(double)2.0;\n\t  sknot[0] = sknot[1] = tmin1;\n\t  sknot[2] = sknot[3] = tmax1;\n\t}\n      qp1cur = newCurve(2,2,sknot,svert,1,2,1);\n      if (qp1cur==SISL_NULL) goto err101;\n      pintcr -> ppar1 = qp1cur;\n    }\n\n  /* war01: */\n  *jstat = 1;\n  goto out;\n\n  /* Iteration can not continue */\n war00:  *jstat = 0;\n  goto out;\n\n\n  /* Error in space allocation */\n err101: *jstat = -101;\n  s6err(\"s1313\",*jstat,kpos);\n  goto out;\n\n  /* Error in surface description parameter direction does not exist */\n err123: *jstat = -123;\n  s6err(\"s1313_s9constline\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower leve function */\n error:\n  *jstat = kstat;\n  s6err(\"s1313_s9constline\",*jstat,kpos);\n  goto out;\n\n out:;\n  if (qc1 != SISL_NULL) freeCurve(qc1);\n  if (qc2 != SISL_NULL) freeCurve(qc2);\n}\n"
  },
  {
    "path": "src/s1314.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1314.c,v 1.2 2001-03-19 15:58:44 afr Exp $\n *\n */\n\n\n#define S1314\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1314(SISLSurf *ps1,double *epoint,double *enorm,int idim,double aepsco,\n\t   double aepsge,double amax,SISLIntcurve *pintcr,int icur,\n\t   int igraph,int *jstat)\n#else\nvoid s1314(ps1,epoint,enorm,idim,aepsco,aepsge,amax,pintcr,icur,igraph,jstat)\n     SISLSurf     *ps1;\n     double   *epoint;\n     double   *enorm;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     double   amax;\n     SISLIntcurve *pintcr;\n     int      icur;\n     int      igraph;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To march an intersection curve desribed by parameter pairs\n*              in an intersection curve object, a B-spline surface and\n*              a plane.\n*\n*\n* INPUT      : ps1    - Pointer to surface.\n*              epoint - SISLPoint in the plane.\n*              enorm  - Normal to the plane.\n*              idim   - Dimension of the space in which the plane lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              amax   - Maximal allowed step length. If amax <=aepsge\n*                       amax is neglected.\n*              icur   - Indicator telling if a 3-D curve is to be made \n*                        0 - Don't make 3-D curve\n*                        1 - Make 3-D curve\n*                        2 - Make 3-D curve and curves in parameter plane\n*              igraph - Indicator telling if the curve is to be outputted\n*                       through function calls:   \n*                        0 - don't output curve through function call\n*                        1 - output as straight line segments through\n*                            s6move and s6line.\n*\n*\n*\n* INPUT/OUTPUT:pintcr - The intersection curve. When comming as input\n*                       only parameter values it the parameter plane\n*                       exist. When comming as output the 3-D geometry\n*                       and possibly the curve in the parameter plane\n*                       of the surface is added.\n*\n* OUTPUT:      jstat  - status messages  \n*                         = 3      : Iteration stopped due to singular\n*                                    point or degenerate surface. A part\n*                                    of intersection curve may have been\n*                                    traced out. If no curve is traced out\n*                                    the curve pointers in the Intcurve\n*                                    object point to SISL_NULL.*                                         = 3      : Marching not succeded\n*                         = 0      : ok\n*                         < 0      : error\n*\n*\n* METHOD     : An implicit description of the plane is made and then\n*              a routine for intersecting implicit represented geometry\n*              by a B-spline surface is used.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err, s1313\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 2. July 1988\n* Revised by : Tor Dokken, SI, Oslo, Norway, Mars 1989\n*              Corrected use of none normalized use of normal vectors\n*\n*********************************************************************\n*/\n{            \n  int kpos=0;         /* Position of error                                  */\n  int kdeg=1;         /* The degree of the implicit equation of the plane   */\n  int kstat;          /* Local status variable                              */\n  double simpli[4];   /* Array containing the implicit description of plane */\n  double snorm[3];    /* Normalized version of normal vector                */\n  \n  \n  \n  if (idim != 3) goto err104;\n  \n  /* Normalize normal vector */\n  \n  (void)s6norm(enorm,idim,snorm,&kstat);\n  \n  simpli[0] = snorm[0];\n  simpli[1] = snorm[1];\n  simpli[2] = snorm[2];\n  simpli[3] = -s6scpr(epoint,snorm,idim);\n  \n  \n  /* Make intersection of implicit surface and B-spline surface */\n  \n  s1313(ps1,simpli,kdeg,aepsco,aepsge,amax,pintcr,icur,igraph,&kstat);\n  if (kstat == -185) goto err185;\n  if (kstat < 0) goto error;\n  \n  *jstat = kstat;\n  goto out;\n  \n  /* Dimension not 3 */\n  \n err104: \n  *jstat = -104;                \n  s6err(\"s1314\",*jstat,kpos);\n  goto out;\n  \n  /* Couldn't march */\n  \n err185:\n  *jstat = -185;\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n error: \n  *jstat = kstat;     \n  s6err(\"s1314\",*jstat,kpos);\n  goto out;\n  \n out:\n  return;\n}                                               \n"
  },
  {
    "path": "src/s1315.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1315.c,v 1.2 2001-03-19 15:58:44 afr Exp $\n *\n */\n\n\n#define S1315\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1315(SISLSurf *ps1,double *ecentr,double aradiu,int idim,\n\t   double aepsco,double aepsge,double amax,\n\t   SISLIntcurve *pintcr,int icur,int igraph,int *jstat)\n#else\nvoid s1315(ps1,ecentr,aradiu,idim,aepsco,aepsge,amax,pintcr,icur,igraph,jstat)\n     SISLSurf     *ps1;\n     double          *ecentr;\n     double          aradiu;\n     int             idim;\n     double          aepsco;\n     double          aepsge;\n     double          amax;\n     SISLIntcurve *pintcr;\n     int             icur;\n     int             igraph;\n     int             *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To march an intersection curve desribed by parameter pairs\n*              in an intersection curve object, a B-spline surface and\n*              a sphere.\n*\n*\n* INPUT      : ps1    - Pointer to surface.\n*              ecentr - Center of the sphere\n*              aradiu - Radius of sphere\n*              idim   - Dimension of the space in which the plane lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              amax   - Maximal allowed step length. If amax <=aepsge\n*                       amax is neglected.\n*              icur   - Indicator telling if a 3-D curve is to be made \n*                        0 - Don't make 3-D curve\n*                        1 - Make 3-D curve\n*                        2 - Make 3-D curve and curves in parameter plane\n*              igraph - Indicator telling if the curve is to be outputted\n*                       through function calls:   \n*                        0 - don't output curve through function call\n*                        1 - output as straight line segments through\n*                            s6move and s6line.\n*\n*\n*\n* INPUT/OUTPUT:pintcr - The intersection curve. When comming as input\n*                       only parameter values it the parameter plane\n*                       exist. When comming as output the 3-D geometry\n*                       and possibly the curve in the parameter plane\n*                       of the surface is added.\n*\n* OUTPUT:      jstat  - status messages  \n*                         = 3      : Iteration stopped due to singular\n*                                    point or degenerate surface. A part\n*                                    of intersection curve may have been\n*                                    traced out. If no curve is traced out\n*                                    the curve pointers in the Intcurve\n*                                    object point to SISL_NULL.*                                         = 3      : Marching not succeded\n*                         = 0      : ok\n*                         < 0      : error\n*\n*\n* METHOD     : An implicit description of the sphere is made and then\n*              a routine for intersecting implicit represented geometry\n*              by a B-spline surface is used.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err, s1313, s1321\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 2. July 1988\n*\n*********************************************************************\n*/\n{            \n  int kpos=0;         /* Position of error                                  */\n  int kdeg=2;         /* The degree of the implicit equation of the plane   */\n  int knumb=1;        /* Number of implicit representations to be made      */\n  int kstat;          /* Local status variable                              */\n  double simpli[16];  /* Array containing the implicit description of sphere*/\n  \n  \n  if (idim != 3) goto err104;\n  \n  /* Make description of sphere */\n  \n  s1321(ecentr,aradiu,idim,knumb,simpli,&kstat);\n  if (kstat < 0) goto error;                              \n  \n  /* Make intersection of implicit surface and B-spline surface */\n  \n  s1313(ps1,simpli,kdeg,aepsco,aepsge,amax,pintcr,icur,igraph,&kstat);\n  if (kstat == -185) goto err185;\n  if (kstat < 0) goto error;\n  \n  *jstat = kstat;\n  goto out;\n  \n  /* Dimension not 3 */\n  \n err104: \n  *jstat = -104;                \n  s6err(\"s1315\",*jstat,kpos);\n  goto out;\n  \n  /* Couldn't march */\n  \n err185:\n  *jstat = -185;\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n error: \n  *jstat = kstat;     \n  s6err(\"s1315\",*jstat,kpos);\n  goto out;\n  \n out:\n  return;\n}                                               \n"
  },
  {
    "path": "src/s1316.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1316.c,v 1.3 2001-03-19 15:58:44 afr Exp $\n *\n */\n\n\n#define S1316\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1316(SISLSurf *ps1,double *epoint,double *edirec,double aradiu,\n\t   int idim,double aepsco,double aepsge,double amax,\n\t   SISLIntcurve *pintcr,int icur,int igraph,int *jstat)\n#else\nvoid s1316(ps1,epoint,edirec,aradiu,idim,aepsco,aepsge,amax,pintcr,\n           icur,igraph,jstat)\n     SISLSurf     *ps1;\n     double   *epoint;\n     double   *edirec;\n     double   aradiu;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     double   amax;\n     SISLIntcurve *pintcr;\n     int      icur;\n     int      igraph;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To march an intersection curve desribed by parameter pairs\n*              in an intersection curve object, a B-spline surface and\n*              a cylinder.\n*\n*\n* INPUT      : ps1    - Pointer to surface.\n*              epoint - SISLPoint on cylinder axis\n*              edirec - Direction vector of cylinder axis\n*              aradiu - Radius of sphere\n*              idim   - Dimension of the space in which the plane lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              amax   - Maximal allowed step length. If amax <=aepsge\n*                       amax is neglected.\n*              icur   - Indicator telling if a 3-D curve is to be made\n*                        0 - Don't make 3-D curve\n*                        1 - Make 3-D curve\n*                        2 - Make 3-D curve and curves in parameter plane\n*              igraph - Indicator telling if the curve is to be outputted\n*                       through function calls:\n*                        0 - don't output curve through function call\n*                        1 - output as straight line segments through\n*                            s6move and s6line.\n*\n*\n*\n* INPUT/OUTPUT:pintcr - The intersection curve. When comming as input\n*                       only parameter values it the parameter plane\n*                       exist. When comming as output the 3-D geometry\n*                       and possibly the curve in the parameter plane\n*                       of the surface is added.\n*\n* OUTPUT:      jstat  - status messages\n*                         = 3      : Iteration stopped due to singular\n*                                    point or degenerate surface. A part\n*                                    of intersection curve may have been\n*                                    traced out. If no curve is traced out\n*                                    the curve pointers in the Intcurve\n*                                    object point to SISL_NULL.\n*                         = 0      : ok\n*                         < 0      : error\n*                         = -185   : No points produced on intersection curve.\n*\n*\n* METHOD     : An implicit description of the cylinder is made and then\n*              a routine for intersecting implicit represented geometry\n*              by a B-spline surface is used.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err, s1313, s1322\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 2. July 1988\n*\n*********************************************************************\n*/\n{\n  int kpos=0;         /* Position of error                                  */\n  int kdeg=2;         /* The degree of the implicit equation of the plane   */\n  int knumb=1;        /* Number of implicit representations to be made      */\n  int kstat;          /* Local status variable                              */\n  double simpli[16];  /* Array containing the implicit description of sphere*/\n\n  if (idim != 3) goto err104;\n\n  /* Make description of cylinder */\n\n  s1322(epoint,edirec,aradiu,idim,knumb,simpli,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Make intersection of implicit surface and B-spline surface */\n\n  s1313(ps1,simpli,kdeg,aepsco,aepsge,amax,pintcr,icur,igraph,&kstat);\n  if (kstat == -185) goto err185;\n  if (kstat < 0) goto error;\n\n  *jstat = kstat;\n  goto out;\n\n  /* Dimension not 3 */\n\n err104: *jstat = -104;\n  s6err(\"s1316\",*jstat,kpos);\n  goto out;\n\n  /* Couldn't march */\n\n err185:\n  *jstat = -185;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n error:\n  *jstat = kstat;\n  s6err(\"s1316\",*jstat,kpos);\n  goto out;\n\n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1317.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1317.c,v 1.3 2001-03-19 15:58:44 afr Exp $\n *\n */\n\n\n#define S1317\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1317(SISLSurf *ps1,double *etop,double *eaxis,double *econe,int idim,\n\t   double aepsco,double aepsge,double amax,SISLIntcurve *pintcr,\n\t   int icur,int igraph,int *jstat)\n#else\nvoid s1317(ps1,etop,eaxis,econe,idim,aepsco,aepsge,amax,pintcr,\n           icur,igraph,jstat)\n     SISLSurf     *ps1;\n     double   *etop;\n     double   *eaxis;\n     double   *econe;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     double   amax;\n     SISLIntcurve *pintcr;\n     int      icur;\n     int      igraph;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To march an intersection curve desribed by parameter pairs\n*              in an intersection curve object, a B-spline surface and\n*              a cone.\n*\n*\n* INPUT      : ps1    - Pointer to surface.\n*            : etop   - The top point of the cone\n*              edirec - Direction of cylinder axis\n*              econe  - A point on the cone surface different from the\n*                       top point\n*              idim   - Dimension of the space in which the plane lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              amax   - Maximal allowed step length. If amax <=aepsge\n*                       amax is neglected.\n*              icur   - Indicator telling if a 3-D curve is to be made\n*                        0 - Don't make 3-D curve\n*                        1 - Make 3-D curve\n*                        2 - Make 3-D curve and curves in parameter plane\n*              igraph - Indicator telling if the curve is to be outputted\n*                       through function calls:\n*                        0 - don't output curve through function call\n*                        1 - output as straight line segments through\n*                            s6move and s6line.\n*\n*\n*\n* INPUT/OUTPUT:pintcr - The intersection curve. When comming as input\n*                       only parameter values it the parameter plane\n*                       exist. When comming as output the 3-D geometry\n*                       and possibly the curve in the parameter plane\n*                       of the surface is added.\n*\n* OUTPUT:      jstat  - status messages\n*                         = 3      : Iteration stopped due to singular\n*                                    point or degenerate surface. A part\n*                                    of intersection curve may have been\n*                                    traced out. If no curve is traced out\n*                                    the curve pointers in the Intcurve\n*                                    object point to SISL_NULL.\n*                         = 0      : ok\n*                         < 0      : error\n*                         = -185   : No points produced on intersection curve.\n*\n*\n* METHOD     : An implicit description of the cone is made and then\n*              a routine for intersecting implicit represented geometry\n*              by a B-spline surface is used.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err, s1313, s1323\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 2. July 1988\n*\n*********************************************************************\n*/\n{\n  int kpos=0;         /* Position of error                                  */\n  int kdeg=2;         /* The degree of the implicit equation of the plane   */\n  int knumb=1;        /* Number of implicit representations to be made      */\n  int kstat;          /* Local status variable                              */\n  double simpli[16];  /* Array containing the implicit description of sphere*/\n\n  if (idim != 3) goto err104;\n\n  /* Make description of cone */\n\n  s1323(etop,eaxis,econe,idim,knumb,simpli,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Make intersection of implicit surface and B-spline surface */\n\n  s1313(ps1,simpli,kdeg,aepsco,aepsge,amax,pintcr,icur,igraph,&kstat);\n  if (kstat == -185) goto err185;\n  if (kstat < 0) goto error;\n\n  *jstat = kstat;\n  goto out;\n\n  /* Dimension not 3 */\n\n err104:\n  *jstat = -104;\n  s6err(\"s1317\",*jstat,kpos);\n  goto out;\n\n  /* Couldn't march */\n\n err185:\n  *jstat = -185;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error:\n  *jstat = kstat;\n  s6err(\"s1317\",*jstat,kpos);\n  goto out;\n\n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1318.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1318.c,v 1.3 2001-03-19 15:58:44 afr Exp $\n *\n */\n\n\n#define S1318\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1318(SISLSurf *ps1,double *ecentr,double *enorm,double abigr,\n\t   double asmalr,int idim,double aepsco,double aepsge,\n\t   double amax,SISLIntcurve *pintcr,int icur,int igraph,int *jstat)\n#else\nvoid s1318(ps1,ecentr,enorm,abigr,asmalr,idim,aepsco,aepsge,amax,pintcr,\n           icur,igraph,jstat)\n     SISLSurf     *ps1;\n     double   *ecentr;\n     double   *enorm;\n     double   abigr;\n     double   asmalr;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     double   amax;\n     SISLIntcurve *pintcr;\n     int      icur;\n     int      igraph;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To march an intersection curve desribed by parameter pairs\n*              in an intersection curve object, a B-spline surface and\n*              a TORUS.\n*\n*\n* INPUT      : ps1    - Pointer to surface.\n*              ecentr - The center of the torus (lying in the symmetri plane)\n*              enorm  - Normal of symmetri plane\n*              abigr  - Distance fro ecentr to center circle of torus\n*              asmalr - The radius of the torus surface\n*              idim   - Dimension of the space in which the plane lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              amax   - Maximal allowed step length. If amax <=aepsge\n*                       amax is neglected.\n*              icur   - Indicator telling if a 3-D curve is to be made\n*                        0 - Don't make 3-D curve\n*                        1 - Make 3-D curve\n*                        2 - Make 3-D curve and curves in parameter plane\n*              igraph - Indicator telling if the curve is to be outputted\n*                       through function calls:\n*                        0 - don't output curve through function call\n*                        1 - output as straight line segments through\n*                            s6move and s6line.\n*\n*\n*\n* INPUT/OUTPUT:pintcr - The intersection curve. When comming as input\n*                       only parameter values it the parameter plane\n*                       exist. When comming as output the 3-D geometry\n*                       and possibly the curve in the parameter plane\n*                       of the surface is added.\n*\n* OUTPUT:      jstat  - status messages\n*                         = 3      : Iteration stopped due to singular\n*                                    point or degenerate surface. A part\n*                                    of intersection curve may have been\n*                                    traced out. If no curve is traced out\n*                                    the curve pointers in the Intcurve\n*                                    object point to SISL_NULL.\n*                         = 0      : ok\n*                         < 0      : error\n*                         = -185   : No points produced on intersection curve.\n*\n*\n* METHOD     : An implicit description of the cone is made and then\n*              a routine for intersecting implicit represented geometry\n*              by a B-spline surface is used.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err, s1313, s1323\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 2. July 1988\n*\n*********************************************************************\n*/\n{\n  int kpos=0;         /* Position of error                                  */\n  int kdeg=2;         /* The degree of the implicit equation of the plane   */\n  int kstat;          /* Local status variable                              */\n  double simpli[8];   /* Array containing the implicit description of sphere*/\n  double snorm[3];    /* Nomalized normal vector                            */\n\n  if (idim != 3) goto err104;\n\n  /* Make description of TORUS */\n\n  (void)s6norm(enorm,idim,snorm,&kstat);\n  if (kstat<0) goto error;\n\n  if (kstat == 0          ||\n      DEQUAL(abigr,DZERO) ||\n      DEQUAL(asmalr,DZERO)) goto err177;\n\n  /* Put the information concerning the torus in the following sequence\n     into simpli: Center, normal, big radius, small radius */\n\n  memcopy(simpli,ecentr,3,DOUBLE);\n  memcopy(simpli+3,snorm,3,DOUBLE);\n  simpli[6] = abigr;\n  simpli[7] = asmalr;\n\n  /* Indicate the the information concerns a torus by putting kdeg=1001 */\n  kdeg = 1001;\n\n  /* Make intersection of implicit surface and B-spline surface */\n\n  s1313(ps1,simpli,kdeg,aepsco,aepsge,amax,pintcr,icur,igraph,&kstat);\n  if (kstat == -185) goto err185;\n  if (kstat < 0) goto error;\n\n  *jstat = kstat;\n  goto out;\n\n  /* Dimension not 3 */\n\n err104:\n  *jstat = -104;\n  s6err(\"s1318\",*jstat,kpos);\n  goto out;\n\n  /* Error in torus description */\n\n err177:\n  *jstat = -177;\n  s6err(\"s1318\",*jstat,kpos);\n  goto out;\n\n  /* Couldn't march */\n\n err185:\n  *jstat = -185;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n error:\n  *jstat = kstat;\n  s6err(\"s1318\",*jstat,kpos);\n  goto out;\n\n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1319.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1319.c,v 1.3 2001-03-19 15:58:44 afr Exp $\n *\n */\n\n\n#define S1319\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1319(SISLSurf *ps1,double *eview,int idim,double aepsco,double aepsge,\n\t   double amax,SISLIntcurve *pintcr,int icur,int igraph,int *jstat)\n#else\nvoid s1319(ps1,eview,idim,aepsco,aepsge,amax,pintcr,icur,igraph,jstat)\n     SISLSurf     *ps1;\n     double   *eview;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     double   amax;\n     SISLIntcurve *pintcr;\n     int      icur;\n     int      igraph;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To march the silhouette curve described by an intersection\n*              curve object, a B-spline surface and a view direction.\n*\n*\n* INPUT      : ps1    - Pointer to surface.\n*              eview  - View direction\n*              idim   - Dimension of the space in which the view direction\n*                       lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              amax   - Maximal allowed step length. If amax <=aepsge\n*                       amax is neglected.\n*              icur   - Indicator telling if a 3-D curve is to be made\n*                        0 - Don't make 3-D curve\n*                        1 - Make 3-D curve\n*                        2 - Make 3-D curve and curves in parameter plane\n*              igraph - Indicator telling if the curve is to be outputted\n*                       through function calls:\n*                        0 - don't output curve through function call\n*                        1 - output as straight line segments through\n*                            s6move and s6line.\n*\n*\n*\n* INPUT/OUTPUT:pintcr - The intersection curve. When comming as input\n*                       only parameter values it the parameter plane\n*                       exist. When comming as output the 3-D geometry\n*                       and possibly the curve in the parameter plane\n*                       of the surface is added.\n*\n* OUTPUT:      jstat  - status messages\n*                         = 3      : Iteration stopped due to singular\n*                                    point or degenerate surface. A part\n*                                    of intersection curve may have been\n*                                    traced out. If no curve is traced out\n*                                    the curve pointers in the Intcurve\n*                                    object point to SISL_NULL.\n*                         = 0      : ok\n*                         < 0      : error\n*                         = -185   : No points produced on intersection curve.\n*\n*\n* METHOD     : An implicit description of the problem is made and then\n*              a routine for intersecting implicit represented geometry\n*              by a B-spline surface is used.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err, s1313\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 19 . November 1988\n*\n*********************************************************************\n*/\n{\n  int kpos=0;         /* Position of error                                  */\n  int kdeg=1003;      /* The degree of the implicit equation of the plane   */\n  int kstat;          /* Local status variable                              */\n  double simpli[4];   /* Array containing the implicit description of plane */\n  double snorm[3];    /* Normalized version of normal vector                */\n\n\n\n  if (idim != 3) goto err104;\n\n  /* Normalize normal vector */\n\n  (void)s6norm(eview,idim,snorm,&kstat);\n\n  simpli[0] = snorm[0];\n  simpli[1] = snorm[1];\n  simpli[2] = snorm[2];\n\n  /* Make intersection of implicit surface and B-spline surface */\n\n  s1313(ps1,simpli,kdeg,aepsco,aepsge,amax,pintcr,icur,igraph,&kstat);\n  if (kstat == -185) goto err185;\n  if (kstat < 0) goto error;\n\n  *jstat = kstat;\n  goto out;\n\n  /* Dimension not 3 */\n\n err104:\n  *jstat = -104;\n  s6err(\"s1319\",*jstat,kpos);\n  goto out;\n\n  /* Couldn't march */\n\n err185:\n  *jstat = -185;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n error:\n  *jstat = kstat;\n  s6err(\"s1319\",*jstat,kpos);\n  goto out;\n\n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1320.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1320.c,v 1.2 2001-03-19 15:58:44 afr Exp $\n *\n */\n\n\n#define S1320\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1320 (SISLSurf * psurf, double earray[], int inarr,\n       int ratflag, SISLSurf ** rsurf, int *jstat)\n#else\nvoid\ns1320 (psurf, earray, inarr, ratflag, rsurf, jstat)\n     SISLSurf *psurf;\n     double earray[];\n     int inarr;\n     int ratflag;\n     SISLSurf **rsurf;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To put a surface description into the implicit\n*              second order surface described by the input array.\n*\n* INPUT      : psurf  - Pointer to input surface.\n*              earray - The description of the input array\n*                       dimension (psurf->idim+1)^2*inarr\n*              inarr  - Number of parallel matrices in earray.\n*                       inarr should be less or equal to 3.\n*              ratflag - If psurf is nonrational it is ignored.\n*                        Otherwise:\n*                        If ratflag = 0 rsurf is the nonrational numerator\n*                        If ratflag = 1 rsurf is a full rational surface\n*\n* OUTPUT     : rsurf  - The resulting surface\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : Dependent on the type of object we make:\n*\n*        F(S,T) = (P(s,t),1)  EARRAY (P(s,t),1)\n*\n*     by sampling enough points to use interpolation for reproduction.\n*\n* REFERENCES :\n*\n* CALLS      : s1896,s6err.\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway.\n* REVISED BY : Mike Floater, 91-01, SI, Oslo, Norway for rational surfaces.\n* REVISED BY : Mike Floater, SI, Oslo 11/9/91 -- ratflag.\n* REVISED BY : Michael Floater, SI, June 92. The rational stuff\n*              was messed up after translation of\n*              the fortran part to c. But it works now.\n* REVISED BY : Atgeirr F Rasmussen, Sintef, October 2000. Fixed the\n*              rational stuff, which assumed dimension was 3.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\n  int kstat = 0;\n  SISLSurf *ssurf = SISL_NULL;\t/* Temperary SISL-surface. */\n  int kdim;\t\t\t/* Number of dimesions in psurf                     */\n  int kdimp1;\t\t\t/* Dimension of  earray should be kdim+1            */\n  int lder[3];\t\t\t/* Derivative indicator array                       */\n  double *scoef = SISL_NULL;\t\t/* Vertices of psurf (scaled in the rational case)  */\n  double *rscoef = SISL_NULL;\t/* pointer to vertices in the rational case         */\n  int ikind;\t\t\t/* kind of surface                                  */\n  double wmin, wmax;\t\t/* min. and max. weight values for rational surface */\n  double scale;\t\t\t/* factor used for scaling rational weights         */\n  int i;\t\t\t/* loop variable                                    */\n  double *sarray = SISL_NULL;\t/* Array for calculating denominator if used      */\n  int knarr;\t\t\t/* Number of parallel arrays to use.   */\n  int nkind;\t\t\t/* Kind of output surface (rsurf).    */\n  SISLSurf *jsurf = SISL_NULL;       /* Temporary SISLSurf. */\n\n  *jstat = 0;\n\n\n  /* Make local pointers. */\n\n  kdim = psurf->idim;\n  ikind = psurf->ikind;\n\n  /* Set dimension of kdimp1.  */\n\n  kdimp1 = kdim + 1;\n\n\n  /* Test input. */\n\n  if (kdim < 1)\n    goto err102;\n  if (inarr < 1 || 3 < inarr)\n    goto err172;\n\n\n  /* rational surfaces is a special case. */\n\n  if (ikind == 2 || ikind == 4)\n    {\n      kdim++;\n      /* scale the coeffs so that min. weight * max. weight = 1. */\n\n      rscoef = psurf->rcoef;\n      wmin = rscoef[kdim-1];\n      wmax = rscoef[kdim-1];\n\n      for (i = kdim-1; i < psurf->in1 * psurf->in2 * kdim; i += kdim)\n\t{\n\t  if (rscoef[i] < wmin)\n\t    wmin = rscoef[i];\n\t  if (rscoef[i] > wmax)\n\t    wmax = rscoef[i];\n\t}\n\n      scale = (double) 1.0 / sqrt (wmin * wmax);\n      scoef = newarray (psurf->in1 * psurf->in2 * kdim, DOUBLE);\n      if (scoef == SISL_NULL)\n\tgoto err101;\n\n      for (i = 0; i < psurf->in1 * psurf->in2 * kdim; i++)\n\t{\n\t  scoef[i] = rscoef[i] * scale;\n\t}\n    }\n  else\n    {\n      scoef = psurf->ecoef;\n    }\n\n  ssurf = newSurf (psurf->in1, psurf->in2, psurf->ik1, psurf->ik2,\n\t\t   psurf->et1, psurf->et2, scoef, 1, kdim, 1);\n  if (ssurf == SISL_NULL)\n    goto err171;\n\n  if ((ikind == 2 || ikind == 4) && ratflag == 1)\n    {\n      /* Output surface will also be rational. */\n\n      nkind = 2;\n\n      /* Add an extra parallel array to pick up the weights\n\t of the subsequent homogeneous vertices of rsurf. */\n\n      knarr = inarr + 1;\n\n      sarray = new0array (kdimp1 * kdimp1 * knarr, DOUBLE);\n      if (sarray == SISL_NULL)\n\tgoto err101;\n\n      memcopy (sarray, earray, kdimp1 * kdimp1 * inarr, double);\n\n      sarray[kdimp1 * kdimp1 * knarr - 1] = (double) 1.0;\n    }\n  else\n    {\n      nkind = 1;\n      knarr = inarr;\n      sarray = earray;\n    }\n\n  lder[0] = 0;\n  lder[1] = 0;\n  lder[2] = 0;\n\n  /* Put surface into implicit surface */\n\n  s1896 (ssurf, sarray, kdimp1, knarr, lder, lder, lder, lder, &jsurf, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  if ((ikind == 2 || ikind == 4) && ratflag == 1)\n    {\n      /* Output from s1896 is a dim+1 non-rational surface jsurf. */\n      /* Convert homogeneous jsurf to rational rsurf. */\n\n      *rsurf = newSurf(jsurf->in1,jsurf->in2,\n                        jsurf->ik1,jsurf->ik2,\n                        jsurf->et1,jsurf->et2,\n                        jsurf->ecoef,\n                        2,jsurf->idim-1,1);\n      freeSurf(jsurf);\n    }\n  else\n    {\n      *rsurf = jsurf;\n    }\n\n  if (ikind == 2 || ikind == 4)\n    {\n      if (scoef)\n\tfreearray (scoef);\n      if (ratflag)\n\tfreearray (sarray);\n    }\n\n  /* Ok. */\n\n  goto out;\n\n\n  /* Error in lower level function */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1320\", *jstat, kpos);\n  goto out;\n\n  /* allocation problems. */\nerr101:\n  *jstat = -101;\n  s6err (\"s1320\", *jstat, kpos);\n  goto out;\n\n  /* Dimension less than 1    */\n\nerr102:\n  *jstat = -102;\n  s6err (\"s1320\", *jstat, kpos);\n  goto out;\n\n  /* Could not create surface. */\n\nerr171:\n  *jstat = -171;\n  s6err (\"s1320\", *jstat, kpos);\n  goto out;\n\n  /* Dimension inarr not equal to 1,2 or 3 */\n\nerr172:\n  *jstat = -172;\n  s6err (\"s1320\", *jstat, kpos);\n  goto out;\n\nout:\n  if (ssurf)\n    freeSurf (ssurf);\n  return;\n}\n"
  },
  {
    "path": "src/s1321.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1321.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1321\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1321(double ecentr[],double aradiu,int idim,int inumb,\n\t   double carray[],int *jstat)\n#else\nvoid s1321(ecentr,aradiu,idim,inumb,carray,jstat)\n     double ecentr[];\n     double aradiu;\n     int    idim;\n     int    inumb;\n     double carray[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To make a matrix of dimension (idim+1)x(idim+1)\n*              describing a hyper sphere as an implicit function.\n*\n*\n* INPUT      : ecentr - Center of the hyper sphere\n*              aradiu - Radius of hyper sphere\n*              idim   - The dimension of the space the hyper sphere lies\n*              inumb  - The number of copies that are to be made of the\n*                       matrix.\n*\n*\n*\n* OUTPUT     : carray - The description of the super sphere. Outside\n*                       this function the space for this array must be\n*                       allocated. The need is (idim+1)*(idim+1)*inumb\n*                       dimension 4x4 (xinarr)\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n*     The matrix is described in the following way (x,y,z)-center and\n*     r radius:\n*\n*            I-                                  -I\n*            I   1    0    0        -x            I      \n*            I   0    1    0        -y            I\n*            I   0    0    1        -z            I\n*            I  -x   -y   -z   x*x+y*y+z*z-r*r    I\n*            I-                                  -I\n*        \n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 28-June-1988\n*                                    \n*********************************************************************\n*/\n{\n  int kdimp1;         /* Dimension of matrix kdimp1 = idim + 1         */\n  int kdimp2;         /* idim + 2                                      */\n  int kstop;          /* Stop condition for for loop                   */\n  int ki,kj,kl;       /* Running variables in loop                     */\n  int kpos=0;         /* Position of error                             */\n  double temp;        /* Temporary storage variable                    */\n  double tsum;        /* Varaible used for summation                   */\n  \n  \n  \n  /* Test i legal input */\n  if (inumb <1 ) inumb = 1;\n  if (idim < 1 ) goto err102;\n  \n  kdimp1 = idim + 1;\n  kdimp2 = idim + 2;\n  kstop  = kdimp1*kdimp1;\n  \n  for (ki=0;ki<kstop;ki++)\n    {\n      carray[ki] = (double)0.0;\n    }\n  \n  /* Make diagonal elements */\n  \n  for (ki=0;ki<kstop;ki+=kdimp2)\n    {\n      carray[ki] = (double)1.0;\n    }\n  \n  /* Make element 1,...,idim of last column and element 1,...,idim of last\n   *  row */\n  \n  tsum = (double)0.0;\n  for (kl=0,ki=idim,kj=idim*kdimp1;kl<idim;kl++,kj++,ki+=kdimp1)\n    {\n      temp = -ecentr[kl];\n      carray[ki] = temp;\n      carray[kj] = temp;\n      tsum +=(temp*temp);                                                \n    }\n  \n  /* Make lower right corner element */\n  \n  carray[kstop-1] = tsum - aradiu*aradiu;\n  \n  /* Make extra copies of hyper sphere */\n  \n  kj = kstop;\n  for (ki=1;ki<inumb;ki++)\n    {\n      for (kl=0;kl<kstop;kl++,kj++)\n        {\n\t  carray[kj] = carray[kl];\n        }\n    }\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Dimension less than 1 */\n err102: *jstat = -102;\n  s6err(\"s1321\",*jstat,kpos);\n  goto out;\n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1322.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1322.c,v 1.3 2001-03-19 15:58:44 afr Exp $\n *\n */\n\n\n#define S1322\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1322(double epoint[],double edirec[],double aradiu,int idim,\n\t   int inumb,double carray[],int *jstat)\n#else\nvoid s1322(epoint,edirec,aradiu,idim,inumb,carray,jstat)\n     double epoint[];\n     double edirec[];\n     double aradiu;\n     int    idim;\n     int    inumb;\n     double carray[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To make a matrix of dimension (idim+1)x(idim+1)\n*              describing a cylinder as an implicit function.\n*\n*\n* INPUT      : epoint - SISLPoint on the cylinder axis\n*              edirec - Direction of cylinder axis\n*              aradiu - Radius of hyper sphere\n*              idim   - The dimension of the space the cylinder lies\n*              inumb  - The number of copies that are to be made of the\n*                       matrix.\n*\n*\n*\n* OUTPUT     : carray - The description of the cylinder. Outside\n*                       this function the space for this array must be\n*                       allocated. The need is (idim+1)*(idim+1)*inumb\n*                       dimension 4x4 (xinarr)\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*     The matrix is described in the following way: (X0,Y0,Z0) point\n*     on cylinder axis, (WX,WY,WZ) direction of cylinder axis and\n*     R radius of cylinder:\n*\n*          I-                                 -I\n*          I   1-WX*WX  -WX*WY   -WX*WZ    A   I\n*          I                                   I\n*          I   -WX*WY   1-WY*WY  -WY*WZ    B   I\n*          I                                   I\n*          I   -WX*WZ   -WY*WZ   1-WZ*WZ   *   I\n*          I                                   I\n*          I      A        B        C      D   I\n*          I-                                 -I\n*\n*     where\n*\n*         A = X0*(WX*WX-1)+WX*(Y0*WY+Z0*WZ)\n*         B = Y0*(WY*WY-1)+WY*(Z0*WZ+X0*WX)\n*         C = Z0*(WZ*WZ-1)+WZ*(X0*WX+Y0*WY)\n*         D = X0*X0+Y0*Y0+Z0*Z0-X0*X0*WX*WX-Y0*Y0*WY*WY-Z0*Z0*WZ*WZ\n*                -2*X0*Y0*WX*WY-2*Y0*Z0*WY*WZ-2*Z0*X0*WZ*WX-R*R\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 28-June-1988\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov. 1994.  Changed loop\n*              building diagonal elements to avoid over-running 'sdirec'.\n*\n*********************************************************************\n*/\n{\n  int kdimp1;         /* Dimension of matrix kdimp1 = idim + 1         */\n  int kdimp2;         /* idim + 2                                      */\n  int kstop;          /* Stop condition for for loop                   */\n  int ki,kj,kl;       /* Running variables in loop                     */\n  int kpos=0;         /* Position of error                             */\n  double twx,twy,twz; /* Local version of normalized direction vector  */\n  double tx0,ty0,tz0; /* Local version of point on axis                */\n  double temp;        /* Temporary storage variable                    */\n  double tsum;        /* Varaible used for summation                   */\n  double sdirec[3];   /* Normalized direction vector                   */\n\n\n  /* Test i legal input */\n  if (inumb <1 ) inumb = 1;\n  if (idim != 3 ) goto err104;\n\n  kdimp1 = idim + 1;\n  kdimp2 = idim + 2;\n  kstop  = kdimp1*kdimp1;\n\n  for (ki=0;ki<kstop;ki++)\n    {\n      carray[ki] = DZERO;\n    }\n\n  /* Normalize direction vector */\n\n  tsum = DZERO;\n\n  for (ki=0;ki<idim;ki++)\n    {\n      temp = edirec[ki];\n      tsum += (temp*temp);\n    }\n\n  tsum = sqrt(tsum);\n  if (DEQUAL(tsum,DZERO)) goto err173;\n\n  for (ki=0;ki<idim;ki++)\n    {\n      sdirec[ki] = edirec[ki]/tsum;\n    }\n\n  /* Make diagonal elements */\n\n  for (ki=0,kl=0 ; ki<kstop-1 ; kl++,ki+=kdimp2)   /* (PFU 14/11-1994) */\n    {\n      temp = sdirec[kl];\n      carray[ki] = (double)1.0 - temp*temp;\n    }\n  carray[ki] = (double) 1.0;  /* (PFU 14/11-1994) */\n\n  /* Make element 1,...,idim of last row and 1,...,idim of last column */\n\n  tsum = DZERO;\n  twx = sdirec[0];\n  twy = sdirec[1];\n  twz = sdirec[2];\n  tx0 = epoint[0];\n  ty0 = epoint[1];\n  tz0 = epoint[2];\n\n  /* Make element (1,4) and (4,1) */\n\n  temp = tx0*(twx*twx-(double)1.0) + twx*(ty0*twy+tz0*twz);\n\n  carray[3]  = temp;\n  carray[12] = temp;\n\n  /* Make element (2,4) and (4,2) */\n\n  temp = ty0*(twy*twy-(double)1.0) + twy*(tz0*twz+tx0*twx);\n\n  carray[7]  = temp;\n  carray[13] = temp;\n\n  /* Make element (3,4) amd (4,3) */\n\n  temp = tz0*(twz*twz-(double)1.0) + twz*(tx0*twx+ty0*twy);\n\n  carray[11] = temp;\n  carray[14] = temp;\n\n  /* Make element (4,4) */\n\n  temp = tx0*tx0*((double)1.0-twx*twx) + ty0*ty0*((double)1.0-twy*twy)\n         + tz0*tz0*((double)1.0-twz*twz) - (double)2.0*tx0*ty0*twx*twy\n         - (double)2.0*ty0*tz0*twy*twz - (double)2.0*tz0*tx0*twz*twx\n\t - aradiu*aradiu;\n\n  carray[15] = temp;\n\n  /* Make element (1,2) and (2,1) */\n\n  temp = -twx*twy;\n  carray[1] = temp;\n  carray[4] = temp;\n\n  /* Make element (1,3) and (3,1) */\n\n  temp = -twx*twz;\n  carray[2] = temp;\n  carray[8] = temp;\n\n  /* Make element (2,3) and (3,2) */\n  temp = -twy*twz;\n  carray[6] = temp;\n  carray[9] = temp;\n\n  /* Make extra copies of cylinder */\n\n  kj = kstop;\n  for (ki=1;ki<inumb;ki++)\n    {\n      for (kl=0;kl<kstop;kl++,kj++)\n        {\n\t  carray[kj] = carray[kl];\n        }\n    }\n\n  *jstat = 0;\n  goto out;\n\n  /* Dimension less than 1 */\n err104: *jstat = -104;\n  s6err(\"s1322\",*jstat,kpos);\n  goto out;\n\n  /* Direction vector of length 0 */\n err173: *jstat = -173;\n  s6err(\"s1322\",*jstat,kpos);\n  goto out;\n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1323.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1323.c,v 1.2 2001-03-19 15:58:44 afr Exp $\n *\n */\n\n\n#define S1323\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1323(double etop[],double eaxis[],double econe[],int idim,\n\t   int inumb,double carray[],int *jstat)\n#else\nvoid s1323(etop,eaxis,econe,idim,inumb,carray,jstat)\n     double etop[];\n     double eaxis[];\n     double econe[];\n     int    idim;\n     int    inumb;\n     double carray[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To make a matrix of dimension (idim+1)x(idim+1)\n*              describing a cone as an implicit function.\n*\n*\n* INPUT      : etop   - The top point of the cone \n*              edirec - Direction of cylinder axis\n*              econe  - A point on the cone surface different from the\n*                       top point\n*              idim   - The dimension of the space the cylinder lies\n*              inumb  - The number of copies that are to be made of the\n*                       matrix.\n*\n*\n*\n* OUTPUT     : carray - The description of the cone. Outside \n*                       this function the space for this array must be\n*                       allocated. The need is (idim+1)*(idim+1)*inumb\n*                       dimension 4x4 (xinarr)\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n*     If the top point of the cone is denoted (X0,Y0,Z0), the direction\n*     vector of the cone axis is denoted (WX,WY,WZ) and COS(T) is\n*     the cosine of the opining angle of the cone, the matrix describing\n*     the cone is:\n*\n*     I-                                                          -I\n*     I         WX*WX           -WX*WY            -WX*WZ           I\n*     I   1 - ----------      -----------       -----------    A   I\n*     I       (COS(T)**2)     (COS(T)**2)       (COS(T)**2)        I\n*     I                                                            I\n*     I       -WX*WY               WY*WY         -WY*WZ            I\n*     I     -----------     1 - -----------     -----------    B   I\n*     I     (COS(T)**2)         (COS(T)**2)     (COS(T)**2)        I\n*     I                                                            I\n*     I       -WX*WZ            -WY*WZ              WZ*WZ          I\n*     I     -----------       -----------    1 - -----------   C   I\n*     I     (COS(T)**2)       (COS(T)**2)        (COS(T)**2)       I\n*     I                                                            I\n*     I          A                 B                 *         D   I\n*     I-                                                          -I\n*\n*     WHERE\n*         A = (X0*WX*WX+WX*(Y0*WY+Z0*WZ))/(COS(T)**2)-X0\n*         B = (Y0*WY*WY+WY*(Z0*WZ+X0*WX))/(COS(T)**2)-Y0\n*         C = (Z0*WZ*WZ+WZ*(X0*WX+Y0*WY))/(COS(T)**2)-Z0\n*         D = X0*X0+Y0*Y0+Z0*Z0-(X0*X0*WX*WY+Y0*Y0*WY*WY+Z0*Z0*WZ*WZ\n*             +2*X0*Y0*WX*WY+2*Y0*Z0*WY*WZ+2*Z0*X0*WZ*WX)/(COS(T)**2)\n*\n*     The matrix is described in the following way: (X0,Y0,Z0) point\n*     on cylinder axis, (WX,WY,WZ) direction of cylinder axis and\n*     R radius of cylinder:\n*\n*          I-                                 -I\n*          I   1-WX*WX  -WX*WY   -WX*WZ    A   I\n*          I                                   I\n*          I   -WX*WY   1-WY*WY  -WY*WZ    B   I\n*          I                                   I\n*          I   -WX*WZ   -WY*WZ   1-WZ*WZ   *   I\n*          I                                   I\n*          I      A        B        C      D   I\n*          I-                                 -I\n*\n*     where\n*\n*         A = X0*(WX*WX-1)+WX*(Y0*WY+Z0*WZ)\n*         B = Y0*(WY*WY-1)+WY*(Z0*WZ+X0*WX)\n*         C = Z0*(WZ*WZ-1)+WZ*(X0*WX+Y0*WY)\n*         D = X0*X0+Y0*Y0+Z0*Z0-X0*X0*WX*WX-Y0*Y0*WY*WY-Z0*Z0*WZ*WZ\n*                -2*X0*Y0*WX*WY-2*Y0*Z0*WY*WZ-2*Z0*X0*WZ*WX-R*R\n*        \n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 28-June-1988\n*                                    \n*********************************************************************\n*/\n{\n  int kdimp1;         /* Dimension of matrix kdimp1 = idim + 1         */\n  int kdimp2;         /* idim + 2                                      */\n  int kstop;          /* Stop condition for for loop                   */\n  int ki,kj,kl;       /* Running variables in loop                     */\n  int kpos=0;         /* Position of error                             */\n  int kstat;          /* Local status variable                         */\n  double twx,twy,twz; /* Local version of normalized direction vector  */\n  double tx0,ty0,tz0; /* Local version of point on axis                */\n  double temp;        /* Temporary storage variable                    */\n  double tcost2;      /* The square of the cosine of the opening angle */\n  double sdirec[3];   /* Normalized direction of cone axis             */\n  double sdcone[3];   /* Normalized vector from top point to cone point*/\n  \n  \n  /* Test i legal input */\n  if (inumb <1 ) inumb = 1;\n  if (idim != 3 ) goto err104;\n  \n  kdimp1 = idim + 1;\n  kdimp2 = idim + 2;\n  kstop  = kdimp1*kdimp1;\n  \n  for (ki=0;ki<kstop;ki++)\n    {\n      carray[ki] = DZERO;\n    }\n  \n  /* Normalize direction vector of axis */\n  \n  s6diff(etop,eaxis,idim,sdirec);\n  (void)s6norm(sdirec,idim,sdirec,&kstat);\n  \n  /* Normalize vector from top point to point on conic surface */        \n  \n  s6diff(etop,econe,idim,sdcone);\n  (void)s6norm(sdcone,idim,sdcone,&kstat);\n  \n  /* Make cosinus of angle between the two normalized vectors */\n  \n  temp = s6scpr(sdirec,sdcone,idim);\n  tcost2 = temp*temp;\n  \n  /* Test if cone degenerate */\n  if (DEQUAL(tcost2,DZERO)) goto err174;\n  \n  /* Make diagonal elements */\n  \n  for (ki=0,kl=0 ; kl<idim ; kl++,ki+=kdimp2)\n    {\n      temp = sdirec[kl];\n      carray[ki] = (double)1.0 - temp*temp/tcost2;\n    }                                                                          \n  \n  twx = sdirec[0];\n  twy = sdirec[1];\n  twz = sdirec[2];\n  tx0 = etop[0];\n  ty0 = etop[1];\n  tz0 = etop[2];\n  \n  \n  /* Make element (1,4) and (4,1) */\n  \n  temp = (tx0*twx*twx + twx*(ty0*twy+tz0*twz))/tcost2 - tx0;\n  \n  carray[3]  = temp;\n  carray[12] = temp;\n  \n  \n  /* Make element (2,4) and (4,2) */\n  \n  temp = (ty0*twy*twy + twy*(tz0*twz+tx0*twx))/tcost2 - ty0;\n  \n  carray[7]  = temp;\n  carray[13] = temp;\n  \n  \n  /* Make element (3,4) and (4,3) */\n  \n  temp = (tz0*twz*twz + twz*(tx0*twx+ty0*twy))/tcost2 - tz0;\n  \n  carray[11] = temp;\n  carray[14] = temp;\n  \n  /* Make element (4,4) */\n  \n  temp = tx0*tx0 + ty0*ty0 + tz0*tz0\n         - ( tx0*tx0*twx*twx + ty0*ty0*twy*twy + tz0*tz0*twz*twz\n         + (double)2.0*tx0*ty0*twx*twy + (double)2.0*ty0*tz0*twy*twz\n         + (double)2.0*tz0*tx0*twz*twx )/tcost2;\n  carray[15] = temp;\n  \n  \n  /* Make element (1,2) and (2,1) */\n  \n  temp = -twx*twy/tcost2;\n  carray[1] = temp;\n  carray[4] = temp;\n  \n  \n  /* Make element (1,3) and (3,1) */\n  \n  temp = -twx*twz/tcost2;\n  carray[2] = temp;\n  carray[8] = temp;\n  \n  \n  /* Make element (2,3) and (3,2) */\n  \n  temp = -twy*twz/tcost2;\n  carray[6] = temp;\n  carray[9]= temp;\n  \n  \n  /* Make extra copies of cylinder */\n  \n  kj = kstop;\n  for (ki=1;ki<inumb;ki++)\n    {\n      for (kl=0;kl<kstop;kl++,kj++)\n        {\n\t  carray[kj] = carray[kl];\n        }\n    }\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Dimension less than 1 */\n err104: *jstat = -104;\n  s6err(\"s1323\",*jstat,kpos);\n  goto out;\n  \n  /* Degenerate cond */\n err174: *jstat = -174;\n  s6err(\"s1323\",*jstat,kpos);\n  goto out;\n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1324.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1324.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1324\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1324(double ecentr[],double aradiu,double enorm[],int idim,\n\t   double carray[],int *jstat)\n#else\nvoid s1324(ecentr,aradiu,enorm,idim,carray,jstat)\n     double ecentr[];\n     double aradiu;\n     double enorm[];\n     int    idim;\n     double carray[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To make two matrix of dimension 4x4\n*              describing a 3-D circle as two implicit functions.\n*\n*\n* INPUT      : ecentr - Center of the circle\n*              aradiu - Radius of the circle\n*              enorm  - Normal vector of circle plane\n*              idim   - The dimension of the space the cirle lies in\n*\n*\n*\n* OUTPUT     : carray - The description of the circle. Outside\n*                       this function the space for this array must be\n*                       allocated. The need is 32 double variables.\n*                       First the matrix for the sphere is stored,\n*                       then the matrix of the plane.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The circle is described as an intersection between a\n*              cylinder and the plane. The matrix describing the\n*              cylinder is put first in the output array, the matrix\n*              describing the plane follows then.\n*              \n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 29-June-1988\n*                                    \n*********************************************************************\n*/\n{\n  int kdimp1;         /* Dimension of matrix kdimp1 = idim + 1         */\n  int kdimp2;         /* idim + 2                                      */\n  int kstop;          /* Stop condition for for loop                   */\n  int ki;             /* Running variables in loop                     */\n  int kpos=0;         /* Position of error                             */\n  int kstat;          /* Status variable                               */\n  \n  \n  \n  /* Test i legal input */\n  if (idim != 3) goto err104;\n  \n  kdimp1 = idim + 1;\n  kdimp2 = idim + 2;\n  kstop  = 2*kdimp1*kdimp1;\n  \n  for (ki=0;ki<kstop;ki++)\n    {\n      carray[ki] = (double)0.0;\n    }\n  \n  /* Make description of cylinder */\n  \n  s1322(ecentr,enorm,aradiu,idim,1,carray,&kstat);\n  if (kstat<0) goto error;\n  \n  \n  /* Make description of plane, element (1,4), (2,4) and (3,4) */\n  \n  carray[28] = enorm[0];\n  carray[29] = enorm[1];\n  carray[30] = enorm[2];\n  \n  /* Make element (4,4) */\n  \n  carray[31] = -s6scpr(enorm,ecentr,idim);\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Dimension not 3 */\n err104: *jstat = -104;\n  s6err(\"s1324\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine */\n error: *jstat = kstat;\n  goto out;\n  \n  \n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1325.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1325.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1325\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\ndouble \ns1325(double aradiu,double angle)\n#else\ndouble s1325(aradiu,angle)\n     double aradiu;\n     double angle;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To create the tangent length for interpolating a\n*              circular arc with an almost equi-oscillating Hermit qubic\n*\n* INPUT      : aradiu  - The radius of the circular arc\n*              angle   - The opening angle of the circular arc\n*\n* OUTPUT     : s1325   - The proposed tangent length\n*\n* METHOD     : A second degree equation giving the tanget length is\n*              solved\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. 30. June 1988\n*                                  \n*********************************************************************\n*/\n{\n  double tcos,tsin;          /* Dummy variables                     */\n  double ta,tb,tc,tl;        /* Dummy variables                     */\n  double tconst = (double)1.85530139760811990992528773586425;\n                             /* Constant used in the calculation    */\n  \n  \n  \n  tcos = cos(angle);\n  tsin = sin(angle);\n  \n  /*  Calculate length of tangents\n   *   tconst = (3-2sqrt(2))**1/3 + (3+2sqrt(2))**1/3 - 0.5 */\n  \n  ta     = (double)0.6*tconst - (double)0.9*tcos;\n  tb     = ((double)0.4*tconst+(double)1.8)*tsin;\n  tc     = ((double)0.4*tconst+(double)1.0)\n           * tcos - (double)0.4*tconst - (double)1.0;\n  tl     = aradiu*(-tb+sqrt(tb*tb-4*ta*tc))/((double)2.0*ta);\n  \n  return(tl);\n}\n"
  },
  {
    "path": "src/s1326.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S1326\n\n#include \"sislP.h\"\n\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n s1326(SISLSurf *ps, int power, double *ecimp, int inarr, double **et1,\n       double **et2, double **ecoef, int *ik1, int *ik2, int *in1,\n       int *in2, int *numprd, int *jstat)\n#else\nvoid\n    s1326(ps, power, ecimp, inarr, et1, et2, ecoef, ik1, ik2,\n\t  in1, in2, numprd, jstat)\n       SISLSurf *ps;\n       int power;\n       double *ecimp;\n       int inarr;\n       double **et1;\n       double **et2;\n       double **ecoef;\n       int *ik1;\n       int *ik2;\n       int *in1;\n       int *in2;\n       int *numprd;\n       int *jstat;\n#endif       \n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute x(s,t)^i y(s,t)^j z(s,t)^k h(s,t)^(power-i-j-k)\n*                 for\n*              i=0,...,power. j=0,...,power-i. k=0,power-i-j.\n*              If implicit coefficients are known, these are multiplied\n*              with these factors to produce the coefficients of a 1D surface \n*              where the input surface are put into an implicit function.\n*\n* INPUT      : ps     - Pointer to the surface \n*              power  - The maximum power to be produced\n*              ecimp  - Coefficients of implicit function, if\n*                       no such function is known ecimp = NULL.\n*              inarr  - Number of parallell arrays of implicit coeff.\n*\n* OUTPUT     : et1    - Knot vector in first direction\n*                       belonging to the powers\n*                       of the curve. The knots produced\n*                       are the Bernstein knot vector, e.g.\n*                       all knots has maximal multiplicity.\n*              et2    - Knot vector in second direction\n*                       belonging to the powers\n*                       of the curve. The knots produced\n*                       are the Bernstein knot vector, e.g.\n*                       all knots has maximal multiplicity.\n*              ecoef  - The coefficients produced stored\n*                       in a long array. For each Bernstein\n*                       segment the ordering is:\n*                       vertices of h^power, h^(power-1)y, h^(power-2)y^2,...,\n*                       x h^(power-1), x y h^(power-2),..., x^(power).\n*                       If ecimp != NULL, the implicit coefficients are\n*                       multiplied by the powers of the Bezier surfaces to\n*                       produce the coefficients of a 1D surface where the\n*                       input surface are put into an implicit function.\n*              ik1     - Order in first parameter direction of the\n*                        produced products\n*              ik2     - Order in first parameter direction of the\n*                        produced products\n*              in1     - Number of vertices in first parameter direction\n*                        in the products\n*              in2     - Number of vertices in second parameter direction\n*                        in the products\n*              numprd - The number of products.\n*\n* METHOD     : \n* REFERENCES :\n*\n*-\n* CALLS      : s1731    - Split B-spline surface into Bezier segments.\n*              s1733    - Pick Bezier segment.\n*              s6multsfs  - Multiply two 1D Bezier surfaces.\n*              s6bezpowsf - Compute power of Bezier surface.\n*              s6err    - Error handling routine \n*\n*\n* WRITTEN BY : Tor Dokken, SINTEF SI, November 1993\n* REWISED BY : Vibeke Skytt, SINTEF, 06.94.\n* \n* \n*********************************************************************/  \n{\n int i,i1,i2,j,k,l;           /* Loop variables */\n int r, k1, k2;               /* Counters.      */\n int knvar;\n  int knumb1;             /* Number of Bezier segments in first direction*/\n  int knumb2;             /* Number of Bezier segments in second direction*/\n  int kdum1,kdum2;        /* Dummy varaible */\n  int kstat;\n  int kdim;              /* Spatial dimension */\n  int krat;              /* Indicator rational/nonrational curve */\n  int kpos=0;\n  int kkps1=ps->ik1;       /* The order of the input curve */\n  int kgradps1=kkps1-1;    /* The degree of the input curve */\n  int kkps2=ps->ik2;       /* The order of the input curve */\n  int kkps12 = kkps1*kkps2;\n  int kgradps2=kkps2-1;    /* The degree of the input curve */\n  int order1=(power*(kgradps1))+1;  /* The polynomial order of the products\n                            in first parameter direction*/\n  int order2=(power*(kgradps2))+1;  /* The polynomial order of the products\n                            in second parameter direction*/\n  int order12 = order1*order2;\n  int kk12;\n  int *poffset=NULL;       /* Array describing offsets into the arrays\n\t\t\t      for powers of the x, y,, z and h coordinates */\n  int order=MAX(order1,order2);/* Maximum of order1 and order 2*/\n  int klength;           /* Length of arrays allocated for powers\n                            of the components */\n  int *variables=NULL;   /* An array containing the indicies of\n                            all homogeneous combinations of the\n                            curve of degree power */\n  int *kpek;             /* Pointer into variables */\n  int numbvar=0;           /* The number of tupples in variables */\n  int kpow11,kpow12;      /* Polynomial degree of products */\n  int kpow21,kpow22;      /* Polynomial degree of products */\n  double sstart1,sstart2; /* Start of current Bezier segment */\n  double send1,send2;     /* End of current Bezier segment */\n  double *scoef1=NULL;    /* Array for storage of Bezier coefficients in \n\t\t\t    mixed  x,y,z sequence*/\n  double *scoef2=NULL;    /* Array for storage of Bezier coefficients in \n\t\t\t    first all xsequence*/\n  double *qs1,*qs2;      /* Pointers */\n  double *qsx,*qsy,*qsz,*qsh;\n  double *temp1=NULL;    /* Temporary storage of product of Bezier curves */\n  double *temp2=NULL;    /* Temporary storage of product of Bezier curves */\n  double *temp3=NULL;    /* Temporary storage of product of Bezier curves */\n  double *temppek;       /* Pointer to product of Bezeir curves */\n  double *Pascal=NULL;   /* Pointer to the binomial coefficients */\n  double *psl1=NULL;     /* Pointer used in Pascals triangle */\n  double *psl2=NULL;     /* Pointer used in Pascals triangle */\n  double *powcomp=NULL;  /* Array for storage of pwoers of components */\n  double *products=NULL; /* Array for storage of inal products */\n  double *xyzh;          /* Pointer into products */\n  double *knots1=NULL;   /* Pointer to output knots */\n  double *knots2=NULL;   /* Pointer to output knots */\n  SISLSurf *qsbez=NULL; /* Input curve represetned in Bernstein knot vector */\n  int kimpl = (ecimp == NULL) ? 0 : 1;  /* Flage indicating whether an\n\t\t\t\t\t   input array of implicit coefficients\n\t\t\t\t\t   are given.                        */\n\n  /* Test input.  */\n  \n  if (inarr <1 || inarr > 3 || (inarr > 1 && !kimpl)) goto err172;\n   \n\n/* Convert the input surface to a surface with the Bernstein knot vector */\n\n  s1731(ps,&qsbez,&kstat);\n  if(kstat<0) goto error;\n\n\n\n  /* Calculate number of Bezier segments */\n\n  knumb1 = qsbez->in1/qsbez->ik1;\n  knumb2 = qsbez->in2/qsbez->ik2;\n  kk12 = qsbez->ik1*qsbez->ik2;\n\n\n/* Make number components in homogeneous polynomial of degree power in 2 or 3 dimensions */\n\n  if(ps->idim==3)\n    numbvar= (power+1)*(power+2)*(power+3)/6;\n\n *numprd=numbvar;\n\n\n/* Allocate space for temporary arrays */\n knvar = numbvar*order12;\n  temp1 = newarray(order12,DOUBLE);\n  if(temp1==NULL) goto err101;\n  temp2 = newarray(order12,DOUBLE);\n  if(temp2==NULL) goto err101;\n  temp3 = newarray(knvar,DOUBLE);\n  if(temp3==NULL) goto err101;\n\n/* Allocate space for binomial coefficients */\n  \n  Pascal = newarray((order+1)*(order+2)/2, DOUBLE);\n  if (Pascal == NULL) goto err101;\n\n  /*Allocate space for offsets into the arrays representing\n    the powers of the x,y, z and h component */\n  poffset = newarray(power+2,INT);\n  if (poffset==NULL) goto error;\n\n/* Make the actual offsets */\n\n  poffset[0]=0;\n\n  for(i=0;i<=power;i++)\n    poffset[i+1] = poffset[i] + (i*kgradps1+1)*(i*kgradps2+1);\n\n\n/* Find size of arrays for storage of powers of the components */\n\n  klength = poffset[power+1];\n\n\n/* Allocate space for powers of the components */\n  powcomp = newarray((ps->idim+1)*klength,DOUBLE);\n  if (powcomp==NULL) goto error;\n\n/* Allocate space for final product. Number of Bezier segments x\n   order of products x number of products, make at the same time\n   the number of vertices and the order */\n   *in1 = knumb1*order1;\n   *in2 = knumb2*order2;\n   *ik1 = order1;\n   *ik2 = order2;\n   if (kimpl)\n      products = new0array((*in1)*(*in2)*inarr, DOUBLE);\n   else\n      products = newarray((*in1)*(*in2)*numbvar,DOUBLE);\n  if(products==NULL) goto err101;\n  knots1 = newarray((*in1)+(*ik1),DOUBLE);\n  if (knots1==NULL) goto err101;\n  knots2 = newarray((*in2)+(*ik2),DOUBLE);\n  if (knots2==NULL) goto err101;\n\n for(i=0,psl2=Pascal; i<=order ; i++,psl1=psl2,psl2+=i)\n     {  \n       psl2[0] = (double)1;\n       \n       for(j=1;j<i;j++)\n\t psl2[j] = psl1[j-1] + psl1[j];\n\n       psl2[i] =(double)1;\n     }\n \n\n/* Detect if rational surface */\n\n  if(ps->ikind==1 || ps->ikind==3) \n    krat=0;\n  else\n    krat=1;\n  kdim = ps->idim;\n             \n  scoef1=newarray((qsbez->idim+1)*kk12,DOUBLE);\n  if(scoef1==NULL)  goto err101;\n  scoef2=newarray((qsbez->idim+1)*kk12,DOUBLE);\n  if(scoef2==NULL)  goto err101;\n\n\n/* Make the actual combinations */\n\n  variables = newarray(numbvar*(ps->idim+1),INT);\n  if(variables==NULL) goto err101;\n  \n  for(i=0,kpek=variables;i<=power;i++)\n    for(j=0;j<=power-i;j++)\n      for(k=0;k<=power-i-j;k++,kpek+=4)\n    {\n      kpek[0] = i;\n      kpek[1] = j;\n      kpek[2] = k;\n      kpek[3] = power-i-j-k;\n    }\n\n  /* Travers all Bezier segments and compute the B-spline surface\n     put into the implicit function.   */\n  \n  for(i2=0,xyzh=products;i2<knumb2;i2++)\n    for(i1=0;i1<knumb1;i1++,xyzh+=(1-kimpl)*knvar)\n     {\n       /* Pick Bezier segment of the surface */\n\n       s1733(qsbez,i1,i2,&sstart1,&send1,&sstart2,&send2,scoef1,&kstat);\n       if(kstat<0) goto error;\n      \n       /* Store knots. */\n       \n       if (i1 == 0)\n       {\n\t  if (i2 == 0)\n\t  {\n\t     for (j=0; j<order2; j++) knots2[j] = sstart2;\n\t  }\n\t  for (j=0; j<order2; j++) knots2[(i2+1)*order2+j] = send2;\n       }\n       if (i2 == 0)\n       {\n\t  if (i1 == 0)\n\t  {\n\t     for (j=0; j<order1; j++) knots1[j] = sstart1;\n\t  }\n\t  for (j=0; j<order1; j++) knots1[(i1+1)*order1+j] = send1;\n       }\n       \n       /* Order the coefficients in separate arrays */   \n       \n       for(j=0,qs1=scoef1,qs2=scoef2;j<kk12;j++,qs2++)\n\t for(l=0;l<kdim+krat;l++,qs1++)\n\t   {\n\t     qs2[l*kk12] = *qs1;\n\t   }\n       if(krat==0)\n\t {\n\t   /* Fill in \"1\"s inn the numerator */\n\t   for(j=0,qs2=scoef2+kk12*qsbez->idim;\n\t       j<kk12;j++,qs2++)\n\t     *qs2 = (double)1.0;\n\t }\n\n       /* Make all homogeneous polynomial from the ps->idim coordinates\n          pluss the numerator */\n\n       for(j=0;j<ps->idim+1;j++)\n\t {\n\n\t    s6bezpowsf(&scoef2[j*kkps12],kkps1,kkps2,power,Pascal,\n                       &powcomp[j*klength]);\n\n\t } \n\n       /* Make the homogeneous combinations of the x,y,...,h components */\n\n       for(j=0,kpek=variables,qs1=temp3;\n\t   j<numbvar;j++,kpek+=(ps->idim)+1,qs1+=(1-kimpl)*order12) \n\t {\n\t   /* Prepare multiplication of x and y powers */\n\n\n\t   qsx = &powcomp[poffset[kpek[0]]];\n\t   qsy = &powcomp[klength+poffset[kpek[1]]];\n\n\t   /* Multiply x and y powers */\n\n\t   s6multsfs(qsx,MAX(1,(kgradps1)*kpek[0]+1),\n\t\t      MAX(1,(kgradps2)*kpek[0]+1),qsy,\n\t\t      MAX(1,(kgradps1)*kpek[1]+1),\n\t\t      MAX(1,(kgradps2)*kpek[1]+1),\n\t\t      Pascal,temp1,&kpow11,&kpow12);\n\n\t   /* Prepare multiplication of z and h powers */\n\n\t   qsz = &powcomp[2*klength+poffset[kpek[2]]];\n\t   qsh = &powcomp[3*klength+poffset[kpek[3]]];\n\n\t   /* Multiply z and homogenous coordinate */\n\n\t   s6multsfs(qsz,\n\t\t      MAX(1,(kgradps1)*kpek[2]+1),\n\t\t      MAX(1,(kgradps2)*kpek[2]+1),\n\t\t      qsh,\n\t\t      MAX(1,(kgradps1)*kpek[3]+1),\n\t\t      MAX(1,(kgradps2)*kpek[3]+1),\n\t\t      Pascal,temp2,&kpow21,&kpow22);\n\t   temppek = temp2;\n\n\t   s6multsfs(temp1, kpow11,kpow12, temppek,kpow21,kpow22,\n\t\t      Pascal, qs1,&kdum1,&kdum2);\n\t   \n/*           fprintf(stdout,\"\\n %d, %d, %d, %d\",kpek[0],kpek[1],kpek[2],kpek[3]);*/\n\n\t   if (kimpl)\n\t   {\n\t      /* Multiply by implicit coefficint and put the product into\n\t\t output array.  */\n\t      \n\t      for (r=0; r<inarr; r++)\n\t\t for (k1=0; k1<order1; k1++)\n\t\t    for (k2=0; k2<order2; k2++)\n\t\t       products[((i2*order2+k2)*(*in1) + i1*order1+k1)*inarr+r]\n\t\t\t  += qs1[k2*order1+k1]*ecimp[r*numbvar+j];\n\t   }\n\t }\n\n\n       if (!kimpl)\n       {\n       /* Copy transposed version of the result onto the output\n\t  array */\n \n       for(j=0,qs2=xyzh,qs1=temp3;j<order12;j++,qs1=temp3+j)\n\t for(l=0;l<numbvar;l++,qs2++,qs1+=order12)\n\t   *qs2=(*qs1);\n       }\n     }\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error. Allocation error, not enough memory.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1326\",*jstat,kpos);\n  goto out;\n  \n  /* Wrong dimension of inarr. */\n  \n  err172 :\n     *jstat = -172;\n  s6err(\"s13267\",*jstat,kpos);\n  goto out;\n  \n/* Error in lower level routine.  */\n\n error:  *jstat = kstat;\n         s6err(\"s1326\",*jstat,kpos);\n         goto out;\n  \n  \n  /* Free local used memory. */\n  \n out: \n  if (temp1)  freearray(temp1);\n  if (temp2)  freearray(temp2);\n  if (temp3)  freearray(temp3);\n  if (scoef1) freearray(scoef1);\n  if (scoef2) freearray(scoef2);\n  if (Pascal) freearray(Pascal);\n  if (variables) freearray(variables);\n  if (powcomp) freearray(powcomp);\n  if (poffset) freearray(poffset);\n  if (qsbez) freeSurf(qsbez);\n\n  if(*jstat<0)\n    {\n      if (products) freearray(products);\n      if (knots1)    freearray(knots1);\n      if (knots2)    freearray(knots2);\n    }\n  else\n    {\n      *ecoef = products;\n      *et1    = knots1;\n      *et2    = knots2;\n    }\n\n}\n\n"
  },
  {
    "path": "src/s1327.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n\n\n#define S1327\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1327(SISLCurve *pcold,double epoint[],double enorm1[],double enorm2[],\n\t   int idim,SISLCurve **rcnew,int *jstat)\n#else\nvoid s1327(pcold,epoint,enorm1,enorm2,idim,rcnew,jstat)\n     SISLCurve   *pcold;\n     double epoint[];\n     double enorm1[];\n     double enorm2[];\n     int    idim;\n     SISLCurve   **rcnew;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Put the equation of the curve pointed at by pcold\n*              into two planes given by the point epoint and the normals\n*              enorm1 and enorm2.. The result is an equation where the\n*              new two-dimensional curve rcnew is to be equal to origo.\n*\n*\n*\n* INPUT      : pcold  - Pointer to input curve.\n*              epoint - SISLPoint in the planes.\n*              enorm1 - Normal to the first plane.\n*              enorm2 - Normal to the second plane.\n*              idim   - Dimension of the space in which the planes lie.\n*\n*\n*\n* OUTPUT     : rcnew  - The new two-dimensional curve.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newCurve   - Create and initialize new curve.\n*\n* WRITTEN BY : Johannes Kaasa, SINTEF, 99-11, based on s1328.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;    /* Position of error.                            */\n  int kdim;        /* Dimension of the space in which the output\n\t\t      curve lies.                                   */\n  int kn;          /* Number of coefficients of curve.              */\n  int kk;          /* Order of curve.                               */\n  int ikind;       /* kind of surface psold is.                     */\n  double *scoef = SISL_NULL; /* Coeffecient array of new curve.          */\n  double *s1,*s2;  /* Pointers used to traverse scoef.              */\n  double *sc=SISL_NULL; /* Pointer used to traverse pcold->ecoef.        */\n  double *scSave=SISL_NULL; /* Pointer to new vertices in rational case. */\n  double *s3;      /* Stop pointer of vertex in psold->ecoef.       */\n  double *spoint;  /* Pointer used to traverse the point epoint.    */\n  double *snorm1;  /* Pointer used to traverse the normal enorm1.   */\n  double *snorm2;  /* Pointer used to traverse the normal enorm2.   */\n  double *rscoef;  /* Scaled coefficients if pcold is rational      */\n  double wmin,wmax;/* min and max values of the weights if rational */\n  double scale;    /* factor for scaling weights if rational        */\n  int i;           /* loop variable                                 */\n  int idimp1;      /* idim+1                                        */\n\n  /* Test input.  */\n\n  if (idim != pcold -> idim) goto err106;\n\n  /* Set simple variables of the new surface.  */\n\n  kdim = 2;\n  kn = pcold -> in;\n  kk = pcold -> ik;\n  ikind = pcold -> ikind;\n\n  /* rational curves are a special case */\n  if(ikind == 2 || ikind == 4)\n  {\n      /* scale the coeffs so that min. weight * max. weight = 1  */\n      idimp1=idim+1;\n      rscoef = pcold -> rcoef;\n      wmin=rscoef[idim];\n      wmax=rscoef[idim];\n      for(i=idim; i< kn*idimp1; i+=idimp1)\n      {\n          if(rscoef[i] < wmin) wmin=rscoef[i];\n          if(rscoef[i] > wmax) wmax=rscoef[i];\n      }\n      scale=1.0/sqrt(wmin*wmax);\n      if ((sc=newarray(kn*idimp1,DOUBLE)) == SISL_NULL) goto err101;\n\n      for(i=0; i< kn*idimp1; i++)\n      {\n          sc[i]=rscoef[i]*scale;\n      }\n\n      scSave = sc;\n  }\n  else\n  {\n      sc = pcold -> ecoef;\n  }\n\n  /* Allocate space for coeffecient of the new surface.  */\n\n  if ((scoef = newarray(kdim*kn,double)) == SISL_NULL) goto err101;\n\n  /* Compute coefficients of new surface.  */\n\n  for (s1=scoef,s2=s1+kdim*kn; s1<s2; s1+=2)\n    {\n      *s1 = *(s1+1) = 0;\n      spoint = epoint;\n      snorm1 = enorm1;\n      snorm2 = enorm2;\n      if(ikind == 2 || ikind == 4)\n      {\n      /* surface is rational so we're using idim+1 - d homogeneous coords */\n          for (s3=sc+idim; sc<s3; sc++,spoint++,snorm1++,snorm2++)\n\t    {\n\t      *s1 += ((*s3)*(*spoint) - *sc)*(*snorm1);\n\t      *(s1+1) += ((*s3)*(*spoint) - *sc)*(*snorm2);\n\t    }\n          sc++;\n      }\n      else\n      {\n      /* surface is not rational so we're using ordinary idim - d coords */\n          for (s3=sc+idim; sc<s3; sc++,spoint++,snorm1++,snorm2++)\n\t    {\n\t      *s1 += (*spoint - *sc)*(*snorm1);\n\t      *(s1+1) += (*spoint - *sc)*(*snorm2);\n\t    }\n      }\n    }\n\n\n  if(ikind == 2 || ikind == 4) freearray(scSave);\n\n  /* Create output curve.  */\n\n  *rcnew = newCurve(kn,kk,pcold->et,scoef,1,kdim,1);\n  if (*rcnew == SISL_NULL) goto err101;\n\n  /* Task done.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n  err101: *jstat = -101;\n    s6err(\"s1327\",*jstat,kpos);\n    goto out;\n\n  /* Error in input. Confliction dimensions.  */\n\n  err106 : *jstat = -106;\n    s6err(\"s1327\",*jstat,kpos);\n    goto out;\n\n  out:\n\n  /* Free space allocated for local array.  */\n\n    if (scoef != SISL_NULL) freearray(scoef);\n    return;\n}\n"
  },
  {
    "path": "src/s1328.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1328.c,v 1.3 2001-03-19 15:58:44 afr Exp $\n *\n */\n\n\n#define S1328\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1328(SISLSurf *psold,double epoint[],double enorm1[],double enorm2[],\n\t   int idim,SISLSurf **rsnew,int *jstat)\n#else\nvoid s1328(psold,epoint,enorm1,enorm2,idim,rsnew,jstat)\n     SISLSurf   *psold;\n     double epoint[];\n     double enorm1[];\n     double enorm2[];\n     int    idim;\n     SISLSurf   **rsnew;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Put the equation of the surface pointed at by psold\n*              into two planes given by the point epoint and the normals\n*              enorm1 and enorm2.. The result is an equation where the \n*              new two-dimensional surface rsnew is to be equal to origo.\n*\n*\n*\n* INPUT      : psold  - Pointer to input surface.\n*              epoint - SISLPoint in the planes.\n*              enorm1 - Normal to the first plane.\n*              enorm2 - Normal to the second plane.\n*              idim   - Dimension of the space in which the planes lie.\n*\n*\n*\n* OUTPUT     : rsnew  - The new two-dimensional surface.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newSurf   - Create and initialize new surface.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-06.\n* REVISED BY : Mike Floater, SI, 91-04.\n* DEBUGGED BY : Mike Floater, SI, 94-06. Use scSave.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;    /* Position of error.                            */\n  int kdim;        /* Dimension of the space in which the output \n\t\t      surface lies.                                 */\n  int kn1,kn2;     /* Number of coefficients of surface.            */\n  int kk1,kk2;     /* Order of surface.                             */\n  int ikind;       /* kind of surface psold is.                     */\n  double *scoef = SISL_NULL; /* Coeffecient array of new surface.        */\n  double *s1,*s2;  /* Pointers used to traverse scoef.              */\n  double *sc=SISL_NULL; /* Pointer used to traverse psold->ecoef.        */\n  double *scSave=SISL_NULL; /* Pointer to new vertices in rational case. */\n  double *s3;      /* Stop pointer of vertex in psold->ecoef.       */\n  double *spoint;  /* Pointer used to traverse the point epoint.    */\n  double *snorm1;  /* Pointer used to traverse the normal enorm1.   */\n  double *snorm2;  /* Pointer used to traverse the normal enorm2.   */\n  double *rscoef;  /* Scaled coefficients if psold is rational      */\n  double wmin,wmax;/* min and max values of the weights if rational */\n  double scale;    /* factor for scaling weights if rational        */\n  int i;           /* loop variable                                 */\n  int idimp1;      /* idim+1                                        */\n  \n  /* Test input.  */\n  \n  if (idim != psold -> idim) goto err106;\n  \n  /* Set simple variables of the new surface.  */\n  \n  kdim = 2;\n  kn1 = psold -> in1;\n  kn2 = psold -> in2;\n  kk1 = psold -> ik1;\n  kk2 = psold -> ik2;\n  ikind = psold -> ikind;\n  \n  /* rational surfaces are a special case */\n  if(ikind == 2 || ikind == 4)\n  {\n      /* scale the coeffs so that min. weight * max. weight = 1  */\n      idimp1=idim+1;\n      rscoef = psold -> rcoef;\n      wmin=rscoef[idim];\n      wmax=rscoef[idim];\n      for(i=idim; i< kn1*kn2*idimp1; i+=idimp1)\n      {\n          if(rscoef[i] < wmin) wmin=rscoef[i];\n          if(rscoef[i] > wmax) wmax=rscoef[i];\n      } \n      scale=1.0/sqrt(wmin*wmax);\n      if ((sc=newarray(kn1*kn2*idimp1,DOUBLE)) == SISL_NULL) goto err101;\n      \n      for(i=0; i< kn1*kn2*idimp1; i++)\n      {\n          sc[i]=rscoef[i]*scale;\n      } \n\n      scSave = sc;\n  }\n  else\n  {\n      sc = psold -> ecoef;\n  }\n\n  /* Allocate space for coeffecient of the new surface.  */\n  \n  if ((scoef = newarray(kdim*kn1*kn2,double)) == SISL_NULL) goto err101;\n  \n  /* Compute coefficients of new surface.  */\n  \n  for (s1=scoef,s2=s1+kdim*kn1*kn2; s1<s2; s1+=2)\n    {\n      *s1 = *(s1+1) = 0;\n      spoint = epoint;\n      snorm1 = enorm1;\n      snorm2 = enorm2;\n      if(ikind == 2 || ikind == 4)\n      {\n      /* surface is rational so we're using idim+1 - d homogeneous coords */\n          for (s3=sc+idim; sc<s3; sc++,spoint++,snorm1++,snorm2++)\n\t    {\n\t      *s1 += ((*s3)*(*spoint) - *sc)*(*snorm1);\n\t      *(s1+1) += ((*s3)*(*spoint) - *sc)*(*snorm2);\n\t    }\n          sc++;\n      }\n      else\n      {\n      /* surface is not rational so we're using ordinary idim - d coords */\n          for (s3=sc+idim; sc<s3; sc++,spoint++,snorm1++,snorm2++)\n\t    {\n\t      *s1 += (*spoint - *sc)*(*snorm1);\n\t      *(s1+1) += (*spoint - *sc)*(*snorm2);\n\t    }\n      }\n    }\n  \n  \n  if(ikind == 2 || ikind == 4) freearray(scSave);\n\n  /* Create output surface.  */\n  \n  *rsnew = newSurf(kn1,kn2,kk1,kk2,psold->et1,psold->et2,scoef,1,kdim,1);\n  if (*rsnew == SISL_NULL) goto err101;\n  \n  /* Task done.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n  err101: *jstat = -101;\n    s6err(\"s1328\",*jstat,kpos);\n    goto out;\n  \n  /* Error in input. Confliction dimensions.  */\n  \n  err106 : *jstat = -106;\n    s6err(\"s1328\",*jstat,kpos);\n    goto out;\n  \n  out:\n  \n  /* Free space allocated for local array.  */\n  \n    if (scoef != SISL_NULL) freearray(scoef);\n    return;    \n}\n"
  },
  {
    "path": "src/s1329.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1329.c,v 1.3 2001-03-19 15:58:44 afr Exp $\n *\n */\n\n\n#define S1329\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1329(SISLSurf *psold,double epoint[],double enorm[],int idim,\n\t   SISLSurf **rsnew,int *jstat)\n#else\nvoid s1329(psold,epoint,enorm,idim,rsnew,jstat)\n     SISLSurf   *psold;\n     double epoint[];\n     double enorm[];\n     int    idim;\n     SISLSurf   **rsnew;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Put the equation of the surface pointed at by psold\n*              into the plane given by the point epoint and the normal\n*              enorm. The result is an equation where the new one-\n*              dimensional surface rsnew is to be equal to zero.\n*\n*\n*\n* INPUT      : psold  - Pointer to input surface.\n*              epoint - SISLPoint in the plane.\n*              enorm  - Normal to the plane.\n*              idim   - Dimension of the space in which the plane lies.\n*\n*\n*\n* OUTPUT     : rsnew  - The new one-dimensional surface.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newarray  - Allocate space for an array of given type.\n*              freearray - Free space occupied by a given array.\n*              newSurf   - Create and initialize new surface.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-06.\n* REVISED BY : Mike Floater, SI, 91-04.\n* CORRECTED BY: Ulf J. Krystad,  SI, 91-07.\n* DEBUGGED BY : Mike Floater, SI, 94-06. Use scSave.\n*********************************************************************\n*/\n{\n  int kpos = 0;    /* Position of error.                            */\n  int kdim;        /* Dimension of the space in which the output \n\t\t      surface lies.                                 */\n  int kn1,kn2;     /* Number of coefficients of surface.            */\n  int kk1,kk2;     /* Order of surface.                             */\n  int ikind;       /* kind of surface psold is                      */\n  double *scoef = SISL_NULL; /* Coeffecient array of new surface.        */\n  double *s1,*s2;  /* Pointers used to traverse scoef.              */\n  double *sc=SISL_NULL; /* Pointer used to traverse psold->ecoef.        */\n  double *scSave=SISL_NULL; /* Pointer to vertices in rational case.     */\n  double *rscoef;  /* Scaled coefficients if psold is rational      */\n  double *s3;      /* Stop pointer for each vertex in psold->ecoef. */\n  double *spoint;  /* Pointer used to traverse the point epoint.    */\n  double *snorm;   /* Pointer used to traverse the normal enorm.    */\n  double wmin,wmax;/* min and max values of the weights if rational */\n  double scale;    /* factor for scaling weights if rational        */\n  int i;           /* loop variable                                 */\n  int idimp1;      /* idim+1                                        */\n  \n  /* Test input.  */\n  \n  if (idim != psold -> idim) goto err106;\n  \n  /* Set simple variables of the new surface.  */\n  \n  kdim = 1;\n  kn1 = psold -> in1;\n  kn2 = psold -> in2;\n  kk1 = psold -> ik1;\n  kk2 = psold -> ik2;\n  ikind = psold -> ikind;\n  \n  /* rational surfaces are a special case */\n  if(ikind == 2 || ikind == 4)\n  {\n      /* scale the coeffs so that min. weight * max. weight = 1  */\n      idimp1=idim+1;\n      rscoef = psold -> rcoef;\n      wmin=rscoef[idim];\n      wmax=rscoef[idim];\n      for(i=idim; i< kn1*kn2*idimp1; i+=idimp1)\n      {\n          if(rscoef[i] < wmin) wmin=rscoef[i];\n          if(rscoef[i] > wmax) wmax=rscoef[i];\n      } \n      scale=1.0/sqrt(wmin*wmax);\n      if ((sc = newarray(idimp1*kn1*kn2,DOUBLE)) == SISL_NULL) goto err101;\n      for(i=0; i< kn1*kn2*idimp1; i++)\n      {\n          sc[i]=rscoef[i]*scale;\n      } \n\n      scSave = sc;\n  }\n  else\n  {\n      sc = psold -> ecoef;\n  }\n\n  /* Allocate space for coeffecient of the new surface.  */\n  \n  if ((scoef = newarray(kdim*kn1*kn2,DOUBLE)) == SISL_NULL) goto err101;\n  \n  /* Compute coefficients of new surface.  */\n  \n  for (s1=scoef,s2=s1+kn1*kn2; s1<s2; s1++)\n    {\n      *s1 = (double)0.0;\n      if(ikind == 2 || ikind == 4)\n      {\n      /* surface is rational so we're using idim+1 - d homogeneous coords */\n          for (s3=sc+idim,spoint=epoint,snorm=enorm; sc<s3; sc++,spoint++,snorm++)\n          {\n\t     /* UJK, Turned direction to get right sign in 1D*/\n\t     /* *s1 += ((*s3)*(*spoint) - *sc)*(*snorm); */\n\t     *s1 += (*sc - (*s3)*(*spoint))*(*snorm);\n          }\n          sc++;\n      }\n      else\n      {\n      /* surface is not rational so we're using ordinary idim - d coords */\n          for (s3=sc+idim,spoint=epoint,snorm=enorm; sc<s3; sc++,spoint++,snorm++)\n\t     /* UJK, Turned direction to get right sign in 1D*/\n\t     /* *s1 += (*spoint - *sc)*(*snorm); */\n\t     *s1 += (*sc - *spoint)*(*snorm);\n      }\n    }\n  \n  if(ikind == 2 || ikind == 4) freearray(scSave);\n\n  /* Create output surface.  */\n  \n  *rsnew = newSurf(kn1,kn2,kk1,kk2,psold->et1,psold->et2,scoef,1,kdim,1);\n  if (*rsnew == SISL_NULL) goto err101;\n  \n  /* Task done.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n  err101: \n    *jstat = -101;\n    s6err(\"s1329\",*jstat,kpos);\n    goto out;\n  \n  /* Error in input. Confliction dimensions.  */\n  \n  err106 : \n    *jstat = -106;\n    s6err(\"s1329\",*jstat,kpos);\n    goto out;\n  \n  out:\n    /* Free space allocated for local array.  */\n  \n    if (scoef != SISL_NULL) freearray(scoef);\n    return;    \n}\n"
  },
  {
    "path": "src/s1330.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1330.c,v 1.3 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1330\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1330(double epar11[],double epar12[],double epar21[],double epar22[],\n\t   double eval11[],double eval12[],double eval21[],double eval22[],\n\t   int *jbound,double gpar1[],double gpar2[],int *jstat)\n#else\nvoid s1330(epar11,epar12,epar21,epar22,eval11,eval12,eval21,eval22,\n           jbound,gpar1,gpar2,jstat)\n     double epar11[];\n     double epar12[];\n     double epar21[];\n     double epar22[];\n     double eval11[];\n     double eval12[];\n     double eval21[];\n     double eval22[];\n     int    *jbound;\n     double gpar1[];\n     double gpar2[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To find if there is an intersection between epar1 and\n*              epar2 with the 4-D SISLbox desribed by eval11[0]:eval11[1]\n*              in the first parameter direction and eval12[0]:eval12[1]\n*              in the second parameter direction in the first patch, and\n*              eval21[0]:eval21[1] in the first parameter direction and\n*              eval22[0]:eval22[1] in the second parameter direction in\n*              the second patch. If there is an intersection find the\n*              intersection closest to epar1.\n*\n* INPUT      : epar11 - Start of line in first surface\n*              epar12 - Start of line in second surface\n*              epar21 - End of line in first surface\n*              epar22 - End of line in second surface\n*              eval11 - Interval in first parameter direction in patch 1\n*              eval12 - Interval in second parameter direction in patch 1\n*              eval21 - Interval in first parameter direction in patch 2\n*              eval22 - Interval in second parameter direction in patch 2\n*\n*\n* OUTPUT     : gpar1  - Parameter pair of intersection in first surface\n*            : gpar2  - Parameter pair of intersection in second surface\n*              jbound - Indicator telling along which boundary\n*                       we have an intersection\n*                       = 0      :  no intersection\n*                       = 1      : intersection along u=eval11[0]\n*                       = 2      : intersection along v=eval12[1]\n*                       = 3      : intersection along u=eval11[1]\n*                       = 4      : intersection along v=eval12[0]\n*                       = 5      : intersection along s=eval21[0]\n*                       = 6      : intersection along t=eval22[1]\n*                       = 7      : intersection along s=eval21[1]\n*                       = 8      : intersection along t=eval22[0]\n*              jstat  - status messages  \n*                       = 0      : Line outside no intersection\n*                       = 1      : Line inside  no intersection\n*                       = 2      : epar2 outside, epar1 inside, step out\n*                       = 3      : epar1 outside, epar2 inside, step in\n*                       = 4      : epar2 outside, epar1 on boundary\n*                       < 0      : error         \n*\n*                                  \n* METHOD     : \n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 16-August-1988\n* Revised by : Tor Dokken, SI, Oslo, Norway, 3-april-1989\n*              Correction of long steps\n*\n*********************************************************************\n*/\n{\n  int    kstat1=0,kstat2=0;  /* Local status variable                        */\n  int    kstat=0;          /* Local status variable                          */\n  int    kpos=0;         /* Position of error                                */\n  int    kins1;          /* epar1 inside/outside SISLbox                         */\n  int    kins2;          /* epar2 inside/outside SISLbox                         */\n  int    kbound1;        /*Intersection indicator along boundary of surface 1*/\n  int    kbound2;        /*Intersection indicator along boundary of surface 2*/\n  \n  double tdom;           /* Denominator of last intersection point           */\n  double tfak1,tfak2;    /* Distance to straight line                        */\n  double spar11[2];      /*Candidate intersection point two first coordinates*/\n  double spar12[2];      /*Candidate intersection point two last coordinates */\n  double spar21[2];      /*Candidate intersection point two first coordinates*/\n  double spar22[2];      /*Candidate intersection point two last coordinates */\n  \n  *jbound = 0;\n  \n  /* Test if both ends are inside */\n  \n  kins1 = kins2 = 0; \n  \n  if (eval11[0] <= epar11[0]+REL_PAR_RES && epar11[0] <= eval11[1]+REL_PAR_RES &&\n      eval12[0] <= epar11[1]+REL_PAR_RES && epar11[1] <= eval12[1]+REL_PAR_RES &&\n      eval21[0] <= epar12[0]+REL_PAR_RES && epar12[0] <= eval21[1]+REL_PAR_RES &&\n      eval22[0] <= epar12[1]+REL_PAR_RES && epar12[1] <= eval22[1]+REL_PAR_RES) \n    kins1 = 1;\n  \n  if (eval11[0] <= epar21[0]+REL_PAR_RES && epar21[0] <= eval11[1]+REL_PAR_RES &&\n      eval12[0] <= epar21[1]+REL_PAR_RES && epar21[1] <= eval12[1]+REL_PAR_RES &&\n      eval21[0] <= epar22[0]+REL_PAR_RES && epar22[0] <= eval21[1]+REL_PAR_RES &&\n      eval22[0] <= epar22[1]+REL_PAR_RES && epar22[1] <= eval22[1]+REL_PAR_RES) \n    kins2 = 1;\n   \n  \n  /* Test if we step from the boundary and out */\n  \n  /* if ((eval11[0] == epar11[0] && epar21[0] < eval11[0]) || */\n  /*     (epar11[0] == eval11[1] && eval11[1] < epar21[0]) || */\n  /*     (eval12[0] == epar11[1] && epar21[1] < eval12[0]) || */\n  /*     (epar11[1] == eval12[1] && eval12[1] < epar21[1]) || */\n  /*     (eval21[0] == epar12[0] && epar22[0] < eval21[0]) || */\n  /*     (epar12[0] == eval21[1] && eval21[1] < epar22[0]) || */\n  /*     (eval22[0] == epar12[1] && epar22[1] < eval22[0]) || */\n  /*     (epar12[1] == eval22[1] && eval22[1] < epar22[1])) goto war04; */\n  if ((DEQUAL(eval11[0],epar11[0]) && epar21[0] < eval11[0]) ||\n      (DEQUAL(epar11[0],eval11[1]) && eval11[1] < epar21[0]) ||\n      (DEQUAL(eval12[0],epar11[1]) && epar21[1] < eval12[0]) ||\n      (DEQUAL(epar11[1],eval12[1]) && eval12[1] < epar21[1]) ||\n      (DEQUAL(eval21[0],epar12[0]) && epar22[0] < eval21[0]) ||\n      (DEQUAL(epar12[0],eval21[1]) && eval21[1] < epar22[0]) ||\n      (DEQUAL(eval22[0],epar12[1]) && epar22[1] < eval22[0]) ||\n      (DEQUAL(epar12[1],eval22[1]) && eval22[1] < epar22[1])) \n     goto war04;\n  \n  if (kins1==1 && kins2==1) \n    goto war01;\n  \n  /* Test if both ends are to the left, right, below or above */\n  \n  if ( (epar11[0]  < eval11[0] && epar21[0]  < eval11[0]) ||\n      (eval11[1] < epar11[0]  && eval11[1] < epar21[0] ) ||\n      (epar11[1]  < eval12[0] && epar21[1]  < eval12[0]) ||\n      (eval12[1] < epar11[1]  && eval12[1] < epar21[1] ) ||\n      (epar12[0]  < eval21[0] && epar22[0]  < eval21[0]) ||\n      (eval21[1] < epar12[0]  && eval21[1] < epar22[0] ) ||\n      (epar12[1]  < eval22[0] && epar22[1]  < eval22[0]) ||\n      (eval22[1] < epar12[1]  && eval22[1] < epar22[1] )   ) \n    goto war00;\n  \n  \n  \n  /* Check if intersection in first two dimensions */                            \n  \n  s1305(epar11,epar21,eval11,eval12,&kbound1,spar11,&kstat);\n  \n  if (kstat<0) goto error;\n  kstat1 = kstat;\n  if (kstat1==0) goto war00;\n  \n  /* Calculate two last coefficients */\n  \n  if (kstat1==2 || kstat1==3)\n    {\n      tfak1 = fabs(spar11[0]-epar11[0]) + fabs(spar11[1]-epar11[1]);\n      tfak2 = fabs(epar21[0]-spar11[0]) + fabs(epar21[1]-spar11[1]);\n      tdom = tfak1 + tfak2;\n      if (DNEQUAL(tdom,DZERO))\n        {\n\t  spar12[0] = (tfak2*epar12[0] + tfak1*epar22[0])/tdom;\n\t  spar12[1] = (tfak2*epar12[1] + tfak1*epar22[1])/tdom;\n\t  \n\t  /* If the two last coefficients are zero, then then this intersection\n\t     point must be discarded */\n\t  \n\t  if (spar12[0]<eval21[0] || eval21[1]<spar12[0] ||\n\t      spar12[1]<eval22[0] || eval22[1]<spar12[1])\n            {\n\t      /* Intersection point outside */\n\t      \n\t      kbound1 = 0;\n            }\n        }\n      else\n        {\n\t  /* epar1, spar and epar2 has equal first coordinates, since there\n\t     is an intersection all must lie on the boundary, thus all are\n\t     inside */\n\t  \n\t  kbound1 = 0;\n        }\n    }\n  else if (kstat1==4 && kins1==1)\n    {\n      /* On boundary and stepping out */\n      goto war04;\n    }\n  \n  /* Check if intersection in last two dimensions */\n  \n  s1305(epar12,epar22,eval21,eval22,&kbound2,spar22,&kstat);\n  \n  if (kstat<0) \n    goto error;\n  kstat2 = kstat;\n  if (kstat2==0) \n    goto war00;\n  \n  if (kstat1==1 && kstat2==1) \n    goto war01;\n  \n  \n  /* Calculate two last coefficients */\n  \n  if (kstat2==2 || kstat2==3)\n    {\n      tfak1 = fabs(spar22[0]-epar12[0]) + fabs(spar22[1]-epar12[1]);\n      tfak2 = fabs(epar22[0]-spar22[0]) + fabs(epar22[1]-spar22[1]);\n      tdom = tfak1 + tfak2;\n      if (DNEQUAL(tdom,DZERO))\n        {\n\t  spar21[0] = (tfak2*epar11[0] + tfak1*epar21[0])/tdom;\n\t  spar21[1] = (tfak2*epar11[1] + tfak1*epar21[1])/tdom;\n\t  \n\t  /* If the two last coefficients are zero, then then this intersection\n\t     point must be discarded */\n\t  \n\t  if (spar21[0]<eval11[0] || eval11[1]<spar21[0] ||\n\t      spar21[1]<eval12[0] || eval12[1]<spar21[1])\n            {\n\t      /*          Intersection point outside */\n\t      \n\t      kbound2 = 0;\n            }\n        }\n      else\n        {\n\t  /* epar1, spar and epar2 has equal last coordinates, since there\n\t     is an intersection all must lie on the boundary, thus all are\n\t     inside */\n\t  \n\t  kbound2 = 0;\n        }\n    }\n  else if (kstat2==4 && kins1==1)\n    {\n      /*  On boundary and stepping out */\n      goto war04;\n    }\n  \n  /* kbound1 and kbound2 tells if we have got and intersection with the\n     boundary */\n  \n  \n  /* If intersections along both boundaries then find which intersection\n     is closest to epar1 */\n  \n  if (kbound1!=0 && kbound2!=0)\n    {\n/*guen      int t1,t2,t3,t4;*/ /* temporary varuiables */\n/*guen changed to           */\n      double t1,t2,t3,t4; /* temporary variables */\n\n      t1 = s6dist(spar11,epar11,2);\n      t2 = s6dist(spar12,epar12,2);\n      t3 = s6dist(spar21,epar11,2);\n      t4 = s6dist(spar22,epar12,2);\n      \n      if ((t1*t1+t2*t2) < (t3*t3+t4*t4) )\n        kbound2 = 0;\n      else\n        kbound1 = 0;\n    }\n  \n  if (kbound1==0 && kbound2 ==0)\n    {\n      /*  No intersection */\n      goto war00;\n    }\n  else if (kbound1!=0 && kbound2==0)\n    {\n      /*  Intersection with boundary of first patch */\n      memcopy(gpar1,spar11,2,DOUBLE);\n      memcopy(gpar2,spar12,2,DOUBLE);\n      *jbound = kbound1;\n    }\n  else if (kbound1==0 && kbound2!=0)\n    {\n      /*  Intersection with boundary of second patch */\n      memcopy(gpar1,spar21,2,DOUBLE);\n      memcopy(gpar2,spar22,2,DOUBLE);\n      *jbound = kbound2+4;\n    }\n  \n  if (kins1 == 1)\n    {\n      if (eval11[0] == epar11[0] || epar11[0] == eval11[1] ||\n\t  eval12[0] == epar11[1] || epar11[1] == eval12[1] ||\n\t  eval21[0] == epar12[0] || epar12[0] == eval21[1] ||\n\t  eval22[0] == epar12[1] || epar12[1] == eval22[1])\n        {\n\t  goto war04;\n\t}\n      else\n\t{\n\t  goto war02; \n\t}\n    }\n  \n  if (kins2 == 1) \n    goto war03; \n  \n  goto war05;\n  \n  /* Line outside */\n  \n war00:\n  *jstat = 0;\n  goto out;                                                                      \n  \n  /* Line inside */                          \n  \n war01:\n  *jstat = 1;\n  goto out;\n  \n  /* epar1 inside epar2 outside */\n war02:\n  *jstat = 2;\n  goto out;\n  \n  /* epar2 inside epar1 outside */\n war03:\n  *jstat = 3;\n  goto out;\n  \n  /* epar1 on boundary, epar2 outside */\n war04:\n  *jstat = 4;\n  goto out;\n  \n  /* Special error */\n war05:\n  *jstat = 5;\n  goto out;\n  \n  /* Error in lower leve function */\n error:\n  *jstat = kstat;\n  s6err(\"s1330\",*jstat,kpos);\n  goto out;\n  \n  \n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1331.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1331.c,v 1.2 2001-03-19 15:58:45 afr Exp $\n *\n */\n\n\n#define S1331\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1331(double ep[],double eimpli[],int ideg,int ider,\n\t   double gder[],double gnorm[],int *jstat)\n#else\nvoid s1331(ep,eimpli,ideg,ider,gder,gnorm,jstat)\n     double ep[];\n     double eimpli[];\n     int    ideg;\n     int    ider;\n     double gder[];\n     double gnorm[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate the position and derivatives up to second\n*              order of a point (and corresponding derivatives) put into\n*              the equation of an implicit surface.\n*\n*   \n* INPUT      : ep     - 0-2 order derivatives of B-spline surface.\n*                       For ideg=1,2 and 1001 the sequence is position,\n*                       first derivative in first parameter direction,\n*                       first derivative in second parameter direction,\n*                       (2,0) derivative, (1,1) derivative, (0,2) derivative\n*                       and normal. (21 numbers)\n*                       For ideg=1003,1004,1005 the second derivatives are followed\n*                       by the third derivatives and the normal (33 numbers)\n*                       Compatible with output of s1421\n*              eimpli - Description of the implicit surface\n*              ideg   - The degree of the implicit surface\n*                        ideg=1:    Plane              \n*                        ideg=2;    Quadric surface\n*                        ideg=1001: Torus surface\n*                        ideg=1003: Silhouette line parallel projection\n*                        ideg=1004: Silhouette line perspective projection\n*                        ideg=1005: Silhouette line circular projection\n*              ider   - Derivatives to be calculated\n*                        ider=-1:   Normal\n*                        ider=0:    Value + normal\n*                        ider=1:    Value + first derivatives + normal\n*                        ider=2:    Value + 1.st + 2.nd + normal\n*                       Note if ideg=1003,1004,1005 then ider is set to max(ider,1).\n*\n*\n* OUTPUT     : \n*              jstat  - status messages\n*                         = 0      : ok, curvature radius\n*                         < 0      : error\n*\n*              gder   - Specified derivatives in order: value, \n*                       1.st derivatives and 2.nd derivatives\n*              gnorm  - Normal of the implicit surface.\n*                       When ideg=1003,1004,1005 i.e. for silhouette curves\n*                       gnorm = f P - f P  which is the direction of\n*                                v u   u v\n*                       the silhouette curve along the surface P.\n*\n* METHOD \n*\n* USE:         This function is only working for 3-D input\n*\n* REFERENCES : \n*-\n* CALLS      : s6scpr,fabs,s1307,s6err\n*              \n*\n* WRITTEN BY : Tor Dokken, SI, Oslo , Norway, 10 October 1988\n* REVISED BY : Mike Floater, SI, Oslo , Norway, 31 January 1991 \n*               Added perspective silhouette (ideg=1004) and\n*                     circular silhouette (ideg=1005).\n*               Introduced a proper useable definition of gnorm for silhouettes.\n*               It's a little different from the usual cases. See s1331\n*               in order to see how it is used.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;          /* Local status variable                       */\n  int ki,kj,kl;           /* Control variables in loop                   */\n  int kpos = 0;           /* Position of error                           */\n  int ksize;              /* Number of doubles for storage of derivateves\n\t\t\t     and normal vector */\n  int ksizem3;            /* ksize - 3                               */\n  double *spu;            /* Pointer to dP/ds                            */\n  double *spv;            /* Pointer to dP/dt                            */\n  double *spuu;           /* Pointer to ddP/(dsds)                       */\n  double *spuv;           /* Pointer to ddP/(dsdt)                       */\n  double *spvv;           /* Pointer to ddP/(dtdt)                       */\n  \n  \n  /* If ideg=1,2 or 1001 then only derivatives up to second order\n     are calculated, then 18 doubles for derivatives and 3 for the\n     normal vector are to be used for calculation of points in the\n     spline surface. For ideg=1003,1004,1005 we have a silhouette curve and\n     derivatives up to the third are to be calculated,\n     thus 30 +3 a total of 33 doubles may be calculated.\n     Note, gnorm in these cases is replaced by f P - f P\n                                                v u   u v\n     so we need ideg to be at least 1. */\n  \n  if (ideg == 1003 || ideg == 1004 || ideg == 1005)\n    {\n      ksize = 33;\n      ider=max(ider,1);\n    }\n  else\n    {\n      ksize = 21;\n    }\n\n  ksizem3 = ksize -3;\n  \n  /* The calculation of the derivatives of one parameter direction with\n   *  respect to the other is dependent on the degree of the implicit equation\n   */\n  \n  /* Set local pointers */\n  \n  spu = ep + 3;\n  spv = ep + 6;\n  spuu = ep + 9;\n  spuv = ep + 12;\n  spvv = ep + 15;\n  \n  if (ideg == 1)\n    {\n      /*  First degree implicit geometry. \n       *\n       *   Let A = (eimpli[0],eimpli[1],eimpli[2],eimpli[3]) and\n       *       Q= (P(s,t),1), \n       *   then putting  Q into the implicit equation gives\n       *\n       *    f(u,v) = A Q\n       *\n       *    df         dQ\n       *    --     = A -- = N P , where N is the normal vector of the plane.\n       *    du         du      u\n       *\n       *    df         dQ\n       *    --     = A -- = N P \n       *    dv         dv      v\n       *\n       *     2          2\n       *    d f        d Q\n       *    --     = A --- = N P \n       *      2          2      uu\n       *    du         du     \n       *\n       *     2          2\n       *    d f        d Q\n       *    --     = A --- = N P \n       *    dudv       dudv     uv\n       *\n       *     2          2\n       *    d f        d Q\n       *    --     = A --- = N P \n       *      2          2      vv\n       *    dv         dv     \n       *\n       */\n      if (ider>=0)\n        {\n\t  gder[0] = s6scpr(ep,eimpli,3) + eimpli[3];\n\t  if (ider>=1)\n            {\n\t      gder[1] = s6scpr(spu,eimpli,3);\n\t      gder[2] = s6scpr(spv,eimpli,3);\n\t      if (ider>=2)\n                {\n\t\t  gder[3] = s6scpr(spuu,eimpli,3); \n\t\t  gder[4] = s6scpr(spuv,eimpli,3);\n\t\t  gder[5] = s6scpr(spvv,eimpli,3); \n                }\n            }\n        }\n      memcopy(gnorm,eimpli,3,DOUBLE);\n    }\n  else if (ideg == 2)\n    {   \n      double sq[4],sduq[4],sdvq[4];    /*vectors*/\n      double tsum1,tsum2,tsum3;        /*Accumulation of matrix product */ \n      \n     /*  Second degree implicit geometry.\n     *   Denote the 4x4 matrix representing the implicit surface a A.*\n     *\n     *   We can now calculate the u and v derivatives of the point put into\n     *   the left hand side of the implicit surface equation:\n     *\n     *            T              T\n     *      f(u,v) = Q A Q = sq Q \n     *\n     *      d        d        T      dQ    T        dQ\n     *      - f    = -- (Q A Q ) = 2 -- A Q  = 2 sq --\n     *      du       du              du             du\n     *\n     *      d        d        T      dQ    T        dQ\n     *      - f    = -- (Q A Q ) = 2 -- A Q  = 2 sq --\n     *      dv       dv              dv             dv\n     *\n     *       2        2               2                  T        2\n     *      d        d        T      d Q    T     dQ   dQ       dQ        dQ\n     *      -- f   = -- (Q A Q ) = 2 --- A Q  + 2 -- A -- = 2(sq--- + sduq--)\n     *        2        2               2          du   du         2       du\n     *      du       du              du                         du\n     *                                                          \n     *       2        2                 2               T        2\n     *      d        d          T      d Q    T    dQ dQ        d Q        dQ\n     *      --  f  = --   (Q A Q ) = 2 ----AQ  + 2 --A--  = 2(sq---- + sduq--)\n     *      dudv     dudv              dudv        du dv        dudv       dv\n     *\n     *       2        2               2                  T        2\n     *      d        d        T      d Q    T     dQ   dQ       dQ        dQ\n     *      -- f   = -- (Q A Q ) = 2 --- A Q  + 2 -- A -- = 2(sq--  + sdvq--)\n     *        2        2               2          dv   dv         2       dv\n     *      dv       dv              dv                         dv\n     *\n     *                                       dQ             dQ\n     *      First calculate sq = QA, sduq =  --A and sdvq = --A\n     *                                      du             dv\n     *\n     */\n      for (ki=0;ki<4;ki++)\n        {\n\t  tsum1 = eimpli[ki+12];\n\t  tsum2 = DZERO;\n\t  tsum3 = DZERO;\n\t  for (kj=0,kl=ki;kj<3;kj++,kl+=4)\n            {\n\t      tsum1 += eimpli[kl]*ep[kj];\n\t      if (ider>=1)\n                {\n\t\t  tsum2 += eimpli[kl]*spu[kj];\n\t\t  tsum3 += eimpli[kl]*spv[kj];\n                }\n            }\n\t  sq[ki]   = tsum1;\n\t  sduq[ki] = tsum2;\n\t  sdvq[ki] = tsum3;\n        }\n      \n      /*  Make value and partial derivatives */\n      \n      if (ider>=0)\n        {\n\t  gder[0] = s6scpr(sq,ep,3) + sq[3];\n\t  if(ider>=1)\n            {\n\t      gder[1] = (double)2.0*s6scpr(sq,spu,3);\n\t      gder[2] = (double)2.0*s6scpr(sq,spv,3);\n\t      if (ider>1)\n                {\n\t\t  gder[3] = (double)2.0*(s6scpr(sq,spuu,3) + \n\t\t\t\t\t s6scpr(sduq,spu,3));\n\t\t  gder[4] = (double)2.0*(s6scpr(sq,spuv,3) + \n\t\t\t\t\t s6scpr(sduq,spv,3));\n\t\t  gder[5] = (double)2.0*(s6scpr(sq,spvv,3) + \n\t\t\t\t\t s6scpr(sdvq,spv,3));\n                }\n            }\n        }\n      memcopy(gnorm,sq,3,DOUBLE);\n    }\n  \n  else if (ideg == 1001)\n    {\n      double sy[3],sz[3],szu[3],szv[3],szuu[3],szuv[3],szvv[3];/* Derivatives */\n      double tzn,tzun,tzvn,tzuun,tzuvn,tzvvn;            /* Scalar products */\n      double tzduz,tzdvz,tzduduz,tzdudvz,tzdvdvz;        /* Scalar products */\n      double tduzduz,tdvzdvz,tduzdvz;                    /* Scalar products */\n      double tlenz,tlenz3,tlenz5;                        /* Vector lengths  */\n      double sp[3],sdup[3],sdvp[3];                      /* temporary vectrs*/ \n      double sdudup[3],sdudvp[3],sdvdvp[3];              /* temporary vectrs*/ \n      double *scentr,*saxis,tbigr,tsmalr;                /* Torus descript  */\n\n      /*  Torus surface. */\n      \n      scentr = eimpli;\n      saxis  = eimpli + 3;\n      tbigr  = *(eimpli+6);\n      tsmalr = *(eimpli+7);\n      \n      \n/*     Intersection of implicit function of 1 and implicit torus surface\n*      and the the surface. Make the following temporary variables.\n*\n*      y = p - scentr\n*      z = y - (y saxis) saxis\n*\n*      Put the point and accompanying derivatives into the implicit\n*      representation of the torus\n*\n*                                   2    2\n*      f(u,v) = (y - R z/sqrt(z z) )  - r\n* \n*\n*                                                                \n*                                    R z          (z z )\n*      df            R z                u      R z    u\n*      -- = 2(y - ---------)(y  -  --------- + ----------)\n*      du         sqrt(z z)   u    sqrt(z z)            3\n*                                              sqrt(z z)\n*\n*         = 2 sp sdup\n*\n*\n*                                 R z            (z z ) \n*      df            R z             v        R z    v\n*      -- = 2(y - ---------)(y  - --------- + ----------)\n*      dv         sqrt(z z)   v   sqrt(z z)            3\n*                                             sqrt(z z)\n*\n*         = 2 sp sdvp\n*\n*\n*\n*                                                                \n*       2             R z            (z z )\n*      d f               u      R z      u  2\n*      --  = 2(y  - --------- + -----------)  + \n*        2      u   sqrt(z z)             3\n*      du                        sqrt(z z)\n*\n*\n*                                    R z           z (z z )\n*                     R z               uu      2R  u    u\n*            2(y - ---------)(y   - --------- + ----------- +\n*                  sqrt(z z)   uu   sqrt(z z)             3\n*                                                sqrt(z z)\n*\n*\n*                                                       2\n*                            R z(z z +zz  )       z(zz )\n*                                 u u   uu      R     u\n*                            -------------- - 3 --------- )\n*                                        3               5\n*                               sqrt(z z)       sqrt(z z)\n*\n*          = 2 sdup sdup + sp sdudup \n*\n*                                                                \n*       2               R z           (z z )          R z           (z z )\n*      d  f                u      R z     u              v      R z     v   \n*      ----  = 2(y  - --------- + -----------)(y  - --------- + -----------) +\n*                 u   sqrt(z z)             3   v   sqrt(z z)             3\n*      dudv                        sqrt(z z)                    sqrt(z z) \n*\n*\n*                                   R z           z (z z )       z (z z )\n*                    R z               uv       R  u    v      R  v    u\n*           2(y - ---------)(y   - --------- + ------------ + ------------ +\n*                 sqrt(z z)   uv   sqrt(z z)             3              3\n*                                               sqrt(z z)      sqrt(z z) \n*\n*\n*                                                        \n*                            R z(z z +zz  )       z(zz )(zz )\n*                                 v u   uv      R     u    v\n*                            -------------- - 3 -------------)\n*                                        3                 5\n*                               sqrt(z z)         sqrt(z z)\n*\n*\n*          = 2 sdup sdvp + sp sdudvp \n*\n*                                                                \n*       2             R z           (z z )\n*      d f               v      R z     v   2\n*      --  = 2(y  - --------- + -----------)  + \n*        2      v   sqrt(z z)             3\n*      dv                        sqrt(z z)\n*\n*\n*                                    R z            z (z z )\n*                     R z               vv       2R  v    v\n*            2(y - ---------)(y   - --------- + ------------ +\n*                  sqrt(z z)   vv   sqrt(z z)             3\n*                                                sqrt(z z)\n*\n*\n*                                                       2\n*                             R z(z z +zz  )       z(zz )\n*                                  v v   vv      R     v\n*                             -------------- - 3 --------- )\n*                                         3               5\n*                                sqrt(z z)       sqrt(z z)\n*\n*\n*          = 2 sdvp sdvp + sp sdvdvp \n*\n*\n*                          \n*      y  = (p - scentr)  = p\n*       u               u    u\n*\n*      y  = (p - scentr)  = p\n*       v               v    v\n*\n*      y  = (p - scentr)  = p\n*       uu              uu   uu\n*\n*      y  = (p - scentr)  = p\n*       uv              uv   uv\n*\n*      y  = (p - scentr)  = p\n*       vv              vv   vv\n*\n*      z  = (y - (y N)N)  = p  - (p N)N          N = saxis (Torus axis)\n*       u               u    u     u\n*\n*      z  = (y - (y N)N)  = p  - (p N)N\n*       v               v    v     v\n*\n*      z  = (y - (y N)N)  = p  - (p  N)N\n*       uu              uu   uu    uu\n*\n*      z  = (y - (y N)N)  = p  - (p  N)N \n*       uv              uv   uv    uv\n*\n*      z  = (y - (y N)N)  = p  - (p  N)N\n*       vv              vv   vv    vv\n*\n*/\n      for (ki=0;ki<3;ki++)\n        sy[ki] = ep[ki] - scentr[ki];\n      \n      tzn   = s6scpr(sy  ,saxis,3);\n      tzun  = s6scpr(spu ,saxis,3);\n      tzvn  = s6scpr(spv ,saxis,3);\n      if (ider>1)\n        {\n\t  tzuun = s6scpr(spuu,saxis,3);\n\t  tzuvn = s6scpr(spuv,saxis,3);\n\t  tzvvn = s6scpr(spvv,saxis,3);\n        }\n      \n      /*  Make z and necessary derivatives of z */ \n      for (ki=0;ki<3;ki++)\n        {    \n\t  sz[ki]   = sy[ki]   - tzn*saxis[ki];\n\t  szu[ki]  = spu[ki]  - tzun*saxis[ki];\n\t  szv[ki]  = spv[ki]  - tzvn*saxis[ki];\n\t  if (ider>1)\n            {\n\t      szuu[ki] = spuu[ki] - tzuun*saxis[ki];\n\t      szuv[ki] = spuv[ki] - tzuvn*saxis[ki];\n\t      szvv[ki] = spvv[ki] - tzvvn*saxis[ki];\n            }\n        }\n      \n      /*  Make a number of necessary scalar products */\n      \n      tzduz   = s6scpr(sz,szu,3);\n      tzdvz   = s6scpr(sz,szv,3);\n      tduzduz = s6scpr(szu,szu,3);\n      tduzdvz = s6scpr(szu,szv,3);\n      tdvzdvz = s6scpr(szv,szv,3);\n      if (ider>1)\n        {\n\t  tzduduz = s6scpr(sz,szuu,3);\n\t  tzdudvz = s6scpr(sz,szuv,3);\n\t  tzdvdvz = s6scpr(sz,szvv,3);\n        }      \n      \n      /*  Find lengt of sz */\n      \n      tlenz = s6length(sz,3,&kstat);\n      \n      if (kstat<0) goto error;\n      if (DEQUAL(tlenz,DZERO)) tlenz =(double)1.0;\n      tlenz3 = tlenz*tlenz*tlenz;\n      tlenz5 = tlenz3*tlenz*tlenz;\n      \n      /* Make a number of necessary vectors */\n      \n      for (ki=0;ki<3;ki++)                    \n\t{\n\t  sp[ki]   = sy[ki]  - tbigr*sz[ki]/tlenz;\n\t  if (ider>=1)\n\t    {\n\t      sdup[ki] = spu[ki] - tbigr*(szu[ki]/tlenz - sz[ki]*tzduz/tlenz3);\n\t      sdvp[ki] = spv[ki] - tbigr*(szv[ki]/tlenz - sz[ki]*tzdvz/tlenz3);\n\t      if (ider>=2)\n\t\t{\n\t\t  sdudup[ki] = spuu[ki] -\n\t\t    tbigr*(szuu[ki]/tlenz -\n\t\t\t   ((double)2.0*szu[ki]*tzduz+\n\t\t\t    sz[ki]*(tduzduz+tzduduz))/tlenz3 +\n\t\t\t   (double)3.0*sz[ki]*tzduz*tzduz/tlenz5);\n\t\t  \n\t\t  sdudvp[ki] = spuv[ki] -\n\t\t    tbigr*(szuv[ki]/tlenz -\n\t\t\t   (szu[ki]*tzdvz+szv[ki]*tzduz+\n\t\t\t    sz[ki]*(tduzdvz+tzdudvz))/tlenz3 +\n\t\t\t   (double)3.0*sz[ki]*tzduz*tzdvz/tlenz5);\n\t\t  \n\t\t  sdvdvp[ki] = spvv[ki] -\n\t\t    tbigr*(szvv[ki]/tlenz -\n\t\t\t   ((double)2.0*szv[ki]*tzdvz+\n\t\t\t    sz[ki]*(tdvzdvz+tzdvdvz))/tlenz3 +\n\t\t\t   (double)3.0*sz[ki]*tzdvz*tzdvz/tlenz5);\n\t\t}\n\t    }\n\t}\n      \n      /*  Make the derivatives */\n      if (ider>=0)\n        {\n\t  gder[0] = s6scpr(sp,sp,3) - tsmalr*tsmalr;\n\t  if (ider>=1)\n            {\n\t      gder[1] = (double)2.0*s6scpr(sp,sdup,3);\n\t      gder[2] = (double)2.0*s6scpr(sp,sdvp,3);\n\t      if (ider>=2)\n                {\n\t\t  gder[3] = (double)2.0*(s6scpr(sdup,sdup,3)+\n\t\t\t\t\t s6scpr(sp,sdudup,3)); \n\t\t  gder[4] = (double)2.0*(s6scpr(sdup,sdvp,3)+\n\t\t\t\t\t s6scpr(sp,sdudvp,3));\n\t\t  gder[5] = (double)2.0*(s6scpr(sdvp,sdvp,3)+\n\t\t\t\t\t s6scpr(sp,sdvdvp,3));\n                }\n            }\n        }\n      memcopy(gnorm,sp,3,DOUBLE);\n    }\n  \n  else if (ideg == 1003)\n    \n    {\n      \n     /* Silhouette curve, the first three elements of eimpli describes\n\tthe viewing direction.\n\t\n\tThe silhouette line is descibed by the implicit equation, when\n\tQ(u,v) is the description of the surface:\n\t\n\tf(u,v) = (Q x Q ) view = 0\n\tu   v          \n\t\n\tf      = (Q  x Q ) view + (Q x Q  ) view\n\tu         uu   v           u   uv\n\t\n\t\n\tf      = (Q  x Q ) view + (Q x Q  ) view\n\tv         uv   v           u   vv\n\t\n\t\n\t\n\tf      = (Q    x Q ) view + 2 (Q  x Q  ) view + (Q  x Q   ) view\n\tuu        uuu    v             uu   uv           u    uuv\n\t\n\t\n\tf      = (Q    x Q )view + (Q  x Q  )view + (Q  x Q  )view + (Q xQ)view\n\tuv        uuv    v          uu   vv          uv   uv          u  uvv\n\t\n\t\n\tf      = (Q    x Q ) view + 2 (Q  x Q  ) view + (Q  x Q   ) view\n\tvv        uvv    v             uv   vv           u    vvv\n\t\n\t\n\tNote that Q  x Q   has zero length.\n\tuv   uv\n      */\n      double *spuuu = ep + 18;\n      double *spuuv = ep + 21;\n      double *spuvv = ep + 24;\n      double *spvvv = ep + 27;\n      double sdum1[3],sdum2[3],sdum3[3];\n      \n      if (ider>=0)\n        {\n\t  s6crss(spu,spv,sdum1);\n\t  gder[0] = s6scpr(sdum1,eimpli,3);\n\t  if (ider>=1)\n            {\n\t      s6crss(spuu,spv,sdum1);\n\t      s6crss(spu,spuv,sdum2);\n\t      gder[1] = s6scpr(sdum1,eimpli,3) + s6scpr(sdum2,eimpli,3);\n\t      s6crss(spuv,spv,sdum1);\n\t      s6crss(spu,spvv,sdum2);\n\t      gder[2] = s6scpr(sdum1,eimpli,3) + s6scpr(sdum2,eimpli,3);\n\t      if (ider>=2)\n                {\n\t\t  s6crss(spuuu,spv,  sdum1);\n\t\t  s6crss(spuu, spuv, sdum2);\n\t\t  s6crss(spu,  spuuv,sdum3);\n\t\t  gder[3] = s6scpr(sdum1,eimpli,3) +\n\t\t    (double)2.0*s6scpr(sdum2,eimpli,3)\n\t\t      + s6scpr(sdum3,eimpli,3);;\n\t\t  s6crss(spuuv,spv,  sdum1);\n\t\t  s6crss(spuu, spvv, sdum2);\n\t\t  s6crss(spu,  spuvv,sdum3);\n\t\t  gder[4] = s6scpr(sdum1,eimpli,3) + s6scpr(sdum2,eimpli,3)\n\t\t    + s6scpr(sdum3,eimpli,3);;\n\t\t  s6crss(spuvv,spv,  sdum1);\n\t\t  s6crss(spuv, spvv, sdum2);\n\t\t  s6crss(spu,  spvvv,sdum3);\n\t\t  gder[5] = s6scpr(sdum1,eimpli,3) +\n\t\t    (double)2.0*s6scpr(sdum2,eimpli,3)\n\t\t      + s6scpr(sdum3,eimpli,3);;\n                }\n            }\n        }\n    }\n  \n  else if (ideg == 1004)\n    \n    {\n      \n     /* Perspective silhouette curve, the first three elements of eimpli\n        describe the eye point E.\n\t\n\tThe silhouette line is descibed by the implicit equation, when\n\tP(u,v) is the description of the surface and\n        N(u,v) = P x P  is the normal to the surface:\n                  u   v\n\t\n\tf(u,v) = N(u,v) . (P(u,v) - E) = 0\n\t\n        Differentiating N gives:\n\n        N = P  x  P   + P  x  P\n         u   uu    v     u     uv\n\n        N = P  x  P   + P  x  P\n         v   uv    v     u     vv\n\n        N  = P   x  P   + 2 P  x  P   + P x P\n         uu   uuu    v       uu    uv    u   uuv\n\n        N  = P   x  P   +  P  x  P   + P x P\n         uv   uuu    v      uu    vv    u   uuv\n\n        N  = P   x  P   + 2 P  x  P   + P x P\n         vv   uvv    v       uv    vv    u   vvv\n\n\n\n        Differentiating f gives:\n\n\tf = N  . (P - E)\n         u   u   \n\n\tf = N  . (P - E)\n         v   v   \n\n\tf  = N   . (P - E) + N  . P\n         uu   uu              u    u \n\n\tf  = N   . (P - E) + N  . P\n         uv   uv              u    v \n\n\tf  = N   . (P - E) + N  . P\n         vv   vv              v    v \n\n\t\n      */\n      double *spuuu = ep + 18;\n      double *spuuv = ep + 21;\n      double *spuvv = ep + 24;\n      double *spvvv = ep + 27;\n      double norm[3],normu[3],normv[3],normuu[3],normuv[3],normvv[3];\n      double cprod1[3],cprod2[3],cprod3[3];\n      double pediff[3];\n      \n\n      if (ider>=0)\n        {\n\t  s6diff(ep,eimpli,3,pediff);\n\n\t  s6crss(spu,spv,norm);\n\t  gder[0] = s6scpr(norm,pediff,3);\n\n\t  if (ider>=1)\n            {\n\t      s6crss(spuu,spv,cprod1);\n\t      s6crss(spu,spuv,cprod2);\n              for (ki=0;ki<3;ki++)\n              {    \n                  normu[ki] = cprod1[ki] + cprod2[ki];\n              }    \n\t      s6crss(spuv,spv,cprod1);\n\t      s6crss(spu,spvv,cprod2);\n              for (ki=0;ki<3;ki++)\n              {    \n                  normv[ki] = cprod1[ki] + cprod2[ki];\n              }    \n\n\t      gder[1] = s6scpr(normu,pediff,3);\n\t      gder[2] = s6scpr(normv,pediff,3);\n\n\t      if (ider>=2)\n                {\n\t\t  s6crss(spuuu,spv,cprod1);\n\t\t  s6crss(spuu,spuv,cprod2);\n\t\t  s6crss(spu,spuuv,cprod3);\n\t\t  for (ki=0;ki<3;ki++)\n\t\t  {    \n\t\t  normuu[ki] = cprod1[ki] + 2.0 * cprod2[ki] + cprod3[ki];\n\t\t  }    \n\n           /*    Note that spuv x spuv = 0 in the formula for normuv  */\n\t\t  s6crss(spuuv,spv,cprod1);\n\t\t  s6crss(spuu,spvv,cprod2);\n\t\t  s6crss(spu,spuvv,cprod3);\n\t\t  for (ki=0;ki<3;ki++)\n\t\t  {    \n\t\t  normuv[ki] = cprod1[ki] + cprod2[ki] + cprod3[ki];\n\t\t  }    \n\n\t\t  s6crss(spuvv,spv,cprod1);\n\t\t  s6crss(spuv,spvv,cprod2);\n\t\t  s6crss(spu,spvvv,cprod3);\n\t\t  for (ki=0;ki<3;ki++)\n\t\t  {    \n\t\t  normvv[ki] = cprod1[ki] + 2.0 * cprod2[ki] + cprod3[ki];\n\t\t  }    \n\n\t\t  gder[3] = s6scpr(normuu,pediff,3) + s6scpr(normu,spu,3);\n\t\t  gder[4] = s6scpr(normuv,pediff,3) + s6scpr(normu,spv,3);\n\t\t  gder[5] = s6scpr(normvv,pediff,3) + s6scpr(normv,spv,3);\n\n                }\n            }\n        }\n    }\n  \n  else if (ideg == 1005)\n    \n    {\n      \n     /* Perspective silhouette curve, the first three elements of eimpli\n        describe Q, the next three  describe B.\n\t\n\tThe silhouette line is descibed by the implicit equation, when\n\tP(u,v) is the description of the surface and\n        N(u,v) = P x P  is the normal to the surface:\n                  u   v\n\t\n\tf(u,v) = N(u,v) x (P(u,v) - Q) . B = 0\n\t\n        Differentiating N gives:\n\n        N = P  x  P   + P  x  P\n         u   uu    v     u     uv\n\n        N = P  x  P   + P  x  P\n         v   uv    v     u     vv\n\n        N  = P   x  P   + 2 P  x  P   + P x P\n         uu   uuu    v       uu    uv    u   uuv\n\n        N  = P   x  P   +  P  x  P   + P x P\n         uv   uuu    v      uu    vv    u   uuv\n\n        N  = P   x  P   + 2 P  x  P   + P x P\n         vv   uvv    v       uv    vv    u   vvv\n\n\n\n        Differentiating f gives:\n\n\tf = { N  x (P - Q) + N x P } . B\n         u     u                  u\n\n\tf = { N  x (P - Q) + N x P } . B\n         v     v                  v\n\n\tf  = { N   x (P - Q) + 2 N x P  + N x P  } . B\n         uu     uu                u   u        uu\n\n\tf  = { N   x (P - Q) + N x P  + N x P  + N x P  } . B\n         uv     uv              u   v    v   u        uv\n\n\tf  = { N   x (P - Q) + 2 N x P  + N x P  } . B\n         vv     vv                v   v        vv\n\n\t\n      */\n      double *spuuu = ep + 18;\n      double *spuuv = ep + 21;\n      double *spuvv = ep + 24;\n      double *spvvv = ep + 27;\n      double *bvec  = eimpli + 3;\n      double norm[3],normu[3],normv[3],normuu[3],normuv[3],normvv[3];\n      double cprod1[3],cprod2[3],cprod3[3],cprod4[3];\n      double pqdiff[3],sum[3];\n      \n\n      if (ider>=0)\n        {\n\t  s6diff(ep,eimpli,3,pqdiff);\n\n\t  s6crss(spu,spv,norm);\n\t  s6crss(norm,pqdiff,cprod1);\n\t  gder[0] = s6scpr(cprod1,bvec,3);\n\n\t  if (ider>=1)\n            {\n\t      s6crss(spuu,spv,cprod1);\n\t      s6crss(spu,spuv,cprod2);\n              for (ki=0;ki<3;ki++)\n              {    \n                  normu[ki] = cprod1[ki] + cprod2[ki];\n              }    \n\t      s6crss(spuv,spv,cprod1);\n\t      s6crss(spu,spvv,cprod2);\n              for (ki=0;ki<3;ki++)\n              {    \n                  normv[ki] = cprod1[ki] + cprod2[ki];\n              }    \n\n\t      s6crss(normu,pqdiff,cprod1);\n\t      s6crss(norm,spu,cprod2);\n              for (ki=0;ki<3;ki++)\n              {    \n                  sum[ki] = cprod1[ki] + cprod2[ki];\n              }    \n\t      gder[1] = s6scpr(sum,bvec,3);\n\n\t      s6crss(normv,pqdiff,cprod1);\n\t      s6crss(norm,spv,cprod2);\n              for (ki=0;ki<3;ki++)\n              {    \n                  sum[ki] = cprod1[ki] + cprod2[ki];\n              }    \n\t      gder[2] = s6scpr(sum,bvec,3);\n\n\t      if (ider>=2)\n                {\n\t\t  s6crss(spuuu,spv,cprod1);\n\t\t  s6crss(spuu,spuv,cprod2);\n\t\t  s6crss(spu,spuuv,cprod3);\n\t\t  for (ki=0;ki<3;ki++)\n\t\t  {    \n\t\t  normuu[ki] = cprod1[ki] + 2.0 * cprod2[ki] + cprod3[ki];\n\t\t  }    \n\n           /*    Note that spuv x spuv = 0 in the formula for normuv  */\n\t\t  s6crss(spuuv,spv,cprod1);\n\t\t  s6crss(spuu,spvv,cprod2);\n\t\t  s6crss(spu,spuvv,cprod3);\n\t\t  for (ki=0;ki<3;ki++)\n\t\t  {    \n\t\t  normuv[ki] = cprod1[ki] + cprod2[ki] + cprod3[ki];\n\t\t  }    \n\n\t\t  s6crss(spuvv,spv,cprod1);\n\t\t  s6crss(spuv,spvv,cprod2);\n\t\t  s6crss(spu,spvvv,cprod3);\n\t\t  for (ki=0;ki<3;ki++)\n\t\t  {    \n\t\t  normvv[ki] = cprod1[ki] + 2.0 * cprod2[ki] + cprod3[ki];\n\t\t  }    \n\n\t          s6crss(normuu,pqdiff,cprod1);\n\t          s6crss(normu,spu,cprod2);\n\t          s6crss(norm,spuu,cprod3);\n                  for (ki=0;ki<3;ki++)\n                  {    \n                      sum[ki] = cprod1[ki] + 2.0 * cprod2[ki] + cprod3[ki];\n                  }    \n\t          gder[3] = s6scpr(sum,bvec,3);\n\n\t          s6crss(normuv,pqdiff,cprod1);\n\t          s6crss(normu,spv,cprod2);\n\t          s6crss(normv,spu,cprod3);\n\t          s6crss(norm,spuv,cprod4);\n                  for (ki=0;ki<3;ki++)\n                  {    \n                      sum[ki] = cprod1[ki] + cprod2[ki] + cprod3[ki] + cprod4[ki];\n                  }    \n\t          gder[4] = s6scpr(sum,bvec,3);\n\n\t          s6crss(normvv,pqdiff,cprod1);\n\t          s6crss(normv,spv,cprod2);\n\t          s6crss(norm,spvv,cprod3);\n                  for (ki=0;ki<3;ki++)\n                  {    \n                      sum[ki] = cprod1[ki] + 2.0 * cprod2[ki] + cprod3[ki];\n                  }    \n\t          gder[5] = s6scpr(sum,bvec,3);\n\n                }\n            }\n        }\n    }\n\n  if(ideg == 1003 || ideg == 1004 || ideg == 1005)\n    {\n      /*  The normal vector has no meaning in this case\n          so we calculate the direction D(u,v) of the solution curve\n          on the surface P(u,v)\n          of  f(u,v) = N(u,v) . d = 0  (ideg = 1003)\n          or  f(u,v) = N(u,v) . (P(u,v) - E) = 0  (ideg = 1004)\n          or  f(u,v) = N(u,v) x (P(u,v) - Q) . B = 0  (ideg = 1005)\n          (through the present solution point)\n          directly. This direction D is in fact  f P  - f P\n                                                  v u    u v\n          where P(u,v) is the parameterised\n          surface, N is the normal P  x P  , and d is the \n                                    u    v\n\t  view direction. The direction D is used by s1331.  */\n     \n      for(ki=0; ki<3; ki++)\n        {\n          gnorm[ki] = gder[2] * spu[ki] - gder[1] * spv[ki];\n        }\n      (void)s6norm(gnorm,3,gnorm,&kstat);\n    }\n\n  /* Everyting is ok */\n  \n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error in lower level function */\n error:\n  *jstat = kstat;\n  s6err(\"s1331\",*jstat,kpos);\n  goto out;\n  \n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1332.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1332.c,v 1.3 2001-03-19 15:58:45 afr Exp $\n *\n */\n\n\n#define S1332\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1332(SISLCurve *pc1,SISLCurve *pc2,double aepsge,double ep[],SISLSurf **rs,int *jstat)\n#else\nvoid s1332(pc1,pc2,aepsge,ep,rs,jstat)\n     SISLCurve  *pc1;\n     SISLCurve  *pc2;\n     double aepsge;\n     double ep[];\n     SISLSurf   **rs;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To create a swept B-spline surface by making\n*              the tensor-product of two B-spline curves.\n*\n* INPUT      : pc1    - Pointer curve 1.\n*              pc2    - Pointer curve 2.\n*              aepsge - Maximal deviation allowed between true swept\n*                       surface and generated surface.\n*              ep     - SISLPoint near the curve to be swept. If the point\n*                       lies on curve 2, then curve 2 is swept along curve 1\n*                       with the point as contact point. If the point lies\n*                       on curve 1, then curve 1 is swept along curve 2 with\n*                       the point as contact point. If the point is not lying\n*                       on any of the curve, then the surface will not\n*                       interpolate any of the curves.\n*\n*\n* OUTPUT     : jstat  - status messages\n*                        > 0      : warning\n*                        = 0      : ok\n*                        < 0      : error\n*              rs     - Pointer to the surface produced.\n*\n* METHOD     : Mathematically, the surface is expressed as:\n*\n*                       in1 in2\n*              P(u,v) = SUM SUM ((p1(i) + p2(j)-ep)*w1(i)*w2(j)*B(i,ik1)*B(j,ik2)\n*                       i=1 j=1\n*-\n* CALLS      : s1707,s6err.\n*\n* WRITTEN BY : A. M. Ytrehus  SI,  Oslo, Norway.  Sep. 1988\n* REVISED BY : Johannes Kaasa SI,  Sep. 1991 (Introduced NURBS)\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Oct. 1994. Removed memory leaks.\n*********************************************************************\n*/\n{\n  double *sknot1 = SISL_NULL;  /* Pointer to knot-vector of curve 1.         */\n  double *scoef1 = SISL_NULL;  /* Pointer to vertices of curve 1.            */\n  double *rcoef1 = SISL_NULL;  /* Pointer to rational vertices of curve 1.   */\n  int kord1;              /* Order of curve 1.                          */\n  int kn1;                /* Number of vertices of curve 1.             */\n  double *sknot2 = SISL_NULL;  /* Pointer to knot-vector of curve 2.         */\n  double *scoef2 = SISL_NULL;  /* Pointer to vertices of curve 2.            */\n  double *rcoef2 = SISL_NULL;  /* Pointer to rational vertices of curve 2.   */\n  int kord2;              /* Order of curve 2.                          */\n  int kn2;                /* Number of vertices of curve 2.             */\n  int kdim;               /* Dimension of the space in which the\n\t\t\t     curves lies.                               */\n  int rdim;               /* Dimension of rational space.               */\n  double *scoef = SISL_NULL;   /* Pointer to vertex array for surface        */\n  double *sp,*spc1,*spc2; /* Pointers to scoef, scoef1 snd scoef2.      */\n  double *spnt;           /* Pointer to epoint.                         */\n  int ki,kj,kp;           /* Loop controllers.                          */\n  int kcopy,kind;         /* Variables for use in newSurf.              */\n  int kstat = 0;          /* Status variable                            */\n  int kpos = 0;           /* Position of error                          */\n\n  double *weight1 = SISL_NULL; /* Rational weights in first direction        */\n  double *weight2 = SISL_NULL; /* Rational weights in second direction       */\n  double weight;          /* Tensor product weights                     */\n\n\n  *rs = SISL_NULL;\n\n  /* The curves must have the same dimension      */\n  if (pc1 -> idim != pc2 -> idim) goto err106;\n\n  /* Make local pointers to description of curves */\n\n  if (!pc1) goto err150;\n  if (!pc2) goto err150;\n\n  s1707(pc1,&kstat);\n  if (kstat<0) goto error;\n\n  s1707(pc2,&kstat);\n  if (kstat<0) goto error;\n\n  sknot1 = pc1 -> et;\n  scoef1 = pc1 -> ecoef;\n  rcoef1 = pc1 -> rcoef;\n  kn1 = pc1 -> in;\n  kord1 = pc1 -> ik;\n  kdim = pc1 -> idim;\n\n  sknot2 = pc2 -> et;\n  scoef2 = pc2 -> ecoef;\n  rcoef2 = pc2 -> rcoef;\n  kn2 = pc2 -> in;\n  kord2 = pc2 -> ik;\n\n  /* Allocate vertex-array for the surface. */\n\n  rdim = kdim + 1;\n  if (pc1->ikind == 2 || pc1->ikind == 4\n                      || pc2->ikind == 2 || pc2->ikind == 4)\n    scoef = newarray(kn1*kn2*rdim,DOUBLE);\n  else\n    scoef = newarray(kn1*kn2*kdim,DOUBLE);\n  if (!scoef) goto err101;\n\n  /* Allocate and initiate rational weights. */\n\n  weight1 = newarray(kn1,DOUBLE);\n  if (!weight1) goto err101;\n  if (pc1->ikind == 2 || pc1->ikind == 4)\n    for (ki=0; ki<kn1; ki++)\n      weight1[ki] = rcoef1[(ki + 1)*rdim - 1];\n  else\n    for (ki=0; ki<kn1; ki++)\n      weight1[ki] = 1.;\n  weight2 = newarray(kn2,DOUBLE);\n  if (!weight2) goto err101;\n  if (pc2->ikind == 2 || pc2->ikind == 4)\n    for (ki=0; ki<kn2; ki++)\n      weight2[ki] = rcoef2[(ki + 1)*rdim - 1];\n  else\n    for (ki=0; ki<kn2; ki++)\n      weight2[ki] = 1.;\n\n  /* Compute the vertices of the surface. */\n\n  sp = scoef;\n  for (kj=0; kj<kn2; kj++)\n    {\n      for (ki=0; ki<kn1; ki++)\n        {\n\t  spc1 = scoef1 + ki*kdim;\n\t  spc2 = scoef2 + kj*kdim;\n\t  spnt = ep;\n          weight = weight1[ki]*weight2[kj];\n\n\t  for (kp=0; kp<kdim; kp++)\n            {\n\t      *sp = (*spc1 + *spc2 - *spnt)*weight;\n\t      sp++;\n\t      spc1++;\n\t      spc2++;\n\t      spnt++;\n            }\n          if (pc1->ikind == 2 || pc1->ikind == 4\n                      || pc2->ikind == 2 || pc2->ikind == 4)\n            {\n              *sp = weight;\n              sp++;\n            }\n        }\n    }\n\n  /* Create the surface */\n\n  kcopy = 1;\n  if (pc1->ikind == 2 || pc1->ikind == 4\n                      || pc2->ikind == 2 || pc2->ikind == 4)\n    kind = 2;\n  else\n    kind = 1;\n  *rs =  newSurf(kn1,kn2,kord1,kord2,sknot1,sknot2,scoef,kind,kdim,kcopy);\n\n  *jstat = 0;\n  goto out;\n\n  /* Empty curve. */\n err150: *jstat = -150;\n  s6err(\"s1332\",*jstat,kpos);\n  goto out;\n\n  /* Different dimension for curves   */\n err106: *jstat = -106;\n  s6err(\"s1332\",*jstat,kpos);\n  goto out;\n\n  /* Error in space allocation. */\n err101: *jstat = -101;\n  s6err(\"s1332\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine. */\n error:  *jstat = kstat;\n  s6err(\"s1332\",*jstat,kpos);\n  goto out;\n out:\n\n  /* Free local memory */\n  if (scoef) freearray(scoef);\n  if (weight1) freearray(weight1);\n  if (weight2) freearray(weight2);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1333.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1333.c,v 1.5 2001-03-19 15:58:45 afr Exp $\n *\n */\n\n\n#define S1333\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1333(int inbcrv,SISLCurve *vpcurv[],int nctyp[],double astpar,\n\t   int iopen,int iord2,int iflag,\n\t   SISLSurf **rsurf,double **gpar,int *jstat)\n#else\nvoid s1333(inbcrv,vpcurv,nctyp,astpar,iopen,iord2,\n           iflag,rsurf,gpar,jstat)\n     int    \tinbcrv;\n     SISLCurve  *vpcurv[];\n     int   \tnctyp[];\n     double\tastpar;\n     int    \tiopen;\n     int    \tiord2;\n     int    \tiflag;\n     SISLSurf   **rsurf;\n     double \t**gpar;\n     int    \t*jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To create a spline lofted surface\n*              from a set of input-curves.\n*\n* INPUT      : inbcrv - Number of curves in the curve-set.\n*              vpcurv  - Array (length inbcrv) of pointers to the\n*                       curves in the curve-set.\n*              nctyp  - Array (length inbcrv) containing the types\n*                       of curves in the curve-set.\n*                        1 - Ordinary curve.\n*                        2 - Knuckle curve. Treated as ordinary curve.\n*                        3 - Tangent to next curve.\n*                        4 - Tangent to prior curve.\n*                       (5 - Double derivative to prior curve.)\n*                       (6 - Double derivative to next curve.)\n*                       13 - SISLCurve giving start of tangent to next curve.\n*                       14 - SISLCurve giving end of tengent to prior curve.\n*              astpar - Start-parameter for spline lofting direction.\n*              iopen  - Flag telling if the resulting surface should\n*                       be closed or open.\n*                       -1 - The surface should be closed and periodic.\n*                        0 - The surface should be closed.\n*                        1 - The surface should be open.\n*              iord2  - Maximal order of the B-spline basis in the\n*                       lofting direction.\n*              iflag  - Flag telling if the size of the tangents in the\n*                       derivative curves should be adjusted or not.\n*                        0 - Do not adjust tangent-sizes.\n*                        1 - Adjust tangent-sizes.\n*\n* OUTPUT     : rsurf  - Pointer to the surface produced.\n*              gpar   - The input-curves are constant parameter-lines\n*                       in the parameter-plane of the produced surface.\n*                       (i) - contains the (constant) value of this\n*                             parameter of input-curve no. i.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : A common basis for all the B-spline curves are found.\n*              The curves are represented using this basis.\n*              The resulting curves are given to an interpolation\n*              routine that calculates the B-spline vertices of the\n*              resulting spline lofted surface.\n*              Throughout these routines, first parameterdirection\n*              will be the interpolating direction, second parameter-\n*              direction will be along the input curves.\n*-\n* CALLS      : s1931,s1917,s1918,s1358,s6err.\n*\n* WRITTEN BY : A. M. Ytrehus   SI  Oslo,Norway. Sep. 1988\n* Revised by : Tor Dokken, SI, Oslo, Norway, 26-feb-1989\n* Revised by : Trond Vidar Stensby, SI, 91-08\n* Revised by : Paal Fugelli, SINTEF, Oslo 02/08-1994. Fixed memory leak.\n*********************************************************************\n*/\n{\n  int kind,kcopy,kdim;\n  int kn1,kord1,knbcrv;\n  int kcnsta,kcnend;         /* Interpolation condition at start or end */\n  int ki,kj,kl,km;\n  int kleng;                 /* Number of doubles describing a curve  */\n  int ktype;                 /* Kind of interpolation condition.      */\n  int kopen;                 /* Open/closed parameter in curve direction. */\n  SISLCurve *qc;             /* Pointer to curve representing surface */\n  int *lder = SISL_NULL;\t     /* Derivative indicators from s1915. */\n  double *spar=SISL_NULL; \t     /* Param. values of point conditions. */\n  double *spar2=SISL_NULL; \t     /* Parameter values from s1915. */\n  double *sknot1=SISL_NULL;       /* Knot vector.                 */\n  double *scoef2=SISL_NULL;       /* Pointer to vertices expressed in same basis  */\n  double tstpar;             /* Parameter value of last curve                */\n  int kstat = 0;             /* Status variable. */\n  int kpos = 0;              /* Position of error. */\n  int knbpar;                /* Number of parameter values produced          */\n  int kdimcrv;               /* kdim multiplied with number of vertices kn1  */\n  int kcont;                 /* Continuity at end of curves */\n  double *etyp = SISL_NULL;\n\n/* -> new statement guen & ujk Thu Jul  2 14:59:05 MESZ 1992 */\n\n/* make compatible to old use of s1604 */\n  if (iopen==SISL_CRV_CLOSED) iopen = SISL_CRV_PERIODIC;\n\n/* a new version with input-iopen == rc->cuopen\n   should be made, with a name different from any\n   other.\n  NOTE: There is an error in this function when iopen = 0\n        qc as input to s1713 (and s1750) then has wrong flag !!*/\n\n/* <- new statement guen & ujk Thu Jul  2 14:59:05 MESZ 1992 */\n\n/* -> guen & ujk Wed Jul  1 17:06:46 MESZ 1992 */\n\n  etyp = newarray (inbcrv, DOUBLE);\n  if (etyp == SISL_NULL)\n    goto err101;\n/* <- guen & ujk Wed Jul  1 17:06:46 MESZ 1992 */\n\n  /* Initiate variables. */\n\n  kdim = vpcurv[0]->idim;\n\n  if (inbcrv < 2) goto err179;\n\n  /* Put the curves into common basis. */\n\n  s1931 (inbcrv, vpcurv, &sknot1, &scoef2, &kn1, &kord1, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Create the parameter-values for the knot-vector\n     (in lofting direction) for a lofted surface, allocate array for\n     parameter values.    */\n\n  s1917 (inbcrv, scoef2, kn1, kdim, nctyp, astpar, iopen,\n\t &spar2, &lder, &knbcrv, &kstat);\n\n  if (kstat < 0)\n    goto error;\n\n  /* Convert condition 13 and 14 to 3 and 4 */\n\n  kleng = kn1*kdim;\n  for (ki=0 ; ki<knbcrv ; ki++)\n    {\n       ktype = nctyp[ki];\n\n      if (ktype == 13 && ki+1<knbcrv)\n        {\n\t  /*\n\t   * Start of tangent to next curve,\n\t   * make difference of next curve and this curve\n\t   */\n\n\t  for (kj=ki*kleng,kl=kj+kleng,km=0; km <kleng ; kj++,kl++,km++)\n\t      scoef2[kj] = scoef2[kl] - scoef2[kj];\n\t  nctyp[ki] = 3;\n        }\n      else if (ktype == 14 && ki>0)\n        {\n\t  /* End of tangent to prior curve,\n\t   * make difference of this curve\n\t   * and prior curve\n\t   */\n\n\t  for (kj=ki*kleng,kl=kj-kleng,km=0; km <kleng ; kj++,kl++,km++)\n\t      scoef2[kj] = scoef2[kj] - scoef2[kl];\n\t  nctyp[ki] = 4;\n        }\n    }\n\n  spar = newarray(knbcrv+1,DOUBLE);\n  if (spar==SISL_NULL) goto err101;\n\n  /*  Only copy parameter values of point conditions */\n\n  for (ki=0,kl=0; ki<knbcrv ; ki++)\n    {\n      if (nctyp[ki] == 1 || nctyp[ki] == 2)\n        {\n\t  spar[kl] = spar2[ki];\n\t  kl++;\n        }\n    }\n\n  /* Add one extra parameter value if closed curve */\n\n  if (iopen != SISL_CRV_OPEN) spar[kl] = spar2[knbcrv];\n\n  /* Adjust tangent-lengths if wanted. */\n\n  if (iflag)\n    {\n      s1918 (knbcrv, sknot1, scoef2, kn1, kord1, kdim, spar2, lder, &kstat);\n      if (kstat < 0) goto error;\n    }\n\n  /* Interpolate with point interpolation method */\n\n  kcnsta = 0;\n  kcnend = 0;\n  kdimcrv = kdim*kn1;\n\n/* -> changed guen & ujk Wed Jul  1 19:45:25 MESZ 1992 */\n/*  s1358(scoef2,knbcrv,kdimcrv,nctyp,spar,kcnsta,kcnend,iopen,iord2,astpar,*/\n/*\t&tstpar,&qc,gpar,&knbpar,&kstat); \t\t\t*/\n\n  for (ki=0; ki < inbcrv; ki++) etyp[ki] = (double)nctyp[ki];\n\n  *gpar = SISL_NULL;  /* PFU 02/08-1994 */\n  s1358(scoef2,knbcrv,kdimcrv,etyp,spar,kcnsta,kcnend,iopen,iord2,astpar,\n\t&tstpar,&qc,gpar,&knbpar,&kstat);\n  if (kstat<0) goto error;\n\n  if (*gpar) freearray(*gpar);  /* 'gpar' not used.  PFU 02/08-1994. */\n\n/* -> changed guen & ujk Wed Jul  1 19:45:25 MESZ 1992 */\n\n  /* The knot vector in the lofting direction and the coefficients are\n     now contained in the curve object pointed to by qc */\n\n  /* Create the surface */\n\n  kind = 1;\n  kcopy = 1;\n  *rsurf = newSurf(kn1,qc->in,kord1,qc->ik,sknot1,qc->et,qc->ecoef,\n\t\t   kind,kdim,kcopy);\n  if (*rsurf == SISL_NULL) goto err101;\n\n  /* Copy cuopen flag from curve */\n  (*rsurf)->cuopen_2 = qc->cuopen;\n\n  /* Release the curve object */\n\n  freeCurve(qc);\n\n  /* Output parametervalues according to the input curves  */\n\n  *gpar = spar;\n\n  /* Decide if the surface should have a cyclic behaviour in first\n     parameter direction i.e. the direction of the curves */\n\n  s1333_count(inbcrv,vpcurv,&kcont,&kstat);\n  if (kstat<0) goto error;\n\n  if (kcont>=0)\n      {\n        s1333_cyclic(*rsurf,kcont,&kstat);\n\tif (kstat<0) goto error;\n\n\t/* Set periodic flag */\n\t(*rsurf)->cuopen_1 = SISL_SURF_PERIODIC;\n      }\n      else\n      {\n         /* Test if the surface should be closed and non-periodic.  */\n\n         for (kopen=-2, ki=0; ki<inbcrv; ki++)\n           kopen = MAX(kopen,vpcurv[ki]->cuopen);\n         if (kopen == SISL_CRV_CLOSED) (*rsurf)->cuopen_1 = SISL_SURF_CLOSED;\n      }\n\n  /* Task done */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in allocation. */\n\n err101:\n  *jstat = -101;\n  s6err(\"s1333\",*jstat,kpos);\n  goto out;\n\n\n  /* Error in interpolation conditions. No. of curves < 2. */\n\n err179:\n  *jstat = -179;\n  s6err(\"s1333\",*jstat,kpos);\n  goto out;\n\n\n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n  s6err(\"s1333\",*jstat,kpos);\n  goto out;\n out:\n\n  /* Free allocated scratch  */\n\n  if (sknot1 != SISL_NULL) freearray(sknot1);\n  if (scoef2 != SISL_NULL) freearray(scoef2);\n  if (spar2 != SISL_NULL) freearray(spar2);\n  if (lder != SISL_NULL) freearray(lder);\n\n/* -> added, guen & ujk Wed Jul  1 18:48:27 MESZ 1992 */\n  if (etyp != SISL_NULL)\n    freearray (etyp);\n/* <- added, guen & ujk Wed Jul  1 18:48:27 MESZ 1992 */\n\n  return;\n}\n"
  },
  {
    "path": "src/s1333count.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1333count.c,v 1.2 2001-03-19 15:58:45 afr Exp $\n *\n */\n\n\n#define S1333_COUNT\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1333_count(int inbcrv,SISLCurve *vpcurv[],int *jcont,int *jstat)\n#else\nvoid s1333_count(inbcrv,vpcurv,jcont,jstat)\n     int    \tinbcrv;\n     SISLCurve  *vpcurv[];\n     int        *jcont;\n     int        *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To count the continuity at the start and end of the curves\n*              based on the multiplicity of knots and return the continuity.\n*\n*\n* INPUT      : inbcrv - Number of curves in the curve-set.\n*              vpcurv  - Array (length inbcrv) of pointers to the\n*                       curves in the curve-set.\n*\n* OUTPUT     : jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*              *jcount - The continuity at the start or end based on\n*                        multiplicity of knots\n*-\n* CALLS      : \n*\n* WRITTEN BY : Tor Dokken  SI  Oslo,Norway.  Feb 1992\n*\n*********************************************************************\n*/\n{\n  int kmult1,kmult2,kmult;   /* Multiplicities */\n  int kcont=0;               /* Continuity so far */\n  int kpos=0;\n  int kleft = 0;\n  int kstat;\n  int ki;\n  SISLCurve *curve=SISL_NULL;     /* Pointer to curve being tested */\n\n  *jcont = -1;\n  \n\n  for (ki=0 ; ki<inbcrv ; ki++)\n    {\n       curve = vpcurv[ki];\n       kmult1 = s6knotmult(curve->et,curve->ik,curve->in,&kleft,\n                           curve->et[curve->ik-1],&kstat);\n       if (kstat<0)goto error;\n       \n       kmult2 = s6knotmult(curve->et,curve->ik,curve->in,&kleft,\n                           curve->et[curve->in],&kstat);\n       if (kstat<0)goto error;\n       kmult = MAX(kmult1,kmult2);\n       kmult = MIN(kmult,curve->ik);\n       \n       if (ki==0)\n\t {\n\t   \n\t   kcont = curve->ik - kmult - 1;\n\t }\n       else\n\t {   \n           kcont = MIN(kcont, curve->ik - kmult - 1); \n\t }\n     }\n  \n\n  /* Task done */\n  \n  *jcont = kcont;\n  \n  *jstat = 0;\n  goto out; \n  \n  /* Error in lower level routine.  */\n\n  error : \n    *jstat = kstat;     \n  s6err(\"s1333_count\",*jstat,kpos);\n  goto out;\n out:\n   \n  return;\n}\n"
  },
  {
    "path": "src/s1333cycli.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1333cycli.c,v 1.4 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1333_CYCLIC\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1333_cyclic(SISLSurf *vsurf,int icont,int *jstat)\n#else\nvoid s1333_cyclic(vsurf,icont,jstat)\n     SISLSurf   *vsurf;\n     int        icont;\n     int    \t*jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To describe the B-spline surface (i.e. not NURBS) vsurf with a\n*              cyclic basis of continuity icont in the first parameter direction.\n*\n* INPUT      : vsurf  - Pointer to the surface\n*              icont  - The required continuity\n*\n* OUTPUT     : jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*              vsurf  - The surface with modified description\n*\n* METHOD     : 1. The cyclic knot vector with the right continuity is made\n*              2. The transformation matrix for the ik2 first vertices between\n*                 the cyclic and the old knot vector in second paramter direction\n*                 is made.\n*              3. The transformation matrix is inverted and used to update the\n*                 ik2 first vertices.\n*              4. The transformation matrix for the ik2 last vertices between\n*                 the cyclic and the old knot vector in second paramter direction\n*                 is made.\n*              5. The transformation matrix is inverted and used to update the\n*                 ik2 last vertices.\n*              6. The knot vector is updated.\n*-\n* CALLS      : s1701,s6err.\n*\n* Written  by : Tor Dokken, SI, Oslo, Norway,feb-1992\n*\n*********************************************************************\n*/\n{\n  double *scycl=SISL_NULL;                    /* Cyclic version of knot vector */\n  double *smatrix=SISL_NULL;                   /* Matrix converting between baes */\n  double *salloc=SISL_NULL;                    /* Matrix for memory allocation */\n  double *salfa=SISL_NULL;                     /* The values of a discrete B-spline\n                                             calculation */\n  double *spek=SISL_NULL;                      /* Pointer used in traversing arrays */\n  double *scoef=SISL_NULL;                     /* Copy of the vertices of the surface */\n  double *sb=SISL_NULL;                        /* Right hand side of equation */\n  double *sfrom,*sto;\n  double *sp;                             /* Hlep array for s1701 */\n  double *st1=SISL_NULL;                       /* Internal version of et1 */\n  double *stx=SISL_NULL;                       /* Knot vector after insertion of knots\n                                             at start */\n\n  int    kdim = vsurf->idim;\n  int    rat = (vsurf->ikind == 1 || vsurf->ikind == 3) ? 0 : 1;\n  double *sourcecoef = (rat) ? vsurf->rcoef : vsurf->ecoef;\n  int    kdim2 = kdim + rat;\n  int    kk1 = vsurf->ik1;\n  int    kn1 = vsurf->in1;\n  int    kn2 = vsurf->in2;\n  int    knumb = kdim2*kn1;\n\n  int    kcont;                           /* Checked continuity */\n  int    kmult;                           /* Multiplicity of knot kk2-1 and kn2*/\n  int    ki,kj,kl;\n  int    kperlength;\n  int    kant;\n  int    kleft=0;                         /* Pointer into knot vector */\n  int    kpl,kfi,kla;                     /* Pointers into conversion matrix */\n  int    kstat;\n  int    *mpiv=SISL_NULL;                      /* Pointer to pivotation array */\n  int    kpos = 0;\n  int    knst1;                           /* NUmber of basis functions in st1 */\n  int    knstx;                           /* Number of basis functions in stx */\n\n\n\n\n  /* Test continuity */\n\n  if (icont < 0) goto finished;\n  kcont = icont;\n  if (icont >= kk1-2) icont = kk1-2;\n\n  /* Make multiplicty to be used at value et1[ik1-1] and et1[in1] */\n  kmult = kk1 - kcont - 1;\n\n  /* Make the number of knots to be changed at the start and the end, this\n     is also equal to extra knot to be inserted in internal version of array et */\n\n  kant = kk1-kmult;\n\n\n  /* Alloocate array for pivotation vector */\n\n  mpiv = new0array(2*kk1,INT);\n  if (mpiv == SISL_NULL) goto err101;\n\n  salloc = new0array(3*kn1+9*kk1+4*kk1*kk1+kdim2*kn1*kn2,DOUBLE);\n  if (salloc == SISL_NULL) goto err101;\n  scycl = salloc;                  /* Size kn1+kk1 */\n  smatrix = scycl + kn1 + kk1;  /* Max size 4*kk1*kk1 */\n  salfa = smatrix + 4*kk1*kk1;     /* Size kk1 */\n  scoef = salfa + kk1;           /* Size kdim2*kn1*kn2 */\n  sb    = scoef + kdim2*kn1*kn2;    /* Size 2*kk1 */\n  sp    = sb + 2*kk1;              /* Size kk1 */\n  st1   = sp + kk1;                /* Size kn1 + 2*kk1 */\n  stx   = st1 + kn1 + 2*kk1;       /* Size kn1 + 2*kk1 */\n\n\n\n  /* Copy vertices, to avoid destruction of surface */\n\n  memcopy(scoef,sourcecoef,kdim2*kn1*kn2,DOUBLE);\n\n\n\n  /* Make cyclic knot vector */\n\n\n  /* First copy all knots */\n\n  memcopy(scycl,vsurf->et1,kn1+kk1,DOUBLE);\n\n  /* The change the ik1 first and the ik1 last knots to make a cyclic basis */\n\n  kperlength = kn1 - kk1 + kmult;\n\n  /* Make knots 0 to ik - kmult - 1 */\n\n  for (ki=kk1-kmult-1 ; 0<=ki ; ki--)\n    {\n      scycl[ki] = scycl[kk1-1] - (scycl[kn1] - scycl[ki+kperlength]);\n    }\n\n\n  /* Make knots kn1 + kmult to kn1 + kk1 -1 */\n\n  for (ki=kmult ; ki < kk1 ; ki++)\n    {\n      scycl[kn1+ki] = scycl[kn1] + (scycl[kk1+ki-kmult] - scycl[kk1-1]);\n\n    }\n      /* s1701 expects et1 to be a refinement of scyclic, thus we have to make a new\n\t version of et1 with the extra kk1-kmult new knots before the start and\n\t after the end and one intermediate version with only kk1-kmult at the start */\n\n  memcopy(st1,scycl,kant,DOUBLE);\n  memcopy(st1+kant,vsurf->et1,kn1+kk1,DOUBLE);\n  memcopy(st1+kant+kk1+kn1,scycl+kn1+kk1-kant,kant,DOUBLE);\n  knst1 = kn1 + 2*kant;\n\n  memcopy(stx,scycl,kn1,DOUBLE);\n  memcopy(stx+kn1,st1+kant+kn1,kk1+kant,DOUBLE);\n  knstx = kn1 + kant;\n\n  /* STEP 2 Make matrix going between bases, only the kk2-kmult first and last knots\n     are to be changed.  */\n\n\n  /* Now we have two cases. We know that only the kk1-kmult first and kk1-kmult\n     last vertices are to be changed. However 2*(kk1-kmult) might be a bigger\n     number than kn1. Thus we have to change all vertices if kn1<=2(kk1-kmult) */\n\n\n  /* Make two steps one for the start and one for the end of the surface */\n\n\n  /* Make matrix for the kk1 first vertices */\n\n  for (ki=kant,spek=smatrix ; ki <kk1+kant ; ki++, spek+=kk1)\n    {\n      /* we use kn1 instead of knstx since s1219 expects et[in-1] != et[in], we only\n         address vertices at the start so this does not matter*/\n\n      s1219(stx,kk1,kn1,&kleft,st1[ki],&kstat);\n      if (kstat<0) goto error;\n\n      s1701(ki,kleft,kk1,knstx,&kpl,&kfi,&kla,st1,stx,sp,salfa,&kstat);\n      if(kstat<0) goto error;\n\n      /* Copy the discrete B-splines into the right position */\n\n      memcopy(spek+kfi,salfa+kpl+kfi,kla-kfi+1,DOUBLE);\n    }\n\n\n\n  /* Do the factorisation of the matrix */\n\n  s6lufacp(smatrix,mpiv,kk1,&kstat);\n  if (kstat<0) goto error;\n\n  /* The vertices in the surface are ordered in the sequence\n     (x11,y11,z11),..,(xij,yij,zij), i=1,..,in1 and j=1,..,in2.\n     i is running faster than j. The only vertices\n     affected by this backsubstitution is the kant first rows.\n     We want to treat the back substitution\n     as idim(=3)*in2 backsubstitutions. Thus we have to copy the proper\n     parts of the vertices into a temporary array. Do backsubstitution and\n     copy back into the surface object */\n\n\n  for (ki=0 ; ki<kn2 ; ki++)\n    for (kl=0 ; kl<kdim2 ; kl++)\n      {\n\tfor (kj=0, sfrom=sourcecoef+ki*knumb+kl,sto=sb ;\n\t     kj<kk1 ; kj++,sfrom+=kdim2,sto++)\n\t  *sto = *sfrom;\n\n\t/* sb now contains the vertices to be backsubsituted */\n\n\ts6lusolp(smatrix,sb,mpiv,kk1,&kstat);\n\tif (kstat<0) goto error;\n\n\t/* Copy the backsubsituted vertices back into scoef */\n\n\tfor (kj=0, sto=scoef+ki*knumb+kl,sfrom=sb ;\n\t     kj<kk1 ; kj++,sfrom++,sto+=kdim2)\n\t  *sto = *sfrom;\n      }\n\n\n  /* Make matrix for the kk1 last vertices */\n\n\n  for (ki=0,spek=smatrix ; ki<kk1*kk1 ; ki++,spek++) *spek = DZERO;\n\n\n  for (ki=kn1-kk1 ,spek=smatrix ; ki <kn1 ; ki++, spek+=kk1)\n    {\n      s1219(scycl,kk1,kn1,&kleft,stx[ki],&kstat);\n      if (kstat<0) goto error;\n\n      s1701(ki,kleft,kk1,kn1,&kpl,&kfi,&kla,stx,scycl,sp,salfa,&kstat);\n      if(kstat<0) goto error;\n\n      /* Copy the discrete B-splines into the right position */\n\n      memcopy(spek+kfi-(kn1-kk1),salfa+kpl+kfi,kla-kfi+1,DOUBLE);\n    }\n\n\n\n  /* Do the factorisation of the matrix */\n\n  s6lufacp(smatrix,mpiv,kk1,&kstat);\n  if (kstat<0) goto error;\n\n  /* The vertices in the surface are ordered in the sequence\n     (x11,y11,z11),..,(xij,yij,zij), i=1,..,in1 and j=1,..,in2.\n     i is running faster than j The only vertices\n     affected by this backsubstitution is the kant last rows.\n     We want to treat the back substitution\n     as idim(=3)*in2 backsubstitutions. Thus we have to copy the proper\n     parts of the vertices into a temporary array. Do backsubstitution and\n     copy back into the surface object */\n\n  for (ki=0 ; ki<kn2 ; ki++)\n    for (kl=0 ; kl<kdim2 ; kl++)\n      {\n\tfor (kj=0, sfrom=scoef+ki*knumb+kdim2*(kn1-kk1)+kl,sto=sb ;\n\t     kj<kk1 ; kj++,sfrom+=kdim2,sto++)\n\t  *sto = *sfrom;\n\n\t/* sb now contains the vertices to be backsubsituted */\n\n\ts6lusolp(smatrix,sb,mpiv,kk1,&kstat);\n\tif (kstat<0) goto error;\n\n\t/* Copy the backsubsituted vertices back into scoef */\n\n\tfor (kj=0, sto=scoef+ki*knumb+kdim2*(kn1-kk1)+kl,sfrom=sb ;\n\t kj<kk1 ; kj++,sto+=kdim2,sfrom++)\n\t  *sto = *sfrom;\n      }\n\n\n  /* Copy knots and vertices into the surface object */\n\n  memcopy(sourcecoef,scoef,kdim2*kn1*kn2,DOUBLE);\n  memcopy(vsurf->et1,scycl,kn1+kk1,DOUBLE);\n\n  /* Set periodicity flag */\n  vsurf->cuopen_1 = SISL_SURF_PERIODIC;\n\n    /* Update divided coefficients */\n    if (rat)\n      {\n\tfor (ki=0; ki<kn1*kn2; ++ki)\n\t  {\n\t    for (kj=0; kj<kdim; ++kj)\n\t      vsurf->ecoef[ki*kdim+kj] = \n\t\tvsurf->rcoef[ki*kdim2+kj]/vsurf->rcoef[ki*kdim2+kdim];\n\t  }\n      }\n\n  /* Task done */\n\n finished:\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in allocation. */\n\n err101:\n  *jstat = -101;\n  s6err(\"s1333_cyclic\",*jstat,kpos);\n  goto out;\n\n\n\n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n  s6err(\"s1333_cyclic\",*jstat,kpos);\n  goto out;\n out:\n\n  /* Free allocated scratch  */\n  if (salloc != SISL_NULL) freearray(salloc);\n  if (mpiv != SISL_NULL) freearray(mpiv);\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s1334.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1334.c,v 1.2 2001-03-19 15:58:46 afr Exp $\n *\n */\n\n\n#define S1334\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1334(double epoint[],int inbpnt,int idim,double nptyp[],\n      int icnsta,int icnend,int iopen,int ik,double astpar,\n      double *cendpar,SISLCurve **rc,double **gpar,int *jnbpar,int *jstat)\n#else\nvoid s1334(epoint,inbpnt,idim,nptyp,icnsta,icnend,iopen,ik,astpar,\n           cendpar,rc,gpar,jnbpar,jstat)\n     double epoint[];\n     int    inbpnt;\n     int    idim;\n     double    nptyp[];\n     int    icnsta;\n     int    icnend;\n     int    iopen;\n     int    ik;\n     double astpar;\n     double *cendpar;\n     SISLCurve  **rc;\n     double **gpar;\n     int    *jnbpar;\n     int    *jstat;\n#endif\n/*\n*************************************************************************\n*\n* Purpose: To calculate a B-spline curve interpolating a set of points.\n*          The points can be assigned a tangent (derivative).\n*          The curve can be closed or open. If end-conditions are\n*          conflicting, the condition closed curve rules out other\n*          end conditions.\n*\n* Input:\n*        Epoint - Array (length idim*inbpnt) containing the points/\n*                 derivatives to be interpolated.\n*        Inbpnt - No. of points/derivatives in the epoint array.\n*        Idim   - The dimension of the space in which the points lie.\n*        nptyp  - Array (length inbpnt) containing type indicator for\n*                 points/derivatives/second-derivatives:\n*                  1 - Ordinary point.\n*                  2 - Knuckle point. (Is treated as an ordinary point.)\n*                  3 - Derivative to next point.\n*                  4 - Derivative to prior point.\n*                ( 5 - Second derivative to next point. )\n*                ( 6 - Second derivative to prior point. )\n*                 13 - Start-point of tangent to next point.\n*                 14 - End-point of tangent to prior  point.\n*        Icnsta - Additional condition at the start of the curve:\n*                  0 : No additional condition.\n*                  1 : Zero curvature at start.\n*        Icnend - Additional condition at the end of the curve:\n*                  0 : No additional condition.\n*                  1 : Zero curvature at end.\n*        Iopen  - Flag telling if the curve should be open or closed:\n*                  0 : Closed curve.\n*                  1 : Open curve.\n*        Ik     - The order of the B-spline curve to be produced.\n*        Astpar - Parameter-value to be used at the start of the curve.\n*\n* Output:\n*        cendpar - Parameter-value used at the end of the curve.\n*        Rc     - Pointer to output-curve.\n*        Gpar   - Pointer to the parameter-values of the points in\n*                 the curve. Represented only once, although derivatives\n*                 and second-derivatives will have the same parameter-\n*                 value as the points.\n*        Jnbpar - No. of different parameter-values.\n*        Jstat  - status variable:\n*                  < 0 : Error.\n*                  = 0 : Ok.\n*                  > 0 : Warning.\n*\n* Method: First the parametrization of the curve and the type\n*         specification of points/derivatives are checked and/or\n*         corrected. Then the knots are calculated, and the\n*         interpolation is performed.\n*\n* Calls: s1906,s1901,s6err.\n*\n* Written by: A.M. Ytrehus  Si  Oslo, Norway  Sep. 1988.\n* The main routine, p19501, is written by: T. Dokken  SI.\n* Rewised by: Trond Vidar Stensby, SI, 1991-07\n*****************************************************************\n*/\n{\n  int kpos = 0;\n  int kstat = 0;\n  int *ltype = SISL_NULL;\t\t/* The kind of interpolation conditions. */\n  int knpt;\t\t\t/* Number of acepted interpolation conditions. */\n  double *lcond = SISL_NULL;\t\t/* The number of acepted interpolation conditions. */\n\n  int *ityp = SISL_NULL;\n  int ki;\n\n  /* make compatible to old use of s1604 */\n\n  if (iopen==SISL_CRV_CLOSED) iopen = SISL_CRV_PERIODIC;\n\n  /* a new version with input-iopen == rc->cuopen\n     should be made, with a name different from any\n     other.\n     NOTE: There is an error in this function when iopen = 0\n           qc as input to s1713 (and s1750) then has wrong flag !!*/\n\n  ityp = newarray (inbpnt, INT);\n  if (ityp == SISL_NULL)\n    goto err101;\n\n  for (ki=0; ki < inbpnt; ki++) ityp[ki] = (int)nptyp[ki];\n\n  /* <- guen & ujk Wed Jul  1 17:06:46 MESZ 1992 */\n\n  *jstat = 0;\n\n  /* Transform interpolation conditions. */\n\n/* -> guen & ujk Wed Jul  1 17:06:46 MESZ 1992 */\n/*  s1906 (epoint, nptyp, icnsta, icnend, inbpnt, idim, &lcond, */\n/*\t &ltype, &knpt, &kstat);\t\t\t\t*/\n  s1906 (epoint, ityp, icnsta, icnend, inbpnt, idim, &lcond,\n\t &ltype, &knpt, &kstat);\n/* <- guen & ujk Wed Jul  1 17:06:46 MESZ 1992 */\n\n  if (kstat < 0)\n    goto error;\n\n  /* Interpolate. */\n\n  s1901(s1909, s1902, lcond, ltype, knpt, astpar, ik, idim, iopen,\n\tcendpar, rc, gpar, jnbpar, &kstat);  \n  if (kstat < 0) goto error;\n\n  *jstat = 0;\n  goto out;\n  \n  /* Error in lower level routine. */\n error: *jstat = kstat;\n  s6err(\"s1334\",*jstat,kpos);\n  goto out;\n\n  /* allocation error */\n err101: *jstat = -101;\n  s6err(\"s1334\",*jstat,kpos);\n  goto out;\n  \n out:\n  if (ltype != SISL_NULL)\n    freearray (ltype);\n\n/* -> added, guen & ujk Wed Jul  1 18:48:27 MESZ 1992 */\n  if (ityp != SISL_NULL)\n    freearray (ityp);\n/* <- added, guen & ujk Wed Jul  1 18:48:27 MESZ 1992 */\n\n  if (lcond != SISL_NULL)\n    freearray (lcond);\n    \n  return;\n}\n"
  },
  {
    "path": "src/s1339.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S1339\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1339(SISLSurf *ps, int ipow, double ea[], int inumprd, int incoef,\n\t double aepsge, double ecimp[], double *cgrad, int *jstat)\n#else\nvoid s1339(ps, ipow, ea, inumprd, incoef, aepsge, ecimp, cgrad, jstat)\n   SISLSurf *ps;\n   int    ipow;\n   double ea[];\n   int    inumprd;\n   int    incoef;\n   double aepsge;\n   double ecimp[];\n   double *cgrad;\n   int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Solve an underdetermined equation system to find implicit\n*              coefficents approximating a Bezier surface.\n*\n*\n* INPUT      : ps       - Surface to approximate.\n*              ipow     - Implicit degree.\n*              ea       - Matrix of equation system of implicit coefficients\n*              inumprd  - Number of products in the matrix ea, i.e. number\n*                         of columns in the matrix.\n*              incoef   - Number of coefficients in the matrix ea, i.e. number\n*                         of rows in the matrix.\n*              aepsge   - Geometry tolerance.\n*\n*\n* OUTPUT     : ecimp    - Implicit coefficients.\n*              cgrad    - Estimated medium gradient of the implicit surface.\n*              jstat    - status messages\n*                                = 1   : Implicit approximation not computed.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      :\n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF Oslo, 94-09.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;    /* Local status variable.                           */\n   int knvec;        /* Number of vectors spanning the null space.       */\n   int kntest = 10;  /* Number of sample points in each par. dir.        */\n   int kr1, kr2, kl; /* Counters of sample points and solution vectors.  */\n   int kl2, kl3;\n   int ki, kj, kk;   /* Counters of multiplisity of factors.             */\n   int kindex;       /* Index in snullvec.                               */\n   int kleft1=0, kleft2=0;  /* Parameters used in surface evaluator.     */\n   double tx, ty, tz;       /* Help variables used to compute gradient.  */\n   double tx1, ty1, tz1;\n   double tg1, tg2, tg3;    /* Help variables used to compute gradient.  */\n   double tweight;          /* Weight belonging to a particular solution\n\t\t\t       to the approximation problem.             */\n   double spar[2];          /* Parameter value of sampling point.        */\n   double tint1, tint2;     /* Parametric intervals between sampling points. */\n   double totaldot;         /* Sum of scalar products between gradients of\n\t\t\t       implicit surface and surface normal of\n\t\t\t       parametric surface.                         */\n   double tepsge = MAX(aepsge/(double)1000, REL_COMP_RES);\n                            /* Tolerance used to sort out negliable vectors\n\t\t\t       of the nullspace.                           */\n   double *snullvec = NULL; /* Vectors spanning the null space.            */\n   double sder[9];          /* Position and derivatives of spline surface. */\n   double snorm[3];         /* Normal of spline surface.                   */\n   double *sgrad = NULL;    /* Array storing gradients.                    */\n   double *accdot = NULL;   /* Accumulated information about the scalar\n\t\t\t      product between the gradient of the implicit\n\t\t\t      surface and the normal of the parametric\n\t\t\t      surface in a number of points.              */\n   double *accgrad = NULL; /* Accumulated information about the gradient\n\t\t\t      of the implicit surface.                    */\n\n   /* Test input. */\n\n   /*if (ps->in1 > ps->ik1 || ps->in2 > ps->ik2) \n     goto err122;*/\n\n   /* Find a number of vectors spanning the null space of the equation\n      system for finding the implicit coefficients.                                                    */\n\n   s6nullspace(ea, incoef, inumprd, tepsge, &snullvec, &knvec, &kstat);\n   if (kstat < 0) goto error;\n\n   /* Allocate scratch for gradients. */\n\n   if ((sgrad = new0array(5*knvec, DOUBLE)) == NULL) \n     goto err101;\n   accgrad = sgrad + 3*knvec;\n   accdot = accgrad + knvec;\n\n   /* Accumulate the dot product between the normal of the surface and\n      the gradient of the candidate implicit surfaces at a number of\n      sample points. Also compute an estimate for the length of the\n      medium gradient of the candidate implicit surfaces.              */\n\n   /* Find parametric interval between sampling points. */\n\n   tint1 = (ps->et1[ps->in1] - ps->et1[ps->ik1-1])/(kntest-1);\n   tint2 = (ps->et2[ps->in2] - ps->et2[ps->ik2-1])/(kntest-1);\n\n   for (kr1=0, spar[0]=ps->et1[ps->ik1-1]; kr1<kntest; kr1++, spar[0]+=tint1)\n      for (kr2=0, spar[1]=ps->et2[ps->ik2-1]; kr2<kntest; kr2++, spar[1]+=tint2)\n      {\n\t /* Evaluate the surface to be approximated. */\n\n\t s1421(ps, 1, spar, &kleft1, &kleft2, sder, snorm, &kstat);\n\t if (kstat < 0) goto error;\n\n\t /* Initialize vector for gradient storage to zero. */\n\n\t memzero(sgrad, 3*knvec, DOUBLE);\n\n\t /* Compute the gradient in the current sample point. */\n\n\t for (kindex=0,tx1=tx=(double)1, ki=0; ki<=ipow; \n\t      ki++, tx1=tx, tx*=sder[0])\n\t    for (ty1=ty=(double)1, kj=0; kj<=ipow-ki; \n\t\t kj++, ty1=ty, ty*=sder[1])\n\t       for (tz1=tz=(double)1, kk=0; kk<=ipow-ki-kj; \n\t\t    kk++, tz1=tz, tz*=sder[2])\n\t       {\n\t\t /* FIX start ------------->                               */\n\t\t /* Fixed by HKE and UJK, Linear term not properly handled */\n\t\t if (ki > 1 && fabs(sder[0]) > REL_COMP_RES)\n\t\t   tg1 = (double)ki*tx1*ty*tz;\n\t\t else if (ki == 1)\n\t\t   tg1 = ty*tz;\n\t\t else\n\t\t   tg1 = 0.0;\n\n\t\t if (kj > 1 && fabs(sder[1]) > REL_COMP_RES)\n\t\t   tg2 = (double)kj*tx*ty1*tz;\n\t\t else if (kj == 1)\n\t\t   tg2 = tx*tz;\n\t\t else\n\t\t   tg2 = 0.0;\n\n\t\t if (kk > 1 && fabs(sder[2]) > REL_COMP_RES)\n\t\t   tg3 = (double)kk*tx*ty*tz1;\n\t\t else if (kk == 1)\n\t\t   tg3 = tx*ty;\n\t\t else\n\t\t   tg3 = 0.0;\n\n\t\t /* FIX end <-------------                                 */\n\n\n\t\t  /* Add contribution to the gradient. */\n\t\t  for (kl3=kl2=kl=0; kl<knvec; kl++, kl2+=inumprd, kl3+=3)\n\t\t  {\n\t\t     sgrad[kl3] += snullvec[kl2+kindex]*tg1;\n\t\t     sgrad[kl3+1] += snullvec[kl2+kindex]*tg2;\n\t\t     sgrad[kl3+2] += snullvec[kl2+kindex]*tg3;\n\t\t  }\n\t\t  kindex++;\n\t       }\n\n\t /* Add information of the current sample point to\n\t    the accumulated scalar product between gradients and\n\t    normals, and to the accumulated lenghts of gradients. */\n\n\t for (kl3=kl=0; kl<knvec; kl++, kl3+=3)\n\t {\n\t    accdot[kl] += s6scpr(sgrad+kl3, snorm, 3);\n\t    accgrad[kl] += s6length(sgrad+kl3, 3, &kstat);\n\t }\n      }\n\n   /* Compute sum of scalar products between gradients and normals,\n      and compute medium of estimated gradient.     */\n\n   for (totaldot=0.0, kl=0; kl<knvec; kl++)\n   {\n      totaldot += accdot[kl]*accdot[kl];\n      accgrad[kl] /= kntest*kntest;\n   }\n   totaldot = sqrt(totaldot);\n\n   /* Initiate output storage to zero. */\n\n   memzero(ecimp, inumprd, DOUBLE);\n   *cgrad = 0.0;\n\n   /* Compute factors of each candidate solution to the set of implicit\n      coefficients, and make the final sulution vector.                 */\n\n   if (totaldot < REL_COMP_RES) goto warn1;  /* Implicitation not possible. */\n\n   for (kl2=kl=0; kl<knvec; kl++, kl2+=inumprd)\n   {\n      tweight = fabs(accdot[kl])/totaldot;\n      for (kindex=0; kindex<inumprd; kindex++)\n\t ecimp[kindex] += tweight*snullvec[kl2+kindex];\n      (*cgrad) += tweight*accgrad[kl];\n   }\n\n   /* Implicit approximation computed. */\n\n   *jstat = 0;\n   goto out;\n\n   /* Implicit approximation not computed. */\n\n   warn1 : *jstat = 1;\n   goto out;\n\n   err101 : *jstat = -101;   /* Error in scratch allocation.   */\n   s6err(\"s1339\",*jstat,0);\n   goto out;\n\n   error : *jstat = kstat;   /* Error in lower level routine. */\n   s6err(\"s1339\",*jstat,0);\n   goto out;\n\n   out:\n      /* Free space occupied by local arrays. */\n\n      if (snullvec != NULL) freearray(snullvec);\n      if (sgrad != NULL) freearray(sgrad);\n\n      return;\n}\n"
  },
  {
    "path": "src/s1340.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1340.c,v 1.5 2001-03-19 15:58:46 afr Exp $\n *\n */\n\n#define S1340\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1340(SISLCurve *oldcurve, double eps[], int startfix, int endfix,\n      double epsco, int itmax, SISLCurve **newcurve, double maxerr[],\n      int *stat)\n#else\nvoid\ns1340(oldcurve, eps, startfix, endfix, epsco, itmax, newcurve,\n      maxerr, stat)\n    SISLCurve \t*oldcurve;\n    double\teps[];\n    int\t\tstartfix;\n    int\t\tendfix;\n    double\tepsco;\n    int\t\titmax;\n    SISLCurve\t**newcurve;\n    double\tmaxerr[];\n    int\t\t*stat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* Purpose: To remove as many knots as possible from the spline curve\n*\t   \"oldcurve\" without perturbing the curve more than a given\n*\t   tolerance. The tolerance is given by \"eps\" and the\n* \t   approximation by \"newcurve\".\n*\n*\n* Input:\n*          oldcurve    - pointer to the original spline curve. Note that\n*                        if the polynomial order of the curve is k, then\n*                        the knot vector of oldcurve is assumed to have\n*                        knots of multiplicity k at the beginning and end.\n*\n*\t   eps\t       - double array giving the desired absolute accuracy\n*                        of the final approximation as compared to oldcurve.\n*                        If oldcurve is a spline curve in a space of\n*\t\t\t dimension dim, then eps must have length dim.\n*                        Note that it is not relative, but absolute accuracy\n*                        that is being used. This means that the difference\n*                        in component i at any parameter value, between\n*                        the given curve and the approximation, is to be\n*                        less than eps[i]. Note that in such comparisons\n*                        the same parametrization is used for both curves.\n*\n*\t   startfix    - the number of derivatives to be kept fixed at\n*\t\t\t the beginning of the knot interval.\n*                        The (0 - (startfix-1)) derivatives will be kept fixed.\n*                        If startfix <0, this routine will set it to 0.\n*                        If startfix< the order of the curve, this routine\n*                        will set it to the order.\n*\n*\t   endfix      - the number of derivatives to be kept fixed at\n*\t\t         the end of the knot interval.\n*                        The (0 - (endfix-1)) derivatives will be kept fixed.\n*                        If endfix <0, this routine will set it to 0.\n*                        If endfix< the order of the curve, this routine\n*                        will set it to the order.\n*\n*\t   epsco       - real number used to check equality between real\n*                        numbers in some routines. Two numbers differing\n*                        by a relative amount less than epsco will in some\n*                        cases be considered equal. A suitable value is just\n*\t\t\t above the unit roundoff of the machine. In IEEE\n*                        double precision arithmetic 1.0E-15 is a reasonable\n*                        choice.\n*                        NB! The computations are not guaranteed to have\n*                            relative accuracy less than epsco.\n*\n*\t   itmax       - maximum number of iterations. The routine will\n*                        follow an iterative procedure trying to remove\n*                        more and more knots. The process will almost always\n*                        stop after less than 10 iterations and it will often\n*                        stop after less than 5 iterations. A suitable\n*                        value for itmax is therefore usually in the region\n*                        3-10.\n*\n*\n*\n*\n* Output:\n*          newcurve    - the spline approximation on the reduced\n*                        knot vector.\n*\t   maxerr      - double array containing an upper bound for the\n*\t\t\t pointwise error in each of the components of the\n*\t\t         spline approximation. The two curves oldcurve and\n*\t\t\t newcurve are compared at the same parameter value,\n*                        i.e., if oldcurve is f and newcurve is g, then\n*\t\t\t               |f(t)-g(t)| <= eps\n*\t\t\t in each of the components.\n*\n*           stat       - status message\n*                           > 0      : warning\n*                           = 0      : ok\n*                           < 0      : error\n*\n*\n*\n*\n* Method:\n*     The method is described in two papers listed as references below.\n*     First, the knots of the input spline, s, are ranked according to their\n*     relative importance in the representation of s (s1353). Using this\n*     information, knots are removed from s and an approximation g is computed\n*     on the reduced knot vector (s1354) with the error guaranteed to be\n*     less than the tolerance in all components. In order to remove more knots,\n*     the knots of g are ranked, and then knots are removed from g, resulting\n*     in a spline h with even fewer knots. The knot vector of h is then\n*     clearly a subsequence of the knot vector of s and s is approximated\n*     on this knot vector (sh1365). If the error is less than the tolerance\n*     then h is accepted as the new best approximation and stored in g.\n*     If the error is greater than the tolerance, knots are removed directly\n*     from s based on the ranking of g resulting in a new g. In either case a\n*     new best approximation g is obtained, and we can continue the iteration.\n*     The iterations stop when no more knots can be removed or all the interior\n*     knots have been removed. (The names s, g, and h are not used in the\n*     code.)\n*\n* NB! It is assumed that the input spline has knots of multiplicity k (the\n*     polynomial order) at each end. This property of the knot vector is\n*     used extensively by the lower level routines.\n*\n*\n* References:\n*     1. A Data-Reduction Strategy for Splines with Applications to the\n*        Approximation of Functions and data, IMA J. of Num. Anal. 8 (1988),\n*        pp. 185-208.\n*\n*     2. Knot Removal for Parametric B-spline Curves and Surfaces,\n*        CAGD 4 (1987), pp. 217-230.\n*\n*\n* Calls: s1353, s1354, sh1365, s6err\n*\n* Written by: Knut Moerken, University of Oslo, November 1992, based\n*             on an earlier Fortran version by the same author.\n* CHANGED BY: Paal Fugelli, SINTEF, 1994-07.  Initialized pointers (to SISL_NULL)\n*      in 'ranking' to avoid potential memory leak when exiting through 'out'.\n*      Removed several other memory leaks.\n* CHANGED BY: Per OEyvind Hvidsten, SINTEF, 1994-11. Added a freeCurve\n*      call before overwriting the *newarray pointer (thus removing a\n*      memory leak.\n*\n*********************************************************************\n*/\n{\n  char ready, big;              /* Boolean variables used for computing\n                                   the stopping criteria.                */\n  int k = oldcurve->ik;         /* Unwrapped version of the given curve. */\n  int dim = oldcurve->idim;\n  double *d = oldcurve->ecoef;\n  int itcount=0;                /* Iteration counter.                    */\n  int n1 = oldcurve->in;        /* n1 and n2 are used for storing the number\n                                   coefficients in consecutive spline\n                                   approximations. The situation n1=n2\n\t\t\t\t   signifies that no more knots can be\n\t\t\t\t   removed.                              */\n  int n2;\n  int i, mini, maxi, indx;      /* Various auxiliary integer variables.  */\n  double *local_err = SISL_NULL;     /* Variables used for storing local error\n                                   estimates.                            */\n  double *l2err = SISL_NULL;\n  double *lepsco = SISL_NULL;\n  double *temp_err = SISL_NULL;\n  SISLCurve *tempcurve = SISL_NULL;  /* Variables that are used for storing\n                                   temporary curves.                     */\n  SISLCurve  *helpcurve = SISL_NULL;\n  rank_info ranking;            /* Variable used for holding ranking\n                                   information (from s1353).             */\n  int lstat=0;                  /* Local status variable.                */\n  int pos=0;\t\t\t/* Parameter to s6err.                  */\n  SISLCurve *qc_kreg = SISL_NULL;    /* Non-periodic version of the input curve. */\n\n\n  /* Initialize ranking ptrs in case of early exit through 'out' (PFU 05/07-94) */\n  ranking.prio = SISL_NULL;\n  ranking.groups = SISL_NULL;\n\n  /* Initialize maxerr to zero. */\n\n  for (i=0; i<dim; i++) maxerr[i] = 0.;\n\n  /* Only interior knots may be removed so if n1==k we can stop\n     straight away.                                             */\n\n  if (n1 == k)\n  {\n    *newcurve = newCurve(n1, k, oldcurve->et, oldcurve->ecoef,\n\t\t\t oldcurve->ikind, oldcurve->idim, 1);\n    if (*newcurve == SISL_NULL)  goto err101;\n\n    *stat = 0;\n    goto out;\n  }\n\n  /* Make sure that the input curve is non-periodic.  */\n\n  if (oldcurve->cuopen == SISL_CRV_PERIODIC)\n  {\n    make_cv_kreg(oldcurve, &qc_kreg, &lstat);\n    if (lstat < 0) goto error;\n\n    /* The input curve is closed and periodic. Make sure that the\n       endpoints of the curve is still matching by fixing the\n       position and the derivative in the endpoints of the curve.\n       The change made to startfix and endfix is only locallly. */\n\n    startfix = MAX(startfix, 2);\n    endfix = MAX(endfix, 2);\n  }\n  else\n    qc_kreg = oldcurve;\n\n  /* Allocate space for some local arrays. */\n\n  temp_err = newarray(dim, double);\n  if (temp_err == SISL_NULL) goto err101;\n\n  lepsco = newarray(dim, double);\n  if (lepsco == SISL_NULL) goto err101;\n\n  /* ranking is of type rank_info which is a struct described in s1353. */\n\n  ranking.prio = newarray(MAX(n1-k,1), int);\n  if (ranking.prio == SISL_NULL) goto err101;\n\n  ranking.groups = newarray(MAX(n1-k,1), int);\n  if (ranking.groups == SISL_NULL) goto err101;\n\n  /* lespco is needed in s1354. In component i we first store the l1-norm\n     of the component i of the B-spline coefficients of oldcurve. */\n\n  for (i=0; i<dim; i++) lepsco[i] = fabs(d[i]);\n\n  indx = 0;\n  for (i=1; i<n1*dim; i++)\n  {\n    lepsco[indx++] += fabs(d[i]);\n    if (indx == dim) indx = 0;\n  }\n\n  /* We can now compute the final value of lepsco which will be used for\n     checking if two numbers are almost equal. */\n\n  for (i=0; i<dim; i++)\n    lepsco[i] = MIN(lepsco[i]*epsco/n1, eps[i]);\n\n  /* This is where the knot removal process starts. */\n\n  /* mini and maxi are lower and upper bounds on how many knots that can\n     be removed. */\n\n  mini = 0;\n  maxi = n1 - k + 1;\n\n  /* Start by ranking the knots of oldcurve. */\n\n  s1353(qc_kreg, eps, &ranking, &lstat);\n  if (lstat < 0) goto error;\n\n  /* Based on the computed ranking, we remove as close to maxi knots\n     from oldcurve as possible, but such that we can always compute an\n     approximation to oldcurve on the reduced knot vector, with error less\n     than eps.  newcurve will be created with icopy==1.  */\n\n  s1354(qc_kreg, qc_kreg, &ranking, eps, lepsco, startfix, endfix,\n\tmini, maxi, newcurve, maxerr, &lstat);\n  if (lstat < 0) goto error;\n\n  /* The spline stored in newcurve is now an approximation to oldcurve\n     with error less than eps. We will now iterate and try to remove knots\n     from newcurve. The integers n1 and n2 will be the number of knots in\n     the two most recent approximations. */\n\n  n2 = (*newcurve)->in;\n\n  /* Start the iterations. We have already done one iteration and we have\n     not had any problems with the error getting too big. */\n\n  itcount = 1;\n  big = 0;\n\n  /* If n1=n2 we are unable to remove any knots, and if n2=k there are\n     no interior knots left so we can stop. Likewise if itmax was 1. */\n\n  ready = (n1 == n2) || (n2 == k) || (itcount == itmax);\n  while (!ready)\n  {\n\n    /* We start by ranking the knots of newcurve which is the approximation\n       with the fewest knots that we have found so far. */\n\n    s1353(*newcurve, eps, &ranking, &lstat);\n    if (lstat < 0) goto error;\n\n    if (!big)\n    {\n\n      /* If we have not had any problems with the error in approximation\n         becoming too big we take the risk of removing as many knots as\n         we can from newcurve and in this way determining an even shorter\n\t knot vector.\n\t First we iterate in s1354 to see how many knots we can remove\n\t and store the approximation to newcurve in helpcurve (will be\n\t created with icopy==1). */\n\n      mini = 0; maxi = (*newcurve)->in - k + 1;\n      s1354(*newcurve, *newcurve, &ranking, eps, lepsco, startfix,\n\t    endfix, mini, maxi, &helpcurve, temp_err, &lstat);\n      if (lstat < 0) goto error;\n\n      /* Now, we have no guarantee that helpcurve is closer to oldcurve\n         than the tolerance so we compute a new approximation to oldcurve\n         on the knot vector of helpcurve and store this in tempcurve (with\n\t icopy==1).\n\t Must make sure that local_err is free'ed if allocated from last\n\t iteration. */\n\n      if (local_err != SISL_NULL) freearray(local_err);\n\n      sh1365(qc_kreg, helpcurve->et, k, helpcurve->in,\n\t     startfix, endfix, &tempcurve,\n\t     &local_err, &l2err, &lstat);\n      if (lstat < 0) goto error;\n\n      /* Don't need l2err or helpcurve anymore. */\n\n      freearray(l2err);\n      freeCurve(helpcurve);\n      helpcurve = SISL_NULL;\n\n      /* We must now check if the new tempcurve is within the tolerance. */\n      i = 0;\n      while (!big && i<dim)\n      {\n\tbig = local_err[i] > eps[i];\n\ti++;\n      }\n    }\n    else\n\n      /* If we have had problems with the error becoming greater than the\n\t tolerance, we simply store newcurve in tempcurve and proceed. */\n\n      tempcurve = *newcurve;\n\n    if (big)\n    {\n\n      /* If at some stage we have had problems with the error becoming\n\t larger than the tolerance, we do not get involved in the risky\n\t approach of removing knots from newcurve. Instead we throw away\n         tempcurve and remove knots directly from oldcurve, but remember\n\t that the only knots left to remove are the knots of newcurve for\n\t which we use the ranking computed above. The result is stored\n\t in helpcurve and later transferred to newcurve. */\n\n      mini= 0; maxi = tempcurve->in - k + 1;\n      s1354(qc_kreg, *newcurve, &ranking, eps, lepsco,\n\t    startfix, endfix, mini, maxi, &helpcurve, maxerr, &lstat);\n      if (lstat < 0) goto error;\n\n      if (*newcurve != SISL_NULL && *newcurve != tempcurve)\n      {\n\tfreeCurve(*newcurve);\n\t*newcurve = SISL_NULL;\n      }\n\n      if (tempcurve != SISL_NULL)\n      {\n\tfreeCurve(tempcurve);\n\ttempcurve = SISL_NULL;\n      }\n      *newcurve = helpcurve;\n      helpcurve = SISL_NULL;\n    }\n    else\n    {\n\n      /* Since we now know that the difference between oldcurve and tempcurve\n\t is within the tolerance, we just have to store the error in maxerr,\n\t throw away the old newcurve, and store tempcurve in newcurve. */\n\n      for (i=0; i<dim; i++) maxerr[i] = local_err[i];\n\n      if (*newcurve != SISL_NULL) freeCurve(*newcurve);\n      *newcurve = tempcurve;\n      tempcurve = SISL_NULL;\n    }\n\n    /* Now we must check if it is time to stop. */\n\n    n1 = n2;\n    n2 = (*newcurve)->in;\n    ++itcount;\n    ready = (n1 == n2) || (n2 == k) || (itcount == itmax);\n  }\n\n  /* Set periodicity flag.  */\n\n  if (oldcurve->cuopen == SISL_CRV_CLOSED ||\n      oldcurve->cuopen == SISL_CRV_PERIODIC)\n    (*newcurve)->cuopen = SISL_CRV_CLOSED;\n\n  /* Success */\n\n  *stat = 0;\n  goto out;\n\n  /* Error in allocation of memory. */\n\nerr101:\n  *stat = -101;\n  s6err(\"s1340\", *stat, pos);\n  goto out;\n\n  /* Error in lower level routine. */\n\nerror:\n  *stat = lstat;\n  s6err(\"s1340\", *stat, pos);\n  goto out;\n\n  /* Clear up and free memory before exit. */\n\nout:\n  if (temp_err != SISL_NULL) freearray(temp_err);\n  if (local_err != SISL_NULL) freearray(local_err);\n  if (l2err != SISL_NULL) freearray(l2err);\n  if (lepsco != SISL_NULL) freearray(lepsco);\n  if (ranking.prio != SISL_NULL) freearray(ranking.prio);\n  if (ranking.groups != SISL_NULL) freearray(ranking.groups);\n  if (qc_kreg != SISL_NULL && qc_kreg != oldcurve) freeCurve(qc_kreg);\n  if (helpcurve != SISL_NULL && helpcurve != (*newcurve)) freeCurve(helpcurve);\n  if (tempcurve != SISL_NULL && tempcurve != (*newcurve)) freeCurve(tempcurve);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1341.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1341.c,v 1.2 2001-03-19 15:58:46 afr Exp $\n *\n */\n\n#define S1341\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1341(double ep[],int im,int idim,int ipar,double epar[],\n\t   double eeps[],int ilend,int irend,double afctol,double aepsco,\n\t   int itmax,int ik,SISLCurve **rc,double emxerr[],int *jstat)\n#else\nvoid s1341(ep,im,idim,ipar,epar,eeps,ilend,irend,afctol,aepsco,\n           itmax,ik,rc,emxerr,jstat)\n     double ep[];\n     int    im;\n     int    idim;\n     int    ipar;\n     double epar[];\n     double eeps[];\n     int    ilend;\n     int    irend;\n     double afctol;\n     double aepsco;\n     int    itmax;\n     int    ik;\n     SISLCurve  **rc;\n     double emxerr[];\n     int    *jstat;\n#endif\n/*\n************************************************************\n*\n* Purpose: To compute a spline-approximation to the data given by the\n*          points ep, and represent it as a B-spline curve with\n*          parameterization determined by the parameter ipar.\n*          The approximation is determined by first forming the piecewise\n*          linear interpolant to the data, and then performing knot\n*          removal on this initial approximation.\n*\n* Input :\n*        Ep     - Array (length idim*im) containing the points to\n*                 be approximated.\n*        Im     - The no. of data points.\n*        Idim   - The dimension of the euclidean space in which the data\n*                 points lie, i.e. the number of components of each data point.\n*        Ipar   - Flag indicating the type of parameterization to be used:\n*                  = 1 : Paramterize by accumulated cord length.\n*                        (Arc length parametrization for the piecewise\n*                        linear interpolant.)\n*                  = 2 : Uniform parameterization.\n*                  = 3 : Parametrization given by epar.\n*                 If ipar<1 or ipar>3, it will be set to 1.\n*        Epar   - Array (length im) containing a parametrization\n*                 of the given data.\n*        Eeps   - Array (length idim) containing the tolerance to be\n*                 used during the data reduction stage. The final\n*                 approximation to the data will deviate less than eeps\n*                 from the piecewise linear interpolant in each of the\n*                 idim components.\n*        Ilend  - The no. of derivatives that are not allowed to change\n*                 at the left end of the curve.\n*                 The (0 - (ilend-1)) derivatives will be kept fixed.\n*                 If ilend <0, this routine will set it to 0.\n*                 If ilend<ik, this routine will set it to ik.\n*        Irend  - The no. of derivatives that are not allowed to change\n*                 at the right end of the curve.\n*                 The (0 - (irend-1)) derivatives will be kept fixed.\n*                 If irend <0, this routine will set it to 0.\n*                 If irend<ik, this routine will set it to ik.\n*        Afctol = Number indicating how the tolerance is to be shared\n*                 between the two data reduction stages. For the linear\n*                 reduction, a tolerance of afctol*eeps will be used,\n*                 while a tolerance of (1-afctol)*eeps will be used\n*                 during the final data reduction. (Similarly for edgeps.)\n*        Aepsco - Two numbers differing by a relative amount less than\n*                 aepsco will in some cases be considered equal.\n*        Itmax  - Max. no. of iterations in the data-reduction routine.\n*        Ik     - The polynomial order of the approximation.\n*\n* Output:\n*        Jstat  - Output staus:\n*                  < 0 : Error.\n*                  = 0 : Ok.\n*                  > o : Warning.\n*        Rc     - Pointer to curve.\n*        Emxerr - Array (length idim) (allocated outside this routine.)\n*                 containing for each component an upper bound on the\n*                 max. deviation of the final approximation from the\n*                 initial piecewise linear interpolant.\n*\n* Method: First the piecewise linear interpoolant is computed by a call\n*         to s1350 or s1351, and then knots are removed from this\n*         interpolant. The degree of the resulting linear spline is then\n*         raised to ik, and a second data-reduction is performed.\n*\n* The main routine,s1340, is written by Knut M|rken,  Si.\n* Written by: C.R.Birkeland  Si  Oslo,Norway April 1993.\n********************************************************************\n*/\n{\n  double *maxerr = SISL_NULL;    /* Arrays used to store error estimates */\n  double *error1 = SISL_NULL;\n  int i;\n  int stat = 0;             /* Loop control variables               */\n  int kpos = 0;\n  SISLCurve *ocurve = SISL_NULL; /* Local spline curve                   */\n  \n  /* Check Input */\n  \n  if (im < 2 || idim < 1) goto err103;\n  if (ipar < 1 || ipar > 3) ipar = 1;\n\n  /* Set default value for afctol */\n\n  if(afctol < 0 || afctol > 1) afctol =0;\n\n  /* Piecewise linear interpolant to the data */\n\n  if (ipar == 3)\n    s1350(ep, epar, im, idim, 2, &ocurve, &stat);\n  else\n    s1351(ep, ipar, im, idim, 2, &ocurve, &stat);\n  if (stat<0) goto error;\n\n  /* Compute tolerance for linear reduction */\n\n  error1 = newarray(idim, DOUBLE);\n  maxerr = newarray(idim, DOUBLE);\n  if (error1 == SISL_NULL || maxerr == SISL_NULL) goto err101;\n  for (i=0; i<idim; i++)\n    maxerr[i] = eeps[i]*afctol;\n\n  /* Data reduction on piecewise linear interpolant */\n\n  s1340(ocurve, maxerr, ilend, irend, aepsco, itmax, rc,\n\terror1, &stat);\n  if (stat<0) goto error;\n  freeCurve(ocurve);\n\n  /* Piecewise linear interpolant to the reduced data \n     (coefficients of linear spline curve rc)\n     expressed as B-spline of order ik */\n\n  s1350((*rc)->ecoef, &((*rc)->et)[1], (*rc)->in, \n\tidim, ik, &ocurve, &stat);\n  if (stat<0) goto error;\n  freeCurve(*rc);\n  \n  /* Compute tolerance for last reduction */\n\n  for (i=0; i<idim; i++)\n    maxerr[i] = eeps[i] - error1[i];\n\n  /* Perform data reduction on the hermite interpolant */\n\n  s1340(ocurve, maxerr, ilend, irend, aepsco, itmax, rc,\n\temxerr, &stat);\n  if (stat<0) goto error;\n\n  /* Set periodicity flag.  */\n  \n  (*rc)->cuopen = ocurve->cuopen;\n  \n  /* Compute total error after reduction */\n\n  for (i=0; i<idim; i++)\n    emxerr[i] += error1[i];\n  \n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation.  */\n\n  err101 :\n    *jstat = -101;\n  goto out;\n\n  /* Error in input */\n\n err103: \n  *jstat = -103;\n  s6err(\"s1341\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine. */\n\n error:\n  *jstat = stat;\n  s6err(\"s1341\",*jstat,kpos);\n  goto out;\n\n  /* Exit */\n\n out:\n  if (maxerr != SISL_NULL) freearray(maxerr);\n  if (error1 != SISL_NULL) freearray(error1);\n  if (ocurve != SISL_NULL) freeCurve(ocurve);\n  return;\n}\n"
  },
  {
    "path": "src/s1342.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1342.c,v 1.2 2001-03-19 15:58:46 afr Exp $\n *\n */\n\n#define S1342\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1342(double ep[],double ev[],int im,int idim,int ipar,double epar[],\n\t   double eeps[],int ilend,int irend,double aepsco,int itmax,\n\t   SISLCurve **rc,double emxerr[],int *jstat)\n#else\nvoid s1342(ep,ev,im,idim,ipar,epar,eeps,ilend,irend,aepsco,itmax,\n           rc,emxerr,jstat)\n     double ep[];\n     double ev[];\n     int    im;\n     int    idim;\n     int    ipar;\n     double epar[];\n     double eeps[];\n     int    ilend;\n     int    irend;\n     double aepsco;\n     int    itmax;\n     SISLCurve  **rc;\n     double emxerr[];\n     int    *jstat;\n#endif\n/*\n***********************************************************\n*\n* Purpose: To compute the approximation to the data given by the points\n*          ep and the derivatives (tangents) ev, and represent it as a\n*          B-spline curve with parametrization determined by the parameter\n*          ipar. The approximation is determined by first forming the cubic\n*          hermite interpolant to the data, and then performing knot\n*          removal on this initial approximation.\n*\n* Input :\n*         Ep     - Array (length idim*im) comtaining the points\n*                  to be approximated.\n*         Ev     - Array (length idim*im) containing the derivatives\n*                  of the points to be approximated.\n*         Im     - The no. of data points.\n*         Idim   - The dimension of the euclidean space in which the\n*                  curve lies.\n*         Ipar   - Flag indicating the type of paramterization to be used.\n*                   = 1 : Parametrize by accumulated cord length (arc\n*                         length parameterization for the piecewise\n*                         linear interpolant.)\n*                   = 2 : Uniform parametrization.\n*                   = 3 : parameterization given by epar.\n*                  If ipar<1 or ipar>3, it will be set to 1.\n*         Epar   - Array (length im) containing a parameterization\n*                  of the given data.\n*         Eeps   - Array (length idim) giving the desired accuracy of\n*                  the spline-approximation in each component.\n*         Ilend  - The no. of derivatives that are not allowed to change\n*                  at the left end of the curve.\n*                  The (0 - (ilend-1)) derivatives will be kept fixed.\n*                  If ilend <0, this routine will set it to 0.\n*                  If ilend<ik, this routine will set it to ik.\n*         Irend  - The no. of derivatives that are not allowed to change\n*                  at the right end of the curve.\n*                  The (0 - (irend-1)) derivatives will be kept fixed.\n*                  If irend <0, this routine will set it to 0.\n*                  If irend<ik, this routine will set it to ik.\n*         Aepsco - Two numbers differing by a relative amount < aepsco,\n*                  will in some cases be considered equal. A suitable\n*                  value is just above the unit roundoff in the machine.\n*                  On a VAX 1.0E-6 is a reasonable choice.\n*                  The computations are not guaranteed to have relative\n*                  accuracy less than aepsco.\n*         Itmax  - Max. no. of iteration.\n* Output:\n*         Jstat  - Output status:\n*                   < 0 : Error.\n*                   = 0 : Ok.\n*                   > 0 : Warning:\n*         Rc     - Pointer to curve.\n*         Emxerr - Array (length idim) (allocated outside this routine.)\n*                  containing an upper bound for the pointwise error\n*                  in each of the components of the spline-approximation.\n*-\n* Method: First the cubic hermite interpolant is computed by a call\n*         to s1379 or s1380, and then knots are removed from this\n*         interpolant.\n*\n* Calls: s1379, s1380, s1340, s6err.\n*\n* The main routine, s1340, is written by Knut M|rken,  Si.\n* Written by: C.R. Birkeland, Si, April 1993.\n**********************************************************\n*/\n{\n  int stat = 0;                /* Error control parameters         */\n  int kpos = 0;\n  SISLCurve *ocurve = SISL_NULL;    /* Local spline curve               */\n\n  /* Check Input */\n\n  if (im < 2 || idim < 1) goto err103;\n  if (ipar < 1 || ipar > 3) ipar = 1;\n\n  /* Compute hermite interpolant */\n\n  if (ipar == 3)\n    s1379(ep, ev, epar, im, idim, &ocurve, &stat);\n  else\n    s1380(ep, ev, im, idim, ipar, &ocurve, &stat);\n  if (stat < 0) goto error;\n\n  /* Perform data reduction on the cubic hermite interpolant */\n\n  s1340(ocurve, eeps, ilend, irend, aepsco, itmax, rc,\n\temxerr, &stat);\n  if (stat < 0) goto error;\n\n  /* Success */\n\n  *jstat = 0;\n  goto out;\n  \n  /* Error in input */\n\n err103: \n  *jstat = -103;\n  s6err(\"s1342\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine. */\n\n error: \n  *jstat = stat;\n  s6err(\"s1342\",*jstat,kpos);\n  goto out;\n\n  /* Exit */\n\n out:\n  if (ocurve != SISL_NULL) freeCurve(ocurve);\n  return;\n}\n"
  },
  {
    "path": "src/s1343.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1343.c,v 1.2 2001-03-19 15:58:46 afr Exp $\n *\n */\n\n#define S1343\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1343(SISLCurve *pc,double eeps[],int ilend,int irend,double aepsco,\n\t   int itmax, SISLCurve **rc,int *jstat)\n#else\nvoid s1343(pc,eeps,ilend,irend,aepsco,itmax,rc,jstat)\n     SISLCurve  *pc;\n     double eeps[];\n     int    ilend;\n     int    irend;\n     double aepsco;\n     int    itmax;\n     SISLCurve  **rc;\n     int    *jstat;\n#endif\n/*\n***********************************************************\n*\n* Purpose: To approximate the input spline-curve by a cubic spline-\n*          curve with error less than eeps in each of the kdim components.\n*\n* Input :\n*         Pc     - Pointer to curve.\n*         Eeps   - Array (length kdim) giving the desired accuracy of\n*                  the spline-approximation in each component.\n*         Ilend  - The no. of derivatives that are not allowed to change\n*                  at the left end of the curve.\n*                  The (0 - (ilend-1)) derivatives will be kept fixed.\n*                  If ilend <0, this routine will set it to 0.\n*                  If ilend<kord, this routine will set it to kord.\n*         Irend  - The no. of derivatives that are not allowed to change\n*                  at the right end of the curve.\n*                  The (0 - (irend-1)) derivatives will be kept fixed.\n*                  If irend <0, this routine will set it to 0.\n*                  If irend<kord, this routine will set it to kord.\n*         Aepsco - Two numbers differing by a relative amount <aepsco,\n*                  will in some cases be considered equal. A suitable\n*                  value is just above the unit roundoff in the machine.\n*                  On a VAX 1.0E-6 is a reasonable choice.\n*                  The computations are not guaranteed to have relative\n*                  accuracy less than aepsco.\n*         Itmax  - Max. no. of iterations.\n*\n* Output:\n*         Jstat  - Output status:\n*                   < 0 : Error.\n*                   = 0 : Ok.\n*                   > 0 : Warning:\n*         Rc     - Pointer to curve.\n*-\n* Method: First sampling points on the input-curve are determined such\n*         that the cubic hermite spline interpolant to these points will\n*         deviate with less than half the tolerance from the input-spline,\n*         and this hermite spline interpolant is run through data\n*         reduction to reduce the no. of knots.\n*\n* Calls: s1379, s1340, s1355, s6err\n*\n* The main routine, s1340, is written by Knut M|rken,  Si.\n* Written by: C.R. Birkeland, Si, April 1993.\n**********************************************************\n*/\n{\n  int i,j;                   /* Loop control variables           */\n  int index = 0;\n  int idim = pc->idim;       /* Space dimension                  */\n  int stat = 0;              /* Error control parameters         */\n  int kpos = 0;\n  int km;\n  int leftknot = 0;\n  double *error1 = SISL_NULL;\n  double *error2 = SISL_NULL;\n  double *epar = SISL_NULL;\n  double *derive = SISL_NULL;\n  double *kp = SISL_NULL;\n  double *kder = SISL_NULL;\n  SISLCurve *ocurve = SISL_NULL;\n  SISLCurve *qc_kreg = SISL_NULL;    /* Non-periodic version of the input curve. */\n  \n  \n  /* Check input-curve. */\n\n  if (!pc) goto err150;\n  s1707(pc, &stat);\n  if (stat<0) goto error;\n  \n  /* Make sure that the input curve is non-periodic.  */\n \n  if (pc->cuopen == SISL_CRV_PERIODIC)\n  {\n     make_cv_kreg(pc, &qc_kreg, &stat);\n     if (stat < 0) goto error;\n     \n     /* The input curve is closed and periodic. Make sure that the\n\tendpoints of the curve is still matching by fixing the\n\tposition and the derivative in the endpoints of the curve.\n\tThe change made to startfix and endfix is only locallly. */\n     \n     ilend = MAX(ilend, 2);\n     irend = MAX(irend, 2);\n  }\n  else \n     qc_kreg = pc;\n  \n  /* Check input */\n\n  if (qc_kreg->in < qc_kreg->ik || qc_kreg->ik < 1 || idim < 1) goto err103;\n  if (qc_kreg->ik < 5)\n    { \n      /* Increase order of curve to 4 (cubic) */\n\n      s1750(qc_kreg, 4, &ocurve, &stat);\n      if (stat < 0) goto error;\n\n      /* Curve is now a cubic spline \n       * Call reduction routine      */\n\n      if( (error2 = newarray( idim, DOUBLE )) == SISL_NULL) goto err101;\n      s1340( ocurve, eeps, ilend, irend, aepsco, itmax, rc, \n\t    error2, &stat);\n      if (stat < 0) goto error;\n\n      /* Success !  Go out ! */\n\n      goto out;\n    }\n\n  /* Set local tolerance */\n\n  if( (error1 = newarray(idim, DOUBLE)) == SISL_NULL) goto err101;\n\n  for (i=0; i<idim; i++)\n    error1[i] = 0.5*eeps[i];\n\n  /* Determine the sample points */\n\n  s1355( qc_kreg, error1, &epar, &km, &stat );\n  if (stat < 0) goto error;\n\n  /* Compute positions and derivatives of input spline\n   * at the given sampling points                      */\n\n  derive = newarray( idim * 2, DOUBLE );\n  kp     = newarray( idim * km, DOUBLE );\n  kder   = newarray( idim * km, DOUBLE );\n  if (derive == SISL_NULL || kp == SISL_NULL || kder == SISL_NULL) goto err101;\n\n  for(i=0; i<km; i++)\n    {\n      if(epar[i] == epar[i+1])\n\ts1227( qc_kreg, 1, epar[i], &leftknot, derive, &stat );\n      else\n\ts1221( qc_kreg, 1, epar[i], &leftknot, derive, &stat );\n\n      for(j=0; j<idim; j++, index++)\n\t{\n\t  kp[index] = derive[j];\n\t  kder[index] = derive[j+idim];\n\t}\n    }\n  if (stat < 0) goto error;\n\n  /* Compute Hermite interpolant */\n\n  s1379( kp, kder, epar, km, idim, &ocurve, &stat );\n  if (stat < 0) goto error;\n\n  /* Compute datareduction on the cubic hermite interpolant */\n\n  if( (error2 = newarray( idim, DOUBLE )) == SISL_NULL) goto err101;\n  s1340( ocurve, error1, ilend, irend, aepsco, itmax, rc, \n\terror2, &stat);\n  if (stat < 0) goto error;\n\n  /* Set periodicity flag.  */\n  \n  if (pc->cuopen == SISL_CRV_CLOSED || \n      pc->cuopen == SISL_CRV_PERIODIC)\n     (*rc)->cuopen = SISL_CRV_CLOSED;\n  \n  /* Success ! */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Allocation error. */\n\n err101: \n   *jstat = -101;\n   s6err(\"s1343\",*jstat,kpos);\n   goto out;\n  \n  /* Error in input */\n\n  err103: \n    *jstat = -103; \n    s6err(\"s1343\",*jstat,kpos);\n    goto out;\n  \n  /* Empty curve. */\n\n  err150: \n    *jstat = -150;\n    s6err(\"s1343\",*jstat,kpos);\n    goto out;\n  \n  /* Error in lower level routine. */\n\n  error: \n    *jstat = stat;\n    s6err(\"s1343\",*jstat,kpos);\n    goto out;\n\n  /* Exit */\n\n  out:\n    /* Free allocated arrays */\n\n    if( error1 != SISL_NULL) freearray(error1);\n    if( error2 != SISL_NULL) freearray(error2);\n    if( epar   != SISL_NULL) freearray(epar);\n    if( derive != SISL_NULL) freearray(derive);\n    if( kp     != SISL_NULL) freearray(kp);\n    if( kder   != SISL_NULL) freearray(kder);\n\n    /* Free local SISL-curves */\n\n    if( ocurve != SISL_NULL) freeCurve(ocurve);\n    if (qc_kreg != SISL_NULL && qc_kreg != pc) freeCurve(qc_kreg);\n\n    return;\n}\n"
  },
  {
    "path": "src/s1345.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1345.c,v 1.3 2001-03-19 15:58:46 afr Exp $\n *\n */\n\n#define S1345\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1345(SISLSurf *oldsurf,double eps[],int edgefix[4],double edgeps[],\n\t   double epsco,int opt,int itmax,SISLSurf **newsurf,\n\t   double maxerr[],int *stat)\n#else\nvoid s1345(oldsurf, eps, edgefix, edgeps, epsco, opt, itmax, newsurf,\n\t    maxerr, stat)\n     SISLSurf \t*oldsurf;\n     double\teps[];\n     int\tedgefix[4];\n     double\tedgeps[];\n     double\tepsco;\n     int \topt;\n     int\titmax;\n     SISLSurf\t**newsurf;\n     double\tmaxerr[];\n     int\t*stat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* Purpose: To remove as many knots as possible from the surface oldsurf\n*          without perturbing the surface more than the given tolerance.\n*          The tolerances are given by eps and epsfix, while the\n*\t   approximation is given by newsurf.\n*          Mark that the error in continuity over the start and end of\n*          a closed or periodic surface is only guaranteed to be within\n*          edgeps.\n*\n*\n*\n* Input:       oldsurf - pointer to the original spline surface. Note\n*\t\t\t if the polynomial orders of the surface are\n*\t\t\t k1 and k2, then the two knot vectors are\n*\t\t\t assumed to have knots of multiplicity k1 and\n*\t\t\t k2 at the ends.\n*\n*\t       eps     - double array of length dim (the number of\n*\t\t\t components of the surface, typically three)\n*\t\t\t giving the desired accuracy of the\n*\t\t\t final approximation compared to oldcurve.\n*                        Note that in such comparisons the two\n*\t\t\t surfaces are not reparametrized in any way.\n*\n*\t       edgefix - integer array of dimension (4) giving the number\n*\t\t\t of derivatives to be kept fixed along each edge\n*\t\t\t of the surface. The numbering of the edges is the\n*\t\t\t same as for edgeps below. All the derivatives of\n*\t\t\t order < nend(i)-1 will be kept fixed along\n*\t\t\t edge i. Hence nend(i)=0 indicates that nothing is\n*\t\t\t to be kept fixed along edge i.\n*\n*                NB! TO BE KEPT FIXED HERE MEANS TO HAVE ERROR LESS THAN\n*\t\t     EDGEPS. IN GENERAL, IT IS IMPOSSIBLE TO REMOVE KNOTS\n*                    AND KEEP AN EDGE COMPLETELY FIXED.\n*\n*\t       edgeps  - double array of length 4*dim ([4,dim]) (dim is\n*                        the number of components of each coefficient)\n*\t\t\t containing the maximum deviation which is\n*\t\t\t acceptable along the edges of the surface.\n*                        edgeps[0]-edgeps[dim-1] gives the tolerance along\n*\t\t\t the edge corresponding to x1 (the first parameter)\n* \t\t\t having it's minimum value.\n*\t\t\t edgeps[dim]-edgeps[2*dim-1] gives the tolerance\n*\t\t\t along the edge corresponding to x1 (the first\n*\t\t\t parameter) having it's maximum value.\n*              \t\t edgeps[2*dim]-edgeps[3*dim-1] gives the tolerance\n*\t\t\t along the edge corresponding to x2 (the second\n*\t\t\t parameter) having it's minimum value.\n*              \t\t edgeps[3*dim]-edgeps[4*dim-1] gives the tolerance\n*\t\t\t along the edge corresponding to x2 (the second\n*\t\t\t parameter) having it's maximum value.\n*           \t NB! EDGEPS WILL ONLY HAVE ANY SIGNIFICANCE IF THE\n*\t\t     CORRESPONDING ELEMENT OF EDGEFIX IS POSITIVE.\n*\n*\t       epsco   - real number used to check equality between real\n*                        numbers in some routines. Two numbers differing\n*                        by a relative amount less than epsco will in some\n*                        cases be considered equal. A suitable value is just\n*                        above the unit roundoff of the machine. In IEEE\n*                        double precision arithmetic 1.0E-15 is a reasonable\n*                        choice.\n*                 NB! THE COMPUTATIONS ARE NOT GUARANTEED TO HAVE\n*                     RELATIVE ACCURACY LESS THAN EPSCO.\n*\n*\n*\n*\t       itmax   - maximum number of iterations. The routine will\n*                        follow an iterative procedure trying to remove\n*                        more and more knots, one direction at a time.\n*                        The process will almost always stop after less\n*                        than 10 iterations and it will often stop after\n*                        less than 5 iterations. A suitable value for itmax\n*                        is therefore usually in the region 3-10.\n*\n*\n*\t       opt     - integer indicating the order in which the\n*\t       \t         knot removal is to be performed.\n*                            = 1 - remove knots in parameter direction 1 only.\n*                            = 2 - remove knots in parameter direction 2 only.\n*                            = 3 - remove knots first in parameter direction\n*\t\t\t       1 and then 2.\n*                            = 4 - remove knots first in parameter direction\n*\t\t\t       2 and then 1.\n*\n*\n*\n*\n*\n* Output:\n*         newsurf      - the approximating surface on the reduced knot vectors.\n*\n*\t  maxerr       - double array of length dim containing an upper\n*\t\t         bound for the pointwise error in each of the\n*\t\t         components of the spline approximation. The two\n*                        surfaces oldsurf and newsurf are compared at the\n*                        same parameter vaues, i.e., if oldsurf is f and\n*                        newsurf is g then\n*                              |f(u,v)-g(u,v)| <= eps\n*                        in each of the components.\n*\n*         stat         - status message\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n*\n*\n* Method:\n*     The data reduction is performed in one parameter direction at a time,\n*     using a subroutine for data reduction for spline curves (s1340).\n*     Consider for example knot removal in the second parameter direction\n*     (suppose oldcurve has m1xm2 coefficients, each with dim components\n*     and suppose also that the knot vectors are t1 and t2).\n*     This amounts to removing knots from each of the m1*dim curves, each\n*     of length m2 and with knot vector t2, obtained by considering the\n*     coefficients d as an array of dimension [m2][dim*m1] instead\n*     of [m2][m1][dim] (note that in the code the arrays are always\n*     treated as one dimensional).\n*     A similar approach is possible when removing knots in the first parameter\n*     direction except that then d has to be transposed in the first two\n*     dimensions first.\n*     The remaining part of the subroutine is more or less obvious except\n*     perhaps the fact that if knots are to be removed in both directions,\n*     the permissible error must be halved so that the total error committed\n*     is kept within the original tolerance.\n*\n*\n* References:\n*     1. A Data-Reduction Strategy for Splines with Applications to the\n*        Approximation of Functions and data, IMA J. of Num. Anal. 8 (1988),\n*        pp. 185-208.\n*\n*     2. Knot Removal for Parametric B-spline Curves and Surfaces,\n*        CAGD 4 (1987), pp. 217-230.\n*\n*-\n* Calls: s1340, s1352, s6chpar, s6err\n*\n* Written by: Knut Moerken, University of Oslo, December 1992, based\n*             on an earlier Fortran version by the same author.\n* Changed by: Paal Fugelli, SINTEF, 1994-07.\n*             Rewritten to fix several major memory leakage problems.\n*\n*********************************************************************\n*/\n\n{\n  int k1 = oldsurf->ik1;          /* Unwrap some of the most commonly */\n  int k2 = oldsurf->ik2;          /* used parameters.                 */\n  int m1 = oldsurf->in1;\n  int m2 = oldsurf->in2;\n  int dim = oldsurf->idim;\n  int ledgefix[4];                /* Local parameter for fixing the edge. */\n  double *et1 = SISL_NULL;\n  double *et2 = SISL_NULL;\n\n  double *local_eps = SISL_NULL;       /* Declaration of local variables, */\n  double *local_edge_eps = SISL_NULL;  /* for usage, see the code.        */\n  double *clocal_eps = SISL_NULL;\n  double *clocal_err = SISL_NULL;\n  double *harray = SISL_NULL;\n  double *tempcoef = SISL_NULL;\n  SISLSurf *qs_kreg = SISL_NULL;\n\n  double *loct1 = SISL_NULL;\n  double *loct2 = SISL_NULL;\n  SISLCurve *local_curve = SISL_NULL;\n  SISLCurve *newlcurve = SISL_NULL;\n\n  int lopt, i, it, n1, n2, antit, j, jh, lstat;\n  double factor;\n  int pos = 0;                    /* Parameter in s6err.             */\n\n\n  /* Make sure the returned surface has a valid value. */\n  *newsurf = SISL_NULL;\n\n  /* Make sure that the input surface is non-periodic.  */\n\n  memcopy(ledgefix, edgefix, 4, INT);\n  if (oldsurf->cuopen_1 == SISL_CRV_PERIODIC ||\n      oldsurf->cuopen_2 == SISL_CRV_PERIODIC)\n  {\n    make_sf_kreg(oldsurf, &qs_kreg, &lstat);\n    if (lstat < 0) goto error;\n\n    /* The input surface is closed and periodic. Make sure that the\n       endcurves of the surface is matching as good as possible\n       by fixing the position and the derivative in the edges of the surface.\n       The change made to startfix and endfix is only locallly. */\n\n    if (oldsurf->cuopen_1 == SISL_CRV_PERIODIC)\n      ledgefix[0] = ledgefix[1] = MAX(MAX(edgefix[0],edgefix[1]), 2);\n    if (oldsurf->cuopen_2 == SISL_CRV_PERIODIC)\n      ledgefix[2] = ledgefix[3] = MAX(MAX(edgefix[2],edgefix[3]), 2);\n  }\n  else\n    qs_kreg = oldsurf;\n\n  /* Unwrap the two (possibly changed) input knot vectors */\n\n  et1 = qs_kreg->et1;\n  et2 = qs_kreg->et2;\n\n\n  /* We start by allocating space for local arrays (any error exit must\n     now handle free'ing of allocated space). */\n\n  local_eps = newarray(dim, DOUBLE);\n  if (local_eps == SISL_NULL) goto err101;\n\n  local_edge_eps = newarray(4*dim, DOUBLE);\n  if (local_edge_eps == SISL_NULL) goto err101;\n\n  /* If we are going to remove knots in both directions, we use half the\n     tolerance each time, otherwise the whole tolerance once. This is\n     signified by factor. */\n\n  factor = (opt < 3) ? 1.0 : 0.5;\n\n  /* Store a local version of the tolerance and initialize the error\n     to zero. */\n\n  for (i=0; i<dim; i++)\n  {\n    local_eps[i] = factor*eps[i];\n    maxerr[i] = 0.0;\n  }\n\n  /* We also need a local version of the edge tolerance. */\n\n  /* Originally the edgetolerance was also multiplied by fac. It turns\n     out that this is unnecessary: Each edge is completely fixed in one\n     of the calls to s1340. */\n\n  for (i=0; i<4*dim; i++) local_edge_eps[i] = edgeps[i];\n\n  /* Now we are ready to prepare for the iterations. it counts the iterations\n     while lopt says which direction to start with and antit tells us how\n     many iterations there should be (one or two). n1 and n2 are used for\n     keeping track of the number of coefficients. */\n\n  it = 0; lopt = (opt-1) % 2 + 1;\n  n1 = m1; n2 = m2;\n\n  antit = (opt < 3) ? 1 : 2;\n  while (it < antit)\n  {\n    if (lopt == 1)\n    {\n\n      /* Here we remove knots along the first parameter direction. */\n\n      /* Since we are going to treat the surface as a collection of\n\t n2 curves in the first direction each with dim components,\n\t we need a tolerance array of length dim*n2 and a similar\n\t array for storing the error. */\n\n      clocal_eps = newarray(dim*n2, DOUBLE);\n      if (clocal_eps == SISL_NULL) goto err101;\n\n      clocal_err = newarray(dim*n2, DOUBLE);\n      if (clocal_err == SISL_NULL) goto err101;\n\n      /* The tolerance will in general not be the same for all the\n\t n2*dim curves. If edges 1 and/or 3 are to be kept fixed then\n\t first and/or last tolerance must be smaller than the tolerance\n\t for middle curves. This is accomplished by a call to s1352. */\n\n      s1352(et2, n2, k2, local_eps, (local_edge_eps+2*dim),\n\t    (local_edge_eps+3*dim), dim, ledgefix[2], ledgefix[3],\n\t    clocal_eps, &lstat);\n      if (lstat < 0) goto error;\n\n      /* First we have to pick out the correct coefficients.\n\t Then we must transpose the coefficient with respect to\n\t n1 and n2 due to the way we store the coefficients of\n\t surfaces. */\n\n      harray = newarray(n1*n2*dim, DOUBLE);\n      if (harray == SISL_NULL) goto err101;\n\n      if (opt == 4)\n      {\n\t/* Here tempcoef points to the coefs of the first direction. */\n\n\ts6chpar(tempcoef, n1, n2, dim, harray);\n\tfreearray(tempcoef);\n\ttempcoef = harray;\n      }\n      else\n      {\n\ts6chpar(qs_kreg->ecoef, n1, n2, dim, harray);\n\ttempcoef = harray;\n      }\n      harray = SISL_NULL;\n\n      /* We then create a curve in which to store the high dimensional\n\t curve. */\n\n      local_curve = newCurve(n1, k1, qs_kreg->et1, tempcoef,\n\t\t\t     1, dim*n2, 0);\n      if (local_curve == SISL_NULL) goto err101;\n\n      /* We can now perform knot removal on this curve. The result\n\t is stored in newlcurve (will always have icopy==1, i.e. a\n\t proper copy). */\n\n      s1340(local_curve, clocal_eps, ledgefix[0], ledgefix[1],\n\t    epsco, itmax, &newlcurve, clocal_err, &lstat);\n      if(lstat<0) goto error;\n\n      /* Remember to update n1 and throw away local_curve (has icopy==0). */\n\n      n1 = newlcurve->in;\n      freeCurve(local_curve);\n      local_curve = SISL_NULL;\n\n      /* Now we must transpose back to return to surface coeffiecients. */\n\n      tempcoef = increasearray(tempcoef,n1*n2*dim, DOUBLE);\n      if (tempcoef == SISL_NULL) goto err101;\n\n      harray = newlcurve->ecoef;\n      s6chpar(harray, n2, n1, dim, tempcoef);\n      harray = SISL_NULL;\n\n      /* We save the surface as a curve and create the final surface\n\t later. */\n\n      local_curve = newlcurve;\n      freearray(newlcurve->ecoef);\n      local_curve->ecoef = tempcoef;\n      newlcurve = SISL_NULL;\n\n      /* Now local_curve has icopy==1, so the knots and coefs are proper\n\t copies.  Must make it safe to free local_curve. */\n\n      local_curve->icopy = 0;\n\n      /* Now we can just save the new knot vector in loct1 and update the\n\t pointer to the \"input\" knot vector et1. */\n\n      loct1 = local_curve->et;\n      et1 = loct1;\n\n      /* tempcoef and loct1 are now safe from free'ing of local_curve, so\n\t throw it away. */\n\n      freeCurve(local_curve);\n      local_curve = SISL_NULL;\n\n      /* Calculate the error in the approximation. */\n\n      /* The error in component i in the approximation is simply\n\t the largest error in component i in any of the curves. */\n\n      for (i=0; i<dim; i++) clocal_eps[i] = 0.0;\n      for (jh=0, i=0; i<n2; i++)\n\tfor (j=0; j<dim; j++, jh++)\n\t  clocal_eps[j] = MAX(clocal_eps[j], clocal_err[jh]);\n\n      /* Accumulate the error in maxerr and use the remaining tolerance\n\t in the next direction. */\n\n      for (i=0; i<dim; i++)\n      {\n\tmaxerr[i] += clocal_eps[i];\n\tlocal_eps[i] = eps[i] - maxerr[i];\n      }\n      freearray(clocal_eps);\n      freearray(clocal_err);\n    }\n    else\n    {\n\n\n      /* Now we are to remove knots in the second direction. This is\n\t very similar to removing knots in the first direction but\n\t we do not need to transpose. */\n\n      /* First some local arrays. */\n\n      clocal_eps = newarray(dim*n1, DOUBLE);\n      if (clocal_eps == SISL_NULL) goto err101;\n\n      clocal_err = newarray(dim*n1, DOUBLE);\n      if (clocal_err == SISL_NULL) goto err101;\n\n      /* Compute a tolerance along the second direction. */\n\n      s1352(et1, n1, k1, local_eps, local_edge_eps,\n\t    local_edge_eps+dim, dim, ledgefix[0], ledgefix[1],\n\t    clocal_eps, &lstat);\n      if (lstat < 0) goto error;\n\n      /* Generate a high dimensional curve along the second direction\n\t with the right coefficients. */\n\n      if (opt == 3)\n      {\n\t/* Here tempcoef points to the coefs of the first direction. */\n\tlocal_curve = newCurve(n2, k2, qs_kreg->et2, tempcoef,\n\t\t\t       1, dim*n1, 0);\n      }\n      else\n\tlocal_curve = newCurve(n2, k2, qs_kreg->et2, qs_kreg->ecoef, 1,\n\t\t\t       dim*n1, 0);\n      if (local_curve == SISL_NULL) goto err101;\n\n      /* Remove knots and store in newlcurve (will always get icopy==1, i.e.\n\t proper copy. */\n\n      s1340(local_curve, clocal_eps, ledgefix[2], ledgefix[3],\n\t    epsco, itmax, &newlcurve, clocal_err, &lstat);\n      if(lstat<0) goto error;\n\n      /* Remember to update n2. */\n\n      n2 = newlcurve->in;\n\n      /* Throw away the old local_curve which has icopy==0 (must throw away\n\t tempcoef too -- non-null if opt==3), but keep newlcurve. */\n\n      freeCurve(local_curve);\n      if (tempcoef != SISL_NULL) freearray(tempcoef);\n      local_curve = newlcurve;\n      newlcurve = SISL_NULL;\n\n      /* Now local_curve has icopy==1, so the knots and coefs are proper\n\t copies.  Must make it safe to free local_curve. */\n\n      local_curve->icopy = 0;\n      tempcoef = local_curve->ecoef;\n\n      /* The new knot vector in the second direction will be stored in\n\t loct2 so we must update the pointer to the \"input\" knot vector et2. */\n\n      loct2 = local_curve->et;\n      et2 = loct2;\n\n      /* tempcoef and loct2 are now safe from free'ing of local_curve, so\n\t throw it away. */\n\n      freeCurve(local_curve);\n      local_curve = SISL_NULL;\n\n      /* Calculate the error in the approximation as above. */\n\n      for (i=0; i<dim; i++) clocal_eps[i] = 0.0;\n      for (jh=0, i=0; i<n1; i++)\n\tfor (j=0; j<dim; j++, jh++)\n\t  clocal_eps[j] = MAX(clocal_eps[j], clocal_err[jh]);\n\n      for (i=0; i<dim; i++)\n      {\n\tmaxerr[i] += clocal_eps[i];\n\tlocal_eps[i] = eps[i] - maxerr[i];\n      }\n      freearray(clocal_eps);\n      freearray(clocal_err);\n    }\n\n    /* Prepare for the next iteration. */\n\n    ++it;\n    lopt = 3 - lopt;\n\n  }\n\n  /* It remains to create a new surface object. If we only removed knots\n     in one direction, one of loct1 and loct2 will be SISL_NULL. */\n\n  if (loct1 == SISL_NULL)\n  {\n    loct1 = newarray(n1+k1, DOUBLE);\n    if (loct1 == SISL_NULL)  goto err101;\n\n    harray = et1;\n    for (i=0; i<n1+k1; i++) loct1[i] = harray[i];\n  }\n\n  if (loct2 ==SISL_NULL)\n  {\n    loct2 = newarray(n2+k2, DOUBLE);\n    if (loct2 == SISL_NULL)  goto err101;\n\n    harray = et2;\n    for (i=0; i<n2+k2; i++) loct2[i] = harray[i];\n  }\n\n  /* Generate the new surface object. */\n\n  *newsurf = newSurf(n1, n2, k1, k2, loct1, loct2, tempcoef,\n\t\t     1, dim, 2);\n\n  /* Avoid free'ing the referenced knots and coefs on exit. */\n\n  loct1 = SISL_NULL;\n  loct2 = SISL_NULL;\n  tempcoef = SISL_NULL;\n\n  /* Set periodicity flag. */\n\n  if (oldsurf->cuopen_1 == SISL_CRV_CLOSED ||\n      oldsurf->cuopen_1 == SISL_CRV_PERIODIC)\n    (*newsurf)->cuopen_1 = SISL_CRV_CLOSED;\n  if (oldsurf->cuopen_2 == SISL_CRV_CLOSED ||\n      oldsurf->cuopen_2 == SISL_CRV_PERIODIC)\n    (*newsurf)->cuopen_2 = SISL_CRV_CLOSED;\n\n  *stat = 0;\n  goto out;\n\n  /* Error in memory allocation. */\n\nerr101:\n  *stat = -101;\n  s6err(\"s1345\", *stat, pos);\n  goto out;\n\n  /* Error in lower level routine. */\n\nerror:\n  *stat = lstat;\n  s6err(\"s1345\", *stat, pos);\n\n  /* Clean up. */\n\nout:\n  if (local_eps != SISL_NULL) freearray(local_eps);\n  if (local_edge_eps != SISL_NULL) freearray(local_edge_eps);\n  if (clocal_eps != SISL_NULL) freearray(clocal_eps);\n  if (qs_kreg != SISL_NULL && qs_kreg != oldsurf) freeSurf(qs_kreg);\n\n  /* Must remember to free everything to avoid memory leak. */\n\n  if (clocal_eps != SISL_NULL) freearray(clocal_eps);\n  if (clocal_err != SISL_NULL) freearray(clocal_err);\n  if (tempcoef != SISL_NULL) freearray(tempcoef);\n  if (loct1 != SISL_NULL) freearray(loct1);\n  if (loct2 != SISL_NULL) freearray(loct2);\n  if (local_curve != SISL_NULL) freeCurve(local_curve);  /* icopy==0 */\n  if (newlcurve != SISL_NULL) freeCurve(newlcurve);  /* icopy ==1 */\n\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s1346.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1346.c,v 1.4 2001-03-19 15:58:46 afr Exp $\n *\n */\n\n#define S1346\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1346(double ep[],int im1,int im2,int idim,int ipar,double epar1[],\n\t   double epar2[],double eeps[],int nend[],double edgeps[],\n\t   double afctol,double aepsco,int iopt,int itmax,int ik1,int ik2,\n\t   SISLSurf **rs,double emxerr[],int *jstat)\n#else\nvoid s1346(ep,im1,im2,idim,ipar,epar1,epar2,eeps,nend,\n           edgeps,afctol,aepsco,iopt,itmax,ik1,ik2,\n           rs,emxerr,jstat)\n     double ep[];\n     int    im1;\n     int    im2;\n     int    idim;\n     int    ipar;\n     double epar1[];\n     double epar2[];\n     double eeps[];\n     int    nend[];\n     double edgeps[];\n     double afctol;\n     double aepsco;\n     int    iopt;\n     int    itmax;\n     int    ik1;\n     int    ik2;\n     SISLSurf   **rs;\n     double emxerr[];\n     int    *jstat;\n#endif\n/*\n********************************************************************\n*\n* Purpose: To compute a tensor-product spline-approximation of order\n*          (ik1,ik2) to the rectangular array of idim-dimensional\n*          points given by ep.\n*\n* Input : Ep     - Array (length idim*im1*im2) containing the points\n*                  to be approximated.\n*         Im1    - The no. of points in first parameter-direction.\n*         Im2    - The no. of points in second parameter-direction.\n*         Idim   - The no. of components of each input-point.\n*                  The approximation will be a parametric surface\n*                  situated in the idim-dimensional euclidean space\n*                  (usually 3).\n*         Ipar   - Flag determining the parametrization of the data points:\n*                   = 1: Mean accumulated cord-length parameterization.\n*                   = 2: Uniform parametrization.\n*                   = 3: Parametrization given by epar1 and epar2.\n*         Epar1  - Array (length im1) containing a parametrization\n*                  in the first parameter-direction. (Will only\n*                  be used if ipar=3).\n*         Epar2  - Array (length im2) containing a parametrization\n*                  in the second parameter-direction. (Will only\n*                  be used if ipar=3).\n*         Eeps   - Array (length idim) containing the max. permissible\n*                  deviation of the approximation from the given data\n*                  points, in each of the components. More specifically,\n*                  the approximation will not deviate more than eeps(kdim)\n*                  in component no. kdim, from the bilinear approximation\n*                  to the data.\n*         Nend   - Array (length 4) giving the no. of derivatives to be\n*                  kept fixed along each edge of the bilinear interpolant.\n*                  The numbering of the edges is the same as for edgeps below.\n*                  All the derivatives of order < (nend(i)-1) will be kept\n*                  fixed along the edge i. Hence nend(i)=0 indicates that\n*                  nothing is to be kpet fixed along edge i. (Used by the\n*                  data reduction routine.)\n*                  To be kept fixed here means to have error less than edgeps.\n*                  In general, it is impossible to remove any knots and keep\n*                  an edge completely fixed.\n*         Edgeps - Array (length idim*4) containing the max. deviation from\n*                  the bilinear interpolant which is acceptable along the\n*                  edges of the surface.\n*                  Edgeps(1,i):edgeps(idim,i) gives the tolerance along\n*                  the edge corresponding to the i-th parameter having\n*                  one of it`s extremal-values.\n*                   i=1: min value of first parameter.\n*                   i=2: max value of first parameter.\n*                   i=3: min value of second parameter.\n*                   i=4: max value of second parameter.\n*                  (Used by the data-reduction routine.)\n*                  Edgeps(kp,i) will only have significance if nend(i)>0.\n*         Afctol - 0.0 >= afctol <= 1.0.\n*                  Afctol indicates how the tolerance is to be shared\n*                  between the two data-reduction stages. For the linear\n*                  reduction, a tolerance of afctol*eeps will be used,\n*                  while a tolerance of (1.0-afctol)*eeps will be used\n*                  during the final data reduction (similarly for edgeps.)\n*                  Default is 0.\n*         Aepsco - Two numbers differing by a relative amount less than\n*                  aepsco, will in some cases be considered equal.\n*                  A suitable value is just above the unit roundoff\n*                  of the computer.\n*                  The computations are not guaranteed to have relative\n*                  accuracy less than aepsco.\n*          Iopt  - Flag indicating the order in which the data-reduction\n*                  is to be performed:\n*                   = 1: Remove knots inparameter-direction 1 only.\n*                   = 2: Remove knots inparameter-direction 2 only.\n*                   = 3: Remove knots first in parameter-direction 1 and\n*                        then in parameter-direction 2.\n*                   = 4: Remove knots first in parameter-direction 2 and\n*                        then in parameter-direction 1.\n*         Itmax  - Max. no. of iterations in the data-reduction.\n*         Ik1    - The order of the approximation in first\n*                  parameter-directon.\n*         Ik2    - The order of the approximation in second\n*                  parameter-directon.\n*\n* Output:\n*         Jstat  - Output status:\n*                   < 0 : Error.\n*                   = 0 : Ok.\n*                   > 0 : Warning:\n*         Rs     - Pointer to surface.\n*         Emxerr - Array (length idim) (allocated outside this routine.)\n*                  containing the error in the approximation to the data.\n*                  This is guaranteed upper bound on the max. deviation\n*                  in each component, between the final approximation\n*                  and the bilinear spline-approximation to the original data.\n*\n* Method:\n*        First the bilinear interpolant to the data is computed, using the\n*        parameterization given by ipar, and knots are removed from this\n*        initial approximation by a call to the data-reduction routine for\n*        surfaces. Then the order is raised to (ik1,ik2) and the final data\n*        reduction is performed.\n*-\n* Calls: s1345, s1350, s6chpar, s6err.\n*\n* Written by: C.R.Birkeland, Si, April 1993.\n* The main routine, s1345, is written by: Knut M|rken,  SI.\n* Changed by: Per OEyvind, SINTEF, 1994-11.\n*             Removed following memory leaks:\n*              1) Improper use of copy flag to newSurf()\n*              2) Forgetting to free temp array after using icopy == 1\n**********************************************************************\n*/\n{\n  int in1,in2;                /* Number of vertices                   */\n  int newin1, newin2;\n  int fouridim=4*idim;\n  int i;                      /* Loop control parameters              */\n  int stat=0, kpos=0;         /* Error message parameters             */\n  double *par1 = SISL_NULL;\n  double *par2 = SISL_NULL;\n  double *knot1 = SISL_NULL;       /* Knot vectors in 1 and 2. par.dir.    */\n  double *knot2 = SISL_NULL;\n  double *error1 = SISL_NULL;      /* Arrays for error storage             */\n  double *error2 = SISL_NULL;\n  double *maxerr = SISL_NULL;\n  double *newcoeff = SISL_NULL;    /* Coefficients array                   */\n  SISLCurve *ocurve1 = SISL_NULL;  /* Used to store local curves           */\n  SISLCurve *ocurve2 = SISL_NULL;\n  SISLSurf *osurf1 = SISL_NULL;    /* Used to store local surfaces         */\n  SISLSurf *osurf2 = SISL_NULL;\n\n  /* Check Input */\n\n  if (im1 < 2 || im2 < 2 || ik1 < 1 || ik2 < 1 || idim < 1)\n    goto err103;\n  if (ipar < 1 || ipar > 3) ipar = 1;\n\n  if (ipar != 3)\n    {\n      /* Generate parametrization */\n\n      s1528(idim, im1, im2, ep, ipar, SISL_CRV_OPEN, SISL_CRV_OPEN,\n\t    &par1, &par2, &stat);\n      if (stat<0) goto error;\n    }\n  else\n    {\n      /* Parametrization is passed as parameter */\n\n      par1 = epar1;\n      par2 = epar2;\n    }\n\n  /* Represent input (points) as a surface of\n   * order 2 (linear) in both directions.\n   * First, generate knot vectors */\n\n  knot1 = newarray(im1+2, DOUBLE);\n  knot2 = newarray(im2+2, DOUBLE);\n  if(knot1 == SISL_NULL || knot2 == SISL_NULL) goto err101;\n  memcopy(&knot1[1],par1,im1,DOUBLE);\n  memcopy(&knot2[1],par2,im2,DOUBLE);\n  knot1[0] = knot1[1];\n  knot2[0] = knot2[1];\n  knot1[im1+1] = knot1[im1];\n  knot2[im2+1] = knot2[im2];\n  osurf1 = newSurf(im1, im2, 2, 2, knot1, knot2, ep,\n\t\t   1,idim, 1);\n  if (osurf1 == SISL_NULL) goto err101;\n  if (knot1) freearray(knot1);\n  if (knot2) freearray(knot2);\n\n  /* Compute tolerance vectors for linear reduction\n   * Both max deviation of surface and max dev. of edges */\n\n  maxerr = newarray(idim, DOUBLE);\n  error1 = newarray(idim, DOUBLE);\n  error2 = newarray(fouridim, DOUBLE);\n  if (error1 == SISL_NULL || error2 == SISL_NULL || maxerr == SISL_NULL)\n    goto err101;\n  for (i=0; i<fouridim; i++)\n    {\n      edgeps[i] = MIN(edgeps[i], eeps[(i+idim)%idim]);\n      error2[i] = afctol * edgeps[i];\n    }\n  for (i=0; i<idim; i++)\n    error1[i] = afctol*eeps[i];\n\n  /* Perform datareduction on the bilinear interpolant */\n\n  s1345(osurf1, error1, nend, error2, aepsco, iopt, itmax,\n\t&osurf2, maxerr, &stat);\n  if (stat<0) goto error;\n\n  in1 = osurf2->in1;\n  in2 = osurf2->in2;\n\n  /* Free surface osurf1 */\n\n  if(osurf1 != SISL_NULL)\n    {\n      freeSurf(osurf1);\n      osurf1 = SISL_NULL;\n    }\n\n  /* Piecewise linear interpolant to the reduced\n   * bilinear interpolant expressed as a surface\n   * of orders ik1 and ik2 */\n\n  /* Second parameter direction */\n\n  s1350(osurf2->ecoef,&(osurf2->et2)[1], in2,\n\tin1 * idim, ik2, &ocurve1, &stat);\n  if (stat<0) goto error;\n\n  newin2 = ocurve1->in;\n\n  /* Transpose result, store new coefficients in\n   * array newcoeff */\n\n  if( (newcoeff = newarray(idim * in1 * newin2, DOUBLE)) == SISL_NULL )\n    goto err101;\n  s6chpar(ocurve1->ecoef, in1, newin2, idim, newcoeff);\n\n  /* First parameter direction */\n\n  s1350(newcoeff, &(osurf2->et1)[1], in1,\n\tidim*newin2, ik1, &ocurve2, &stat);\n  if (stat<0) goto error;\n  newin1 = ocurve2->in;\n\n  /* Free surface osurf2 */\n\n  if(osurf2 != SISL_NULL)\n    {\n      freeSurf(osurf2);\n      osurf2 = SISL_NULL;\n    }\n\n  /* Transpose back and get coefficients of bilinear\n   * approximatoin surface of orders ik1 and ik2     */\n\n  newcoeff = increasearray(newcoeff,\n\t\t\t   idim * newin1 * newin2, DOUBLE);\n  if (newcoeff == SISL_NULL) goto err101;\n  s6chpar(ocurve2->ecoef, newin2, newin1, idim, newcoeff);\n\n  /* Store results as a surface */\n\n  osurf1 = newSurf(newin1, newin2, ik1, ik2, ocurve2->et,\n\t\t   ocurve1->et, newcoeff, 1, idim, 1);\n\n  free(newcoeff); newcoeff = SISL_NULL;\n\n  if (osurf1 == SISL_NULL) goto err101;\n\n  /* Set periodicity flag. */\n\n  osurf1->cuopen_1 = ocurve2->cuopen;\n  osurf1->cuopen_2 = ocurve1->cuopen;\n\n  /* Compute tolerance for final datareduction */\n\n  for (i=0; i<fouridim; i++)\n    error2[i] = edgeps[i]-error2[i];\n  for (i=0; i<idim; i++)\n    error1[i] = eeps[i]-maxerr[i];\n\n  /* Perform final datareduction step */\n\n  s1345(osurf1, error1, nend, error2, aepsco, iopt, itmax,\n\trs, emxerr, &stat);\n  if (stat<0) goto error;\n\n  /* Compute total (and final) error */\n\n  for(i=0; i<idim; i++)\n    emxerr[i] += maxerr[i];\n\n  /* Success */\n\n  *jstat = 0;\n  goto out;\n\n  /* Empty array. */\n\n err101:\n  *jstat = -101;\n  s6err(\"s1346\",*jstat,kpos);\n  goto out;\n\n  /* Error in input */\n\n err103:\n  *jstat = -103;\n  s6err(\"s1346\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine. */\n\n error:\n  *jstat = stat;\n  s6err(\"s1346\",*jstat,kpos);\n  goto out;\n\n  /* Exit */\n\n out:\n  /* Free SISL-curves allocated in this routine */\n\n  if(ocurve1 != SISL_NULL) freeCurve(ocurve1);\n  if(ocurve2 != SISL_NULL) freeCurve(ocurve2);\n\n  /* Free SISL-surfaces allocated in this routine */\n\n  if(osurf1 != SISL_NULL) freeSurf(osurf1);\n\n  /* Free arrays */\n\n  if(error1 != SISL_NULL) freearray(error1);\n  if(error2 != SISL_NULL) freearray(error2);\n  if(maxerr != SISL_NULL) freearray(maxerr);\n\n  if (ipar != 3)\n    {\n      freearray(par1);\n      freearray(par2);\n    }\n\n  return;\n}\n"
  },
  {
    "path": "src/s1347.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1347.c,v 1.2 2001-03-19 15:58:46 afr Exp $\n *\n */\n\n#define S1347\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1347(double ep[],double etang1[],double etang2[],double eder11[],\n\t   int im1,int im2,int idim,int ipar,double epar1[],double epar2[],\n\t   double eeps[],int nend[],double edgeps[],double aepsco,int iopt,\n\t   int itmax,SISLSurf **rs,double emxerr[],int *jstat)\n#else\nvoid s1347(ep,etang1,etang2,eder11,im1,im2,idim,ipar,epar1,epar2,\n\t   eeps,nend,edgeps,aepsco,iopt,itmax,rs,emxerr,jstat)\n     double ep[];\n     double etang1[];\n     double etang2[];\n     double eder11[];\n     int    im1;\n     int    im2;\n     int    idim;\n     int    ipar;\n     double epar1[];\n     double epar2[];\n     double eeps[];\n     int    nend[];\n     double edgeps[];\n     double aepsco;\n     int    iopt;\n     int    itmax;\n     SISLSurf   **rs;\n     double emxerr[];\n     int    *jstat;\n#endif\n/*\n********************************************************************\n*\n* Purpose: To compute a bicubic hermite spline-approximation to the\n*          position and derivative data given by ep,etang1,etang2\n*          and eder11.\n*\n* Input : Ep     - Array (length idim*im1*im2) containing the points\n*                  to be approximated.\n*         Etang1 - Array (length idim*im1*im2) containing the derivatives\n*                  (tangents) in the first parameter-direction at the\n*                  data-points.\n*         Etang2 - Array (length idim*im1*im2) containing the derivatives\n*                  (tangents) in the second parameter-direction at the\n*                  data-points.\n*         Eder11 - Array (length idim*im1*im2) containing the cross (twist)\n*                  derivatives at the data-points.\n*         Im1    - The no. of points in the first parameter-direction.\n*         Im2    - The no. of points in the second parameter-direction.\n*         Ipar   - Flag determining the parametrization of the data-points.\n*                   = 1: Mean accumulated cord length parametrization.\n*                   = 2: Uniform parametrization.\n*                   = 3: Parametrization given by epar1 and epar2.\n*         Epar1  - Array (length im1) containing a parametrization in the\n*                  first parameter-direction. (Will only be used if ipar=3.)\n*         Epar2  - Array (length im2) containing a parametrization in the\n*                  surface lies.)\n*         Eeps   - Array (length idim) containing the maximum deviation\n*                  which is acceptable in each of the idim components of\n*                  the surface (except possibly along the edges).\n*         Nend   - Array (length 4) containing the no. of derivatives \n*                  to be kept fixed along each edge of the surface.\n*                  The numbering of the edges is the same as for edeps below.\n*                  All the derivatives of order < nend(i)-1 will be kept fixed\n*                  along edge no. i. Hence nend(i)=0 indicates that nothing\n*                  is to be kpet fixed along edge no. i.\n*                  To be kept fixed here means to have error less than edgeps.\n*                  In general, it is impossible to remove any knots and\n*                  keep an edge completely fixed.\n*         Edgeps - Array (length idim*4) containing the max. deviation\n*                  which is acceptable along the edges of the surfaces.\n*                  Edgeps(1,i):edgeps(idim,i) gives the tolerance along\n*                  the edge corresponding to the i-th parameter having\n*                  its min. or max value.\n*                  i=1 : min value of first parameter.\n*                  i=2 : max value of first parameter.\n*                  i=3 : min value of second parameter.\n*                  i=4 : max value of second parameter.\n*                  Edgeps(kp,i) will only have any significance if nend(i)>0.\n*         Aepsco - Two numbers differing by a relative amount less than\n*                  aepsco will in some cases be considered equal.\n*                  A suitable value is just above the unit roundoff\n*                  of the machine. On VAX, 1.0E-6 is a reasonable choice.\n*                  The computations are not guaranteed to have relative\n*                  accuracy less than aepsco.\n*         Iopt   - Flag indicationg the order in which tha data-reduction\n*                  is to be performed.\n*                   = 1 : Remove knots in parameter-direction 1 only.\n*                   = 2 : Remove knots in parameter-direction 2 only.\n*                   = 3 : Remove knots in parameter-direction 1 and\n*                         and then in parameter-direction 2.\n*                   = 4 : Remove knots in parameter-direction 2 and\n*                         and then in parameter-direction 1.\n*         Itmax  - Max. no. of iteration.\n*\n* Ouput:  Jstat  - Output status:\n*                   < 0 : Error.\n*                   = 0 : Ok.\n*                   > 0 : Warning.\n*         Rs     - Pointer to surface.\n*         Emxerr - Array (length idim) (allocated outside this routine.)\n*                  containing an upper bound for the error comitted in\n*                  each component during the data reduction.\n*\n* Method: First the bicubic hermite spline-interpolant is computed\n*         using the appropriate parametrization, and then knots\n*         are removed from this approximation by a call to the\n*         data-reduction routine for surfaces.\n*\n* Calls: s1530, s1345, s6err.\n*\n* Written by: C.R.Birkeland, Si, Oslo, Norway, May 1993.\n* The datareduction routine, s1345, is written by: Knut M|rken,  SI.\n**********************************************************************\n*/\n{\n  int stat=0, kpos=0;         /* Error message parameters        */\n  double *par1 = SISL_NULL;        /* Used to store parametrizations  */\n  double *par2 = SISL_NULL;\n  SISLSurf *osurf = SISL_NULL;     /* Hermite interp. surface         */ \n\n  /* Check Input */\n\n  if (im1 < 2 || im2 < 2 || idim < 1) \n    goto err103; \n  if (ipar < 1 || ipar > 3) ipar = 1;\n\n  /* Generate parametrization */\n\n  if (ipar != 3) \n    { \n      /* Generate parametrization */\n      \n      s1528(idim, im1, im2, ep, ipar, SISL_CRV_OPEN, SISL_CRV_OPEN,\n\t    &par1, &par2, &stat);\n      if (stat<0) goto error;\n    }\n  else \n    {\n      /* Parametrization is passed as parameter */\n\n      par1 = epar1;\n      par2 = epar2;\n    } \n\n  /* Perform bicubic hermite spline interpolation */\n\n  s1530(ep, etang1, etang2, eder11, par1, par2,\n\tim1, im2, idim, &osurf, &stat);\n  if (stat<0) goto error;\n\n  /* Perform final datareduction step */\n\n  s1345(osurf, eeps, nend, edgeps, aepsco, iopt, itmax,  \n        rs, emxerr, &stat);\n  if (stat<0) goto error;\n  \n  /* Success */\n\n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error in input */\n\n  err103: \n    *jstat = -103;\n    s6err(\"s1347\",*jstat,kpos);\n    goto out;\n  \n  /* Error in lower level routine. */\n\n  error: \n    *jstat = stat;\n    s6err(\"s1347\",*jstat,kpos);\n    goto out;\n  \n  /* Exit. */\n\n  out:\n    /* Free SISL-surface allocated in this routine */\n\n    if(osurf != SISL_NULL) freeSurf(osurf);\n\n    if (ipar != 3)\n      {\n\tif(par1 != SISL_NULL) freearray(par1);\n\tif(par2 != SISL_NULL) freearray(par2);\n      }\n    return;\n}\n"
  },
  {
    "path": "src/s1348.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1348.c,v 1.3 2001-03-19 15:58:46 afr Exp $\n *\n */\n\n#define S1348\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1348(SISLSurf *ps,double eeps[],int nend[],double edgeps[],\n\t   double aepsco,int iopt,int itmax,SISLSurf **rs,int *jstat)\n#else\nvoid s1348(ps,eeps,nend,edgeps,aepsco,iopt,itmax,rs,jstat)\n     SISLSurf   *ps;\n     double eeps[];\n     int    nend[];\n     double edgeps[];\n     double aepsco;\n     int    iopt;\n     int    itmax;\n     SISLSurf   **rs;\n     int    *jstat;\n#endif\n/*\n********************************************************************\n*\n* Purpose: To compute a cubic tensor-product spline approximation\n*          to a given tensor product spline surface of arbitrary order,\n*          with error less than eeps in each of the idim components.\n*          Mark that the error in continuity over the start and end of\n*          a closed or periodic surface is only guaranteed to be within\n*          edgeps.\n*\n* Input : Ps     - Pointer to surface.\n*         Eeps   - Array (length kdim) containing the maximum deviation\n*                  which is acceptable in each of the kdim components of\n*                  of the surface (except possibly along the edges).\n*         Nend   - Array (length 4) containing the no. of derivatives\n*                  to be kept fixed along each edge of the surface.\n*                  The numbering of the edges is the same as for edeps below.\n*                  All the derivatives of order < nend(i)-1 will be kept fixed\n*                  along edge no. i. Hence nend(i)=0 indicates that nothing\n*                  is to be kpet fixed along edge no. i.\n*                  To be kept fixed here means to have error less than edgeps.\n*                  In general, it is impossible to remove any knots and\n*                  keep an edge completely fixed.\n*         Edgeps - Array (length kdim*4) containing the max. deviation\n*                  which is acceptable along the edges of the surfaces.\n*                  Edgeps(1,i):edgeps(kdim,i) gives the tolerance along\n*                  the edge corresponding to the i-th parameter having\n*                  its min. or max value.\n*                  i=1 : min value of first parameter.\n*                  i=2 : max value of first parameter.\n*                  i=3 : min value of second parameter.\n*                  i=4 : max value of second parameter.\n*                  Edgeps(kp,i) will only have any significance if nend(i)>0.\n*         Aepsco - Two numbers differing by a relative amount less than\n*                  aepsco will in some cases be considered equal.\n*                  A suitable value is just above the unit roundoff\n*                  of the machine. On VAX, 1.0E-6 is a reasonable choice.\n*                  The computations are not guaranteed to have relative\n*                  accuracy less than aepsco.\n*         Iopt   - Flag indicationg the order in which tha data-reduction\n*                  is to be performed.\n*                   = 1 : Remove knots in parameter-direction 1 only.\n*                   = 2 : Remove knots in parameter-direction 2 only.\n*                   = 3 : Remove knots in parameter-direction 1 and\n*                         and then in parameter-direction 2.\n*                   = 4 : Remove knots in parameter-direction 2 and\n*                         and then in parameter-direction 1.\n*         Itmax  - Max. no. of iterations.\n*\n* Output:\n*         Jstat  - Output status:\n*                   < 0 : Error.\n*                   = 0 : Ok.\n*                   > 0 : Warning:\n*         Rs     - Pointer to surface.\n*\n* Method:\n*        First a tensor-product bicubic spline-approximation with error\n*        less than half the tolerance is computed. Then the no. of\n*        parameters is reduced by the use of data-reduction, also with\n*        a tolerance of half the input-tolerance.\n*        The initial approximation is deteremined by first sampling the\n*        surface and its 10, 01 and 11 derivatives sufficiently often to\n*        ensure that a piecewise bicubic hermite interpolation will give\n*        an error less than half the tolerance, and then computing this\n*        approximation.\n*\n* Calls: s1387, s1530, s1345, s6err.\n*\n* Written by: C.R.Birkeland, Si, Oslo, Norway, April 1993.\n* The datareduction routine, s1345, is written by: Knut M|rken,  SI.\n* Changed by: Per OEyvind, SINTEF, 1994-11.\n*             Added input check for invalid Eeps values.\n*             Removed 2 array \"overlooks\", when setting side1 and side2.\n**********************************************************************\n*/\n{\n  int i,j,k;                    /* Loop control                        */\n  int index = 0;\n  int idim=ps->idim;\n  int stat = 0;                 /* Error message parameters            */\n  int kpos = 0;\n  int im1, im2;                 /* Number of vertices                  */\n  int leftknot1 = 0;            /* Used in call to s1424: evaluator    */\n  int leftknot2 = 0;\n  int side1 = 0;                /* Evaluation from what side           */\n  int side2 = 0;\n  int ledgefix[4];                /* Local parameter for fixing the edge. */\n  double *error1 = SISL_NULL;        /* For error bounds                    */\n  double *error2 = SISL_NULL;\n  double *error1472 = SISL_NULL;\n  double *newcoeff = SISL_NULL;\n  double *ep = SISL_NULL;            /* Used to store points                */\n  double *eder10 = SISL_NULL;        /* Used to store corresponding derivatives */\n  double *eder01 = SISL_NULL;\n  double *eder11 = SISL_NULL;\n  double *derive = SISL_NULL;\n  double *par1 = SISL_NULL;          /*  Used to store parametrizations      */\n  double *par2 = SISL_NULL;\n  SISLCurve *ocurve = SISL_NULL;\n  SISLSurf *osurf1 = SISL_NULL;\n  SISLSurf *osurf2 = SISL_NULL;\n  double parvalue[2];\n  SISLSurf *qs_kreg = SISL_NULL;\n\n\n  /* Check input and description of surface.\n   * ---------------------------------------\n   */\n\n  if (!ps) goto err150;\n  if (ps->ik1 < 1 || ps->ik2 < 1 || idim < 1) goto err103;\n\n  /* Get the eeps value with largest absolute value */\n  parvalue[0] = fabs(eeps[0]);\n  for (i = 1; i < 4; i++)\n  {\n    parvalue[1] = fabs(eeps[i]);\n    if (parvalue[1] > parvalue[0])\n      parvalue[0] = parvalue[1];\n  }\n\n  /* If no max deviation are large than zero ... */\n  if (DEQUAL(parvalue[0], 0.0))\n    goto err103;\n\n  /* Allocate error matrices */\n\n  error1 = newarray( idim, DOUBLE);\n  error2 = newarray( idim, DOUBLE);\n  error1472 = newarray( idim, DOUBLE);\n  if( error1 == SISL_NULL || error2 == SISL_NULL || error1472 == SISL_NULL )\n    goto err101;\n\n  /* Make sure that the input surface is non-periodic.  */\n\n  memcopy(ledgefix, nend, 4, INT);\n  if (ps->cuopen_1 == SISL_CRV_PERIODIC ||\n      ps->cuopen_2 == SISL_CRV_PERIODIC)\n  {\n     make_sf_kreg(ps, &qs_kreg, &stat);\n     if (stat < 0) goto error;\n\n     /* The input surface is closed and periodic. Make sure that the\n\tendcurves of the surface is matching as good as possible\n\tby fixing the position and the derivative in the edges of the surface.\n\tThe change made to startfix and endfix is only locallly. */\n\n     if (ps->cuopen_1 == SISL_CRV_PERIODIC)\n\tledgefix[0] = ledgefix[1] = MAX(MAX(nend[0],nend[1]), 2);\n     if (ps->cuopen_2 == SISL_CRV_PERIODIC)\n\tledgefix[2] = ledgefix[3] = MAX(MAX(nend[2],nend[3]), 2);\n  }\n  else\n     qs_kreg = ps;\n\n  /* First,  make sure both orders are higher or equal to 4 */\n\n  if (qs_kreg->ik1 < 4 || qs_kreg->ik2 < 4)\n    {\n      /* Increase order in at least one direction */\n\n      s1387(qs_kreg, MAX( 4, qs_kreg->ik1), MAX( 4, qs_kreg->ik2),\n\t    &osurf1, &stat);\n      if (stat<0) goto error;\n    }\n  else\n    osurf1 = newSurf(qs_kreg->in1, qs_kreg->in2, qs_kreg->ik1, qs_kreg->ik2,\n\t\t     qs_kreg->et1, qs_kreg->et2, qs_kreg->ecoef, 1, idim, 1);\n\n  /* Make sure orders in both directions are 4. */\n\n  if (osurf1->ik1 == 4 && osurf1->ik2 == 4)\n    {\n      /* Orders in both parameterdirections are now 4.\n       * No degree reduction necessary.\n       * Specify directly error bounds for use\n       * in the datareduction routine. */\n\n      for(i=0; i<idim; i++)\n\terror2[i] = eeps[i];\n      osurf2 = newSurf(osurf1->in1, osurf1->in2, 4, 4, osurf1->et1,\n\t\t       osurf1->et2, osurf1->ecoef, 1, idim, 1);\n    }\n  else\n    {\n      /* The order must be decreased for at least one direction.\n       * Create error bounds. */\n\n      for(i=0; i<idim; i++)\n\t{\n\t  error1[i] = 0.25 * eeps[i];\n\t  error2[i] = eeps[i]-error1[i];\n\t}\n\n      /* Check second direction */\n\n      /* Create curve equivalent and determine sampling points\n       * for 2. direction */\n\n      ocurve = newCurve(osurf1->in2, osurf1->ik2, osurf1->et2,\n\t\t\tosurf1->ecoef, 1, idim*osurf1->in1, 1);\n      if(ocurve == SISL_NULL) goto err101;\n\n      error1472 = increasearray(error1472, idim*osurf1->in1, DOUBLE);\n      if(error1472 == SISL_NULL) goto err101;\n      for(i=0; i<idim*osurf1->in1; i++)\n\terror1472[i] = error1[i % idim];\n      s1355(ocurve, error1472, &par2, &im2, &stat);\n      if (stat<0) goto error;\n      freeCurve(ocurve);\n      ocurve = SISL_NULL;\n\n      /* Create curve equivalent and determine sample points\n       * for 1. direction after transposing surface coefficients */\n\n      newcoeff = newarray(idim * osurf1->in1 * osurf1->in2, DOUBLE);\n      if (newcoeff == SISL_NULL) goto err101;\n      s6chpar(osurf1->ecoef, osurf1->in1, osurf1->in2, idim, newcoeff);\n\n      ocurve = newCurve(osurf1->in1, osurf1->ik1, osurf1->et1,\n\t\t\tnewcoeff, 1, idim*osurf1->in2, 1);\n      if(ocurve == SISL_NULL) goto err101;\n\n      error1472 = increasearray(error1472, idim*osurf1->in2, DOUBLE);\n      if(error1472 == SISL_NULL) goto err101;\n      for(i=0; i<idim*osurf1->in2; i++)\n\terror1472[i] = error1[i % idim];\n      s1355(ocurve, error1472, &par1, &im1, &stat);\n      if (stat<0) goto error;\n      freeCurve(ocurve);\n      ocurve = SISL_NULL;\n\n      /* Compute points and derivatives on the surface\n       * at the points given by calculated par.values */\n\n      derive = newarray( idim * 4, DOUBLE );\n      ep     = newarray( idim * im1 * im2, DOUBLE );\n      eder10 = newarray( idim * im1 * im2, DOUBLE );\n      eder01 = newarray( idim * im1 * im2, DOUBLE );\n      eder11 = newarray( idim * im1 * im2, DOUBLE );\n      if (ep == SISL_NULL || eder10 == SISL_NULL || eder01 == SISL_NULL ||\n\t  eder11 == SISL_NULL || derive == SISL_NULL) goto err101;\n      index = 0;\n      for(j=0; j<im2; j++)\n\t{\n\t  parvalue[1] = par2[j];\n\t  if(j+1 < im2 && par2[j] != par2[j+1])\n\t    side2 = 1;\n\t  else\n\t    side2 = -1;\n\n\t  for(i=0; i<im1; i++)\n\t    {\n\t      parvalue[0] = par1[i];\n\t      if(i+1 < im1 && par1[i] != par1[i+1])\n\t\tside1 = 1;\n\t      else\n\t\tside1 = -1;\n\n\t      s1425( qs_kreg, 1, 1, side1, side2, parvalue, &leftknot1,\n\t\t\t  &leftknot2, derive, &stat );\n\t      if(stat < 0) goto error;\n\t      for(k=0; k<idim; k++, index++)\n\t\t{\n\t\t  ep[index] = derive[k];\n\t\t  eder10[index] = derive[k+idim];\n\t\t  eder01[index] = derive[k+2*idim];\n\t\t  eder11[index] = derive[k+3*idim];\n\t\t}\n\t    }\n\t}\n      if (stat < 0) goto error;\n\n      /* Compute Hermite interpolant */\n\n      s1530(ep, eder10, eder01, eder11, par1, par2, im1, im2,\n\t    idim, &osurf2, &stat);\n      if(stat < 0) goto error;\n    }\n\n  /* Perform datareduction on the bicubic surface.\n   * Use tolerance error2                         */\n\n  s1345(osurf2, error2, ledgefix, edgeps, aepsco, iopt, itmax,\n\trs, error1, &stat);\n  if(stat < 0) goto error;\n\n  /* Set periodicity flag. */\n\n  if (ps->cuopen_1 == SISL_CRV_CLOSED || ps->cuopen_1 == SISL_CRV_PERIODIC)\n     (*rs)->cuopen_1 = SISL_CRV_CLOSED;\n  if (ps->cuopen_2 == SISL_CRV_CLOSED || ps->cuopen_2 == SISL_CRV_PERIODIC)\n     (*rs)->cuopen_2 = SISL_CRV_CLOSED;\n  /*\n   * Success.\n   * --------\n   */\n\n  *jstat = 0;\n  goto out;\n\n\n  /*\n   * Error in allocation.\n   * --------------------\n   */\n\n  err101:\n    *jstat = -101;\n    s6err(\"s1348\",*jstat,kpos);\n    goto out;\n\n  /* Error in input */\n\n  err103:\n    *jstat = -103;\n    s6err(\"s1348\",*jstat,kpos);\n    goto out;\n\n  /*\n   * Error in input, pointer to SISLSurf was SISL_NULL pointer.\n   * -----------------------------------------------------\n   */\n\n  err150:\n    *jstat = -150;\n    s6err(\"s1348\",*jstat,kpos);\n    goto out;\n\n  /*\n   * Error in lower level routine.\n   * -----------------------------\n   */\n\n   error:\n    *jstat = stat;\n    s6err(\"s1348\",*jstat,kpos);\n    goto out;\n\n  /*\n   * Exit s1348.\n   * -----------\n   */\n\n  out:\n    if(error1 != SISL_NULL)    freearray(error1);\n    if(error2 != SISL_NULL)    freearray(error2);\n    if(error1472 != SISL_NULL) freearray(error1472);\n    if(newcoeff != SISL_NULL)  freearray(newcoeff);\n    if(ep != SISL_NULL)        freearray(ep);\n    if(eder10 != SISL_NULL)    freearray(eder10);\n    if(eder01 != SISL_NULL)    freearray(eder01);\n    if(eder11 != SISL_NULL)    freearray(eder11);\n    if(derive != SISL_NULL)    freearray(derive);\n    if(par1 != SISL_NULL)      freearray(par1);\n    if(par2 != SISL_NULL)      freearray(par2);\n    if(osurf1 != SISL_NULL)    freeSurf(osurf1);\n    if(osurf2 != SISL_NULL)    freeSurf(osurf2);\n    if (qs_kreg != SISL_NULL && qs_kreg != ps) freeSurf(qs_kreg);\n\n    return;\n}\n"
  },
  {
    "path": "src/s1349.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1349.c,v 1.3 2001-03-19 15:58:46 afr Exp $\n *\n */\n\n\n#define S1349\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1349(int inbcrv,SISLCurve *vpcrv[],int *jstat)\n#else\nvoid s1349(inbcrv,vpcrv,jstat)\n     int   inbcrv;\n     SISLCurve *vpcrv[];\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To convert a B-spline curve with the first ik knots not\n*              equal to et(ik) and the last ik knots not equal to\n*              et(in+1) to a representation with the first ik knots\n*              equal to et(ik), and the last ik knots equal to et(in+1).\n*\n* INPUT      : inbcrv - No. of curves in the curve-set.\n*              vpcrv  - Array (length inbcrv) of pointers to curves\n*                       to the curves in the curve-set.\n*\n* OUTPUT     : jstat  - status messages:\n*                        > 0      : warning\n*                        = 0      : ok\n*                        < 0      : error\n*              vpcrv  - Array (length inbcrv) to curves in the curve-set..\n*                       (Changed description.)\n*\n* METHOD     : For each curve, the multiplicity of the end vertices is\n*              counted, and those curves not having the right multiplicity\n*              are converted to a representation with the right multiplicity.\n*-\n* CALLS      : s1712,s6err\n*\n* WRITTEN BY : A. M. Ytrehus SI, Oslo, Norway.  Sep.  1988\n* Revised by : Tor Dokken, SI, Oslo, Norway. 26. Feb. 1989\n* Revised by : Paal Fugelli, SINTEF, Oslo 02/08-1994. Fixed memory leak.\n*\n*********************************************************************\n*/\n{\n  SISLCurve **wp = SISL_NULL;      /* Local pointer to current curve.           */\n  SISLCurve *qc2 = SISL_NULL;      /* Pointer to new curve-object.              */\n  int kvert;              /* No. of vertices in current curve.           */\n  int kord;               /* Order of current curve.                     */\n  double *sknot = SISL_NULL;   /* Pointer to knot-vector of current curve.    */\n  int kk,kr;              /* Loop controllers.                           */\n  double *sp1,*sp2;       /* Pointers to sknot.                          */\n  int kmul1,kmul2;        /*                                             */\n  double tval1,tval2;     /*                                             */\n  int kstat = 0;          /* Status variable.                            */\n  int kpos = 0;           /* Position of error.                          */\n\n  wp = vpcrv;\n  for (kk=0; kk<inbcrv; kk++)\n    {\n      /* Make local pointers to description of curve */\n      sknot = (*wp) -> et;\n      kvert = (*wp) -> in;\n      kord = (*wp) -> ik;\n\n      /* Count multiplicity of start-knot. */\n      kmul1 = 0;\n      sp1 = sknot + kord - 1;\n      tval1 = *sp1;\n      for (kr=0; kr<kord; kr++)\n\t{\n          if (*sp1 == tval1) kmul1++;\n          sp1--;\n\t}\n\n      /* Count multiplicity of end-knot. */\n      kmul2 = 0;\n      sp2 = sknot + kvert;\n      tval2 = *sp2;\n      for (kr=0; kr<kord; kr++)\n\t{\n          if (*sp2 == tval2) kmul2++;\n          sp2++;\n\t}\n\n      /* If the multiplicity of both end-knots equals kord, the curve is ok. */\n      if (kmul1 != kord || kmul2 != kord)\n\t{\n          /* Both ends do not have multiplicity of order kord.\n             Create a new curve-object.                        */\n          s1712((*wp),tval1,tval2,&qc2,&kstat);\n          if (kstat<0) goto error;\n\t  if ((*wp)) freeCurve(*wp);  /* PFU 02/08-1994 */\n          *wp = qc2;\n          qc2 = SISL_NULL;\n\t}\n      wp++;\n    }\n\n  *jstat = 0;\n  goto out;\n\n/* Error in lower level routine. */\nerror: *jstat = kstat;\n       s6err(\"s1349\",*jstat,kpos);\n       goto out;\nout:\nreturn;\n}\n"
  },
  {
    "path": "src/s1350.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1350.c,v 1.2 2001-03-19 15:58:46 afr Exp $\n *\n */\n\n#define S1350\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1350(double ep[],double epar[],\n\t   int im,int idim,int ik,\n\t   SISLCurve **rc, int *jstat)\n#else\nvoid s1350(ep,epar,im,idim,ik,rc,jstat)\n     double ep[];\n     double epar[];\n     int im;\n     int idim;\n     int ik;\t   \n     SISLCurve **rc;\n     int    *jstat;\n#endif\n/*\n************************************************************\n*\n* Purpose: To compute the piecewise linear interpolant to a set \n*          of datapoints and express it as a linear combination \n*          of B-splines of order ik using the parametrization\n*          given by epar.\n*\n* Input :\n*        Ep     - Array [idim,im] containing the points to\n*                 be approximated.\n*        Epar   - Array (length im) containing a parametrization\n*                 of the given data.\n*        Im     - The no. of data points.\n*        Idim   - The dimension of the euclidean space in which the data\n*                 points lie, i.e. the number of components of each data point.\n*        Ik     - The polynomial order of the approximation.\n*\n* Output:\n*        Jstat  - Output staus:\n*                  < 0 : Error.\n*                  = 0 : Ok.\n*                  > o : Warning.\n*        Rc     - Pointer to curve.\n*\n* Method: The routine uses the parametrization given by the array\n*         epar. The knotvector will have ik-multiple knots at both \n*         ends and (ik-1)-tuple knots at each interior points on the\n*         knot vector. This makes it easy to determine the B-spline\n*         coefficients of the piecewise linear interpolant.\n*\n*\n* The fortran version was written by Knut M|rken,  Si.\n* Written by: C.R.Birkeland  Si  Oslo,Norway April 1993.\n********************************************************************\n*/\n{\n  int i, j, k;                   /* Loop index                     */\n  int kic, kit, kw1, kw2;        /* Used in calculations           */\n  double ts, tw1, tw2;           /* Used in calculations           */\n  int kpos = 0;                  /* Indicator of position of error */\n  int in;\n  int jidim;                     /*  j*idim                        */\n  int jidimp1;                   /*  (j+1)*idim                    */\n  double *et = SISL_NULL;             /* Array for knotvector           */\n  double *ec = SISL_NULL;             /* Array for coefficients         */\n  double ikinv;                  /*   1. / ik                      */\n  int kclosed;                   /* Used to test if the curve is closed. */\n\n  /* Check Input */\n  \n  if (im < 2 || idim < 1 || ik < 2) goto err103;\n\n  /* Allocate matrices */\n\n  in = (ik-1)*im + 2 - ik;\n  et = newarray(in+ik, DOUBLE);\n  ec = newarray(in*idim, DOUBLE);\n  if (et==SISL_NULL || ec == SISL_NULL) goto err101;\n\n  /* Perform the one and only division required \n     in this routine */\n\n  ikinv = 1./(ik-1);\n\n  /* Generate first knots and first coefficient */\n\n  for(i=0; i<ik; i++)\n      et[i] = epar[0];\n  for(i=0; i<idim; i++)\n      ec[i] = ep[i];\n  \n  /* Compute remaining knots and coefficients */\n\n  kic = idim;\n  kit = ik;\n  for(j=0, jidim=0, jidimp1=idim; j<im-1; j++, jidim+=idim, \n       jidimp1+=idim)\n    {\n      ts = epar[j+1];\n      \n      /* Compute coefficients of the B-splines starting\n\t at point j and set knots for next point */\n\n      kw1 = ik-1;\n      kw2 = 0;\n      for (i=1; i<ik; i++)\n\t{\n\t  et[kit] = ts;\n\t  kit++;\n\t  kw1--;\n\t  kw2++;\n\t  tw1 = kw1*ikinv;\n\t  tw2 = kw2*ikinv;\n\t  for (k=0; k<idim; k++)\t \n\t    ec[kic + k] = tw1*ep[jidim + k] + \n\t      tw2*ep[jidimp1 + k];\n\t  kic += idim;\n\t}\n    }\n\n  /* Set last knot */\n\n  et[kit] = ts;\n  if ((*rc = newCurve(in,ik,et,ec,1,idim,2)) == SISL_NULL)\n        goto err101;\n\n  /* Test if the input data is closed.  */\n  \n  for (kclosed=1, i=0; i<idim; i++)\n     if (DNEQUAL(ep[i], ep[(im-1)*idim+i])) kclosed = 0;\n  if (kclosed) (*rc)->cuopen = SISL_CRV_CLOSED;\n     \n  /* Success */\n  \n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation.  */\n\n  err101 :\n    *jstat = -101;\n    if (et != SISL_NULL) freearray(et);  \n    if (ec != SISL_NULL) freearray(ec);\n    goto out;\n\n  /* Error in input */\n\n err103: \n  *jstat = -103;\n  s6err(\"s1350\",*jstat,kpos);\n  goto out;\n  \n  /* Exit */\n\n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1351.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1351.c,v 1.2 2001-03-19 15:58:46 afr Exp $\n *\n */\n\n#define S1351\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1351(double ep[],int ipar,\n\t   int im,int idim,int ik,\n\t   SISLCurve **rc, int *jstat)\n#else\nvoid s1351(ep,ipar,im,idim,ik,rc,jstat)\n     double ep[];\n     int ipar;\n     int im;\n     int idim;\n     int ik;\t   \n     SISLCurve **rc;\n     int    *jstat;\n#endif\n/*\n************************************************************\n*\n* Purpose: To compute the piecewise linear interpolant to a set \n*          of datapoints and express it as a linear combination \n*          of B-splines of order ik using the parametrization\n*          determined by ipar.\n*\n* Input :\n*        Ep     - Array [idim,im] containing the points to\n*                 be approximated.\n*        Ipar   - Integer indicating type of parametrization:\n*                 1: Chord length parametrization.\n*                 2: Uniform parametrization.\n*        Im     - The no. of data points.\n*        Idim   - The dimension of the euclidean space in which the data\n*                 points lie, i.e. the number of components of each data point.\n*        Ipar   - Flag indicating the type of parameterization to be used:\n*                  = 1 : Paramterize by accumulated cord length.\n*                        (Arc length parametrization for the piecewise\n*                        linear interpolant.)\n*                  = 2 : Uniform parameterization.\n*                  = 3 : Parametrization given by epar.\n*                 If ipar<1 or ipar>3, it will be set to 1.\n*        Ik     - The polynomial order of the approximation.\n*\n* Output:\n*        Jstat  - Output staus:\n*                  < 0 : Error.\n*                  = 0 : Ok.\n*                  > o : Warning.\n*        Rc     - Pointer to curve.\n*\n* Method: \n*\n* The fortran version was written by Knut M|rken,  Si.\n* Written by: C.R.Birkeland  Si  Oslo,Norway April 1993.\n*\n********************************************************************\n*/\n{\n  int stat = 0;                  /* Error-Status parameters       */ \n  int kpos = 0;\n  int par=0;                     /* Type of parametrization       */\n  double *epar = SISL_NULL;           /* Parametrization array         */ \n  int i;                         /* Loop index                    */ \n  int kpek1, kpek2;              /* Used in gen. of cord len. par.*/\n\n  /* Check Input */\n  \n  if (im < 2 || idim < 1 || ik < 2) goto err103;\n  if (ipar < 1 || ipar > 2) goto err103;\n\n  /* Allocate array for parametrization */\n\n  if( (epar = newarray(im, DOUBLE)) == SISL_NULL ) goto err101;\n  epar[0] = (double) 0.0;\n\n  /* Compute parametrization */\n\n  if (ipar == 1)\n    {\n      /* Chord length parametrization */\n\n      kpek1 = 0;\n      for (i=1; i<im; i++)\n\t{\n\t  kpek2 = kpek1 + idim;\n\t  epar[i] = epar[i-1] + s6dist(&ep[kpek2], &ep[kpek1], idim);\n\t  kpek1 = kpek2;\n\t}\n      if (epar[im-1] == 0.) par=2;\n    }\n\n  if (ipar == 2 || par == 2)\n    /* Uniform parametrization */\n\n    for (i=1; i<im; i++)\n      epar[i] = i;\n      \n  /* Compute cubic spline hermite interpolant */\n\n  s1350(ep, epar, im, idim, ik, rc, &stat);\n  if (stat<0) goto error;\n  \n  /* Success */\n\n  *jstat = 0;\n  goto out;\n\n\n  /* Error in scratch allocation.  */\n\n  err101 :\n    *jstat = -101;\n    s6err(\"s1351\",*jstat,kpos);\n    goto out;\n\n  /* Error in input */\n\n  err103: \n    *jstat = -103;\n    s6err(\"s1351\",*jstat,kpos);\n    goto out;\n  \n  /* Error in lower level routine. */\n\n  error:\n    *jstat = stat;\n    s6err(\"s1351\",*jstat,kpos);\n    goto out;\n\n  /* Exit */\n\n  out:\n    if(epar != SISL_NULL) freearray(epar);\n    return;\n}\n"
  },
  {
    "path": "src/s1352.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1352.c,v 1.5 2001-03-19 15:58:46 afr Exp $\n *\n */\n\n#define S1352\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1352(double t[],int n,int k,double inteps[],double lefteps[],\n\t   double righteps[],int dim,int leftfix,int rightfix,\n\t   double eps[],int *stat)\n#else\nvoid s1352(t, n, k, inteps, lefteps, righteps, dim, leftfix, rightfix,\n\t   eps, stat)\n     double\tt[];\n     int\tn;\n     int\tk;\n     double \tinteps[];\n     double\tlefteps[];\n     double\trighteps[];\n     int\tdim;\n     int\tleftfix;\n     int\trightfix;\n     double\teps[];\n     int\t*stat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* Purpose: To compute a variable tolerance, eps, along a knot vector. This\n*          tolerance will be used for knot removal of tensor product B-spline\n*          surfaces. The tolerance is to be lefteps at the left end of the\n*          knot vector, then increase to inteps at the midpoint and then\n*          decrease again to righteps at the right end of the knot vector\n*          (this description applies to each of the dim components of the\n*          tolerance.) The way the tolerance increases from the left end to\n*          the midpoint, is determined by the variable leftfix.\n*          The tolerance will increase according to the first half\n*          of a perfect B-spline of order leftfix+1 (if leftfix=0 the\n*          tolerance will be inteps along the first half of the knot vector\n*          irrespective of the value of lefteps) translated and scaled\n*          appropriately. The value of eps(.,i)\n*          will be the value of this spline at the 'de Boor point',\n*\n*                           (t[i+1]+...+t[i+k-1])/(k-1)),\n*\n*          assuming that this point lies to the left of the midpoint.\n*          To the right of the midpoint the tolerance will decrease in a\n*\t   similar way depending on the integer irend.\n*\n*\n*\n*\n* Input:\n*          t           - the knot vector along which we are to compute\n*\t\t\t tolerances.\n*\n*          n           - the number of B-splines associated by t.\n*\n*          k           - the polynomial order of the B-splines associated\n*                        with t.\n*\n*          inteps      - double array of length dim giving the maximum\n*\t\t\t tolerance in the interior of t.\n*\n*\t   lefteps     - double array of length dim giving the tolerance\n*                        at the beginning of t.\n*\n*          righteps    - double array of length dim giving the tolerance\n*                        at the end of t.\n*          dim         - the dimension of the tolerance vectors.\n*\n*          leftfix     - the number of derivatives to be kept fixed during\n*                        knot removal at the edge corresponding to the\n*                        beginning of t. The greater the value of leftfix\n*                        the more slowly the tolerance is allowed to increase\n*\t\t\t towards the middle of t.\n*          rightfix    - similar to leftfix.\n*\n*\n* Output:\n*          eps         - double array of length dim containing the computed\n*                        tolerance vector.\n*\n* Method:\n*     As indicated above the main ingredient in this routine is the perfect\n*     B-spline. First the knots for the perfect B-spline of order leftfix+1\n*     are computed and the tolerance over the first half of the knot vector\n*     is calculated. Then the knots for the perfect B-spline of order\n*     rightfix+1 are computed and the tolerance over the second half of\n*     the knot vector is calculated.\n*\n*\n* References:\n*     Larry Schumaker, Spline Functions: Basic Theory, Wiley.\n*\n*\n*-\n*\n* Calls: s1221\n*\n* WRITTEN BY : Knut Moerken, University of Oslo, July 1992, based\n*              on an earlier Fortran version.\n* Changed by: Paal Fugelli, SINTEF, 1994-07.\n*             Added code at end to to fix memory leakage problem.\n*\n*********************************************************************\n*/\n{\n  int ih = 3*MAX(leftfix, rightfix) + 2; /* Size of knot vector.       */\n  double *th = SISL_NULL;\t\t\t /* Knot vector.               */\n  double *hcoef = SISL_NULL;\t\t\t /* B-spline coefficients.     */\n  double *w = SISL_NULL;\t\t\t /* Work array for s1221.      */\n\n  SISLCurve *hspline = SISL_NULL;             /* Object that will be used\n\t\t\t\t\t    for storing the perfect\n\t\t\t\t\t    B-spline.\t\t       */\n\n                                         /* The usage of the rest of\n\t\t\t\t\t    the variables should be\n\t\t\t\t\t    clear from the code.       */\n\n  int left=0, i, lstat, j, jh, pos=0;\n  double k1inv, ta, tb, tmid, hh, maxval, sum, cnst, ch, val;\n\n  /* A useful constant. */\n\n  if (k == 1) k1inv = 1.0;\n  else k1inv = 1.0 / (float) (k-1);\n\n  /* Determine the left and right ends and the midpoint of the knot\n     interval over which the tolerance vector is to be computed,\n     hh will also be useful. */\n\n  ta = t[k-1]; tb = t[n];\n  tmid = ta + (tb-ta)/2.0;\n  hh = 1.0 / (tb-ta);\n\n  /* Allocate space for the knot vector of the perfect B-spline. For\n     simplicity we use s1221 for computing values on this B-spline and\n     then it is easiest if it is a B-spline on a knot vector with\n     multiple knots at the ends. If the order of the perfect B-spline is\n     r then we use array of length 3r-1, so that the perfect B-spline\n     becomes the middle one on this knot vector. Since we do not\n     bother to allocate space twice we make sure we have enough space\n     for largest of these knot vectors. */\n\n  th = newarray(ih, double);\n  if (th == SISL_NULL) goto err101;\n\n  /* The length of the coefficient vector should be clear from\n     the argument above. We set all coefficients to zero except the one\n     that multiplies the perfect B-spline which of course must be one. */\n\n  hcoef = new0array(2*MAX(leftfix, rightfix)+1, double);\n  if (hcoef == SISL_NULL) goto err101;\n\n  hcoef[leftfix] = 1.0;\n\n  /* Determine the knot vector. */\n\n  if (leftfix == 0)\n    {\n      /* For order one we only need two knots which we could really pick\n\t quite arbitrarily as long as we avoid the discontinuity. */\n\n      th[0] = MIN(-1.1, (2*t[0]-ta-tb)*hh);\n      th[1] = MAX(1.1, (2*t[n+k-1]-ta-tb)*hh);\n    }\n  else\n    {\n\n      /* Compute the knots of the perfect B-spline and give the first and\n\t last knot maximal multiplicity. */\n\n      cnst = PI / (float) (leftfix+1);\n\n      /* First the \"real knots\". */\n\n      for (j=0; j<=leftfix+1; j++)\n\tth[leftfix+j] = cos((leftfix+1-j)*cnst);\n\n      /* Increase the multiplicity at the ends (-1 and 1 if the arithmetic\n\t is exact). */\n\n      for (j=0; j<leftfix; j++)\n\t{\n\t  th[j] = th[leftfix];\n\t  th[j+2*leftfix+2] = th[j+2*leftfix+1];\n\t}\n    }\n\n  /* Allocate space for a work array to be used by s1221 which will also\n     be used for returning results. */\n\n  w = newarray(MAX((leftfix+1),(rightfix+1)), double);\n  if (w == SISL_NULL) goto err101;\n\n  /* Create the spline object that represents the perfect B-spline. */\n\n  hspline = newCurve(2*leftfix+1, leftfix+1, th, hcoef, 1, 1, 0);\n  if (hspline == SISL_NULL) goto err101;\n\n  /* Evaluate the perfect B-spline at its maximum, the midpoint 0,\n     and save it in maxval. */\n\n  s1221(hspline, 0, 0.0, &left, w, &lstat);\n  if (lstat < 0) goto err;\n\n  maxval = w[0];\n\n  /* Now we are ready to compute tolerances. To do this we stretch the\n     perfect B-spline so that it starts at ta and ends at tb and therefore\n     has its maximum at tmid. To compute tolerances in the left half\n     of [ta, tmid] we use the first half of the perfect B-spline, adjusted\n     so that its value at ta is lefteps and its value at tmid is inteps.\n     The right half is treated similarly. The tolerance for coefficient\n     i will then from the adjusted perfect B-spline at the de Boor point\n     (t[i+1]+...+t[i+k-1])/(k-1). */\n\n  /* We start by computing the tolerance at the left end which is lefteps. */\n\n  if (leftfix > 0)\n    {\n      for (ih=0; ih<dim; ih++) eps[ih] = lefteps[ih];\n    }\n  else\n    {\n      for (ih=0; ih<dim; ih++) eps[ih] = inteps[ih];\n    }\n\n  /* We then compute the second de Boor point (sum). */\n\n  if (k == 1) sum = t[1];\n  else\n    {\n      sum = 0.0;\n\n      for (j=2; j<k+1; j++) sum += t[j];\n\n      sum *= k1inv;\n    }\n\n  /* Then we enter a loop to compute the tolerances up to the midpoint. */\n\n  i = 1;  ih = dim;\n\n  while (sum < tmid)\n    {\n\n      /* Determine the correct argument to the perfect B-spline. */\n\n      ch = (2*sum-ta-tb)*hh;\n\n      /* Evaluate the perfect B-spline. */\n\n      s1221(hspline, 0, ch, &left, w, &lstat);\n      if (lstat < 0) goto err;\n\n      /* Scale the value. */\n\n      val = w[0];\n      val /= maxval;\n\n      /* Compute the tolerance at this de Boor point. */\n\n      for (jh=0; jh<dim; jh++, ih++)\n\teps[ih] = MIN((inteps[jh]-lefteps[jh])*val + lefteps[jh],inteps[jh]);\n\n      ++i;\n\n      /* Compute the next de Boor point. */\n\n     if (k == 1) sum = t[i];\n     else\n       {\n\t sum = 0.0;\n\n\t for (j=i+1; j<i+k; j++) sum += t[j];\n\n\t sum *= k1inv;\n       }\n    }\n\n  /* Now we have to prepare for computing tolerances in [tmid,ta].\n     If the number of derivatives to be kept fixed is deifferent at the\n     two ends we must compute a new knot vector. */\n\n  if (leftfix != rightfix)\n    {\n      if (rightfix == 0)\n\t{\n\t  th[0] = MIN(-1.1, (2*t[0]-ta-tb)*hh);\n\t  th[1] = MAX(1.1, (2*t[n+k-1]-ta-tb)*hh);\n\t}\n      else\n\t{\n\t  cnst = PI / (float) (rightfix+1);\n\n\t  for (j=0; j<=rightfix+1; j++)\n\t    th[rightfix+j] = cos((rightfix+1-j)*cnst);\n\t  for (j=0; j<rightfix; j++)\n\t    {\n\t      th[j] = th[rightfix];\n\t      th[j+2*rightfix+2] = th[j+2*rightfix+1];\n\t    }\n\t}\n\n      /* For simplicity we always update the coefficient vector. */\n\n      hcoef[leftfix] = 0.0;\n      hcoef[rightfix] = 1.0;\n\n      /* For simplicity we also free the old spline object (has icopy==0). */\n\n      freeCurve(hspline);\n      hspline = newCurve(2*rightfix+1, rightfix+1, th, hcoef, 1, 1, 0);\n      if (hspline == SISL_NULL) goto err101;\n\n      /* Find the maximum of the perfect B-spline. */\n\n      s1221(hspline, 0, 0.0, &left, w, &lstat);\n      if (lstat < 0) goto err;\n\n      maxval = w[0];\n    }\n\n  /* Compute the remaining tolerances as above (the next de Boor point is\n     already known). */\n\n  while (i<n-1)\n    {\n      ch = (2*sum-ta-tb)*hh;\n\n      s1221(hspline, 0, ch, &left, w, &lstat);\n      if (lstat < 0) goto err;\n\n      val = w[0];\n      val /= maxval;\n\n      for (jh=0; jh<dim; jh++, ih++)\n\teps[ih] = MIN((inteps[jh]-righteps[jh])*val + righteps[jh],inteps[jh]);\n\n      ++i;\n\n     if (k == 1) sum = t[i];\n     else\n       {\n\t sum = 0.0;\n\n\t for (j=i+1; j<i+k; j++) sum += t[j];\n\n\t sum *= k1inv;\n       }\n    }\n\n  /* Compute the final tolerance which is righteps. */\n\n  if (rightfix > 0)\n    {\n      for (jh=0; jh<dim; jh++, ih++) eps[ih] = righteps[jh];\n    }\n  else\n    {\n      for (jh=0; jh<dim; jh++, ih++) eps[ih] = inteps[jh];\n    }\n\n  /* Everything went well. */\n\n  *stat = 0;\n  goto out;\n\n  /* Error in memory allocation. */\n\n err101:\n  *stat = -101;\n  s6err(\"s1352\", *stat, pos);\n\n  goto out;\n\n  /* Error in lower level routine. */\n\n err:\n  *stat = lstat;\n  s6err(\"s1352\", *stat, pos);\n\n  /* Free memory. */\n\n out:\n  if (w != SISL_NULL) freearray(w);\n  if (hspline != SISL_NULL) freeCurve(hspline);\n\n  /* Must also remove knots and coefs because hspline had icopy==0. */\n\n  if (th != SISL_NULL) freearray(th);\n  if (hcoef != SISL_NULL) freearray(hcoef);\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s1353.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1353.c,v 1.3 2006-05-02 15:06:56 sbr Exp $\n *\n */\n\n#define S1353\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1353(SISLCurve *curve,double eps[],rank_info *ranking,int *stat)\n#else\nvoid s1353(curve, eps, ranking, stat)\n     SISLCurve\t*curve;\n     double\teps[];\n     rank_info\t*ranking;\n     int *stat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* Purpose: To compute a ranking of the knots of curve, suitable for use\n*          during knot removal.\n*\n*\n*\n* Input:\n*          curve       - pointer to the curve whose knots are to be ranked.\n*\n*\t   eps         - double array containing the tolerance in the\n*\t\t\t different components to be used during knot removal.\n*\n*\n*\n* Output:  ranking     - a pointer to a rank_info object containing the\n*                        result of the ranking computations. The struct\n*\t\t\t rank_info contains four variables listed below\n*                        (t, k, and n refer to the knot vector of curve,\n*\t\t\t its polynomial order and the number of B-spline\n*                        coefficients):\n*\t ranking->prio - integer array of dimension (n-k) containing the\n*\t\t\t ranking of the interior knots. The knots are listed\n* \t\t\t in order of increasing ranking number, cf. the\n*\t\t\t second reference, with knots with the same ranking\n*\t\t         number listed in the order in which they occur\n*\t\t         in t. To differentiate between the different\n*                        ranking numbers the array ranking->groups is used.\n*      ranking->groups - integer array of dimension (n-k) used to partition\n*\t                 ranking->prio into blocks of knots with the same\n*                        ranking number. ranking->groups[0] contains the\n*\t\t\t number of knots with the smallest ranking number,\n*                        ranking->groups[1] contains the number of knots with\n*                        the two smallest ranking numbers etc.. Only the first\n*                        ranking->antgr elements of ranking->groups are used.\n*       ranking->antgr - the number of distinct ranking numbers among the\n*                        interior knots of t.\n*      ranking->antrem - an estimate of the number of knots that can be\n*                        removed from curve.\n*\n*           stat       - status message\n*                           > 0      : warning\n*                           = 0      : ok\n*                           < 0      : error\n*\n*\n*\n* Method:\n*      The ranking strategy is described in the two references.\n*      somewhat simplified, the computation of the ranking number of knot\n*      number i consists of computing the error in the best approximation to\n*      the input spline from a subspace where this knot has been removed,\n*      and then finding in which of the intervals [0,eps/2], (eps/2,eps],\n*      (2*eps,4*eps],... , the error lies. This interval number is then\n*      the ranking number of the knot.\n*      The best approximation is computed in a certain discrete max-norm,\n*      and this leads to well conditioned linear systems.\n*\n*      NB! It is assumed that the first and lasty knots occur with\n*      multiplicity k.\n*\n*      NB! The code is unreadable without close study of the two references.\n*\n*\n* References:\n*      1. A Data-Reduction Strategy for Splines with Applications to the\n*         Approximation of Functions and data, IMA J. of Num. Anal. 8 (1988),\n*         pp. 185-208.\n*\n*      2. Knot Removal for Parametric B-spline Curves and Surfaces,\n*         CAGD 4 (1987), pp. 217-230.\n*\n*\n* Written by: Knut Moerken, University of Oslo, July 1992, based on an\n*              earlier Fortran version by the same author.\n*\n*********************************************************************\n*/\n{\n  int k = curve->ik;            /* The basic parameters of curve will be */\n  int dim = curve->idim;        /* used extensively and are therefore    */\n  int n = curve->in;            /* extracted and stored in local         */\n  double *et = curve->et;       /* variables.                            */\n  double *ecoef = curve->ecoef;\n  int *prio = ranking->prio;    /* Local versions of the ranking arrays. */\n  int *groups = ranking->groups;\n  int antgr;                    /* The two integers of ranking.          */\n  int antrem;\n  int pos=0;                    /* Integer used by s6err.                */\n                                /* The routine requires a large number of\n\t\t\t\t   integers and floats, see the code.    */\n  int i, ii, i2, inxt, mult, dm, j1, j2, nkt, dih, dj, dj1, hmult,\n      p, dp, di2, j, count, di, iw, ph, gh;\n  double h, x, pm1h, pm1, muj1, muj, mm, h1, h2, denom, ln2inv;\n  double *c, *hh, *mu, *w, *e, *s;\n\n  /* We start by allocating space for local arrays. */\n\n  /* c will contain the right-hand-sides in the linear systems that\n     are going to be solved. */\n\n  c = newarray(dim*(k+1), double);\n  if (c == SISL_NULL) goto err101;\n\n  /* hh will contain the last column of the coefficient matrix during\n     elimination. */\n\n  hh = newarray(k+1, double);\n  if (hh == SISL_NULL) goto err101;\n\n  /* mu will contain one of the two diagonals of the coefficient matrix. */\n\n  mu = newarray(k+1, double);\n  if (mu == SISL_NULL) goto err101;\n\n  /* w will contain the weights of the interior knots (of type double). */\n\n  w = newarray(dim*(n-k), double);\n  if (w == SISL_NULL) goto err101;\n\n  /* e and s are auxialiary arrays. */\n\n  e = newarray(dim, double);\n  if (e == SISL_NULL) goto err101;\n\n  s = newarray(dim, double);\n  if (s == SISL_NULL) goto err101;\n\n  /* Start the computation of the weights. We first compute real (not integer)\n     weights, w. The weight of a knot is computed by removing it and computing\n     a best approximation without the knot. The weight is the error in this\n     approximation. The norm used is the max-norm of the B-spline coefficients\n     on the original knot vector et. */\n\n  /* The integer i points to the previous knot that was removed, while\n     dih points to the location in w where the next weight is to be stored.\n     nkt gives the number of interior knots and therefore the number of\n     weights to be computed (the number of weights is nkt*dim).\n     We clearly have to loop until i=n-1 (remember that we assumed the first\n     and last knots to occur with multiplicity k). */\n\n  i = k - 1; dih = 0; nkt = n - k;\n\n  while (i < n-1)\n    {\n\n      /* The knot that we want to compute a weight for now is x=et[i+1].\n\t inxt will point to the smallest knot distinct from x. */\n\n      inxt = i + 1; x = et[inxt];\n      while (x == et[inxt+1]) ++inxt;\n\n      /* mult is the multiplicity of x, while dm is the dimension of\n\t the linear system we are going to solve, see reference 1. */\n\n      mult = inxt - i; dm = k - mult + 2;\n\n      /* Set up the linear system of equations. The first dm-1 unknowns\n         are the coefficients of the spline approximation that are different\n\t from the coefficients of curve while the last unknown is the\n\t error in the approximation. */\n\n      /* pm1h is the first entry in last column of the coefficient matrix. */\n\n\t       pm1h = 1.0;\n      if ( fmod((float) dm, (float) 2.0) == 0 )  pm1h = -1.0;\n\n      /* The integer j is used to step through the equations during\n\t elimination, while muj is used to hold the mu of equation j\n\t in ref. 1. The array mu (and muj1) will be used for storing\n\t the inverse of muj, while mm is the factor that the previous\n\t (or next0 equation is multiplied with to eliminate one variable.\n\t hh is used for keeping track of the last column of the coefficient\n\t matrix during elimination, while j1 and j2 are pointers to knots\n\t in et that are needed for computing muj. dj1 is a pointer to the\n\t B-spline coefficient that occurs on the right-hand-side\n\t of the equation (really dim right-hand-sides), while dj\n         is a pointer to the right-hand-side after elimination\n\t (i2 is always dim behind (or ahead of) dj.) */\n\n      muj1 = 1.0; mu[0] = 1.0;\n      j1 = inxt - k + 1; dj1 = dim*j1;\n      j2 = inxt + 1;\n      hh[0] = pm1 = pm1h;\n\n      di2 = (j1-1)*dim;\n\n      for (ii = 0; ii < dim; ++ii, ++di2) c[ii] = ecoef[di2];\n\n      j = 1; dj = dim;\n      i2 = 0; di2 = 0;\n\n      /* Eliminate from the top until muj1 becomes larger than 2\n\t (see ref. 1). */\n\n      while (muj1 <= 2 && j < dm - 1)\n\t{\n\t  h = et[j1];\n\n\t  /* The two conditions tested here correspond to a singular system\n\t     which can only occur with a buggy knot vector. */\n\n\t  if (h == et[j2] || x == h) goto err112;\n\t  muj = (x-h) / (et[j2]-h);\n\t  mm = (1-muj) * muj1;\n\t  mu[j] = muj1 = 1 / muj;\n\t  pm1 = -pm1;\n\t  hh[j] = pm1 - mm*hh[i2];\n\t  for (ii=0; ii<dim; ++ii, ++dj, ++dj1, ++di2)\n\t    c[dj] = ecoef[dj1] - mm*c[di2];\n\n\t  i2 = j; ++j; ++j1; ++j2;\n\t}\n\n      /* Now we remember how far down we managed to eliminate in p and prepare\n\t to eliminate from the last equation to p+1. The variables have the\n\t same interpretations as before except for the obvious changes since\n\t we are eliminating upwards from the bottom and not dowmwards from\n\t the top. */\n\n      p = i2;\n\n      /* Initialize variables as above. */\n\n      j1 = i; dj1 = dim*(j1+1)-1;\n      j2 = j1 + k;\n      i2 = j1 + 1; di2 = dim*(i2+1) - 1;\n      pm1 = 1;\n      hh[dm-1] = 1.0;\n      dj = dim*dm - 1;\n\n      for (ii=0; ii<dim; ++ii, --dj, --di2) c[dj] = ecoef[di2];\n\n      muj1 = mu[dm-1] = 1.0;\n      i2 = dm - 1; di2 = dim*dm - 1;\n\n      /* Eliminate. */\n\n      for (j=dm-2; j>p; --j)\n\t{\n\t  h = et[j2];\n\t  if (h == x || h == et[j1]) goto err112;\n\t  muj = (h-x) / (h-et[j1]);\n\t  mm = (1-muj)*muj1;\n\t  muj1 = 1/muj;\n\t  mu[j] = muj1;\n\t  pm1 = -pm1;\n\t  hh[j] = pm1 - mm*hh[i2];\n\t  for (ii=0; ii<dim; ++ii, --dj, --dj1, --di2)\n\t    c[dj] = ecoef[dj1] - mm*c[di2];\n\n\t  i2 = j; --j1; --j2;\n\t}\n\n      /* Now we are left with two equations (no. p and p+1) in two unknowns\n\t (one B-spline coefficient and the error in the approximation) which\n\t we solve the standard way. The weight is then obtained by taking\n\t the absolute value of the error. */\n\n      h1 = mu[i2]; h2 = mu[p];\n      denom = 1/(h1*hh[i2]-h2*hh[p]);\n      dp = dim*p; di2 = dim*i2;\n      for (ii=0; ii<dim; ++ii, ++di2, ++dp, ++dih)\n\t{\n\t  h = e[ii] = (h1*c[di2] - h2*c[dp])*denom;\n\t  w[dih] = fabs(h);\n\t}\n\n      /* We now determine the weights of the remaining knots at x. */\n\n      count = 1;\n\n      for (hmult=mult-1; hmult>0; --hmult)\n\t{\n\n\t  /* First do the back substitution of the system used to determine\n             the previous weight. In this way the nontrivial B-spline\n\t     coefficients of the spline that best approximates the given\n\t     spline curve but without the knot x, is determined.\n             The weight of the next knot at x is obtained by solving a\n             linear system of the same sort as the one above, but based on\n\t     this new spline instead. In this way a weight for the new\n\t     spline is found; the weight of this knot with respect to the\n\t     original spline is then set equal to this weight plus the\n\t     weight of the previous spline (at this knot). */\n\n\t  /* Substitute to the end. */\n\n\t  i2 = i + count; dj = dim*(p+1);\n\t  for (j=p+1; j<dm; ++j)\n\t    {\n\t      h1 = hh[j]; h2 = mu[j];\n\t      for (ii=0; ii<dim; ++ii, ++dj)\n\t\tc[dj] = (c[dj] - h1*e[ii])*h2;\n\t    }\n\n\t  /* Substitute to the beginning. */\n\n\t  dj1 = dim*(p+1) - 1; dj = dj1 - dim;\n\t  for (j=p-1; j>=0; --j)\n\t    {\n\t      h1 = hh[j]; h2 = mu[j];\n\t      for (ii=dim-1; ii>-1; --ii, --dj, --dj1)\n\t\t{\n\t\t  c[dj1] = (c[dj] - h1*e[ii])*h2;\n\t\t}\n\t    }\n\n\t  /* Set up the new system of equations. The dimension will be\n\t     one greater than the previous one and the system is based\n\t     on the spline that was just computed so that the multiplicity\n\t     of x has been reduced by one. */\n\n\t  /* The variables have the same interpretations as above. */\n\t  ++count; ++dm;\n\t  pm1h = -pm1h;\n\t  pm1 = hh[0] = pm1h;\n\t  j1 = i + hmult - k + 1;\n\t  j2 = inxt + 1;\n\t  i2 = j1 - 1; di2 = dim*i2;\n\t  muj1 = 1.0;\n\n\t  for (ii=0; ii<dim; ++ii, ++di2) c[ii] = ecoef[di2];\n\n\n\t  j = 1; dj = dim;\n\t  i2 = 0; di2 = 0;\n\n\t  /* Eliminate unknowns until muj1 becomes greater than 2. */\n\n\t  while (muj1 <= 2 && j < dm - 1)\n\t    {\n\t      h = et[j1];\n\t      if (h == et[j2] || x == h) goto err112;\n\t      muj = (x-h) / (et[j2]-h);\n\t      mm = (1-muj) * muj1;\n\t      mu[j] = muj1 = 1 / muj;\n\t      pm1 = -pm1;\n\t      hh[j] = pm1 - mm*hh[i2];\n\t      for (ii=0; ii<dim; ++ii, ++dj, ++di2)\n\t\tc[dj] = c[dj] - mm*c[di2];\n\n\t      i2 = j; ++j; ++j1; ++j2;\n\n\t    }\n\n\t  /* Remember where we have are. */\n\n\t  p = i2;\n\n\t  /* Prepare elimination from the end up to p. */\n\n\t  j1 = i; dj1 = dim*(j1+1) - 1;\n\t  j2 = j1 + k + count - 1;\n\t  i2 = i + count; di2 = dim*(i2+1) - 1;\n\t  pm1 = 1;\n\t  hh[dm-1] = 1.0;\n\t  dj = dim*dm - 1;\n\n\t  for (ii=0; ii<dim; ++ii, --dj, --di2) c[dj] = ecoef[di2];\n\n\n\t  muj1 = mu[dm-1] = 1.0;\n\t  i2 = dm - 1; di2 = dim*dm - 1;\n\n\t  /* Eliminate from the end. */\n\t  for (j=dm-2; j>p; --j)\n\t    {\n\t      h = et[j2];\n\t      if (h == x || h == et[j1]) goto err112;\n\t      muj = (h-x) / (h-et[j1]);\n\t      mm = (1-muj)*muj1;\n\t      muj1 = 1/muj;\n\t      mu[j] = muj1;\n\t      pm1 = -pm1;\n\t      hh[j] = pm1 - mm*hh[i2];\n\t      for (ii=0; ii<dim; ++ii, --dj, --di2)\n\t\tc[dj] = c[dj] - mm*c[di2];\n\n\t      i2 = j; --j1; --j2;\n\t    }\n\n\t  /* Solve the two equations in two unknowns and determine w\n\t     by adding the absolute value of the current error to the\n\t     previous weight. */\n\n\t  h1 = mu[i2]; h2 = mu[p];\n\t  denom = 1/(h1*hh[i2]-h2*hh[p]);\n\t  dp = dim*p; di2 = dim*i2;\n\t  for (ii=0; ii<dim; ++ii, ++di2, ++dp, ++dih)\n\t    {\n\t      h = e[ii] = (h1*c[di2] - h2*c[dp])*denom;\n\t      w[dih] = w[dih-dim] + fabs(h);\n\t    }\n\t}\n\n      /* Go to the next distinct knot. */\n\n      i = inxt;\n\n    }\n\n  /* We now have the information that is needed for computing the\n     ranking numbers, see refs. 1 and 2. */\n\n  /* We start by computing the inverse of eps/2 (careful if eps is small). */\n\n  for (ii=0; ii<dim; ++ii)\n    s[ii] = 2.0/MAX(eps[ii],1.0e-300);\n\n  /* We need the constant 1/logarithm(2). */\n\n  ln2inv = 1.0 / log((double) 2.0);\n  di = 0;\n\n  /* Since all the weights are nonnegative, each of them must fall in one\n     of the intervals [0,eps/2), [eps/2, eps), [eps, 2eps), [2eps, 4eps), ...\n     If we number these intervals from 0, then the ranking number of a knot\n     is the number of the interval that contains its weight. For a parametic\n     curve we choose the ranking number to be the largest of the ranking\n     numbers of the dim components. The ranking numbers are stored in\n     the array groups. */\n\n  for (i=0; i<nkt; ++i)\n    {\n      iw = 0;\n      for (ii=0; ii<dim; ++ii, ++di)\n\t{\n\t  h = w[di];\n\t  if (h > 0.5*eps[ii])\n\t    iw = MAX(iw, (int)floor(log(h*s[ii])*ln2inv+1));\n\t}\n      groups[i] = iw;\n    }\n\n  /* We next sort the ranking numbers in increasing order. Since each ranking\n     number belongs to a specific knot, this induces an ordering of the knots.\n     This ordering is stored in prio. Note that if two knots have the same\n     ranking they are listed in prio in the order that they occur in et. */\n\n  for (i=0; i<nkt; ++i) prio[i]=i;\n\n  for (i=1; i<nkt; ++i)\n    {\n      gh = groups[i]; ph = prio[i];\n\n      for (j=i-1; gh < groups[j];)\n\t{\n\t  groups[j+1] = groups[j];\n\t  prio[j+1] = prio[j];\n\t  --j;\n\t  if (j <0) goto out;\n\t}\n\n    out:\n      groups[j+1] = gh; prio[j+1] = ph;\n    }\n\n  /* We next prepare for estimating how many knots that can be removed (very\n     heuristic and not important for the perfomance of the knot removal. */\n\n  if (groups[0] == 0) antrem = 0;\n    else\n      antrem = -1;\n\n  /* The array groups should end up with the cumulative number of knots in\n     each interval. */\n\n  j = 0;\n  for (i=0; i<nkt-1; ++i)\n    if (groups[i] < groups[i+1])\n      {\n\tgroups[j] = i+1; ++j;\n      }\n\n  antgr = ++j;\n  groups[antgr-1] = n - k;\n\n  /* More guessing about antrem. */\n\n  if (antrem == 0)\n    {\n      if (antgr > 1)\n\tantrem = (int)(0.75*groups[1]/(antgr-1));\n      else\n\tantrem = (int)(0.9*groups[0]);\n    }\n  else\n    antrem = 1;\n\n  antrem = MAX(MIN(1, nkt), antrem);\n\n  /* Finish of ranking. */\n\n  ranking->antgr = antgr;\n  ranking->antrem = antrem;\n\n\n\n  /* Free memory. */\n\n  freearray(hh);\n  freearray(c);\n  freearray(mu);\n  freearray(w);\n  freearray(e);\n  freearray(s);\n\n  /* Successful computations. */\n\n  return;\n\n  /* Error in allocation of memory. */\n\n err101:\n  *stat = -101;\n  s6err(\"s1353\", *stat, pos);\n  goto err;\n\n  /* Error in knot vector (singular system of equations). */\n\n err112:\n  *stat = -112;\n  s6err(\"s1353\", *stat, pos);\n  goto err;\n\n  /* Clean up. */\n\n err:\n  if (c != SISL_NULL) freearray(c);\n  if (hh != SISL_NULL) freearray(hh);\n  if (mu != SISL_NULL) freearray(mu);\n  if (w != SISL_NULL) freearray(w);\n  if (e != SISL_NULL) freearray(e);\n  if (s != SISL_NULL) freearray(s);\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s1354.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1354.c,v 1.3 2001-03-19 15:58:46 afr Exp $\n *\n */\n\n#define S1354\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1354(SISLCurve *oldcurve,SISLCurve *rankcurve,rank_info *ranking,\n\t   double eps[],double epsco[],int startfix,int endfix,int mini,\n\t   int maxi,SISLCurve **newcurve,double maxerr[],int *stat)\n#else\nvoid s1354(oldcurve, rankcurve, ranking, eps, epsco,\n\t   startfix, endfix, mini, maxi, newcurve, maxerr, stat)\n     SISLCurve\t*oldcurve;\n     SISLCurve\t*rankcurve;\n     rank_info\t*ranking;\n     double\teps[];\n     double\tepsco[];\n     int\tstartfix;\n     int\tendfix;\n     int\tmini;\n     int\tmaxi;\n     SISLCurve\t**newcurve;\n     double\tmaxerr[];\n     int\t*stat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* Purpose: To remove as many knots as possible from oldcurve\n*          without perturbing this spline more than eps, using the ranking\n*          information in rank_info which was obtained from the spline\n*          rankcurve; and compute an approximation to oldcurve on the\n*          knot vector of rankcurve. The knot vector of rankcurve must be\n*          a subsequence of the knot vector of oldcurve and the knots are\n*          always removed from rankcurve so that the final reduced knot\n*          vector will always be a subsequence of both the knot vectors of\n*          oldcurve and rankcurve. The final approximation is given in\n*\t   newcurve.\n*\n*\n*\n*\n* Input:\n*          oldcurve    - pointer to the original spline from which the knots\n*\t\t\t are to be removed.\n*\n*          rankcurve   - pointer to the curve that the ranking information\n*                        is based on. It is assumed the knot vector of\n*                        rankcurve is a subsequence of the knot vector of\n*\t\t\t oldcurve.\n*\n*\t   ranking     - a pointer to a rank_info object containing the\n*                        result of the ranking computations. The struct\n*                        rank_info contains four variables listed below\n*                        (t, k, and n refer to the knot vector of rankcurve,\n*                        its polynomial order and the number of B-spline\n*                        coefficients):\n*        ranking->prio - integer array of dimension (n-k) containing the\n*                        ranking of the interior knots. The knots are listed\n*                        in order of increasing ranking number, cf. the\n*                        second reference, with knots with the same ranking\n*                        number listed in the order in which they occur\n*                        in t. To differentiate between the different\n*                        ranking numbers the array ranking->groups is used.\n*      ranking->groups - integer array of dimension (n-k) used to partition\n*                        ranking->prio into blocks of knots with the same\n*                        ranking number. ranking->groups[0] contains the\n*                        number of knots with the smallest ranking number,\n*                        ranking->groups[1] contains the number of knots with\n*                        the two smallest ranking numbers etc.. Only the first\n*                        ranking->antgr elements of ranking->groups are used.\n*       ranking->antgr - the number of distinct ranking numbers among the\n*                        interior knots of t.\n*      ranking->antrem - an estimate of the number of knots that can be\n*                        removed from curve.\n*\n*          eps         - double array containing the tolerance. The\n*\t\t\t approximation must at each parameter value deviate\n*\t\t\t less than eps from oldcurve (in each component).\n*\n*\t   epsco       - double array of containing a tolerance which\n*                        is used when the number of coefficients in the\n*                        approximating spline becomes very small. More\n*                        specifically, if so many knots are removed that\n*                        the corresponding spline approximation has fewer\n*                        knots than startfix+endfix (the total number of\n*                        constraints), then it is required that the error\n*                        is less than epsco in each component.\n*\n*          startfix    - the number of derivatives to be kept fixed at the\n*\t\t\t left end of the parameter interval.\n*\n*          endfix      - the number of derivatives to be kept fixed at the\n*\t\t\t right end of the parameter interval.\n*\n*          mini        - a lower bound on how many knots that can be removed.\n*\n*          maxi        - an upper bound on how many knots that can be removed.\n*\n*\n* Output:\n*          newcurve    - pointer to the spline approximation on the reduced\n*\t\t\t knot vector.\n*          maxerr      - double array containing an upper bound for the\n*                        pointwise error in each of the components of the\n*                        spline approximation. The two curves oldcurve and\n*\t\t\t newcurve are compared at the same parameter value,\n*                        i.e., if oldcurve is f and newcurve is g, then\n*\t\t\t               |f(t)-g(t)| <= eps\n*\t\t\t in each of the components.\n*\n*           stat       - status message\n*                           > 0      : warning\n*                           = 0      : ok\n*                           < 0      : error\n*\n*\n* Method:\n*     The routine determines the maximum number of knots that can be removed\n*     by binary search starting by removing ranking->antrem (antrem below)\n*     knots. In other words, it first tries to remove antrem knots from\n*     oldcurve. If this gives an error less than the tolerance, it tries\n*     to remove (antrem+maxi)/2 knots, while if the error is greater than\n*     the tolerance, the routine will try to remove (mini+antrem)/2 of the\n*     knots. This is continued until the number of knots that can be removed\n*     has been determined exactly, together with the corresponding\n*     approximation. The acceptable approximation with the fewest knots is\n*     kept in the variables igtau,igc,ign, and this is\n*     initialized to the spline given by etprio,edprio,imprio.\n*\n*     During each iteration it must be determined which knots to remove,\n*     given the number of knots to remove. The basis for this choice is\n*     the ranking information (below groups and prio denote the arrays\n*     ranking->groups and ranking->prio and t and k denote the knot vector\n*     and order of rankcurve). Suppose we are to remove r knots.\n*     First the smallest integer i satisying groups(i) >= r is determined.\n*     In prio all the interior knots of t are listed (or rather their\n*     index in t, t[k-1+5] has index 5), and since we are to remove\n*     all knots in the first ranking groups, we remove the first groups[i-1]\n*     knots of prio (assuming for simplicity that groups[-1]=0).\n*     In the last group we reach into (which consists of knots no.\n*     prio[groups[i-1]+1], prio[groups[i-1]+2],...,prio[groups[i]])\n*     knots are removed uniformly on index, meaning that if we are to remove\n*     half the knots in this group, we pick every other knot as they are\n*     listed in prio, if we are to remove 1/3 of the knots, we remove every\n*     three knots and so on. In general, it is difficult to say what\n*     uniformly on subscripts should mean (how do you choose one knot from\n*     six in a symmetric way) but the approach used here seems to work\n*     reasonably well (see the program text below).\n*     When it is known which knots to remove, the corresponding knot vector\n*     can be constructed and an approximation computed.\n*     the error is then checked as indicated above, and the iterations proceed.\n*\n*     For more information cf. the references:\n*\n*\n* References:\n*      1. A Data-Reduction Strategy for Splines with Applications to the\n*         Approximation of Functions and data, IMA J. of Num. Anal. 8 (1988),\n*         pp. 185-208.\n*\n*      2. Knot Removal for Parametric B-spline Curves and Surfaces,\n*         CAGD 4 (1987), pp. 217-230.\n*\n*\n* Calls: sh1365, s6err\n*\n* Written by : Knut Moerken, University of Oslo, July 1992, based on an\n*              earlier Fortran version.\n* Changed by: Paal Fugelli, SINTEF, 1994-07.\n*             Changed to fix several major memory leakage problems.\n*\n*********************************************************************\n*/\n{\n  int k = oldcurve->ik;           /* Make some parameters more easily */\n  int dim = oldcurve->idim;       /* accessible. */\n  int mprio = rankcurve->in;\n  int *prio = ranking->prio;\n  int *group = ranking->groups;\n  int antrem = ranking->antrem;\n  int antgr = ranking->antgr;\n  char *del_array;                /* Boolean array that is used for\n                                     marking what knots to include.   */\n  char big, bigco;                /* Boolean variables that are used\n                                     for checking whether the error\n\t\t\t\t     is small enough.                 */\n  int lstat=0;\t\t\t  /* Local status variable.           */\n  int pos=0;\t\t\t  /* Parameter to s6err.              */\n  int nlim = MAX(k, startfix+endfix); /* The minimum number of B-spline\n\t\t\t\t\t coefficients that should be\n\t\t\t\t\t left in newcurve.            */\n\n\t\t\t\t/* For the use of the other variables,\n\t\t\t\t   see the code below.              */\n  int i, start, stop, indx, count, r, p, hn;\n  SISLCurve *hcurve = SISL_NULL;\n  double h;\n  double *local_err = SISL_NULL, *l2_err = SISL_NULL, *ltau = SISL_NULL;\n\n  /* Allocate memory for the local arrays. */\n\n  del_array = newarray(mprio-k, char);\n  if (del_array == SISL_NULL) goto err101;\n\n  /* In case we do not enter the while loop at all we must give newcurve\n     a value. */\n\n  *newcurve = newCurve(mprio, k, rankcurve->et, rankcurve->ecoef, 1, dim, 1);\n  if (newcurve == SISL_NULL) goto err101;\n\n  /* Iterate by binary search until the lower and upper bound on how many\n     knots to include are essentially equal. */\n\n  while (mini+1 < maxi)\n  {\n\n    /* To start with none of the knots of rankspline are marked\n       for removal. */\n\n    for (i=0; i<mprio-k; i++) del_array[i] = 0;\n\n    /* We then have to find out which knots to remove. We remove knots\n       group by group, with start pointing (into prio) to the first knot\n       of the current group and stop to the one following the last of this\n       group. */\n\n    start = 0;\n    stop = group[0];\n    count = 0;\n\n    /* We remove all knots of each group and mark them in del_array\n       until this would mean that we have removed too many. */\n\n    while (stop <= antrem)\n    {\n      for (i=start; i<stop; i++) del_array[prio[i]] = 1;\n\n      count++;\n\n      if (count < antgr)\n      {\n\tstart = stop;\n\tstop = group[count];\n      }\n      else\n      {\n\n\t/* start=stop signifies that we have reached the end. */\n\n\tstop = stop + 1;\n\tstart = stop + 1;\n      }\n    }\n\n    /* Now there are p more knots to remove from a group containing\n       p knots. These p knots are removed \"uniformly on index\". */\n\n    r = stop - start;\n    p = antrem - start;\n\n    if (p > 0)\n    {\n      h = (double) (r+1) / (double) p;\n      for (i=0; i<p; i++)\n      {\n\tindx = start - 1 + (int) floor( h*(i+0.5)+0.5 );\n\tdel_array[prio[indx]] = 1;\n      }\n    }\n\n    /* Gives the number of coefficients in the new spline to be computed. */\n\n    hn = mprio - antrem ;\n\n    /* The new knot vector is stored in ltau.  It might already be allocated\n       from the last iteration, so free it first if required. */\n\n    if (ltau != SISL_NULL) freearray(ltau);\n    ltau = newarray(hn+k, double);\n    if (ltau == SISL_NULL) goto err101;\n\n    /* Set the first and last k knots. */\n\n    for (i=0; i<k; i++)\n    {\n      ltau[i] = rankcurve->et[i];\n      ltau[i+hn] = rankcurve->et[i+mprio];\n    }\n\n    /* Set the remaining knots as indicated by del_array. */\n\n    for (indx=k, i=0; i<mprio-k; i++)\n      if (!del_array[i]) ltau[indx++] = rankcurve->et[i+k];\n\n    /* Compute an approximation on the new knot vector and store it\n       in hcurve.\n       sh1365() will allocate space for hcurve (with icopy==1), local_err\n       and l2_err.\n       Need local_err to store the error of the approximation until we know\n       that we have an approximation with error smaller than the tolerance,\n       then we can transfer the error to maxerr.\n       Must remember to free local_err and l2_err since there will be\n       a memory leak if they were allocated in the previous iteration. */\n\n    if (local_err != SISL_NULL) freearray(local_err);\n    if (l2_err != SISL_NULL) freearray(l2_err);\n\n    sh1365(oldcurve, ltau, k, hn, startfix, endfix,\n\t   &hcurve, &local_err, &l2_err, &lstat);\n    if (lstat < 0) goto err;\n\n    /* Check the error. big signifies that the error in one of the\n       components is larger than the tolerance. bigco signifies that\n       the error in one of the components is larger than the (usually\n       much smaller) tolerance epsco. */\n    big = 0;\n    bigco = 0;\n\n    for (i=0; i<dim; i++)\n    {\n      big = big || (local_err[i] > eps[i]);\n      bigco = bigco || (local_err[i] > epsco[i]);\n    }\n\n    /* The error is too large if it is big or if it is bigco and the\n       number of coefficients is smaller than nlim. The latter test is\n       important when the sum of the number of derivatives to be kept\n       fixed at the two ends is larger than k. */\n\n    big = big || (bigco && hn < nlim);\n\n    if (big)\n    {\n\n      /* If the error was too big, we just throw away hcurve and\n\t indicate that an upper bound for the number of knots to\n\t remove is antrem. */\n\n      if (hcurve != SISL_NULL) freeCurve(hcurve);\n      hcurve = SISL_NULL;\n      maxi = antrem;\n    }\n    else\n    {\n\n      /* If the error is acceptable we know that we can remove at least\n\t antrem knots and store hcurve in newcurve. We also save the\n\t error in maxerr. */\n\n      mini = antrem;\n      if (*newcurve != SISL_NULL) freeCurve(*newcurve);\n      *newcurve = hcurve;\n      hcurve = SISL_NULL;\n      for (i=0; i<dim; i++)  maxerr[i] = local_err[i];\n    }\n\n    /* The number of knots to be removed next time is half way between\n       mini and maxi. */\n\n    antrem = mini + (maxi-mini)/2;\n  }\n\n  *stat = 0;\n\n  goto out;\n\n\n\n  /* Error in memory allocation. */\n\nerr101:\n  *stat = -101;\n  goto out;\n\n  /* Error in lower level routine. */\n\nerr:\n  *stat = lstat;\n  s6err(\"s1354\", *stat, pos);\n\n  /* Clean up before exit. */\n\nout:\n  if (hcurve != SISL_NULL) freeCurve(hcurve);\n  if (del_array != SISL_NULL) freearray(del_array);\n  if (local_err != SISL_NULL) freearray(local_err);\n  if (l2_err != SISL_NULL) freearray(l2_err);\n  if (ltau != SISL_NULL) freearray(ltau);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1355.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1355.c,v 1.3 2001-03-19 15:58:47 afr Exp $\n *\n */\n\n#define S1355\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1355(SISLCurve *pc,double eeps[],double **epar,\n\t   int *im, int *jstat)\n#else\nvoid s1355(pc,eeps,epar,im,jstat)\n     SISLCurve  *pc;\n     double eeps[];\n     double **epar;\n     int *im;\n     int    *jstat;\n#endif\n/*\n***********************************************************\n*\n* Purpose: To determine a set of sampling points on a given spline\n*          curve such that the error in the cubic hermite spline\n*          interpolant will be smaller than a given tolerance.\n*\n* Input :\n*         Pc     - Pointer to spline curve.\n*         Eeps   - Array (length kdim) giving the desired accuracy of\n*                  the hermite interpolant in each component.\n*\n* Output:\n*         Epar   - Array of dimension im containing the parametervalues\n*                  of the desired sampling points.\n*         Im     - Number of sampling points.\n*         Jstat  - Output status:\n*                   < 0 : Error.\n*                   = 0 : Ok.\n*                   > 0 : Warning:\n*\n* Method:\n*\n* Calls: s1707, s1720, s6err\n*\n* Written by: C.R. Birkeland, Si, April 1993.\n* Changed by: Per OEyvind, SINTEF, 1994-11.\n*             Added input check for invalid Eeps values.\n**********************************************************\n*/\n{\n  int i,j,k;               /* Loop control variables                       */\n  int number = 0;\n  int idim = pc->idim;     /* Space-dimension                              */\n  int ik, in;              /* Order and number of vertices                 */\n  int stat = 0;            /* Error control variables                      */\n  int kpos = 0;\n  int multi = 0;           /* Used to study multiplicity of original curve */\n  int parlen;\n  int help;\n  double end, start;       /* Used to determine sampling point parameters  */\n  double maxstep;\n  double *coeff;           /* Only used as pointer to curve coefficients   */\n  double *et = SISL_NULL;       /* Pointer to knotvector                        */\n  double *par = SISL_NULL;      /* Storage of SISL-curve parameters             */\n  double *maxtab = SISL_NULL;\n  double *neweps = SISL_NULL;\n  SISLCurve *oc=SISL_NULL;      /* Local SISL-curve                             */\n\n  /* Check input-curve. */\n\n  if (!pc) goto err150;\n  s1707(pc, &stat);\n  if (stat<0) goto error;\n\n  /* Check other input */\n\n  if (pc->in < pc->ik || pc->ik < 1 || idim < 1) goto err103;\n\n  /* Find 4'th derivative of spline pc used in error estimate */\n\n  s1720( pc, 4, &oc, &stat);\n  if (stat<0) goto error;\n\n  /* Initialize */\n\n  ik = oc->ik;\n  in = oc->in;\n  et = oc->et;\n  coeff = oc->ecoef;\n\n  /* Allocate matrices */\n\n  parlen = ik*in;\n  par    = newarray(parlen, DOUBLE);\n  maxtab = newarray(idim, DOUBLE);\n  neweps = newarray(idim, DOUBLE);\n  if (maxtab == SISL_NULL || par == SISL_NULL || neweps == SISL_NULL) goto err101;\n\n  /* Do calculations here which may be done outside main loop */\n\n  for(i=0; i<idim; i++)\n    neweps[i] = eeps[i] * 384 / 5. ;\n\n  /* Main loop */\n\n  number = 0;\n  multi = 0;\n  for(help=0; help<in-ik+1; help++)\n    {\n      start = et[ik+help-1];\n      end = et[ik+help];\n\n      /* Find largest coefficient in each direction\n       * to determine largest possible 4'th derivative\n       * in interval et[start], et[end]                 */\n\n      /* Set maxtab to zero */\n\n      for(i=0; i<idim; i++)\n\tmaxtab[i] = 0.;\n      for(i=help*idim, k=0; k<ik-1; i+=idim, k++)\n\tfor(j=0; j<idim; j++)\n\t  maxtab[j] = MAX( maxtab[j], fabs(coeff[i+j]) );\n\n      /* Find maximum interval between two parametervalues,\n       * in interval [ et(start), et(end) ].\n       * Minimum step (Set a little bit larger than 'end - start' */\n\n      maxstep = 1.1*end-start;\n      for(i=0; i<idim; i++)\n\t{\n\t  if( maxtab[i] > 0. )\n\t    maxstep = MIN( neweps[i]/maxtab[i], maxstep );\n\t}\n      maxstep = pow(maxstep, 0.25);\n\n      /* Validate maxstep (and thus eeps) */\n\n      if (DEQUAL(maxstep, 0.0))\n        goto err103;\n\n      /* Max. distance between parametervalues in interval\n       * [start, end] must not exceed maxstep.\n       * Generate the necessary parametervalues            */\n\n      while(start<end)\n\t{\n\t  par[number] = start;\n\t  start += maxstep;\n\t  number++;\n\n\t  /* Make sure array for parametervalues is large enough */\n\n\t  if (number+1>=parlen)\n\t    {\n\t      parlen = 2*parlen;\n\t      if ((par = increasearray(par, parlen, double)) == SISL_NULL)\n\t\tgoto err101;\n            }\n\t}\n\n      /* Test for multiple knots in original knotvector */\n\n      if(end == start)\n\t{\n\t  /* Check if knotmultiplicity is  'pc->ik - 1' */\n\n\t  if(multi == pc->ik - 3)\n\t    {\n\t      par[number] = start;\n\t      number++;\n\t      multi=0;\n\t    }\n\t  else\n\t    multi++;\n\t}\n      else\n\tmulti = 0;\n    }\n\n  par[number] = end;\n  if ((par = increasearray(par,number+1,DOUBLE)) == SISL_NULL) goto err101;\n  *epar = par;\n  *im = number+1;\n\n  /* Success ! */\n\n  *jstat = 0;\n  goto out;\n\n  /* Allocation error. */\n\n err101:\n   *jstat = -101;\n   s6err(\"s1355\",*jstat,kpos);\n   goto out;\n\n  /* Error in input */\n\n  err103:\n    *jstat = -103;\n    s6err(\"s1355\",*jstat,kpos);\n    goto out;\n\n  /* Empty curve. */\n\n  err150:\n    *jstat = -150;\n    s6err(\"s1355\",*jstat,kpos);\n    goto out;\n\n  /* Error in lower level routine. */\n\n  error:\n    *jstat = stat;\n    s6err(\"s1355\",*jstat,kpos);\n    goto out;\n\n  /* Exit */\n\n  out:\n    if( maxtab != SISL_NULL) freearray(maxtab);\n    if( neweps != SISL_NULL) freearray(neweps);\n    if( oc != SISL_NULL) freeCurve(oc);\n    return;\n}\n"
  },
  {
    "path": "src/s1356.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1356\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   s1356(double epoint[],int inbpnt,int idim,int nptyp[],\n      int icnsta,int icnend,int iopen,int ik,double astpar,\n      double *cendpar,SISLCurve **rc,double **gpar,int *jnbpar,int *jstat)\n#else\nvoid s1356(epoint,inbpnt,idim,nptyp,icnsta,icnend,iopen,ik,astpar,\n           cendpar,rc,gpar,jnbpar,jstat)\n     double epoint[];\n     int    inbpnt;\n     int    idim;\n     int    nptyp[];\n     int    icnsta;\n     int    icnend;\n     int    iopen;\n     int    ik;\n     double astpar;\n     double *cendpar;\n     SISLCurve  **rc;\n     double **gpar;\n     int    *jnbpar;\n     int    *jstat;\n#endif\n/*\n*************************************************************************\n*\n* Purpose: To calculate a B-spline curve interpolating a set of points.\n*          The points can be assigned a tangent (derivative).\n*          The curve can be closed or open. If end-conditions are\n*          conflicting, the condition closed curve rules out other\n*          end conditions.\n*\n* Input:\n*        Epoint - Array (length idim*inbpnt) containing the points/\n*                 derivatives to be interpolated.\n*        Inbpnt - No. of points/derivatives in the epoint array.\n*        Idim   - The dimension of the space in which the points lie.\n*        nptyp  - Array (length inbpnt) containing type indicator for\n*                 points/derivatives/second-derivatives:\n*                  1 - Ordinary point.\n*                  2 - Knuckle point. (Is treated as an ordinary point.)\n*                  3 - Derivative to next point.\n*                  4 - Derivative to prior point.\n*                ( 5 - Second derivative to next point. )\n*                ( 6 - Second derivative to prior point. )\n*                 13 - Start-point of tangent to next point.\n*                 14 - End-point of tangent to prior  point.\n*        Icnsta - Additional condition at the start of the curve:\n*                  0 : No additional condition.\n*                  1 : Zero curvature at start.\n*        Icnend - Additional condition at the end of the curve:\n*                  0 : No additional condition.\n*                  1 : Zero curvature at end.\n*        Iopen  - Flag telling if the curve should be open or closed:\n*                  1 : Open curve.\n*                  0 : Closed, non-periodic curve.\n*                 -1 : Periodic curve.\n*        Ik     - The order of the B-spline curve to be produced.\n*        Astpar - Parameter-value to be used at the start of the curve.\n*\n* Output:\n*        cendpar - Parameter-value used at the end of the curve.\n*        Rc     - Pointer to output-curve.\n*        Gpar   - Pointer to the parameter-values of the points in\n*                 the curve. Represented only once, although derivatives\n*                 and second-derivatives will have the same parameter-\n*                 value as the points.\n*        Jnbpar - No. of different parameter-values.\n*        Jstat  - status variable:\n*                  < 0 : Error.\n*                  = 0 : Ok.\n*                  > 0 : Warning.\n*\n* Method: First the parametrization of the curve and the type\n*         specification of points/derivatives are checked and/or\n*         corrected. Then the knots are calculated, and the\n*         interpolation is performed.\n*\n* Calls: s1906,s1901,s6err.\n*\n* Written by: A.M. Ytrehus  Si  Oslo, Norway  Sep. 1988.\n* The main routine, p19501, is written by: T. Dokken  SI.\n* Rewised by: Trond Vidar Stensby, SI, 1991-07\n* REWISED BY: Vibeke Skytt, 03.94. This routine corresponds to s1334,\n*                                  but differ in the use of the parameter\n*                                  iopen and the input array ntype is of\n*                                  type int.\n*****************************************************************\n*/\n{\n  int kpos = 0;\n  int kstat = 0;\n  int *ltype = SISL_NULL;\t\t/* The kind of interpolation conditions. */\n  int knpt;\t\t\t/* Number of acepted interpolation conditions. */\n  double *lcond = SISL_NULL;\t\t/* The number of acepted interpolation conditions. */\n\n  *jstat = 0;\n\n  /* Transform interpolation conditions. */\n\n  s1906 (epoint, nptyp, icnsta, icnend, inbpnt, idim, &lcond,\n\t &ltype, &knpt, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Interpolate. */\n\n  s1912(s1909, s1902, lcond, ltype, knpt, astpar, ik, idim, iopen,\n\tcendpar, rc, gpar, jnbpar, &kstat);  \n  if (kstat < 0) goto error;\n\n  *jstat = 0;\n  goto out;\n  \n  /* Error in lower level routine. */\n error: *jstat = kstat;\n  s6err(\"s1356\",*jstat,kpos);\n  goto out;\n\n out:\n  if (ltype != SISL_NULL)\n    freearray (ltype);\n  if (lcond != SISL_NULL)\n    freearray (lcond);\n    \n  return;\n}\n"
  },
  {
    "path": "src/s1357.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S1357\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1357(double epoint[],int inbpnt,int idim,int ntype[],double epar[],\n\t   int icnsta,int icnend,int iopen,int ik,double astpar,\n\t   double *cendpar,SISLCurve **rc,double **gpar,int *jnbpar,int *jstat)\n#else\nvoid s1357(epoint,inbpnt,idim,ntype,epar,icnsta,icnend,iopen,ik,astpar,\n           cendpar,rc,gpar,jnbpar,jstat)\n     double epoint[];\n     int    inbpnt;\n     int    idim;\n     int    ntype[];\n     double epar[];\n     int    icnsta;\n     int    icnend;\n     int    iopen;\n     int    ik;\n     double astpar;\n     double *cendpar;\n     SISLCurve  **rc;\n     double **gpar;\n     int    *jnbpar;\n     int    *jstat;\n#endif\n/*\n*************************************************************************\n*\n* Purpose: To calculate a B-spline curve interpolating a set of points.\n*          The points can be assigned a tangent (derivative).\n*          The curve can be closed or open. If end-conditions are\n*          conflicting, the condition closed curve rules out other\n*          end conditions.\n*          The parametrization is given by the array Epar.\n*\n* Input:\n*        Epoint - Array (length idim*inbpnt) containing the points/\n*                 derivatives to be interpolated.\n*        Inbpnt - No. of points/derivatives in the epoint array.\n*        Idim   - The dimension of the space in which the points lie.\n*        ntype  - Array (length inbpnt) containing type indicator for\n*                 points/derivatives/second-derivatives:\n*                  1 - Ordinary point.\n*                  2 - Knuckle point. (Is treated as an ordinary point.)\n*                  3 - Derivative to next point.\n*                  4 - Derivative to prior point.\n*                ( 5 - Second derivative to next point. )\n*                ( 6 - Second derivative to prior point. )\n*                 13 - Start-point of tangent to next point.\n*                 14 - End-point of tangent to prior  point.\n*        Epar   - Array containing the wanted parametrization. Only parameter\n*                 values corresponding to position points are given.\n*                 For closed curves, one additional parameter value\n*                 must be spesified. The last entry contains\n*                 the parametrization of the repeted start point.\n*                 (if the endpoint is equal to the startpoint of\n*                 the interpolation the lenght of the array should\n*                 be equal to inpt1 also in the closed case).\n*        Icnsta - Additional condition at the start of the curve:\n*                  0 : No additional condition.\n*                  1 : Zero curvature at start.\n*        Icnend - Additional condition at the end of the curve:\n*                  0 : No additional condition.\n*                  1 : Zero curvature at end.\n*        Iopen  - Flag telling if the curve should be open or closed:\n*                  1 : The curve should be open.\n*                  0 : The curve should be closed.\n*                 -1 : The curve should be closed and periodic.\n*        Ik     - The order of the B-spline curve to be produced.\n*        Astpar - Parameter-value to be used at the start of the curve.\n*\n* Output:\n*        Jstat  - status variable:\n*                  < 0 : Error.\n*                  = 0 : Ok.\n*                  > 0 : Warning.\n*        cendpar - Parameter-value used at the end of the curve.\n*        Rc     - Pointer to output-curve.\n*        Gpar   - Pointer to the parameter-values of the points in\n*                 the curve. Represented only once, although derivatives\n*                 and second-derivatives will have the same parameter-\n*                 value as the points.\n*        Jnbpar - No. of different parameter-values.\n*\n* Method: First the parametrization of the curve and the type\n*         specification of points/derivatives are checked and/or\n*         corrected. Then the knots are calculated, and the\n*         interpolation is performed.\n*\n* Calls: s1907,s1908,s1902,s1891,s1713,s1750,s6err.\n*\n* Written by: Trond Vidar Stensby, SI, 1991-07\n* The Fortran routine, p19539, is written by: T. Dokken  SI.\n* Bug fix:    Michael Floater, 82.9.93. The construction of gpar and *jnbpar\n*                  at the end of the routine was incorrect.\n* REWISED BY: Vibeke Skytt, 03.94. This routine corresponds to s1358,\n*                                  but differ in the use of the parameter\n*                                  iopen and the input array ntype is of\n*                                  type int.\n* REWISED BY: Johannes Kaasa, 01.98. Made sure the start and end points\n*                  are correct in the periodic case. I also made proper\n*                  handling when the order is higher than the number of\n*                  interpolation points.\n*****************************************************************\n*/\n{\n  int kpos = 0;\n  SISLCurve *qc = SISL_NULL;\t\t/* Temporary SISLCurves.                    */\n  SISLCurve *qc2 = SISL_NULL;\n  SISLCurve *dummy = SISL_NULL;\n  int *ltype = SISL_NULL;\t\t/* Type of interpolation condition\n\t\t\t\t   (temporary)                              */\n  int *ltype2 = SISL_NULL;\t\t/* Type of interpolation condition (finial) */\n  int *sder = SISL_NULL;\t\t/* Vector of derivative indicators.         */\n  int knpt;\t\t\t/* Number of interpolation conditions.      */\n  int kordr;\t\t\t/* Local order.                             */\n  int kstat;\t\t\t/* Status variable.                         */\n  int kn;\t\t\t/* Number of coefficients of B-spline curve.*/\n  int ki, kj, kl;\t\t/* Loop control variable.                   */\n  int kright = 1;\t\t/* One equation system to solve in\n\t\t\t\t   interpolation.                           */\n  int knlr = 0;\t\t\t/* Indicates shape of interpolation matrix. */\n  int knrc = 0;\t\t\t/* Indicates shape of interpolation matrix. */\n  int kopen;                    /* Local open/closed parameter. Closed,\n\t\t\t\t   non-periodic is treated as an open curve.*/\n  int kpair;                    /* Pair order or not.                       */\n  int kcont;                    /* Continuity in start/end point.           */\n  int kleft;                    /* Pointer into knot array.                 */\n  int klast1, klast2;           /* Last element in array.                   */\n  double split_par;             /* Splitting parameter.                     */\n  double tdiff;                 /* Length of parameter interval.            */\n  double *lpar = SISL_NULL;\t\t/* Parameter values. (temporary)            */\n  double *lcond = SISL_NULL;\t\t/* Interpolation conditions. (temporary)    */\n  double *sknot = SISL_NULL;\t\t/* Knot vector.                             */\n  double *spar = SISL_NULL;\t\t/* Parameter valued. (finial)               */\n  double *scond = SISL_NULL;\t\t/* Interpolation conditions. (finial)       */\n  double *scoef = SISL_NULL;\t\t/* Coefficients of curve.                   */\n  double *temp = SISL_NULL;          /* Temporary storage.                       */\n\n  *jstat = 0;\n\n  /* If necessary reduce the order. */\n\n  kordr = MIN (ik, inbpnt);\n\n  /* Set local open/closed parameter. */\n\n  kopen = (iopen == SISL_CRV_PERIODIC) ? 0 : 1;\n\n  /* Check pair order or not. */\n\n  kpair = (kordr % 2 == 0) ? 1 : 0;\n\n  /* Transform interpolation conditions. */\n\n  s1907 (epoint, ntype, epar, iopen, icnsta, icnend, inbpnt,\n\t idim, &lcond, &ltype, &lpar,&knpt, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Test interpolation conditions, and adjust the input conditions\n     if necessary.  */\n\n  s1908 (lcond, ltype, lpar, knpt, kordr, idim, iopen, &scond, &ltype2,\n\t &spar, &knpt, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Allocate scratch for derivative indicator. */\n\n  sder = newarray (knpt, INT);\n  if (sder == SISL_NULL) goto err101;\n\n  for (ki = 0; ki < knpt; ki++)\n    sder[ki] = abs (ltype2[ki]);\n\n\n  if (iopen == SISL_CRV_PERIODIC)\n    {\n      knlr = kordr / 2;\n      knrc = kordr - knlr - 1;\n      knpt--;\n    }\n\n  /* Produce knot vector. */\n\n  s1902 (lpar, knpt, kordr, kopen, &sknot, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Perform interpolation.  */\n\n  s1891 (spar, scond, idim, knpt, kright, sder, kopen, sknot,\n\t &scoef, &kn, kordr, knlr, knrc, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Corrected start and end for odd order periodic curves. */\n\n  if (iopen == SISL_CRV_PERIODIC && kpair)\n  {\n     if ((temp = newarray(idim, double)) == SISL_NULL)\n\tgoto err101;\n\n     /* Find number of present starting knots. */\n\n     ki = 0;\n     while (sknot[ki] < epar[0]) ki++;\n\n     klast1 = kn + kordr - 1;\n     klast2 = idim*(kn - 1);\n     tdiff = lpar[knpt] - lpar[0];\n     for ( ; ki < (kordr - 1); ki++)\n     {\n\ttemp[0] = sknot[knpt - 1] - tdiff;\n\tfor (kj = klast1; kj > 0; kj--)\n\t   sknot[kj] = sknot[kj - 1];\n\tsknot[0] = temp[0];\n\n\tfor (kl = 0; kl < idim; kl++)\n\t   temp[kl] = scoef[(knpt - 1)*idim + kl];\n\tfor (kj = klast2; kj > 0; kj -= idim)\n\t{\n\t   for (kl = 0; kl < idim; kl++)\n\t      scoef[kj + kl] = scoef[kj - idim + kl];\n\t}\n\tfor (kl = 0; kl < idim; kl++)\n\t   scoef[kl] = temp[kl];\n     }\n  }\n\n  /* Express the curve as a curve object.  */\n\n  qc = newCurve (kn, kordr, sknot, scoef, 1, idim, 1);\n  if (qc == SISL_NULL) goto err101;\n  qc->cuopen = iopen;\n\n  /* Corrected start and end for even order periodic curves. */\n\n  if (iopen == SISL_CRV_PERIODIC && !kpair &&\n      fabs(qc->et[qc->ik - 1] - epar[0]) > REL_PAR_RES)\n  {\n\n     /* Shift the start/end point. */\n\n     split_par = epar[0];\n     while (split_par < qc->et[qc->ik-1])\n        split_par += (qc->et[qc->in] - qc->et[qc->ik-1]);\n     while (split_par > qc->et[qc->in])\n        split_par -= (qc->et[qc->in] - qc->et[qc->ik-1]);\n     s1710(qc, split_par, &qc2, &dummy, &kstat);\n     if (kstat != 2) goto error;\n     tdiff = qc2->et[qc2->ik - 1] - epar[0];\n     if (fabs(tdiff) > REL_PAR_RES)\n     {\n        for (ki = 0; ki < (qc2->in + qc2->ik); ki++)\n           qc2->et[ki] -= tdiff;\n     }\n\n     /* qc2 is represented on a closed basis, and flagged\n        as SISL_CRV_CLOSED. We have to open it again. First\n        find the continuity in the new end point.           */\n\n     kcont = qc->ik - 1 - max(s6knotmult(qc->et, qc->ik, qc->in,\n                                     &kleft, epar[0], &kstat), 1);\n     if (kstat < 0) goto error;\n\n     make_cv_cyclic(qc2, kcont, &kstat);\n     if (kstat < 0) goto error;\n\n     if (qc != SISL_NULL) freeCurve (qc);\n     qc = qc2;\n     qc2 = SISL_NULL;\n\n  }\n\n  if (kordr < ik)\n    {\n      /* The order of the curve is less than expected. Increase the order. */\n\n      qc2 = SISL_NULL;\n      s1750 (qc, ik, &qc2, &kstat);\n      if (kstat < 0) goto error;\n\n      if (qc != SISL_NULL) freeCurve (qc);\n      qc = qc2;\n      qc2 = SISL_NULL;\n    }\n\n  /* Set open/closed parameter of curve. */\n\n  qc->cuopen = iopen;\n\n  /* Set end of parameter interval.  */\n\n  *cendpar = *(qc->et + qc->in);\n\n  /* Interpolation performed. */\n\n  /* Find distinct parameter values. */\n\n  *gpar = lpar;\n\n  /* Bug fix, MSF, 28.9.93. Change\n      *jnbpar = 1;\n     to:  */\n\n  *jnbpar = 0;\n\n  for (ki = 1; ki<knpt; ki++)\n    {\n      if (spar[ki - 1] < spar[ki])\n\n      /* Bug fix. MSF, 28.9.93 Change (*gpar)[(*jnbpar)++] = spar[ki]; to: */\n\n\t(*gpar)[(*jnbpar)++] = spar[ki-1];\n    }\n\n  /* Bug fix. MSF, 28.9.93 Change (*gpar)[(*jnbpar)++] = spar[ki]; to: */\n\n  (*gpar)[(*jnbpar)++] = spar[ki-1];\n\n  *rc = qc;\n  goto out;\n\n\n  /* Error in scratch allocation.  */\n\n  err101:\n    *jstat = -101;\n    s6err (\"s1357\", *jstat, kpos);\n    goto out;\n\n  /* Error in lower level routine. */\n\n  error:\n    *jstat = kstat;\n    s6err (\"s1357\", *jstat, kpos);\n    goto out;\n\n  out:\n  /* Free scratch occupied by local arrays. */\n\n    if (scond != SISL_NULL)    freearray (scond);\n    if (scoef != SISL_NULL)    freearray (scoef);\n    if (sder != SISL_NULL)     freearray (sder);\n    if (ltype != SISL_NULL)    freearray (ltype);\n    if (ltype2 != SISL_NULL)   freearray (ltype2);\n    if (lcond != SISL_NULL)    freearray (lcond);\n    if (sknot != SISL_NULL)    freearray (sknot);\n    if (spar != SISL_NULL)     freearray (spar);\n    if (temp != SISL_NULL)     freearray (temp);\n\n    return;\n}\n"
  },
  {
    "path": "src/s1358.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1358.c,v 1.2 2001-03-19 15:58:47 afr Exp $\n *\n */\n\n\n#define S1358\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1358(double epoint[],int inbpnt,int idim,double ntype[],double epar[],\n\t   int icnsta,int icnend,int iopen,int ik,double astpar,\n\t   double *cendpar,SISLCurve **rc,double **gpar,int *jnbpar,int *jstat)\n#else\nvoid s1358(epoint,inbpnt,idim,ntype,epar,icnsta,icnend,iopen,ik,astpar,\n           cendpar,rc,gpar,jnbpar,jstat)\n     double epoint[];\n     int    inbpnt;\n     int    idim;\n     double    ntype[];\n     double epar[];\n     int    icnsta;\n     int    icnend;\n     int    iopen;\n     int    ik;\n     double astpar;\n     double *cendpar;\n     SISLCurve  **rc;\n     double **gpar;\n     int    *jnbpar;\n     int    *jstat;\n#endif\n/*\n*************************************************************************\n*\n* Purpose: To calculate a B-spline curve interpolating a set of points.\n*          The points can be assigned a tangent (derivative).\n*          The curve can be closed or open. If end-conditions are\n*          conflicting, the condition closed curve rules out other\n*          end conditions.\n*          The parametrization is given by the array Epar.\n*\n* Input:\n*        Epoint - Array (length idim*inbpnt) containing the points/\n*                 derivatives to be interpolated.\n*        Inbpnt - No. of points/derivatives in the epoint array.\n*        Idim   - The dimension of the space in which the points lie.\n*        ntype  - Array (length inbpnt) containing type indicator for\n*                 points/derivatives/second-derivatives:\n*                  1 - Ordinary point.\n*                  2 - Knuckle point. (Is treated as an ordinary point.)\n*                  3 - Derivative to next point.\n*                  4 - Derivative to prior point.\n*                ( 5 - Second derivative to next point. )\n*                ( 6 - Second derivative to prior point. )\n*                 13 - Start-point of tangent to next point.\n*                 14 - End-point of tangent to prior  point.\n*        Epar   - Array containing the wanted parametrization. Only parameter\n*                 values corresponding to position points are given.\n*                 For closed curves, one additional parameter value\n*                 must be spesified. The last entry contains\n*                 the parametrization of the repeted start point.\n*                 (if the endpoint is equal to the startpoint of\n*                 the interpolation the lenght of the array should\n*                 be equal to inpt1 also in the closed case).\n*        Icnsta - Additional condition at the start of the curve:\n*                  0 : No additional condition.\n*                  1 : Zero curvature at start.\n*        Icnend - Additional condition at the end of the curve:\n*                  0 : No additional condition.\n*                  1 : Zero curvature at end.\n*        Iopen  - Flag telling if the curve should be open or closed:\n*        Ik     - The order of the B-spline curve to be produced.\n*        Astpar - Parameter-value to be used at the start of the curve.\n*\n* Output:\n*        Jstat  - status variable:\n*                  < 0 : Error.\n*                  = 0 : Ok.\n*                  > 0 : Warning.\n*        cendpar - Parameter-value used at the end of the curve.\n*        Rc     - Pointer to output-curve.\n*        Gpar   - Pointer to the parameter-values of the points in\n*                 the curve. Represented only once, although derivatives\n*                 and second-derivatives will have the same parameter-\n*                 value as the points.\n*        Jnbpar - No. of different parameter-values.\n*\n* Method: First the parametrization of the curve and the type\n*         specification of points/derivatives are checked and/or\n*         corrected. Then the knots are calculated, and the\n*         interpolation is performed.\n*\n* Calls: s1907,s1908,s1902,s1891,s1713,s1750,s6err.\n*\n* Written by: Trond Vidar Stensby, SI, 1991-07\n* The Fortran routine, p19539, is written by: T. Dokken  SI.\n* Bug fix:    Michael Floater, 82.9.93. The construction of gpar and *jnbpar\n*                  at the end of the routine was incorrect.\n*****************************************************************\n*/\n{\n  int kpos = 0;\n  SISLCurve *qc = SISL_NULL;\t\t/* Temporary SISLCurves.                    */\n  SISLCurve *qc2 = SISL_NULL;\n  int *ltype = SISL_NULL;\t\t/* Type of interpolation condition \n\t\t\t\t   (temporary)                              */\n  int *ltype2 = SISL_NULL;\t\t/* Type of interpolation condition (finial) */\n  int *sder = SISL_NULL;\t\t/* Vector of derivative indicators.         */\n  int knpt;\t\t\t/* Number of interpolation conditions.      */\n  int kordr;\t\t\t/* Local order.                             */\n  int kstat;\t\t\t/* Status variable.                         */\n  int kn;\t\t\t/* Number of coefficients of B-spline curve.*/\n  int ki;\t\t\t/* Loop control variable.                   */\n  int kright = 1;\t\t/* One equation system to solve in \n\t\t\t\t   interpolation.                           */\n  int knlr = 0;\t\t\t/* Indicates shape of interpolation matrix. */\n  int knrc = 0;\t\t\t/* Indicates shape of interpolation matrix. */\n  double *lpar = SISL_NULL;\t\t/* Parameter values. (temporary)            */\n  double *lcond = SISL_NULL;\t\t/* Interpolation conditions. (temporary)    */\n  double *sknot = SISL_NULL;\t\t/* Knot vector.                             */\n  double *spar = SISL_NULL;\t\t/* Parameter valued. (finial)               */\n  double *scond = SISL_NULL;\t\t/* Interpolation conditions. (finial)       */\n  double *scoef = SISL_NULL;\t\t/* Coefficients of curve.                   */\n  int *ityp = SISL_NULL;\n\n/* -> new statement guen & ujk Thu Jul  2 14:59:05 MESZ 1992 */\n\n/* make compatible to old use of s1604 */\n\n  if (iopen==SISL_CRV_CLOSED) iopen = SISL_CRV_PERIODIC;\n\n/* a new version with input-iopen == rc->cuopen\n   should be made, with a name different from any\n   other.\n  NOTE: There is an error in this function when iopen = 0\n        qc as input to s1713 (and s1750) then has wrong flag !!*/\n\n/* <- new statement guen & ujk Thu Jul  2 14:59:05 MESZ 1992 */\n\n  ityp = newarray (inbpnt, INT);\n  if (ityp == SISL_NULL) goto err101;\n\n  for (ki=0; ki < inbpnt; ki++) ityp[ki] = (int)ntype[ki];\n  *jstat = 0;\n\n  /* Transform interpolation conditions. */\n\n  s1907 (epoint, ityp, epar, iopen, icnsta, icnend, inbpnt,\n\t idim, &lcond, &ltype, &lpar,&knpt, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Test interpolation conditions, and adjust the input conditions\n     if necessary.  */\n\n  s1908 (lcond, ltype, lpar, knpt, ik, idim, iopen, &scond, &ltype2,\n\t &spar, &knpt, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Allocate scratch for derivative indicator. */\n\n  sder = newarray (knpt, INT);\n  if (sder == SISL_NULL) goto err101;\n\n  for (ki = 0; ki < knpt; ki++)\n    sder[ki] = abs (ltype2[ki]);\n\n  kordr = MIN (ik, knpt);\n\n  if (!(iopen == SISL_CRV_OPEN))\n    {\n      knlr = kordr / 2;\n      knrc = kordr - knlr - 1;\n      knpt--;\n    }\n\n  /* Produce knot vector. */\n\n  s1902 (lpar, knpt, kordr, iopen, &sknot, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Perform interpolation.  */\n\n  s1891 (spar, scond, idim, knpt, kright, sder, iopen, sknot,\n\t &scoef, &kn, kordr, knlr, knrc, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Express the curve as a curve object.  */\n\n  qc = newCurve (kn, kordr, sknot, scoef, 1, idim, 1);\n  if (qc == SISL_NULL) goto err101;\n  qc->cuopen = (iopen == SISL_CRV_OPEN) ? iopen : SISL_CRV_PERIODIC;\n  \n  if (iopen == SISL_CRV_CLOSED)\n    {\n      /* A closed, non-periodic curve is expected. Pick the part of the\n         interpolation curve that has got a full basis.  */\n\n      s1713 (qc, sknot[kordr - 1], sknot[kn], &qc2, &kstat);\n      if (kstat < 0) goto error;\n\n      if (qc != SISL_NULL) freeCurve (qc);\n      qc = qc2;\n    }\n\n  if (kordr < ik)\n    {\n      /* The order of the curve is less than expected. Increase the order. */\n\n      qc2 = SISL_NULL;\n      s1750 (qc, ik, &qc2, &kstat);\n      if (kstat < 0) goto error;\n\t\n      if (qc != SISL_NULL) freeCurve (qc);\n      qc = qc2;\n    }\n\n  /* Set open/closed parameter of curve. */\n\n  qc->cuopen = iopen;\n\n  /* Set end of parameter interval.  */\n  \n  *cendpar = *(qc->et + qc->in);\n\n  /* Interpolation performed. */\n\n  /* Find distinct parameter values. */\n\n  *gpar = lpar;\n\n  /* Bug fix, MSF, 28.9.93. Change\n      *jnbpar = 1;\n     to:  */\n\n  *jnbpar = 0;\n\n   /*called from s1333: s1358(epoint,21,21,only 1,epar,0,0,1,3,,\n           cendpar,rc,gpar,jnbpar,jstat) */\n  /* Error: iopen = 1, order=3, hp has a case where the size of gpar is 21 and\n     when leaving this loop *jnbpar (and knpt and ki) is also 21 !!!!!!!!!!!!? */\n  /* The above error is now fixed, MSF.\n     The following chunk of code merely removes double knots\n     from the knot vector spar (length knpt) producing\n     both the number *jnbpar of different knots and\n     an array gpar with the different knots of length *jnbpar. */\n \n  for (ki = 1; ki<knpt; ki++)\n    {\n      if (spar[ki - 1] < spar[ki])\n\t \n      /* Bug fix. MSF, 28.9.93 Change (*gpar)[(*jnbpar)++] = spar[ki]; to: */\n\n\t(*gpar)[(*jnbpar)++] = spar[ki-1];\n    }\n\n  /* Bug fix. MSF, 28.9.93 Change (*gpar)[(*jnbpar)++] = spar[ki]; to: */\n\n  (*gpar)[(*jnbpar)++] = spar[ki-1];\n  \n  *rc = qc;\n  goto out;\n\n\n  /* Error in scratch allocation.  */\n\n  err101:\n    *jstat = -101;\n    s6err (\"s1358\", *jstat, kpos);\n    goto out;\n\n  /* Error in lower level routine. */\n\n  error:\n    *jstat = kstat;\n    s6err (\"s1358\", *jstat, kpos);\n    goto out;\n\n  out:\n  /* Free scratch occupied by local arrays. */\n\n    if (scond != SISL_NULL)    freearray (scond);\n    if (scoef != SISL_NULL)    freearray (scoef);\n    if (sder != SISL_NULL)     freearray (sder);\n    if (ltype != SISL_NULL)    freearray (ltype);\n\n/* -> added, guen & ujk Wed Jul  1 18:48:27 MESZ 1992 */\n    if (ityp != SISL_NULL)     freearray (ityp);\n/* <- added, guen & ujk Wed Jul  1 18:48:27 MESZ 1992 */\n\n    if (ltype2 != SISL_NULL)   freearray (ltype2);\n    if (lcond != SISL_NULL)    freearray (lcond);\n    if (sknot != SISL_NULL)    freearray (sknot);\n    if (spar != SISL_NULL)     freearray (spar);\n\n    return;\n}\n\n"
  },
  {
    "path": "src/s1359.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1359.c,v 1.3 2001-03-19 15:58:47 afr Exp $\n *\n */\n#define S1359\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1359(double egeo[],double aepsge,int idim,int inbinf,\n\t   int ipar,double epar[],SISLCurve **rcurve,int *jstat)\n#else\nvoid s1359(egeo,aepsge,idim,inbinf,ipar,epar,rcurve,jstat)\n     double egeo[];\n     double aepsge;\n     int    idim;\n     int    inbinf;\n     int    ipar;\n     double epar[];\n     SISLCurve  **rcurve;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To represent the curve described in egeo as\n*              an Hermit curve on a B-spline format.It hte first and last points\n*              have exactly the same position a cyclic basis is made by moving\n*              the first and last knots.\n*\n*\n* INPUT      : egeo   - The geometry of the point to be interpolated\n*                       The sequence of the information for each point\n*                       is: position, unit tangent, curvature vector\n*                           and radius of curvature.\n*                       When the dimension is 2 this is 7 doubles\n*                       When the dimension is 3 this is 10 doubles\n*                       Total size of egeo is thus:\n*                        idim=2 :  7*inbinf doubles\n*                        idim=3 : 10*inbinf doubles\n*              aepsge - Geoemtry resolution. Here used for minimal knot\n*                       distance.\n*              idim   - Dimension of the spcae the points lie in\n*                       only 2 and 3 is legal\n*              inbinf - Number of points\n*              ipar   - Array telling if input parametrization (in epar)\n*                       is to be used:\n*                        ipar = 0 : Don't use input parametrization\n*                        ipar = 1 : Use input parametrization\n*\n* INPUT/OUTPUT:\n*              epar   - Parametrization of the points. ipar determines\n*                       if this is input or output\n*\n* OUTPUT     : rcurve - The curve produced\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, OSLO, Norway, 30. June 1988\n*              UJK and VSK 24.10.90, Changed test for recognizing zero curvature\n*              Tor Dokken, SI, Cyclic behaviour when closed\n*********************************************************************\n*/\n{\n  int kn;             /* Number of vertices                                 */\n  int kk = 4;         /* Order of b-spline basis                            */\n  int knt;            /* Number of knots produced so far                    */\n  int kvert;          /* Pointer to first free variable in vertex array     */\n  int kpos =1;        /* Position of error                                  */\n  int kstat;          /* Local status variable                              */\n  int ki,kj;          /* Running variables in loop                          */\n  int kv1,kv2,kv3;    /* Running variables in loop                          */\n  int kincre;         /* Number of doubles for each point in egeo           */\n  int kcycpos;        /* Indicator telling if cyclic or open geometry       */\n  double *sprevp;     /* Pointer to position at start of current segment    */\n  double *sprevt;     /* Pointer to tangent  at start of current segment    */\n  double *sprevc;     /* Pointer to curvature at start of current segment   */\n  double *sprevr;     /* Pointer to radius of curvature start current segment*/\n  double snprevt[3];  /* Nomralized version of sprevc                        */\n  double *scurp;      /* Pointer to position at end   of current segment     */\n  double *scurt;      /* Pointer to tangent  at end   of current segment     */\n  double *scurc;      /* Pointer to curvature at end   of current segment    */\n  double *scurr;      /* Pointer to radius of curvature end   current segment*/\n  double sncurt[3];   /* Normalized version of scurc                         */\n  double tcos;        /* Description of angle                                */\n  double tl1,tl2;     /* Tangent lengths                                     */\n  double tangle;      /* Arcus cosinus if tcos                               */\n  double tdist;       /* Distance between start and end of current segment   */\n  double tpar;        /* Parameter value at end of segment                   */\n  double *st = SISL_NULL;  /* Pointer to knot vector                              */\n  double *scoef=SISL_NULL; /* Pointer to vertices                                 */\n  double tmpval=aepsge;/* Maximal difference in x, y and z coordinate        */\n  double max_dist;\n  /* Allocate space for knots and vertices */\n  \n  if (idim != 2 && idim != 3) goto err105;\n\n  /* No. of points given must be > 1 since it makes no sence to interpolate\n     over 0 or 1 point, so check inbinf.*/\n\n  if (inbinf < 2) goto err181;\n  \n  \n  if (idim==2)\n    kincre = 7;\n  else\n    kincre = 10;\n  \n  \n  /* To make sure that we don't make a too long jump in parametrization, find\n     maximal difference in x, y and z coordinate. */\n  \n  if (ipar==0)\n    {\n      double tmin,tmax,*sp;\n      \n      for (kj=0 ; kj<idim ; kj++)\n        {\n\t  tmin = *(egeo+kj);\n\t  tmax = tmin;\n\t  for (ki=0,sp=egeo+kj ; ki < inbinf ; ki++,sp+=kincre)\n            {\n\t      tmin = MIN(tmin,*sp);\n\t      tmax = MAX(tmax,*sp);\n            }\n\t  tmpval = MAX(tmpval,(tmax-tmin));\n        }\n    }\n  \n  kn = 3*(inbinf-1) + 1;\n  scoef = newarray(idim*kn,DOUBLE);\n  if (scoef == SISL_NULL) goto err101;\n  \n  st = newarray(kk+kn,DOUBLE);                                                  \n  if (st == SISL_NULL) goto err101;\n  \n  /* Make four first knots */\n  if (ipar==0)\n    {\n      epar[0] = DZERO;\n    }\n  \n  st[0] = epar[0];\n  st[1] = epar[0];\n  st[2] = epar[0];\n  st[3] = epar[0];\n  \n  /* Make first vertex */\n  memcopy(scoef,egeo,idim,DOUBLE);\n  \n  \n  /* Set pointers to start point, tangent, curvature and radius of curvature\n   */\n  \n  sprevp = egeo;\n  sprevt = sprevp + idim;\n  sprevc = sprevt + idim;\n  sprevr = sprevc + idim;\n  \n  /* Normalize curvature vector at start */\n  \n  (void)s6norm(sprevt,idim,snprevt,&kstat);\n  \n  for (ki=1,knt=4,kvert=idim;ki<inbinf;ki++)\n    {\n      \n      /* For each pair of adjacent points in egeo make an Hermit segment */\n      \n      /* Set pointers position, tangent, curvature and radius of end of\n\t current segment segment */\n      \n      scurp = sprevp + kincre;\n      scurt = sprevt + kincre;\n      scurc = sprevc + kincre;\n      scurr = sprevr + kincre;\n      \n      /* Normalize curvature vector at end of segment */\n      \n      (void)s6norm(scurt,idim,sncurt,&kstat);\n      \n      /* Make cosine of angle between tangent vectors by making the scalar\n\t product of the normalized versions of the two vectors */\n      \n      tcos = s6scpr(snprevt,sncurt,idim);\n      \n      /* Find the actual angle by making the arcus tangens of this value */\n      \n      if (tcos >= DZERO)             \n\ttcos = MIN((double)1.0,tcos);\n      else\n\ttcos = MAX((double)-1.0,tcos);\n      \n      tangle = fabs(acos(tcos));\n      \n      if (tangle < ANGULAR_TOLERANCE) tangle = DZERO;\n      \n      tdist = s6dist(sprevp,scurp,idim);\n      \n      /* Make tangent length of start of segment */\n      \n      \n/* UJK and VSK 24.10.90 */\n/*      if (DEQUAL(tangle,DZERO) || *sprevr < (double)-1.0) */\n      if (DEQUAL(tangle,DZERO) || *sprevr < DZERO)\n        {\n\t  /* Parallel tangents or infinit radius of curvature use 1/3 of\n\t     the distance between the points as tangent length    */\n\t  tl1 = tdist/(double)3.0;\n        }\n      else\n        {\n\t  /* Base tangent length on radius of curvature and opening angle */\n\t  tl1 = s1325(*sprevr,tangle);\n        }\n      \n      /*  Make tangent length of end of segment */\n      \n      if (DEQUAL(tangle,DZERO) || *scurr < DZERO)\n        {\n\t  /* Parallel tangents or infinit radius of curvature use 1/3 of\n\t     the distance between the points as tangent length         */\n\t  tl2 = tdist/(double)3.0;\n        }\n      else\n        {\n\t  /* Base tangent length on radius of curvature and opening angle */\n\t  tl2 = s1325(*scurr,tangle);\n        }\n      \n      /* Make sure that the tangent does not explode due to numeric errors,\n\t and make a controlled tangent when the radius is zero or almost zero*/\n      \n      /* ALA 28.10.93  An improved control was nessesary*/\n\n      if (tangle < 0.1)\t\tmax_dist = (double)0.35*tdist;\n      else if (tangle < 0.35)\tmax_dist = (double)0.40*tdist;\n      else if (tangle < 0.75)\tmax_dist = (double)0.50*tdist;\n      else \t\t\tmax_dist = (double)0.70*tdist;\n\n      if ( tl1 > max_dist) tl1 = max_dist;\n      if ( tl2 > max_dist) tl2 = max_dist;\n      \n      /* We want to have a parametrization that is as close as possible to an\n         arc length parametrization */                                             \n      \n      \n      if (ipar==0)\n        {\n\t  /* Make parametrization of segment by making an average of arc of a\n\t     circle with radius sprevr and scurr spanning an angle tangle.\n\t     If one or both radius infinit use the distance between the points\n\t     */\n\t  \n\t  if (DNEQUAL(*sprevr,(double)-1.0) && \n\t      DNEQUAL(*scurr,(double)-1.0))\n            {\n\t      tpar = (double)0.5*tangle*(*sprevr+*scurr);\n            }\n\t  else if (DNEQUAL(*sprevr,(double)-1.0) && \n\t\t   DEQUAL(*scurr,(double)-1.0))\n            {\n\t      tpar = (double)0.5*(*sprevr*tangle + tdist);\n            }\n\t  else if (DEQUAL(*sprevr,(double)-1.0) && \n\t\t   DNEQUAL(*scurr,(double)-1.0))\n            {\n\t      tpar = (double)0.5*(tdist + tangle*(*scurr));\n            }\n\t  else\n            {\n\t      tpar =  tdist;\n            }\n\t  \n\t  tpar = MAX(tpar,tdist);\n\t  tpar = MAX(tpar,aepsge);\n\t  \n\t  /* Make sure that we don't make a parameter inteval greater than\n\t     the maximal length of a SISLbox around the input points */\n\t  \n          /* tpar = MIN(tpar,tmpval);\n             BOH:220793: Start change */\n\t  \n          if (tangle <= PIHALF)\n\t     tpar = MIN(tpar, ((double)1.1*tdist));\n          else\n\t     tpar = MIN(tpar,tmpval);\n\t  \n          /* BOH: End change. */\n\t  \n\t  if (DEQUAL((epar[ki-1]+tpar),epar[ki-1]))\n            {\n\t      tpar = fabs(epar[ki-1])*(double)0.1;\n            }\n\t  \n\t  if (DEQUAL(tpar,DZERO))\n            {\n\t      tpar = (double)1.0;\n            }\n\t  \n\t  epar[ki] = epar[ki-1] + tpar;\n\t  \n        }\n      \n      /*  Make 3 new knots */\n      st[knt]   = epar[ki];\n      st[knt+1] = epar[ki];\n      st[knt+2] = epar[ki];\n      \n      /*  Make 3 new vertices of segment */\n      \n      for (kj=0,kv1=kvert,kv2=kv1+idim,kv3=kv2+idim ; kj<idim ;\n\t   kj++,kv1++,kv2++,kv3++)\n        {\n\t  scoef[kv1] = sprevp[kj] + tl1*sprevt[kj];\n\t  scoef[kv2] = scurp[kj]  - tl2*scurt[kj];\n\t  scoef[kv3] = scurp[kj];\n        }\n      \n      /*  Update pointers */\n      sprevp = scurp;\n      sprevt = scurt;\n      sprevc = scurc;\n      sprevr = scurr;\n      for (kj=0;kj<idim;kj++) snprevt[kj] = sncurt[kj];\n      \n      /*  Only update number of vertices if epar[ki-1] != epar[ki] */ \n      \n      if (DNEQUAL(epar[ki-1],epar[ki]))\n        {\n\t  kvert+=(3*idim);\n\t  knt+=3;\n        }\n    }\n  \n  /* VSK, 07.94. Moved this statement before inserting the last knot.\n     Update number of vertices */\n  \n  kn = kvert/idim;\n  \n  /* Insert last knot */\n  \n  st[kn+kk-1] = st[kn+kk-2];\n  \n  /* Test if cyclic curve */\n\n  for (ki=0, kcycpos=1 ; ki<idim ; ki++)\n    if (egeo[ki] != egeo[(inbinf-1)*kincre+ki]) kcycpos=0;\n  \n  if (kcycpos ==1)\n    {\n      st[0] -= (st[kn] - st[kn-1]);\n      st[kn+kk-1] += (st[kk] - st[kk-1]);\n    }\n  \n  \n  /* Make the curve */\n  \n  kpos = 1;\n  *rcurve = SISL_NULL;\n  *rcurve = newCurve(kn,kk,st,scoef,1,idim,1);\n  if (*rcurve == SISL_NULL) goto err101;\n  \n  /* Periodicity flag */\n  if (kcycpos)\n    {\n       test_cyclic_knots(st,kn,kk,&kstat);\n       if (kstat<0) goto error;\n      if (kstat == 2) (*rcurve)->cuopen = SISL_CRV_PERIODIC;\n    }\n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1359\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level.  */\n  \n error: *jstat = kstat;\n  s6err(\"s1359\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input, negative relative tolerance given */\n  \n err105: *jstat = -105;\n  s6err(\"s1359\",*jstat,kpos);\n  goto out;\n\n  /* Error in input, to few points given(inbinf < 2. */\n\n  err181: *jstat = -181;\n   s6err(\"s1359\",*jstat,kpos);\n   goto out;\n  \n  /* Free allocated arrays */\n out:\n  \n  \n  if (st != SISL_NULL)    freearray(st);\n  if (scoef != SISL_NULL) freearray(scoef);\n  \n  \n  return;\n}\n"
  },
  {
    "path": "src/s1360.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1360.c,v 1.4 2001-03-19 15:58:47 afr Exp $\n *\n */\n\n\n#define S1360\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1360(SISLCurve *pc,double aoffset,double aepsge,double enorm[],\n\t   double amax,int idim,SISLCurve **rc,int *jstat)\n#else\nvoid s1360(pc,aoffset,aepsge,enorm,amax,idim,rc,jstat)\n     SISLCurve  *pc;\n     double aoffset;\n     double aepsge;\n     double enorm[];\n     double amax;\n     int    idim;\n     SISLCurve  **rc;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To create a B-spline approximating the offset curve of\n*              a NURBS curve. The curve must have continous first\n*              derivative if the offset is different from zero. If the\n*              offset is zero then the position must be continous.\n*                           *\n*\n* INPUT      : pc     - The input NURBS curve.\n*              aoffset- The offset distance.\n*                       If idim=2 a positive offset value will place the\n*                       offset curve on the positive side of the normal vector,\n*                       and a negative value places the offset curve on the\n*                       negative side of the normal vector.\n*                       If idim=3 the offset is determined by the cross\n*                       product of the tangent vector and the anorm vector.\n*                       The offset distance is multiplied by this vector.\n*              enorm  - normal vector\n*              aepsge - Maximal deviation allowed between true offset curve\n*                       and the approximated offset curve.\n*              amax   - Maximal stepping length. Is negleceted if amax<=aepsge\n*                       If amax==0 then a maximal step length of the longest\n*                       SISLbox side is used.\n*              idim   - The dimension of the space (2 or 3).\n*\n* OUTPUT     :\n*              jstat  - status messages\n*                            > 0      : warning\n*                            = 0      : ok\n*                            = -1     : curve is degenrate.\n*\t\t\t\t        nothing returned.\n*                            < 0      : error\n*              rc     - Pointer the approximated offset curve\n*\n* METHOD     :\n*\n* EXAMPLE OF USE:\n*              SISLCurve *qr;\n*              int    kstat;\n*              .\n*              .\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1307, s1311, s1361, s1362, s6norm, s6length,\n*              s6dist,s6ang,s6scpr,s6diff,s6err\n*\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. 24. May 1988\n* REVISED BY : Michael Floater, SI, Oslo, 6/2/92.\n*                   Give error if pc is degenerate.\n* CHANGED BY : Ulf J. Krystad, Oslo, Norway. April 1992\n*              call to s1312 changed to call to s1359.\n*********************************************************************\n*/\n{\n  int kmaxinf;        /* Number of vertices space is allocated for       */\n  int knbinf=0;       /* Number of points stored so far                  */\n  int kder=2;         /* Derivative indicator                            */\n  int kstat,kstat1;   /* Status variable                                 */\n  int kstat2;\n  int kleft=0;        /* Left indicator for point calculation            */\n  int kleftend=0;     /* Pointer telling left knot of end of last segment*/\n  int kmult;          /* Multiplicity of knot at parameter value         */\n  int kn;             /* The number of B-splines, i.e., the dimension of\n\t\t\t the spline space associated with the knot\n\t\t\t vector.                                         */\n  int kk;             /* The polynomial order of the curve.              */\n  int kdim;           /* The dimension of the space in which the curve\n\t\t\t lies. Equivalently, the number of components\n\t\t\t of each B-spline coefficient.                   */\n  int notaccepted;    /* Loop control variable                           */\n  int kcont;          /* Loop control variable                           */\n  int kdiv;           /* Divergence indicator                            */\n  int knbit;          /* Number of iterations                            */\n  int kpos=0;         /* Position of error                               */\n  int kpar = 1;       /* Indicate that parametrization array exist       */\n  double sder1[9];    /* Derivatives from right                          */\n  double sder2[9];    /* Derivatives from left                           */\n  double smidd[3];    /* Middle point of current Bezier segement         */\n  double smtang[3];   /* Tangent at smidd                                */\n  double sdiff[3];    /* Difference of vectors                           */\n  double tproj1;      /* Projection of vector                            */\n  double tproj2;      /* Projection of vector                            */\n  double tlast;       /* Value in last itertion                          */\n  double tfak;        /* Necessary reduction of interval length          */\n  double *s3dinf=SISL_NULL;/* Pointer to storage for point info (10 dobules pr\n\t\t\t point when idim=3, 7 when idim=3)               */\n  double *spar=SISL_NULL;  /* Pointer to array for storage of knots           */\n  double *st;         /* Pointer to the first element of the knot vector\n\t\t\t of the curve. The knot vector has [kn+kk]\n\t\t\t elements.                                       */\n  double *scoef;      /* Pointer to the first element of the curve's\n\t\t\t B-spline coefficients. This is assumed to be an\n\t\t\t array with [kn*kdim] elements stored in the\n\t\t\t following order:\n\t\t\t First the kdim components of the first B-spline\n\t\t\t coefficient, then the kdim components of the\n\t\t\t second B-spline coefficient and so on.          */\n  double sder[9];     /* Poisition, first and second derivative on curve */\n  double tx1,tx2,txm; /* Parameter value */\n  double tstep;       /* Step length     */\n  double tmax;        /* Local maximal step length                 */\n  double tlengthend;  /* Length of 1st derivative at end of segment */\n  double tincre;      /* Parameter value increment */\n  double *start;      /* Pointer to start of current segment */\n  double tdist;       /* Distance */\n  double tang;        /* Angle */\n  double tnew;        /* New increment */\n  double tdum;        /* Temporary variable */\n  double tl1,tl2;     /* Vector lengths */\n  double tscal;       /* Scalar product */\n\n  /* Test that dimension is 2 or 3 */\n  if (idim !=2 && idim !=3) goto err105;\n\n  if (aepsge <= DZERO) goto err184;\n\n\n\n  /* Make maximal step length based on box-size of surface */\n\n  sh1992cu(pc,0,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  tmax = MAX(pc->pbox->e2max[0][0] - pc->pbox->e2min[0][0],\n\t     pc->pbox->e2max[0][1] - pc->pbox->e2min[0][1]);\n  tmax = MAX(tmax,pc->pbox->e2max[0][2] - pc->pbox->e2min[0][2]);\n\n  /* Check for degenerate curve. */\n\n  if(tmax == DZERO)\n  {\n      /* Curve is degenerate -- pc is just a point. */\n      *jstat = -1;\n      goto out;\n  }\n\n  if (amax>DZERO) tmax = MIN(tmax,amax);\n  /* Copy curve attributes to local parameters.  */\n\n  kn    = pc -> in;\n  kk    = pc -> ik;\n  st    = pc -> et;\n  scoef = pc -> ecoef;\n  kdim  = pc -> idim;\n\n  kmaxinf = 100;\n\n  /* Allocate space for storage of points,tangents, curvature and radius of\n     curvature */\n\n  s3dinf = newarray((3*kdim+1)*kmaxinf,DOUBLE);\n  if (s3dinf == SISL_NULL) goto err101;\n\n  /* Allocate space for parametrization array */\n\n  spar = newarray(kmaxinf,DOUBLE);\n  if (spar == SISL_NULL) goto err101;\n\n  /* Store knot values at start of curve */\n\n  tx1     = st[kk-1];\n  spar[0] = tx1;\n\n\n  /* Make start point and intital step length */\n\n  kder = 2;\n\n  s1362(pc,aoffset,enorm,idim,kder,tx1,&kleftend,sder,&kstat);\n  if (kstat<0) goto error;\n\n  /* Calculate unit tangent and radius of curvature */\n\n  s1307(sder,kdim,s3dinf,&kstat);\n  if (kstat<0) goto error;\n  knbinf = 1;\n\n  /* Calculate step length based on curvature */\n\n  tstep = s1311(s3dinf[3*kdim],aepsge,tmax,&kstat);\n  if (kstat<0) goto error;\n\n  /* Remember length of start tangent, end of zero segment */\n\n  tlengthend = s6length(sder+kdim,kdim,&kstat);\n  if (kstat<0) goto error;\n\n  /* While end not reached */\n\n\n  while (tx1 < st[kn])\n    {\n\n      /*  Find candidate end point, make sure that no breaks in tangent or\n\t  curvature exists between start and endpoints of the segment      */\n\n      /*  Make step length equal to aepsge if the length is zero */\n\n      /*  Find parameter value of candidate end point of segment */\n\n      if (DEQUAL(tlengthend,DZERO))\n        {\n\t  /* Step equal to computer resolution */\n\t  tincre = tx1*((double)1.0+REL_COMP_RES);\n        }\n      else\n        tincre = tstep/tlengthend;\n\n      /*  Make sure that we don't pass any knots */\n\n      tx2 = MIN(tx1 + tincre,st[kleftend+1]);\n\n\n      /*  While segement not accepted */\n\n      notaccepted = 1;\n\n      while(notaccepted==1)\n        {\n\n\t  /* Make end point of segment, and store it */\n\n\t  if (knbinf+2>=kmaxinf)\n            {\n\t      kmaxinf = kmaxinf + 100;\n\t      s3dinf = increasearray(s3dinf,(3*kdim+1)*kmaxinf,DOUBLE);\n\t      spar   = increasearray(spar,kmaxinf,DOUBLE);\n            }\n\n\t  /* Check multiplicity of end point of segment make sure that if\n\t     the multiplicity is greater than kk that we calculate derivatives\n\t     from the left. */\n\n\t  kmult = s6knotmult(st,kk,kn,&kleft,tx2,&kstat);\n\t  if (tx2 >= st[kn]) kmult = 0;\n\t  if (kmult > kk-2)\n\t    {\n\t      /* Check right and left hand derivatives of curve */\n\n\t      s1227(pc,2,tx2,&kleft,sder2,&kstat);\n\t      if (kstat<0) goto error;\n\n\t      s1221(pc,2,tx2,&kleft,sder1,&kstat);\n\t      if (kstat<0) goto error;\n\n\t      tl1 = s6length(sder1+kdim,kdim,&kstat1);\n\t      tl2 = s6length(sder2+kdim,kdim,&kstat2);\n\t      tscal = s6scpr(sder1+kdim,sder2+kdim,kdim);\n\t      tdum = MAX(tl1,tl2);\n\t      if (kstat1<0 || kstat2<0) goto error;\n\n\t      if(DEQUAL(tl1*tl2+tdum,tscal+tdum)) kmult = 0; /* G1 continuity*/\n\t    }\n\n\t  /* Make correct value of kleftend */\n\n\t  s1219(st,kk,kn,&kleftend,tx2,&kstat);\n\t  if (kstat<0) goto error;\n\n\n\t  /* Real offset, test multiplicity before calculation */\n\n          if (kmult > kk-2) tdum = tx2 * ((double)1.0-REL_COMP_RES);\n          else tdum = tx2;\n\n          /* We have the right value of kleftend, if no offset and\n             break then s1362 will decrease kleft */\n\n          if (aoffset != DZERO)\n\t    {\n              s1362(pc,aoffset,enorm,idim,kder,tdum,&kleft,sder,&kstat);\n\t      if (kstat<0) goto error;\n\t    }\n          else if (kmult > kk-2)\n\t    memcopy(sder,sder2,kdim*3,DOUBLE); /* Copy left derivatives */\n          else\n\t    {\n\t      s1221(pc,2,tx2,&kleft,sder,&kstat);\n\t      if (kstat<0) goto error;\n\t    }\n\n\t  /* Remember length of start tangent, end of zero segment */\n\n\t  tlengthend = s6length(sder+kdim,kdim,&kstat);\n\t  if (kstat<0) goto error;\n\n\n\n\t  /* Calculate unit tangent and radius of curvature */\n\n\t  s1307(sder,kdim,s3dinf+(3*kdim+1)*knbinf,&kstat);\n\t  if (kstat<0) goto error;\n\n\t  /* Decide if Hermit shape acceptable and find position and tangent\n\t     at midpoint of segment */\n\n\t  start = s3dinf + (3*kdim+1)*(knbinf-1);\n\n\t  s1361(start,start+(3*kdim+1),kdim,smidd,smtang,&kstat);\n\t  if (kstat<0) goto error;\n\n\t  /* Iterate to midpoint of segment, start from middle of [tx1,tx2].\n\t     The iteration is performed to find the intersection between the\n\t     plane described by smidd and smtang. */\n\n\t  txm = (tx1+tx2)/(double)2.0;\n\n\t  kcont = 1;\n\t  kdiv  = 0;\n\n\t  knbit = 0;\n\t  while (kcont==1)\n            {\n\n\t      /* Calculate position and tangent at txm */\n\n\t      s1362(pc,aoffset,enorm,idim,kder,txm,&kleft,sder,&kstat);\n\t      if (kstat<0) goto error;\n\n\t      /* Make difference of calculated point and smidd, project this\n\t\t onto the normal of the plane. */\n\n\t      s6diff(sder,smidd,kdim,sdiff);\n\t      tproj1 = s6scpr(sdiff,smtang,kdim);\n\t      tproj2 = s6scpr(&sder[kdim],smtang,kdim);\n\n\t      /* If tproj2==0 then curve tangent normal to plane, half step\n\t\t length */\n\n\t      if (DEQUAL(tproj2,DZERO))\n                {\n\t\t  kdiv  = 1;\n\t\t  kcont = 0;\n                }\n\t      else if (knbit==0)\n                {\n\t\t  /* First iteration */\n\t\t  knbit = 1;\n\t\t  txm -= tproj1/tproj2;\n\t\t  txm = MAX(tx1,txm);\n\t\t  txm = MIN(tx2,txm);\n\t\t  tlast = fabs(tproj1);\n                }\n\n\t      else if (fabs(tproj1)>=tlast)\n                {\n\t\t  /* Not convergence any longer */\n\t\t  kcont = 0;\n                }\n\t      else\n                {\n\t\t  /* Still convergence */\n\t\t  txm   -= tproj1/tproj2;\n\t\t  tlast  = fabs(tproj1);\n\t\t  knbit += 1;\n\t\t  if (txm <=tx1 || tx2 <= txm)\n                    {\n\t\t      kdiv  = 1;\n\t\t      kcont = 0;\n                    }\n                }\n            }\n\t  /* Find how close the midpoint position and tangent of the segement\n\t     is to the true curve */\n\n\t  tdist = s6dist(sder,smidd,kdim);\n\n\t  tang  = s6ang(&sder[kdim],smtang,kdim);\n\n\t  /* If the point is not within the resolution treat it as divergence, except\n\t     when the segment length is less than aepsge */\n\n\t  if ((s6dist(start,smidd,kdim) <= aepsge) &&\n\t      (s6dist(start+(3*kdim+1),smidd,kdim) <= aepsge))\n\t    {\n\t      kdiv = 0;\n\t    }\n\t  else if (fabs(tdist) > aepsge || fabs(tang) > ANGULAR_TOLERANCE)\n            {\n\t      kdiv = 1;\n            }\n\n\t  /* Dependent on previous conditions decide if the segment is acceptable\n\t     or not */\n\n\t  if (kdiv==0)\n            {\n\t      /* Segement acceptable */\n\t      notaccepted = 0;\n            }\n\t  else\n            {\n\t      /* Segment unacceptable. Remember that the error of the Hermit\n\t\t interpolation is O(h**4). Thus taking this into consideration\n\t\t we can determin the new parameter interval. */\n\n\t      tfak = MAX(tdist/aepsge,(double)1.0);\n\t      tfak = (double)2.0*pow(tfak,ONE_FOURTH);\n\n\t      tnew = MIN(tincre/(double)2.0,(tx2-tx1)/tfak);\n\t      if (DEQUAL(tmax+tnew,tmax+tincre)) goto err179;\n\t      tincre = tnew;\n\t      tx2 = tx1 + tincre;\n            }\n        }\n\n      /*  Store segment information */\n\n      if (kmult>kk-2)\n\t{\n          /* End of segment is possible break, add exstra version of point */\n\n          if (aoffset != DZERO)\n\t    {\n\t      spar[knbinf] = tx2-(double)0.1*(tx2-spar[knbinf-1]);\n\t      s1362(pc,aoffset,enorm,idim,kder,tx2,&kleft,sder,&kstat);\n\t      if (kstat<0) goto error;\n\t    }\n          else\n\t    {\n\t      spar[knbinf] = tx2;\n\t      memcopy(sder,sder1,3*kdim,DOUBLE);/*Copy right hand derivatives*/\n\t    }\n\n          knbinf++;\n\n\t  /* Remember length of start tangent, end of zero segment */\n\n\t  tlengthend = s6length(sder+kdim,kdim,&kstat);\n\t  if (kstat<0) goto error;\n\n\t  /* Calculate unit tangent and radius of curvature */\n\n\t  s1307(sder,kdim,s3dinf+(3*kdim+1)*knbinf,&kstat);\n\t  if (kstat<0) goto error;\n\t}\n\n      /*  Make knots */\n      spar[knbinf] = tx2;\n\n      if (kstat<0) goto error;\n      knbinf += 1;\n\n      /*  Make new step length */\n\n      /*  Calculate step length based on curvature */\n\n      tstep = s1311(s3dinf[(3*kdim+1)*knbinf-1],aepsge,tmax,&kstat);\n      if (kstat<0) goto error;\n\n      /*  Update start parameter value of segment */\n\n      tx1 = tx2;\n    }\n\n\n  /*  Interpolate offset curve */\n\n  /* UJK, 92.04. : s1312 and s1359 shadow functions\n     s1312(s3dinf,kdim,knbinf,kpar,spar,rc,&kstat); */\n  s1359(s3dinf,aepsge,kdim,knbinf,kpar,spar,rc,&kstat);\n  if (kstat < 0) goto error;\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in memory allocation */\n\n err101:\n  *jstat = -101;\n  s6err(\"s1360\",*jstat,kpos);\n  goto out;\n\n  /* Error in input, dimension not equal to 2 or 3 */\n\n err105:\n  *jstat = -105;\n  s6err(\"s1360\",*jstat,kpos);\n  goto out;\n\n\n err179:\n  *jstat = -179;\n  s6err(\"s1360\",*jstat,kpos);\n  goto out;\n\n  /* Negative aepsge */\n\n err184:\n  *jstat = -184;\n  s6err(\"s1360\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level function */\n\n error:\n  *jstat = kstat;\n  s6err(\"s1360\",*jstat,kpos);\n  goto out;\n\n out:\n  if (s3dinf != SISL_NULL) freearray(s3dinf);\n  if (spar   != SISL_NULL) freearray(spar);\n  return;\n}\n"
  },
  {
    "path": "src/s1361.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1361.c,v 1.2 2001-03-19 15:58:47 afr Exp $\n *\n */\n#define S1361\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1361(double epnt1[],double epnt2[],int idim,\n\t   double gmidd[],double gmtang[],int *jstat)\n#else\nvoid s1361(epnt1,epnt2,idim,gmidd,gmtang,jstat)\n     double epnt1[];\n     double epnt2[];\n     int    idim;\n     double gmidd[];\n     double gmtang[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To determint if the shape described by the input, points,\n*              tangents, curvatures and radius of curvature when used\n*              for making an Hermit segment, have a shape close to\n*              a circular arc.\n*\n* INPUT      : epnt1   - Start point with tangent, curvature and radius\n*                        of curvature.\n*              epnt2   - End point with tangent, curvature and radius\n*                        of curvature.\n*              idim    - The dimension of the space the point lie in\n*              gmidd   - The middle point of the Bezier segement\n*              gmtang  - The tangent at the middle of the Bezier segment\n*\n*\n* OUTPUT     : jstat   - Status variable\n*                         0 - Shape not acceptabel\n*                         1 - Shape acceptable\n*\n* METHOD     : \n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. 18. Oct 1988\n*              UJK, October 1990, Included test for negative curvature. \n*********************************************************************\n*/                        \n{\n  double tang1,tang2;    /* Tangent lengths */\n  double tscal1,tscal2;  /* The cosine of an angle         */\n  double ta1,ta2;        /* An angle                       */\n  double tlength;        /* The length of a vector         */\n  double tdiff;          /* Difference between two numbers */\n  double tdist;          /* Distance between points        */\n  double tv2,tv3;        /* Vertex compnents               */\n  int    ki;             /* Variable in loop               */\n  int    kstat;          /* Local status variable          */\n  \n  /* Find angle between tangents of epnt1 and epnt2, we assume that\n     the tangents are normalized */\n  \n  tscal1  = s6scpr(epnt1+idim,epnt2+idim,idim);\n  \n  if (tscal1 >= DZERO)\n    tscal1  = MIN((double)1.0,tscal1);\n  else\n    tscal1  = MAX((double)-1.0,tscal1);\n  \n  ta1 = acos(tscal1);\n  \n  if (fabs(ta1) < ANGULAR_TOLERANCE) ta1 = DZERO;\n  \n  \n  /* Make distance between epnt1 and epnt2 */\n  \n  tdist = s6dist(epnt1,epnt2,idim);\n  \n  /* Make tangent lengths for start and end points */\n  \n  if (DNEQUAL(ta1,DZERO))\n    {\n      /*  Make tangents based on radius of curvature */\n      \n      tang1 = s1325(epnt1[3*idim],ta1);\n      tang2 = s1325(epnt2[3*idim],ta1);\n    }\n  \n  /* Make sure that the tangent does not explode due to numeric errors, and\n     make a controlled tangent when the radius is zero or almost zero  */\n  \n  /* UJK, October 90, must include the case negative curvature */\n  if (DEQUAL(ta1,DZERO) || tang1 > tdist || epnt1[3*idim] <= DZERO)\n    tang1 = tdist/(double)3.0;\n  if (DEQUAL(ta1,DZERO) || tang2 > tdist || epnt2[3*idim] <= DZERO) \n    tang2 = tdist/(double)3.0;\n  \n  \n  /* We now know the Bezier polygon of the Hermit curve. Make angles\n     between line 1 and 2 and between line 2 and 3. Make length of line 3\n     */\n  \n  tscal1 = DZERO;\n  tscal2 = DZERO;\n  tlength = DZERO;\n  \n  for (ki=0;ki<idim;ki++)\n    {\n      /*  Make difference between second and third vertex, and accumulte\n\t  scalar products between polygon lines */\n      tv2 = epnt1[ki] + tang1*epnt1[ki+idim]; \n      tv3 = epnt2[ki] - tang2*epnt2[ki+idim];\n      tdiff = tv3 - tv2 ;\n      tlength += tdiff*tdiff;\n      tscal1  += tdiff*epnt1[ki+idim]; \n      tscal2  += tdiff*epnt2[ki+idim];\n      \n      /*  Make midpoint and tangent at midpoint */\n      \n      gmidd[ki]  = (epnt1[ki] + (double)3.0*(tv2+tv3) + epnt2[ki])/(double)8.0;\n      gmtang[ki] = (epnt2[ki] + tv3 - tv2 - epnt1[ki])/(double)8.0;\n      \n    }                                                      \n  tlength = sqrt(tlength);\n  if (DEQUAL(tlength,DZERO)) tlength = (double)1.0;\n  \n  tscal1 = tscal1/tlength;\n  tscal2 = tscal2/tlength;\n\n  if (tscal1 >= DZERO)\n    tscal1  = MIN((double)1.0,tscal1);\n  else\n    tscal1  = MAX((double)-1.0,tscal1);\n\n  if (tscal2 >= DZERO)\n    tscal2  = MIN((double)1.0,tscal2);\n  else\n    tscal2  = MAX((double)-1.0,tscal2);\n  \n  ta1    = acos(tscal1);\n  ta2    = acos(tscal2);\n  \n  /* Normalize tangent at midpoint */\n  \n  (void)s6norm(gmtang,idim,gmtang,&kstat);\n  \n  \n  /* Make total angular change of polygon */\n  \n  ta1 = fabs(ta1) + fabs(ta2);\n  \n  /* If total angular change is greater than PI/3 or the length is greater\n     than 0.45 x the distance don't accept. The last condition make sure\n     that the middle span in the polygon is less that what we get when\n     we have a 90 circular arc. The first condition makes sure that the\n     polygon direction is not oscillating too much*/\n  \n  if (ta1 > (double)1.0 || tlength > (double)0.45*tdist)\n    *jstat = 0;\n  else\n    *jstat = 1;\n}\n\n"
  },
  {
    "path": "src/s1362.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1362.c,v 1.2 2001-03-19 15:58:47 afr Exp $\n *\n */\n\n\n#define S1362\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1362(SISLCurve *pc1,double aoffset,double enorm[],int idim,\n\t   int ider,double ax,int *ileft,double eder[],int *jstat)\n#else\nvoid s1362(pc1,aoffset,enorm,idim,ider,ax,ileft,eder,jstat)\n     SISLCurve *pc1;\n     double       aoffset;\n     double       enorm[];\n     int          idim;\n     int          ider;\n     double       ax;\n     int          *ileft;\n     double       eder[];\n     int          *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the value and ider<=2 first derivatives of\n*              the offset curve to the B-spline curve pointed to by pc1,\n*              at the point with parameter value ax.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve for which position\n*                       and derivatives are to be computed.\n*              aoffset- Offset distance\n*              enorm  - Only used when idim==3\n*              idim   - Dimension of the space the curve lies in 2 or 3\n*              ider   - The number of derivatives to compute.\n*                       < 0 : Error.\n*                       = 0 : Compute position.\n*                       = 1 : Compute position and first derivative.\n*                       etc.\n*              ax     - The parameter value at which to compute\n*                       position and derivatives.\n*\n*                \n*\n* INPUT/OUTPUT : ileft - Pointer to the interval in the knot vector\n*                        where ax is located. If et is the knot vector,\n*                        the relation\n*                          \n*                          et[ileft] <= ax < et[ileft+1]\n* \n*                        should hold. (If ax == et[in] then ileft should\n*                        be in-1. Here in is the number of B-spline\n*                        coefficients.)\n*                        If ileft does not have the right value upon\n*                        entry to the routine, its value will be changed\n*                        to the value satisfying the above condition.\n*\n*\n*\n* OUTPUT     : eder   - Double array of dimension [(ider+1)*idim]\n*                       containing the position and derivative vectors.\n*                       (idim is the number of components of each B-spline\n*                       coefficient, i.e. the dimension of the Euclidean\n*                       space in which the curve lies.)\n*                       These vectors are stored in the following order:\n*                       First the idim components of the position vector,\n*                       then the idim components of the tangent vector,\n*                       then the idim components of the second derivative\n*                       vector, and so on.\n*                       (The C declaration of eder as a two dimensional array\n*                       would therefore be eder[ider+1,idim].)\n*              jstat  - Status messages  \n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : The offset curve is made in the following way:\n*\n*              q(u) = p(u) + aoffset N(u)\n*\n*              For idim==2: N(u) = (-y'(u),x'(u))\n*\n*              For idim==3: N(u) = p'(u)xenorm\n*\n*              The derivatives of these expressions are calculated:\n*\n*\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1221, s6length, s6crss, s6scpr, s6err\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, October 1988\n*\n*********************************************************************\n*/                                     \n{\n  int kstat=0;        /* Local status variable.                          */\n  int kpos=0;         /* The position of the error.                      */\n  int kder=ider+1;    /* Derivatives necessary to calculate              */\n  int ki,kj;          /* Loop variable                                   */\n  double sder[12];    /* Storage of derivatives                          */\n  double snorm[3];    /* Normal to tangent vector                        */\n  double sdnorm[3];   /* Derivative of normal to tangent                 */\n  double sddnorm[3];  /* Second derivative to normal of tangent          */\n  double tderl;       /* Length of the first derivative                  */\n  double tl;          /* The length of the derivative vector             */\n  double *spnt;       /* Pointer to derivative                           */\n  double *start;      /* Pointer to derivative                           */\n  \n  if (idim !=2 && idim != 3) goto err105;\n  \n  if (DEQUAL(aoffset,DZERO))\n    {\n      s1221(pc1,ider,ax,ileft,eder,&kstat);\n      if (kstat<0) goto error;\n    }\n  else\n    {\n      s1221(pc1,kder,ax,ileft,sder,&kstat);\n      if (kstat<0) goto error;\n      \n      tderl = s6length(sder+idim,idim,&kstat);\n      if (DEQUAL(tderl,DZERO)) tderl = (double)1.0;\n      \n      /* The tangent length might be very different from 1. scale it and\n\t higher order derivatives to give tangent length one, this may give\n\t over or underflow in the calculations */\n      \n      \n      for (ki=1,start=sder+idim ; ki<=kder ; ki++,start+=idim)\n        {\n\t  for (kj=0,spnt=start ; kj<idim*(kder+1-ki) ; kj++,spnt++)\n            {\n\t      *spnt /= tderl;\n            }\n        }\n      \n      \n      if (idim==2)\n        {\n\t  snorm[0]   = -sder[3];\n\t  snorm[1]   =  sder[2];\n\t  if(ider>=1)\n\t    {                                                           \n\t      sdnorm[0]  = -sder[5];\n\t      sdnorm[1]  =  sder[4];\n\t      if(ider>=2)\n\t\t{\n\t\t  sddnorm[0] = -sder[7];\n\t\t  sddnorm[1] =  sder[6];\n\t\t}\n\t    }\n        }\n      else\n        {\n\t  s6crss(sder+idim,enorm,snorm);\n\t  if (ider>=1)\n\t    {\n\t      s6crss(sder+2*idim,enorm,sdnorm);\n\t      if (ider>=2)\n\t\ts6crss(sder+3*idim,enorm,sddnorm);\n\t    }\n        }\n      \n      tl = s6length(snorm,idim,&kstat);\n      if (DEQUAL(tl,DZERO)) tl = (double)1.0;\n      \n      /* Calculate position on offset curve */\n      \n      for (ki=0;ki<idim;ki++)\n        eder[ki] = sder[ki] + aoffset*snorm[ki]/tl;\n      \n      if (ider>=1)\n        {\n\t  double tpndpn;         /* The scalar product: snorm sdnorm */\n\t  double tl3=tl*tl*tl;   /* tl**3 */\n\t  \n\t  tpndpn = s6scpr(snorm,sdnorm,idim);\n\t  \n\t  \n\t  /*  Calculate derivative of offset curve */\n\t  for (ki=0;ki<idim;ki++)\n            {\n\t      eder[idim+ki] = sder[idim+ki] + aoffset*(sdnorm[ki]/tl\n\t\t\t    - snorm[ki]*tpndpn/tl3);\n            }\n\t  if (ider>=2)\n            {\n\t      double tl5= tl3*tl*tl; /* tl**5 */\n\t      double tpnddpn;         /* The scalar product: snorm sddnorm */\n\t      double tdpndpn;         /* The scalar product: sdnorm sdnorm */\n\t      \n\t      tpnddpn = s6scpr(snorm,sddnorm,idim);\n\t      tdpndpn = s6scpr(sdnorm,sdnorm,idim); \n\t      \n\t      \n\t      /*      Calculate derivative of offset curve */\n\t      for (ki=0;ki<idim;ki++)\n                {\n\t\t  eder[2*idim+ki] = sder[2*idim+ki] + aoffset*(sddnorm[ki]/tl\n\t\t\t\t  - (double)2.0*sdnorm[ki]*tpndpn/tl3\n\t\t\t\t  - snorm[ki]*(tdpndpn+tpnddpn)/tl3\n\t\t\t\t  + (double)3.0*snorm[ki]*tpndpn*tpndpn/tl5);\n                }\n            }\n        }\n      \n      \n      /* Scale the derivatives to match the original parametrization,\n\t the kder=ider+1 derivative is not given as output  */\n      \n      for (ki=1,start=eder+idim ; ki<kder ; ki++,start+=idim)\n        {\n\t  for (kj=0,spnt=start ; kj<idim*(kder-ki) ; kj++,spnt++)\n            {\n\t      *spnt *= tderl;\n            }\n        }\n    }\n  /* Successful computations.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  \n  /* idim not 2 0r 3 */\n err105: *jstat = -105;\n  s6err(\"s1362\",*jstat,kpos);\n  goto out;\n  \n  \n  /* Error in lower level routine.  */\n  \n error:  *jstat = kstat;\n  s6err(\"s1362\",*jstat,kpos);\n  goto out;\n  \n out: return;\n}\n"
  },
  {
    "path": "src/s1363.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1363.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1363\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1363(SISLCurve *pc,double *cmin,double *cmax,int *jstat)\n#else\nvoid s1363(pc,cmin,cmax,jstat)\n     SISLCurve  *pc;\n     double *cmin;\n     double *cmax;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To pick the parametrization of a B-spline curve\n*\n* INPUT      : pc     - The B-spline curve.   \n*\n* OUTPUT     : \n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*              cmin   - Start of parametrization of curve\n*              cmax   - End of parametrization of curve\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-                                                 \n* CALLS      : s6err\n*              \n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. Nov 1988\n*\n*********************************************************************\n*/\n{\n  int kstat;          /* Local status variable                           */\n  int kpos=0;         /* Position of error                               */\n  \n  /* Check if curve is correct */\n  \n  s1707(pc,&kstat);\n  if (kstat<0) goto error;\n  \n  /* Pick parametrization */\n  \n  *cmin = pc->et[pc->ik - 1];\n  *cmax = pc->et[pc->in];\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in lower level function */\n  \n error:  *jstat = kstat;\n  s6err(\"s1363\",*jstat,kpos);\n  goto out;\n out:\n  \n  return;\n}          \n"
  },
  {
    "path": "src/s1364.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1364.c,v 1.2 2001-03-19 15:58:47 afr Exp $\n *\n */\n\n\n#define S1364\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1364(SISLCurve *pc,double aepsge,int *jstat)\n#else\nvoid s1364(pc,aepsge,jstat)\n     SISLCurve  *pc;\n     double aepsge;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To decide if a B-spline curve is closed within a\n*              tolerance\n*\n* INPUT      : pc     - The B-spline curve.   \n*              aepsge - Geometric tolerance\n*\n* OUTPUT     : \n*              jstat  - status messages  \n*                                         = 1      : SISLCurve closed\n*                                         = 0      : SISLCurve open\n*                                         < 0      : error\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-                                                 \n* CALLS      : s1221, s6dist, s6err\n*              \n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. Nov 1988\n*\n*********************************************************************\n*/\n{\n  int kn;             /* The number of B-splines, i.e., the dimension of\n\t\t\t the spline space associated with the knot\n\t\t\t vector.                                         */\n  int kk;             /* The polynomial order of the curve.              */\n  int kdim;           /* Dimension of space                              */\n  int kleft=0;        /* Pointer to knots                                */\n  int kder=0;         /* Derivatives to be calculated                    */\n  int kstat;          /* Local status variable                           */\n  int kpos=0;         /* Position of error                               */\n  double *st;         /* Pointer to the first element of the knot vector\n\t\t\t of the curve. The knot vector has [kn+kk]\n\t\t\t elements.                                       */\n  double sdum1[3];    /* Arrays for calculation of points                */ \n  double sdum2[3];    /* Arrays for calculation of points                */\n  double *sder1 = SISL_NULL; /* Pointers to points                            */\n  double *sder2 = SISL_NULL; /* Pointers to points                            */\n  double tdist;       /* Distance between points                         */\n  \n  /* Check if curve is correct */\n  \n  s1707(pc,&kstat);\n  if (kstat<0) goto error;\n  \n  \n  /* Copy curve attributes to local parameters.  */\n  \n  kn = pc -> in;\n  kk = pc -> ik;\n  kdim = pc -> idim;\n  st = pc -> et;\n  \n  if (kdim>3)\n    {\n      sder1 = newarray(kdim,DOUBLE);\n      sder2 = newarray(kdim,DOUBLE);\n    }\n  else\n    {\n      sder1 = sdum1;\n      sder2 = sdum2;\n    }\n  \n  /* Calculate start point of curve */\n  \n  s1221(pc,kder,st[kk-1],&kleft,sder1,&kstat);\n  if (kstat<0) goto error;\n  \n  /* Calculate end point of curve */\n  \n  s1221(pc,kder,st[kn],&kleft,sder2,&kstat);\n  if (kstat<0) goto error;\n  \n  tdist = s6dist(sder1,sder2,kdim);\n  \n  if (tdist>aepsge)\n    *jstat = 0;\n  else\n    *jstat = 1;\n  goto out;\n  \n  /* Error in lower level function */\n  \n error:  *jstat = kstat;\n  s6err(\"s1364\",*jstat,kpos);\n  goto out;\n out:\n  \n  if (kdim>3)\n    {\n      if (sder1 != SISL_NULL) freearray(sder1);\n      if (sder2 != SISL_NULL) freearray(sder2);\n    }\n  \n  return;\n}          \n"
  },
  {
    "path": "src/s1365.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1365.c,v 1.5 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1365\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1365(SISLSurf *ps, double aoffset, double aepsge, double amax,\n\t   int idim, SISLSurf **rs, int *jstat)\n#else\nvoid s1365(ps,aoffset,aepsge,amax,idim,rs,jstat)\n     SISLSurf   *ps;\n     double aoffset;\n     double aepsge;\n     double amax;\n     int    idim;\n     SISLSurf   **rs;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To create a B-spline approximating the offset surface of\n*              a NURBS surface.\n*\n*\n*\n* INPUT      : ps     - The input NURBS surface.\n*              aoffset- The offset distance.\n*                       The offset is determined by the cross\n*                       product of the tangent vector and the anorm vector.\n*                       The offset distance is multiplied by this vector.\n*              aepsge - Maximal deviation allowed between true offset surface\n*                       and the approximated offset surface.\n*              amax   - Maximal stepping length. Is negleceted if amax<=aepsge\n*                       If amax==0 then a maximal step length of the longest\n*                       box side is used.\n*              idim   - The dimension of the space (idm = 3 is required).\n*\n* OUTPUT     :\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*              rs     - Pointer the approximated offset surface\n*\n* METHOD     : The 4 edge curves of the surface are extracted. Offset curves\n*              of these 4 edge curves are approximated and a common\n*              basis for the two pairs of opposite offset curves is calculated.\n*              Vertices are recomputed.\n*\n* EXAMPLE OF USE:\n*\n*\n* REFERENCES :\n*\n*\n*-\n* CALLS      : s1435     - Pick a given edge-curve of a B-spline surface.\n*              s1360     - Approximate the offset curve of a NURBS curve.\n*              s1933     - Put a set of curves on a common basis.\n*              s1366     - Create a B-spline surface approximating the offset\n*                          surface of a B-spline surface\n*\n* WRITTEN BY : Per Evensen,  SI, 89-3.\n* REWISED BY : Per Evensen,  SI, 90-9; Corrected start/end parameter values of\n*                                      common curves.\n*\n*********************************************************************\n*/\n{\n  SISLCurve *pc[4];\n  SISLCurve *rc[4],*rc13[2],*rc24[2];\n  int kstat = 0;     /* Local status variable.                           */\n  int kpos = 0;      /* Position of error.                               */\n  int kdim;          /* Dimension of the space in which the surface lies.*/\n  int knbcrv = 2;    /* Number of curves in set. */\n  /*  int kopen = 1;      Flag telling that the resulting surface should\n\t\t\tbe open in both parameter directions. */\n  int kn13,kord13;   /* Number of vertices and order of edge curves along\n\t\t\t1. parameter direction. */\n  int kn24,kord24;   /* Number of vertices and order of edge curves along\n\t\t\t2. parameter direction. */\n  int nder[4];       /* Number of edges along each surface edge.         */\n  double sp[4];      /* Parameter value of edge in constatnt direction.  */\n  double toffset = (double)0.0; /* Local offset value for extraction of edge-\n\t\t\t\t   curves. */\n  double snorm[3];   /* Local normal vector for extraction of edge-curves. */\n  double tstart1,tend1; /* Endpoints of parameter interval in first\n\t\t\t   direction.                                     */\n  double tstart2,tend2; /* Endpoints of parameter interval in second\n\t\t\t   direction.                                     */\n  double *sknot13=SISL_NULL;/* Pointer to common knot-vector of edge curves along\n\t\t\t  1. parameter direction. */\n  double *sknot24=SISL_NULL;/* Pointer to common knot-vector of edge curves along\n\t\t\t  2. parameter direction. */\n  int  kk;              /* Loop controller. */\n\n  /* Initialization of variables */\n  kdim = ps -> idim;\n  for (kk=0; kk<4; kk++)\n  {\n     nder[kk] = 1;\n     pc[kk] = SISL_NULL;\n     rc[kk] = SISL_NULL;\n  }\n  for (kk=0; kk<3; kk++) snorm[kk] = DZERO;\n\n  /* Fetch the 4 edge-curves of surface */\n\n  for (kk=0; kk<4; kk++)\n    {\n      s1435(ps,kk,&pc[kk],&sp[kk],&kstat);\n      if (kstat < 0) goto error;\n    }\n\n  /* Create a B-spline curve approximating the offset curve of the 4 edges */\n\n  for (kk=0; kk<4; kk++)\n    {\n      s1360(pc[kk],toffset,aepsge,snorm,amax,kdim,&rc[kk],&kstat);\n      if (kstat<0) goto error;\n    }\n\n  /* Rearrange the pointers to the 4 edge curves. */\n\n  rc13[0] = rc[0];\n  rc13[1] = rc[2];\n  rc24[0] = rc[1];\n  rc24[1] = rc[3];\n\n  /* Fetch endpoints of parameter intervals.  */\n\n  tstart1 = *(ps->et1 + ps->ik1 - 1);\n  tend1 = *(ps->et1 + ps->in1);\n  tstart2 = *(ps->et2 + ps->ik2 - 1);\n  tend2 = *(ps->et2 + ps->in2);\n\n  /* Put the edge curves along 1. parameter direction into common basis. */\n\n  s1933(knbcrv,rc13,tstart1,tend1,&sknot13,&kn13,&kord13,&kstat);\n  if (kstat<0) goto error;\n\n  /* Put the edge curves along 2. parameter direction into common basis. */\n\n  s1933(knbcrv,rc24,tstart2,tend2,&sknot24,&kn24,&kord24,&kstat);\n  if (kstat<0) goto error;\n\n  /* Create a B-spline surface approximating the offset surface of a B-spline\n     surface. */\n\n  s1366(ps,aoffset,aepsge,amax,idim,sknot13,kn13,kord13,\n\tsknot24,kn24,kord24,rs,&kstat);\n  if (kstat<0) goto error;\n\n  /* Surface approximated. */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n  s6err(\"s1365\",*jstat,kpos);\n  goto out;\n\n  out:\n     for (kk=0; kk<4; kk++)\n     {\n\tif (pc[kk] != SISL_NULL) freeCurve(pc[kk]);\n\tif (rc[kk] != SISL_NULL) freeCurve(rc[kk]);\n     }\n     if (sknot13 != SISL_NULL) freearray(sknot13);\n     if (sknot24 != SISL_NULL) freearray(sknot24);\n\n     return;\n}\n"
  },
  {
    "path": "src/s1366.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1366.c,v 1.7 2001-03-19 15:58:47 afr Exp $\n *\n */\n\n\n#define S1366\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1366(SISLSurf *ps, double aoffset, double aepsge, double amax, int idim,\n\t   double *eknot13, int in13, int ik13,\n\t   double *eknot24, int in24, int ik24,\n\t   SISLSurf **rs, int *jstat)\n#else\nvoid s1366(ps,aoffset,aepsge,amax,idim,eknot13,in13,ik13,\n\t   eknot24,in24,ik24,rs,jstat)\n     SISLSurf   *ps;\n     double aoffset;\n     double aepsge;\n     double amax;\n     int    idim;\n     double *eknot13;\n     int    in13;\n     int    ik13;\n     double *eknot24;\n     int    in24;\n     int    ik24;\n     SISLSurf   **rs;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To create a B-spline approximating the offset surface of\n*              a B-spline surface.\n*\n*\n*\n* INPUT      : ps     - The input B-spline surface.\n*              aoffset- The offset distance.\n*                       The offset is determined by the cross\n*                       product of the tangent vector and the anorm vector.\n*                       The offset distance is multiplied by this vector.\n*              aepsge - Maximal deviation allowed between true offset surface\n*                       and the approximated offset surface.\n*              amax   - Maximal stepping length. Is negleceted if amax<=aepsge\n*              idim   - The dimension of the space (3).\n*              eknot13- Pointer to common knot-vector along first parameter\n*                       direction.\n*              in13   - Number of vertices of knot-vector along first\n*                       parameter direction.\n*              ik13   - Order of knot-vector along first parameter direction.\n*              eknot24- Pointer to common knot-vector along second parameter\n*                       direction.\n*              in24   - Number of vertices of knot-vector along second\n*                       parameter direction.\n*              ik24   - Order of knot-vector along second parameter direction.\n*\n* OUTPUT     :\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*              rs     - Pointer the approximated offset surface\n*\n* METHOD     : Points, derivatives, cross derivatives and normals are calcu-\n*              lated on selected points on the surface. The selected points\n*              corresponds to parameter-pairs of all specific values of the\n*              knot-vector. The offset values of these points are calculated.\n*\n* EXAMPLE OF USE:\n*\n*\n* REFERENCES :\n*\n*\n*-\n* CALLS      : s1367     - Evaluate the surface at a given parameter pair\n*                          value.\n*              s1347     - Interpolate a bicubic hermite spline-approximation\n*                          surface.\n*\n* WRITTEN BY : Per Evensen,  SI, 89-4.\n* REWISED BY : Per Evensen,  SI, 90-9 Corrected pointers.\n* REWISED BY : Paal Fugelli, SINTEF, 1994-07 Added free'ing of allocated\n*              memory (at end) to fix memory leakage problem.\n*              1994-09 Added error checks after calls to increasearray() macros\n*                      and changed usage style of 'kmaxik'.\n*********************************************************************\n*/\n{\n  int kstat = 0;     /* Local status variable.                           */\n  int kpos = 0;      /* Position of error.                               */\n  int ki;            /* Loop controller. */\n  int kk1;           /* Loop controller. */\n  int kk2;           /* Loop controller. */\n\n  int kder = 1;      /* Number of derivatives necessary to achieve.      */\n  int klfs=0;       /* Pointer to knot interval.                        */\n  int klft=0;       /* Pointer to knot interval.                        */\n  int knbpnt=0;      /* Number of points stored. */\n  int km1=1;         /* Counter of points in 1. parameter direction. */\n  int km2=1;         /* Counter of points in 2. parameter direction. */\n  int kain=0;        /* Array index. */\n  int kmaxis=512;    /* Number of vertices space is allocated for       */\n  int kmaxik1=512;   /* Number of vertices along first parameter direction which\n\t\t\tspace is allocated for. */\n  int kmaxik2=512;   /* Number of vertices along second parameter direction which\n\t\t\tspace is allocated for. */\n  int kpar=3;        /* Flag determining the parametrization of the data-points.\n\t\t\t= 1: Mean accumulated cord length parametrization.\n\t\t\t= 2: Uniform parametrization.\n\t\t\t= 3: Parametrization given by spar1 and spar2. */\n  int lend[4];       /* Array containing the no. of derivatives to be kept fixed\n\t\t\talong each of the edges of teh surface. */\n  int kopt=3;        /* Flag indicating the order in which the data-reduction\n\t\t\tis to be performed. */\n  int ktmax=10;      /* Max. number of itarations. */\n  double *spar1;     /* Array (length km1) containing a parametrization in the\n\t\t\t1. parameter direction. */\n  double *spar2;     /* Array (length km2) containing a parametrization in the\n\t\t\t2. parameter direction. */\n  double seps[3];    /* Array containing the maximum deviation which is\n\t\t\tacceptable in each of the idim components of the\n\t\t\tsurface (except possibly along the edges). */\n  double sedgeps[12];/* Array containing the max. deviation which is acceptable\n\t\t\talong the edges of teh surface. */\n  double tepsco;     /* Computer resolution. */\n  double smxerr[3];  /* Array containing an upper bound for the error comitted\n\t\t\tin each component during the data reduction. */\n  double *spnt=SISL_NULL; /* Pointer to storage of point info. */\n  double *stng1=SISL_NULL;/* Pointer to derivatives in 1. parameter direction. */\n  double *stng2=SISL_NULL;/* Pointer to derivatives in 2. parameter direction. */\n  double *scrss=SISL_NULL; /* Pointer to cross derivatives. */\n  double spar[2];    /* Parameter value at where to evaluate surface.    */\n  double sder[27];   /* Pointer to array containing the derivatives.     */\n\n  /* Initialization of variables */\n  tepsco = (double)0.000001;\n\n  for (ki=0; ki<3; ki++) seps[ki] = aepsge;\n\n  for (ki=0; ki<4; ki++) lend[ki] = 1;\n\n  for (ki=0; ki<12; ki++) sedgeps[ki] = aepsge;\n\n  /* Allocate space for storage of points, derivatives and cross-derivatives. */\n\n  spnt = newarray(idim*kmaxis,DOUBLE);\n  if (spnt == SISL_NULL) goto err101;\n\n  stng1 = newarray(idim*kmaxis,DOUBLE);\n  if (stng1 == SISL_NULL) goto err101;\n\n  stng2 = newarray(idim*kmaxis,DOUBLE);\n  if (stng2 == SISL_NULL) goto err101;\n\n  scrss = newarray(idim*kmaxis,DOUBLE);\n  if (scrss == SISL_NULL) goto err101;\n\n  /* Allocate space for storage of parametrization in 1. direction. */\n\n  spar1 = newarray(kmaxik1,DOUBLE);\n  if (spar1 == SISL_NULL) goto err101;\n\n  /* Allocate space for storage of parametrization in 2. direction. */\n\n  spar2 = newarray(kmaxik2,DOUBLE);\n  if (spar2 == SISL_NULL) goto err101;\n\n  /* Initiate parameter value in first and second parameter direction. */\n  spar[0] = eknot13[ik13-1];\n  spar[1] = eknot24[ik24-1];\n\n  /* Evaluate the surface (ps) at the parameter value spar.  */\n  s1367(ps,aoffset,aepsge,idim,spar,kder,&klfs,&klft,sder,&kstat);\n  if (kstat<0) goto error;\n\n  /* Store information about points, derivatives and cross-derivative. */\n  for (ki=0; ki<idim; ki++)\n  {\n    spnt[kain] = sder[ki];\n    stng1[kain] = sder[ki+idim];\n    stng2[kain] = sder[ki+2*idim];\n    scrss[kain] = sder[ki+3*idim];\n    kain += 1;\n  }\n\n  /* Store parametrization along both parameter directions. */\n  spar1[km1-1] = spar[0];\n  spar2[km2-1] = spar[1];\n\n  knbpnt += 1;\n\n  for (kk1=ik13; kk1<=in13; kk1++)\n  {\n\n    /* check if current knot-value in first parameter direction is\n       equal the previous or not. */\n    if (DNEQUAL(spar[0],eknot13[kk1]))\n    {\n\n      /* Evaluate the surface (ps) at the parameter value spar.  */\n      spar[0] = eknot13[kk1];\n      s1367(ps,aoffset,aepsge,idim,spar,kder,&klfs,&klft,sder,&kstat);\n      if (kstat<0) goto error;\n\n      /* Store information about points, derivatives and cross-derivative. */\n      knbpnt += 1;\n      km1 += 1;\n\n      /* Possibly increase size of arrays. */\n      if (knbpnt>=kmaxis)\n      {\n\tkmaxis += 512;\n\tspnt  = increasearray(spnt,idim*kmaxis,DOUBLE);\n\tif ( spnt == SISL_NULL )  goto err101;\n\tstng1 = increasearray(stng1,idim*kmaxis,DOUBLE);\n\tif ( stng1 == SISL_NULL )  goto err101;\n\tstng2 = increasearray(stng2,idim*kmaxis,DOUBLE);\n\tif ( stng2 == SISL_NULL )  goto err101;\n\tscrss = increasearray(scrss,idim*kmaxis,DOUBLE);\n\tif ( scrss == SISL_NULL )  goto err101;\n      }\n\n      /* Possibly increase size of arrays. */\n      if (km1>=kmaxik1)\n      {\n\tkmaxik1 = km1 + 512;\t/* kmaxik += 10; (PFU 19/09-94) */\n\tspar1 = increasearray(spar1,kmaxik1,DOUBLE);\n\tif ( spar1 == SISL_NULL )  goto err101;\n      }\n\n      for (ki=0; ki<idim; ki++)\n      {\n\tspnt[kain] = sder[ki];\n\tstng1[kain] = sder[ki+idim];\n\tstng2[kain] = sder[ki+2*idim];\n\tscrss[kain] = sder[ki+3*idim];\n\tkain += 1;\n      }\n\n      /* Store parametrization along 1. parameter direction. */\n      spar1[km1-1] = spar[0];\n    }\n  }\n\n\n  for (kk2=ik24; kk2<=in24; kk2++)\n  {\n\n    /* check if current knot-value in second parameter direction is\n       equal the previous or not. */\n    if (DNEQUAL(spar[1],eknot24[kk2]))\n    {\n\n      /* Initiate parameter value in first parameter direction. */\n      spar[0] = eknot13[ik13-1];\n      klfs = 0;\n\n      /* Evaluate the surface (ps) at the parameter value spar.  */\n      spar[1] = eknot24[kk2];\n      s1367(ps,aoffset,aepsge,idim,spar,kder,&klfs,&klft,sder,&kstat);\n      if (kstat<0) goto error;\n\n      /* Store information about points, derivatives and cross-derivative. */\n      knbpnt += 1;\n      km2 += 1;\n\n      /* Possibly increase size of arrays. */\n      if (knbpnt>=kmaxis)\n      {\n\tkmaxis += 512;\n\tspnt  = increasearray(spnt,idim*kmaxis,DOUBLE);\n\tif ( spnt == SISL_NULL )  goto err101;\n\tstng1 = increasearray(stng1,idim*kmaxis,DOUBLE);\n\tif ( stng1 == SISL_NULL )  goto err101;\n\tstng2 = increasearray(stng2,idim*kmaxis,DOUBLE);\n\tif ( stng2 == SISL_NULL )  goto err101;\n\tscrss = increasearray(scrss,idim*kmaxis,DOUBLE);\n\tif ( scrss == SISL_NULL )  goto err101;\n      }\n\n      /* Possibly increase size of arrays. */\n      if (km2>=kmaxik2)\n      {\n\tkmaxik2 = km2 + 512;  /* kmaxik += 10; (PFU 19/09-94) */\n\tspar2 = increasearray(spar2,kmaxik2,DOUBLE);\n\tif ( spar1 == SISL_NULL )  goto err101;\n      }\n\n      for (ki=0; ki<idim; ki++)\n      {\n\tspnt[kain] = sder[ki];\n\tstng1[kain] = sder[ki+idim];\n\tstng2[kain] = sder[ki+2*idim];\n\tscrss[kain] = sder[ki+3*idim];\n\tkain += 1;\n      }\n\n      /* Store parametrization along 1. parameter direction. */\n      spar2[km2-1] = spar[1];\n\n      for (kk1=ik13; kk1<=in13; kk1++)\n      {\n\n\t/* check if current knot-value in first parameter direction is\n\t   equal the previous or not. */\n\tif (DNEQUAL(spar[0],eknot13[kk1]))\n\t{\n\t  spar[0] = eknot13[kk1];\n\n\t  /* Evaluate the surface (ps) at the parameter value spar.  */\n\t  s1367(ps,aoffset,aepsge,idim,spar,kder,\n\t\t&klfs,&klft,sder,&kstat);\n\t  if (kstat<0) goto error;\n\n\t  /* Store information about points, derivatives and\n\t     cross-derivative. */\n\t  knbpnt += 1;\n\n\t  /* Possibly increase size of arrays. */\n\t  if (knbpnt>=kmaxis)\n\t  {\n\t    kmaxis += 512;\n\t    spnt  = increasearray(spnt,idim*kmaxis,DOUBLE);\n\t    if ( spnt == SISL_NULL )  goto err101;\n\t    stng1 = increasearray(stng1,idim*kmaxis,DOUBLE);\n\t    if ( stng1 == SISL_NULL )  goto err101;\n\t    stng2 = increasearray(stng2,idim*kmaxis,DOUBLE);\n\t    if ( stng2 == SISL_NULL )  goto err101;\n\t    scrss = increasearray(scrss,idim*kmaxis,DOUBLE);\n\t    if ( scrss == SISL_NULL )  goto err101;\n\t  }\n\n\t  for (ki=0; ki<idim; ki++)\n\t  {\n\t    spnt[kain] = sder[ki];\n\t    stng1[kain] = sder[ki+idim];\n\t    stng2[kain] = sder[ki+2*idim];\n\t    scrss[kain] = sder[ki+3*idim];\n\t    kain += 1;\n\t  }\n\t}\n      }\n    }\n  }\n\n  /* Compute a bicubic hermite spline-approximation to the position and\n     derivative data given by spnt, stng1, stng2 and scrss. */\n\n  s1347(spnt,stng1,stng2,scrss,km1,km2,idim,kpar,spar1,spar2,seps,lend,\n\tsedgeps,tepsco,kopt,ktmax,rs,smxerr,&kstat);\n  if (kstat<0) goto error;\n\n  /* Surface approximated. */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in memory allocation */\n\nerr101:\n  *jstat = -101;\n  s6err(\"s1366\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\nerror:\n  *jstat = kstat;\n  s6err(\"s1366\",*jstat,kpos);\n  goto out;\n\nout:\n  if (spnt != SISL_NULL) freearray(spnt);\n  if (stng1 != SISL_NULL) freearray(stng1);\n  if (stng2 != SISL_NULL) freearray(stng2);\n  if (scrss != SISL_NULL) freearray(scrss);\n  if (spar1 != SISL_NULL) freearray(spar1);\n  if (spar2 != SISL_NULL) freearray(spar2);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1367.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1367.c,v 1.2 2001-03-19 15:58:47 afr Exp $\n *\n */\n\n\n#define S1366\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1367(SISLSurf *ps,double aoffset,double aepsge,int idim,double epar[],\n\t   int ider,int *ilfs,int *ilft,double eder[],int *jstat)\n#else\nvoid s1367(ps,aoffset,aepsge,idim,epar,ider,ilfs,ilft,eder,jstat)\n     SISLSurf   *ps;\n     double aoffset;\n     double aepsge;\n     int    idim;\n     double epar[];\n     int    ider;\n     int    *ilfs;\n     int    *ilft;\n     double eder[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Evaluate the surface at the parameter pair value epar.\n*\n*\n*\n* INPUT      : ps     - The input B-spline surface.\n*              aoffset- The offset distance.\n*                       If idim=2 a positive signe on this value put the\n*                       offset on the side of the positive normal vector,\n*                       and a negative sign puts the offset on the sign\n*                       of the negative normal vector.\n*                       If idim=3 the offset is determined by the cross\n*                       product of the tangent vector and the anorm vector.\n*                       The offset distance is multiplied by this vector.\n*              aepsge - Maximal deviation allowed between true offset surface\n*                       and the approximated offset surface.\n*              idim   - The dimension of the space (3).\n*              epar   - Parameter pair value at which to compute position\n*                       and derivatives.\n*              ider   - The number of derivatives to compute.\n*                       < 0: Error\n*                       = 0: Compute position\n*                       = 1: Compute position and first derivative\n*                       etc.\n* INPUT/OUTPUT:\n*              ilfs   - Pointer to the interval in the knot vector in 1.\n*                       parameter direction.\n*              ilft   - Pointer to the interval in the knot vector in 2.\n*                       parameter direction.\n*\n* OUTPUT     : \n*              jstat  - status messages  \n*                                         = 3      : Surface is degenerate\n*                                                    at the point, normal\n*                                                    found by s6degnorm\n*                                         = 2      : Surface is degenerate\n*                                                    at the point, normal\n*                                                    has zero length\n*                                         = 1      : Surface is close to\n*                                                    degenerate at the point\n*                                                    Angle between tangents,\n*                                                    less than angular tolerance\n*                                         = 0      : ok\n*                                         < 0      : error\n*              eder   - Array of dimension [(ider+1)*(ider+1)*idim]\n*\n* METHOD     : Points, derivatives, cross derivatives and normals are calcu-\n*              lated at the selected point on the surface. The selected point\n*              corresponds to the input parameter-pair (epar).\n*              The offset values are calculated in the following way:\n*\n*              O(u,v)   = P(u,v)   + aoffset (N(u,v)/n(u,v))\n*\n*              O(u,v)   = P(u,v)   + aoffset (N(u,v)/n(u,v))\n*                    u          u                           u\n*\n*              O(u,v)   = P(u,v)   + aoffset (N(u,v)/n(u,v))\n*                    v          v                           v\n*\n*              O(u,v)   = P(u,v)   + aoffset (N(u,v)/n(u,v))\n*                    uv         uv                          uv\n*\n*\n* EXAMPLE OF USE:\n*\n*\n* REFERENCES :\n*\n*\n*\n* CALLS      : s1424     - Evaluate the surface at the parameter pair value\n*                          (epar).\n*              s6length, s6crss, s6scpr, s6err\n*\n* WRITTEN BY : Per Evensen,  SI, 89-4.\n* REVISED BY : Michael Floater, SI, 3/2/92.\n*              If an edge of the surface is degenerate, a normal is\n*              still returned via s6degnorm.\n*              Derivatives are set to null.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;     /* Local status variable.                           */\n  int kpos = 0;      /* Position of error.                               */\n  int kdim;          /* Dimension of the space in which the surface lies.*/\n  int ki;            /* Loop controller.                                 */\n  \n  int kder = ider+1; /* Number of derivatives to calculate.              */\n  int knmb;          /* Number of array-elements.                        */\n  double snorm[3];   /* Pointer to array containing the normal.          */\n  double utang[3];   /* Pointer to array containing the u tangent. */\n  double vtang[3];   /* Pointer to array containing the v tangent. */\n  double sdum[27];   /* Array used instead of allocation.                */\n  double *sder=SISL_NULL; /* Pointer to array containing the derivatives.     */\n  \n  if (idim !=3) goto err105;\n  \n  /* Only allocate space if sdum is too small. */\n  \n  kdim = ps->idim;\n  knmb = kdim*kder*kder;\n  if (knmb>27)\n    sder = newarray(knmb,DOUBLE);\n  else\n    sder = &sdum[0];\n \n\n  /* Set the answer to zero in case nothing is found,\n     e.g. if ps is degenerate at the given point. */\n\n  for (ki=0;ki<knmb;ki++) eder[ki] = DZERO;\n\n\n  if (DEQUAL(aoffset,DZERO))\n    {\n      /* Evaluate the surface (ps) at the parameter value spar.  */\n      \n      s1424(ps,kder,kder,epar,ilfs,ilft,sder,&kstat);\n      if (kstat<0) goto error;\n      \n      /* Copy relevant information to eder. */\n      \n      for (ki=0;ki<idim;ki++)\n        {\n\t  eder[ki] = sder[ki];\n\t  eder[ki+kdim] = sder[ki+kdim];\n\t  eder[ki+2*kdim] = sder[ki+3*kdim];\n\t  eder[ki+3*kdim] = sder[ki+4*kdim];\n        }\n    }\n  else\n    {\n      \n      double tlen1,tlen2,tnorm,tang=(double)0.0;\n      \n      /* Evaluate the surface (ps) at the parameter value spar.  */\n      \n      s1424(ps,kder,kder,epar,ilfs,ilft,sder,&kstat);\n      if (kstat<0) goto error;\n      \n      /*\n       *   Let P(s,t) be a point on the B-spline surface, and N(s,t) the\n       *   normal in P.\n       *\n       *   The normal is found by the expression: N = P  x P .\n       *                                               s    t\n       *\n       *   The length of the normal N is found by:\n       *\n       *           1/2\n       *   n = (N*N)   .\n       */\n      \n      /* Calculate surface normal, make cross products of tangents. */\n      \n      s6crss(sder+kdim,sder+3*kdim,snorm);\n      \n      /*  Make length of tangents and normal */\n      \n      tlen1 = s6length(sder+kdim,kdim,&kstat);\n      tlen2 = s6length(sder+3*kdim,kdim,&kstat);\n      tnorm = s6length(snorm,kdim,&kstat);\n      \n      /*  Calculate angle between tangents */\n      \n      if (tlen1 != DZERO && tlen2 != DZERO && tnorm != DZERO)\n        tang = tnorm/(tlen1*tlen2);\n\n      \n      if (tang == (double)0.0) *jstat = 2;\n      else if (tang <= ANGULAR_TOLERANCE) *jstat = 1;   \n      else *jstat = 0;\n      \n\n      /* I just chose a reasonable tolerance here.\n\t It should be relative to the size of the surface.\n\t 10e-8 ought to work OK if the size of ps is about\n\t 1 and we're\n\t working in double precision. */\n\n      if (tnorm < 0.00000001)\n      {\n\t  /* Find a normal if possible and then leave. */\n\n\t  s6degnorm(ps,2,epar,sder,utang,vtang,snorm,&kstat);\n\t  if(kstat < 0) goto error;\n\t  if(kstat == 0)\n\t  {\n              tnorm = s6length(snorm,kdim,&kstat);\n\t      *jstat = 3;\n              for (ki=0;ki<idim;ki++)\n\t\t       eder[ki]=sder[ki]+aoffset*snorm[ki]/tnorm;\n\t  }\n\t  else\n\t  {\n              for (ki=0;ki<idim;ki++) eder[ki]=sder[ki];\n\t  }\n\t  goto out;\n      }\n\n      /*\n       *   The offset point, O(s,t,o), where o is the offset distance, is\n       *   found by the expression:\n       *\n       *   O = P + o*(N/n)    \n       */\n      \n      /* Calculate position of offset point. */\n      \n      for (ki=0;ki<idim;ki++) eder[ki]=sder[ki]+aoffset*snorm[ki]/tnorm;\n      \n      /* Calculate derivatives only if we are at a degenerate point. */\n\n      if (ider > 0)\n\t{\n\t  \n\t  double *spnt;      /* Pointer to the derivatives.                */\n\t  double tder1,tder2;/* Lebgth of tangents.                        */\n\t  double snoru1[3];  /* The first derivative of the surface normal\n\t\t\t\tin first parameter direction, 1. part.     */\n\t  double snoru2[3];  /* The first derivative of the surface normal\n\t\t\t\tin first parameter direction, 2. part.     */\n\t  double snoru[3];   /* The first derivative of the surface normal\n\t\t\t\tin first parameter direction.              */\n\t  double snorv1[3];  /* The first derivative of the surface normal\n\t\t\t\tin second parameter direction, 1. part.    */\n\t  double snorv2[3];  /* The first derivative of the surface normal\n\t\t\t\tin second parameter direction, 2. part.    */\n\t  double snorv[3];   /* The first derivative of the surface normal\n\t\t\t\tin second parameter direction.             */\n\t  double snoruv1[3]; /* The cross derivative of the surface normal,\n\t\t\t\t1. part.                                   */\n\t  double snoruv2[3]; /* The cross derivative of the surface normal,\n\t\t\t\t2. part.                                   */\n\t  double snoruv3[3]; /* The cross derivative of the surface normal,\n\t\t\t\t3. part.                                   */\n\t  double snoruv[3];  /* The cross derivative of the surface normal.*/\n\t  double tnun;       /* The scalar product; snorm snoru.           */\n\t  double tnvn;       /* The scalar product; snorm snorv.           */\n\t  double tunvn;      /* The scalar product; snoru snorv.           */\n\t  double tnuvn;      /* The scalar product; snorm snoruv.          */\n\t  double snorus[3];  /* The first derivative of the surface normal\n\t\t\t\tdivided by the length of the normal\n\t\t\t\tin first parameter direction.              */\n\t  double snorvs[3];  /* The first derivative of the surface normal\n\t\t\t\tdivided by the length of the normal\n\t\t\t\tin second parameter direction.             */\n\t  double snoruvs[3]; /* The cross derivative of the surface normal\n\t\t\t\tdivided by the length of the normal.       */\n\t  \n\t  /* Calculate length of tangents. */\n\t  \n\t  tder1 = s6length(sder+kdim,kdim,&kstat);\n\t  tder2 = s6length(sder+3*kdim,kdim,&kstat);\n\t  \n\t  /* The tangent length might be very different from 1. Scale it and\n\t     higher order derivatives to give tangent length one. */\n\t  \n\t  for (ki=0;ki<idim;ki++)\n            {\n\t      spnt = sder+kdim+ki;\n\t      *spnt /= tder1;\n\t      \n\t      spnt = sder+2*kdim+ki;\n\t      *spnt /= (tder1+tder1);\n\t      \n\t      spnt = sder+3*kdim+ki;\n\t      *spnt /= tder2;\n\t      \n\t      spnt = sder+4*kdim+ki;\n\t      *spnt /= (tder1+tder2);\n\t      \n\t      spnt = sder+5*kdim+ki;\n\t      *spnt /= (tder1+tder1+tder2);\n\t      \n\t      spnt = sder+6*kdim+ki;\n\t      *spnt /= (tder2+tder2);\n\t      \n\t      spnt = sder+7*kdim+ki;\n\t      *spnt /= (tder1+tder2+tder2);\n\t      \n\t      spnt = sder+8*kdim+ki;\n\t      *spnt /= (tder1+tder1+tder2+tder2);\n            }\n\t  \n\t  /*\n\t   *   The first derivative of the surface normal in first parameter direction\n\t   *   is calculated by the expression:\n\t   *\n\t   *\n\t   *   N  = P  x P   + P x P\n\t   *    u    uu   v     u   uv\n\t   */\n\t  \n\t  /* Calculate first derivative of the surface normal in first\n\t     parameter direction. */\n\t  \n\t  s6crss(sder+2*kdim,sder+3*kdim,snoru1);\n\t  s6crss(sder+kdim,sder+4*kdim,snoru2);\n\t  \n\t  for (ki=0;ki<idim;ki++) snoru[ki]=snoru1[ki]+snoru2[ki];\n\t  \n\t  /*\n\t   *   The first derivative of the surface normal in second parameter direction\n\t   *   is calculated by the expression:\n\t   *\n\t   *\n\t   *   N  = P  x P   + P x P\n\t   *    v    uv   v     u   vv\n\t   */\n\t  \n\t  /* Calculate first derivative of the surface normal in second\n\t     parameter direction. */\n\t  \n\t  s6crss(sder+4*kdim,sder+3*kdim,snorv1);\n\t  s6crss(sder+kdim,sder+6*kdim,snorv2);\n\t  \n\t  for (ki=0;ki<idim;ki++) snorv[ki]=snorv1[ki]+snorv2[ki];\n\t  \n\t  /*\n\t   *   The cross derivative of the surface normal is calculated by the \n\t   *   expression:\n\t   *\n\t   *\n\t   *   N   = P   x P   + 2*(P  x P  ) + P  x P\n\t   *    uv    uuv   v        uu   vv     u    uvv\n\t   */\n\t  \n\t  /* Calculate cross derivative of the surface normal. */\n\t  \n\t  s6crss(sder+5*kdim,sder+3*kdim,snoruv1);\n\t  s6crss(sder+2*kdim,sder+6*kdim,snoruv2);\n\t  s6crss(sder+kdim,sder+7*kdim,snoruv3);\n\t  \n\t  for (ki=0;ki<idim;ki++) \n\t    snoruv[ki]=snoruv1[ki]+(double)2.0*snoruv2[ki]+snoruv3[ki];\n\t  \n\t  \n\t  /*\n\t   *   The first derivative of the surface normal divided by the length of\n\t   *   the normal in first parameter direction is calculated by the \n\t   *   expression:\n\t   *\n\t   *                             3\n\t   *   (N/n)  = N /n - (N * N )/n  N\n\t   *        u    u           u\n\t   */\n\t  \n\t  /* Calculate first derivative of the surface normal divided\n\t     by the length of the normal in first parameter direction. */\n\t  \n\t  tnun = s6scpr(snorm,snoru,idim);\n\t  \n\t  for (ki=0;ki<idim;ki++) \n\t    snorus[ki]=\n\t      snoru[ki]/tnorm-(tnun/(tnorm*tnorm*tnorm))*snorm[ki];\n\t  \n\t  /*\n\t   *   The first derivative of the surface normal divided by the length of\n\t   *   the normal in second parameter direction is calculated by the \n\t   *   expression:\n\t   *\n\t   *                             3\n\t   *   (N/n)  = N /n - (N * N )/n  N\n\t   *        v    v           v\n\t   */\n\t  \n\t  /* Calculate first derivative of the surface normal divided\n\t     by the length of the normal in second parameter direction. */\n\t  \n\t  tnvn = s6scpr(snorm,snorv,idim);\n\t  \n\t  for (ki=0;ki<idim;ki++) \n\t    snorvs[ki]=\n\t      snorv[ki]/tnorm-(tnvn/(tnorm*tnorm*tnorm))*snorm[ki];\n\t  \n\t  /*\n\t   *   The cross derivative of the surface normal divided by the length of\n\t   *   the normal is calculated by expression:\n\t   *\n\t   *                               3                3\n\t   *   (N/n)   = N  /n - (N * N )/n  N  - (N * N )/n  N  -  ==>\n\t   *        uv    uv           v      u         u      v\n\t   *\n\t   *                        3                3                        5\n\t   *             (N  * N )/n  N - (N * N  )/n  N + 3(N * N )(N * N )/n  N\n\t   *               u    v               uv                u       v\n\t   */\n\t  \n\t  /* Calculate cross derivative of the surface normal divided\n\t     by the length of the normal. */\n\t  \n\t  tunvn = s6scpr(snoru,snorv,idim);\n\t  tnuvn = s6scpr(snorm,snoruv,idim);\n\t  \n\t  for (ki=0;ki<idim;ki++) \n\t    snoruvs[ki]=\n\t      snoruv[ki]/tnorm-(tnvn/(tnorm*tnorm*tnorm))*snoru[ki]-\n\t\t(tnun/(tnorm*tnorm*tnorm))*snorv[ki]-\n\t\t  (tunvn/(tnorm*tnorm*tnorm))*snorm[ki]-\n\t\t    (tnuvn/(tnorm*tnorm*tnorm))*snorm[ki]+\n\t\t      (((double)3.0*tnun*tnvn)/(tnorm*tnorm*tnorm*tnorm*tnorm))*\n\t\t\tsnorm[ki];\n\t  \n\t  /*\n\t   *   The first derivative in first parameter direction offset point, \n\t   *   where o is the offset distance, is found by the expression:\n\t   *\n\t   *           \n\t   *   O  = P  + o*(N/n)    \n\t   *    u    u          u\n\t   */\n\t  \n\t  /* Calculate position of first derivative in first parameter direction\n\t     offset point. */\n\t  \n\t  for (ki=0;ki<idim;ki++) \n            eder[ki+kdim]=sder[ki+kdim]+aoffset*snorus[ki];\n\t  \n\t  /*\n\t   *   The first derivative in second parameter direction offset point, \n\t   *   where o is the offset distance, is found by the expression:\n\t   *\n\t   *\n\t   *   O  = P  + o*(N/n)    \n\t   *    v    v          v\n\t   */\n\t  \n\t  /* Calculate position of first derivative in second parameter direction\n\t     offset point. */\n\t  \n\t  for (ki=0;ki<idim;ki++) \n            eder[ki+2*kdim]=sder[ki+3*kdim]+aoffset*snorvs[ki];\n\t  \n\t  /*\n\t   *   The cross derivative offset point, \n\t   *   where o is the offset distance, is found by the expression:\n\t   *\n\t   *\n\t   *   O   = P   + o*(N/n)    \n\t   *    uv    uv          uv\n\t   */\n\t  \n\t  /* Calculate position of cross derivative offset point. */\n\t  \n\t  for (ki=0;ki<idim;ki++) \n            eder[ki+3*kdim]=sder[ki+4*kdim]+aoffset*snoruvs[ki];\n\t  \n\t  \n\t  \n\t  /* Scale the derivatives to match the original parametrization. */\n\t  \n\t  for (ki=0;ki<idim;ki++)\n            {\n\t      spnt = eder+kdim+ki;\n\t      *spnt *= tder1;\n\t      \n\t      spnt = eder+2*kdim+ki;\n\t      *spnt *= tder2;\n\t      \n\t      spnt = eder+3*kdim+ki;\n\t      *spnt *= (tder1+tder2);\n            }\n\t  \n\t}\n    }\n  \n  /* SISLPoint and derivatives calculated, with a possible offset distance. */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in input, dimension not equal to 3 */\n  \n  err105: *jstat = -105;\n  s6err(\"s1367\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"s1367\",*jstat,kpos);\n  goto out;\n  \n  out: return;\n}\n"
  },
  {
    "path": "src/s1369.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1369.c,v 1.2 2001-03-19 15:58:47 afr Exp $\n *\n */\n\n\n#define S1369\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1369(SISLSurf *ps,double ecentr[],double enorm[],double abigr,\n\t   double asmalr,int idim,double aepsco,double aepsge,\n\t   int *jpt,double **gpar,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1369(ps,ecentr,enorm,abigr,asmalr,idim,aepsco,aepsge,\n           jpt,gpar,jcrv,wcurve,jstat)\n     SISLSurf     *ps;\n     double   ecentr[];\n     double   enorm[];\n     double   abigr;\n     double   asmalr;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a surface and a torus. \n*\n* INPUT      : ps     - Pointer to the surface.\n*              ecentr - The center of the torus (lying in the symmetry plane)\n*              enorm  - Normal of symmetry plane\n*              abigr  - Distance from ecentr to center circle of torus\n*              asmalr - The radius of the torus surface\n*              idim   - Dimension of the space in which the torus\n*                       lies. idim should be equal to two or three.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              jcrv   - Number of intersection curves.\n*              wcurve - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the surface is put into the equation of the\n*              torus achieving a surface in the one-dimensional space.\n*              The zeroes of this surface are found.\n*\n*\n* REFERENCES : Main routine written by Vibeke Skytt, SI, 1988.\n*\n* CALLS      : sh1369, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n*\n*********************************************************************\n*/                                                               \n{                                                                     \n  int kstat = 0;              /* Local status variable.                      */\n  int kpos = 0;               /* Position of error.                          */\n  int i;\n  int trackflag = 0;\n  int jtrack;\n  SISLTrack **wtrack=SISL_NULL;\n  int jsurf;\n  SISLIntsurf **wsurf=SISL_NULL;\n  int *pretop=SISL_NULL;\n\n  sh1369(ps,ecentr,enorm,abigr,asmalr,idim,aepsco,aepsge,\n\t trackflag,&jtrack,&wtrack,jpt,gpar,&pretop,jcrv,wcurve,\n\t &jsurf,&wsurf,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  for(i=0; i<jsurf; i++)\n    freeIntsurf(wsurf[i]);\n  if(wsurf != SISL_NULL) freearray(wsurf);\n\n  if(jsurf > 0) \n    *jstat=10;\n  else \n    *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : \n    *jstat = kstat;\n    s6err(\"s1369\",kstat,kpos);\n    goto out;\n\n  out:\n    return;\n}                                               \n                                           \n                       \n       \n"
  },
  {
    "path": "src/s1370.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1370.c,v 1.3 2001-03-19 15:58:47 afr Exp $\n *\n */\n\n\n#define S1370\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1370 (SISLCurve * pcurv, double earray[], int idim, int inarr,\n       int ratflag, SISLCurve ** rcurv, int *jstat)\n#else\nvoid\ns1370 (pcurv, earray, idim, inarr, ratflag, rcurv, jstat)\n     SISLCurve *pcurv;\n     double earray[];\n     int idim;\n     int inarr;\n     int ratflag;\n     SISLCurve ** rcurv;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To put a curve description into the implicit\n*              second order surface described by the input array.\n*\n* INPUT      : pcurv  - Pointer to input curve\n*              earray - The description of the input array\n*                       dimension (idim+1)x(idim+1) (xinarr)\n*              idim   - Put curve into implicit equation\n*              inarr  - Number of parallel matrices in earray.\n*                       inarr should be less or equal to 3.\n*              ratflag - If pcurv is nonrational it is ignored.\n*                        Otherwise:\n*                        If ratflag = 0 rcurv is the nonrational numerator\n*                        If ratflag = 1 rcurv is a full rational curve\n*\n* OUTPUT     : rcurv  - The resulting curve\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : Dependent on the type of object we make:\n*\n*        F(S,T) = (P(s,t),1)  EARRAY (P(s,t),1)\n*\n*     by sampling enough point to use interpolation for reproduction.\n*\n* REFERENCES :\n*\n* CALLS      : s1893,s6err.\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo , Norway\n* REVISED BY : Mike Floater, SI, Oslo 11/4/91 for rational curves\n* REVISED BY : Mike Floater, SI, Oslo 11/9/91 -- ratflag.\n* REVISED BY : Michael Floater, SI, June 92. The rational stuff\n*              was completely messed up after translation of\n*              the fortran part to c. But it works now.\n* REVISED BY : Christophe Birkeland, SI, July 1992.\n* REVISED BY : Christophe Rene Birkeland, SINTEF Oslo, May 1993.\n*              jcurve removed, other minor changes\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, September 1994.\n*              Didn't work for rationals - '(*rcurve)->rcoef' returned from\n*              s1893() was SISL_NULL (must copy from ecoef).\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\n  int kstat = 0;\n  SISLCurve *icurve = SISL_NULL;\t/* Temporary SISLCurve. */\n  int kn;\t\t\t/* Number of vertices of pcurv            */\n  int kk;\t\t\t/* Order in  pcurv                        */\n  int kdim;\t\t\t/* Number of dimesions in pcurv           */\n  int kdimp1;\t\t\t/* Dimension of  earray should be kdim+1  */\n  double *st = SISL_NULL;\t\t/* First knot vector is pcurv             */\n  double *scoef = SISL_NULL;\t\t/* Vertices of pcurv                      */\n  int ikind;\t\t\t/* kind of surface pcurv is               */\n  double *rscoef = SISL_NULL;\t/* Scaled coefficients if pcurv is rational       */\n  double wmin, wmax;\t\t/* min and max values of the weights if rational  */\n  double scale;\t\t\t/* factor for scaling weights if rational         */\n  int i;\t\t\t/* loop variable                          */\n  double *sarray = SISL_NULL;\t/* Array for calculating denominator if used      */\n  int knarr;\t\t\t/* Number of parallel arrays to use.              */\n  int nkind;\t\t\t/* Kind of output curve (rcurf).                  */\n\n  *jstat = 0;\n\n  /* Make local pointers. */\n\n  kn = pcurv->in;\n  kk = pcurv->ik;\n  kdim = pcurv->idim;\n  st = pcurv->et;\n  ikind = pcurv->ikind;\n\n  kdimp1 = kdim + 1;\n\n  /* Test input. */\n\n  if (kdim != idim || (kdim != 2 && kdim != 3))\n    goto err104;\n  if (inarr < 1 || 3 < inarr) goto err172;\n\n  /* rational surfaces are a special case. */\n  if (ikind == 2 || ikind == 4)\n    {\n      kdim++;\n\n      /* scale the coeffs so that min. weight * max. weight = 1. */\n\n      rscoef = pcurv->rcoef;\n      wmin = rscoef[kdim-1];\n      wmax = rscoef[kdim-1];\n\n      for (i = 2*kdim-1; i < kn * kdim; i += kdim)\n\t{\n\t  if (rscoef[i] < wmin)\n\t    wmin = rscoef[i];\n\t  if (rscoef[i] > wmax)\n\t    wmax = rscoef[i];\n\t}\n      scale = (double) 1.0 / sqrt (wmin * wmax);\n      scoef = newarray (kn * kdim, DOUBLE);\n      if (scoef == SISL_NULL)\n\tgoto err101;\n\n      for (i = 0; i < kn * kdim; i++)\n        scoef[i] = rscoef[i] * scale;\n    }\n  else\n    scoef = pcurv->ecoef;\n\n  icurve = newCurve (kn, kk, st, scoef, 1, kdim, 1);\n  if (icurve == SISL_NULL)\n    goto err171;\n\n  icurve->cuopen = pcurv->cuopen;\n\n  if ((ikind == 2 || ikind == 4) && ratflag == 1)\n    {\n      /* Output curve will also be rational. */\n\n      nkind = 2;\n\n      /* Add an extra parallel array to pick up the weights\n\t of the subsequent homogeneous vertices of rcurv. */\n\n      knarr = inarr + 1;\n      sarray = new0array (kdimp1 * kdimp1 * knarr, DOUBLE);\n      if (sarray == SISL_NULL) goto err101;\n\n      memcopy (sarray, earray, kdimp1 * kdimp1 * inarr, DOUBLE);\n      sarray[kdimp1 * kdimp1 * knarr - 1] = (DOUBLE) 1.0;\n    }\n  else\n    {\n      nkind = 1;\n      knarr = inarr;\n      sarray = earray;\n    }\n\n  /* Put curve into implicit surface. */\n\n  s1893 (icurve, sarray, kdimp1, knarr, 0, 0, rcurv, &kstat);\n  if (kstat < 0) goto error;\n\n  if (*rcurv == SISL_NULL) goto err171;\n\n  if ( ikind == 2 || ikind == 4 )\n  {\n    /* Free arrays. */\n\n    if (scoef) freearray (scoef);\n    if (ratflag && sarray) freearray (sarray);\n\n    if ( ratflag == 1 )\n    {\n      /* Output from s1893 is a dim+1 non-rational curve. */\n      /* Convert homogeneous curve to rational form (rcoef is SISL_NULL here). */\n\n      (*rcurv)->rcoef = newarray((*rcurv)->in * (*rcurv)->idim, DOUBLE);\n      memcopy((*rcurv)->rcoef, (*rcurv)->ecoef,\n\t      (*rcurv)->in * (*rcurv)->idim, DOUBLE);\n\n      (*rcurv)->idim --;    /* Adjust from the homogeneus coordinates. */\n      (*rcurv)->ikind = 2;  /* i.e. rational */\n\n    }\n  }\n\n\n  /* Ok ! */\n\n  goto out;\n\n  /* Error in lower level function. */\n\n  error:\n    *jstat = kstat;\n    s6err (\"s1370\", *jstat, kpos);\n    goto out;\n\n  /* Allocation problems.    */\n\n  err101:\n    *jstat = -101;\n    s6err (\"s1370\", *jstat, kpos);\n    goto out;\n\n  /* Dimension not equal to 3.    */\n\n  err104:\n    *jstat = -104;\n    s6err (\"s1370\", *jstat, kpos);\n    goto out;\n\n  /* Could not create curve */\n\n  err171:\n    *jstat = -171;\n    s6err (\"s1370\", *jstat, kpos);\n    goto out;\n\n  /* Dimension inarr not equal to 1,2 or 3. */\n\n  err172:\n    *jstat = -172;\n    s6err (\"s1370\", *jstat, kpos);\n    goto out;\n\n  out:\n  if (icurve != SISL_NULL) freeCurve (icurve);\n  return;\n}\n"
  },
  {
    "path": "src/s1371.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1371.c,v 1.2 2001-03-19 15:58:47 afr Exp $\n *\n */\n\n\n#define S1371\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1371(SISLCurve *pc1,double ecentr[],double aradiu,int idim,\n\t   double aepsco,double aepsge,\n\t   int *jpt,double **gpar,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1371(pc1,ecentr,aradiu,idim,aepsco,aepsge,jpt,gpar,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     double   ecentr[];\n     double   aradiu;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a curve and a sphere if\n*              the dimension is equal to three and a curve and a circle \n*              if the dimension is two.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve.\n*              ecentr - Center of circle/sphere\n*              aradiu - Radius of the circle or sphere\n*              idim   - Dimension of the space in which the plane/line\n*                       lies. idim should be equal to two or three.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : *jpt   - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              *jcrv  - Number of intersection curves.\n*              wcurve - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The sphere is represented as a quadric surface.\n*              Then s1374 is used to find intersections.\n*\n*\n*\n* REFERENCES : Main routine written by Tor Dokken, SI, 1988.\n*\n* CALLS      : sh1371, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n*\n*\n*********************************************************************\n*/                                                               \n{                                                                     \n  int kstat = 0;           /* Local status variable.                       */\n  int kpos = 0;            /* Position of error.                           */\n  int trackflag = 0;\n  int jtrack;\n  int *pretop=SISL_NULL;\n  SISLTrack **wtrack=SISL_NULL;\n\n  sh1371(pc1,ecentr,aradiu,idim,aepsco,aepsge,\n\t trackflag,&jtrack,&wtrack,jpt,gpar,&pretop,jcrv,wcurve,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  \n  /* Error in lower level routine.  */\n\n  error : \n    *jstat = kstat;\n    s6err(\"s1371\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}                                               \n"
  },
  {
    "path": "src/s1372.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1372.c,v 1.4 2001-03-19 15:58:47 afr Exp $\n *\n */\n\n\n#define S1372\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1372(SISLCurve *pc1,double epoint[],double edirec[],double aradiu,\n\t   int idim,double aepsco,double aepsge,\n\t   int *jpt,double **gpar,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1372(pc1,epoint,edirec,aradiu,idim,aepsco,aepsge,\n           jpt,gpar,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     double   epoint[];\n     double   edirec[];\n     double   aradiu;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find all intersections between a curve and a cylinder if\n*              the dimension is equal to three and a curve and a circle\n*              if the dimension is two.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve.\n*              epoint - SISLPoint on cylinder axis\n*              edirec - Direction of cylinder axis\n*              aradiu - Radius of the circle or sphere\n*              idim   - Dimension of the space in which the cylinder/circle\n*                       lies. idim should be equal to two or three.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : *jpt   - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie continuous.\n*                       Intersection curves are stored in wcurve.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the curve is put into the equation of the\n*              sphere/circle achieving a curve in the one-dimentional space.\n*              The zeroes of this curve is found.\n*\n*\n* REFERENCES : Main routine written by Tor Dokken, SI, 1988.\n*\n* CALLS      : sh1371,sh1372, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov. 1994.  Updated to\n*              handle 2D input as specified in header.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;           /* Local status variable.                       */\n  int kpos = 0;            /* Position of error.                           */\n  int trackflag = 0;\n  int jtrack;\n  int *pretop=SISL_NULL;\n  SISLTrack **wtrack=SISL_NULL;\n\n\n  if ( idim == 2 )\n    sh1371(pc1,epoint,aradiu,idim,aepsco,aepsge,\n\t   trackflag,&jtrack,&wtrack,jpt,gpar,&pretop,jcrv,wcurve,&kstat);\n  else\n    sh1372(pc1,epoint,edirec,aradiu,idim,aepsco,aepsge,\n\t   trackflag,&jtrack,&wtrack,jpt,gpar,&pretop,jcrv,wcurve,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  /*\n   * Intersections found.\n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n    s6err(\"s1372\",kstat,kpos);\n    goto out;\n\n  out:\n    return;\n}\n"
  },
  {
    "path": "src/s1373.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1373.c,v 1.3 2001-03-19 15:58:48 afr Exp $\n *\n */\n\n\n#define S1373\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1373(SISLCurve *pc1,double etop[],double eaxis[],double econe[],int idim,\n\t   double aepsco,double aepsge,\n\t   int *jpt,double **gpar,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1373(pc1,etop,eaxis,econe,idim,aepsco,aepsge,jpt,gpar,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     double   etop[];\n     double   eaxis[];\n     double   econe[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find all intersections between a curve and a cone.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve.\n*              etop   - Top point on cone.\n*              eaxis  - Point on the cone axis (other than top point).\n*              econe  - SISLPoint on cone surface.\n*              idim   - Dimension of the space in which the cone\n*                       lies. idim should be equal to three.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : *jpt   - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie continuous.\n*                       Intersection curves are stored in wcurve.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the curve is put into the equation of the\n*              cone achieving a curve in the one-dimentional space.\n*              The zeroes of this curve is found.\n*\n*\n* REFERENCES : Main routine written by Tor Dokken, SI, 1988.\n*\n* CALLS      : sh1373, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov. 1994.  Updated\n*              header to reflect that only 3D input is accepted.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;              /* Local status variable.                      */\n  int kpos = 0;               /* Position of error.                          */\n  int trackflag = 0;\n  int jtrack;\n  SISLTrack **wtrack=SISL_NULL;\n  int *pretop=SISL_NULL;\n\n  sh1373(pc1,etop,eaxis,econe,idim,aepsco,aepsge,\n\t trackflag,&jtrack,&wtrack,jpt,gpar,&pretop,jcrv,wcurve,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  /*\n   * Intersections found.\n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n    s6err(\"s1373\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}\n"
  },
  {
    "path": "src/s1374.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1374.c,v 1.2 2001-03-19 15:58:48 afr Exp $\n *\n */\n\n\n#define S1374\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1374(SISLCurve *pc1,double earray[],int idim,double aepsco,double aepsge,\n\t   int *jpt,double **gpar,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1374(pc1,earray,idim,aepsco,aepsge,jpt,gpar,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     double   earray[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a curve and a quadric\n*              curve if idim=2 and a quadric surface if idim=3.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve.\n*              earray - Matrix of dimension (idim+1)x(idim+1) describing\n*                       the conic surface such for idim=2:\n*                                         T\n*                        (x,y,1) A (x,y,1)  = 0 is the implicit equation\n*                                               for the curve\n*\n*                       For idim=3:\n*                        (x,y,z,1) A (x,y,z,1) = 0 is the implicit equation\n*                                                  for the surface\n*\n*              idim   - Dimension of the space in which the plane/line\n*                       lies. idim should be equal to two or three.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : *jpt   - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the curve is put into the equation of the\n*              cone achieving a curve in the one-dimentional space.\n*              The zeroes of this curve is found.\n*\n*\n* REFERENCES : Main routine written by Tor Dokken, SI, 1988.\n*\n* CALLS      : sh1374, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n*\n*********************************************************************\n*/                                                               \n{                                                                     \n  int kstat = 0;              /* Local status variable.                      */\n  int kpos = 0;               /* Position of error.                          */\n  int trackflag = 0;\n  int jtrack;\n  SISLTrack **wtrack=SISL_NULL;\n  int *pretop=SISL_NULL;\n\n  sh1374(pc1,earray,idim,aepsco,aepsge,\n\t trackflag,&jtrack,&wtrack,jpt,gpar,&pretop,jcrv,wcurve,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error: \n    *jstat = kstat;\n    s6err(\"s1374\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}                                               \n                                           \n                       \n"
  },
  {
    "path": "src/s1375.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1375.c,v 1.2 2001-03-19 15:58:48 afr Exp $\n *\n */\n\n\n#define S1375\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1375(SISLCurve *pc1,double ecentr[],double enorm[],double abigr,\n\t   double asmalr,int idim,double aepsco,double aepsge,\n\t   int *jpt,double **gpar,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1375(pc1,ecentr,enorm,abigr,asmalr,idim,aepsco,aepsge,\n           jpt,gpar,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     double   ecentr[];\n     double   enorm[];\n     double   abigr;\n     double   asmalr;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a curve and a torus. \n*\n* INPUT      : pc1    - Pointer to the curve.\n*              ecentr - The center of the torus (lying in the symmetri plane)\n*              enorm  - Normal of symmetri plane\n*              abigr  - Distance fro ecentr to center circle of torus\n*              asmalr - The radius of the torus surface\n*              idim   - Dimension of the space in which the plane/line\n*                       lies. idim should be equal to two or three.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : *jpt   - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the curve is put into the equation of the\n*              torus achieving a curve in the one-dimentional space of order\n*              4*(ik-1) + 1, when the order of the original curve is ik.\n*              The zeroes of this curve are found.\n*\n* REFERENCES : Main routine written by Vibeke Skytt, SI, 1988.\n*\n* CALLS      : sh1375, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n*\n*\n*********************************************************************\n*/                                                               \n{        \n  int kstat = 0;           /* Local status variable.                       */\n  int kpos = 0;            /* Position of error.                           */\n  int trackflag = 0;\n  int jtrack;\n  int *pretop=SISL_NULL;\n  SISLTrack **wtrack=SISL_NULL;\n                                                             \n  sh1375(pc1,ecentr,enorm,abigr,asmalr,idim,aepsco,aepsge,\n\t trackflag,&jtrack,&wtrack,jpt,gpar,&pretop,jcrv,wcurve,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : \n    *jstat = kstat;\n    s6err(\"s1375\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}                                               \n                                           \n                       \n"
  },
  {
    "path": "src/s1376.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1376.c,v 1.2 2001-03-19 15:58:48 afr Exp $\n *\n */\n\n\n#define S1376\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1376(double et[],int in,int ik,double **gt,int *jkn,int *jkk,int *jstat)           \n#else\nvoid s1376(et,in,ik,gt,jkn,jkk,jstat)\n     double et[];\n     int    in;\n     int    ik;\n     double **gt;\n     int    *jkn;\n     int    *jkk;\n     int    *jstat;           \n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make the knot vector for the representing a spline\n*              basis of order 4*(ik-1)+1, with the same knot values as et.\n*              This basis is used for representing a curve or surface\n*              put into a conic equation.\n*\n* INPUT      : et     - Knots of input spline basis\n*              in     - Number of vertices in input basis\n*              ik     - Order of input basis\n*\n* OUTPUT     : gt     - Pointer to array of knots. The array is allocated\n*                       inside this routine.\n*              jkn    - Number of vertices\n*              jkk    - Order of B-spline basis produced\n*\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n* METHOD     : \n*\n* REFERENCES :\n*\n*-                                   \n* CALLS      : \n*\n* WRITTEN BY : Tor Dokken, SI, 88-11.\n*\n*********************************************************************\n*/                                                               \n{                                                                     \n  double tval;     /* Value of knot                                 */\n  double *sdum;    /* Pointer to knot array                         */\n  int ki,kl;       /* Variable in loop                              */\n  int knumb;       /* Number of intervals                           */\n  int kstop;       /* Loop stop variable                            */\n  int kpos=0;      /* Position of error                             */\n  \n  /* Run through the knot vector to decide how many intervals exist */\n  \n  knumb = 0;       \n  tval = et[ik-1];\n  \n  for (ki=ik ; ki<=in ; ki++)\n    {\n      if (tval < et[ki])\n        {\n\t  /*      New knot value found */\n\t  knumb = knumb + 1;\n\t  tval = et[ki];\n        }\n    }\n  \n  *jkk = 4*(ik-1) + 1;\n  *jkn = (*jkk-1)*(knumb-1) + *jkk;\n  \n  sdum = newarray(*jkn+*jkk,DOUBLE);\n  if (sdum == SISL_NULL) goto err101;\n  \n  *gt  = sdum; \n  \n  /* Make knot values */\n  \n  tval = et[ik-1];\n  \n  /* Make jkk first knot values */\n  \n  for (kl=0;kl<*jkk;kl++)\n    {\n      sdum[kl] = tval;\n    }\n  \n  /* kl points to the array entry where the next knot value is to be stored\n   */\n  \n  for (ki=ik ; ki<=in ; ki++)\n    {\n      if (tval < et[ki])\n        {\n\t  /* New knot value, remember this and make knots */\n\t  tval = et[ki];\n\t  kstop = kl + *jkk-1;\n\t  for (;kl<kstop;kl++)\n            sdum[kl] = tval;\n        }   \n    }\n  \n  /* Make last knot value */\n  \n  sdum[kl] = tval;\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation */\n err101: *jstat = -101;\n  s6err(\"s1376\",*jstat,kpos);\n  goto out;\n out:\n  \n  return;\n}                                               \n"
  },
  {
    "path": "src/s1377.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1377.c,v 1.3 2001-03-19 15:58:48 afr Exp $\n *\n */\n\n\n#define S1377\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1377 (SISLCurve * pcurv, double econic[], int ideg, int idim,\n       SISLCurve ** rcurv, int *jstat)\n#else\nvoid\ns1377 (pcurv, econic, ideg, idim, rcurv, jstat)\n     SISLCurve *pcurv;\n     double econic[];\n     int ideg;\n     int idim;\n     SISLCurve **rcurv;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To put a curve description into the descripiton of\n*              a torus surface described by the input array econic.\n*\n*\n* INPUT      : pcurv  - Pointer to input curve\n*              econic - Description of torus\n*              ideg   - Type of conic: torus: ideg=1001\n*              idim   - Dimension of object space\n*\n*\n* OUTPUT     : rcurv  - The resulting curve\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : We first make the appropriate knot vector, then we calulate\n*              parametervalues for the interpolation, then the appropriate\n*              values of the curve put into the conic equation are found,\n*              and at last the curve is interpolated.\n*\n* REFERENCES :\n*\n* CALLS      : s1376,s1890,s1221,s6scpr,s1891,s6err.\n*\n* WRITTEN BY : Tor Dokken, SI, 1988-11\n* REVISED BY : Mike Floater, SI, 1991-04 for a rational curve.\n*\n*********************************************************************\n*/\n{\n  int ikind;\t\t\t/* Type of curve pcurv is                           */\n  int kn;\t\t\t/* Number of vertices of pcurv                      */\n  int kk;\t\t\t/* Order in  pcurv                                  */\n  int kjkk;\t\t\t/* Order of interpolated basis                      */\n  int kjkn;\t\t\t/* Number of vertices in interpolated basis         */\n  int kdim;\t\t\t/* Number of dimensions in pcurv                    */\n  int kstat;\t\t\t/* Local status variable                            */\n  int kpos = 0;\t\t\t/* Position indicator for errors                    */\n  int kzero = 0;\t\t/* Value 0 needed in call s1891    \t          */\n  int kone = 1;\t\t\t/* Value 1 needed in call s1891\t\t          */\n  int cuopen;\t\t\t/* Open/Closed flag                                 */\n  int ki, kj;\t\t\t/* Loop control variable                            */\n  int kleft = 0;\t\t/* Pointer into knot vector                         */\n  int *der = SISL_NULL;\t\t/* Derivate indicators. */\n  double *st = SISL_NULL;\t\t/* First knot vector is pcurv                       */\n  double *scentr = econic;\t/* Center of torus             */\n  double *saxis = econic + 3;\t/* Axis of torus               */\n  double tbigr = *(econic + 6);\t/* Big radius of torus         */\n  double tsmalr = *(econic + 7);/* Small radius of torus       */\n  double tbigr2 = tbigr * tbigr;/* Square of big radius        */\n  double tdiffr2 = tbigr2 - tsmalr * tsmalr;\t/* Difference of square of radii*/\n  double *sval1 = SISL_NULL;\t\t/* Array of values of curve put into torus eq.      */\n  double *sval2 = SISL_NULL;\n  double *sgt = SISL_NULL;\t\t/* Knot vector of curve put into torus surface      */\n  double sy[3];\t\t\t/* Difference between point and torus center        */\n  double tzn;\t\t\t/* Projection of sy onto torus axis                 */\n  double tyy;\t\t\t/* Square of length of sy                           */\n  double tzz;\t\t\t/* Square of length of sz                           */\n  double ty;\t\t\t/* Component of sy                                  */\n  double tz;\t\t\t/* Component of sz                                  */\n  double sder[4];\t\t/* Point on the curve                           */\n  double ww;\t\t\t/* the weight of sder squared if pcurv is rational  */\n  double *par = SISL_NULL;\n  SISLCurve *tempcurv = SISL_NULL;\t/* only used for rational curves              */\n\n  *jstat = 0;\n  if (idim != pcurv->idim) goto err104;\n  if (ideg != 1001) goto err200;\n  \n  /* Make local pointers. */\n\n  kn = pcurv->in;\n  kk = pcurv->ik;\n  kdim = pcurv->idim;\n  st = pcurv->et;\n  ikind = pcurv->ikind;\n\n  if (ikind == 2 || ikind == 4)\n    {\n      tempcurv = newCurve (kn, kk, st, pcurv->rcoef, ikind - 1, kdim + 1, 0);\n      if (tempcurv == SISL_NULL)\n\tgoto err171;\n      tempcurv->cuopen = pcurv->cuopen;\n    }\n  else\n    {\n      tempcurv = pcurv;\n    }\n\n\n  /* Test input. */\n\n  if (kdim != 3)\n    goto err104;\n\n\n  /* Make description of knot array for interpolation. */\n\n  s1376 (st, kn, kk, &sgt, &kjkn, &kjkk, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Make parameter values and derivative indicators. */\n\n  s1890 (sgt, kjkk, kjkn, &par, &der, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Allocate array for values of curve put into torus equation. */\n\n  sval1 = newarray (kjkn, DOUBLE);\n  if (sval1 == SISL_NULL)\n    goto err101;\n\n\n  /* Calculate values to be interpolated. */\n\n  for (ki = 0; ki < kjkn; ki++)\n    {\n      /*  Calculate values on 3-D curve. */\n\n      s1221 (tempcurv, 0, par[ki], &kleft, sder, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /*\n       *   The calculation of a point on the torus surface can be done in the\n       *   following way.\n       *\n       *      y = p - scentr\n       *      z = y - (y saxis) saxis\n       *\n       *   The equation of the torus can be written\n       *\n       *                          2    2\n       *      (y - R z/sqrt(z z) )  - r = 0\n       *\n       *\n       *   or by eliminating the square root:\n       *\n       *          f =\n       *\n       *          2           2  2      2       2  2 2\n       *      (yy)  + 2 (yy)(R -r ) - 4R zz + (R -r )  = 0\n       *\n       *\n       *\n       *       or in 4-D homogeneous coordinates:\n       *\n       *\n       *  f =\n       *\n       *      2      2      2  2      2 2      4  2  2 2\n       *  (yy)  + 2 w (yy)(R -r ) - 4w R zz + w (R -r )  = 0\n       *\n       *      where y = T - w*scentr,  p=T/w\n       *\n       *   We thus need to calculate yy and zz:\n       */\n\n      if (ikind == 2 || ikind == 4)\n\t{\n\t  for (kj = 0; kj < 3; kj++)\n\t    sy[kj] = sder[kj] - sder[3] * scentr[kj];\n\t  ww = sder[3] * sder[3];\n\t}\n      else\n\t{\n\t  for (kj = 0; kj < 3; kj++)\n\t    sy[kj] = sder[kj] - scentr[kj];\n\t  ww = (double) 1.0;\n\t}\n\n      tzn = s6scpr (sy, saxis, 3);\n\n      tyy = (double) 0.0;\n      tzz = (double) 0.0;\n\n\n      /*  Make z and necessary derivatives of z */\n\n      for (kj = 0; kj < 3; kj++)\n\t{\n\t  ty = sy[kj];\n\t  tz = ty - tzn * saxis[kj];\n\t  tyy += ty * ty;\n\t  tzz += tz * tz;\n\t}\n\n/*\n *                                      2            2   2\n * Now tyy = yy and tzz = zz, tbigr2 = R ,tdiffr2 = R - r   \n * --------------------------------------------------------\n */\n\n      sval1[ki] = tyy * tyy + ((double) 2.0 * ww * tyy\n\t\t\t       + ww * ww * tdiffr2) * tdiffr2\n\t- (double) 4.0 *ww * tbigr2 * tzz;\n    }\n\n  cuopen = TRUE;\n\n  s1891 (par, sval1, kone, kjkn, kone, der, cuopen, sgt, &sval2, &kjkn, kjkk,\n\t kzero, kzero, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  *rcurv = SISL_NULL;\n  *rcurv = newCurve (kjkn, kjkk, sgt, sval2, 1, 1, 1);\n  if (*rcurv == SISL_NULL)\n    goto err171;\n  (*rcurv)->cuopen = pcurv->cuopen;\n\n \n  /* Ok ! */\n\n  goto out;\n\n\n  /* Error in lower level function */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1377\", *jstat, kpos);\n  goto out;\n\n  /* Error in space allocation */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1377\", *jstat, kpos);\n  goto out;\n\n  /* Dimension not equal to 3 or conflicting dimensions */\n\nerr104:\n  *jstat = -104;\n  s6err (\"s1377\", *jstat, kpos);\n  goto out;\n\n  /* Could not create curve. */\n\nerr171:\n  *jstat = -171;\n  s6err (\"s1377\", *jstat, kpos);\n  goto out;\n\n  /* Wrong implicit type (ideg). */\n\nerr200:\n  *jstat = -200;\n  s6err (\"s1377\", *jstat, kpos);\n  goto out;\n\nout:\n\n  /* Release allocated arrays */\n\n  if (sgt != SISL_NULL)\n    freearray (sgt);\n  if (par != SISL_NULL)\n    freearray(par);\n  if (der != SISL_NULL)\n    freearray(der);\n  if (sval1 != SISL_NULL)\n    freearray (sval1);\n  if (sval2 != SISL_NULL)\n    freearray (sval2);\n  if ((ikind == 2 || ikind == 4) && (tempcurv != SISL_NULL))\n    freeCurve (tempcurv);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1378.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1378.c,v 1.3 2001-03-19 15:58:48 afr Exp $\n *\n */\n\n\n#define S1378\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1378 (SISLSurf * psurf, double econic[], int ideg, int idim,\n       SISLSurf ** rsurf, int *jstat)\n#else\nvoid\ns1378 (psurf, econic, ideg, idim, rsurf, jstat)\n     SISLSurf *psurf;\n     double econic[];\n     int ideg;\n     int idim;\n     SISLSurf **rsurf;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To put a surface description into the descripiton of\n*              a torus surface described by the input array econic.\n*\n* INPUT      : psurf  - Pointer to input surface\n*              econic - Description of torus\n*              ideg   - Type of conic: torus: ideg=1001\n*              idim   - Dimension of object space\n*\n* OUTPUT     : rsurf  - The resulting surface\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : We first make the appropriate knot vector, then we calulate\n*              parametervalues for the interpolation, then the appropriate\n*              values of the surface put into the conic equation are found,\n*              and at last the surface is interpolated.\n*\n* REFERENCES :\n*\n* CALLS      : s1376,s1890,s1424,s6scpr,s1891,s6err.\n*\n* WRITTEN BY : Tor Dokken, SI, 1988-11\n* REVISED BY : Mike Floater, SI, 1991-01 for a rational surface.\n*\n*********************************************************************\n*/\n{\n  int ikind;\t\t\t/* type of surface psurf is                         */\n  int kn1;\t\t\t/* Number of vertices of psurf in first par.dir     */\n  int kk1;\t\t\t/* Order in  psurf in first par.dir                 */\n  int kn2;\t\t\t/* Number of vertices of psurf in second par.dir    */\n  int kk2;\t\t\t/* Order in  psurf in second par.dir                */\n  int kjkk1;\t\t\t/* Order of interpolated basis in first par.dir     */\n  int kjkn1;\t\t\t/* Number of vertices in interpolated basis first.dr*/\n  int kjkk2;\t\t\t/* Order of interpolated basis in first par SISLdir     */\n  int kjkn2;\t\t\t/* Number of vertices in interpolated basis secnd.dr*/\n  int kdim;\t\t\t/* Number of dimesions in psurf                     */\n  int kstat;\t\t\t/* Local status variable                            */\n  int kpos = 0;\t\t\t/* Position indicator for errors                    */\n  int kzero = 0;\t\t/* Value 0 needed in call s1891\t\t          */\n  int kone = 1;\t\t\t/* Value 1 needed in call s1891\t\t\t  */\n  int cuopen;\t\t\t/* Open/Closed flag                                 */\n  int ki, kj, kl;\t\t/* Loop control variable                            */\n  int kp;\t\t\t/* Index of points put into conic equation          */\n  int klfs = 0;\t\t\t/* Pointer into knot vector                         */\n  int klft = 0;\t\t\t/* Pointer into knot vector                         */\n  double *st1 = SISL_NULL;\t\t/* First knot vector is psurf                       */\n  double *st2 = SISL_NULL;\t\t/* Second knot vector is psurf                      */\n  double *scentr = econic;\t/* Center of torus             */\n  double *saxis = econic + 3;\t/* Axis of torus               */\n  double tbigr = *(econic + 6);\t/* Big radius of torus         */\n  double tsmalr = *(econic + 7);/* Small radius of torus       */\n  double tbigr2 = tbigr * tbigr;/* Square of big radius        */\n  double tdiffr2 = tbigr2 - tsmalr * tsmalr;\t/* Difference of square of radia*/\n  double *sval1 = SISL_NULL;\t\t/* Array of values of surface put into torus eq.    */\n  double *sval2 = SISL_NULL;\n  double *sval3 = SISL_NULL;\n  double *sgt1 = SISL_NULL;\t\t/* Knot vector in first parameter direction of\n\t\t\t\t   surface put into torus equation                  */\n  double *sgt2 = SISL_NULL;\t\t/* Knot vector in second parameter direction of\n\t\t\t\t   surface put into torus equation                  */\n  double sy[3];\t\t\t/* Difference between point and torus center        */\n  double tzn;\t\t\t/* Projection of sy onto torus axis                 */\n  double tyy;\t\t\t/* Square of length of sy                           */\n  double tzz;\t\t\t/* Square of length of sz                           */\n  double ty;\t\t\t/* Component of sy                                  */\n  double tz;\t\t\t/* Component of sz                                  */\n  double sder[4];\t\t/* SISLPoint on the surface                         */\n  double spar[2];\t\t/* Current parameter pair                           */\n  double ww;\t\t\t/* the weight of sder squared if psurf is rational  */\n  double *par1 = SISL_NULL;\t\t/* Parameter vaues in direction 1. \t\t  */\n  double *par2 = SISL_NULL;\t\t/* Parameter vaues in direction 2. \t\t  */\n  int *der1 = SISL_NULL;\t\t/* Derivative indicators in direction 1.\t\t  */\n  int *der2 = SISL_NULL;\t\t/* Derivative indicators in direction 2.\t\t  */\n  SISLSurf *tempsurf = SISL_NULL;\t/* only used for rational surfaces             */\n\n  *jstat = 0;\n\n\n  /* Test if torus. */\n\n  if (ideg != 1001)\n    goto err180;\n\n  if (idim != psurf->idim)\n    goto err104;\n\n  /* Make local pointers. */\n\n  kn1 = psurf->in1;\n  kk1 = psurf->ik1;\n  kn2 = psurf->in2;\n  kk2 = psurf->ik2;\n  kdim = psurf->idim;\n  st1 = psurf->et1;\n  st2 = psurf->et2;\n  ikind = psurf->ikind;\n\n  if (ikind == 2 || ikind == 4)\n    {\n      tempsurf = newSurf (kn1, kn2, kk1, kk2, st1, st2,\n\t\t\t  psurf->rcoef, ikind - 1, kdim + 1, 0);\n      if (tempsurf == SISL_NULL)\n\tgoto err171;\n      tempsurf->cuopen_1 = psurf->cuopen_1;\n      tempsurf->cuopen_2 = psurf->cuopen_2;\n    }\n  else\n    {\n      tempsurf = psurf;\n    }\n\n  /* Test input. */\n\n  if (kdim != 3)\n    goto err104;\n\n\n  /* Make description of knot array for interpolation in first parameter\n     direction. */\n\n  s1376 (st1, kn1, kk1, &sgt1, &kjkn1, &kjkk1, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Make parameter values and derivative indicators. */\n\n  s1890 (sgt1, kjkk1, kjkn1, &par1, &der1, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Make description of knot array for interpolation in second parameter\n     direction. */\n\n  s1376 (st2, kn2, kk2, &sgt2, &kjkn2, &kjkk2, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Make parameter values and derivative indicators. */\n\n  s1890 (sgt2, kjkk2, kjkn2, &par2, &der2, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Allocate array for values of surface put into torus equation. */\n\n  sval1 = newarray (kjkn1 * kjkn2, DOUBLE);\n  if (sval1 == SISL_NULL)\n    goto err101;\n\n\n  /* Calculate values to be interpolated. */\n\n  /* Index of point to be stored. */\n\n  kp = 0;\n\n  for (kj = 0; kj < kjkn2; kj++)\n    {\n\n      spar[1] = par2[kj];\n\n      for (ki = 0; ki < kjkn1; ki++)\n\t{\n\t  /*  Calculate values on 3-D surface */\n\n\t  spar[0] = par1[ki];\n\n\t  s1424 (tempsurf, 0, 0, spar, &klfs, &klft, sder, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  /*\n\t   *       The calculation of a point on the torus surface\n\t   *\t\t can be done in the following way.\n\t   *\n\t   *          y = p - scentr\n\t   *          z = y - (y saxis) saxis\n\t   *\n\t   *       The equation of the torus can be written\n\t   *\n\t   *                              2    2\n\t   *          (y - R z/sqrt(z z) )  - r = 0\n\t   *\n\t   *\n\t   *       or by elliminating the square root:\n           *\n           *          f =\n\t   *\n\t   *              2           2  2      2       2  2 2\n\t   *          (yy)  + 2 (yy)(R -r ) - 4R zz + (R -r )  = 0\n\t   *\n           *       or in 4-D homogeneous coordinates:\n           *\n           *                                               4\n           *          f =\n\t   *\n\t   *              2      2      2  2      2 2      4  2  2 2\n\t   *          (yy)  + 2 w (yy)(R -r ) - 4w R zz + w (R -r )  = 0\n\t   *\n\t   *         where Y = T - w*scentr,  p+T/w\n\t   *\n\t   *       We thus need to calculate yy and zz:\n\t   */\n\n\t  if (ikind == 2 || ikind == 4)\n\t    {\n\t      for (kl = 0; kl < 3; kl++)\n\t\tsy[kl] = sder[kl] - sder[3] * scentr[kl];\n\t      ww = sder[3] * sder[3];\n\t    }\n\t  else\n\t    {\n\t      for (kl = 0; kl < 3; kl++)\n\t\tsy[kl] = sder[kl] - scentr[kl];\n\t      ww = (double) 1.0;\n\t    }\n\n\t  tzn = s6scpr (sy, saxis, 3);\n\n\t  tyy = (double) 0.0;\n\t  tzz = (double) 0.0;\n\n\t  /*      Make z and necessary derivatives of z */\n\n\t  for (kl = 0; kl < 3; kl++)\n\t    {\n\t      ty = sy[kl];\n\t      tz = ty - tzn * saxis[kl];\n\t      tyy += ty * ty;\n\t      tzz += tz * tz;\n\t    }\n\n\t  /*                                      2            2   2\n\t     Now tyy = yy and tzz = zz, tbigr2 = R ,tdiffr2 = R - r   */\n\n\t  sval1[kp++] = tyy * tyy + ((double) 2.0 * ww * tyy + ww * ww * tdiffr2) * tdiffr2\n\t    - (double) 4.0 *ww * tbigr2 * tzz;\n\t}\n    }\n\n  cuopen = TRUE;\n\n  /* Interpolate in second parameter direction, the first parameter direction\n     is treated as a point of dimension kjkn1 */\n\n  s1891 (par2, sval1, kjkn1, kjkn2, kone, der2, cuopen, sgt2, &sval2,\n\t &kjkn2, kjkk2, kzero, kzero, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Interpolate in first parameter direction, perform kjkn2 interpolations\n     of one dimensional data */\n\n  s1891 (par1, sval2, kone, kjkn1, kjkn2, der1, cuopen, sgt1, &sval3,\n\t &kjkn1, kjkk1, kzero, kzero, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  *rsurf = SISL_NULL;\n  *rsurf = newSurf (kjkn1, kjkn2, kjkk1, kjkk2, sgt1, sgt2, sval3, 1, 1, 1);\n  if (*rsurf == SISL_NULL)\n    goto err171;\n  (*rsurf)->cuopen_1 = psurf->cuopen_1;\n  (*rsurf)->cuopen_2 = psurf->cuopen_2;\n\n  /* Ok ! */\n\n  goto out;\n\n\n  /* Error in lower level function */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1378\", *jstat, kpos);\n  goto out;\n\n  /* Error in space allocation */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1378\", *jstat, kpos);\n  goto out;\n\n  /* Dimension not equal to 3  or confliciting dim  */\n\nerr104:\n  *jstat = -104;\n  s6err (\"s1378\", *jstat, kpos);\n  goto out;\n\n  /* Could not create surface. */\n\nerr171:\n  *jstat = -171;\n  s6err (\"s1378\", *jstat, kpos);\n  goto out;\n\n  /* Error in torus description */\n\nerr180:\n  *jstat = -180;\n  s6err (\"s1378\", *jstat, kpos);\n  goto out;\n\nout:\n\n  /* Release allocated arrays */\n\n  if (sgt1 != SISL_NULL)\n    freearray (sgt1);\n  if (sgt2 != SISL_NULL)\n    freearray (sgt2);\n  if (sval1 != SISL_NULL)\n    freearray (sval1);\n  if (sval2 != SISL_NULL)\n    freearray (sval2);\n  if (sval3 != SISL_NULL)\n    freearray (sval3);\n  if (par1 != SISL_NULL)\n    freearray(par1);\n  if (par2 != SISL_NULL)\n    freearray(par2);\n  if (der1 != SISL_NULL)\n    freearray(der1);\n  if (der2 != SISL_NULL)\n    freearray(der2);\n  if ((ikind == 2 || ikind == 4) && (tempsurf != SISL_NULL))\n    freeSurf (tempsurf);\n\n\n  return;\n}\n"
  },
  {
    "path": "src/s1379.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1379.c,v 1.3 2001-03-19 15:58:48 afr Exp $\n *\n */\n\n\n#define S1379\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n  s1379(double ep[],double ev[],double epar[],int im,int idim,\n\tSISLCurve **rcurve,int *jstat)\n#else\nvoid s1379(ep,ev,epar,im,idim,rcurve,jstat)\n     double ep[];\n     double ev[];\n     double epar[];\n     int    im;\n     int    idim;\n     SISLCurve  **rcurve;\n     int    *jstat;\n#endif\n/*\n************************************************************************\n*\n* Purpose: To compute the cubic Hermit interpolant to the data given\n*          by the points ep, the derivatives ev and paramterization epar.\n*          The curve is represented as a B-spline curve.If the first and\n*          last points are exactly equal (down to the last bit) the a periodic\n*          basis with the first 1 single knot, then a 3 tupple knot is made\n*          at the start and 3 tupple knot followed by a single knot at the\n*          end. If also the derivatives at the start and end are equal then\n*          all knots will be double.\n*\n*\n* Input:\n*          ep     - Array containing the point in sequence\n*                   (x,y,..,x,y,..)\n*          ev     - Array containing the derivatives in sequence\n*                   (x,y,..,x,y,..)\n*          epar   - Parametrization array. The array should be increasing\n*                   in value.\n*          im     - Number of point and derivatives\n*          idim   - The dimension of the space the points and derivatives\n*                   lie in\n* Output:\n*          rcurve - Pointer to the curve produced\n*          jstat  - Status variable\n*                    < 0 - Error.\n* Method:\n*     The knot vector will have 4-tupple, 3-tupple or 2-tupple  knots at\n*     epar[0] and epar[im-1]. This is decided by checking if the input\n*     data is cyclic:\n*        if first point != last point  4-tupple knots\n*        if first == last and there derivatives different 3-tupple\n*        if both position and derivatives equal 2-tupple\n*     In the case not 4-tupple knots the new knot intervals are made cyclic.\n*\n*     Suppose we have reached data point no. j which corresponds to the\n*     parameter value z=epar(j), i.e., the knot vector et has a double\n*     knot at z, and these knots must be et(2*j+1) and et(2*j+2).\n*     then there are only two B-splines which are nonzero at z, namely\n*     B(2*j-1) and B(2*j) (remember everything is cubic), and these are\n*     also the only B-splines with nonzero derivative at z. we can\n*     therefore determine the coefficients of these two B-splines,\n*     ec(2*j-1) and ec(2*j), by solving a 2x2 linear system OF\n*     equations, and this can be done directly.\n*     Suppose the distance from z to the previous knot is h1 (measured\n*     in parameter interval, so h1= et(2*j+2)-et(2*j), and the distance\n*     to the next knot is h2 = et(2*j+3) -et(2*j+1). then the two\n*     B-splines and their derivatives have the following values at z:\n*\n*                B(2*j-1,z)=h2/(h1+h2),    B(2*j,z)=h1/(h1+h2)\n*               dB(2*j-1,z)=-3/(h1+h2),   dB(2*j,z)=3/(h1+h2).\n*\n*     solving the linear system for ec(2*j-1) and ec(2*j) yields\n*\n*                    ec(2*j-1)=ep(j) - h1*ev(j)/3,\n*                      ec(2*j)=ep(j) + h2*ev(j)/3.\n*\n*     it can also be easily checked that these equations are valid for\n*     the first two and last two coefficients as well, provided one\n*     sets h1=0 and h2=0, respectively.\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI 1988-11\n* Revised by : Tor Dokken, SI 1992-04\n* Revised by : Johs. Kaasa,SI 1993-01\n*\n*********************************************************************\n*/\n{\n  int ki,kj;          /* Loop variables                              */\n  int kk;             /* Polynomial order                            */\n  int kn;             /* Number of vertices                          */\n  int kpoint;         /* Pointer into point and derivative array     */\n  int kcoef;          /* Pointer into coefficient array              */\n  int kpos=0;         /* Position of error                           */\n  int kthis;          /* Current point                               */\n  int kstat=0;        /* Status variable                             */\n  int kcycpos = 1;    /* Flag telling if first and last points are equal */\n  int kcycder = 1;    /* Flag telling if first and last derviatives are equal */\n  double *st=SISL_NULL;    /* Knot vector                                 */\n  double *scoef=SISL_NULL; /* B-spline vertices                           */\n  double th1,th2;     /* Parameter intervals                         */\n\n\n\n  /* Check input */\n\n  if (im < 2)   goto err181;\n  if (idim < 1) goto err102;\n\n  /* Set the dimension and order of the spline space */\n\n  kn = 2*im;\n  kk = 4;\n\n  /* Allocate arrays for temporary storage of knots and vertices */\n\n  st    = newarray(kn+kk,DOUBLE);\n  if (st == SISL_NULL) goto err101;\n  scoef = newarray(idim*kn,DOUBLE);\n  if (scoef == SISL_NULL) goto err101;\n\n  /* Check if the curve is periodic, e.g. if first and last points are\n     equal and/or that first and last derivates are equal */\n\n  /*  for (kj=0, kcycpos=1 ; kj<idim && kcycpos == 1 ; kj++)\n     if (ep[kj] != ep[idim*(im-1)+kj]) kcycpos =0; */\n  for (kj=0, kcycpos=1 ; kj<idim && kcycpos == 1 ; kj++)\n     if (DNEQUAL(ep[kj], ep[idim*(im-1)+kj])) kcycpos =0;\n\n  /*  for (kj=0, kcycder=1 ; kj<idim && kcycder == 1 ; kj++)\n    if (ev[kj] != ev[idim*(im-1)+kj]) kcycder= 0; */\n  for (kj=0, kcycder=1 ; kj<idim && kcycder == 1 ; kj++)\n    if (DNEQUAL(ev[kj], ev[idim*(im-1)+kj])) kcycder= 0;\n\n  /* Make the knot vector, first all knots except the two first and the two last */\n\n  for (ki=2,kj=0 ; ki<kn+2 ; ki+=2, kj++)\n    st[ki] = st[ki+1] = epar[kj];\n\n\n\n  /* Make the two first and two last knots */\n\n  if (kcycder == 1 && kcycpos == 1)\n    {\n      /* Two first knots to be shifted */\n\n      st[0]= st[1] = epar[0] - (epar[im-1]-epar[im-2]);\n      st[kn+2]= st[kn+3] = epar[im-1] + epar[1] - epar[0];\n    }\n  else if (kcycder ==0 && kcycpos ==1)\n    {\n      /* First and last knot to be shifted */\n\n      st[0] = epar[0] - (epar[im-1]-epar[im-2]);\n      st[1] = st[2];\n      st[kn+2] = st[kn];\n      st[kn+3] = epar[im-1] + epar[1] - epar[0];\n    }\n  else\n    {\n      /* k-regular basis */\n\n      st[0] = st[1] = st[2];\n      st[kn+2] = st[kn+3] = st[kn];\n    }\n\n  /* Compute knot vector and coefficients as indicated above */\n\n  for (kj=0, kcoef=0, kpoint = 0 ; kj < kn ; kj+=2)\n    {\n      th1 = st[kj+3] - st[kj+1];\n      th2 = st[kj+4] - st[kj+2];\n\n      /*  Compute coefficient no kj */\n\n      kthis = kpoint;\n      for (ki=0;ki<idim;ki++,kpoint++)\n        {\n\t  scoef[kcoef++] = ep[kpoint] - th1*ONE_THIRD*ev[kpoint];\n        }\n\n      /*  Compute coefficient no kj+1 */\n\n      kpoint = kthis;\n      for (ki=0;ki<idim;ki++,kpoint++)\n        {\n\t  scoef[kcoef++] = ep[kpoint] + th2*ONE_THIRD*ev[kpoint];\n        }\n    }\n\n  /* Make new curve object */\n\n  *rcurve = newCurve(kn,kk,st,scoef,1,idim,1);\n  if (*rcurve == SISL_NULL) goto err101;\n\n  /* Remove unneccesarry knots */\n\n  s6crvcheck(*rcurve,&kstat);\n  if (kstat<0) goto error;\n\n  /* Periodicity flag */\n  if (kcycpos)\n    {\n       test_cyclic_knots((*rcurve)->et,(*rcurve)->in,(*rcurve)->ik,&kstat);\n       if (kstat<0) goto error;\n       if (kstat == 2) (*rcurve)->cuopen = SISL_CRV_PERIODIC;\n    }\n\n  /* Calculation completed */\n\n  *jstat = 0;\n  goto out;\n\n\n  /* Error in space allocation. Return zero. */\n\n\n  /* Error in space allocation */\n err101: *jstat = -101;\n  s6err(\"s1379\",*jstat,kpos);\n  goto out;\n\n\n  /* Dimension less than 1*/\n err102: *jstat = -102;\n  s6err(\"s1379\",*jstat,kpos);\n  goto out;\n\n  /* Too few interpolation conditions */\n\n err181: *jstat = -181;\n  s6err(\"s1379\",*jstat,kpos);\n  goto out;\n\n error:  *jstat =kstat;\n  s6err(\"s1379\",*jstat,kpos);\n  goto out;\n\n out:\n  if (st != SISL_NULL) freearray(st);\n  if (scoef != SISL_NULL) freearray(scoef);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1380.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1380.c,v 1.2 2001-03-19 15:58:48 afr Exp $\n *\n */\n\n\n#define S1380\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1380(double ep[],double ev[],int im,int idim,int ipar,\n\t   SISLCurve **rcurve,int *jstat)\n#else\nvoid s1380(ep,ev,im,idim,ipar,rcurve,jstat)\n     double ep[];\n     double ev[];\n     int    im;\n     int    idim;\n     int    ipar;\n     SISLCurve  **rcurve;\n     int    *jstat;\n#endif\n/*\n************************************************************************\n*\n* Purpose: To compute the cubic Hermit interpolant to the data given\n*          by the points ep and the derivatives ev. \n*          The curve is represented as a B-spline curve.\n*\n* Input:\n*          ep     - Array containing the point in sequence\n*                   (x,y,..,x,y,..)\n*          ev     - Array containing the derivatives in sequence\n*                   (x,y,..,x,y,..)\n*          im     - Number of point and derivatives\n*          idim   - The dimension of the space the points and derivatives\n*                   lie in\n*          ipar   - Type of parametrization\n*                    1 - Parametrization using cordlength between point\n*                  !=1 - Uniform parametrization\n* Output:\n*          rcurve - Pointer to the curve produced\n*          jstat  - Status variable\n*                    < 0 - Error.\n* Method:\n*     First the parmaterization is calculated and then the interpolation\n*     is performed using s1379.\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI 1988-11\n*\n*********************************************************************\n*/                                                               \n{\n  int ki;             /* Loop variables                              */\n  int kpek1,kpek2;    /* Pointers into point array                   */\n  int kstat;          /* Status variable                             */\n  int kpos=0;         /* Position of error                           */\n  double *spar=SISL_NULL;  /* Pointer to parametrization array            */\n  \n  \n  \n  /* Check input */        \n  \n  if (im < 2)   goto err181;\n  if (idim < 1) goto err102;\n  \n  /* Allocate array for parametrization */\n  \n  spar = newarray(im,DOUBLE);\n  if (spar == SISL_NULL) goto err101;\n  \n  spar[0] = (double)0.0;\n  \n  if (ipar == 1)                 \n    {\n      /*  Cord length parametrization */\n      \n      kpek1 = 0;\n      for (ki=1 ; ki<im ; ki++)\n\t{\n\t  kpek2 = kpek1 + idim;\n\t  spar[ki] = spar[ki-1] + s6dist(&ep[kpek2],&ep[kpek1],idim);\n\t  kpek1 = kpek2;\n\t}\n    }\n  else\n    {\n      /*  Uniform parametrization */\n      for (ki=0;ki<im;ki++)\n\tspar[ki] = ki;\n    }\n  \n  /* Calculate Hermite interpolant */\n  \n  s1379(ep,ev,spar,im,idim,rcurve,&kstat);\n  if (kstat<0) goto error;\n  \n  /* Calculation completed */\n  \n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error in space allocation. Return zero. */\n  \n  \n  /* Error in space allocation */\n err101: *jstat = -101;\n  s6err(\"s1380\",*jstat,kpos);\n  goto out;\n  \n  \n  /* Dimension less than 1*/\n err102: *jstat = -102;\n  s6err(\"s1380\",*jstat,kpos);\n  goto out;\n  \n  /* Too few interpolation conditions */\n  \n err181: *jstat = -181;\n  s6err(\"s1380\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine */\n  \n error:  *jstat = kstat;\n  s6err(\"s1380\",*jstat,kpos);\n  goto out;\n  \n  \n out:\n  if (spar != SISL_NULL) freearray(spar);\n  \n  return;\n}\n"
  },
  {
    "path": "src/s1381.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1381.c,v 1.2 2001-03-19 15:58:48 afr Exp $\n *\n */\n\n\n#define S1381\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1381(double et[],int in,int ik,double **gt,int *jkn,int jkk,int *jstat)           \n#else\nvoid s1381(et,in,ik,gt,jkn,jkk,jstat)\n     double et[];\n     int    in;\n     int    ik;\n     double **gt;\n     int    *jkn;\n     int    jkk;\n     int    *jstat;           \n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make the knot vector for the representing a spline\n*              basis of order jkk with the same knot values as et.\n*              This basis is used e.g. for representing the silhouette line\n*              functions of a surface. \n                   jkk = 2*ik-2  for ordinary silhouette\n                   jkk = 3*ik-3  for perspective silhouette\n                   jkk = 3*ik-3  for circular silhouette\n*\n* INPUT      : et     - Knots of input spline basis\n*              in     - Number of vertices in input basis\n*              ik     - Order of input basis\n*              jkk    - Order of B-spline basis produced\n*\n* OUTPUT     : gt     - Pointer to array of knots. The array is allocated\n*                       inside this routine.\n*              jkn    - Number of vertices\n*\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n* METHOD     : \n*\n* REFERENCES :\n*\n*-                                   \n* CALLS      : \n*\n* WRITTEN BY : Tor Dokken, SI, 88-11.\n* REVISED BY : Mike Floater, SI, 91-04 jkk is input not output.\n*\n*********************************************************************\n*/                                                               \n{                                                                     \n  double tval;     /* Value of knot                                 */\n  double *sdum;    /* Pointer to knot array                         */\n  int ki,kl;       /* Variable in loop                              */\n  int knumb;       /* Number of intervals                           */\n  int kstop;       /* Loop stop variable                            */\n  int kpos=0;      /* Position of error                             */\n  \n  /* Run through the knot vector to decide how many intervals exist */\n  knumb = 0;       \n  tval = et[ik-1];\n  \n  for (ki=ik ; ki<=in ; ki++)\n    {\n      if (tval < et[ki])\n        {\n\t  /*      New knot value found */\n\t  knumb = knumb + 1;\n\t  tval = et[ki];\n        }\n    }\n  \n  *jkn = (jkk-1)*(knumb-1) + jkk;\n  \n  sdum = newarray(*jkn+jkk,DOUBLE);\n  if (sdum == SISL_NULL) goto err101;\n  \n  *gt  = sdum; \n  \n  /* Make knot values */\n  \n  tval = et[ik-1];\n  \n  /* Make jkk first knot values */\n  \n  for (kl=0;kl<jkk;kl++)\n    {        \n      sdum[kl] = tval;\n    }\n  \n  /* kl points to the array entry where the next knot value is to be stored\n   */\n  \n  for (ki=ik ; ki<=in ; ki++)\n    {\n      if (tval < et[ki])\n        {\n\t  /* New knot value, remember this and make knots */\n\t  tval = et[ki];\n\t  kstop = kl + jkk-1;\n\t  for (;kl<kstop;kl++)\n            sdum[kl] = tval;\n        }   \n    }\n  \n  /* Make last knot value */\n  \n  sdum[kl] = tval;\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation */\n err101: *jstat = -101;\n  s6err(\"s1381\",*jstat,kpos);\n  goto out;\n out:\n  \n  return;\n}                                               \n"
  },
  {
    "path": "src/s1382.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1382.c,v 1.2 2001-03-19 15:58:48 afr Exp $\n *\n */\n\n\n#define S1382\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1382 (SISLSurf * psurf, double eview[], int idim, SISLSurf ** rsurf,\n       int *jstat)\n#else\nvoid\ns1382 (psurf, eview, idim, rsurf, jstat)\n     SISLSurf *psurf;\n     double eview[];\n     int idim;\n     SISLSurf **rsurf;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To make the function whose zeroes describes the silhouette\n*              lines of a surface. The silhouette lines are described\n*              by a viewing direction.\n*\n* INPUT      : psurf  - Pointer to input surface.\n*              eview  - Viewing direction.\n*              idim   - Dimension of the space in which the surface lies.\n*\n* OUTPUT     : rsurf  - The resulting surface\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : We first make the appropriate knot vector, then we calulate\n*              parameter values for the interpolation, then the normal\n*              vectors of the surface are calculated at these parameter\n*              values. The scalar product of the normal vector and the\n*              viewing direction is made and these values are interpolated\n*              to make the function describing the silhouette lines.\n*\n*              For nonrational surfaces the function whose zeroes form the\n*              silhouette is\n*\n*                      f = N . eview = (P xP ) . eview\n*                                        U  V\n*\n*              which, if P is degree m x n, is degree 2m-1 x 2n-1\n*              or order 2(m+1)-2 x 2(n+1)-2.\n*              In the rational case, setting  P(U,V) = T(U,V) / w(U,V), we find\n*\n*                                                     4\n*                      P xP =(wT -w T) x (wT -w T) / w\n*                       U  V    U  U        V  V\n*\n*                                                      3\n*                           =(wT xT +w T xT+w TxT ) / w\n*                               U  V  U V    V   U\n*\n*              so we find the zeroes of\n*\n*                      f = (wT xT +w T xT+w TxT ) . eview\n*                             U  V  U V    V   U\n*\n*              which, if P is degree m x n, is degree 3m-1 x 3n-1\n*              or order 3(m+1)-3 x 3(n+1)-3.\n*\n* REFERENCES :\n*\n* CALLS      : s1381,s1890,s1421,s6crss,c6scpr,s1891,s6err.\n*\n* WRITTEN BY : Tor Dokken, SI, 1988-11\n* REVISED BY : Mike Floater, SI, 1991-04 for rational surfaces\n*\n*********************************************************************\n*/\n{\n  int kn1;\t\t\t/* Number of vertices of psurf in first par.dir     */\n  int kk1;\t\t\t/* Order in  psurf in first par.dir                 */\n  int kn2;\t\t\t/* Number of vertices of psurf in second par.dir    */\n  int kk2;\t\t\t/* Order in  psurf in second par.dir                */\n  int kjkk1;\t\t\t/* Order of interpolated basis in first par.dir     */\n  int kjkn1;\t\t\t/* Number of vertices in interpolated basis first.dr*/\n  int kjkk2;\t\t\t/* Order of interpolated basis in first par SISLdir */\n  int kjkn2;\t\t\t/* Number of vertices in interpolated basis secnd.dr*/\n  int kdim;\t\t\t/* Number of dimesions in psurf                     */\n  int kstat = 0;\t\t/* Local status variable                            */\n  int kpos = 0;\t\t\t/* Position indicator for errors                    */\n  int kzero = 0;\t\t/* Value 0 needed in call s1891   \t          */\n  int kone = 1;\t\t\t/* Value 1 needed in call s1891\t\t          */\n  int cuopen;\t\t\t/* Used as a logical parameter\t\t\t  */\n  int ki, kj;\t\t\t/* Loop control variable                            */\n  int kp;\t\t\t/* Index of points put into conic equation          */\n  int klfs = 0;\t\t\t/* Pointer into knot vector                         */\n  int klft = 0;\t\t\t/* Pointer into knot vector                         */\n  double *st1 = SISL_NULL;\t\t/* First knot vector is psurf                       */\n  double *st2 = SISL_NULL;\t\t/* Second knot vector is psurf                      */\n  double *sval1 = SISL_NULL;\t\t/* Array of values of surface put into torus eq.    */\n  double *sval2 = SISL_NULL;\n  double *sval3 = SISL_NULL;\n  double *sgt1 = SISL_NULL;\t\t/* Knot vector in first parameter direction of\n\t\t\t\t   surface put into torus equation                  */\n  double *sgt2 = SISL_NULL;\t\t/* Knot vector in second parameter direction of\n\t\t\t\t   surface put into torus equation                  */\n  double sder[12];\t\t/* SISLPoint on the surface                             */\n  double spar[2];\t\t/* Current parameter pair                           */\n  double snorm[3];\t\t/* Normal vector                                    */\n  int i;\t\t\t/* a loop variable                                  */\n  int ikind;\t\t\t/* kind of surface psurf is                         */\n  double tutv[3];\t\t/* T_u x T_v  in rational case                      */\n  double tvt[3];\t\t/* T_v x T    in rational case                      */\n  double ttu[3];\t\t/* T   x T_u  in rational case                      */\n  double *par1 = SISL_NULL;\n  double *par2 = SISL_NULL;\n  int *der1 = SISL_NULL;\n  int *der2 = SISL_NULL;\n  SISLSurf *tempsurf = SISL_NULL;\t/* only used for rational surfaces                  */\n\n  *jstat = 0;\n\n  if (idim != psurf->idim)\n    goto err104;\n\n  /* Make local pointers */\n\n  kn1 = psurf->in1;\n  kk1 = psurf->ik1;\n  kn2 = psurf->in2;\n  kk2 = psurf->ik2;\n  kdim = psurf->idim;\n  st1 = psurf->et1;\n  st2 = psurf->et2;\n  ikind = psurf->ikind;\n\n\n  /* Test input */\n\n  if (kdim != 3)\n    goto err104;\n\n  if (ikind == 2 || ikind == 4)\n    {\n      /* A tricky way to evaluate the derivatives of the HOMOGENEOUS form\n\t of psurf. In other words we need the derivs of T(u,v) where\n\t p(u,v) = T(u,v) / w(u,v).\n\t We should really have a separate evaluator for this\n\t but I didn't want to mess around with the existing evaluator\n\t which does the division automatically. MF 16/4/91 */\n\n      tempsurf = newSurf (kn1, kn2, kk1, kk2, st1, st2, psurf->rcoef,\n\t\t\t  ikind - 1, kdim + 1, 0);\n      if (tempsurf == SISL_NULL)\n\tgoto err171;\n      tempsurf->cuopen_1 = psurf->cuopen_1;\n      tempsurf->cuopen_2 = psurf->cuopen_2;\n\n      kjkk1 = 3 * kk1 - 3;\n      kjkk2 = 3 * kk2 - 3;\n    }\n  else\n    {\n      tempsurf = psurf;\n      kjkk1 = 2 * kk1 - 2;\n      kjkk2 = 2 * kk2 - 2;\n    }\n\n\n  /* Make description of knot array for interpolation in first parameter\n     direction */\n\n  s1381 (st1, kn1, kk1, &sgt1, &kjkn1, kjkk1, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Make parameter values and derivative indicators */\n\n  s1890 (sgt1, kjkk1, kjkn1, &par1, &der1, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Make description of knot array for interpolation in second parameter\n     direction\n     */\n\n  s1381 (st2, kn2, kk2, &sgt2, &kjkn2, kjkk2, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Make parameter values and derivative indicators */\n\n  s1890 (sgt2, kjkk2, kjkn2, &par2, &der2, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Allocate array for values of surface put into torus equation */\n\n  sval1 = newarray (kjkn1 * kjkn2, DOUBLE);\n  if (sval1 == SISL_NULL)\n    goto err101;\n\n\n  /* Calculate values to be interpolated */\n\n  /* Index of point to be stored */\n\n  kp = 0;\n\n  for (kj = 0; kj < kjkn2; kj++)\n    {\n\n      spar[1] = par2[kj];\n\n      for (ki = 0; ki < kjkn1; ki++)\n\t{\n\t  /* Calculate values on 3-D surface */\n\n\t  spar[0] = par1[ki];\n\n\t  s1421 (tempsurf, 1, spar, &klfs, &klft, sder, snorm, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  if (ikind == 2 || ikind == 4)\n\t    {\n\t      /* Calculate f = (wT xT +w T xT+w TxT ) . eview\n\t                          U  V  U V    V   U\n                 instead of normal to surface in rational case. */\n\n\t      s6crss (sder + 4, sder + 8, tutv);\n\t      s6crss (sder + 8, sder, tvt);\n\t      s6crss (sder, sder + 4, ttu);\n\n\t      for (i = 0; i < 3; i++)\n\t\t{\n\t\t  snorm[i] = sder[3] * tutv[i] + sder[7] * tvt[i] +\n\t\t    sder[11] * ttu[i];\n\t\t}\n\t    }\n\n\t  /* Make scalar product of normal vector and eview */\n\n\t  sval1[kp++] = s6scpr (snorm, eview, kdim);\n\t}\n    }\n\n  cuopen = TRUE;\n\n  /* Interpolate in second parameter direction, the first parameter direction\n     is treated as a point of dimension kjkn1 */\n\n  s1891 (par2, sval1, kjkn1, kjkn2, kone, der2, cuopen, sgt2, &sval2,\n\t &kjkn2, kjkk2, kzero, kzero, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Interpolate in first parameter direction, perform kjkn2 interpolations\n     of one dimensional data */\n\n  s1891 (par1, sval2, kone, kjkn1, kjkn2, der1, cuopen, sgt1, &sval3,\n\t &kjkn1, kjkk1, kzero, kzero, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  *rsurf = SISL_NULL;\n  *rsurf = newSurf (kjkn1, kjkn2, kjkk1, kjkk2, sgt1, sgt2, sval3, 1, 1, 1);\n  if (*rsurf == SISL_NULL)\n    goto err171;\n  (*rsurf)->cuopen_1 = psurf->cuopen_1;\n  (*rsurf)->cuopen_2 = psurf->cuopen_2;\n\n  /* Ok ! */\n\n  goto out;\n\n\n  /* Error in lower level function */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1382\", *jstat, kpos);\n  goto out;\n\n  /* Error in space allocation */\nerr101:\n  *jstat = -101;\n  s6err (\"s1382\", *jstat, kpos);\n  goto out;\n\n  /* Dimension not equal to 3 or conflicitng dim   */\n\nerr104:\n  *jstat = -104;\n  s6err (\"s1382\", *jstat, kpos);\n  goto out;\n\n  /* Could not create surface. */\n\nerr171:\n  *jstat = -171;\n  s6err (\"s1382\", *jstat, kpos);\n  goto out;\n\nout:\n\n  /* Release allocated arrays */\n\n  if (sgt1 != SISL_NULL)\n    freearray (sgt1);\n  if (sgt2 != SISL_NULL)\n    freearray (sgt2);\n  if (sval1 != SISL_NULL)\n    freearray (sval1);\n  if (sval2 != SISL_NULL)\n    freearray (sval2);\n  if (sval3 != SISL_NULL)\n    freearray (sval3);\n  if (par1 != SISL_NULL)\n    freearray(par1);\n  if (par2 != SISL_NULL)\n    freearray(par2);\n  if (der1 != SISL_NULL)\n    freearray(der1);\n  if (der2 != SISL_NULL)\n    freearray(der2);\n  if ((ikind == 2 || ikind == 4) && (tempsurf != SISL_NULL))\n    freeSurf (tempsurf);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1383.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1383.c,v 1.5 2009-03-18 13:30:55 vsk Exp $\n *\n */\n\n\n#define S1383\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1383(SISLSurf *psurf,SISLCurve *pcurv,double aepsge,double amax,int ider,\n\t   SISLCurve **rcpos,SISLCurve **rcder1,SISLCurve **rcder2,int *jstat)\n#else\nvoid s1383(psurf,pcurv,aepsge,amax,ider,rcpos,rcder1,rcder2,jstat)\n     SISLSurf   *psurf;\n     SISLCurve  *pcurv;\n     double aepsge;\n     double amax;\n     int    ider;\n     SISLCurve  **rcpos;\n     SISLCurve  **rcder1;\n     SISLCurve  **rcder2;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To create a 3-D B-spline approximating the curve traced out\n*              by a curve in the parameter plane.             \n*\n* INPUT      : psurf  - The surface object\n*              pcurv  - The input B-spline curve in the parameter plane   \n*              aepsge - Maximal deviation allowed between true 3-D curve\n*                       and the approximated 3-D curve.\n*              amax   - Maximal stepping length. Is negleceted if amax<=aepsge\n*                       If amax <= 0.0 the 3-D SISLbox of the surface us used\n*                       for estimating max step length\n*              ider   - Derivativ indicator\n*                        0 - Calculate only psositional curve\n*                        1 - Calculate positional + derivative curves\n*\n* OUTPUT     : \n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*              rcpos  - Pointer the approximated position curve\n*              rcder1 - Pointer the approximated position curve\n*              rcder2 - Pointer the approximated position curve\n*\n* METHOD     : \n*\n* EXAMPLE OF USE:\n*              SISLCurve *qr;         \n*              int    kstat;\n*              .\n*              .\n*\n* REFERENCES :\n*\n*-                                                 \n*              \n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. November 1988\n* CHANGED BY : Ulf J. Krystad, Oslo, Norway. April 1992\n*              call to s1312 changed to call to s1359.\n*\n*********************************************************************\n*/\n{\n  int kmaxinf;        /* Number of vertices space is allocated for       */\n  int knbinf=0;       /* Number of points stored so far                  */\n  int kstat;          /* Status variable                                 */\n  int kleftc=0;       /* Left indicator for point calculation            */\n  int klefts1=0;      /* Left indicator for point calculation            */\n  int klefts2=0;      /* Left indicator for point calculation            */\n  int kn;             /* The number of B-splines, i.e., the dimension of\n\t\t\t the spline space associated with the knot\n\t\t\t vector.                                         */\n  int kk;             /* The polynomial order of the curve.              */\n  int kdimc;          /* The dimension of the space in which the curve\n\t\t\t lies. Equivalently, the number of components\n\t\t\t of each B-spline coefficient.                   */\n  int kdims;          /* Dimension of space where the surface lies       */\n  int notaccepted;    /* Loop control variable                           */\n  int kcont;          /* Loop control variable                           */\n  int kdiv;           /* Divergence indicator                            */\n  int knbit;          /* Number of iterations                            */\n  int kpos=0;         /* Position of error                               */\n  int kpar = 1;       /* Indicate that parametrization array exist       */\n  int kmult;           /* Multiplicity of knot                           */\n  double smidd[3];    /* Middle point of current Bezier segement         */\n  double smtang[3];   /* Tangent at smidd                                */\n  double sdiff[3];    /* Difference of vectors                           */\n  double tproj1;      /* Projection of vector                            */\n  double tproj2;      /* Projection of vector                            */\n  double tlast;       /* Value in last itertion                          */\n  double tfak;        /* Necessary reduction of interval length          */\n  double *s3dinf=SISL_NULL;/* Pointer to storage for point info (10 dobules pr\n\t\t\t point when idim=3, 7 when idim=3)              */\n  double *sudpos=SISL_NULL;/* Pointer to storage of u-derivatives             */\n  double *sudder=SISL_NULL;/* Pointer to storage of ut-derivatives            */\n  double *svdpos=SISL_NULL;/* Pointer to storage of u-derivatives             */\n  double *svdder=SISL_NULL;/* Pointer to storage of vt-derivatives            */\n  double *spar=SISL_NULL;  /* Pointer to array for storage of knots           */\n  double *st;         /* Pointer to the first element of the knot vector\n\t\t\t of the curve. The knot vector has [kn+kk]\n\t\t\t elements.                                       */\n  double sder[9];     /* Position, first and second derivative on curve  */\n  double sderu[6];    /* Position and derivative of u-derivative         */\n  double sderv[6];    /* Position and derivative of v-derivative         */\n  double sdern[6];    /* Position and derivative of normal vector        */\n  double tx1,tx2,txm; /* Parameter value */\n  double tstep;       /* Step length     */\n  double tlengthend;  /* Length of 1st derivative at end of segment */\n  double tincre;      /* Parameter value increment */\n  double *start;      /* Pointer to start of current segment */\n  double tmax;        /* Local maximal step length                       */\n  double tdist;       /* Distance */\n  double tang;        /* Angle */\n  double tnew;        /* New increment */\n  double tlength;     /* Estimated length of current curve piece */\n  \n  \n  /* Make maximal step length based on box-size of surface */\n  \n   sh1992su(psurf,0,aepsge,&kstat);\n   if (kstat < 0) goto error;\n  \n  tmax = MAX(psurf->pbox->e2max[0][0] - psurf->pbox->e2min[0][0],\n\t     psurf->pbox->e2max[0][1] - psurf->pbox->e2min[0][1]);\n  tmax = MAX(tmax,psurf->pbox->e2max[0][2] - psurf->pbox->e2min[0][2]);\n  \n  if (amax>DZERO) tmax = MIN(tmax,amax);\n  \n  /* Copy curve attributes to local parameters.  */\n  \n  kdimc = pcurv -> idim;\n  kk    = pcurv -> ik;\n  kn    = pcurv -> in;\n  st    = pcurv -> et;\n  kdims = psurf -> idim;\n  \n  if (kdimc != 2 || kdims != 3) goto err105;\n  \n  kmaxinf = 100;\n  \n  /* Allocate space for storage of points,tangents, curvature and radius of\n     curvature */\n  \n  s3dinf = newarray((3*kdims+1)*kmaxinf,DOUBLE);                               \n  if (s3dinf == SISL_NULL) goto err101;\n\n  if (ider >= 1)\n    {\n      sudpos = newarray(kdims*kmaxinf,DOUBLE);                               \n      if (sudpos == SISL_NULL) goto err101;\n      sudder = newarray(kdims*kmaxinf,DOUBLE);                               \n      if (sudder == SISL_NULL) goto err101;\n      svdpos = newarray(kdims*kmaxinf,DOUBLE);                               \n      if (svdpos == SISL_NULL) goto err101;\n      svdder = newarray(kdims*kmaxinf,DOUBLE);                               \n      if (svdder == SISL_NULL) goto err101;\n    }\n  \n  /* Allocate space for parametrization array */\n  \n  spar = newarray(kmaxinf,DOUBLE);\n  if (spar == SISL_NULL) goto err101;\n  \n  /* Store knot values at start of curve */\n  \n  tx1 = st[kk-1];\n  spar[0] = tx1;\n  \n  \n  /* Make start point and intital step length */\n  \n  s1384(pcurv,psurf,kdims,1,tx1,&kleftc,&klefts1,&klefts2,\n\tsder,sderu,sderv,sdern,&kstat);\n  if (kstat<0) goto error;\n  \n  /* Calculate unit tangent and radius of curvature */\n  \n  s1307(sder,kdims,s3dinf,&kstat);\n  if (kstat<0) goto error;\n  knbinf = 1;                   \n  \n  /* Store the other calculated information */\n  \n  if (ider>=1)\n    {\n      memcopy(sudpos,sderu,kdims,DOUBLE);\n      memcopy(sudder,sderu+kdims,kdims,DOUBLE);\n      memcopy(svdpos,sderv,kdims,DOUBLE);\n      memcopy(svdder,sderv+kdims,kdims,DOUBLE);\n    }\n  \n  /* Calculate step length based on curvature */\n  \n  tstep = s1311(s3dinf[3*kdims],aepsge,tmax,&kstat);\n  if (kstat<0) goto error;\n  \n  /* Remember length of start tangent, end of zero segment */\n  \n  tlengthend = s6length(sder+kdims,kdims,&kstat);\n  if (kstat<0) goto error;                                            \n  \n  /* While end not reached */\n  \n  \n  while (tx1 < st[kn])\n    {\n      \n      /* Find candidate end point, make sure that no breaks in tangent or\n\t curvature exists between start and endpoints of the segment      */\n      \n      /* Make step length equal to aepsge if the length is zero */\n      \n      /* Find parameter value of candidate end point of segment */\n      \n      if (DEQUAL(tlengthend,DZERO))\n        { \n\t  /* Step equal to parameter resolution */\n\t  tincre = max(tx1*((double)1.0+REL_PAR_RES),REL_PAR_RES);\n        }\n      else\n        tincre = tstep/tlengthend;\n      \n      /* Make sure that we don't pass any knots */\n      \n      tx2 = MIN(tx1 + tincre,st[kleftc+1]);\n      \n      /* While segement not accepted */\n      \n      notaccepted = 1;\n      \n      while(notaccepted==1)\n        {\n\t  \n\t  /* Make end point of segment, and store it */\n\t  \n\t  if (knbinf>=kmaxinf)\n            {\n\t      kmaxinf = kmaxinf + 100;\n\t      s3dinf = increasearray(s3dinf,(3*kdims+1)*kmaxinf,DOUBLE);\n\t      if (s3dinf == SISL_NULL) goto err101;\n\t      spar   = increasearray(spar,kmaxinf,DOUBLE);\n\t      if (spar == SISL_NULL) goto err101;\n\n\t      if (ider >= 1)\n\t\t{\n\t\t  sudpos = increasearray(sudpos,kdims*kmaxinf,DOUBLE);\n\t\t  if (sudpos == SISL_NULL) goto err101;\n\t\t  sudder = increasearray(sudder,kdims*kmaxinf,DOUBLE);\n\t\t  if (sudder == SISL_NULL) goto err101;\n\t\t  svdpos = increasearray(svdpos,kdims*kmaxinf,DOUBLE);\n\t\t  if (svdpos == SISL_NULL) goto err101;\n\t\t  svdder = increasearray(svdder,kdims*kmaxinf,DOUBLE);\n\t\t  if (svdder == SISL_NULL) goto err101;\n\t\t}\n            }\n\t  \n\t  \n\t  s1384(pcurv,psurf,kdims,-1,tx2,&kleftc,&klefts1,&klefts2,\n\t\tsder,sderu,sderv,sdern,&kstat);\n\t  if (kstat<0) goto error;\n\t  \n\t  \n\t  /* Remember length of start tangent, end of zero segment */\n\t  \n\t  tlengthend = s6length(sder+kdims,kdims,&kstat);\n\t  if (kstat<0) goto error;\n\t  \n\t  \n\t  \n\t  /* Calculate unit tangent and radius of curvature */\n\t  \n\t  s1307(sder,kdims,s3dinf+(3*kdims+1)*knbinf,&kstat);\n\t  if (kstat<0) goto error;\n\t  \n\t  /* Store the other calculated information */\n\t  \n\t  if (ider>=1)\n            {\n\t      memcopy(&sudpos[kdims*knbinf],sderu,kdims,DOUBLE);\n\t      memcopy(&sudder[kdims*knbinf],sderu+kdims,kdims,DOUBLE);\n\t      memcopy(&svdpos[kdims*knbinf],sderv,kdims,DOUBLE);\n\t      memcopy(&svdder[kdims*knbinf],sderv+kdims,kdims,DOUBLE);\n            }\n\t  \n\t  \n\t  /* Decide if Hermit shape acceptable and find position and tangent\n\t     at midpoint of segment */\n\t  \n\t  start = s3dinf + (3*kdims+1)*(knbinf-1);\n\t  \n\t  s1361(start,start+(3*kdims+1),kdims,smidd,smtang,&kstat);\n\t  if (kstat<0) goto error;\n\t  \n\t  /* Iterate to midpoint of segment, start from middle of [tx1,tx2].\n\t     The iteration is performed to find the intersection between the\n\t     plane described by smidd and smtang. */\n\t  \n\t  txm = (tx1+tx2)/(double)2.0;\n\t  \n\t  kcont = 1;\n\t  kdiv    = 0;\n\t  \n\t  knbit = 0;\n\t  while (kcont==1)\n            {\n\t      \n\t      /*  Calculate position and tangent at txm */\n\t      \n\t      \n\t      \n\t      s1384(pcurv,psurf,kdims,-1,txm,&kleftc,&klefts1,&klefts2,\n\t\t    sder,sderu,sderv,sdern,&kstat);\n\t      if (kstat<0) goto error;\n\t      \n\t      /* Make difference of calculated point and smidd, project this\n\t\t onto the normal of the plane. */\n\t      \n\t      s6diff(sder,smidd,kdims,sdiff);\n\t      tproj1 = s6scpr(sdiff,smtang,kdims);\n\t      tproj2 = s6scpr(&sder[kdims],smtang,kdims);\n\t      \n\t      /* If tproj2==0 then curve tangent normal to plane, half step\n\t\t length */\n\t      \n\t      if (DEQUAL(tproj2,DZERO))\n                {\n\t\t  kdiv = 1;\n\t\t  kcont = 0;\n                }\n\t      else if (knbit==0)\n                {\n\t\t  /* First iteration */\n\t\t  knbit = 1;\n\t\t  txm -= tproj1/tproj2;\n\t\t  tlast = fabs(tproj1);\n                }\n\t      \n\t      else if (fabs(tproj1)>=tlast)\n                {\n\t\t  /* Not convergence any longer */\n\t\t  kcont = 0;\n                }\n\t      else\n                {\n\t\t  /* Still convergence */\n\t\t  txm -= tproj1/tproj2;\n\t\t  tlast = fabs(tproj1);\n\t\t  knbit += 1;\n\t\t  if (txm <=tx1 || tx2 <= txm)\n                    {\n\t\t      kdiv = 1;\n\t\t      kcont = 0;\n                    }\n                }\n            }\n\t  /* Find how close the midpoint position and tangent of the segement\n\t     is to the true curve */\n\t  \n\t  tdist = s6dist(sder,smidd,kdims);\n\t  \n\t  tang  = s6ang(&sder[kdims],smtang,kdims);\n\n\t  tlength = s6dist(start,smidd,kdims) + \n\t    s6dist(start+3*kdims+1,smidd,kdims);\n\t  \n\t  /* If the point is not within the resolution treat it as divergence\n\t   */\n\t  if (fabs(tdist) > aepsge || fabs(tang) > ANGULAR_TOLERANCE)\n            {\n\t      kdiv = 1;\n            }\n\t  \n\t  /* Dependent on previous conditions decide if the segment \n\t     is acceptable or not */\n\t  \n\t  if (kdiv==0 || tlength < (double)2*aepsge)\n            {\n\t      /* Segement acceptable */\n\t      notaccepted = 0;\n            }\n\t  else\n            {\n\t      /* Segment unacceptable. Remember that the error of the Hermit\n\t\t interpolation is O(h**4). Thus taking this into consideration\n\t\t we can determin the new parameter interval. */\n\t      \n\t      tfak = MAX(tdist/aepsge,(double)1.0);\n\t      tfak = (double)2.0*pow(tfak,ONE_FOURTH);\n\t      \n\t      tnew = MIN(tincre/(double)2.0,(tx2-tx1)/tfak);\n\t      if (DEQUAL(tmax+tnew,tmax+tincre)) goto err179;\n\t      tincre = tnew;\n\t      tx2 = tx1 + tincre;\n            }\n        }\n      \n      /* Store segment information */\n      \n      /* Make knots */\n      spar[knbinf] = tx2;\n      \n      if (kstat<0) goto error;\n      knbinf += 1;\n      \n      /* Make new step length */ \n      \n      /* Calculate step length based on curvature */\n      \n      tstep = s1311(s3dinf[(3*kdims+1)*knbinf-1],aepsge,tmax,&kstat);\n      if (kstat<0) goto error;\n      \n      /* Update start parameter value of segment, and calculate right\n\t hand derivative */\n      \n      tx1 = tx2;\n      \n      s1384(pcurv,psurf,kdims,1,tx1,&kleftc,&klefts1,&klefts2,\n\t    sder,sderu,sderv,sdern,&kstat);\n      if (kstat<0) goto error;\n      \n      kmult = s6knotmult(st,kk,kn,&kleftc,tx1,&kstat);\n      if (kstat<0) goto error;\n      \n      if (kmult>=kk-1)\n        {\n\t  if (knbinf>=kmaxinf)\n            {\n\t      kmaxinf = kmaxinf + 100;\n\t      s3dinf = increasearray(s3dinf,(3*kdims+1)*kmaxinf,DOUBLE);\n\t      if (s3dinf == SISL_NULL) goto err101;\n\t      spar   = increasearray(spar,kmaxinf,DOUBLE);\n\t      if (spar == SISL_NULL) goto err101;\n\n\t      if (ider >= 1)\n\t\t{\n\t\t  sudpos = increasearray(sudpos,kdims*kmaxinf,DOUBLE);\n\t\t  if (sudpos == SISL_NULL) goto err101;\n\t\t  sudder = increasearray(sudder,kdims*kmaxinf,DOUBLE);\n\t\t  if (sudder == SISL_NULL) goto err101;\n\t\t  svdpos = increasearray(svdpos,kdims*kmaxinf,DOUBLE);\n\t\t  if (svdpos == SISL_NULL) goto err101;\n\t\t  svdder = increasearray(svdder,kdims*kmaxinf,DOUBLE);\n\t\t  if (svdder == SISL_NULL) goto err101;\n\t\t}\n            }\n\t  \n\t  /* Remember length of start tangent, end of zero segment */\n\t  \n\t  tlengthend = s6length(sder+kdims,kdims,&kstat);\n\t  if (kstat<0) goto error;\n\t  \n\t  /* Calculate unit tangent and radius of curvature */\n\t  \n\t  s1307(sder,kdims,s3dinf+(3*kdims+1)*knbinf,&kstat);\n\t  if (kstat<0) goto error;\n\t  \n\t  /* Store the other calculated information */\n\t  \n\t  if (ider>=1)\n            {\n\t      memcopy(&sudpos[kdims*knbinf],sderu,kdims,DOUBLE);\n\t      memcopy(&sudder[kdims*knbinf],sderu+kdims,kdims,DOUBLE);\n\t      memcopy(&svdpos[kdims*knbinf],sderv,kdims,DOUBLE);\n\t      memcopy(&svdder[kdims*knbinf],sderv+kdims,kdims,DOUBLE);\n            }\n\t  \n\t  spar[knbinf] = spar[knbinf-1];\n\t  \n\t  knbinf += 1;\n\t  \n        }\n    }\n  \n  \n  /*  Interpolate trace curve */\n  \n  /* UJK, 92.04. : s1312 and s1359 shadow functions\n     s1312(s3dinf,kdims,knbinf,kpar,spar,rcpos,&kstat); */\n  s1359(s3dinf,aepsge,kdims,knbinf,kpar,spar,rcpos,&kstat);\n  if (kstat < 0) goto error;\n  \n  if (ider>=1)\n    {\n      /*   Interpolate u-derivative curve */\n      s1379(sudpos,sudder,spar,knbinf,kdims,rcder1,&kstat);\n      if (kstat<0) goto error;\n      \n      /*   Interpolate v-derivative curve */\n      s1379(svdpos,svdder,spar,knbinf,kdims,rcder2,&kstat);\n      if (kstat<0) goto error;\n    }                \n  \n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in memory allocation */\n  \n err101: *jstat = -101;\n  s6err(\"s1383\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input, dimension not equal to 2 or 3 */\n  \n err105: *jstat = -105;\n  s6err(\"s1383\",*jstat,kpos);\n  goto out;\n    \n  \n err179: *jstat = -179;\n  s6err(\"s1383\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level function */\n  \n error:  *jstat = kstat;\n  s6err(\"s1383\",*jstat,kpos);\n  goto out;\n  \n  \n out:\n  \n  if (s3dinf != SISL_NULL) freearray(s3dinf);\n  if (sudpos != SISL_NULL) freearray(sudpos);\n  if (sudder != SISL_NULL) freearray(sudder);\n  if (svdpos != SISL_NULL) freearray(svdpos);\n  if (svdder != SISL_NULL) freearray(svdder);\n  if (spar   != SISL_NULL) freearray(spar);\n  \n  return;\n}          \n                                      \n"
  },
  {
    "path": "src/s1384.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1384.c,v 1.3 2001-03-19 15:58:48 afr Exp $\n *\n */\n\n\n#define S1384\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1384(SISLCurve *pcurve,SISLSurf *psurf,int idim,int iside,double ax,\n\t   int *ileftc,int *ilefts1,int *ilefts2,double eder[],\n\t   double ederu[],double ederv[],double edern[],int *jstat)\n#else\nvoid s1384(pcurve,psurf,idim,iside,ax,ileftc,ilefts1,ilefts2,\n           eder,ederu,ederv,edern,jstat)\n     SISLCurve  *pcurve;\n     SISLSurf   *psurf;\n     int    idim;\n     int    iside;\n     double ax;\n     int    *ileftc;\n     int    *ilefts1;\n     int    *ilefts2;\n     double eder[];\n     double ederu[];\n     double ederv[];\n     double edern[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the value and first and second derivatives of\n*              a curve traced out by a curve in the parameter plane\n*              at the point with parameter value ax. In addition to \n*              calculate posision and first derivative of dp(u(s),v(s))/du,\n*              ddp(u(s),v(s))/duds, dp(u(s),v(s))/dv, ddp(u(s),v(s))/dvds\n*              and similar values for the normal vector to the trace curve\n*\n*\n*\n*\n* INPUT      : pcurve - Pointer to the curve in the parameter plane\n*              psurf  - The surface from which the curve is traced out\n*              idim   - Dimension of the space the curve lies in 2 or 3\n*              iside  - Calculate derivative from right or left\n*                        ileft ==  -1 from left\n*                        ileft!=  -1 from right\n*              ax     - The parameter value at which to compute\n*                       position and derivatives.\n*\n*                \n*\n* INPUT/OUTPUT : ileftc- Pointer to the interval in the knot vector\n*                        where ax is located. If et is the knot vector,\n*                        the relation\n*                          \n*                          et[ileft] <= ax < et[ileft+1]\n* \n*                        should hold. (If ax == et[in] then ileft should\n*                        be in-1. Here in is the number of B-spline\n*                        coefficients.)\n*                        If ileft does not have the right value upon\n*                        entry to the routine, its value will be changed\n*                        to the value satisfying the above condition.\n*              ilefts1- Similar pointer to first knot vector of surface \n*              ilefts2- Similar pointer to second knot vector of surface \n*\n*\n* OUTPUT     : eder   - Double array of dimension [3*idim]\n*                       containing the position and derivative vectors.\n*                       (idim is the number of components of each B-spline\n*                       coefficient, i.e. the dimension of the Euclidean\n*                       space in which the curve lies.)\n*                       These vectors are stored in the following order:\n*                       First the idim components of the position vector,\n*                       then the idim components of the tangent vector,\n*                       then the idim components of the second derivative\n*                       vector, and so on.\n*                       (The C declaration of eder as a two dimensional array\n*                       would therefore be eder[kder+1,idim].)\n*\n*              ederu  - Double array of dimension [2*idim] containing\n*                        dp(u(s),v(s))/du and ddp(u(s),v(s))/duds.\n*              ederv  - Double array of dimension [2*idim] containing\n*                       dp(u(s),v(s))/dv, ddp(u(s),v(s))/dvds\n*              edern  - Double array of dimension [2*idim] conatining\n*                       the value and derivative of the normal to the\n*                       tangent curve. NOT IMPLEMENTED\n*              jstat  - Status messages  \n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : First the point and relevant derivatives are calculated on\n*              the point in the parameter plane, then relevant derivatives\n*              are calculated in the surface and the information is combined\n*              to produce the specified derivatives.\n*\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1221, s6length, s6crss, s6scpr, s6err\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, October 1988\n* REVISED BY : Christophe rene Birkeland, SINTEF Oslo, May 1993\n*              Testing for SISL_NULL (array sders and sderc)\n*\n*********************************************************************\n*/                                     \n{\n  int kstat=0;        /* Local status variable.                          */\n  int kpos=0;         /* The position of the error.                      */\n  int kder=3;         /* Derivatives necessary to calculate              */\n  int ki;             /* Loop variable                                   */\n  int knum1,knum2;    /* Numbers of points and derivatives               */\n  int kdimc;          /* Dimension of curve                              */\n  int kdims;          /* Dimension of surface                            */\n  double sdumc[8];    /* Values from curve calculation                   */\n  double sdums[30];   /* Values from surface calcualtion                 */\n  double snorm[3];    /* Normal to tangent vector                        */\n  double *sders=SISL_NULL; /* Values and derivatives on surface               */\n  double *sderc=SISL_NULL; /* Values and derivatives on curve                 */\n  double tduds,tdvds; /* Derivatives of curve                            */\n  double tddudss,tddvdss; /* Derivatives of curve                        */\n  double *sdpdu,*sdpdv;/* Pointers to derivatives of surface             */\n  double *sddpduu;    /* Pointers to derivatives of surface              */\n  double *sddpduv;    /* Pointers to derivatives of surface              */\n  double *sddpdvv;    /* Pointers to derivatives of surface              */\n  double *ps;         /* Pointer in loop                                 */\n  double tlsn;        /* Length of sn                                    */\n  \n  kdimc = pcurve -> idim;\n  kdims = psurf  -> idim;\n  \n  if (kdimc !=2 && kdims != idim) goto err105;\n  \n  knum1 = kdimc*(kder+1);\n  knum2 = kdims*(kder+1)*(kder+2)/2;\n  \n  if (knum1>8)\n  {\n    if((sderc = newarray(knum1,DOUBLE)) == SISL_NULL) goto err101;\n  }\n  else  \n    sderc = sdumc;\n  \n  if (knum2>30)\n  {\n    if((sders = newarray(knum2,DOUBLE)) == SISL_NULL) goto err101;\n  }\n  else   \n    sders = sdums;\n  \n  /* Calculate point values and derivatives on curve */ \n  \n  \n  if (iside != -1)\n    {\n      /*  Calculated derivatives from the right */\n      s1221(pcurve,kder,ax,ileftc,sderc,&kstat);\n      if (kstat<0) goto error;\n    }\n  else\n    {\n      /*  Calculated derivatives from the left */\n      s1227(pcurve,kder,ax,ileftc,sderc,&kstat);\n      if (kstat<0) goto error;\n    }\n  \n  /* Calculate position and derivatives of the surface */ \n  \n  s1421(psurf,kder,sderc,ilefts1,ilefts2,sders,snorm,&kstat);            \n  if (kstat<0) goto error;\n  \n  /* Make some pointers that facilitate the futher calculations */\n  \n  tduds  = sderc[2];\n  tdvds  = sderc[3];\n  tddudss = sderc[4];\n  tddvdss = sderc[5];\n  sdpdu   = sders + idim;\n  sdpdv   = sdpdu + idim;\n  sddpduu = sdpdv + idim;\n  sddpduv = sddpduu + idim;\n  sddpdvv = sddpduv + idim;\n  \n  /* FIRST MAKE CALCULATION OF POSITION, DERIVATIVE AND SECOND DERIVATIVE\n     OF TRACE CURVE */\n  \n  /* Calculate position of point */\n  \n  for (ki=0;ki<idim;ki++) eder[ki] = sders[ki];\n  \n  /* Calculate first derivatives */\n  \n  ps = eder + idim;\n  for (ki=0;ki<idim;ki++)\n    *(ps++) = sdpdu[ki]*tduds + sdpdv[ki]*tdvds;\n  \n  /*  Calculate second derivatives of */\n  \n  for (ki=0;ki<idim;ki++)\n    *(ps++) = sddpduu[ki]*tduds*tduds + sdpdu[ki]*tddudss +\n      sddpdvv[ki]*tdvds*tdvds + sdpdv[ki]*tddvdss +\n\t(double)2.0*sddpduv[ki]*tduds*tdvds;\n  \n  /* MAKE CALCULATION OF VALUE (POSITION) AND DERIVATIVES OF dp/du WITH\n     RESPECT TO THE TRACE CURVE */\n  \n  ps = ederu;\n  for (ki=0;ki<idim;ki++)\n    *(ps++) = sdpdu[ki];\n  \n  for (ki=0;ki<idim;ki++)\n    *(ps++) = sddpduu[ki]*tduds + sddpduv[ki]*tdvds;\n  \n  \n  /* MAKE CALCULATION OF VALUE (POSITION) AND DERIVATIVES OF dp/dv WITH\n     RESPECT TO THE TRACE CURVE */\n  \n  ps = ederv;\n  for (ki=0;ki<idim;ki++)\n    *(ps++) = sdpdv[ki];\n  \n  for (ki=0;ki<idim;ki++)\n    *(ps++) = sddpduv[ki]*tduds + sddpdvv[ki]*tdvds;\n  \n  \n  /* MAKE POSITION AND DERIVATIVE OF THE NORMAL VECTOR:\n     \n     NOT IMPLEMENTED..................\n     d                 d\n     ( -- p(u(s),v(s)) x -- p(u(s),v(s)) )\n     dp(u(s),v(s))     du                dv\n     ------------- x ----------------------------------\n     ds              length of numerator\n     \n     */\n  \n  /* First make the normal vector as cross product of the u and v derivative,\n     the length of the normal vector and the two components of the derivative\n     with respect to s.\n     */\n  \n  s6crss(ederu,ederv,snorm);\n  \n  tlsn = s6length(snorm,3,&kstat);\n  \n  if (kstat<0) goto error;\n  \n  if (DEQUAL(tlsn,DZERO)) tlsn = (double)1.0;\n  \n  s6crss(eder+idim,snorm,edern);\n  \n  ps = edern;\n  \n  for (ki=0;ki<idim;ki++,ps++)\n    *(ps) /= tlsn;\n  \n  /*\n    \n    To calculate the derivative of the normal we maks:\n    \n    d                 d\n    ( -- p(u(s),v(s)) x -- p(u(s),v(s)) )\n    d    dp(u(s),v(s))   du                dv\n    --  (------------- x ---------------------------------- ) =\n    ds       ds              length of numerator\n    \n    \n    2             \n    d p(u(s),v(s))   sn      dp(u(s),v(s))    d            \n    -------------- x ---   + ------------- x  --sn/lsn -\n    dsds         lsn         ds           ds\n    \n    \n    d p(u(s),v(s))   sn       d\n    -------------- x ---- (sn --sn)\n    ds              3     ds\n    lsn\n    \n    \n    d                 d \n    sn   =   -- p(u(s),v(s)) x -- p(u(s),v(s))  \n    du                dv\n    \n    \n    lsn  =   length of(sn)\n    \n    \n    2\n    d                   d\n    sn1  =   --  p(u(s),v(s))) x -- p(u(s),v(s)) )\n    duds                dv\n    \n    2                   2\n    d                   d\n    sn2  =   --  p(u(s),v(s))) x -- p(u(s),v(s)) )\n    du                  dvds\n    \n    \n    \n    d   \n    --sn =   sn1 + sn2\n    ds\n    \n    \n    Make the components of the derivative \n    \n    s6crss(ederu+idim,ederv,sn1);\n    s6crss(ederu,ederv+idim,sn2);\n    \n    for (ki=0;ki<3;ki++)\n    sdnds[ki] = sn1[ki] + sn2[ki];\n    \n    \n    Make the cross products of the three components \n    \n    s6crss(eder+6,sn,sdum1);\n    s6crss(eder+3,sdnds,sdum2);\n    s6crss(eder+3,sn,sdum3);\n    \n    Make the necessary factor for the last component \n    \n    tfak = s6scpr(sn,sdnds,3);\n    \n    Make the first derivative of the normal vector\n    \n    ps= edern+3;\n    \n    tlsn3 = tlsn*tlsn*tlsn;\n    \n    for (ki=0;ki<idim;ki++)\n    *(ps++) = (sdum1[ki] + sdum2[ki])/tlsn + sdum3[ki]*tfak/tlsn3;\n    \n    \n    END OF NOT IMPLEMENTED */\n  \n  /* Successful computations.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in allocations */\n\n  err101: *jstat = -101;\n    s6err(\"s1384\",*jstat,kpos);\n    goto out;\n  \n  /* idim not 2 0r 3 */\n\n  err105: *jstat = -105;\n    s6err(\"s1384\",*jstat,kpos);\n    goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error:  *jstat = kstat;\n    s6err(\"s1384\",*jstat,kpos);\n    goto out;\n  \n  out:\n  \n    if (knum1>8)\n      { \n        if (sderc != SISL_NULL) freearray(sderc);\n      }\n    if (knum2>30) \n      {\n        if (sders != SISL_NULL) freearray(sders);\n      }\n    return;\n}\n"
  },
  {
    "path": "src/s1385.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1385.c,v 1.2 2001-03-19 15:58:48 afr Exp $\n *\n */\n\n\n#define S1385\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1385(double ep0[],double ept[],double ep1[],double as,int idim,\n\t   double aepsge,SISLCurve **rc,int *jstat)      \n#else\nvoid s1385(ep0,ept,ep1,as,idim,aepsge,rc,jstat)\n     double ep0[];\n     double ept[];\n     double ep1[];\n     double as;\n     int    idim;\n     double aepsge;\n     SISLCurve  **rc;\n     int    *jstat;      \n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To describe a conic arc by the start point, the inter-\n*              section point of the tangents, the end point and a shape\n*              factor. The conic arc is converted to a spline curve.\n*             \n*\n* INPUT      : ep0    - Start point of segment\n*              ept    - Intersection point of tangents\n*              ep1    - End point of segment\n*              as     - Shape factor\n*                        as < 0.5 a ellipse\n*                        as = 0.5 a parabola\n*                        as > 0.5 a hyperbola\n*                        as >= 1  The start and end point lies on\n*                                 different branches of the parabola.\n*                                 If as>=1 then as is put to 0.999999\n*              idim   - The dimension of the curve to be produced\n*              aepsge - Tolerance to be used for the conversion\n*\n*\n*\n*\n* OUTPUT     : \n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*              rc     - Pointer to the curve produced\n*\n* METHOD     : The conic is made as a rational B-spline curve according\n*              to the following formula:\n*\n*                     ep0 (1-t)(1-t) + 2 s/(1-s) t(1-t) ept + tt ep1\n*              p(t) = ----------------------------------------------\n*                         (1-t)(1-t) + 2 s/(1-s) t(1-t) + tt        \n*\n*              The the conic arc is converted to a B-spline curve within\n*              the tolerance specified.\n*\n* REFERENCES :\n*\n*-                                      \n* CALLS      : \n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, May 1988\n*\n*********************************************************************\n*/\n{\n  int kk=3;              /* Polynomial order                       */\n  int kn=3;              /* Number of vertices                     */\n  int kind=4;            /* Rational Bezier curve                  */\n  int kpos=0;            /* Position of error                      */\n  int kstat;             /* Local status variable                  */\n  int ki;                /* Lopp variable                          */\n  double tdum;           /* Homogenous coordinate                  */\n  double toffset=DZERO;  /* Approximation is with zero offset      */\n  double tmax;           /* Maximal step length                    */\n  double st[6];          /* Knots                                  */\n  double *scoef=SISL_NULL;    /* Vertices                               */\n  double *sdum=SISL_NULL;     /* Dummy normal vector                    */\n  SISLCurve *qc=SISL_NULL;        /* Pointer to rational description of conic */\n  \n  /* Allocate scrath for vertex vector */\n  \n  scoef = newarray((idim+1)*3,DOUBLE);\n  if (scoef==SISL_NULL) goto err101;\n  sdum  = new0array(idim,DOUBLE);\n  if (sdum == SISL_NULL) goto err101;\n  \n  if (as>=(double)1.0) as = (double)0.9999999;\n  memcopy(scoef,ep0,idim,DOUBLE);\n  scoef[idim] = (double)1.0;\n  tdum = as/((double)1.0-as);\n  scoef[2*idim+1] = tdum;\n  for (ki=0;ki<idim;ki++)\n    {\n      if (DEQUAL(tdum,DZERO))\n        {\n\t  scoef[idim+1+ki] = ept[ki];\n        }\n      else\n        {\n\t  scoef[idim+1+ki] = tdum*ept[ki];\n        }\n    }\n  \n  memcopy(scoef+2*idim+2,ep1,idim,DOUBLE);\n  scoef[3*idim+2] = (double)1.0;\n  \n  st[0] = DZERO;\n  st[1] = st[0];                                                     \n  st[2] = st[0];\n  st[3] = (double)1.0;\n  st[4] = st[3];\n  st[5] = st[4];\n  \n  qc = newCurve(kn,kk,st,scoef,kind,idim,1);\n  if (qc == SISL_NULL) goto err101;\n  \n  /* Convert to spline representation */\n  \n  tmax = s6dist(ep0,ep1,idim);\n  \n  s1360(qc,toffset,aepsge,sdum,tmax,idim,rc,&kstat);\n  if (kstat<0) goto error;\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"S1385\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower leve function */\n error:\n  *jstat = kstat;\n  s6err(\"S1385\",*jstat,kpos);\n  goto out;\n  \n  \n  \n  /* Free allocated arrays */\n out:\n  \n  if (scoef != SISL_NULL) freearray(scoef);\n  if (sdum  != SISL_NULL) freearray(sdum);\n  if (qc    != SISL_NULL) freeCurve(qc);\n  \n  return;\n}\n    \n"
  },
  {
    "path": "src/s1386.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1386.c,v 1.5 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1386\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1386(SISLSurf *ps,int ider1,int ider2,SISLSurf **rsnew,int *jstat)\n#else\nvoid s1386(ps,ider1,ider2,rsnew,jstat)\n     SISLSurf \t*ps;\n     int  \tider1;\n     int  \tider2;\n     SISLSurf \t**rsnew;\n     int  \t*jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To express the (ider1,ider2)-th derivative of a B-pline\n*              surface as a B-spline surface with order (ider1,ider2)\n*              less than the original B-spline surface.\n*\n*\n*\n* INPUT      : ps       - Surface to make a derivative from.\n*              ider1    - The derivative to be produced in the first\n*                         parameter direction 0 <= ider1 < p2 ->ik1\n*              ider2    - The derivative to be produced in the second\n*                         parameter direction 0 <= ider2 < p2 ->ik2\n*\n*\n*\n* OUTPUT     : rsnew    - The result of the (ider1,ider2) differentiation of ps.\n*              jstat    - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : For non-rational surfaces, we treate the surface as a\n*                curve in both parameter directions and utilize the\n*                curve differentiation method twice.\n*              For nurbs, we find the new orders and dimensions, and then\n*                interpolate a set of points on the derivative surface.\n*\n*\n* REFERENCES : Larry L. Schumaker, Spline Functions:Basic Theory.  p.195.\n*              Carl de Boor, A Practial Guide to Spline.           p.139.\n*\n*-\n* CALLS      : newCurve  - Allocate space for a new curve-object.\n*              freeCurve - Free space occupied by given curve-object.\n*              s1705.c   - Remove unnecesery knots and vertices from a curve.\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-06.\n* REVISED BY : Johannes Kaasa, SI, May 92 (Introduced NURBS. Remark that\n*              it is then impossible to make the derivative in a higher\n*              dimensional space. We must treat the surface as a collection\n*              of seperate curves in each direction, this will of course make\n*              the function less efficient).\n* REVISED BY : Christophe Birkeland, SI, July 1992 (memcopy-statement line 276\n*              is changed, call s6chpar line 283: kn1 & kn2 interchanged)\n* REVISED BY : Christophe Birkeland, SI, August 1992\n*              The NURBS algorithm is changed completely. First we find the new\n*              orders and dimensions of the surface, then we estimate points\n*              on the derivative surface, and at last we interpolate the\n*              resulting derivative surface.\n* REVISED BY : Johannes Kaasa, SI, Aug. 92 (Established correct order and interior\n*              knot multiplicity in the NURBS case. In addition I have used s1891\n*              to solve the interpolation matrix in both parameter directions).\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Oct. 1994.  Changed icopy\n*              value from 0 to 2 in call to newSurf for rationals and free'ed 'rat',\n*              'par1', 'par2', 'der1' and 'der2' at exit to remove memory\n*              leakage problems.  Initialized 'rsnew'.  Increased the size\n*              of 'scoef' for non-rationals by 'kn2*ider1*ps->idim', since the\n*              first call to s1720() will increase \"in\" by ider1.\n*              NOTE: closed and periodic case isn't handled correctly by this\n*              routine and it will have to be handled separatly for NURBS and\n*              polynomial case.\n*\n**********************************************************************/\n{\n  SISLCurve *qc1 = SISL_NULL;      /* Temporary curve                     */\n  SISLCurve *qc2 = SISL_NULL;      /* Temporary curve                     */\n  SISLCurve *qc3 = SISL_NULL;      /* Temporary curve                     */\n  SISLCurve *qc4 = SISL_NULL;      /* Temporary curve                     */\n\n  int kk1;                    /* Order in first parameter direction  */\n  int kk2;                    /* Order in second parameter direction */\n  int kn1;                    /* NumberOrder in first parameter direction */\n  int kn2;                    /* Order in second parameter direction */\n  int kdim;                   /* Dimension used in temporary calc    */\n  int kstat;                  /* Local parameter value               */\n  int kpos=0;                 /* Position of error                   */\n  double *st1 = SISL_NULL;         /* Pointer to knot vector              */\n  double *st2 = SISL_NULL;         /* Pointer to knot vector              */\n  double *scoef = SISL_NULL;       /* Pointer to coefficients             */\n\n  /* NURBS variables: */\n\n  SISLSurf *rat=SISL_NULL;         /* The denominator surface.            */\n  double *ratcoef=SISL_NULL;       /* The vertices of rat.                */\n  int ki, kj, kl, km;         /* Index in for loop.                  */\n  int rdim;                   /* Rational dimension.                 */\n\n  double eps;                 /* Knot equality resolution.               */\n  int multadd;                /* Added multiplicity of interior knots.   */\n  int mult;                   /* Original multiplicity of the knots.     */\n  int oldprev;                /* Previous index in the original knots.   */\n  int oldcurr;                /* Current index in the original knots.    */\n  int newcurr;                /* Current index in the new knots.         */\n  double denom;               /* The denominator.                        */\n  double limit;               /* Used as a loop control parameter        */\n  int left1 = 0;              /* Interval indicator.                     */\n  int left2 = 0;              /* Interval indicator.                     */\n  double par[2];              /* Parameter values used for interpolation */\n  double *par1 = SISL_NULL;        /* Parameter values used for interpolation */\n  double *par2 = SISL_NULL;        /* Parameter values used for interpolation */\n  int *der1 = SISL_NULL;           /* The derivative indicators (= 0).        */\n  int *der2 = SISL_NULL;           /* The derivative indicators (= 0).        */\n  double *deriv = SISL_NULL;       /* The derivates returned by s1221.        */\n  double *tau = SISL_NULL;         /* Interpolation points.                   */\n  int iopen = TRUE;           /* Open flag.                              */\n  int in;                     /* Number of vertices in interpolation.    */\n  int inlr = 0, inrc = 0;\n  int indx1, indx2;\n\n  /* Check that we have a surface to differentiable. */\n\n  *rsnew = SISL_NULL;  /* Must be valid incase of error exit. */\n\n  if (!ps) goto err150;\n\n  /* Check that the number of derivation is legal. */\n\n  if ( ider1 < 0  ||  ider2 < 0 )  goto err156;\n\n  if (ps->ikind == 2 || ps->ikind == 4)\n  {\n\n     /* NURBS surface. */\n\n     kdim=ps->idim;\n     rdim = kdim + 1;\n\n     /* Make the denominator surface. */\n\n     ratcoef = newarray(ps->in1 * ps->in2, DOUBLE);\n     limit = ps->in1*ps->in2;\n     for (kj=0; kj < limit ; kj++)\n\tratcoef[kj] = ps->rcoef[(kj + 1)*rdim - 1];\n     rat = newSurf(ps->in1,ps->in2, ps->ik1,ps->ik2, ps->et1,\n\t\t   ps->et2,ratcoef, 1, 1, 1);\n     if (ratcoef != SISL_NULL) freearray(ratcoef);\n\n\n\n     /* Make resolution for testing of knot equality. */\n\n     eps = fabs(ps->et1[ps->in1] - ps->et1[ps->ik1 - 1])*REL_PAR_RES;\n\n     /* Make the new knot vector st1 in first direction. */\n\n     kn1 = 0;\n     kk1 = (ider1 + ider2 + 1)*ps->ik1 - (ider1 + ider2);\n     multadd = (ider1+ider2)*ps->ik1 - ider2;\n\n     st1 = newarray((2 + ps->in1 - ps->ik1)*kk1, DOUBLE);\n\n     for (newcurr=0; newcurr<kk1; newcurr++)\n     {\n\tst1[newcurr] = ps->et1[ps->ik1 - 1];\n        kn1++;\n     }\n\n     oldcurr = ps->ik1;\n     oldprev = oldcurr;\n     limit = ps->et1[ps->in1] - eps;\n     while (ps->et1[oldcurr] < limit)\n     {\n\tmult = 0;\n\twhile ((ps->et1[oldcurr] - ps->et1[oldprev]) < eps)\n\t{\n\t   oldcurr++;\n\t   mult++;\n\t}\n\tmult += multadd;\n\tif (mult > kk1) mult = kk1;\n\tfor (kj=0; kj<mult; kj++)\n\t{\n\t   st1[newcurr + kj] = ps->et1[oldprev];\n\t   kn1++;\n\t}\n\tnewcurr += mult;\n\toldprev = oldcurr;\n     }\n     for (kj=0; kj<kk1; kj++)\n\tst1[newcurr + kj] = ps->et1[ps->in1];\n\n     /* Resize new knot vector st1 */\n\n     st1 = increasearray(st1,kn1+kk1,DOUBLE);\n     if (st1 == SISL_NULL) goto err101;\n\n     /* Calculate parameter values and derivate indicators. */\n\n     s1890(st1, kk1, kn1, &par1, &der1, &kstat);\n     if (kstat < 0) goto error;\n\n\n\n     /* Knot vector in second parameter direction */\n\n     /* Make resolution for testing of knot equality in second parameter\n      * direction. */\n\n     eps = fabs(ps->et2[ps->in2] - ps->et2[ps->ik2 - 1])*REL_PAR_RES;\n\n     /* Make the new knot vector st2. */\n\n     kn2 = 0;\n     kk2 = (ider1 + ider2 + 1)*ps->ik2 - (ider1 + ider2);\n     multadd = (ider1 + ider2)*ps->ik2 - ider1;\n\n     st2 = newarray((2 + ps->in2 - ps->ik2)*kk2, DOUBLE);\n\n     for (newcurr=0; newcurr<kk2; newcurr++)\n     {\n\tst2[newcurr] = ps->et2[ps->ik2 - 1];\n        kn2++;\n     }\n\n     oldcurr = ps->ik2;\n     oldprev = oldcurr;\n     limit = ps->et2[ps->in2]-eps;\n     while (ps->et2[oldcurr] < limit)\n     {\n\tmult = 0;\n\twhile ((ps->et2[oldcurr] - ps->et2[oldprev]) < eps)\n\t{\n\t   oldcurr++;\n\t   mult++;\n\t}\n\tmult += multadd;\n\tif (mult > kk2) mult = kk2;\n\tfor (kj=0; kj<mult; kj++)\n\t{\n\t   st2[newcurr + kj] = ps->et2[oldprev];\n\t   kn2++;\n\t}\n\tnewcurr += mult;\n\toldprev = oldcurr;\n     }\n\n     for (kj=0; kj<kk2; kj++)\n\tst2[newcurr + kj] = ps->et2[ps->in2];\n\n     /* Resize new knot vector st2 */\n\n     st2 = increasearray(st2,kn2+kk2,DOUBLE);\n     if (st2 == SISL_NULL) goto err101;\n\n     /* Calculate parameter values and derivate indicators. */\n\n     s1890(st2, kk2, kn2, &par2, &der2, &kstat);\n     if (kstat < 0) goto error;\n\n\n\n     /* ------------------------------- */\n     /* Calculate interpolation points. */\n     /* ------------------------------- */\n\n     deriv = newarray((ider1 + 1)*(ider2 + 1)*kdim, DOUBLE);\n     tau = newarray(rdim*kn1*kn2, DOUBLE);\n     if (tau == SISL_NULL) goto err101;\n\n     km = 0;\n     for (kj=0 ; kj<kn1 ; kj++)\n\tfor (kl=0; kl<kn2; kl++)\n\t{\n\t   par[0]=par1[kj];\n\t   par[1]=par2[kl];\n\t   s1424(rat, 0, 0, par, &left1, &left2, &denom, &kstat);\n\t   if (kstat < 0) goto error;\n\t   denom = pow(denom, (ider1 + ider2 + 1));\n\t   s1424(ps, ider1, ider2, par, &left1, &left2, deriv, &kstat);\n\t   if (kstat < 0) goto error;\n\t   for (ki=0; ki<kdim; ki++)\n\t      tau[km++] =\n\t\t deriv[(ider2*(ider1+1)+ider1)*kdim + ki]*denom;\n\t   tau[km++] = denom;\n\t}\n\n     /* Solve the interpolation equation in the second parameter direction. */\n\n     s1891(par2, tau, rdim, kn2, kn1, der2, iopen, st2, &scoef, &in, kk2,\n          inlr, inrc, &kstat);\n     if (kstat < 0) goto error;\n     if (in != kn2) goto error;\n\n     /* Transpose scoef and put in tau. */\n\n     km = 0;\n     for (kj=0; kj<kn2; kj++)\n       {\n\t indx1 = kj*rdim;\n         for (kl=0; kl<kn1; kl++)\n\t   {\n\t     indx2 = kl*kn2*rdim;\n             for (ki=0; ki<rdim; ki++)\n                tau[km++] = scoef[indx2 + indx1 + ki];\n\t   }\n       }\n\n     if (scoef != SISL_NULL) freearray(scoef);\n\n     /* Solve the interpolation equation in the first parameter direction. */\n\n     s1891(par1, tau, rdim, kn1, kn2, der1, iopen, st1, &scoef, &in, kk1,\n          inlr, inrc, &kstat);\n     if (kstat < 0) goto error;\n     if (in != kn1) goto error;\n\n     *rsnew = newSurf(kn1,kn2,kk1,kk2,st1,st2,scoef,ps->ikind,3,2);\n  }\n  else\n  {\n     /* Not NURBS. */\n\n     kk1 = ps -> ik1;\n     kk2 = ps -> ik2;\n     kn1 = ps -> in1;\n     kn2 = ps -> in2;\n\n     /* Create curve representing the surface a a curve in the second parameter\n        direction, copy input arrays */\n\n     kdim = (ps->in1)*(ps->idim);\n\n     qc1 = newCurve(ps->in2,ps->ik2,ps->et2,ps->ecoef,1,kdim,1);\n     if (qc1 == SISL_NULL) goto err101;\n\n     /* Make the derivative in the second parameter direction */\n\n     s1720(qc1,ider2,&qc2,&kstat);\n     if (kstat<0) goto error;\n\n     /* Remember new knot vector in second parameter direction */\n\n     kk2 = qc2 -> ik;\n     kn2 = qc2 -> in;\n     st2 = newarray(kk2+kn2,DOUBLE);\n     if (st2 == SISL_NULL) goto err101;\n\n     memcopy(st2,qc2->et,kk2+kn2,DOUBLE);\n\n     /* Allocate space for turned parameter directions */\n\n     scoef = newarray((kn1*kn2 + kn2*ider1)*(ps->idim),DOUBLE);\n     if (scoef == SISL_NULL) goto err101;\n\n     /* Turn parameter directions */\n\n     s6chpar(qc2->ecoef,kn1,kn2,(ps->idim),scoef);\n\n\n     /* Represent the surface as curve using the first knot vector */\n\n     kdim = kn2*(ps->idim);\n\n     qc3 = newCurve(ps->in1,ps->ik1,ps->et1,scoef,1,kdim,1);\n     if (qc3 == SISL_NULL) goto err101;\n\n     /* Make the derivative in the first parameter direction */\n\n     s1720(qc3,ider1,&qc4,&kstat);\n     if (kstat<0) goto error;\n\n\n     /* Remember new knot vector in first parameter direction */\n\n     kk1 = qc4 -> ik;\n     kn1 = qc4 -> in;\n     st1 = newarray(kk1+kn1,DOUBLE);\n     if (st1 == SISL_NULL) goto err101;\n\n     memcopy(st1,qc4->et,kk1+kn1,DOUBLE);\n\n\n     /* Turn parameter directions of coefficients to match surface */\n\n     s6chpar(qc4->ecoef,kn2,kn1,(ps->idim),scoef);\n\n     /* Create surface object containing the differentiated of the surface */\n\n     *rsnew = newSurf(kn1,kn2,kk1,kk2,st1,st2,scoef,ps->ikind,(ps->idim),1);\n     if (*rsnew == SISL_NULL) goto err101;\n\n  }\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation */\n\n err101: *jstat = -101;\n  s6err(\"s1386\",*jstat,kpos);\n  goto out;\n\n  /* Error. No surface to differentiate.  */\n\n err150:\n  *jstat = -150;\n  s6err(\"s1386\",*jstat,kpos);\n  goto out;\n\n  /* Error. Illegal number of derivatives.  */\n\n err156:\n  *jstat = -156;\n  s6err(\"s1386\",*jstat,kpos);\n  goto out;\n\n  /* Error. Error in lower level function. */\n\n error:  *jstat = kstat;\n  s6err(\"s1386\",*jstat,kpos);\n  goto out;\n\n\n  /* Free local used memory. */\n\n out:\n  if (qc1 != SISL_NULL) freeCurve(qc1);\n  if (qc2 != SISL_NULL) freeCurve(qc2);\n  if (qc3 != SISL_NULL) freeCurve(qc3);\n  if (qc4 != SISL_NULL) freeCurve(qc4);\n  if (ps->ikind != 2 && ps->ikind != 4)\n  {\n     if (st1 != SISL_NULL) freearray(st1);\n     if (st2 != SISL_NULL) freearray(st2);\n     if (scoef != SISL_NULL) freearray(scoef);\n  }\n  else\n  {\n    if (par1)  freearray(par1);\n    if (par2)  freearray(par2);\n    if (der1)  freearray(der1);\n    if (der2)  freearray(der2);\n\n    if (rat) freeSurf(rat);\n\n    if (tau != SISL_NULL) freearray(tau);\n\n    if (deriv != SISL_NULL) freearray(deriv);\n  }\n\n  return;\n}\n"
  },
  {
    "path": "src/s1387.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1387.c,v 1.2 2001-03-19 15:58:48 afr Exp $\n *\n */\n\n\n#define S1387\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1387(SISLSurf *ps,int ik1,int ik2,SISLSurf **rsnew,int *jstat)\n#else\nvoid s1387(ps,ik1,ik2,rsnew,jstat)\n     SISLSurf *ps;\n     int  ik1;\n     int  ik2;\n     SISLSurf **rsnew;\n     int  *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To express the B-spline surface as a B-spline surface\n*              of higher orders.\n*\n*\n*\n* INPUT      : ps       - Surface \n*              ik1      - New order in first direction \n*              ik2      - New order in second direction\n*\n*\n* OUTPUT     : rsnew    - The resulting order elevated surface\n*              jstat    - status messages\n*                                         = 1      : Input orders equal\n*                                                    to surface orders.\n*                                                    Pointer set to input\n*                                                    surface.\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : We treat  the surface as a curve in both parameter directions\n*              and utilize the curve order elevation method twice\n*\n*\n* REFERENCES : Larry L. Schumaker, Spline Functions:Basic Theory. \n*              Carl de Boor, A Practial Guide to Spline.           \n*\n*-\n* CALLS      : newCurve  - Allocate space for a new curve-object.\n*              freeCurve - Free space occupied by given curve-object.\n*\n* WRITTEN BY : Tor Dokken, SI 1988-11\n* REVISED BY : Johannes Kaasa, SI, May 1992 (Introduced NURBS)\n* REVISED BY : Christophe Birkeland, SI, July 1992 (Parameters in call s1750)\n*\n**********************************************************************/\n{\n  SISLCurve *qc1 = SISL_NULL;\t/* Temporary curve                          */\n  SISLCurve *qc2 = SISL_NULL;\t/* Temporary curve                          */\n  SISLCurve *qc3 = SISL_NULL;\t/* Temporary curve                          */\n  SISLCurve *qc4 = SISL_NULL;\t/* Temporary curve                          */\n  int kk1;\t\t\t/* Order in first parameter direction       */\n  int kk2;\t\t\t/* Order in second parameter direction      */\n  int kn1;\t\t\t/* NumberOrder in first parameter direction */\n  int kn2;\t\t\t/* Order in second parameter direction      */\n  int kdim;\t\t\t/* Dimension used in temporary calc         */\n  int kstat = 0;\t\t/* Local parameter value                    */\n  int kpos = 0;\t\t\t/* Position of error                        */\n  double *st1 = SISL_NULL, *st2 = SISL_NULL;\t/* Pointers to knot vectors                 */\n  double *scoef = SISL_NULL;\t\t/* Pointer to coefficients                  */\n  int rdim;                     /* Potential rational dimension.            */\n  double *rcoef;                /* Potential rational vertices.             */\n\n  *jstat = 0;\n\n\n  kk1 = ps->ik1;\n  kk2 = ps->ik2;\n  kn1 = ps->in1;\n  kn2 = ps->in2;\n  \n  if (ps->ikind == 2 || ps->ikind == 4)\n    {\n      rdim = ps->idim + 1;\n      rcoef = ps->rcoef;\n    }\n  else\n    {\n      rdim = ps->idim;\n      rcoef = ps->ecoef;\n    }\n    \n  if (ik1 < kk1 || ik2 < kk2)\n    goto err183;\n\n  if (ik1 == kk1 && ik2 == kk2)\n    goto war01;\n\n\n  /* Create curve representing the surface a a curve in the second parameter\n     direction, copy input arrays. */\n\n  kdim = (ps->in1) * rdim;\n\n  qc1 = newCurve (ps->in2, ps->ik2, ps->et2, rcoef, 1, kdim, 1);\n  if (qc1 == SISL_NULL)\n    goto err171;\n\n\n  /* Make the order elevation in second parameter direction. */\n\n  s1750 (qc1, ik2, &qc2, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Remember new knot vector in second parameter direction. */\n\n  kk2 = qc2->ik;\n  kn2 = qc2->in;\n  st2 = newarray (kk2 + kn2, DOUBLE);\n  if (st2 == SISL_NULL)\n    goto err101;\n\n  memcopy (st2, qc2->et, kk2 + kn2, DOUBLE);\n\n  /* Allocate space for turned parameter directions. */\n\n  scoef = newarray (kn1 * kn2 * rdim, DOUBLE);\n  if (scoef == SISL_NULL)\n    goto err101;\n\n\n  /* Turn parameter directions. */\n\n  s6chpar (qc2->ecoef, kn1, kn2, rdim, scoef);\n\n\n  /* Represent the surface a curve using the first knot vector. */\n\n  kdim = kn2 * rdim;\n\n  qc3 = newCurve (ps->in1, ps->ik1, ps->et1, scoef, 1, kdim, 1);\n  if (qc3 == SISL_NULL)\n    goto err101;\n\n\n  /* Make the order elevation in the first parameter direction. */\n\n  s1750 (qc3, ik1, &qc4, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Remember new knot vector in first parameter direction. */\n\n  kk1 = qc4->ik;\n  kn1 = qc4->in;\n  st1 = newarray (kk1 + kn1, DOUBLE);\n  if (st1 == SISL_NULL)\n    goto err101;\n\n  memcopy (st1, qc4->et, kk1 + kn1, DOUBLE);\n\n  /* Turn parameter directions of coefficients to match surface. */\n\n\n  /* Allocate space for turned parameter directions. */\n\n  scoef = increasearray (scoef, kn1 * kn2 * rdim, DOUBLE);\n  if (scoef == SISL_NULL)\n    goto err101;\n\n  s6chpar (qc4->ecoef, kn2, kn1, rdim, scoef);\n\n\n  /* Create surface object containing the order elevated surface. */\n\n  *rsnew = newSurf (kn1, kn2, kk1, kk2, st1, st2, scoef, (ps->ikind), (ps->idim), 1);\n  if (*rsnew == SISL_NULL)\n    goto err171;\n  \n  /* Set periodicity flag according to that of the input surface. */\n\t\t      \n  (*rsnew)->cuopen_1 = ps->cuopen_1;\t      \n  (*rsnew)->cuopen_2 = ps->cuopen_2;\t      \n    \n  goto out;\n\n\n  /* Input orders equal to surface orders */\n\nwar01:\n  *jstat = 1;\n  *rsnew = ps;\n  goto out;\n\n  /* Error in space allocation */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1387\", *jstat, kpos);\n  goto out;\n\n  /* Could not create curve or surface. */\n\nerr171:\n  *jstat = -171;\n  s6err (\"s1387\", *jstat, kpos);\n  goto out;\n\n  /* Order(s) specified too low */\n\nerr183:\n  *jstat = -183;\n  s6err (\"s1387\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level function. */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1387\", *jstat, kpos);\n  goto out;\n\n  /* Free local used memory. */\n\nout:\n  if (qc1 != SISL_NULL)\n    freeCurve (qc1);\n  if (qc2 != SISL_NULL)\n    freeCurve (qc2);\n  if (qc3 != SISL_NULL)\n    freeCurve (qc3);\n  if (qc4 != SISL_NULL)\n    freeCurve (qc4);\n  if (st1 != SISL_NULL)\n    freearray (st1);\n  if (st2 != SISL_NULL)\n    freearray (st2);\n  if (scoef != SISL_NULL)\n    freearray (scoef);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1388.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1388.c,v 1.3 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1388\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1388(SISLSurf *ps1,double *gcoons[],int *jnumb1,int *jnumb2,int *jdim,int *jstat)\n#else\nvoid s1388(ps1,gcoons,jnumb1,jnumb2,jdim,jstat)\n     SISLSurf   *ps1;\n     double *gcoons[];\n     int    *jnumb1;\n     int    *jnumb2;\n     int    *jdim;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Convert a B-spline surface of order up to 4 in both\n*              direction to a mesh of Coons patches with uniform\n*              parametrization. The function assumes that the B-spline\n*              surface is C1.\n*\n*\n* INPUT      : ps1    - Pointer to the surface to be converted\n*\n*\n* OUTPUT     : gcoons - Array containing the sequence of Coons patches.\n*                       The total number of patches is jnumb1*jnumb2.\n*                       The patches are stored in sequence with jdim*16\n*                       doubles for each patch. For each corner of the patch\n*                       we store in sequence position, derivative in first\n*                       direction, derivative in second direction and twist.\n*                       This array is allocated inside the routine and must\n*                       be released by the calling routine.\n*\n*              jstat  - status messages  \n*                                         = 1      : Orders too high surface\n*                                                    interpolated\n*                                         = 0      : ok\n*                                         < 0      : error\n*                      \n*\n* METHOD     : For each polynomial patch the corner position, (1,0)-\n*              (0,1)- and (1,1)-derivative is calculated.\n*\n* USE:         int knumb1,knumb2,kdim,kstat;\n*              double *scoons;\n*              SISLSurf *qs1;\n*               .\n*               .\n*              s1388(qs1,&scoons,&knumb1,&knumb2,&kdim,&kstat);\n*               .\n*\n*              If one of the orders of the surface is greater than four\n*              (*jstat==1) then degree reduction (order reduction) should\n*              be applied before using this routine to get a satisfactory\n*              representation of the surface by Coons patches.\n*              The degree reduction routine is s1348.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1424, s6err\n*\n* WRITTEN BY : Tor Dokken, SI, Norway, 1988-11\n*\n*********************************************************************\n*/                                     \n{\n  int kstat=0;        /* Local status variable.                          */\n  int kpos=0;         /* Position of error.                              */\n  int kdim;           /* Dimension of the space in which the surface lies. */\n  int kder=1;         /* Calculate all first derivatives                 */\n  int klfs=0;         /* Pointer into first knot vector                  */\n  int klft=0;         /* Pointer into second knot vector                 */\n  int kdumlfs;        /* Temporary pointer into first knot vector        */\n  int kdumlft;        /* Temporary pointer into second knot vector       */\n  int ksize;          /* Number of doubles to store a Coons patch        */\n  \n  int kj;          /* Control variables in for loop                   */\n  int kn1;            /* Number of vertices in first parameter direction */\n  int kn2;            /* Number of vertices in first parameter direction */\n  int kk1;            /* Order in first parameter direction              */\n  int kk2;            /* Order in first parameter direction              */\n  double *st1;        /* Knots in first parameter direction              */\n  double *st2;        /* Knots in second parameter direction             */\n  double spar[2];     /* Current parameter value                         */\n  double sparx[2];    /* Temporary parameter value                       */\n  double tdiff1;      /* Length of parameter interval in direction 1     */\n  double tdiff2;      /* Length of parameter interval in direction 2     */\n  double *scorn1;     /* Pointer to corner 1 of current Coons patch      */\n  double *scorn2;     /* Pointer to corner 2 of current Coons patch      */\n  double *scorn3;     /* Pointer to corner 3 of current Coons patch      */\n  double *scorn4;     /* Pointer to corner 4 of current Coons patch      */\n  double tdum;        /* Temporary variable                              */\n  \n  kn1 = ps1->in1;\n  kn2 = ps1->in2;\n  kk1 = ps1->ik1;\n  kk2 = ps1->ik2;\n  kdim = ps1 ->idim;\n  st1 = ps1 -> et1;\n  st2 = ps1 -> et2;\n  \n  /* Calculate number of doubles to store a Coons patch */\n  \n  ksize = kdim*16;\n  \n  \n  /* Allocate array for storage of the coefficients */\n  \n  *gcoons = newarray((kn1*kn2*16*kdim),DOUBLE);\n  if (*gcoons == SISL_NULL) goto err101;\n  \n  klft = kk2 - 1;\n  \n  *jnumb2 = 0;\n  \n  scorn1 = *gcoons;\n  \n  while (klft < kn2)\n    {\n      *jnumb1 = 0;\n      klfs = kk1 - 1;\n      while (klfs < kn1)\n        {\n\t  \n\t  /* Set pointers to the corners */\n\t  \n\t  scorn2 = scorn1 + 4*kdim;\n\t  scorn3 = scorn2 + 4*kdim;\n\t  scorn4 = scorn3 + 4*kdim;\n\t  \n\t  spar[0] = st1[klfs];\n\t  spar[1] = st2[klft];\n\t  \n\t  /* The parameter pair spar describes the lower left corner of the\n\t     current polynomial patch. By evaluating at spar we get\n\t     pointers into the knot vectors telling where we are. These are\n\t     klfs and klft t. We can calulate in the other corners by\n\t     just adding one to these pointers and find their parameter value.\n\t     */\n\t  \n\t  /* Calulate first corner of patch */\n\t  \n\t  s1424(ps1,kder,kder,spar,&klfs,&klft,scorn1,&kstat);\n\t  if (kstat<0) goto error;\n\t  \n\t  /* Find length of parameter intervals */\n\t  \n\t  tdiff1 = st1[klfs+1] - st1[klfs];\n\t  tdiff2 = st2[klft+1] - st2[klft];\n\t  \n\t  /* Calculate second corner of patch */\n\t  \n\t  sparx[0] = st1[klfs+1];\n\t  sparx[1] = spar[1];\n\t  kdumlfs = klfs;\n\t  kdumlft = klft;\n\t  \n\t  s1424(ps1,kder,kder,sparx,&kdumlfs,&kdumlft,scorn2,&kstat);\n\t  if (kstat<0) goto error;\n\t  \n\t  \n\t  /* Calculate third corner of patch */\n\t  \n\t  sparx[0] = spar[0];\n\t  sparx[1] = st2[klft+1];\n\t  kdumlfs = klfs;\n\t  kdumlft = klft;\n\t  \n\t  s1424(ps1,kder,kder,sparx,&kdumlfs,&kdumlft,scorn3,&kstat);\n\t  if (kstat<0) goto error;\n\t  \n\t  /* Calculate third corner of patch */\n\t  \n\t  sparx[0] = st1[klfs+1];\n\t  sparx[1] = st2[klft+1];\n\t  kdumlfs = klfs;\n\t  kdumlft = klft;\n\t  \n\t  s1424(ps1,kder,kder,sparx,&kdumlfs,&kdumlft,scorn4,&kstat);\n\t  if (kstat<0) goto error;                 \n\t  \n\t  /* Scale derivatives to match uniform parametrization */\n\t  \n\t  \n\t  /* Scale derivatives in first direction */\n\t  \n\t  for (kj=kdim;kj<2*kdim;kj++)\n            {\n\t      scorn1[kj] *= tdiff1;\n\t      scorn2[kj] *= tdiff1;\n\t      scorn3[kj] *= tdiff1;\n\t      scorn4[kj] *= tdiff1;\n            }\n\t  \n\t  /* Scale derivatives in second direction */\n\t  \n\t  for (kj=2*kdim;kj<3*kdim;kj++)\n            {\n\t      scorn1[kj] *= tdiff2;\n\t      scorn2[kj] *= tdiff2;\n\t      scorn3[kj] *= tdiff2;\n\t      scorn4[kj] *= tdiff2;\n            }\n\t  \n\t  /* Scale twist */\n\t  \n\t  tdum = tdiff1*tdiff2;\n\t  \n\t  for (kj=3*kdim;kj<4*kdim;kj++)\n            {\n\t      scorn1[kj] *= tdum;\n\t      scorn2[kj] *= tdum;\n\t      scorn3[kj] *= tdum;\n\t      scorn4[kj] *= tdum;\n            }\n\t  \n\t  /* Update position of first point of Coons patch */\n\t  \n\t  scorn1 += ksize;\n\t  \n\t  klfs += 1;\n\t  *jnumb1 +=1;\n        }\n      \n      klft += 1;\n      *jnumb2 +=1;\n    }\n  \n  /* The array is probably too big for the Coons patches, decrease the\n     array size */\n  \n  \n  /* Allocate array for storage of the coefficients */\n  \n  *gcoons = increasearray(*gcoons,((*jnumb1)*(*jnumb2)*16*kdim),DOUBLE);\n  if (*gcoons == SISL_NULL) goto err101;\n  \n  \n  /* Test if order to high */\n  \n  *jdim = kdim;\n  \n  if (kk1>4 || kk2 > 4) goto war01;\n  \n  *jstat = 0;\n  \n  goto out;\n  \n  /* Orders too high */\n  \n war01:*jstat=1;\n  goto out;\n  \n  \n  \n  \n  /* Error in scratch allocation */\n  \n err101: *jstat = -101;\n  s6err(\"s1388\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"s1388\",*jstat,kpos);\n  goto freeout;\n  \n  /* Some error has occured free allocated space */\n  \n freeout:\n  if (*gcoons != SISL_NULL) freearray(*gcoons);\n  goto out;\n  \n out:\n  return;\n}\n\n"
  },
  {
    "path": "src/s1389.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1389.c,v 1.2 2001-03-19 15:58:48 afr Exp $\n *\n */\n\n\n#define S1389\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1389(SISLCurve *pc1,double *gcubic[],int *jnumb,int *jdim,int *jstat)\n#else\nvoid s1389(pc1,gcubic,jnumb,jdim,jstat)\n     SISLCurve  *pc1;\n     double *gcubic[];\n     int    *jnumb;\n     int    *jdim;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Convert a B-spline curve of order up to 4 to a sequence\n*              of cubic segment with uniform parametrization\n*\n*                                            \n* INPUT      : pc1    - Pointer to the curve to be converted\n*\n*\n* OUTPUT     : gcubic - Array containing the sequence of cubic segments.\n*                       Each segment is represented by the start point,\n*                       followed by the start tangent, end point and end\n*                       tangent. Each segment takes 4*jdim doubles.\n*                       This array is allocated inside the function and must\n*                       be released by the calling function.            \n*\n*              jstat  - status messages  \n*                                         = 1      : Order too high, curve\n*                                                    interpolated\n*                                         = 0      : ok\n*                                         < 0      : error\n*                      \n*\n* METHOD     : For each polynomial segment end, the position and first\n*              derivative is calculated.\n*\n* USE:         int knumb,kdim,kstat;\n*              double *scubic;\n*              SISLSurf *qc1;\n*               .\n*               .\n*              s1389(qc1,&scubic,&knumb,&kdim,&kstat);\n*               .\n*              If one of the order of the curve is greater than four\n*              (*jstat==1) then degree reduction (order reduction) should\n*              be applied before using this routine to get a satisfactory\n*              representation of the curve by Coons patches.\n*              The degree reduction routine is s1343.\n*\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1221, s1227, s6err\n*\n* WRITTEN BY : Tor Dokken, SI, Norway, 1988-11\n*\n*********************************************************************\n*/                                     \n{\n  int kstat=0;        /* Local status variable.                          */\n  int kpos=0;         /* Position of error.                              */\n  int kdim;           /* Dimension of the space in which the surface lies. */\n  int kder=1;         /* Calculate all first derivatives                 */\n  int kleft=0;        /* Pointer into knot vector                        */\n  int kdumlft;        /* Temporary pointer into knot vector              */\n  int ksize;          /* Number of doubles to store a cubic segment      */\n  \n  int ki;             /* Control variables in for loop                   */\n  int kn;             /* Number of vertices                              */\n  int kk;             /* Polynomial order                                */\n  double *st;         /* Knots                                           */\n  double tpar;        /* Current parameter value                         */\n  double tparx;       /* Temporary parameter value                       */\n  double tdiff1;      /* Length of parameter interval                    */\n  double *scorn1;     /* Pointer to first end of segment                 */\n  double *scorn2;     /* Pointer to second end of segment                */\n  \n  kn  = pc1->in;\n  kk  = pc1->ik;\n  kdim = pc1 -> idim;\n  st  = pc1 -> et;\n  \n  \n  /* Calculate number of doubles to store a cubic segment*/\n  \n  ksize = kdim*4;\n  \n  \n  /* Allocate array for storage of the coefficients */\n  \n  *gcubic = newarray((kn*4*kdim),DOUBLE);\n  if (*gcubic == SISL_NULL) goto err101;\n  \n  kleft = kk - 1;\n  \n  *jnumb = 0;\n  \n  scorn1 = *gcubic;\n  \n  while (kleft < kn)\n    {\n      \n      /* Set pointers to the end of the segment */\n      \n      scorn2 = scorn1 + 2*kdim;\n      \n      tpar = st[kleft];\n      \n      /* The parameter describes the left corner of the segment. By \n\t evaluating at tpar we get the kleft to point to the parameter\n\t interval. The other end is at st[kleft+1].\n\t */\n      \n      /* Calulate start of segement */\n      \n      s1221(pc1,kder,tpar,&kleft,scorn1,&kstat);\n      if (kstat<0) goto error;\n      \n      /* Find length of aprameter intervals */\n      \n      tdiff1 = st[kleft+1] - st[kleft];\n      \n      /* Calculate end of segment, us left derivative */\n      \n      tparx = st[kleft+1];\n      kdumlft = kleft;\n      \n      s1227(pc1,kder,tparx,&kdumlft,scorn2,&kstat);\n      if (kstat<0) goto error;\n      \n      /* Scale derivatives to match uniform parametrization */\n      \n      for (ki=kdim;ki<2*kdim;ki++)\n        {\n\t  scorn1[ki] *= tdiff1;\n\t  scorn2[ki] *= tdiff1;\n        }\n      \n      kleft += 1;\n      *jnumb +=1;\n      scorn1 += kdim*4;\n    }\n  \n  /* The array is probably too big for the Coons patches, decrease the\n     array size */\n  \n  \n  /* Allocate array for storage of the coefficients */\n  \n  *gcubic = increasearray(*gcubic,((*jnumb)*4*kdim),DOUBLE);\n  if (*gcubic == SISL_NULL) goto err101;\n  \n  \n  /* Test if order to high */\n  \n  *jdim = kdim;\n  \n  if (kk>4) goto war01;\n  \n  *jstat = 0;\n  \n  goto out;\n  \n  /* Orders too high */\n  \n  war01:*jstat=1;\n    goto out;\n  \n  /* Error in scratch allocation */\n  \n  err101: \n    *jstat = -101;\n    s6err(\"s1389\",*jstat,kpos);\n    goto freeout;\n  \n  /* Error in lower level function.  */\n  \n  error : *jstat = kstat;\n    s6err(\"s1389\",*jstat,kpos); \n    goto freeout;\n  \n  /* Some error has occured free allocated space */\n  \n  freeout:\n    if (*gcubic != SISL_NULL) freearray(*gcubic);\n    goto out;\n  \n  out:\n    return;\n}\n\n"
  },
  {
    "path": "src/s1390.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1390.c,v 1.3 2001-03-19 15:58:48 afr Exp $\n *\n */\n\n\n#define S1390\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1390 (SISLCurve * pc1[], SISLSurf ** ps1, int nder[], int *jstat)\n#else\nvoid\ns1390 (pc1, ps1, nder, jstat)\n     SISLCurve *pc1[];\n     SISLSurf **ps1;\n     int nder[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n*  Purpose : Make a 4-edged-blending surface between 4 curves\n*            where each curve is associated a number of cross-derivative\n*            curves. The curves are numbered successively around the\n*            blending parameter directions are expected to be as follows when\n*            this routine is entered:\n*\n*                                 Direction right\n*                                      3\n*                                 ------------\n*                                 !          !\n*                    Direction up !          ! Direction up\n*                         4       !          !      2\n*                                 !          !\n*                                 !          !\n*                                 ------------\n*                                 Direction rigth\n*                                      1\n*\n*\n*       NB!  The cross-derivatives are always pointing into the patch,\n*            and note the directions in the above diagram.\n*\n*\n*\n* Input     : pc1       - Pointers to boundary curves\n*                         pc1[i],i=0,...nder[0]-1 are pointers to position\n*                         and cross-derivatives along first edge.\n*                         pc1[i],i=nder[0],...nder[1]-1 are pointers\n*                         to position and cross-derivatives along second edge.\n*                         pc1[i],i=nder[0]+nder[1],...nder[2]-1 are pointers\n*                         to position and cross-derivatives along third edge.\n*                         pc1[i],i=nder[0]+nder[1]+nder[2],...nder[3]-1 are\n*                         pointers to position and cross-derivatives\n*                         along fourth edge.\n*             nder[0:3] - nder[i] gives number of curves on\n*                         edge number i+1.\n*\n* Output    : ps1       - Pointer to blending surface.\n*\n*             jstat     - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* Use       : SISLCurve pc1[ANT];\n*             SISLSurf  *ps1;\n*             int jstat,nder[4];\n*\n*             pc1[0] = curve one;\n*             .\n*             .\n*             s1390(pc1,&ps1,nder,&jstat);\n*\n*\n* NB!    1. Inconsistent corner information will be overruled.\n*\n*-\n* Calls        : Previous version called h19732 - Rectangular blending.\n*\t\t This version calls s1750,s1333,s1387,\n*\t\t      s1934,s1935,s1938,s1924,s6err\n*\n* Note\t       : The original code written by Morten was removed and\n*                replaced by the code in s1922, and s1922.c was then\n*                removed. This was done by Bjoern Olav Hoset.\n*\n* Written by   : Morten Daehlen, SI, Aug. 88.\n* Rewritten by : Christophe R. Birkeland, SI, Aug. 91.(Routine s1922)\n* Revised by:    Christophe Rene Birkeland, SI, May. 93.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Sept. 1994. Removed\n*          memory leak from 'cpar', multiple free's of '(n)surf13' and\n*          '(n)surf24' and relocated some of the memory free'ing to reduce\n*          the memory requirements.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable used in calls to\n\t\t\t\t * lower subroutines\t\t\t*/\n  int kpos = 0;\t\t\t/* Error position indicator\t\t*/\n  int idim;\t\t\t/* Dimension of the space in which the\n\t\t\t\t * curves lie\t\t\t\t*/\n  int ki, kj, kk, kij;\t\t/* Loop control parameter\t\t*/\n  int kidim;\t\t\t/* Equals ki*idim\t\t\t*/\n  int kjdim;\t\t\t/* Equals kj*idim\t\t\t*/\n  int n0, n1, n2, n3;\t\t/* Equals nder[0],nder[1],nder[2],nder[3]*/\n  int n01;\t\t\t/* Equals nder[0]+nder[1]\t\t*/\n  int n012;\t\t\t/* Equals nder[0]+nder[1]+nder[2]\t*/\n  int inbcrv13;\t\t\t/* Number of curves in vpcrv13\t\t*/\n  int inbcrv24;\t\t\t/* Number of curves in vpcrv24\t\t*/\n  int iopen = TRUE;\t\t/* Indicates open=TRUE or closed curve\t*/\n  int ord13 = 0;\t\t/* Order to be used in lofting following\n\t\t\t\t * curves 1 and 3                       */\n  int ord24 = 0;\t\t/* Order to be used in lofting following\n\t\t\t\t * curves 1 and 3                       */\n  int order2;\t\t        /* Order of lofted surfaces in second\n\t\t\t\t * parameter direction                  */\n  int nr1;\t\t\t/* Number of degrees of freedom in the\n\t\t\t\t * B-basis given by the knot vector tr1 */\n  int nr2;\t\t\t/* Number of degrees of freedom in the\n\t\t\t\t * B-basis given by the knot vector tr2 */\n  int in2;\t\t\t/* Equals crv2ki->in\t\t\t*/\n  int in3;\t\t\t/* Equals crv3ki->in\t\t\t*/\n  int sf1ind, sf2ind;\t\t/* Index used in algorithm to match\n\t\t\t\t * vertices from surface 1 & 2\t\t*/\n  int type[6];\t\t\t/* Indicates type of curve in curve-set */\n  double stpar = DZERO;\t\t/* Start parameter value only used in\n\t\t\t\t * call s1333.\t\t\t\t*/\n  double ewrem;\t\t\t/* Stores a value of array ew\t\t*/\n  double start = 0.0;\t        /* Start and stop values in normalized \t*/\n  double stop = 1.0;    \t/* knot vectors\t\t\t\t*/\n  double *tr1 = SISL_NULL;\t\t/* Union of knot-vectors nsurf13->et1\n\t\t\t\t * and nsurf24->et2\t\t\t*/\n  double *tr2 = SISL_NULL;\t\t/* Union of knot-vectors nsurf13->et2\n\t\t\t\t * and nsurf24->et1\t\t\t*/\n  double *cpar = SISL_NULL;\t\t/* Array needed in call s1333\t\t*/\n  double *srfr1 = SISL_NULL;\t\t/* Vertices of first surface represented\n\t\t\t\t * with common refined knot vectors\t*/\n  double *srfr2 = SISL_NULL;\t\t/* Vertices of second surface represented\n\t\t\t\t * with common refined knot vectors\t*/\n  double *scoef = SISL_NULL;\t\t/* Vertices of output surface\t\t*/\n  double *ew = SISL_NULL;\t\t/* Weight matrix used used to blend\n\t\t\t\t * together 2 surfaces\t\t\t*/\n  SISLCurve *rc1 = SISL_NULL;\t/* Parameter needed in call s1750\t*/\n  SISLCurve *rc2 = SISL_NULL;\t/* Parameter needed in call s1750\t*/\n  SISLCurve *vpcrv13[6];\t/* Array of pointers to curves 1 & 3\n\t\t\t\t * (inclusive derivatives)\t\t*/\n  SISLCurve *vpcrv24[6];\t/* Array of pointers to curves 2 & 4\n\t\t\t\t * (inclusive derivatives)\t\t*/\n  SISLCurve *crv2ki = SISL_NULL;\t/* \"Derivatiave curve\" ki-1 of curve 2\t*/\n  SISLCurve *crv3ki = SISL_NULL;\t/* \"Derivatiave curve\" ki-1 of curve 3\t*/\n  SISLSurf *surf13 = SISL_NULL;\t/* Surface generated by s1333 from curves\n\t\t\t\t * contained in vpcrv13\t\t\t*/\n  SISLSurf *nsurf13 = SISL_NULL;\t/* Surface generated by s1387\t\t*/\n  SISLSurf *surf24 = SISL_NULL;\t/* Surface generated by s1333 from curves\n\t\t\t\t * contained in vpcrv24\t\t\t*/\n  SISLSurf *nsurf24 = SISL_NULL;\t/* Surface generated by s1387\t\t*/\n\n  *jstat = 0;\n\n\n  /*\n   * Initialization\n   * ---------------\n   */\n\n  idim = pc1[0]->idim;\n  n0   = nder[0];\n  n1   = nder[1];\n  n2   = nder[2];\n  n3   = nder[3];\n  n01  = n0 + n1;\n  n012 = n01 + n2;\n\n\n  /*\n   * Check input: derivative order and all input curves\n   * --------------------------------------------------\n   */\n\n  if (n0 > 3 || n1 > 3 || n2 > 3 || n3 > 3)\n    goto err151;\n  for(ki=0; ki < n012+n3; ki++)\n    {\n      s1707(pc1[ki], &kstat);\n      if (kstat < 0) goto error;\n    }\n\n\n  /*\n   * Copy curves 1 & 3 (inclusive derivatives) into vpcrv13\n   * ------------------------------------------------------\n   */\n\n  inbcrv13 = n0 + n2;\n\n  for (ki = 0; ki < n0; ki++)\n    vpcrv13[ki] = pc1[ki];\n  for (ki = 0; ki < n2; ki++)\n    vpcrv13[ki + n0] = pc1[n01 + ki];\n\n  /*\n   * Copy curves 2 & 4 (inclusive derivatives) into vpcrv24\n   * ------------------------------------------------------\n   */\n\n  inbcrv24 = n1 + n3;\n\n  for (ki = 0; ki < n3; ki++)\n    vpcrv24[ki] = pc1[n012 + ki];\n  for (ki = 0; ki < n1; ki++)\n    vpcrv24[ki + n3] = pc1[n0 + ki];\n\n\n  /*\n   * Find max. order in lofting directions\n   * ----------------------------------------------------\n   */\n\n  for(ki=0; ki < n0+n2; ki++)\n    ord13 = MAX( vpcrv13[ki]->ik, ord13);\n  ord13 = MAX( n1+n3, ord13);\n\n  for(ki=0; ki < n1+n3; ki++)\n    ord24 = MAX( vpcrv24[ki]->ik, ord24);\n  ord24 = MAX( n0+n2, ord24);\n\n\n  /*\n   * Spline lofted surface between curve 1 and 3.\n   * --------------------------------------------\n   */\n\n  for (ki = 0; ki < n0; ki++)\n    switch (ki)\n      {\n      case 0:\n\ttype[ki] = 1;\n\tcontinue;\n      case 1:\n\ttype[ki] = 4;\n\tcontinue;\n      case 2:\n\ttype[ki] = 6;\n\tcontinue;\n      }\n  for (ki = 0; ki < n2; ki++)\n    {\n      switch (ki)\n\t{\n\tcase 0:\n\t  type[ki + n0] = 1;\n\t  continue;\n\tcase 1:\n\t  type[ki + n0] = 4;\n\t  break;\n\tcase 2:\n\t  type[ki + n0] = 6;\n\t  break;\n\t}\n\n      if (ki > 0)\n\t{\n\t  /*\n\t   * Derivative directions along curve 3\n\t   * must be turned for use in call s1333\n\t   * -------------------------------------\n\t   */\n\n\t  crv3ki = vpcrv13[n0 + ki];\n\t  in3 = crv3ki->in;\n\t  for (kj = 0; kj < idim * in3; kj++)\n\t    crv3ki->ecoef[kj] = -crv3ki->ecoef[kj];\n\t}\n    }\n\n  /*\n   * LOFTING in 1. par. dir. using curve 1 and 3\n   * -------------------------------------------\n   */\n\n  s1333 (inbcrv13, vpcrv13, type, stpar, iopen, ord24, 0,\n\t &surf13, &cpar, &kstat);\n  if (cpar) freearray(cpar);  /* Not used (PFU 26/09-94) */\n  if (kstat < 0) goto error;\n\n  /*\n   * DEGREE raising if  necessary, first check that\n   * order in 1. par. direction is right.\n   * ----------------------------------------------\n   */\n\n  order2 = MAX( surf13->ik2, ord24 );\n\n  if (surf13->ik1 != ord13) goto err160;\n\n  if (order2 > surf13->ik2)\n  {\n    s1387 (surf13, ord13, order2, &nsurf13, &kstat);\n    if (surf13) freeSurf(surf13);  /* Not needed anymore (PFU 26/09-94) */\n  }\n  else\n    nsurf13 = surf13;\n  surf13 = SISL_NULL;  /* Just in case */\n  if (kstat < 0) goto error;\n\n  /*\n   * Derivative direction along curve 3\n   * must be turned back to original direction\n   * ------------------------------------------\n   */\n\n  for (ki = 1; ki < n2; ki++)\n    {\n      crv3ki = vpcrv13[n0 + ki];\n      in3 = crv3ki->in;\n      for (kj = 0; kj < idim * in3; kj++)\n\tcrv3ki->ecoef[kj] = -crv3ki->ecoef[kj];\n    }\n\n\n  /*\n   * Spline lofted surface between curve 4 and 2.\n   * --------------------------------------------\n   */\n\n  for (ki = 0; ki < n3; ki++)\n    switch (ki)\n      {\n      case 0:\n\ttype[ki] = 1;\n\tcontinue;\n      case 1:\n\ttype[ki] = 4;\n\tcontinue;\n      case 2:\n\ttype[ki] = 6;\n\tcontinue;\n      }\n  for (ki = 0; ki < n1; ki++)\n    {\n      switch (ki)\n\t{\n\tcase 0:\n\t  type[ki + n3] = 1;\n\t  continue;\n\tcase 1:\n\t  type[ki + n3] = 4;\n\t  break;\n\tcase 2:\n\t  type[ki + n3] = 6;\n\t  break;\n\t}\n\n      /*\n       * Derivative direction along curve 2\n       * must be turned for use in call s1333\n       * ------------------------------------\n       */\n\n      if (ki > 0)\n\t{\n\t  crv2ki = vpcrv24[ki + n3];\n\t  in2 = crv2ki->in;\n\t  for (kj = 0; kj < idim * in2; kj++)\n\t    crv2ki->ecoef[kj] = -crv2ki->ecoef[kj];\n\t}\n    }\n\n  /*\n   * LOFTING in 2. par. dir. using curve 2 and 4\n   * -------------------------------------------\n   */\n\n  s1333 (inbcrv24, vpcrv24, type, stpar, iopen, ord13, 0,\n\t &surf24, &cpar, &kstat);\n  if (cpar) freearray(cpar);  /* Not used (PFU 26/09-94) */\n  if (kstat < 0) goto error;\n\n  /*\n   * DEGREE raising if  necessary, first check that\n   * order in 1. par. direction is right.\n   * ----------------------------------------------\n   */\n\n  order2 = MAX( surf24->ik2, ord13 );\n\n  if (surf24->ik1 != ord24) goto err160;\n\n  if (order2 > surf24->ik2)\n  {\n    s1387 (surf24, ord24, order2, &nsurf24, &kstat);\n    if (surf24) freeSurf(surf24);  /* Not needed anymore (PFU 26/09-94) */\n  }\n  else\n    nsurf24 = surf24;\n  surf24 = SISL_NULL;\n  if (kstat < 0) goto error;\n\n\n  /*\n   * Derivative direction along curve 2\n   * must be turned back to original direction\n   * ------------------------------------------\n   */\n\n  for (ki = 1; ki < n1; ki++)\n    {\n      crv2ki = vpcrv24[ki + n3];\n      in2 = crv2ki->in;\n      for (kj = 0; kj < idim * in2; kj++)\n\tcrv2ki->ecoef[kj] = -crv2ki->ecoef[kj];\n    }\n\n  /*\n   * Normalize knot vectors\n   * ----------------------\n   */\n\n  s1934 (nsurf13->et1, nsurf13->in1, nsurf13->ik1, start, stop, &kstat);\n  if (kstat < 0) goto error;\n  s1934 (nsurf13->et2, nsurf13->in2, nsurf13->ik2, start, stop, &kstat);\n  if (kstat < 0) goto error;\n  s1934 (nsurf24->et1, nsurf24->in1, nsurf24->ik1, start, stop, &kstat);\n  if (kstat < 0) goto error;\n  s1934 (nsurf24->et2, nsurf24->in2, nsurf24->ik2, start, stop, &kstat);\n  if (kstat < 0) goto error;\n\n\n  /*\n   * Next we find union of knot-vectors nsurf13->et1 and nsurf24->et2,\n   * and union of knot-vectors nsurf13->et2 and nsurf24->et1.\n   * -----------------------------------------------------------------\n   */\n\n  s1935 (nsurf13->et1, nsurf13->in1, nsurf24->et2, nsurf24->in2,\n\t &tr1, &nr1, ord13, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  s1935 (nsurf13->et2, nsurf13->in2, nsurf24->et1, nsurf24->in1,\n\t &tr2, &nr2, ord24, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /*\n   * Represent the two surfaces with common refined knot-vectors\n   * ------------------------------------------------------------\n   */\n\n  s1938 (nsurf13, tr1, nr1, tr2, nr2, &srfr1, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  s1938 (nsurf24, tr2, nr2, tr1, nr1, &srfr2, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /*\n   * Allocate array scoef\n   * -------------------\n   */\n\n  scoef = newarray (nr1 * nr2 * idim, DOUBLE);\n  if (scoef == SISL_NULL)\n    goto err101;\n\n\n  /*\n   * Match vertices from surface 1 and 2\n   * ------------------------------------\n   */\n\n  s1924 (n0, n1, n2, n3, nr1, nr2, &ew, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  for (kij = kj = 0; kj < nr2; kj++)\n    {\n      kjdim = kj * idim;\n      for (ki = 0; ki < nr1; ki++, kij++)\n\t{\n\t  kidim = ki * idim;\n\t  sf1ind = kidim * nr2 + kjdim;\n\t  sf2ind = kjdim * nr1 + kidim;\n\t  ewrem = ew[kij];\n\n\t  for (kk = 0; kk < idim; kk++)\n\t    scoef[sf2ind + kk] = ewrem * srfr1[sf2ind + kk] +\n\t      (1 - ewrem) * srfr2[sf1ind + kk];\n\t}\n    }\n\n  /*\n   * Generate the new surface\n   * ------------------------\n   */\n\n  *ps1 = newSurf (nr1, nr2, ord13, ord24, tr1, tr2, scoef, 1, idim, 2);\n  if (*ps1 == SISL_NULL)\n    goto err171;\n\n  goto out;\n\n\n  /* Memory error. */\n\n  err101:\n    *jstat = -101;\n    s6err (\"s1390\", *jstat, kpos);\n    goto out;\n\n  /* Input error: order of derivative greater than two */\n\n  err151:\n    *jstat = -151;\n    s6err (\"s1390\", *jstat, kpos);\n    goto out;\n\n  /* Error in orders of generated surfaces */\n\n  err160:\n    *jstat = -160;\n    s6err (\"s1390\", *jstat, kpos);\n    goto out;\n\n  /* Could not create surface. */\n\n  err171:\n    *jstat = -171;\n    s6err (\"s1390\", *jstat, kpos);\n    goto out;\n\n  /* Error in lower level routine. */\n\n  error:\n    *jstat = kstat;\n    s6err (\"s1390\", *jstat, kpos);\n    goto out;\n\n  out:\n    if (nsurf13 != SISL_NULL) freeSurf (nsurf13);\n    if (nsurf24 != SISL_NULL) freeSurf (nsurf24);\n    if (ew != SISL_NULL) freearray (ew);\n    if (srfr1 != SISL_NULL) freearray (srfr1);\n    if (srfr2 != SISL_NULL) freearray (srfr2);\n    if (rc1 != SISL_NULL) freeCurve(rc1);\n    if (rc2 != SISL_NULL) freeCurve(rc2);\n\n    return;\n}\n"
  },
  {
    "path": "src/s1391.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1391.c,v 1.3 2001-03-19 15:58:49 afr Exp $\n *\n */\n\n\n#define S1391\n\n#include \"sislP.h\"\n\ntypedef void (*fshapeProc)(\n#if defined(SISLNEEDPROTOTYPES)\n                           double [],\n                           double [],\n                           int,\n                           int,\n                           int *\n#endif\n);\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1391(SISLCurve **pc,SISLSurf ***ws,int icurv,int nder[],int *jstat)\n#else\nvoid s1391(pc,ws,icurv,nder,jstat)\n     SISLCurve **pc;\n     SISLSurf  ***ws;\n     int   icurv;\n     int   nder[];\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* Purpose   : To create a first derivative continuous blend over a\n*             3-, 4-, 5- and 6-sided region in space. The boundary of the\n*             region are B-spline curves and the cross boundary derivatives\n*             are given as B-spline curves. This function automatically\n*             preprosesses the input cross tangent curves in order to\n*             make them suitable for the blending. Thus, the cross tangent\n*             curves should be taken as the cross tangents of the\n*             surrounding surface. It is not necessary and not advisable\n*             to match tangents etc. in the corners.\n*\n*\n* Input     : pc        - Pointers to boundary curves. All curves must\n*                         have same parameter direction around the patch,\n*                         either clockwise or counter-clockwise.\n*                         pc1[i],i=0,...nder[0]-1 are pointers to position\n*                         and cross-derivatives along first edge.\n*                         pc1[i],i=nder[0],...nder[1]-1 are pointers\n*                         to position and cross-derivatives along second edge.\n*                         .\n*                         .\n*                         pc1[i],i=nder[0]+...+nder[icurve-2],...\n*                         nder[icurve-1]-1 are pointers to position and\n*                         cross-derivatives along fourth edge.\n\n*             icurv     - (3,5,4 or 6), Number of boundary curves.\n*             nder[0:icurv-1] - nder[i] gives number of curves on\n*                               edge number i+1. These numbers has to\n*                               be equal to 2.\n*\n* Output    : ws        - ws[0:icurve-1] are pointers to the blending surface\n*\n*             jstat     - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* Use        : SISLCurve *pc1[KCURVE];\n*              SISLSurf  **rs1;\n*              int jstat,icurve,nder[KSURF];\n*\n*              icurve = number of boundaries;\n*              nder[0] = nder[1] = ... = nder[icurve-1] = 2;\n*              pc1[0] = curve one;\n*              .\n*              .\n*\n*              s1391(pc1,&rs1,icurve,nder,&jstat);  icurve surfaces is given\n*                                                   as output.\n*\n*\n*  NB!         Position and tangent has to be given, that is\n*              n1=n2=n3=((n4=n5)=n6)=2.\n*\n*-\n* Calls      : s1720  - Differentiate B-spline curve.\n*              sh1263 - Prepare input curves for the blending\n*              sh1460 - Perform blending.\n*              s6err  - Error messages.\n*\n* Written by : Morten Daehlen, SI, Aug. 88.\n* Rewritten by : Vibeke Skytt, SINTEF SI, 93-11.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Sept. 1994. Fixed memory\n*              problems related to 'qc1'.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;   /* Local status variable.  */\n   int kpos = 0;\n   int ki;\n   SISLCurve **qc1 = SISL_NULL;  /* Input curves to the\n\t\t\t       preparation of curves function.         */\n   SISLCurve **qc2 = SISL_NULL;  /* Output curves from the\n\t\t\t       preparation of curves function.         */\n   fshapeProc fshape;\n   /* #if defined(SISLNEEDPROTOTYPES)\n   void (*fshape)(double*, double*, int, int, int*);\n#else\n   void (*fshape)();\n#endif  */\n   fshape = shape;\n\n   if ((qc1 = newarray(3*icurv, SISLCurve*)) == SISL_NULL) goto err101;\n   if ((qc2 = newarray(2*icurv, SISLCurve*)) == SISL_NULL) goto err101;\n   memzero(qc1, 3*icurv, SISLCurve*);\n   memzero(qc2, 2*icurv, SISLCurve*);\n\n   /* Test input.  */\n\n   if (icurv != 3 && icurv != 4 && icurv != 5 && icurv != 6) goto err180;\n   for (ki=0; ki<icurv; ki++)\n      if (nder[ki] != 2) goto err180;\n\n   /* Copy input curve to the prepare array. Differentiate\n      the position curve to get a second derivative curve. */\n\n   for (ki=0; ki<icurv; ki++)\n   {\n      qc1[3*ki] = pc[2*ki];\n      qc1[3*ki+1] = pc[2*ki+1];\n      qc1[3*ki+2] = SISL_NULL;\n\n      s1720(qc1[3*ki], 1, qc1+3*ki+2, &kstat);\n      if (kstat < 0) goto error;\n   }\n\n   /* Prepare boundary conditions for vertex blend. */\n\n   sh1263(qc1, icurv, qc2, &kstat);\n   if (kstat < 0) goto error;\n\n   /* Perform blending of 3-, 4-, 5 or 6-sided area.  */\n\n   sh1460(fshape, qc2, icurv, ws, &kstat);\n   if (kstat < 0) goto error;\n\n   /* Blending performed. */\n\n   *jstat = 0;\n   goto out;\n\n   /* Error in scratch allocation. */\n\n   err101 :\n      *jstat = -101;\n   s6err(\"s1391\", *jstat, kpos);\n   goto out;\n\n   /* Error in input. Wrong number of boundaries or derivative curves. */\n\n   err180 :\n      *jstat = -180;\n   s6err(\"s1391\", *jstat, kpos);\n   goto out;\n\n   /* Error in lower level function. */\n\n   error :\n      *jstat = kstat;\n   s6err(\"s1391\", *jstat, kpos);\n   goto out;\n\n   out :\n      for (ki=0; ki<icurv; ki++)\n      {\n\t if (qc1[3*ki+2] != SISL_NULL) freeCurve(qc1[3*ki+2]);\n\t if (qc2[2*ki] != SISL_NULL) freeCurve(qc2[2*ki]);\n\t if (qc2[2*ki+1] != SISL_NULL) freeCurve(qc2[2*ki+1]);\n      }\n      if (qc1 != SISL_NULL) freearray(qc1);\n      if (qc2 != SISL_NULL) freearray(qc2);\n\n      return;\n}\n"
  },
  {
    "path": "src/s1393.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1393.c,v 1.2 2001-03-19 15:58:49 afr Exp $\n *\n */\n\n\n#define S1393\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1393(int n1,SISLCurve *pc1[],SISLCurve *sc1[],SISLCurve *ec1[],int *jstat)\n#else\nvoid s1393(n1,pc1,sc1,ec1,jstat)\n     int   n1;\n     SISLCurve *pc1[];\n     SISLCurve *sc1[];\n     SISLCurve *ec1[];\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* Purpose :  Split curve at midpoint, turn second curve, \n*            and normalize parameterinterval.\n*\n* Input     : pc1       - Pointers to first boundary curves\n*             n1        - Number of curves\n*\n* Output    : sc1       - Pointers to first part of curve.\n*             ec1       - Pointers to second part of curve.\n*\n*             jstat     - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                      \n*-\n* Calls      : s6err - error messages.\n*              s1710 - split curve at given parameter value.\n*              s1706 - Turn parametrization of curve.\n*              s1399 - Normalize parameterinterval.\n*\n* Written by : Mortend Daehlen, SI, Aug. 88.\n*\n*********************************************************************\n*/                                     \n{\n  int kpos = 0;\n  int ki;\n  int kstat = 0;\n  double ax,astart,astop;\n  SISLCurve *h1,*h2;\n  \n  astart = DZERO;\n  astop  = (double)1.0;\n  \n  /* For each curve in pc1 split/turn and normalize. */\n  for (ki=0;ki<n1;ki++)\n    {\n      \n      /* Split */\n      \n      ax=(pc1[ki]->et[pc1[ki]->in]-(pc1[ki]->et[(pc1[ki]->ik)-1]))/(double)2.0;\n      s1710(pc1[ki],ax,&h1,&h2,&kstat); \n      if (kstat < 0) goto error;\n      \n      /* Turn */\n      \n      s1706(h2);\n      if (kstat < 0) goto error;\n      \n      /* Normalize */\n      \n      s1399(h1,astart,astop);\n      if (kstat < 0) goto error;\n      s1399(h2,astart,astop);\n      if (kstat < 0) goto error;\n      sc1[ki] = h1;\n      ec1[ki] = h2;\n    }\n  \n  *jstat=0;\n  goto out;\n  \n  /* Error in lower level routine.   */\n  \n error: *jstat = kstat;\n  s6err(\"s1393\",*jstat,kpos);\n  goto out;\n  \n out: return;\n}\n"
  },
  {
    "path": "src/s1399.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1399.c,v 1.2 2001-03-19 15:58:49 afr Exp $\n *\n */\n\n\n#define S1399\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1399(SISLCurve *pc,double astart,double astop)\n#else\nvoid s1399(pc,astart,astop)\n     SISLCurve  *pc;\n     double astart;\n     double astop;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Change the knotvector to go from astart to astop.\n*\n* INPUT      : pc      - The curve.\n*              astart  - Parametervalue at new startpoint.\n*              astop   - Parametervalue at new endpoint.\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Morten Daehlen, SI, 88-09.\n*\n********************************************************************/\n{\n  int  kk= pc->ik;             /* Order of the input curve.             */\n  int  kn= pc->in;             /* Number of vertices in the input curve.*/\n  double *st=SISL_NULL;             /* Pointers used in loop.                */ \n  double a,b;\n  int ii, kpos=0, kstat=0;\n  if (!pc) goto out;\n  \n  if((st = newarray(kk+kn,DOUBLE)) == SISL_NULL) goto err101;\n  \n  a = pc -> et[kk-1];\n  b = pc -> et[kn];\n  \n  for (ii=0;ii<kn+kk;ii++)\n    st[ii] = astart+(((pc -> et[ii])-a)/(b-a))*(astop-astart);\n  for (ii=0;ii<kn+kk;ii++)\n    pc -> et[ii] = st[ii];\n  goto out;\n  \n  /* Error in scratch allocation */\n  \n  err101: \n    kstat = -101;\n    s6err(\"s1399\",kstat,kpos);\n    goto out;\n      \n  out:\n    if (st != SISL_NULL) freearray(st);\n    return;\n}\n"
  },
  {
    "path": "src/s1401.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1401.c,v 1.5 2001-03-19 15:58:49 afr Exp $\n *\n */\n\n\n#define S1401\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void s1401_s9blend(double [],int,int,int *);\nstatic void s1401_s9basis1(int,int,double [],int,int,int,double [],\n\t\t\t\t int,int,double [],double [],double **,int *);\nstatic void s1401_s9basis2(int,int,double [],int,int,int,double [],\n\t\t\t\t int,int,double [],double [],double **,int *);\n#else\n  static void   s1401_s9blend();\n  static void   s1401_s9basis1();\n  static void   s1401_s9basis2();\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1401(SISLCurve *vcurve[],double etwist[],\n\t      SISLSurf **rsurf,int *jstat)\n#else\nvoid s1401(vcurve,etwist,rsurf,jstat)\n     double etwist[];\n     SISLCurve *vcurve[];\n     int *jstat;\n     SISLSurf **rsurf;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Compute a Gordon patch given position and cross tangent\n*              conditions at the boundary of a squared region and the\n*              twist vector in the corners/\n*\n*\n*\n* INPUT      : vcurve - Position and cross-tangent curves around the square\n*                       region. For each edge of the region position and cross-\n*                       tangent curves are given. The dimension of the array is 8.\n*                       The orientation is as follows :\n*\n*                                     3 ---->\n*                               -------------------\n*                               |                 |\n*                           /|\\ |                 | /|\\\n*                            |  |                 |  |\n*                            |  |                 |  |\n*                            4  |                 |  2\n*                               |                 |\n*                               -------------------\n*                                     1 ---->\n*\n*              etwist - Twist-vectors of the corners of the vertex region. The\n*                       first element of the array is the twist in the corner\n*                       before the first edge, etc. The dimension of the array\n*                       is 4*kdim.\n*\n*\n* OUTPUT     : rsurf  - Gordons patch represented as a B-spline patch.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n* REFERENCES : I. D. Faux and M. J. Pratt :\n*                        Computational Geometry for Design and Manufacture\n*              J. Hahn : Filling Polygonal Holes with Rectangular Patches\n*\n* USE        : 3D non-rational geometry only.\n*\n*-\n* CALLS      : s1221 - Evaluate curve at a given parameter value.\n*              s1931unit\n*              s1750\n*              freeCurve\n*              newSurf\n*\n* WRITTEN BY : Vibeke Skytt, SI, April 90.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov. 1994.  Updated\n*              comments from Coons to Gordons patches.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\n  int kdim;\n  int kder;\n  int kcurve;\n  int ki,kj,kk,kh,kl;\n  int kleft = 0;\n  int kn1;\n  int kk1;\n  int kn2;\n  int kk2;\n  int korder = 4;\n\n  double tpar;\n  double salpha[16];\n  double sknot0[8];\n  double *sder = SISL_NULL;\n  double *sknot1 = SISL_NULL;\n  double *scoef1 = SISL_NULL;\n  double *sknot2 = SISL_NULL;\n  double *scoef2 = SISL_NULL;\n  double *ssurf1 = SISL_NULL;\n  double *ssurf2 = SISL_NULL;\n  double *ssurf3 = SISL_NULL;\n  double *ssurf4 = SISL_NULL;\n  double *smat = SISL_NULL;\n  double *ssurf1new = SISL_NULL;\n  double *ssurf2new = SISL_NULL;\n  double *ssurf3new = SISL_NULL;\n\n  SISLCurve *qc1[4];\n  SISLCurve *qc2[4];\n\n  for (ki=0; ki<4; ki++)\n  {\n     qc1[ki] = SISL_NULL;\n     qc2[ki] = SISL_NULL;\n  }\n\n  /* Test dimension.  */\n\n  kdim = vcurve[0] -> idim;\n  for (ki=1; ki<8; ki++)\n    if (vcurve[ki]->idim != kdim) goto err102;\n\n  /* Allocate scratch for local array.  */\n\n  if ((sder = newarray(3*kdim,DOUBLE)) == SISL_NULL) goto err101;\n  if ((smat = newarray(16*kdim,DOUBLE)) == SISL_NULL) goto err101;\n\n  /* TEST !!! */\n\n  /*\n  kder = 1;\n  for (ki=0; ki<4; ki++)\n    {\n      kj = (ki + 1) % 4;\n\n      tpar = (ki >= 2) ? *(vcurve[2*ki]->et + vcurve[2*ki]->ik - 1) :\n\t*(vcurve[2*ki]->et + vcurve[2*ki]->in);\n\n      s1221(vcurve[2*ki+1],kder,tpar,&kleft,sder,&kstat);\n      if (kstat < 0) goto error;\n\n      memcopy(sder,sder+kdim,kdim,DOUBLE);\n\n      tpar = (kj < 2) ? *(vcurve[2*kj]->et + vcurve[2*kj]->ik - 1) :\n\t*(vcurve[2*kj]->et + vcurve[2*kj]->in);\n\n      s1221(vcurve[2*kj+1],kder,tpar,&kleft,sder+kdim,&kstat);\n      if (kstat < 0) goto error;\n    }\n  */\n\n\n  /* Set up blending functions.  */\n\n  salpha[0] = (double)1.0;\n  salpha[1] = salpha[2] = salpha[3] = (double)0.0;\n  s1401_s9blend(salpha,4,1,&kstat);\n\n  salpha[4] = salpha[5] = salpha[6] = (double)0.0;\n  salpha[7] = (double)1.0;\n  s1401_s9blend(salpha+4,4,1,&kstat);\n\n  salpha[9] = (double)1.0;\n  salpha[8] = salpha[10] = salpha[11] = (double)0.0;\n  s1401_s9blend(salpha+8,4,1,&kstat);\n\n  salpha[14] = (double)1.0;\n  salpha[12] = salpha[13] = salpha[15] = (double)0.0;\n  s1401_s9blend(salpha+12,4,1,&kstat);\n\n  /* Initiate knot vector of blending functions.  */\n\n  for (ki=0; ki<4; ki++)\n    {\n      sknot0[ki] = (double)0.0;\n      sknot0[4+ki] = (double)1.0;\n    }\n\n  /* Evaluate the boundary curves in the corners of the region.  */\n\n  for (ki=0; ki<4; ki++)\n    {\n      tpar = (ki < 2) ? *(vcurve[2*ki]->et + vcurve[2*ki]->ik - 1) :\n\t*(vcurve[2*ki]->et + vcurve[2*ki]->in);\n\n      kder = 1;\n\n      s1221(vcurve[2*ki],kder,tpar,&kleft,sder,&kstat);\n      if (kstat < 0) goto error;\n\n      kder = 0;\n      s1221(vcurve[2*ki+1],kder,tpar,&kleft,sder+2*kdim,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Copy into matrix of correction term.  */\n\n      kj = (ki > 1);\n      kk = MIN(ki % 3,1);\n\n      memcopy(smat+(kk*4+kj)*kdim,sder,kdim,DOUBLE);\n      memcopy(smat+((kk+2)*4+kj)*kdim,sder+(((kk+kj)%2)+1)*kdim,kdim,DOUBLE);\n      memcopy(smat+(kk*4+kj+2)*kdim,sder+(2-((kk+kj)%2))*kdim,kdim,DOUBLE);\n\n    }\n\n  for (kh=0; kh<kdim; kh++)\n    {\n      smat[3*kdim+kh] *= -(double)1.0;\n      smat[13*kdim+kh] *= -(double)1.0;\n    }\n\n  /* Copy twist vector into matrix of correction term.  */\n\n  memcopy(smat+10*kdim,etwist,kdim,DOUBLE);\n  memcopy(smat+11*kdim,etwist+3*kdim,kdim,DOUBLE);\n  memcopy(smat+14*kdim,etwist+kdim,kdim,DOUBLE);\n  memcopy(smat+15*kdim,etwist+2*kdim,kdim,DOUBLE);\n\n  /* Put all curves along the standard edges 1 and 3 on the same knotvector.\n     First fetch the actual curves.  */\n\n  kcurve = 4;\n  qc1[0] = vcurve[0];\n  qc1[1] = vcurve[4];\n  qc1[2] = vcurve[1];\n  qc1[3] = vcurve[5];\n\n  for (ki=0; ki<4; ki++)\n    {\n      if (qc1[ki]->ik < 4)\n\t{\n\t  /* Raise the order of the curve. */\n\n\t  s1750(qc1[ki],korder,qc1+ki,&kstat);\n\t  if (kstat < 0) goto error;\n\t}\n    }\n\n  /* Express the curves in a common basis.  */\n\n  s1931unit(kcurve,qc1,&sknot1,&scoef1,&kn1,&kk1,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Put all curves along the standard edges 2 and 4 on the same knotvector.\n     First fetch the actual curves.  */\n\n  qc2[0] = vcurve[6];\n  qc2[1] = vcurve[2];\n  qc2[2] = vcurve[7];\n  qc2[3] = vcurve[3];\n\n  for (ki=0; ki<4; ki++)\n    {\n      if (qc2[ki]->ik < 4)\n\t{\n\t  /* Raise the order of the curve. */\n\n\t  s1750(qc2[ki],korder,qc2+ki,&kstat);\n\t  if (kstat < 0) goto error;\n\t}\n    }\n\n  /* Express the curves in a common basis.  */\n\n  s1931unit(kcurve,qc2,&sknot2,&scoef2,&kn2,&kk2,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Allocate scratch for coefficients of blending surfaces.  */\n\n  if ((ssurf1 = new0array(4*kn1*kdim,DOUBLE)) == SISL_NULL) goto err101;\n  if ((ssurf2 = new0array(kn2*4*kdim,DOUBLE)) == SISL_NULL) goto err101;\n  if ((ssurf3 = new0array(16*kdim,DOUBLE)) == SISL_NULL) goto err101;\n\n  /* Compute coefficients of 1. blending surface.  */\n\n  for (ki=0; ki<4; ki++)\n    for (kj=0; kj<4; kj++)\n      for (kk=0; kk<kn1; kk++)\n\tfor (kh=0; kh<kdim; kh++)\n\t  ssurf1[(kk*4+kj)*kdim+kh] +=\n\t    salpha[ki*4+kj]*scoef1[(ki*kn1+kk)*kdim+kh];\n\n  /* Compute coefficients of 2. blending surface.  */\n\n  for (ki=0; ki<4; ki++)\n    for (kk=0; kk<kn2; kk++)\n      for (kj=0; kj<4; kj++)\n\tfor (kh=0; kh<kdim; kh++)\n\t  ssurf2[(kj*kn2+kk)*kdim+kh] +=\n\t    scoef2[(ki*kn2+kk)*kdim+kh]*salpha[ki*4+kj];\n\n  /* Compute the correction surface.  */\n\n  for (ki=0; ki<4; ki++)\n    for (kj=0; kj<4; kj++)\n      for (kk=0; kk<4; kk++)\n\tfor (kl=0; kl<4; kl++)\n\t  for (kh=0; kh<kdim; kh++)\n\t    ssurf3[(kk*4+kl)*kdim+kh] +=\n\t      salpha[ki*4+kk]*salpha[kj*4+kl]*smat[(ki*4+kj)*kdim+kh];\n\n  /* Express all 3 surfaces in the same basis.  */\n\n  s1401_s9basis1(kk2,kn2,sknot2,kdim,4,4,sknot0,kk1,kn1,sknot1,ssurf1,\n\t  &ssurf1new,&kstat);\n  if (kstat < 0) goto error;\n\n  s1401_s9basis2(kk1,kn1,sknot1,kdim,kk2,kn2,sknot2,4,4,sknot0,ssurf2,\n\t  &ssurf2new,&kstat);\n  if (kstat < 0) goto error;\n\n  s1401_s9basis1(kk2,kn2,sknot2,kdim,4,4,sknot0,4,4,sknot0,ssurf3,\n\t  &ssurf4,&kstat);\n  if (kstat < 0) goto error;\n\n  s1401_s9basis2(kk1,kn1,sknot1,kdim,kk2,kn2,sknot2,4,4,sknot0,ssurf4,\n\t  &ssurf3new,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Compute the coefficients of Gordons patch.  */\n\n  for (ki=0; ki<kn1*kn2*kdim; ki++)\n    ssurf1new[ki] += ssurf2new[ki] - ssurf3new[ki];\n\n  /* Store Gordons patch.  */\n\n  if ((*rsurf = newSurf(kn2,kn1,kk2,kk1,sknot2,sknot1,ssurf1new,1,kdim,1)) == SISL_NULL)\n    goto err101;\n\n  /* Gordons patch defined.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation.  */\n\n  err101 :\n    *jstat = -101;\n  goto out;\n\n  /* Error in input. Dimension of curves not equal.  */\n\n  err102 :\n    *jstat = -102;\n  goto out;\n\n  /* Error in lower level function.  */\n\n  error :\n    *jstat = kstat;\n  goto out;\n\n  out :\n\n    /* Free space occupied by local arrays.  */\n\n    if (sder != SISL_NULL) freearray(sder);\n  if (smat != SISL_NULL) freearray(smat);\n  if (qc1[0] && qc1[0] != vcurve[0]) freeCurve(qc1[0]);\n  if (qc1[1] && qc1[1] != vcurve[4]) freeCurve(qc1[1]);\n  if (qc1[2] && qc1[2] != vcurve[1]) freeCurve(qc1[2]);\n  if (qc1[3] && qc1[3] != vcurve[5]) freeCurve(qc1[3]);\n  if (qc2[0] && qc2[0] != vcurve[6]) freeCurve(qc2[0]);\n  if (qc2[1] && qc2[1] != vcurve[2]) freeCurve(qc2[1]);\n  if (qc2[2] && qc2[2] != vcurve[7]) freeCurve(qc2[2]);\n  if (qc2[3] && qc2[3] != vcurve[3]) freeCurve(qc2[3]);\n  if (sknot1 != SISL_NULL) freearray(sknot1);\n  if (sknot2 != SISL_NULL) freearray(sknot2);\n  if (scoef1 != SISL_NULL) freearray(scoef1);\n  if (scoef2 != SISL_NULL) freearray(scoef2);\n  if (ssurf1 != SISL_NULL) freearray(ssurf1);\n  if (ssurf2 != SISL_NULL) freearray(ssurf2);\n  if (ssurf3 != SISL_NULL) freearray(ssurf3);\n  if (ssurf4 != SISL_NULL) freearray(ssurf4);\n  if (ssurf1new != SISL_NULL) freearray(ssurf1new);\n  if (ssurf2new != SISL_NULL) freearray(ssurf2new);\n  if (ssurf3new != SISL_NULL) freearray(ssurf3new);\n\n    return;\n}\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n   s1401_s9blend(double econd[],int icond,int idim,int *jstat)\n#else\nstatic void s1401_s9blend(econd,icond,idim,jstat)\n     int icond,idim,*jstat;\n     double econd[];\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Hermite interpolation of position and icond-3 derivatives\n*              in one endpoint and position and derivative in the other\n*              endpoint, represented as a Bezier curve on the interval [0,1].\n*\n*\n*\n* INPUT      : icond      - Number of interpolation conditions.\n*              idim       - Dimension of geometry space.\n*\n*\n* INPUT/OUTPUT : econd    - Interpolation conditions as input, Bezier coefficients\n*                           as output.\n*\n*\n* OUTPUT     : jstat      - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n*********************************************************************\n*/\n{\n  int ki;\n\n  if (icond != 4) goto err001;\n\n  for (ki=0; ki<idim; ki++)\n    {\n      econd[idim+ki] = ONE_THIRD*econd[idim+ki] + econd[ki];\n      econd[2*idim+ki] = ONE_THIRD*econd[2*idim+ki] + econd[3*idim+ki];\n    }\n\n  *jstat = 0;\n  goto out;\n\n  err001 :\n    *jstat = -1;\n  goto out;\n\n  out :\n    return;\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n   s1401_s9basis1(int ik1new,int in1new,double et1new[],\n\t\t       int idim,int ik1,int in1,double et1[],\n\t\t       int ik2,int in2,double et2[],double ecoef[],\n\t\t       double **gcoefnew,int *jstat)\n#else\nstatic void s1401_s9basis1(ik1new,in1new,et1new,idim,ik1,in1,et1,\n\t\t\t\t ik2,in2,et2,ecoef,gcoefnew,jstat)\n     int ik1new,in1new,idim,ik1,in1,ik2,in2,*jstat;\n     double et1new[],et1[],et2[],ecoef[],**gcoefnew;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Express a surface on an extended knot vector in the 1.\n*              parameter direction.\n*\n*\n*\n* INPUT      : ik1new     - New order in the 1. parameter direction.\n*              in1new     - New number of vertices in 1. parameter direction.\n*              et1new     - New knot vector in the 1. parameter direction.\n*              ik1        - Current order in 1. parameter direction.\n*              in1        - Current number of vertices in 1. parameter direction.\n*              et1        - Current knot vector in 1. parameter direction.\n*              ik2        - Order in 2. parameter direction.\n*              in2        - Number of vertices in 2. parameter direction.\n*              et2        - Knot vector in 2. parameter direction.\n*              ecoef      - Vertices of current surface.\n*              idim       - Dimension of geometry space.\n*\n*\n*\n* OUTPUT     : gcoefnew   - Vertices of the new surface.\n*              jstat      - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n*********************************************************************\n*/\n{\n\n  int kstat = 0;\n  int kdim = idim*in2;\n  int knbcrv = 1;\n  int kkind = 1;\n  int kcopy = 1;\n  double tstart,tstop;\n  double *scoef = SISL_NULL;\n  double *scoef2 = SISL_NULL;\n  SISLCurve *qc = SISL_NULL;\n\n  tstart = et1new[ik1new-1];\n  tstop = et1new[in1new];\n\n  /* Allocate scratch for coefficient arrays.  */\n\n  if ((scoef = newarray(in1*in2*idim,DOUBLE)) == SISL_NULL) goto err101;\n  if ((*gcoefnew = newarray(in1new*in2*idim,DOUBLE)) == SISL_NULL)\n     goto err101;\n\n  /* Change parameter directions of surface.  */\n\n  s6chpar(ecoef,in1,in2,idim,scoef);\n\n  /* Express the surface with interchanged parameter directions\n     as a curve.  */\n\n  if ((qc = newCurve(in1,ik1,et1,scoef,kkind,kdim,kcopy)) == SISL_NULL) goto err101;\n\n  /* Express the surface interpreted as a curve on the extended\n     knot vector.  */\n\n  s1932(knbcrv,&qc,tstart,tstop,et1new,in1new,ik1new,&scoef2,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Change parameter directions of output surface. */\n\n  s6chpar(scoef2,in2,in1new,idim,*gcoefnew);\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation.  */\n\n  err101 :\n    *jstat = -101;\n  goto out;\n\n  /* Error in lower level function.  */\n\n  error :\n    *jstat = kstat;\n  goto out;\n\n  out :\n     /* Free scratch.  */\n\n    if (scoef != SISL_NULL) freearray(scoef);\n    if (scoef2 != SISL_NULL) freearray(scoef2);\n    if (qc != SISL_NULL) freeCurve(qc);\n\n    return;\n}\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n   s1401_s9basis2(int ik2new,int in2new,double et2new[],\n\t\t       int idim,int ik1,int in1,double et1[],\n\t\t       int ik2,int in2,double et2[],double ecoef[],\n\t\t       double **gcoefnew,int *jstat)\n#else\nstatic void s1401_s9basis2(ik2new,in2new,et2new,idim,ik1,in1,et1,\n\t\t\t\t ik2,in2,et2,ecoef,gcoefnew,jstat)\n     int ik2new,in2new,idim,ik1,in1,ik2,in2,*jstat;\n     double et2new[],et1[],et2[],ecoef[],**gcoefnew;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Express a surface on an extended knot vector in the 2.\n*              parameter direction.\n*\n*\n*\n* INPUT      : ik2new     - New order in the 2. parameter direction.\n*              in2new     - New number of vertices in 2. parameter direction.\n*              et2new     - New knot vector in the 2. parameter direction.\n*              ik1        - Order in 1. parameter direction.\n*              in1        - Number of vertices in 1. parameter direction.\n*              et1        - Knot vector in 1. parameter direction.\n*              ik2        - Current order in 2. parameter direction.\n*              in2        - Current number of vertices in 2. parameter direction.\n*              et2        - Current knot vector in 2. parameter direction.\n*              ecoef      - Vertices of current surface.\n*              idim       - Dimension of geometry space.\n*\n*\n*\n* OUTPUT     : gcoefnew   - Vertices of the new surface.\n*              jstat      - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* CALLS     : s1932, newCurve\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\n  int kdim = idim*in1;\n  int knbcrv = 1;\n  int kkind = 1;\n  int kcopy = 1;\n  double tstart,tstop;\n  SISLCurve *qc = SISL_NULL;\n\n  tstart = et2new[ik2new-1];\n  tstop = et2new[in2new];\n\n  /* Express the surface as a curve.  */\n\n  if ((qc = newCurve(in2,ik2,et2,ecoef,kkind,kdim,kcopy)) == SISL_NULL) goto err101;\n\n  /* Express the surface interpreted as a curve on the extended\n     knot vector.  */\n\n  s1932(knbcrv,&qc,tstart,tstop,et2new,in2new,ik2new,gcoefnew,&kstat);\n  if (kstat < 0) goto error;\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation.  */\n\n  err101 :\n    *jstat = -101;\n  goto out;\n\n  /* Error in lower level function.  */\n\n  error :\n    *jstat = kstat;\n  goto out;\n\n  out :\n\n     /* Free scratch.  */\n\n     if (qc != SISL_NULL) freeCurve(qc);\n\n    return;\n}\n"
  },
  {
    "path": "src/s1421.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1421.c,v 1.5 2001-03-19 15:58:49 afr Exp $\n *\n */\n#define S1421\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1421(SISLSurf *ps1,int ider,double epar[],int *ilfs,int *ilft,\n\t   double eder[],double enorm[],int *jstat)\n#else\nvoid s1421(ps1,ider,epar,ilfs,ilft,eder,enorm,jstat)\n     SISLSurf   *ps1;\n     int    ider;\n     double epar[];\n     int    *ilfs;\n     int    *ilft;\n     double eder[];\n     double enorm[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Evaluate the surface pointed at by ps1 at the parameter\n*              value epar. Compute ider derivatives.\n*\n*\n*\n* INPUT      : ps1    - Pointer to the surface to evaluate.\n*              ider   - Number of derivatives to calculate.\n*                       < 0 : No derivative calculated.    \n*                       = 0 : Position calculated.\n*                       = 1 : Position and first derivative calculated.\n*                       etc.\n*              epar   - Parameter-value at which to calculate. Dimension\n*                       of epar is 2.\n*\n*                \n*\n* INPUT/OUTPUT : ilfs  - Pointer to the interval in the knotvector\n*                        in first parameter direction where epar[0] \n*                        is found. The relation\n*                          \n*                          et1[ilfs] <= epar[0] < et1[ilfs+1]\n* \n*                        where et1 is the knotvektor should hold.\n*                        ilfs is set equal to zero at the first call\n*                        to the routine. \n*                ilft  - Corresponding to ilfs in the second parameter\n*                        direction.\n*             \n*\n*\n*\n* OUTPUT     : eder   - Array where the derivative of the curve in\n*                       apar is placed. The sequence is position,\n*                       first derivative in first parameter direction,\n*                       first derivative in second parameter direction,\n*                       (2,0) derivative, (1,1) derivative, (0,2) \n*                       derivative, etc. Dimension of eder is \n*                       idim*(1+2+...+(ider+1)).\n*              enorm  - Normal of surface. Is calculated if ider >= 1.\n*                       Dimension is idim. The normal is not normalized.\n*              jstat  - status messages  \n*                                         = 2      : Surface is degenerate\n*                                                    at the point, normal\n*                                                    has zero length\n*                                         = 1      : Surface is close to\n*                                                    degenerate at the point\n*                                                    Angle between tangents,\n*                                                    less than angular tolerance\n*                                         = 0      : ok\n*                                         < 0      : error\n*                      \n*\n* METHOD     : Suppose that the given surface is of the form\n*\n*                 s(u,v) = sum(i,j) c(i,j)*B(i,k1,t1)*B(j,k2,t2)\n*\n*              where c is the matrix of B-spline coefficients (each c(i,j)\n*              is a vector with idim components),\n*              B(i,k1,t1) the B-splines accociated with the knot vector t1,\n*              and B(j,k2,t2) the B-splines accociated with the knot vector t2.\n*              This may be expressed in matrix form as\n*\n*                           s(u,v) = tran(B2(v)) * C * B1(u),     (1)\n*\n*              where\n*\n*                tran(B1(u))=(B(1,k1,t1)(u),B(2,k1,t1)(u),...,B(n1,k1,t1(u)))\n*\n*              is the vector of B-spline values at u, and tran(a) denotes\n*              the transpose of the vector a.\n*              It is known that for a given value of u, there are at most\n*              k1 (the order of the splines associated with t1) nonzero\n*              B-splines. If ilfs has the correct value, these B-splines\n*              will be\n*\n*              B(ilfs-k1+1,k1),B(ilfs+k1+2,k1),...,B(ilfs,k1),\n*\n*              and similarly in the second parameter direction.\n*              This means that in Equation 1 above the matrix C can be\n*              reduced to a k2xk1 matrix and the vectors of B-spline values,\n*              B1(u) and B2(v), can be reduced to vectors of length\n*              k1 and k2 respectively.\n*\n*              This notation is also valid for derivatives. The D(i,j)\n*              derivative of S is given by\n*\n*                    D(i,j)S(u,v) = tran(D(j)B2(v) * C * D(i)B1(u),\n*\n*              where D(i)B1(u) denotes the vector of the i'th derivatives\n*              of the B-splines accociated with t1, at the point u\n*              and similarly in the second parameter direction.\n*              Therefore, if in (1) the vector B1(u) is replaced with\n*              the matrix DB1 with D(i)B1(u) as the i+1'st column\n*              for i=0,1,...ider, and similarly for B2(v),\n*              then all the required derivatives DS(u,v) are given by\n*              the matrix product\n*\n*                        DS(u,v) = tran(DB2) * C * DB1.    (2)\n*\n*              Here DS(u,v) is an iderxider matrix. This is the basis\n*              for the algorithm: First the matrix DB2 is computed,\n*              then tran(DB2) is multiplied with C and the result stored\n*              in the local array ew.\n*              Finally DB1 is computed\n*              and multiplied with ew and the result stored in eder.\n*                               --- Knut Moerken.\n*\n*              Note that only the elements of DS in the TOP LEFT\n*              HAND TRIANGLE are computed. This saves time and\n*              space, c.f. s1424   --- Michael Floater.\n*\n*\n* CALLS      : s1220 - Computes B-spline values and derivatives at\n*                      a given point.\n*              s1219 - Determines ilfs.\n*              s6err    - Error handling routine \n*              s6strider - Make derivative of rational expression\n*\n*\n* WRITTEN BY : Michael Floater, SI, 1.9.92. The old version of\n*              s1421 called s1424 which wasted (a little) time\n*              and space. For example, if ider=2, the derivatives\n*              puuv, puvv, and puuvv were calculated (in s1424)\n*              and then discarded.\n*                 This new version is itself a version of s1424 but\n*              calculates no unnecessary derivatives.\n*              After testing with clock() this new version of s1421\n*              appears to be on average about 10% faster for B-splines\n*              and 20% faster for NURBS.\n*              Note that for NURBS we call s6strider, a triangular\n*              version of s6sratder.\n* Revised by : Christophe Rene Birkeland, SINTEF Oslo, May 1993.\n*              SISL_NULL tests included\n* Revised by : Johannes Kaasa, SINTEF Oslo, Nov. 1995,\n*              Made local copies of leftknot.\n*\n*********************************************************************\n*/                                     \n{\n  int kstat=0;        /* Local status variable.                          */\n  int kpos=0;         /* The position of error.                          */\n  int kn1,kn2;        /* The number of B-splines accociated with the knot\n\t\t\t vectors st1 and st2.                            */\n  int kk1,kk2;        /* The polynomial order of the surface in the two\n\t\t\t directions.                                     */\n  int kdim;           /* The dimension of the space in which the surface\n\t\t\t lies. Equivalently, the number of components\n\t\t\t of each B-spline coefficient.                   */\n  int kleft2,kleft1;  /* Local versions of ilfs and ilft which are\n\t\t\t used in order to avoid the pointers.            */\n  int ki,kj,kih,kjh;  /* Control variables in for loops and for stepping\n\t\t\t through arrays.                                 */\n  int kh,kl,kl1,kl2;  /* Control variables in for loops and for stepping\n\t\t\t through arrays.                                 */\n  double *st1,*st2;   /* The knot vectors of the surface. These have\n\t\t\t length [kn1+kk1] and [kn2+kk2],\n\t\t\t respectively.                                   */\n  double *scoef;      /* The B-spline coefficients of the surface.\n\t\t\t This is an array of dimension [kn2*kn1*kdim].   */\n  double tt;          /* Dummy variable used for holding an array element\n\t\t\t in a for loop.                                  */\n  double *ebder=SISL_NULL; /* Pointer to an array of dimension\n\t\t\t [max(kk1*(ider+1),kk2*(ider+1))] which will\n\t\t\t contain the values and ider first derivatives of\n\t\t\t the kk1 (kk2) nonzero B-splines at epar[0] (epar[1]).\n\t\t\t These are stored in the following order:\n\t\t\t First the value, 1. derivative etc. of the\n\t\t\t first nonzero B-spline, then the same for the\n\t\t\t second nonzero B-spline and so on.              */\n  \n  double *ew=SISL_NULL;    /* Pointer to an array of dimension [kk1*(ider+1)*kdim]\n\t\t\t which will be used to store the result of the first\n\t\t\t matrix multiplication in (2) above. This array is\n\t\t\t initialized to all zeros.                       */\n  double *sder=SISL_NULL;  /* Pointer to array used for storage of points, if\n\t\t\t non rational sder points to eder, if rational sder\n\t\t\t has to be allocated to make room for the homogenous\n\t\t\t coordinate */\n  \n  double sdum1[49];   /* Arraye used for ebder */\n  double sdum2[147];  /* Array used for ew */\n  int knumb1;         /* Necessary size of ebder */   \n  int knumb2;         /* Necessary size of ew */   \n\n  int tot,temp;       /* Temporary variables. */\n  int kinc;           /* For controlling kih.                */\n  \n  kleft1 = *ilfs;\n  kleft2 = *ilft;\n  \n  /* Copy surface to local parameters.  */\n  \n  kn1 = ps1 -> in1;\n  kn2 = ps1 -> in2;                                         \n  kk1 = ps1 -> ik1;\n  kk2 = ps1 -> ik2;\n  st1 = ps1 -> et1;\n  st2 = ps1 -> et2;\n  kdim = ps1 -> idim;\n  if (ps1->ikind == 2 || ps1->ikind == 4)\n    {\n      scoef = ps1 -> rcoef;\n      kdim +=1;\n      if((sder=newarray(kdim*(ider+1)*(ider+2)/2,DOUBLE)) == SISL_NULL)\n         goto err101;\n    }\n  else\n    {\n      scoef = ps1 -> ecoef;\n      sder = eder;  \n    }\n  \n  /* Check the input. */\n  \n  if (kdim < 1) goto err102;\n  if (kk1 < 1) goto err115;\n  if (kn1 < kk1 || kn2 < kk2) goto err116;\n  if (ider < 0) goto err178;\n  if (st1[kk1-1] == st1[kk1] || st1[kn1-1] == st1[kn1]) goto err117;\n  if (st2[kk2-1] == st2[kk2] || st2[kn2-1] == st2[kn2]) goto err117;  \n  \n  /* Allocate space for B-spline values and derivatives and one work array. */\n  \n  knumb1 = max(kk1*(ider+1),kk2*(ider+1));\n  \n  /* ONly allocate ebder if sdum1 too small */\n  \n  if (knumb1>49)\n    { \n      if((ebder = newarray(knumb1,double)) == SISL_NULL) goto err101;\n    }\n  else\n    {\n      ebder = &sdum1[0];\n      for (ki=0;ki<knumb1;ki++)\n\tebder[ki] = DZERO;\n    }\n  \n  if (ebder == SISL_NULL) goto err101;\n  \n  /* Only allocate ew if sdum2 too small */\n  \n  knumb2 = (kk1*(ider+1)*kdim);\n  if (knumb2>147)\n    {\n      if((ew=new0array(knumb2,double)) == SISL_NULL) goto err101;\n    }\n  else\n    { \n      ew = &sdum2[0];\n      for (ki=0;ki<knumb2;ki++)\n\tsdum2[ki] = DZERO;\n    }\n  \n  if (ew == SISL_NULL) goto err101;\n  \n  /* Set all the elements of sder to 0. */\n  \n  for (ki=0; ki<kdim*(ider+1)*(ider+2)/2; ki++) sder[ki] = DZERO;\n  \n  /* Compute the values and derivatives of the nonzero B-splines in the\n     second parameter direction.                                        */\n  \n  s1220(st2,kk2,kn2,&kleft2,epar[1],ider,ebder,&kstat);\n  \n  if (kstat < 0) goto error;\n  \n  /* Update ilfs (ilft was updated above, in s1220). */\n  \n  s1219(st1,kk1,kn1,&kleft1,epar[0],&kstat);\n  \n  if (kstat < 0) goto error;\n  \n  /* Compute the first matrix product in (2) above. */\n  \n  /* ki steps through the appropriate kk2 rows of B-spline coefficients\n     while kih steps through the B-spline value and derivatives for the\n     B-spline given by ki.                                              */\n  \n  kih = 0;\n  for (ki=kleft2-kk2+1; ki<=kleft2; ki++)\n    {      \n      /* kj counts through the ider+1 derivatives to be computed.\n\t kjh steps through ew once for each ki to accumulate the contribution\n\t from the different B-splines.\n\t kl1 points to the first component of the first B-spline coefficient\n\t in row no. ki of the B-spline coefficient matrix that multiplies\n\t a nonzero B-spline in the first parameter direction.\n\t */\n      \n      kjh = 0; kl1 = ki*kdim*kn1 + kdim*(kleft1-kk1+1);\n      for (kj=0; kj<=ider; kj++)\n\t{\n\t  \n\t  /* The value of the B-spline derivative is stored in tt while\n\t     kl2 steps through the kdim components of all the B-spline\n\t     coefficients that multiplies nonzero B-splines along st1. \n\t     */\n\t  \n\t  tt = ebder[kih++]; kl2 = kl1;\n\t  for (kl=0; kl<kdim*kk1; kl++,kjh++,kl2++)\n\t    {\n\t      ew[kjh] += scoef[kl2]*tt;\n\t    }\n\t}\n    }\n  \n  /* Compute the values and derivatives of the nonzero B-splines in the\n     first parameter direction.                                        */\n  \n  s1220(st1,kk1,kn1,&kleft1,epar[0],ider,ebder,&kstat);         \n  \n  if (kstat < 0) goto error;\n  \n  /* Compute the remaining matrix product. */\n  \n  /* kh steps through the ider+1 derivatives in the first parameter direction\n     (the rows of ew if we image it as a kk1x(ider+1) matrix with each element\n     a kdim dimensional vector) while kl1 steps through the elements of ew\n     (again considering each element to have kdim components).                   \n     */\n  \n  kl1 = 0;\n  for (kh=0; kh<=ider; kh++)\n    {      \n      /* ki steps through the kk1 columns of ew (corresponding to the columns\n\t of scoef that multiply nonzero B-splines along st1), while kih\n\t steps through the B-spline values and derivatives for the nonzero\n\t B-splines along st1 (stored in ebder).\n\t */\n\n      kinc = 0;\n      for (ki=0; ki<kk1; ki++,kinc+=(ider+1))\n\t{\n\t  \n\t  kih = kinc;\n\n\t  /* kj counts through the ider+1 derivatives in the first\n\t     parameter direction (corresponding to the columns of sder).\n\t     kjh points to the row of sder corresponding to derivatives of\n\t     order kh in the second parameter direction (if sder is\n\t     considered a matrix with elements consisting of vectors with\n\t     kdim components).\n\t     */\n\t  \n\t  for (kj=0; kj<=ider-kh; kj++)\n\t    {\n\t      /* Find index for sder (a triangular matrix). */\n\n              tot = kj + kh;\n\n\t      temp = ((tot * (tot+1)) >> 1) + kh;\n\n\t      kjh = temp * kdim;\n\n\t      /* Pick out the current element of ebder.\n\t\t kl2 steps through the kdim components of the (kh,ki)\n\t\t element of ew.\n\t\t */\n\t      \n\t      tt = ebder[kih++];\n\t      kl2 = kl1;\n\t      for (kl=0; kl<kdim; kl++,kjh++,kl2++)\n\t\t{\n\t\t  sder[kjh] += ew[kl2]*tt;\n\t\t}\n\t    }\n\t  kl1 += kdim;\n\t}\n    }\n  \n  /* Free memory. */\n  \n  /* If rational surface calculate the derivatives based on derivatives in\n     homogenous coordinates */\n  \n  if (ps1->ikind == 2 || ps1->ikind == 4)\n    {\n      s6strider(sder,ps1->idim,ider,eder,&kstat);\n      if (kstat<0) goto error;\n      if(sder != SISL_NULL) freearray(sder);\n    }\n  \n  /* Only free ew and ebder if the were allocated by newarray */\n  \n  if (knumb1 > 49 && ebder != SISL_NULL)\n     freearray(ebder);\n  if (knumb2 > 147 && ew != SISL_NULL)\n     freearray(ew);\n  \n  /* Make cross products of tangents, if idim==3 and derivative >0 */\n  \n  if (ider>0 && ps1->idim ==3)\n    {\n      double tlen1,tlen2,tnorm,tang=(double)0.0;\n      \n      s6crss(eder+ps1->idim,eder+2*ps1->idim,enorm);\n      \n      /*  Make length of tangents and normal */\n      \n      tlen1 = s6length(eder+ps1->idim,ps1->idim,&kstat);\n      tlen2 = s6length(eder+2*ps1->idim,ps1->idim,&kstat);\n      tnorm = s6length(enorm,ps1->idim,&kstat);\n      \n      /*  Calculate angle between tangents */\n      \n      if (tlen1 != DZERO && tlen2 != DZERO && tnorm != DZERO)\n        tang = tnorm/(tlen1*tlen2);\n      \n      if (tang == DZERO) *jstat = 2;\n      else if (tang <= ANGULAR_TOLERANCE) *jstat = 1;   \n      else *jstat = 0;\n      goto out;\n    }\n  \n  /* Successful computations.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Not enough memory. */\n err101: *jstat = -101;\n  s6err(\"s1421\",*jstat,kpos);\n  goto out;\n  \n  /* kdim less than 1. */\n err102: *jstat = -102;\n  s6err(\"s1421\",*jstat,kpos);\n  goto out;\n  \n  /* Polynomial order less than 1. */\n err115: *jstat = -115;\n  s6err(\"s1421\",*jstat,kpos);\n  goto out;\n  \n  /* Fewer B-splines than the order. */\n err116: *jstat = -116;\n  s6err(\"s1421\",*jstat,kpos);\n  goto out;\n  \n  /* Error in knot vector.\n     (The first or last interval of one of the knot vectors is empty.) */\n err117: *jstat = -117;\n  s6err(\"s1421\",*jstat,kpos);\n  goto out;\n  \n  /* Illegal derivative requested. */\n err178: *jstat = -178;\n  s6err(\"s1221\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n error:  *jstat = kstat;\n  s6err(\"s1421\",*jstat,kpos);\n  goto out;\n  \n out:\n    *ilfs = kleft1;\n    *ilft = kleft2;\n    return;\n}\n"
  },
  {
    "path": "src/s1422.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1422.c,v 1.2 2001-03-19 15:58:49 afr Exp $\n *\n */\n\n\n#define S1422\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   s1422(SISLSurf *ps1,int ider,int iside1,int iside2,double epar[],int *ilfs,\n       int *ilft,double eder[],double enorm[],int *jstat)\n#else\nvoid s1422(ps1,ider,iside1,iside2,epar,ilfs,ilft,eder,enorm,jstat)\n     SISLSurf   *ps1;\n     int    ider;\n     int    iside1;\n     int    iside2;\n     double epar[];\n     int    *ilfs;\n     int    *ilft;\n     double eder[];\n     double enorm[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Evaluate the surface pointed at by ps1 at the parameter\n*              value epar. Compute ider derivatives from the right hand\n*\t       or the left hand sides.\n*\n*\n*\n* INPUT      : ps1    - Pointer to the surface to evaluate.\n*              ider   - Number of derivatives to calculate.\n*                       < 0 : No derivative calculated.    \n*                       = 0 : Position calculated.\n*                       = 1 : Position and first derivative calculated.\n*                       etc.\n*\t       iside1 - Indicator telling if the derivatives in the first\n*\t\t\tparameter direction is to be calculated from the\n*\t\t\tleft or from the right:\n*\t\t\t <  0 calculate derivative from the left hand side\n*\t\t\t >= 0 calculate derivative from the right hand side.\n*\t       iside2 - Indicator telling if the derivatives in the second\n*\t\t\tparameter direction is to be calculated from the\n*\t\t\tleft or from the right:\n*\t\t\t <  0 calculate derivative from the left hand side\n*\t\t\t >= 0 calculate derivative from the right hand side.\n*              epar   - Parameter-value at which to calculate. Dimension\n*                       of epar is 2.\n*\n*                \n*\n* INPUT/OUTPUT : ilfs  - Pointer to the interval in the knotvector\n*                        in first parameter direction where epar[0] \n*                        is found. The relation\n*                          \n*                          et1[ilfs] <= epar[0] < et1[ilfs+1]\n* \n*                        where et1 is the knotvektor should hold.\n*                        ilfs is set equal to zero at the first call\n*                        to the routine. \n*                ilft  - Corresponding to ilfs in the second parameter\n*                        direction.\n*             \n*\n*\n*\n* OUTPUT     : eder   - Array where the derivative of the curve in\n*                       apar is placed. The sequence is position,\n*                       first derivative in first parameter direction,\n*                       first derivative in second parameter direction,\n*                       (2,0) derivative, (1,1) derivative, (0,2) \n*                       derivative, etc. Dimension of eder is \n*                       idim*(1+2+...+(ider+1)).\n*              enorm  - Normal of surface. Is calculated if ider >= 1.\n*                       Dimension is idim. The normal is not normalized.\n*              jstat  - status messages  \n*                                         = 2      : Surface is degenerate\n*                                                    at the point, normal\n*                                                    has zero length\n*                                         = 1      : Surface is close to\n*                                                    degenerate at the point\n*                                                    Angle between tangents,\n*                                                    less than angular tolerance\n*                                         = 0      : ok\n*                                         < 0      : error\n*                      \n*\n* METHOD     : \n*\n* REFERENCES :\n*\n*-\n* CALLS      : \n*\n* WRITTEN BY : \n*\n*********************************************************************\n*/                                     \n{\n  int kstat=0;        /* Local status variable.                          */\n  int kpos=0;         /* Position of error.                              */\n  int kdim;           /* Dimension of the space in which the surface lies. */\n  int keder;          /* Integer used in address calculations on eder    */\n  int ksp;            /* Integer used in address calculations on sp      */\n  int kincre;         /* Increment for address calculations              */\n  int ki,kl;          /* Control variables in for loop                   */\n  int knumb;          /* Number of elements used for storage of deriv.s  */\n  double *sp;         /* Pointer to temporary array                      */\n  double sdum[48];    /* Array used in stead of allocation               */\n  \n  \n  /* Allocate array for storage of ider*ider derivatives */\n  \n  sp = SISL_NULL;\n  kdim = ps1 -> idim;\n  knumb = kdim*(ider+1)*(ider+1);\n  \n  /* Only allocate space if sdum is too smaall */\n  \n  if (knumb>48)\n    sp = newarray(knumb,DOUBLE);\n  else\n    sp = &sdum[0];\n  \n  if (sp == SISL_NULL) goto err101;\n  \n  \n  /* Evaluate s1422surface.  */\n  \n  s1425(ps1,ider,ider,iside1,iside2,epar,ilfs,ilft,sp,&kstat);\n  \n  if (kstat < 0) goto error;\n  \n  /* Copy required derivatives into eder */\n  \n  kincre = kdim*ider;\n  \n  /*  Copy all derivatives of order 0, then of order 1, up to order ider */\n  \n  for (kl=0,keder=0;kl<=ider;kl++)\n    {\n      for (ki=0,ksp=kl*kdim ; ki<=kl ; ki++,ksp+=kincre,keder+=kdim)\n        {\n\t  memcopy(eder+keder,sp+ksp,kdim,DOUBLE);\n        }\n    }\n  \n  /* Make cross products of tangents, if idim==3 and derivative >0 */\n  \n  if (ider>0 && kdim ==3)\n    {\n      double tlen1,tlen2,tnorm,tang=(double)0.0;\n      \n      s6crss(eder+kdim,eder+2*kdim,enorm);\n      \n      /*  Make length of tangents and normal */\n      \n      tlen1 = s6length(eder+kdim,kdim,&kstat);\n      tlen2 = s6length(eder+2*kdim,kdim,&kstat);\n      tnorm = s6length(enorm,kdim,&kstat);\n      \n      /*  Calculate angle between tangents */\n      \n      if (tlen1 != DZERO && tlen2 != DZERO && tnorm != DZERO)\n        tang = tnorm/(tlen1*tlen2);\n      \n      if (tang == DZERO) *jstat = 2;\n      else if (tang <= ANGULAR_TOLERANCE) *jstat = 1;   \n      else *jstat = 0;\n      goto out;\n      \n    }\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"s1422\",*jstat,kpos);\n  goto out;\n  \n err101: *jstat = -101;\n  s6err(\"s1422\",*jstat,kpos);\n  \n  \n out:\n  \n  /* Free allocated space (Space only allocated if sdum is too small) */\n  \n  if (knumb>48)\n    if (sp != SISL_NULL) freearray(sp);\n  \n  return;\n}\n\n\n"
  },
  {
    "path": "src/s1424.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1424.c,v 1.3 2001-03-19 15:58:49 afr Exp $\n *\n */\n\n\n#define S1424\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1424(SISLSurf *ps1,int ider1,int ider2,double epar[],\n\t   int *ileft1,int *ileft2,double eder[],int *jstat)\n#else\nvoid s1424(ps1,ider1,ider2,epar,ileft1,ileft2,eder,jstat)\n     SISLSurf   *ps1;\n     int    ider1;\n     int    ider2;\n     double epar[];\n     int    *ileft1;\n     int    *ileft2;\n     double eder[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the value and ider1*ider2 first derivatives\n*              of the tensor product B-spline surface pointed to by\n*              ps1, at the point with parameter value (epar[0],epar[1]).\n*              The derivatives that will be computed are D(i,j),\n*              i=0,1,...,ider1, j=0,1,...,ider2.\n*\n*\n*\n* INPUT      : ps1    - Pointer to the surface for which position\n*                       and derivatives are to be computed.\n*              ider1  - The number of derivatives to be computed with respect\n*                       to the first parameter direction.\n*                       < 0 : Error.\n*                       = 0 : No derivatives with respect to the first\n*                             parameter direction will be computed.\n*                             (Only derivatives of the type D(0,0),D(0,1),\n*                             ...,D(0,ider2)).\n*                       = 1 : Derivatives up to first order with respect to\n*                             the first parameter direction will be computed.\n*                       etc.\n*              ider2  - The number of derivatives to be computed with respect\n*                       to the second parameter direction.\n*                       < 0 : Error.\n*                       = 0 : No derivatives with respect to the second\n*                             parameter direction will be computed.\n*                             (Only derivatives of the type D(0,0),D(1,0),\n*                             ...,D(ider1,0)).\n*                       = 1 : Derivatives up to first order with respect to\n*                             the second parameter direction will be computed.\n*                       etc.\n*              epar   - Double array of dimension [2] containing the\n*                       parameter values of the point at which the position\n*                       and derivatives are to be computed.\n*\n*\n*\n* INPUT/OUTPUT : ileft1 - Pointer to the interval in the knot vector\n*                        in the first parameter direction where epar[0] \n*                        is located. If et1 is the knot vector in the first\n*                        parameter direction, the relation\n*                          \n*                          et1[ileft] <= epar[0] < et1[ileft+1]\n* \n*                        should hold. (If epar[0] == et1[in1] then ileft should\n*                        be in1-1. Here in1 is the number of B-spline\n*                        coefficients associated with et1.)\n*                        If ileft1 does not have the right value upon\n*                        entry to the routine, its value will be changed\n*                        to the value satisfying the above condition.\n*               ileft2 - Pointer to the interval in the knot vector\n*                        in the second parameter direction where epar[1] \n*                        is located. If et2 is the knot vector in the second\n*                        parameter direction, the relation\n*                          \n*                          et2[ileft] <= epar[1] < et2[ileft+1]\n* \n*                        should hold. (If epar[1] == et2[in2] then ileft should\n*                        be in2-1. Here in2 is the number of B-spline\n*                        coefficients associated with et2.)\n*                        If ileft2 does not have the right value upon\n*                        entry to the routine, its value will be changed\n*                        to the value satisfying the above condition.\n*             \n*\n*\n*\n* OUTPUT     : eder   - Double array of dimension [(ider2+1)*(ider1+1)*idim]\n*                       containing the position and the derivative vectors\n*                       of the surface at the point with parameter value\n*                       (epar[0],epar[1]).\n*                       (idim is the number of components of each B-spline\n*                       coefficient, i.e. the dimension of the Euclidean\n*                       space in which the surface lies.)\n*                       These vectors are stored in the following order:\n*                       First the idim components of the position vector,\n*                       then the idim components of the D(1,0) vector,\n*                       and so on up to the idim components of the D(ider1,0)\n*                       vector,\n*                       then the idim components of the D(1,1) vector etc.\n*                       Equivalently, if eder is considered to be a\n*                       three dimensional array, then its declaration in C\n*                       would be eder[ider2+1,ider1+1,idim]\n*              jstat  - Status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                      \n*\n* METHOD     : Suppose that the given surface is of the form\n*\n*                 s(u,v) = sum(i,j) c(i,j)*B(i,k1,t1)*B(j,k2,t2)\n*\n*              where c is the matrix of B-spline coefficients (each c(i,j)\n*              is a vector with idim components),\n*              B(i,k1,t1) the B-splines accociated with the knot vector t1,\n*              and B(j,k2,t2) the B-splines accociated with the knot vector t2.\n*              This may be expressed in matrix form as\n*\n*                           s(u,v) = tran(B2(v)) * C * B1(u),     (1)\n*\n*              where\n*\n*                tran(B1(u))=(B(1,k1,t1)(u),B(2,k1,t1)(u),...,B(n1,k1,t1(u)))\n*\n*              is the vector of B-spline values at u, and tran(a) denotes\n*              the transpose of the vector a.\n*              It is known that for a given value of u, there are at most\n*              k1 (the order of the splines associated with t1) nonzero\n*              B-splines. If ileft1 has the correct value, these B-splines\n*              will be\n*\n*              B(ileft1-k1+1,k1),B(ileft1+k1+2,k1),...,B(ileft1,k1),\n*\n*              and similarly in the second parameter direction.\n*              This means that in Equation 1 above the matrix C can be\n*              reduced to a k2xk1 matrix and the vectors of B-spline values,\n*              B1(u) and B2(v), can be reduced to vectors of length\n*              k1 and k2 respectively.\n*\n*              This notation is also valid for derivatives. The D(i,j)\n*              derivative of S is given by\n*\n*                    D(i,j)S(u,v) = tran(D(j)B2(v) * C * D(i)B1(u),\n*\n*              where D(i)B1(u) denotes the vector of the i'th derivatives\n*              of the B-splines accociated with t1, at the point u\n*              and similarly in the second parameter direction.\n*              Therefore, if in (1) the vector B1(u) is replaced with\n*              the matrix DB1 with D(i)B1(u) as the i+1'st column\n*              for i=0,1,...ider1, and similarly for B2(v),\n*              then all the required derivatives DS(u,v) are given by\n*              the matrix product\n*\n*                        DS(u,v) = tran(DB2) * C * DB1.    (2)\n*\n*              Here DS(u,v) is an ider2xider1 matrix. This is the basis\n*              for the algorithm: First the matrix DB2 is computed,\n*              then tran(DB2) is multiplied with C and the result stored\n*              in the local array ew, and finally DB1 is computed\n*              and multiplied with DB1 and the result stored in eder.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1220 - Computes B-spline values and derivatives at\n*                      a given point.\n*              s1219 - Determines ileft1.\n*              s6err    - Error handling routine \n*              s6sratder - Make derivative of rational expression\n*\n* WRITTEN BY : Knut Moerken, University of Oslo, August 1988.\n* REVISED BY : Per Evensen, SI, Oslo, Norway, April 1989; Prepared for\n*              rational decription.\n* REVISED BY : Mike Floater, SI, Oslo, Norway, January 1991; ecoef becomes rcoef.\n* DEBUGGED BY : Mike Floater, SI, Oslo, Norway, April 1991;\n*               1. The freearray calls for ew and ebder were the wrong way round.\n*               2. The array sder was not being freed when rational.\n* REVISED BY : Johannes Kaasa, SI, Aug. 92 (Max. derivative only set to order\n*              for non-rational splines).\n* Revised by : Christophe Rene Birkeland, SINTEF Oslo, May 1993.\n*              SISL_NULL tests included\n* Revised by : Johannes Kaasa, SINTEF Oslo, Nov. 1995,\n*              Made local copies of leftknot.\n*\n*********************************************************************\n*/                                     \n{\n  int kstat=0;        /* Local status variable.                          */\n  int kpos=0;         /* The position of error.                          */\n  int kn1,kn2;        /* The number of B-splines accociated with the knot\n\t\t\t vectors st1 and st2.                            */\n  int kk1,kk2;        /* The polynomial order of the surface in the two\n\t\t\t directions.                                     */\n  int kdim;           /* The dimension of the space in which the surface\n\t\t\t lies. Equivalently, the number of components\n\t\t\t of each B-spline coefficient.                   */\n  int kder1,kder2;    /* Local versions of ider1 and ider2. Since\n\t\t\t derivatives of order higher than kk1-1 and kk2-1,\n\t\t\t respectively, are all zero, we set\n\t\t\t kder1=min(kk1-1,ider1) and kder2=(kk2-1,ider2). */\n  int kleft2,kleft1;  /* Local versions of ileft1 and ileft2 which are\n\t\t\t used in order to avoid the pointers.            */\n  int ki,kj,kih,kjh;  /* Control variables in for loops and for stepping\n\t\t\t through arrays.                                 */\n  int kh,kl,kl1,kl2;  /* Control variables in for loops and for stepping\n\t\t\t through arrays.                                 */\n  double *st1,*st2;   /* The knot vectors of the surface. These have\n\t\t\t length [kn1+kk1] and [kn2+kk2],\n\t\t\t respectively.                                   */\n  double *scoef;      /* The B-spline coefficients of the surface.\n\t\t\t This is an array of dimension [kn2*kn1*kdim].   */\n  double tt;          /* Dummy variable used for holding an array element\n\t\t\t in a for loop.                                  */\n  double *ebder=SISL_NULL; /* Pointer to an array of dimension\n\t\t\t [max(kk1*(ider1+1),kk2*(ider2+1))] which will\n\t\t\t contain the values and ider first derivatives of\n\t\t\t the kk1 (kk2) nonzero B-splines at epar[0] (epar[1]).\n\t\t\t These are stored in the following order:\n\t\t\t First the value, 1. derivative etc. of the\n\t\t\t first nonzero B-spline, then the same for the\n\t\t\t second nonzero B-spline and so on.              */\n  \n  double *ew=SISL_NULL;    /* Pointer to an array of dimension [kk1*(ider1+1)*kdim]\n\t\t\t which will be used to store the result of the first\n\t\t\t matrix multiplication in (2) above. This array is\n\t\t\t initialized to all zeros.                       */\n  double *sder=SISL_NULL;  /* Pointer to array used for storage of points, if\n\t\t\t non rational sder points to eder, if rational sder\n\t\t\t has to be allocated to make room for the homogenous\n\t\t\t coordinate */\n  \n  double sdum1[49];   /* Arraye used for ebder */\n  double sdum2[147];  /* Array used for ew */\n  int knumb1;         /* Necessary size of ebder */   \n  int knumb2;         /* Necessary size of ew */   \n  \n  kleft1 = *ileft1;\n  kleft2 = *ileft2;\n  \n  /* Copy surface to local parameters.  */\n  \n  kn1 = ps1 -> in1;\n  kn2 = ps1 -> in2;                                         \n  kk1 = ps1 -> ik1;\n  kk2 = ps1 -> ik2;\n  st1 = ps1 -> et1;\n  st2 = ps1 -> et2;\n  kdim = ps1 -> idim;\n  if (ps1->ikind == 2 || ps1->ikind == 4)\n    {\n      scoef = ps1 -> rcoef;\n      kdim +=1;\n      if((sder = newarray(kdim*(ider1+1)*(ider2+1),DOUBLE)) == SISL_NULL)\n         goto err101;\n    }\n  else\n    {\n      scoef = ps1 -> ecoef;\n      sder = eder;  \n    }\n  \n  /* Check the input. */\n  \n  if (kdim < 1) goto err102;\n  if (kk1 < 1) goto err115;\n  if (kn1 < kk1 || kn2 < kk2) goto err116;\n  if (ider1 < 0 || ider2 < 0) goto err178;\n  if (st1[kk1-1] == st1[kk1] || st1[kn1-1] == st1[kn1]) goto err117;\n  if (st2[kk2-1] == st2[kk2] || st2[kn2-1] == st2[kn2]) goto err117;\n  if (ps1->ikind == 1 || ps1->ikind == 3)\n  {\n     kder1 = min(kk1-1,ider1);\n     kder2 = min(kk2-1,ider2);\n  }\n  else\n  {\n     kder1 = ider1;\n     kder2 = ider2;\n  }\n  \n  /* Allocate space for B-spline values and derivatives and one work array. */\n  \n  knumb1 = max(kk1*(kder1+1),kk2*(kder2+1));\n  \n  /* ONly allocate ebder if sdum1 too small */\n  \n  if (knumb1>49)\n    {\n      if((ebder = newarray(knumb1,double)) == SISL_NULL) goto err101;\n    }\n  else\n    {\n      ebder = &sdum1[0];\n      for (ki=0;ki<knumb1;ki++)\n\tebder[ki] = DZERO;\n    }\n  \n  if (ebder == SISL_NULL) goto err101;\n  \n  /* Only allocate ew if sdum2 too small */\n  \n  knumb2 = (kk1*(kder2+1)*kdim);\n  if (knumb2>147)\n    {\n      if((ew = new0array(knumb2,double)) == SISL_NULL) goto err101;\n    }\n  else\n    { \n      ew = &sdum2[0];\n      for (ki=0;ki<knumb2;ki++)\n\tsdum2[ki] = DZERO;\n    }\n  \n  if (ew == SISL_NULL) goto err101;\n  \n  /* Set all the elements of sder to 0. */\n  \n  for (ki=0; ki<(ider2+1)*(ider1+1)*kdim; ki++) sder[ki] = DZERO;\n  \n  /* Compute the values and derivatives of the nonzero B-splines in the\n     second parameter direction.                                        */\n  \n  s1220(st2,kk2,kn2,&kleft2,epar[1],kder2,ebder,&kstat);\n  \n  if (kstat < 0) goto error;\n  \n  /* Update ileft1 (ileft2 was updated above, in s1220). */\n  \n  s1219(st1,kk1,kn1,&kleft1,epar[0],&kstat);\n  \n  if (kstat < 0) goto error;\n  \n  /* Compute the first matrix product in (2) above. */\n  \n  /* ki steps through the appropriate kk2 rows of B-spline coefficients\n     while kih steps through the B-spline value and derivatives for the\n     B-spline given by ki.                                              */\n  \n  kih = 0;\n  for (ki=kleft2-kk2+1; ki<=kleft2; ki++)\n    {\n      \n      /* kj counts through the kder2+1 derivatives to be computed.\n\t kjh steps through ew once for each ki to accumulate the contribution\n\t from the different B-splines.\n\t kl1 points to the first component of the first B-spline coefficient\n\t in row no. ki of the B-spline coefficient matrix that multiplies\n\t a nonzero B-spline in the first parameter direction.\n\t */\n      \n      kjh = 0; kl1 = ki*kdim*kn1 + kdim*(kleft1-kk1+1);\n      for (kj=0; kj<=kder2; kj++)\n\t{\n\t  \n\t  /* The value of the B-spline derivative is stored in tt while\n\t     kl2 steps through the kdim components of all the B-spline\n\t     coefficients that multiplies nonzero B-splines along st1. \n\t     */\n\t  \n\t  tt = ebder[kih++]; kl2 = kl1;\n\t  for (kl=0; kl<kdim*kk1; kl++,kjh++,kl2++)\n\t    {\n\t      ew[kjh] += scoef[kl2]*tt;\n\t    }\n\t}\n    }\n  \n  /* Compute the values and derivatives of the nonzero B-splines in the\n     first parameter direction.                                        */\n  \n  s1220(st1,kk1,kn1,&kleft1,epar[0],kder1,ebder,&kstat);         \n  \n  if (kstat < 0) goto error;\n  \n  /* Compute the remaining matrix product. */\n  \n  /* kh steps through the kder2+1 derivatives in the first parameter direction\n     (the rows of ew if we image it as a kk1x(ider1+1) matrix with each element\n     a kdim dimensional vector) while kl1 steps through the elements of ew\n     (again considering each element to have kdim components).                   \n     */\n  \n  kl1 = 0;\n  for (kh=0; kh<=kder2; kh++)\n    {\n      \n      /* ki steps through the kk1 columns of ew (corresponding to the columns\n\t of scoef that multiply nonzero B-splines along st1), while kih\n\t steps through the B-spline values and derivatives for the nonzero\n\t B-splines along st1 (stored in ebder).\n\t */\n      \n      kih = 0;\n      for (ki=0; ki<kk1; ki++)\n\t{\n\t  \n\t  /* kj counts through the kder1+1 derivatives in the first\n\t     parameter direction (corresponding to the columns of sder).\n\t     kjh points to the row of sder corresponding to derivatives of\n\t     order kh in the second parameter direction (if sder is\n\t     considered a matrix with elements consisting of vectors with\n\t     kdim components.\n\t     */\n\t  \n\t  kjh = kh*(kder1+1)*kdim;\n\t  for (kj=0; kj<=kder1; kj++)\n\t    {\n\t      /* Pick out the current element of ebder.\n\t\t kl2 steps through the kdim components of the (kh,ki)\n\t\t element of ew.\n\t\t */\n\t      \n\t      tt = ebder[kih++];\n\t      kl2 = kl1;\n\t      for (kl=0; kl<kdim; kl++,kjh++,kl2++)\n\t\t{\n\t\t  sder[kjh] += ew[kl2]*tt;\n\t\t}\n\t    }\n\t  kl1 += kdim;\n\t}\n    }\n  \n  if (kder1 < ider1 || kder2 < ider2)\n    \n    /* The derivatives are not positioned in the right way in sder, \n       shift values into the right position \n       */\n    \n    for (kj=ider2 ; 0<=kj ; kj--)\n      {\n\tfor (ki=ider1 ; 0<=ki ; ki--)\n\t  {\n\t    if ( ki <= kder1 && kj <= kder2)\n\t      memmove(sder+kdim*(ki+kj*(ider1+1)),sder+kdim*(ki+kj*(kder1+1)),\n\t\t      kdim*sizeof(double));\n\t      /* memcopy(sder+kdim*(ki+kj*(ider1+1)),sder+kdim*(ki+kj*(kder1+1)), */\n\t      /* \t      kdim,DOUBLE); */\n\t    else\n\t      for (kl=0;kl<kdim;kl++)     \n\t\t*(sder+kdim*(ki+kj*(ider1+1))+kl) = DZERO;\n\t  }\n      }\n\n  /* Free memory. */\n  \n  /* If rational surface calculate the derivatives based on derivatives in\n     homogenous coordinates */\n  \n  if (ps1->ikind == 2 || ps1->ikind == 4)\n    {\n      s6sratder(sder,ps1->idim,ider1,ider2,eder,&kstat);\n      if (kstat<0) goto error;\n      if(sder != SISL_NULL) freearray(sder);\n    }\n  \n  /* Only free ew and ebder if the were allocated by newarray */\n  \n  if (knumb1 > 49 && ebder != SISL_NULL) freearray(ebder);\n  if (knumb2 > 147 && ew != SISL_NULL) freearray(ew);\n  \n  /* Successful computations.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Not enough memory. */\n\n  err101: \n    *jstat = -101;\n    s6err(\"s1424\",*jstat,kpos);\n    goto out;\n  \n  /* kdim less than 1. */\n\n  err102: \n    *jstat = -102;\n    s6err(\"s1424\",*jstat,kpos);  \n    goto out;\n  \n  /* Polynomial order less than 1. */\n\n  err115: \n    *jstat = -115;\n    s6err(\"s1424\",*jstat,kpos);\n    goto out;\n  \n  /* Fewer B-splines than the order. */\n\n  err116: \n    *jstat = -116;\n    s6err(\"s1424\",*jstat,kpos); \n    goto out;\n  \n  /* Error in knot vector.\n     (The first or last interval of one of the knot vectors is empty.) */\n\n  err117: \n    *jstat = -117;\n    s6err(\"s1424\",*jstat,kpos);\n    goto out;\n  \n  /* Illegal derivative requested. */\n\n  err178: \n    *jstat = -178;\n    s6err(\"s1424\",*jstat,kpos);\n    goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error:  \n    *jstat = kstat;\n    s6err(\"s1424\",*jstat,kpos); \n    goto out;\n  \n  out: \n    *ileft1 = kleft1;\n    *ileft2 = kleft2;\n    return;\n}\n"
  },
  {
    "path": "src/s1425.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1425.c,v 1.3 2001-03-19 15:58:49 afr Exp $\n *\n */\n\n\n#define S1425\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1425(SISLSurf *ps1,int ider1,int ider2,int iside1,int iside2,double epar[],\n\t   int *ileft1,int *ileft2,double eder[],int *jstat)\n#else\nvoid s1425(ps1,ider1,ider2,iside1,iside2,epar,ileft1,ileft2,eder,jstat)\n     SISLSurf   *ps1;\n     int    ider1;\n     int    ider2;\n     int    iside1;\n     int    iside2;\n     double epar[];\n     int    *ileft1;\n     int    *ileft2;\n     double eder[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the value and ider1*ider2 first derivatives\n*              of the tensor product B-spline surface pointed to by\n*              ps1, at the point with parameter value (epar[0],epar[1]).\n*              The derivatives that will be computed are D(i,j),\n*              i=0,1,...,ider1, j=0,1,...,ider2. the calculations are\n*\t       from the right hand or left hand sides.\n*\n*\n*\n* INPUT      : ps1    - Pointer to the surface for which position\n*                       and derivatives are to be computed.\n*              ider1  - The number of derivatives to be computed with respect\n*                       to the first parameter direction.\n*                       < 0 : Error.\n*                       = 0 : No derivatives with respect to the first\n*                             parameter direction will be computed.\n*                             (Only derivatives of the type D(0,0),D(0,1),\n*                             ...,D(0,ider2)).\n*                       = 1 : Derivatives up to first order with respect to\n*                             the first parameter direction will be computed.\n*                       etc.\n*              ider2  - The number of derivatives to be computed with respect\n*                       to the second parameter direction.\n*                       < 0 : Error.\n*                       = 0 : No derivatives with respect to the second\n*                             parameter direction will be computed.\n*                             (Only derivatives of the type D(0,0),D(1,0),\n*                             ...,D(ider1,0)).\n*                       = 1 : Derivatives up to first order with respect to\n*                             the second parameter direction will be computed.\n*                       etc.\n*\t       iside1 - Indicator telling if the derivatives in the first\n*\t\t\tparameter direction is to be calculated from the\n*\t\t\tleft or from the right:\n*\t\t\t <  0 calculate derivative from the left hand side\n*\t\t\t >= 0 calculate derivative from the right hand side.\n*\t       iside2 - Indicator telling if the derivatives in the second\n*\t\t\tparameter direction is to be calculated from the\n*\t\t\tleft or from the right:\n*\t\t\t <  0 calculate derivative from the left hand side\n*\t\t\t >= 0 calculate derivative from the right hand side.\n*              epar   - Double array of dimension [2] containing the\n*                       parameter values of the point at which the position\n*                       and derivatives are to be computed.\n*\n*\n*\n* INPUT/OUTPUT : ileft1 - Pointer to the interval in the knot vector\n*                        in the first parameter direction where epar[0] \n*                        is located. If et1 is the knot vector in the first\n*                        parameter direction, the relation\n*                          \n*                          et1[ileft] <= epar[0] < et1[ileft+1]\n* \n*                        should hold. (If epar[0] == et1[in1] then ileft should\n*                        be in1-1. Here in1 is the number of B-spline\n*                        coefficients associated with et1.)\n*                        If ileft1 does not have the right value upon\n*                        entry to the routine, its value will be changed\n*                        to the value satisfying the above condition.\n*               ileft2 - Pointer to the interval in the knot vector\n*                        in the second parameter direction where epar[1] \n*                        is located. If et2 is the knot vector in the second\n*                        parameter direction, the relation\n*                          \n*                          et2[ileft] <= epar[1] < et2[ileft+1]\n* \n*                        should hold. (If epar[1] == et2[in2] then ileft should\n*                        be in2-1. Here in2 is the number of B-spline\n*                        coefficients associated with et2.)\n*                        If ileft2 does not have the right value upon\n*                        entry to the routine, its value will be changed\n*                        to the value satisfying the above condition.\n*             \n*\n*\n*\n* OUTPUT     : eder   - Double array of dimension [(ider2+1)*(ider1+1)*idim]\n*                       containing the position and the derivative vectors\n*                       of the surface at the point with parameter value\n*                       (epar[0],epar[1]).\n*                       (idim is the number of components of each B-spline\n*                       coefficient, i.e. the dimension of the Euclidean\n*                       space in which the surface lies.)\n*                       These vectors are stored in the following order:\n*                       First the idim components of the position vector,\n*                       then the idim components of the D(1,0) vector,\n*                       and so on up to the idim components of the D(ider1,0)\n*                       vector,\n*                       then the idim components of the D(1,1) vector etc.\n*                       Equivalently, if eder is considered to be a\n*                       three dimensional array, then its declaration in C\n*                       would be eder[ider2+1,ider1+1,idim]\n*              jstat  - Status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                      \n*\n* METHOD     : Suppose that the given surface is of the form\n*\n*                 s(u,v) = sum(i,j) c(i,j)*B(i,k1,t1)*B(j,k2,t2)\n*\n*              where c is the matrix of B-spline coefficients (each c(i,j)\n*              is a vector with idim components),\n*              B(i,k1,t1) the B-splines accociated with the knot vector t1,\n*              and B(j,k2,t2) the B-splines accociated with the knot vector t2.\n*              This may be expressed in matrix form as\n*\n*                           s(u,v) = tran(B2(v)) * C * B1(u),     (1)\n*\n*              where\n*\n*                tran(B1(u))=(B(1,k1,t1)(u),B(2,k1,t1)(u),...,B(n1,k1,t1(u)))\n*\n*              is the vector of B-spline values at u, and tran(a) denotes\n*              the transpose of the vector a.\n*              It is known that for a given value of u, there are at most\n*              k1 (the order of the splines associated with t1) nonzero\n*              B-splines. If ileft1 has the correct value, these B-splines\n*              will be\n*\n*              B(ileft1-k1+1,k1),B(ileft1+k1+2,k1),...,B(ileft1,k1),\n*\n*              and similarly in the second parameter direction.\n*              This means that in Equation 1 above the matrix C can be\n*              reduced to a k2xk1 matrix and the vectors of B-spline values,\n*              B1(u) and B2(v), can be reduced to vectors of length\n*              k1 and k2 respectively.\n*\n*              This notation is also valid for derivatives. The D(i,j)\n*              derivative of S is given by\n*\n*                    D(i,j)S(u,v) = tran(D(j)B2(v) * C * D(i)B1(u),\n*\n*              where D(i)B1(u) denotes the vector of the i'th derivatives\n*              of the B-splines accociated with t1, at the point u\n*              and similarly in the second parameter direction.\n*              Therefore, if in (1) the vector B1(u) is replaced with\n*              the matrix DB1 with D(i)B1(u) as the i+1'st column\n*              for i=0,1,...ider1, and similarly for B2(v),\n*              then all the required derivatives DS(u,v) are given by\n*              the matrix product\n*\n*                        DS(u,v) = tran(DB2) * C * DB1.    (2)\n*\n*              Here DS(u,v) is an ider2xider1 matrix. This is the basis\n*              for the algorithm: First the matrix DB2 is computed,\n*              then tran(DB2) is multiplied with C and the result stored\n*              in the local array ew, and finally DB1 is computed\n*              and multiplied with DB1 and the result stored in eder.\n*\n*\t\tNote: \tThe curves are all treated as open curves. If to be\n*\t\t\tupdated for cycli curves, a local array spar should\n*\t\t\tbe introduced. spar should be equal to epar exept when:\n*\t\t\t1. cyclic curve, epar[0] == et1[ik1-1] and iside1<0\n*\t\t           then epar[0] should be set to et1[in1]\n*\t\t\t2. cyclic curve, epar[0] == et1[in1] and iside1>=0\n*\t\t           then epar[0] should be set to et1[ik1-1]\n*\t\t\t3. cyclic curve, epar[1] == et1[ik2-1] and iside1<0\n*\t\t           then epar[1] should be set to et1[in2]\n*\t\t\t4. cyclic curve, epar[1] == et1[in2] and iside1>=0\n*\t\t           then epar[1] should be set to et1[ik2-1]\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1220 - Computes B-spline values and derivatives at\n*                      a given point.\n*              s1219 - Determines ileft1.\n*              s6err    - Error handling routine \n*              s6sratder - Make derivative of rational expression\n*\n* WRITTEN BY : Knut Moerken, University of Oslo, August 1988.\n* REVISED BY : Per Evensen, SI, Oslo, Norway, April 1989; Prepared for\n*              rational decription.\n* REVISED BY : Mike Floater, SI, Oslo, Norway, January 1991; ecoef becomes rcoef.\n* DEBUGGED BY : Mike Floater, SI, Oslo, Norway, April 1991;\n*               1. The freearray calls for ew and ebder were the wrong way round.\n*               2. The array sder was not being freed when rational.\n* Revised by : Johannes Kaasa, SINTEF Oslo, Nov. 1995,\n*              Made local copies of leftknot.\n*\n*********************************************************************\n*/                                     \n{\n  int kstat=0;        /* Local status variable.                          */\n  int kpos=0;         /* The position of error.                          */\n  int kn1,kn2;        /* The number of B-splines accociated with the knot\n\t\t\t vectors st1 and st2.                            */\n  int kn;\t      /* Variable used for storing shorter version of knot\n\t\t\t vector used by left hand derivatives */\n  int kmult;\t      /* Multiplicity of knot */\n  int kk1,kk2;        /* The polynomial order of the surface in the two\n\t\t\t directions.                                     */\n  int kdim;           /* The dimension of the space in which the surface\n\t\t\t lies. Equivalently, the number of components\n\t\t\t of each B-spline coefficient.                   */\n  int kder1,kder2;    /* Local versions of ider1 and ider2. Since\n\t\t\t derivatives of order higher than kk1-1 and kk2-1,\n\t\t\t respectively, are all zero, we set\n\t\t\t kder1=min(kk1-1,ider1) and kder2=(kk2-1,ider2). */\n  int kleft2,kleft1;  /* Local versions of ileft1 and ileft2 which are\n\t\t\t used in order to avoid the pointers.            */\n  int ki,kj,kih,kjh;  /* Control variables in for loops and for stepping\n\t\t\t through arrays.                                 */\n  int kh,kl,kl1,kl2;  /* Control variables in for loops and for stepping\n\t\t\t through arrays.                                 */\n  double *st1,*st2;   /* The knot vectors of the surface. These have\n\t\t\t length [kn1+kk1] and [kn2+kk2],\n\t\t\t respectively.                                   */\n  double *scoef;      /* The B-spline coefficients of the surface.\n\t\t\t This is an array of dimension [kn2*kn1*kdim].   */\n  double tt;          /* Dummy variable used for holding an array element\n\t\t\t in a for loop.                                  */\n  double *ebder=SISL_NULL; /* Pointer to an array of dimension\n\t\t\t [max(kk1*(ider1+1),kk2*(ider2+1))] which will\n\t\t\t contain the values and ider first derivatives of\n\t\t\t the kk1 (kk2) nonzero B-splines at epar[0] (epar[1]).\n\t\t\t These are stored in the following order:\n\t\t\t First the value, 1. derivative etc. of the\n\t\t\t first nonzero B-spline, then the same for the\n\t\t\t second nonzero B-spline and so on.              */\n  \n  double *ew=SISL_NULL;    /* Pointer to an array of dimension [kk1*(ider1+1)*kdim]\n\t\t\t which will be used to store the result of the first\n\t\t\t matrix multiplication in (2) above. This array is\n\t\t\t initialized to all zeros.                       */\n  double *sder=SISL_NULL;  /* Pointer to array used for storage of points, if\n\t\t\t non rational sder points to eder, if rational sder\n\t\t\t has to be allocated to make room for the homogenous\n\t\t\t coordinate */\n  \n  double sdum1[49];   /* Arraye used for ebder */\n  double sdum2[147];  /* Array used for ew */\n  int knumb1;         /* Necessary size of ebder */   \n  int knumb2;         /* Necessary size of ew */   \n  \n  kleft2 = *ileft2;\n  kleft1 = *ileft1;\n  \n  /* Copy surface to local parameters.  */\n  \n  kn1 = ps1 -> in1;\n  kn2 = ps1 -> in2;                                         \n  kk1 = ps1 -> ik1;\n  kk2 = ps1 -> ik2;\n  st1 = ps1 -> et1;\n  st2 = ps1 -> et2;\n  kdim = ps1 -> idim;\n  if (ps1->ikind == 2 || ps1->ikind == 4)\n    {\n      scoef = ps1 -> rcoef;\n      kdim +=1;\n      if((sder=newarray(kdim*(ider1+1)*(ider2+1),DOUBLE)) == SISL_NULL)\n\tgoto err101;\n    }\n  else\n    {\n      scoef = ps1 -> ecoef;\n      sder = eder;  \n    }\n  \n  /* Check the input. */\n  \n  if (kdim < 1) goto err102;\n  \n  if (kk1 < 1) goto err115;\n  \n  if (kn1 < kk1 || kn2 < kk2) goto err116;\n  \n  if (ider1 < 0 || ider2 < 0) goto err178;\n  \n  if (st1[kk1-1] == st1[kk1] || st1[kn1-1] == st1[kn1]) goto err117;\n  \n  if (st2[kk2-1] == st2[kk2] || st2[kn2-1] == st2[kn2]) goto err117;\n  \n  kder1 = min(kk1-1,ider1);\n  kder2 = min(kk2-1,ider2);\n  \n  /* Allocate space for B-spline values and derivatives and one work array. */\n  \n  knumb1 = max(kk1*(kder1+1),kk2*(kder2+1));\n  \n  /* ONly allocate ebder if sdum1 too small */\n  \n  if (knumb1>49)\n  {\n    if((ebder=newarray(knumb1,double)) == SISL_NULL) goto err101;\n  }\n  else\n    {\n      ebder = &sdum1[0];\n      for (ki=0;ki<knumb1;ki++)\n\tebder[ki] = DZERO;\n    }\n  \n  if (ebder == SISL_NULL) goto err101;\n  \n  /* Only allocate ew if sdum2 too small */\n  \n  knumb2 = (kk1*(kder2+1)*kdim);\n  if (knumb2>147)\n  {\n    if((ew=new0array(knumb2,double)) == SISL_NULL) goto err101;\n  }\n  else\t\n    { \n      ew = &sdum2[0];\n      for (ki=0;ki<knumb2;ki++)\n\tsdum2[ki] = DZERO;\n    }\n  \n  if (ew == SISL_NULL) goto err101;\n  \n  /* Set all the elements of sder to 0. */\n  \n  for (ki=0; ki<(ider2+1)*(ider1+1)*kdim; ki++) sder[ki] = DZERO;\n  \n  /* If the left hand derivative at epar[1] is to be calculated, this can be\n     done by forgetting all polynomial segments starting in epar[1] or\n     right of epar[1], thus the position of epar[1] in the knot vector is to be\n     calculated */\n  \n  if (iside2<0)\n  {\n     /* Calculate last knot equal to or left of epar[1] */\n     \n     s1219(st2,kk2,kn2,&kleft2,epar[1],&kstat);\n     if (kstat < 0) goto error;\n\t\t    \n    \n     if (st2[kn2] == epar[1])\n\tkmult = 0;\n     else\n     {\n        kmult = s6knotmult(st2,kk2,kn2,&kleft2,epar[1],&kstat);\n        if (kstat < 0) goto error;\n     }\n     \n     kleft2 = MAX(kk2-1,kleft2 - kmult);\t\t    \n     kn = kleft2+1;\n  }\n  else\n     kn = kn2;\n  \n  /* Compute the values and derivatives of the nonzero B-splines in the\n     second parameter direction.                                        */\n  \n  s1220(st2,kk2,kn,&kleft2,epar[1],kder2,ebder,&kstat);\n  \n  if (kstat < 0) goto error;\n  \n  /* Update ileft1 (ileft2 was updated above, in s1220). */\n  \n  s1219(st1,kk1,kn1,&kleft1,epar[0],&kstat);\n  if (kstat < 0) goto error;\n    \n   /* If the left hand derivative at epar[0] is to be calculated, this can be\n     done by forgetting all polynomial segments starting in epar[0] or\n     right of epar[0], thus the position of epar[0] in the knot vector \n     is to be calculated */\n  \n  if (iside1<0)\n  {\n     /* ileft1 already calculated */\n     if (epar[0] == st1[kn1])\n\tkmult = 0;\n     else\n     {\n\t kmult = s6knotmult(st1,kk1,kn1,&kleft1,epar[0],&kstat);\n         if (kstat < 0) goto error;\n     }\n     \n     kleft1 = MAX(kk1-1,kleft1-kmult);\n     kn = kleft1 + 1;\n  }\n  else\n     kn = kn1;\n  \n  /* Compute the first matrix product in (2) above. */\n  \n  /* ki steps through the appropriate kk2 rows of B-spline coefficients\n     while kih steps through the B-spline value and derivatives for the\n     B-spline given by ki.                                              */\n  \n  kih = 0;\n  for (ki=kleft2-kk2+1; ki<=kleft2; ki++)\n    {\n      \n      /* kj counts through the kder2+1 derivatives to be computed.\n\t kjh steps through ew once for each ki to accumulate the contribution\n\t from the different B-splines.\n\t kl1 points to the first component of the first B-spline coefficient\n\t in row no. ki of the B-spline coefficient matrix that multiplies\n\t a nonzero B-spline in the first parameter direction.\n\t */\n      \n      kjh = 0; kl1 = ki*kdim*kn1 + kdim*(kleft1-kk1+1);\n      for (kj=0; kj<=kder2; kj++)\n\t{\n\t  \n\t  /* The value of the B-spline derivative is stored in tt while\n\t     kl2 steps through the kdim components of all the B-spline\n\t     coefficients that multiplies nonzero B-splines along st1. \n\t     */\n\t  \n\t  tt = ebder[kih++]; kl2 = kl1;\n\t  for (kl=0; kl<kdim*kk1; kl++,kjh++,kl2++)\n\t    {\n\t      ew[kjh] += scoef[kl2]*tt;\n\t    }\n\t}\n    }\n\n  \n  /* Compute the values and derivatives of the nonzero B-splines in the\n     first parameter direction.                                        */\n  \n  s1220(st1,kk1,kn,&kleft1,epar[0],kder1,ebder,&kstat);         \n  \n  if (kstat < 0) goto error;\n  \n  /* Compute the remaining matrix product. */\n  \n  /* kh steps through the kder2+1 derivatives in the first parameter direction\n     (the rows of ew if we image it as a kk1x(ider1+1) matrix with each element\n     a kdim dimensional vector) while kl1 steps through the elements of ew\n     (again considering each element to have kdim components).                   \n     */\n  \n  kl1 = 0;\n  for (kh=0; kh<=kder2; kh++)\n    {\n      \n      /* ki steps through the kk1 columns of ew (corresponding to the columns\n\t of scoef that multiply nonzero B-splines along st1), while kih\n\t steps through the B-spline values and derivatives for the nonzero\n\t B-splines along st1 (stored in ebder).\n\t */\n      \n      kih = 0;\n      for (ki=0; ki<kk1; ki++)\n\t{\n\t  \n\t  /* kj counts through the kder1+1 derivatives in the first\n\t     parameter direction (corresponding to the columns of sder).\n\t     kjh points to the row of sder corresponding to derivatives of\n\t     order kh in the second parameter direction (if sder is\n\t     considered a matrix with elements consisting of vectors with\n\t     kdim components.\n\t     */\n\t  \n\t  kjh = kh*(kder1+1)*kdim;\n\t  for (kj=0; kj<=kder1; kj++)\n\t    {\n\t      /* Pick out the current element of ebder.\n\t\t kl2 steps through the kdim components of the (kh,ki)\n\t\t element of ew.\n\t\t */\n\t      \n\t      tt = ebder[kih++];\n\t      kl2 = kl1;\n\t      for (kl=0; kl<kdim; kl++,kjh++,kl2++)\n\t\t{\n\t\t  sder[kjh] += ew[kl2]*tt;\n\t\t}\n\t    }\n\t  kl1 += kdim;\n\t}\n    }\n  \n  if (kder1 < ider1 || kder2 < ider2)\n    \n    /* The derivatives are not positioned in the right way in sder, \n       shift values into the right position \n       */\n    \n    for (kj=ider2 ; 0<=kj ; kj--)\n      {\n\tfor (ki=ider1 ; 0<=ki ; ki--)\n\t  {\n\t    if ( ki <= kder1 && kj <= kder2)\n\t      /* memcopy(sder+kdim*(ki+kj*(ider1+1)),sder+kdim*(ki+kj*(kder1+1)), */\n\t      /* \t      kdim,DOUBLE); */\n\t      memmove(sder+kdim*(ki+kj*(ider1+1)),sder+kdim*(ki+kj*(kder1+1)),\n\t\t      kdim*sizeof(double));\n\t    else\n\t      for (kl=0;kl<kdim;kl++)     \n\t\t*(sder+kdim*(ki+kj*(ider1+1))+kl) = DZERO;\n\t  }\n      }\n  /* Free memory. */\n  \n  /* If rational surface calculate the derivatives based on derivatives in\n     homogenous coordinates */\n  \n  if (ps1->ikind == 2 || ps1->ikind == 4)\n    {\n      s6sratder(sder,ps1->idim,ider1,ider2,eder,&kstat);\n      if (kstat<0) goto error;\n      if(sder != SISL_NULL) freearray(sder);\n    }\n  \n  /* Only free ew and ebder if the were allocated by newarray */\n  \n  if (knumb1 > 49)\n    {\n      if(ebder != SISL_NULL) freearray(ebder);\n    }\n  if (knumb2 > 147)\n    {\n      if(ew != SISL_NULL) freearray(ew);\n    }\n  \n  /* Successful computations.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Not enough memory. */\n err101: *jstat = -101;\n  s6err(\"s1425\",*jstat,kpos);\n  goto out;\n  \n  /* kdim less than 1. */\n err102: *jstat = -102;\n  s6err(\"s1425\",*jstat,kpos);\n  goto out;\n  \n  /* Polynomial order less than 1. */\n err115: *jstat = -115;\n  s6err(\"s1425\",*jstat,kpos);\n  goto out;\n  \n  /* Fewer B-splines than the order. */\n err116: *jstat = -116;\n  s6err(\"s1425\",*jstat,kpos);\n  goto out;\n  \n  /* Error in knot vector.\n     (The first or last interval of one of the knot vectors is empty.) */\n err117: *jstat = -117;\n  s6err(\"s1425\",*jstat,kpos);\n  goto out;\n  \n  /* Illegal derivative requested. */\n err178: *jstat = -178;\n  s6err(\"s1425\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n error:  *jstat = kstat;\n  s6err(\"s1425\",*jstat,kpos);\n  goto out;\n  \n out: \n   *ileft2 = kleft2;\n   *ileft1 = kleft1;\n   return;\n}\n\n"
  },
  {
    "path": "src/s1435.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1435.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1435\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1435(SISLSurf *ps1,int iedge,SISLCurve **rcedge,double *cpar,int *jstat)\n#else\nvoid s1435(ps1,iedge,rcedge,cpar,jstat)\n     SISLSurf   *ps1;\n     int    iedge;\n     SISLCurve  **rcedge;\n     double *cpar;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Pick given edge-curve of B-spline surface.\n*\n*\n*\n* INPUT      : ps1    - Pointer to surface.\n*              iedge  - Number of surface. See figure below.\n*\n*                           -----------------\n*                           !   iedge=2     !\n*                           !               !\n*                    iedge=3!               !iedge=1\n*                           !               !\n*                           !               !\n*                           !               !\n*                           -----------------\n*                               iedge=0\n*\n*\n*\n* OUTPUT     : rcedge - SISLEdge curve.\n*              cpar   - Parameter value of edge in constant direction.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1436 - Pick curve with constant second parameter.\n*              s1437 - Pick curve with constant first parameter.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-06.\n*\n*********************************************************************\n*/                                     \n{\n  int kstat = 0;        /* Local status parameter.                        */\n  int kpos = 0;         /* Position of error.                             */\n  double tstart1,tend1; /* Endpoints of parameter interval in first \n\t\t\t   direction.                                     */\n  double tstart2,tend2; /* Endpoints of parameter interval in second \n\t\t\t   direction.                                     */\n  double tpar;          /* Parameter value of curve in constant parameter\n\t\t\t   direction.                                     */\n  \n  /* Fetch endpoints of parameter intervals.  */\n  \n  tstart1 = *(ps1->et1 + ps1->ik1 - 1);\n  tend1 = *(ps1->et1 + ps1->in1);\n  tstart2 = *(ps1->et2 + ps1->ik2 - 1);\n  tend2 = *(ps1->et2 + ps1->in2);\n  \n  /* Find constant parameter of edge. */\n  \n  if (iedge == 0) tpar = tstart2;\n  else if (iedge == 1) tpar = tend1;\n  else if (iedge == 2) tpar = tend2;\n  else if (iedge == 3) tpar = tstart1;\n  \n  if (iedge == 0 || iedge == 2)\n    {\n      \n      /* Pick curve with constant second parameter.  */\n      \n      s1436(ps1,tpar,rcedge,&kstat);\n      if (kstat < 0) goto error;\n    }\n  else if (iedge == 1 || iedge == 3)\n    {\n      \n      /* Pick curve with constant first parameter.  */\n      \n      s1437(ps1,tpar,rcedge,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* SISLCurve picked.  */\n  \n  *cpar = tpar;\n  *jstat = 0;\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"s1435\",*jstat,kpos);\n  goto out;\n  \n out: return;\n}\n"
  },
  {
    "path": "src/s1436.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1436.c,v 1.2 2001-03-19 15:58:49 afr Exp $\n *\n */\n\n\n#define S1436\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1436(SISLSurf *ps1,double apar,SISLCurve **rcurve,int *jstat)\n#else\nvoid s1436(ps1,apar,rcurve,jstat)\n     SISLSurf   *ps1;\n     double apar;\n     SISLCurve  **rcurve;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make constant parameter curve in the surface. The \n*              constant parameter value used is apar and is in the \n*              second parameter direction.\n*\n*\n*\n* INPUT      : ps1    - Surface.\n*              apar   - Parameter value to use whe picking out constant\n*                       parameter curve in second parameter direction.\n*\n*\n*\n* OUTPUT     : rcurve - Constant parameter curve.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The surface is treated as a (ps1->idim*ps1->in1)-\n*              dimensional curve with ps1->in2 vertices. The value\n*              of this curve at apar is calculated. This value is\n*              then viewed as the vertices of a (ps1->idim)-dimensional\n*              curve. The curve with these vertices and the knot-vector\n*              ps1->in2 is the curve we are looking for.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1221     - Evaluate curve in given parameter value.\n*              newCurve  - Create and initialize new curve.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n* REWISED BY : Per Evensen,  SI, 89-3; Prepared for rational description.\n* REWISED BY : Per Evensen,  SI, 90-9; Corrected arguments in last call to newCurve.\n* MODIFIED BY : Mike Floater,  SI, 91-01; Use rcoef instead of ecoef if rational.\n*\n*********************************************************************\n*/                                     \n{\n  int kstat = 0;     /* Local status variable.                        */\n  int kpos = 0;      /* Position of error.                            */\n  int kder = 0;      /* Number of derivatives of curve to evalutate.  */\n  int kleft = 0;     /* Parameter used in evaluation of curve.        */\n  int kind = 0;      /* Kind of curve\n                         = 1 : Polynomial B-spline curve.\n                         = 2 : Rational B-spline curve.\n                         = 3 : Polynomial Bezier curve.\n                         = 4 : Rational Bezier curve.                 */\n  int kdim;\n  double *scoef;     /* Pointer to vertices.                          */\n  double *scurve = SISL_NULL; /* Vertices of constant parameter curve.     */\n  SISLCurve *qc = SISL_NULL;  /* Pointer to intermediate curve.         */\n\n  /* Prepare for rational description. */\n\n  kdim = ps1->idim;\n  kind = ps1->ikind;\n  if(ps1->ikind == 2 || ps1->ikind == 4)\n  {\n      scoef = ps1->rcoef;\n      kdim = kdim+1;\n  }\n  else\n  {\n      scoef = ps1->ecoef;\n  }\n\n  /* Create the curve describing the surface as a curve.  */\n  \n  if ((qc = newCurve(ps1->in2,ps1->ik2,ps1->et2,scoef,1,\n\t\t     ps1->in1*kdim,0)) == SISL_NULL) goto err101;\n  \n  /* Allocate space for value of curve.  */\n  \n  if ((scurve = newarray(ps1->in1*kdim,double)) == SISL_NULL) goto err101;\n  \n  /* Evaluate this curve at given parameter value.  */\n  \n  s1221(qc,kder,apar,&kleft,scurve,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Create constant parameter curve.  */\n  \n  *rcurve = newCurve(ps1->in1,ps1->ik1,ps1->et1,scurve,kind,ps1->idim,1);\n  if (*rcurve == SISL_NULL) goto err101;\n  \n  /* Set periodicity flag.      */\n\t\n  (*rcurve)->cuopen = ps1->cuopen_1;\n  \n  /* Curve picked.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1436\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"s1436\",*jstat,kpos);\n  goto out;\n  \n out: \n  \n  /* Free space occupied by local arrays.  */\n  \n  if (scurve != SISL_NULL) freearray(scurve);\n  if (qc != SISL_NULL) freeCurve(qc);\n  \n  return;\n}\n"
  },
  {
    "path": "src/s1437.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1437.c,v 1.2 2001-03-19 15:58:49 afr Exp $\n *\n */\n\n\n#define S1437\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1437(SISLSurf *ps1,double apar,SISLCurve **rcurve,int *jstat)\n#else\nvoid s1437(ps1,apar,rcurve,jstat)\n     SISLSurf   *ps1;\n     double apar;\n     SISLCurve  **rcurve;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make constant parameter curve in the surface. The \n*              constant parameter value used is apar and is in the \n*              first parameter direction.\n*\n*\n*\n* INPUT      : ps1    - Surface.\n*              apar   - Parameter value to use whe picking out constant\n*                       parameter curve in first parameter direction.\n*\n*\n*\n* OUTPUT     : rcurve - Constant parameter curve.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : First the parameter directions of the surface is \n*              interchanged. Then the surface is viewed as a\n*              (ps1->idim*ps1->in2)-dimensional curve with\n*              knot vector ps1->et1, and evaluated in apar.\n*              The result of the evalutation is when viewed as\n*              a curve with ps1->in2 vertices and knot vector\n*              ps1->et2, the curve we are looking for.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1221    - Evaluate curve in given parameter value.\n*              s6chpar  - Change parameter direction of vertices of\n*                         surface.\n*              newCurve - Create and initialize new curve.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n* REWISED BY : Per Evensen,  SI, 89-3; Prepared for rational description.\n* REWISED BY : Per Evensen,  SI, 90-9; Corrected arguments in last call to newCurve.\n*\n*********************************************************************\n*/                                     \n{\n  int kstat = 0;     /* Local status variable.                           */\n  int kpos = 0;      /* Position of error.                               */\n  int kind = 0;      /* Kind of curve\n                         = 1 : Polynomial B-spline curve.\n                         = 2 : Rational B-spline curve.\n                         = 3 : Polynomial Bezier curve.\n                         = 4 : Rational Bezier curve.                 */\n  int kdim;          /* Dimension of the space in which the surface lies.*/\n  int kder = 0;      /* Number of derivatives of curve to evaluate.      */\n  int kleft = 0;     /* Parameter used in evalutation of curve.          */\n  double *ecoef = SISL_NULL;  /* Pointer to vertices                          */\n  double *scoef = SISL_NULL;  /* Vertices of surface with changed parameter\n\t\t\t    directions.                                  */\n  double *scurve = SISL_NULL; /* Vertices of constant parameter curve.        */\n  SISLCurve *qc = SISL_NULL;  /* Intermediate curve.                       */\n  \n  /* Get dimension of space.  */\n  \n  kdim = ps1 -> idim;\n  kind = ps1->ikind;\n                       \n  /* Prepare for rational description. */\n\n  if(ps1->ikind == 2 || ps1->ikind == 4)\n  {\n      ecoef = ps1->rcoef;\n      kdim = kdim+1;\n  }\n  else\n  {\n      ecoef = ps1->ecoef;\n  }\n\n  \n  /* Allocate space for coefficients of constant parameter curve\n     and of surface with changed parameter direction.                */\n  \n  if ((scurve = newarray(kdim*ps1->in2,double)) == SISL_NULL) goto err101;\n  if ((scoef = newarray(kdim*ps1->in1*ps1->in2,double)) == SISL_NULL) goto err101;\n  \n  /* Change parameter directions of surface.  */\n  \n  s6chpar(ecoef,ps1->in1,ps1->in2,kdim,scoef);\n  \n  /* Create curve to evaluate.  */\n  \n  qc = newCurve(ps1->in1,ps1->ik1,ps1->et1,scoef,1,kdim*ps1->in2,0);\n  if (qc == SISL_NULL) goto err101;\n  \n  /* Evaluate this curve in given parameter value.  */\n  \n  s1221(qc,kder,apar,&kleft,scurve,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Create constant parameter curve.  */\n  \n  *rcurve = newCurve(ps1->in2,ps1->ik2,ps1->et2,scurve,kind,ps1->idim,1);\n  if (*rcurve == SISL_NULL) goto err101;\n  \n  /* Set periodicity flag.      */\n\t\t       \n  (*rcurve)->cuopen = ps1->cuopen_2;\t\t       \n  \n  /* Curve picked.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1437\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"s1437\",*jstat,kpos);\n  goto out;\n  \n out: \n  \n  /* Free space occupied by local arrays.  */\n  \n  if (scoef != SISL_NULL) freearray(scoef);\n  if (scurve != SISL_NULL) freearray(scurve);\n  if (qc != SISL_NULL) freeCurve(qc);\n  \n  return;\n}\n"
  },
  {
    "path": "src/s1438.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1438.c,v 1.3 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1438\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1438(SISLCurve  *pc,int iedge,SISLPoint **rpedge,double *cpar,int *jstat)\n#else\nvoid s1438(pc,iedge,rpedge,cpar,jstat)\n     SISLCurve  *pc;\n     int    iedge;\n     SISLPoint  **rpedge;\n     double *cpar;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Pick given edge-point of B-spline curve.\n*\n*\n*\n* INPUT      : pc     - Pointer to curve.\n*              iedge  - Number of point. See figure below.\n*\n*                           \n*                    iedge=0-----------------iedge=1\n*\n*\n*\n* OUTPUT     : rpedge - SISLEdge point.\n*              cpar   - Parameter value of edge.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 05.89.\n*\n*********************************************************************\n*/                                     \n{\n  int kpos = 0;         /* Position of error.                             */\n  \n  if (iedge == 0)\n    {\n      *cpar = pc->et[pc->ik - 1];\n      \n      if (((*rpedge) = newPoint(pc->ecoef,pc->idim,1)) == SISL_NULL)\n\tgoto err101;\n    }\n  else if (iedge == 1)\n    {\n      *cpar = pc->et[pc->in];\n      \n      if (((*rpedge)=newPoint(pc->ecoef+pc->idim*(pc->in-1),pc->idim,1))==SISL_NULL)\n\tgoto err101;\n    }\n  else goto err141;\n  \n  /* SISLPoint picked.  */\n  \n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1438\",*jstat,kpos);\n  goto out;\n  \n  /* Error in number of edges.  */\n  \n  err141 : *jstat = -141;\n  s6err(\"s1438\",*jstat,kpos);\n  goto out;\n  \n out: ;\n}\n"
  },
  {
    "path": "src/s1439.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1439.c,v 1.2 1994-12-05 15:46:49 pfu Exp $\n *\n */\n\n\n#define S1439\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1439(SISLSurf *ps1,double apar,int idirec,SISLCurve **rcurve,int *jstat)\n#else\nvoid s1439(ps1,apar,idirec,rcurve,jstat)\n     SISLSurf   *ps1;\n     double apar;\n     int idirec;\n     SISLCurve  **rcurve;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Pick a curve along a constant parameter line in a NURBS\n*              surface.\n*              The constant parameter value used is apar and is in the\n*              idirec parameter direction.\n*              This routine replaces s1436() and s1437().\n*\n*\n*\n* INPUT      : ps1    - Surface.\n*              apar   - Parameter value to use when picking out constant\n*                       parameter curve.\n*              idirec - Parameter direction in which to pick (must be 1 or 2)\n*\n*\n* OUTPUT     : rcurve - Constant parameter curve.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n* REFERENCES :\n*\n* CALLS      : s1436, s1437 - These two routines do the job, which\n*                             one is called depends on what parameter\n*                             direction to pick from.\n*\n* WRITTEN BY : Christophe Rene Birkelan, SINTEF Oslo, July 1993.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;      /* Position of error.                            */\n\n  if(idirec == 1)\n    {\n      s1437(ps1, apar, rcurve, jstat);\n      if(*jstat < 0) goto error;\n    }\n  else if(idirec == 2)\n    {\n      s1436(ps1, apar, rcurve, jstat);\n      if(*jstat < 0) goto error;\n    }\n  else\n    goto err115;\n\n  /* Success !  Curve picked */\n\n  goto out;\n\n\n  /* Error in input parameter idirec.  */\n\n  err115:\n    *jstat = -115;\n    s6err(\"s1439\",*jstat,kpos);\n    goto out;\n\n  /* Error in lower level routine.  */\n\n  error:\n    s6err(\"s1439\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}\n"
  },
  {
    "path": "src/s1440.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1440.c,v 1.3 2001-03-19 15:58:49 afr Exp $\n *\n */\n\n\n#define S1440\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1440(SISLSurf *ps1,SISLSurf **rs2,int *jstat)\n#else\nvoid s1440(ps1,rs2,jstat)\n     SISLSurf *ps1;\n     SISLSurf **rs2;\n     int  *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Interchange the two parameter directions used in the\n*              mathematical description of a surface and thereby\n*              change the direction of the normal vector of the surface.\n*\n*\n*\n* INPUT      : ps1    - Pointer to the original surface.\n*\n*\n*\n* OUTPUT     : rs2    - Pointer to the surface with interchanged\n*                       parameter directions.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6chpar  - Change parameter directions of the vertices\n*                         of the surface.\n*              newSurf  - Create new surface.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n* REVISED BY : Johannes Kaasa, SI, 91-09 (Introduced NURBS).\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov. 1994.  Added\n*              handling of 'cuopen' flags.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;          /* Position of error.                  */\n  double *ssurf = SISL_NULL;  /* Pointer to vertices of new surface. */\n  int kdim;              /* Local (rational) dimension.         */\n  double *vert;          /* Pointer to vertices.                */\n\n  /* Check for rational surface. */\n\n  if (ps1->ikind == 2 || ps1->ikind == 4)\n    {\n      kdim = ps1->idim + 1;\n      vert = ps1->rcoef;\n    }\n  else\n    {\n      kdim = ps1->idim;\n      vert = ps1->ecoef;\n    }\n\n  /* Allocate scratch for vertices of new surface.  */\n\n  ssurf = newarray(ps1->in1*ps1->in2*kdim,double);\n  if (ssurf == SISL_NULL) goto err101;\n\n  /* Change parameter directions of vertices.  */\n\n  s6chpar(vert,ps1->in1,ps1->in2,kdim,ssurf);\n\n  /* Create output surface.  */\n\n  *rs2 = SISL_NULL;\n  if ((*rs2 = newSurf(ps1->in2,ps1->in1,ps1->ik2,ps1->ik1,ps1->et2,\n\t\t      ps1->et1,ssurf,ps1->ikind,ps1->idim,1)) == SISL_NULL) goto err101;\n\n  /* Set periodicity flag */\n\n  (*rs2)->cuopen_1 = ps1->cuopen_2;\n  (*rs2)->cuopen_2 = ps1->cuopen_1;\n\n  /* Parameter directions changed.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;\n  s6err(\"s1440\",*jstat,kpos);\n  goto out;\n\n out:\n\n  /* Free space occupied by local array.  */\n\n  if (ssurf != SISL_NULL) freearray(ssurf);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1450.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1450.c,v 1.2 2001-03-19 15:58:49 afr Exp $\n *\n */\n\n\n#define S1450\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1450(SISLSurf *ps1,double aepsge,int *jclos1,int *jclos2,\n\t   int *jdgen1,int *jdgen2,int *jdgen3,int *jdgen4,int *jstat)\n#else\nvoid s1450(ps1,aepsge,jclos1,jclos2,jdgen1,jdgen2,jdgen3,jdgen4,jstat)\n     SISLSurf   *ps1;\n     double aepsge;\n     int    *jclos1;\n     int    *jclos2;\n     int    *jdgen1;\n     int    *jdgen2;\n     int    *jdgen3;\n     int    *jdgen4;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To decide if a surface is closed or degenerate along\n*              its boundaries.\n*\n* INPUT      : ps1    - Pointer to the surface to be checked\n*              aepsge - Tolerance for testing\n*\n* OUTPUT     : jclos1 - Closed indicator in first parameter direction\n*                        0 - Surface open if first parameter direction\n*                        1 - Surface closed if first parameter direction\n*            : jclos2 - Closed indicator in second parameter direction\n*                        0 - Surface open if second parameter direction\n*                        1 - Surface closed if second parameter direction\n*              jdgen1 - Degenerate indicator along standard edge 1\n*                       (v=et2[ik2-1])\n*                        0 - SISLEdge is not degenerate\n*                        1 - SISLEdge is degenerate\n*              jdgen2 - Degenerate indicator along standard edge 2\n*                       (u=et1[in1]\n*                        0 - SISLEdge is not degenerate\n*                        1 - SISLEdge is degenerate\n*              jdgen3 - Degenerate indicator along standard edge 3\n*                       (v=et2[in2]\n*                        0 - SISLEdge is not degenerate\n*                        1 - SISLEdge is degenerate\n*              jdgen4 - Degenerate indicator along standard edge 4\n*                       (u=et1[ik1-1])\n*                        0 - SISLEdge is not degenerate\n*                        1 - SISLEdge is degenerate\n*\n*              jstat  - status messages  \n*                                         > 0      : Warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                      \n*\n* METHOD     : All standard edges are picked out and then tested\n*              to find if the surface is closed in one of the parameter\n*              directions or if it degenerate along some edge.\n*\n* USE:        int kclos1,kclos2,kdgen1,kdgen2,kdgen3,kdgen4,kstat;\n*              double tepsge;\n*              SISLSurf *qs1;\n*               .\n*               .\n*              s1450(qs1,tepsge,&kclos1,&kclos2,&kdgen1,&kdgen2,&kdgen3,\n*                    &kdgen4,&kstat);\n*               .\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1436, s1437, s1451\n*\n* WRITTEN BY : Tor Dokken, SI, Norway, 1988-11\n* REVISED BY : Johannes Kaasa, SI, Sep 1991 (Introduced NURBS)\n*\n*********************************************************************\n*/                                     \n{\n  int kstat=0;        /* Local status variable.                          */\n  int kpos=0;         /* Position of error.                              */\n  int kdim;           /* Dimension of the space in which the surface lies. */\n  int rdim;           /* Dimension of the rational space.                */\n  int kn1;            /* Number of vertices in first parameter direction */\n  int kn2;            /* Number of vertices in first parameter direction */\n  int kk1;            /* Order in first parameter driection              */\n  int kk2;            /* Order in first parameter driection              */\n  int ki;             /* Control variables in for loop                   */\n  double *scoef;      /* B-spline vertices of surface                    */\n  double *st1,*st2;   /* Pointers to knot vectors                        */\n  double *sv1,*sv2,*sv3,*sv4;      /* Pointers to vertices               */\n  SISLCurve *q1=SISL_NULL;    /* Pointer to boundary curve        */\n  SISLCurve *q2=SISL_NULL;    /* Pointer to boundary curve        */\n  SISLCurve *q3=SISL_NULL;    /* Pointer to boundary curve        */\n  SISLCurve *q4=SISL_NULL;    /* Pointer to boundary curve        */\n  \n  \n  if (aepsge < (double)0.0) goto err184;\n  \n  kn1 = ps1->in1;\n  kn2 = ps1->in2;\n  kk1 = ps1->ik1;\n  kk2 = ps1->ik2;\n  kdim = ps1 ->idim;\n  scoef = ps1 -> ecoef;\n  st1   = ps1 -> et1;\n  st2   = ps1 -> et2;\n  if (ps1->ikind == 2 || ps1->ikind == 4)\n    rdim = kdim + 1;\n  else\n    rdim = kdim;\n  \n  /* Initiate output variables */\n  \n  *jclos1 = 1;\n  *jclos2 = 1;\n  *jdgen1 = 1;\n  *jdgen2 = 1;\n  *jdgen3 = 1;\n  *jdgen4 = 1;\n  \n  /* Pick standard edge 1 */\n  \n  s1436(ps1,st2[kk2-1],&q1,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Pick standard edge 2 */\n  \n  s1437(ps1,st1[kn1],&q2,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Pick standard edge 3 */\n  \n  s1436(ps1,st2[kn2],&q3,&kstat);\n  if (kstat < 0) goto error;\n  \n  \n  /* Pick standard edge 4 */\n  \n  s1437(ps1,st1[kk1-1],&q4,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Check if close in first parameter direction i.e. if the\n     vertices of standard edge 2 and 4 correspond */\n  \n  if (rdim == kdim)\n    {\n      sv2 = q2->ecoef;\n      sv4 = q4->ecoef;\n    }\n  else\n    {\n      sv2 = q2->rcoef;\n      sv4 = q4->rcoef;\n    }\n  for (ki=0; ki<kn2 ; ki++,sv2+=rdim,sv4+=rdim)\n    if(s6dist(sv2,sv4,kdim)>aepsge)\n      {\n        *jclos1 = 0;\n        ki = kn2;\n      }\n  \n  /* Check if close in second parameter direction i.e. if the\n     vertices of standard edge 1 and 3 correspond */\n  \n  if (rdim == kdim)\n    {\n      sv1 = q1->ecoef;\n      sv3 = q3->ecoef;\n    }\n  else\n    {\n      sv1 = q1->rcoef;\n      sv3 = q3->rcoef;\n    }\n  for (ki=0; ki<kn1; ki++,sv1+=rdim,sv3+=rdim)\n    if(s6dist(sv1,sv3,kdim)>aepsge)\n      {\n        *jclos2 = 0;\n        ki = kn1;\n      }\n  \n  /* Check if standard edge 1 degenerate */\n  \n  s1451(q1,aepsge,jdgen1,&kstat);\n  if (kstat<0) goto error;\n  \n  /* Check if standard edge 2 degenerate */\n  \n  s1451(q2,aepsge,jdgen2,&kstat);\n  if (kstat<0) goto error;\n  \n  /* Check if standard edge 3 degenerate */\n  \n  s1451(q3,aepsge,jdgen3,&kstat);\n  if (kstat<0) goto error;\n  \n  /* Check if standard edge 4 degenerate */\n  \n  s1451(q4,aepsge,jdgen4,&kstat);\n  if (kstat<0) goto error;\n  \n  \n  \n  *jstat = 0;\n  \n  goto out;\n  \n  /* Negative absolute tolerance.   */\n  \n err184: *jstat = -184;\n  s6err(\"s1450\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"s1450\",*jstat,kpos);\n  goto out;\n  \n out:\n    if (q1 != SISL_NULL) freeCurve(q1);\n    if (q2 != SISL_NULL) freeCurve(q2);\n    if (q3 != SISL_NULL) freeCurve(q3);\n    if (q4 != SISL_NULL) freeCurve(q4);\n  return;\n}\n\n                     \n"
  },
  {
    "path": "src/s1451.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1451.c,v 1.2 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1451\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1451(SISLCurve *pc1,double aepsge,int *jdgen,int *jstat)\n#else\nvoid s1451(pc1,aepsge,jdgen,jstat)\n     SISLCurve  *pc1;\n     double aepsge;\n     int    *jdgen;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To check if a curve is degenerated.\n*                              \n* INPUT      : pc1    - Pointer to the curve to be tested.\n*              aepsge - The curve is degenerate if all vertices lie\n*                       within the distance aepsge from each other\n*\n* OUTPUT     : jdgen  - Degenerate indicator\n*                        0 - The curve is not degenerate\n*                        1 - The curve is degenerate\n*\n*              jstat  - status messages  \n*                                         > 0      : Warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                      \n*\n* METHOD     : Testing  distance between all vertices\n*\n* USE:         int kdgen,kstat;\n*              double aepsge;\n*              SISLCurve *qc1;\n*               .\n*               .\n*              s1451(qc1,aepsge,&kdgen,&kstat);\n*               .\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6dist, s6err; \n*\n* WRITTEN BY : Tor Dokken, SI, Norway, 1988-11\n*\n*********************************************************************\n*/                                     \n{\n  int kpos=0;         /* Position of error.                              */\n  int kdim;           /* Dimension of the space in which the surface lies. */\n  int kn;             /* Number of vertices                              */\n  int kk;             /* Polynomial order                                */\n  \n  int ki,kj;          /* Control variables in for loop                   */\n  double *scoef;      /* Vertices                                        */\n  double *sv1,*sv2;   /* Pointer to vertices                             */\n  \n  \n  if (aepsge < (double)0.0) goto err184;\n  \n  /* Initiate degenerate indicator */\n  \n  *jdgen = 1;\n  \n  kn  = pc1->in;\n  kk  = pc1->ik;\n  kdim = pc1 -> idim;\n  scoef  = pc1 -> ecoef;\n  \n  for (kj=0,sv2=scoef ; kj < kn ; kj++,sv2+=kdim)\n    {\n      for (ki=kj+1,sv1=sv2+kdim; ki < kn ; ki++,sv1+=kdim)\n\t{\n\t  if (s6dist(sv1,sv2,kdim) > aepsge)\n\t    {\n\t      *jdgen = 0;\n\t      ki = kn;\n\t      kj = kn;\n\t    }\n\t}\n    }\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Negative absolute tolerance.   */\n  \n err184: *jstat = -184;\n  s6err(\"s1451\",*jstat,kpos);\n  goto out;\n  \n out:\n  return;\n}\n\n"
  },
  {
    "path": "src/s1452.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1452\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1452(SISLSurf *ps, double aepsge, double aoffset, SISLSurf **rs,\n\t   int *jstat)\n#else\nvoid s1452(ps,aepsge,aoffset,rs,jstat)\n     SISLSurf   *ps;\n     double aepsge;\n     double aoffset;\n     SISLSurf   **rs;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To create a B-spline approximating the offset surface of\n*              a B-spline surface.\n*\n*\n*\n* INPUT      : ps     - The input B-spline surface.\n*              aepsge - Maximal deviation allowed between true offset surface\n*                       and the approximated offset surface.\n*              aoffset- The offset distance.\n*                       If idim=2 a positive signe on this value put the\n*                       offset on the side of the positive normal vector,\n*                       and a negative sign puts the offset on the sign\n*                       of the negative normal vector.\n*                       If idim=3 the offset is determined by the cross\n*                       product of the tangent vector and the anorm vector.\n*                       The offset distance is multiplied by this vector.\n*\n* OUTPUT     :\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*              rs     - Pointer the approximated offset surface\n*\n* METHOD     : The 4 edge curves of the surface are extracted. Offset curves\n*              of these 4 edge curves are approximated and a common\n*              basis for the two pairs of opposite offset curves is calculated.\n*              Vertices are recomputed.\n*\n* EXAMPLE OF USE:\n*\n*\n* REFERENCES :\n*\n*\n*-\n* CALLS      : s1365     - This routine is performing the actual computation\n*                          The existence of the current routine is for\n*                          historical reasons.\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 0394.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;     /* Local status variable.                           */\n  int kpos = 0;      /* Position of error.                               */\n  int kdim = ps->idim;  /* Dimension of geometry space.                  */\n  double tmax = (double)0;  /* Dummy.                                    */\n\n  /* Compute offset surface. */\n\n   s1365(ps, aoffset, aepsge, tmax, kdim, rs, &kstat);\n   if (kstat < 0) goto error;\n\n  /* Surface approximated. */\n\n  *jstat = kstat;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n  s6err(\"s1452\",*jstat,kpos);\n  goto out;\n\n  out: return;\n}\n"
  },
  {
    "path": "src/s1500.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1500.c,v 1.2 2001-03-19 15:58:49 afr Exp $\n *\n */\n\n\n#define S1500\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1500(double base[],double norm[],double axisA[],double alpha,\n         double ratio,int idim,int inumb,double carray[],int *jstat)\n#else\nvoid s1500(base,norm,axisA,alpha,ratio,idim,inumb,carray,jstat)\n     double base[];\n     double norm[];\n     double axisA[];\n     double alpha;\n     double ratio;\n     int    idim;\n     int    inumb;\n     double carray[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To make a matrix of dimension (idim+1)x(idim+1)\n*              describing an elliptic cone as an implicit function.\n*\n*\n* INPUT      : base   - The base point of the cone\n*                                (the centre of the base ellipse) \n*              norm  - Direction of cone axis\n*              axisA  - One of the axes of the ellipse\n*              alpha  - The opening angle of axisA\n*              ratio  - The ratio of axisA to axisB \n*              idim   - The dimension of the space the cylinder lies in\n*              inumb  - The number of copies that are to be made of the\n*                       matrix.\n*\n*\n*\n* OUTPUT     : carray - The description of the elliptic cone. Outside \n*                       this function the space for this array must be\n*                       allocated. The need is (idim+1)*(idim+1)*inumb\n*                       dimension 4x4 (xinarr)\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n*     If the base point of the cone is denoted p=(p1,p2,p3),\n*     the axis vector of the cone is denoted n=(n1,n2,n3),\n*     the direction vector of one ellipse axis is denoted A=(a1,a2,a3),\n*     the second B = (n X A) / |n x A|  is B=(b1,b2,b3),\n*     alpha is the opening angle of the cone at the axis A,\n*     then the matrix describing\n*     the cone is A:\n*\n*\n*     WHERE\n*        A11 = cos2*a1*a1+cos2*r*b1*b1-sin2*n1*n1\n*  A21 = A12 = cos2*a1*a2+cos2*r*b1*b2-sin2*n1*n2\n*  A31 = A13 = cos2*a1*a3+cos2*r*b1*b3-sin2*n1*n3\n*  A41 = A14 = -cos2*(A.p)*a1-cos2*r*(B.p)*b1+a*cos*sin*n1+sin2*(n.p)*n1\n*        A22 = cos2*a2*a2+cos2*r*b2*b2-sin2*n2*n2\n*  A32 = A23 = cos2*a2*a3+cos2*r*b2*b3-sin2*n2*n3\n*  A42 = A24 = -cos2*(A.p)*a2-cos2*r*(B.p)*b2+a*cos*sin*n2+sin2*(n.p)*n2\n*        A33 = cos2*a3*a3+cos2*r*b3*b3-sin2*n3*n3\n*  A43 = A34 = -cos2*(A.p)*a3-cos2*r*(B.p)*b3+a*cos*sin*n3+sin2*(n.p)*n3\n*        A44 = cos2*(A.p)**2+cos2*r*(B.p)**2-(cos*a+sin*(n.p))**2\n*\n*     aND\n*\n*        cos=cos(alpha), sin=sin(alpha), cos2=cos*cos, sin2=sin*sin\n*        a=|A|, r=(|A|/|B|)**2,\n*        A.p=a1*p1+a2*p2+a3*p3 (dot product), similarly for B.p, n.p,\n*   and  B=n*A/|nxA| (cross product).\n*\n*        \n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Mike Floater, SI, Oslo, Norway, 16-October-1988\n*                                    \n*********************************************************************\n*/\n{\n  int kdimp1;         /* Dimension of matrix kdimp1 = idim + 1         */\n  int kstop;          /* Stop condition for for loop                   */\n  int ki,kj,kl;       /* Running variables in loop                     */\n  int kpos=0;         /* Position of error                             */\n  int kstat;          /* Local status variable                         */\n  double a1,a2,a3;    /* Coordinates of A vector                       */\n  double b1,b2,b3;    /* Coordinates of B vector                       */\n  double n1,n2,n3;    /* Coordinates of ndirec vector                  */\n  double temp;        /* Temporary storage variable                    */\n  double cosT;        /* cos(alpha)                                    */\n  double cosT2;       /* The square of cos(alpha)                      */\n  double sinT;        /* sin(alpha)                                    */\n  double sinT2;       /* The square of sin(alpha)                      */\n  double cosTsinT;    /* cos(alpha)*sin(alpha)                         */\n  double ndirec[3];   /* Normalized direction of cone axis             */\n  double A[3];        /* Normalized elliptic axisA                     */\n  double B[3];        /* Normalized elliptic axisB                     */\n  double asize;       /* Length of axisA                               */\n  double r;           /* ratio*ratio                                   */\n  double Adotp;       /* scalar product of A and base                  */\n  double Bdotp;       /* scalar product of B and base                  */\n  double ndotp;       /* scalar product of n and base                  */\n  \n  \n  /* Test i legal input */\n  if (inumb <1 ) inumb = 1;\n  if (idim != 3 ) goto err104;\n  \n  kdimp1 = idim + 1;\n  kstop  = kdimp1*kdimp1;\n  \n  for (ki=0;ki<kstop;ki++)\n    {\n      carray[ki] = DZERO;\n    }\n  \n  /* Normalise direction vector of cone axis */\n  \n  (void)s6norm(norm,idim,ndirec,&kstat);\n  \n  /* Test if norm degenerate */\n  if(kstat == 0) goto err174;\n\n  \n  /* Normalise elliptic axisA and find its length */        \n  \n  asize=s6norm(axisA,idim,A,&kstat);\n  \n  /* Test if norm degenerate */\n  if(kstat == 0) goto err174;\n\n  /* Calculate the other elliptic axis from ndirec and A       */        \n  /* Note that norm and axisA are assumed to be orthogonal     */        \n  \n  (void)s6crss(ndirec,A,B);\n  \n  /* Calculate cosine and sine of angle alpha */\n  \n  cosT=cos(alpha);\n  sinT=sin(alpha);\n  cosT2=cosT*cosT;\n  sinT2=sinT*sinT;\n  cosTsinT=cosT*sinT;\n  \n  /* Find the square of the ratio of lengths of axisA and axisB  */\n\n  r=ratio*ratio;\n\n  \n  /* set up coordinates of the normalised axes  */\n\n  a1 = A[0];\n  a2 = A[1];\n  a3 = A[2];\n  b1 = B[0];\n  b2 = B[1];\n  b3 = B[2];\n  n1 = ndirec[0];\n  n2 = ndirec[1];\n  n3 = ndirec[2];\n  \n  /* set up dot (scalar) products of axes and base point */\n\n  Adotp = s6scpr(A,base,idim);\n  Bdotp = s6scpr(B,base,idim);\n  ndotp = s6scpr(ndirec,base,idim);\n\n  \n  /* Make element (1,1)  */\n  \n  carray[0] = cosT2*(a1*a1+r*b1*b1)-sinT2*n1*n1;\n  \n  /* Make element (1,1)  */\n  \n  carray[5] = cosT2*(a2*a2+r*b2*b2)-sinT2*n2*n2;\n  \n  /* Make element (1,1)  */\n  \n  carray[10] = cosT2*(a3*a3+r*b3*b3)-sinT2*n3*n3;\n  \n  /* Make element (1,2) and (2,1) */\n  \n  temp = cosT2*(a1*a2+r*b1*b2)-sinT2*n1*n2;\n  carray[1] = temp;\n  carray[4] = temp;\n  \n  \n  /* Make element (1,3) and (3,1) */\n  \n  temp = cosT2*(a1*a3+r*b1*b3)-sinT2*n1*n3;\n  carray[2] = temp;\n  carray[8] = temp;\n  \n  \n  /* Make element (2,3) and (3,2) */\n  \n  temp = cosT2*(a2*a3+r*b2*b3)-sinT2*n2*n3;\n  carray[6] = temp;\n  carray[9] = temp;\n  \n  \n  \n  /* Make element (1,4) and (4,1) */\n  \n  temp = -cosT2*(Adotp*a1+r*Bdotp*b1)+(asize*cosTsinT+sinT2*ndotp)*n1;\n  carray[3]  = temp;\n  carray[12] = temp;\n  \n  \n  /* Make element (2,4) and (4,2) */\n  \n  temp = -cosT2*(Adotp*a2+r*Bdotp*b2)+(asize*cosTsinT+sinT2*ndotp)*n2;\n  carray[7]  = temp;\n  carray[13] = temp;\n  \n  \n  /* Make element (3,4) and (4,3) */\n  \n  temp = -cosT2*(Adotp*a3+r*Bdotp*b3)+(asize*cosTsinT+sinT2*ndotp)*n3;\n  carray[11] = temp;\n  carray[14] = temp;\n  \n  /* Make element (4,4) */\n  \n  temp = cosT*asize+sinT*ndotp;\n  carray[15] = cosT2*(Adotp*Adotp+r*Bdotp*Bdotp)-temp*temp;\n  \n  \n  /* Make extra copies of cone */\n  \n  kj = kstop;\n  for (ki=1;ki<inumb;ki++)\n    {\n      for (kl=0;kl<kstop;kl++,kj++)\n        {\n\t  carray[kj] = carray[kl];\n        }\n    }\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Dimension less than 1 */\n err104: *jstat = -104;\n  s6err(\"s1500\",*jstat,kpos);\n  goto out;\n  \n  /* norm axis or elliptic axis is zero */\n err174: *jstat = -174;\n  s6err(\"s1500\",*jstat,kpos);\n  goto out;\n  \n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1501.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1501.c,v 1.3 2001-03-19 15:58:49 afr Exp $\n *\n */\n\n\n#define S1501\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1501(SISLSurf *ps1,double *base,double *norm,double *axisA,double alpha,double ratio,int idim,\n\t   double aepsco,double aepsge,double amax,SISLIntcurve *pintcr,\n\t   int icur,int igraph,int *jstat)\n#else\nvoid s1501(ps1,base,norm,axisA,alpha,ratio,idim,aepsco,aepsge,amax,pintcr,\n           icur,igraph,jstat)\n     SISLSurf     *ps1;\n     double   *base;\n     double   *norm;\n     double   *axisA;\n     double   alpha;\n     double   ratio;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     double   amax;\n     SISLIntcurve *pintcr;\n     int      icur;\n     int      igraph;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To march an intersection curve desribed by parameter pairs\n*              in an intersection curve object, a B-spline surface and\n*              an elliptic cone.\n*\n*\n* INPUT      : ps1    - Pointer to surface.\n*              base   - Base point of cone\n*              norm   - Direction of cone axis\n*              axisA  - One of the two ellipse axis vectors\n*              alpha  - The opening angle of the cone at axisA\n*              ratio  - The ratio of axisA to axisB\n*              idim   - Dimension of the space in which the plane lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              amax   - Maximal allowed step length. If amax <=aepsge\n*                       amax is neglected.\n*              icur   - Indicator telling if a 3-D curve is to be made\n*                        0 - Don't make 3-D curve\n*                        1 - Make 3-D curve\n*                        2 - Make 3-D curve and curves in parameter plane\n*              igraph - Indicator telling if the curve is to be output\n*                       through function calls:\n*                        0 - don't output curve through function call\n*                        1 - output as straight line segments through\n*                            s6move and s6line.\n*\n*\n*\n* INPUT/OUTPUT:pintcr - The intersection curve. When coming as input\n*                       only parameter values in the parameter plane\n*                       exist. When coming as output the 3-D geometry\n*                       and possibly the curve in the parameter plane\n*                       of the surface are added.\n*\n* OUTPUT:      jstat  - status messages\n*                         = 3      : Iteration stopped due to singular\n*                                    point or degenerate surface. A part\n*                                    of intersection curve may have been\n*                                    traced out. If no curve is traced out\n*                                    the curve pointers in the Intcurve\n*                                    object point to SISL_NULL.\n*                         = 0      : ok\n*                         < 0      : error\n*                         = -185   : No points produced on intersection curve.\n*\n*\n* METHOD     : An implicit description of the cone is made and then\n*              a routine for intersecting implicit represented geometry\n*              by a B-spline surface is used.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err, s1313, s1500\n* WRITTEN BY : Mike Floater, SI, Oslo, Norway, 22 Oct, 1988\n*\n*********************************************************************\n*/\n{\n  int kpos=0;         /* Position of error                                  */\n  int kdeg=2;         /* The degree of the implicit equation of the plane   */\n  int knumb=1;        /* Number of implicit representations to be made      */\n  int kstat;          /* Local status variable                              */\n  double simpli[16];  /* Array containing the implicit description of sphere*/\n\n  if (idim != 3) goto err104;\n\n  /* Make description of cone */\n\n  s1500(base,norm,axisA,alpha,ratio,idim,knumb,simpli,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Make intersection of implicit surface and B-spline surface */\n\n  s1313(ps1,simpli,kdeg,aepsco,aepsge,amax,pintcr,icur,igraph,&kstat);\n  if (kstat == -185) goto err185;\n  if (kstat < 0) goto error;\n\n  *jstat = kstat;\n  goto out;\n  /* Dimension not 3 */\n\n err104:\n  *jstat = -104;\n  s6err(\"s1501\",*jstat,kpos);\n  goto out;\n\n  /* Couldn't march */\n\n err185:\n  *jstat = -185;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error:\n  *jstat = kstat;\n  s6err(\"s1501\",*jstat,kpos);\n  goto out;\n\n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1502.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1502.c,v 1.3 2001-03-19 15:58:49 afr Exp $\n *\n */\n\n\n#define S1502\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1502(SISLCurve *pc1,double base[],double norm[],double axisA[],\n\t   double alpha,double ratio,int idim,double aepsco,double aepsge,\n\t   int *jpt,double **gpar,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1502(pc1,base,norm,axisA,alpha,ratio,idim,aepsco,aepsge,\n\t   jpt,gpar,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     double   base[];\n     double   norm[];\n     double   axisA[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find all intersections between a curve and an elliptic cone.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve.\n*              base   - Base point of cone, center of elliptic base.\n*              norm   - Direction of cone axis, default pointing from\n*                       basepoint towards top point of the cone.\n*              axisA  - One of the two ellipse axis vectors.\n*              alpha  - The opening angle of the cone at axisA\n*              ratio  - The ratio of axisA to axisB\n*              idim   - Dimension of the space in which the elliptic cone\n*                       lies. idim should be equal to three.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : *jpt   - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie continuous.\n*                       Intersection curves are stored in wcurve.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the curve is put into the equation of the\n*              cone achieving a curve in the one-dimentional space.\n*              The zeroes of this curve is found.\n*\n* REFERENCES : Main routine written by Mike Floater, SI, 1990.\n*\n* CALLS      : sh1502, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov. 1994. Changed header\n*              text to reflect that the routine only handles 3D input.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;           /* Local status variable.                       */\n  int kpos = 0;            /* Position of error.                           */\n  int trackflag = 0;\n  int jtrack;\n  int *pretop=SISL_NULL;\n  SISLTrack **wtrack=SISL_NULL;\n\n  sh1502(pc1,base,norm,axisA,alpha,ratio,idim,aepsco,aepsge,\n\t trackflag,&jtrack,&wtrack,jpt,gpar,&pretop,jcrv,wcurve,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  /*\n   * Intersections found.\n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n\n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n    s6err(\"s1502\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}\n"
  },
  {
    "path": "src/s1503.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1503.c,v 1.2 2001-03-19 15:58:49 afr Exp $\n *\n */\n\n\n#define S1503\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1503(SISLSurf *ps1,double base[],double norm[],double axisA[],\n\t   double alpha,double ratio,int idim,double aepsco,double aepsge,\n\t   int *jpt,double **gpar,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1503(ps1,base,norm,axisA,alpha,ratio,idim,aepsco,aepsge,\n\t   jpt,gpar,jcrv,wcurve,jstat)\n     SISLSurf     *ps1;\n     double   base[];\n     double   norm[];\n     double   axisA[];\n     double   alpha;\n     double   ratio;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a tensor-product surface\n*              and a cone.\n*\n*\n*\n* INPUT      : ps1    - Pointer to the surface.\n*              base   - Base point of cone\n*              norm   - Direction of cone axis\n*              axisA  - One of the two ellipse axis vectors\n*              alpha  - The opening angle of the cone at axisA\n*              ratio  - The ratio of axisA to axisB\n*              idim     - Dimension of the space in which the cone lies.\n*              aepsco   - Computational resolution.\n*              aepsge   - Geometry resolution.\n*                                                                        \n*                                                                        \n*\n* OUTPUT     : *jpt   - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       plane of the surface. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the surface are put into the equation of \n*              the cone resulting in a surface in one-dimensional space.\n*              Then the zeroes of this surface are found.\n*\n*\n* REFERENCES : Main routine written by Mike Floater, SI, 1990.\n*\n* CALLS      : sh1503, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n*\n*\n*********************************************************************\n*/\n{            \n  int kstat = 0;           /* Local status variable.                       */\n  int kpos = 0;            /* Position of error.                           */\n  int i;\n  int trackflag = 0;\n  int jtrack;\n  int *pretop=SISL_NULL;\n  int jsurf;\n  SISLIntsurf **wsurf=SISL_NULL;\n  SISLTrack **wtrack=SISL_NULL;\n\n  sh1503(ps1,base,norm,axisA,alpha,ratio,idim,aepsco,aepsge,\n\t trackflag,&jtrack,&wtrack,jpt,gpar,&pretop,jcrv,wcurve,\n\t &jsurf,&wsurf,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  for(i=0; i<jsurf; i++)\n    freeIntsurf(wsurf[i]);\n  if(wsurf != SISL_NULL) freearray(wsurf);\n\n  if(jsurf > 0) \n    *jstat=10;\n  else \n    *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : \n    *jstat = kstat;\n    s6err(\"s1503\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}                                               \n"
  },
  {
    "path": "src/s1504.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1504.c,v 1.3 2006-11-17 20:55:25 vsk Exp $\n *\n */\n\n\n#define S1504\n#include \"sislP.h\"\n\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1504(double *et,int ik,int in,\n\t   double *ax,int im,int ider,double ebder[],int ileft[],int *jstat)\n#else\nvoid s1504(et,ik,in,ax,im,ider,ebder,ileft,jstat)\n     double *et;\n     int    ik;\n     int    in;\n     double *ax;\n     int    im;\n     int    ider;\n     double ebder[];\n     int ileft[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To compute the value and ider first derivatives of the\n*              ik (possibly) nonzero B-splines associated with the knot\n*              vector et at the array of points ax[0],...,ax[im-1].\n*\n*\n*\n* INPUT      : et     - Double array of dimension [in+ik] containing\n*                       the knot vector.\n*              ik     - The polynomial order of the B-splines associated\n*                       with et.\n*              in     - The dimension of the spline space associated with\n*                       the knot vector et.\n*              ax     - The array of values at which the non-zero B-splines\n*                       and derivatives are to be computed.\n*              ider   - The number of derivatives to be computed.\n*                       < 0 : Error.\n*                       = 0 : Compute position.\n*                       = 1 : Compute position and first derivative.\n*                       etc.\n*\n* OUTPUT     : ebder  - Triple array of dimension [(ider+1)*ik*im] containing\n*                       values of the ik nonzero B-splines and their\n*                       derivatives at the points ax[0],...,ax[im-1].\n*                       These numbers are stored in the following order:\n*                       First the (ider+1) derivatives of the first nonzero\n*                       B-spline at ax[0]. Then the (ider+1) derivatives of\n*                       the second nonzero B-spline at ax[0], etc.\n*                       Later we repeat for ax[1],... etc.\n* OUTPUT     : ileft  - Array of dimension im containing the index of\n*                       the first non-zero B-spline for each value in ax.\n*              jstat  - Status messages\n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : Call 1220 im times.\n*\n* CALLS      : s1220.\n*\n* WRITTEN BY : Michael Floater, SINTEF, May, 1998.\n*\n*********************************************************************\n*/\n{\n  int kstat=0;        /* Local status variable.                          */\n  int kpos=0;         /* The position of error.                          */\n  int kleft=0;        /* Local version of ileft.                         */\n  int j,k,kk;         /* Control variables in for loops and for stepping\n\t\t\t through arrays.                                 */\n  double *eder = SISL_NULL;  /* B-spline evaluationas at a single value. */\n  int size;           /* (ider+1) * ik.                                  */\n\n  if (ider < 0) goto err178;\n\n  size = (ider + 1) * ik;\n  eder = newarray(size,double);\n  if (eder == SISL_NULL) goto err101;\n\n  kk = 0;\n  for(k=0; k<im; k++)\n  {\n    s1220(et,ik,in,&kleft,ax[k],ider,eder,&kstat);\n    if (kstat < 0) goto error;\n\n    ileft[k] = kleft;\n    for(j=0; j<size; j++)\n    {\n      ebder[kk+j] = eder[j];\n    }\n    kk += size;\n  }\n\n  *jstat = 0;\n  goto out;\n\n  /* Not enough memory. */\n err101: *jstat = -101;\n  s6err(\"s1504\",*jstat,kpos);\n  goto out;\n\n  /* Illegal derivative requested. */\n err178: *jstat = -178;\n  s6err(\"s1504\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n error:  *jstat = kstat;\n  s6err(\"s1504\",*jstat,kpos);\n  goto out;\n\n out: \n  if (eder != SISL_NULL)\n      freearray(eder);\n  return;\n}\n"
  },
  {
    "path": "src/s1505.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n#define S1505\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1505(const SISLSurf *ps1,int ider,int m1, int m2,double *ebder1,double\n      *ebder2, int *ileft1,int *ileft2,double eder[],double norm[],int *jstat)\n#else\nvoid s1505(ps1,ider,m1,m2,ebder1,ebder2,ileft1,ileft2,eder,norm,jstat)\n     SISLSurf   *ps1;\n     int    ider;\n     int m1;\n     int m2;\n     double *ebder1;\n     double *ebder2;\n     int    *ileft1;\n     int    *ileft2;\n     double eder[];\n     double norm[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate the surface pointed at by ps1 over an m1 * m2\n*              grid, assuming that the B-splines have been\n*              pre-evaluated, by s1504, over that grid.\n*              The knots et1 and et2 and grid points (x[i],y[j]) are not needed.\n*              Compute ider derivatives.\n*\n* INPUT      : ps1    - Pointer to the surface to evaluate.\n*              ider   - Number of derivatives to calculate.\n*                       < 0 : No derivative calculated.\n*                       = 0 : Position calculated.\n*                       = 1 : Position and first derivative calculated.\n*                       etc.\n*              m1     - Number of grid points in first direction.\n*              m2     - Number of grid points in first direction.\n*              ileft1 - Array of indexes to the intervals in the knotvector\n*                       in the first parameter direction where each subsequence\n*                       of k1 non-zero B-splines are located.\n*              ileft2 - Array of indexes to the intervals in the knotvector\n*                       in the second parameter direction where each subsequence\n*                       of k2 non-zero B-splines are located.\n*              ebder1 - Triple array of dimension [(ider+1)*k1*m1] containing\n*                       values of the k1 nonzero B-splines and their\n*                       derivatives at the points x[0],...,x[m1-1]\n*                       (i.e. pre-evaluated B-splines).\n*                       These numbers are stored in the following order:\n*                       First the (ider+1) derivatives of the first nonzero\n*                       B-spline at x[0]. Then the (ider+1) derivatives of\n*                       the second nonzero B-spline at x[0], etc.\n*                       Later we repeat for x[1],... etc.\n*\n*              ebder2 - Triple array of dimension [(ider+1)*k2*m2] containing\n*                       values of the k2 nonzero B-splines and their\n*                       derivatives at the points y[0],...,y[m2-1]\n*\n* OUTPUT     : eder   - Array where the derivatives of the surface\n*                       are placed, dimension\n*                         idim * ((ider+1)(ider+2) / 2) * m1 * m2.\n*                       The sequence is position,\n*                       first derivative in first parameter direction,\n*                       first derivative in second parameter direction,\n*                       (2,0) derivative, (1,1) derivative, (0,2)\n*                       derivative, etc. at point (x[0],y[0]),\n*                       followed by the same information at (x[1],y[0]),\n*                       etc.\n*              norm   - Normals of surface. Is calculated if ider >= 1.\n*                       Dimension is idim*m1*m2.\n*                       The normals are not normalized.\n*              jstat  - status messages\n*                          = 2      : Surface is degenerate\n*                                     at some point, normal\n*                                     has zero length.\n*                          = 1      : Surface is close to\n*                                     degenerate at some point\n*                                     Angle between tangents,\n*                                     less than angular tolerance.\n*                          = 0      : ok\n*                          < 0      : error\n*\n* METHOD     : The code and method is similar to that of s1421 except that\n*              the B-splines and their derivatives have already been\n*              calculated (and are given in ebder1 and ebder2) and\n*              we evaluate over a whole grid rather than at one point.\n*              The method is to find the control points and control derivatives\n*              of each isocurve in x (fixed y value). We then\n*              evaluate at each x value along the isocurve.\n*\n* CALLS      : s6err     - Error handling routine\n*              s6strider - Make derivative of rational expression\n*\n* WRITTEN BY : Michael Floater, SINTEF, May 1998.\n*********************************************************************\n*/\n{\n  int kstat=0;        /* Local status variable.                          */\n  int kpos=0;         /* The position of error.                          */\n  int i1,i2;          /* Loop variables. */\n  int i1pos,i2pos;    /* Offset indexes. */\n  int kn1,kn2;        /* The number of B-splines accociated with the knot\n\t\t\t vectors st1 and st2.                            */\n  int kk1,kk2;        /* The polynomial order of the surface in the two\n\t\t\t directions.                                     */\n  int kdim;           /* The dimension of the space in which the surface\n\t\t\t lies. Equivalently, the number of components\n\t\t\t of each B-spline coefficient.                   */\n  int kleft1,kleft2;  /* Local versions of knot intervals.            */\n  int ki,kx,kjh;      /* Control variables in for loops and for stepping\n\t\t\t through arrays.                                 */\n  int kih2;           /* Index for stepping through ebder2. */\n  int ky,kl,kl1,kl2;  /* Control variables in for loops and for stepping\n\t\t\t through arrays.                                 */\n  double *scoef;      /* The B-spline coefficients of the surface.\n\t\t\t This is an array of dimension [kn2*kn1*kdim].   */\n  double tt;          /* Dummy variable used for holding an array element\n\t\t\t in a for loop.                                  */\n  double *ew=SISL_NULL;    /* Pointer to an array of dimension [kn1*(ider+1)*kdim]\n\t\t\t which will be used to store the result of the first\n\t\t\t matrix multiplication. */\n  double *sder=SISL_NULL;  /* Pointer to array used for storage of points, if\n\t\t\t rational has room for homogenous coordinates. */\n  double *enorm=SISL_NULL; /* Array for surface normal. */\n  int size;           /* Space occupied by points and derivs at one eval. */\n  int sizeh;          /* Space occupied by homogeneous points and derivs . */\n  int size1,size2;    /* Useful variables. */\n  int ederpos;       /* Index of position in eder. */\n  int normpos;       /* Index of position in norm. */\n\n  int knumb2;         /* Necessary size of ew */\n\n  int tot,temp;       /* Temporary variables. */\n\n  kn1 = ps1 -> in1;\n  kn2 = ps1 -> in2;\n  kk1 = ps1 -> ik1;\n  kk2 = ps1 -> ik2;\n  kdim = ps1 -> idim;\n  /* Check the input. */\n\n  if (kdim < 1) goto err102;\n  if (kk1 < 1) goto err115;\n  if (kn1 < kk1 || kn2 < kk2) goto err116;\n  if (ider < 0) goto err178;\n\n  *jstat = 0;\n\n  if (ps1->ikind == 2 || ps1->ikind == 4)\n  {\n    scoef = ps1 -> rcoef;\n    kdim +=1;\n  }\n  else\n  {\n    scoef = ps1 -> ecoef;\n  }\n  sizeh = kdim*(ider+1)*(ider+2)/2;\n  if((sder=newarray(sizeh,DOUBLE)) == SISL_NULL) goto err101;\n  if((enorm=newarray(ps1->idim,DOUBLE)) == SISL_NULL) goto err101;\n\n  size = ps1->idim*(ider+1)*(ider+2)/2;\n  size1 = (ider+1)*kk1;\n  size2 = (ider+1)*kk2;\n\n  /* Allocate space for B-spline values and derivatives and one work array. */\n\n  knumb2 = kn1*(ider+1)*kdim;\n  if((ew=newarray(knumb2,DOUBLE)) == SISL_NULL) goto err101;\n\n  ederpos = 0;\n  normpos = 0;\n\n  /* Run through grid points in the y direction. */\n  for(i2=0, i2pos=0; i2<m2; i2++, i2pos += size2)\n  {\n    kleft2 = ileft2[i2];\n\n    /* Compute the control points (and control derivatives\n       of the v = x[i2] isocurve. */\n\n    /* Set all the elements of ew to 0. */\n    for(ki=0; ki<knumb2; ki++) ew[ki] = DZERO;\n\n    /* ki steps through the appropriate kk2 rows of B-spline coefficients\n       while kih2 steps through the B-spline value and derivatives for the\n       B-spline given by ki.            */\n\n    kih2 = i2pos;\n    for (ki=kleft2-kk2+1; ki<=kleft2; ki++)\n    {\n      /* kx counts through the ider+1 derivatives to be computed.\n         kjh steps through ew once for each ki to accumulate the\n         contribution from the different B-splines.\n         kl1 points to the first component of the first B-spline coefficient\n         in row no. ki of the B-spline coefficient matrix.\n      */\n\n      kjh = 0; kl1 = kdim*ki*kn1;\n      for (kx=0; kx<=ider; kx++)\n      {\n        /* The value of the B-spline derivative is stored in tt while\n           kl2 steps through the kdim components of all the B-spline\n           coefficients that multiply nonzero B-splines along st1.\n        */\n\n        tt = ebder2[kih2++]; kl2 = kl1;\n        for (kl=0; kl<kdim*kn1; kl++,kjh++,kl2++)\n        {\n           ew[kjh] += scoef[kl2]*tt;\n        }\n      }\n    }\n\n    /* Run through grid points in the x direction\n       evaluating along the iso-curve defined by y = y[i2]. */\n    for(i1=0, i1pos=0; i1<m1; i1++, i1pos += size1)\n    {\n      kleft1 = ileft1[i1];\n\n      /* Set all the elements of sder to 0. */\n      for(ki=0; ki<sizeh; ki++) sder[ki] = DZERO;\n\n      for(ky=0; ky<=ider; ky++)\n      {\n\tkl1 = kdim * (ky * kn1 + kleft1 - kk1 + 1);\n\tfor(kx=0; kx<=ider-ky; kx++)\n\t{\n          tot = kx + ky;\n          temp = ((tot * (tot+1)) >> 1) + ky;\n\t  kjh = temp * kdim;\n\n\t  for(ki=0; ki<kk1; ki++)\n          {\n\t    tt = ebder1[i1pos + (ider+1) * ki + kx];\n\t    for(kl=0; kl<kdim; kl++)\n\t    {\n\t      sder[kjh+kl] += ew[kl1 + kdim * ki + kl] * tt;\n\t    }\n          }\n        }\n      }\n\n      /* If rational surface calculate the derivatives based on\n         derivatives in homogenous coordinates */\n\n      if (ps1->ikind == 2 || ps1->ikind == 4)\n      {\n        s6strider(sder,ps1->idim,ider,eder+ederpos,&kstat);\n        if (kstat<0) goto error;\n      }\n      else\n      {\n        for(ki=0; ki<sizeh; ki++) eder[ederpos+ki] = sder[ki];\n      }\n\n      /* Calculate normal if idim==3 and ider>0. */\n\n      if (ider>0 && ps1->idim ==3)\n        {\n\n          s6crss(eder+ederpos+ps1->idim,eder+ederpos+2*ps1->idim,enorm);\n\n          s6norm(enorm,3,norm+normpos,&kstat);\n         }\n\n      ederpos += size;\n      normpos += 3;\n    }\n  }\n\n  goto out;\n\n  /* Not enough memory. */\n err101: *jstat = -101;\n  s6err(\"s1505\",*jstat,kpos);\n  goto out;\n\n  /* kdim less than 1. */\n err102: *jstat = -102;\n  s6err(\"s1505\",*jstat,kpos);\n  goto out;\n\n  /* Polynomial order less than 1. */\n err115: *jstat = -115;\n  s6err(\"s1505\",*jstat,kpos);\n  goto out;\n\n  /* Fewer B-splines than the order. */\n err116: *jstat = -116;\n  s6err(\"s1505\",*jstat,kpos);\n  goto out;\n\n  /* Illegal derivative requested. */\n err178: *jstat = -178;\n  s6err(\"s1221\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n error:  *jstat = kstat;\n  s6err(\"s1505\",*jstat,kpos);\n  goto out;\n\n out:\n  /* Free memory. */\n  if(sder != SISL_NULL) freearray(sder);\n  if(enorm != SISL_NULL) freearray(enorm);\n  if (ew != SISL_NULL) freearray(ew);\n\n    return;\n}\n"
  },
  {
    "path": "src/s1506.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n#define S1506\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1506(SISLSurf *ps1,int ider,int m1,double *x,int m2,double *y,\n      double eder[],double norm[],int *jstat)\n#else\nvoid s1506(ps1,ider,m1,x,m2,y,eder,norm,jstat)\n     SISLSurf *ps1;\n     int      ider;\n     int      m1;\n     double   *x;\n     int      m2;\n     double   *y;\n     double   eder[];\n     double   norm[];\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate the surface pointed at by ps1 over an m1 * m2 grid\n*              of points (x[i],y[j]). Compute ider derivatives and normals\n*              if suitable.\n*\n* INPUT      : ps1    - Pointer to the surface to evaluate.\n*              ider   - Number of derivatives to calculate.\n*                       < 0 : No derivative calculated.\n*                       = 0 : Position calculated.\n*                       = 1 : Position and first derivative calculated.\n*                       etc.\n*              m1     - Number of grid points in first direction.\n*               x     - Array of x values of the grid.\n*              m2     - Number of grid points in first direction.\n*               y     - Array of y values of the grid.\n*\n* OUTPUT     : eder   - Array where the derivatives of the surface\n*                       are placed, dimension\n*                         idim * ((ider+1)(ider+2) / 2) * m1 * m2.\n*                       The sequence is position,\n*                       first derivative in first parameter direction,\n*                       first derivative in second parameter direction,\n*                       (2,0) derivative, (1,1) derivative, (0,2)\n*                       derivative, etc. at point (x[0],y[0]),\n*                       followed by the same information at (x[1],y[0]),\n*                       etc.\n*              norm   - Normals of surface. Is calculated if ider >= 1.\n*                       Dimension is idim*m1*m2.\n*                       The normals are not normalized.\n*              jstat  - status messages\n*                          = 2      : Surface is degenerate\n*                                     at some point, normal\n*                                     has zero length.\n*                          = 1      : Surface is close to\n*                                     degenerate at some point\n*                                     Angle between tangents,\n*                                     less than angular tolerance.\n*                          = 0      : Ok.\n*                          < 0      : Error.\n*\n* METHOD     : We call s1504 to pre-evaluate the B-splines then call\n*              s1505 to multiply them with the coefficients.\n*\n*-\n* CALLS      : s1504, s1505.\n*\n* WRITTEN BY : Michael Floater, SINTEF, May 1998.\n*********************************************************************\n*/\n{\n  int kstat=0;         /* Local status variable.                          */\n  int kpos=0;          /* The position of error.                          */\n  int n1,n2;           /* The number of B-splines accociated with the knot\n\t\t \t vectors st1 and st2.                            */\n  int k1,k2;           /* The polynomial order of the surface in the two\n\t\t \t directions.                                     */\n  int kdim;            /* The space dimension of the surface. */\n  double *ebder1=SISL_NULL; /* Triple array of dimension (ider+1)*k1*m1\n                         containing dericatives of B-splines. */\n  double *ebder2=SISL_NULL; /* Triple array of dimension (ider+1)*k2*m2\n                         containing dericatives of B-splines. */\n  int *ileft1=SISL_NULL;    /* Array of dimension m1 containing the left knots\n                         of the B-splines in x. */\n  int *ileft2=SISL_NULL;    /* Array of dimension m2 containing the left knots\n                         of the B-splines in y. */\n  double *et1=SISL_NULL;    /* x knot vector. */\n  double *et2=SISL_NULL;    /* y knot vector. */\n\n\n  n1 = ps1 -> in1;\n  n2 = ps1 -> in2;\n  k1 = ps1 -> ik1;\n  k2 = ps1 -> ik2;\n  et1 = ps1 -> et1;\n  et2 = ps1 -> et2;\n  kdim = ps1 -> idim;\n\n  /* Check the input. */\n  if (kdim < 1) goto err102;\n  if (k1 < 1 || k2 < 1) goto err115;\n  if (n1 < k1 || n2 < k2) goto err116;\n  if (ider < 0) goto err178;\n\n  /* Pre-evaluate B-splines in x. */\n  ebder1 = newarray((ider+1)*k1*m1,DOUBLE);\n  if(ebder1 == SISL_NULL) goto err101;\n\n  ileft1 = newarray(m1,INT);\n  if(ileft1 == SISL_NULL) goto err101;\n\n  s1504(et1,k1,n1,x,m1,ider,ebder1,ileft1,&kstat);\n  if(kstat < 0) goto error;\n\n  /* Pre-evaluate B-splines in y. */\n  ebder2 = newarray((ider+1)*k2*m2,DOUBLE);\n  if(ebder2 == SISL_NULL) goto err101;\n  ileft2 = newarray(m2,INT);\n  if(ileft2 == SISL_NULL) goto err101;\n\n  s1504(et2,k2,n2,y,m2,ider,ebder2,ileft2,&kstat);\n  if(kstat < 0) goto error;\n\n  /* Multiply out with the coefficients. */\n\n  s1505(ps1,ider,m1,m2,ebder1,ebder2,\n      ileft1,ileft2,eder,norm,&kstat);\n  if(kstat < 0) goto error;\n\n  *jstat = 0;\n  goto out;\n\n  /* Not enough memory. */\n err101: *jstat = -101;\n  s6err(\"s1506\",*jstat,kpos);\n  goto out;\n\n  /* kdim less than 1. */\n err102: *jstat = -102;\n  s6err(\"s1506\",*jstat,kpos);\n  goto out;\n\n  /* Polynomial order less than 1. */\n err115: *jstat = -115;\n  s6err(\"s1506\",*jstat,kpos);\n  goto out;\n\n  /* Fewer B-splines than the order. */\n err116: *jstat = -116;\n  s6err(\"s1506\",*jstat,kpos);\n  goto out;\n\n  /* Illegal derivative requested. */\n err178: *jstat = -178;\n  s6err(\"s1221\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n error:  *jstat = kstat;\n  s6err(\"s1506\",*jstat,kpos);\n  goto out;\n\n out:\n  /* Free memory. */\n  if(ebder1 != SISL_NULL) freearray(ebder1);\n  if(ileft1 != SISL_NULL) freearray(ileft1);\n  if(ebder2 != SISL_NULL) freearray(ebder2);\n  if(ileft2 != SISL_NULL) freearray(ileft2);\n\n    return;\n}\n"
  },
  {
    "path": "src/s1507.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1507.c,v 1.3 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1507\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1507(SISLCurve **curves, int nc, int periodic,\n      SISLCurve ***newcurves, int *jstat)\n#else\nvoid s1507(curves, nc, periodic, newcurves, jstat)\n     SISLCurve **curves;\n     int nc;\n     int periodic;\n     SISLCurve ***newcurves;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To reparametrize a sequence of B-spline curves so that\n*              they are all parametrized over [0,1].\n*              The newly parametrized curves are then \"healed\" (i.e. altered\n*              near their end points) so that they connect with C1 continuity.\n*\n*              If periodic = 1, the healing will ensure that the\n*              last and first curves also join with $C^1$ continuity.\n*              Each B-spline curve must have at least four control points\n*              and rational B-splines are not currently supported.\n*\n*              One application of this routine is in lofting a sequence\n*              of piecewise G1 curves: a direct loft would only\n*              guarantee a C0 lofted surface but by preprocessing (and\n*              inevitably modifying) the curves to make them piecwise\n*              C1 first will ensure that the lofted surface will be C1.\n*\n* INPUT      : curves   - An array of pointers to B-spline curves.\n*              n        - Number of curves in the sequence.\n*              periodic - Should the curves join periodically?\n*\n* OUTPUT     : newcurves - A pointer to a new array of curves.\n*              jstat     - status messages\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : First the parameter intervals are scaled to [0,1] and\n*              then the first two and last two control points in each\n*              curve are altered to ensure both C1 continuity and that\n*              the new curves are as close to the originals as possible\n*              (in the sense of l2 in the control points).\n*\n* REFERENCES :\n*\n*\n* CALLS      :\n*\n* WRITTEN BY : Michael Floater, SINTEF, September 1998.\n*\n**********************************************************************/\n{\n  int kpos = 0;\t\t\t/* Position of error                        */\n\n  int i,j;                      /* Loop variables.                          */\n\n  int k,k1,k2;                  /* Order of B-spline curve                  */\n  int n;                        /* Dimension of spline space                */\n  int dim;                      /* Euclidean space dimension                */\n  int inext;                    /* Usually i+1                              */\n  int nheal;                    /* Number of joins between curves:\n                                   = number of curves - 1 unless\n                                   the periodic flag is 1.                  */\n\n  SISLCurve **curves2;          /* Local array of SISL curves               */\n\n  double startpar;              /* Start of parameter interval of a curve.  */\n  double endpar;                /* Start of parameter interval of a curve.  */\n  double len;                   /* Length of parameter interval of a curve. */\n  double average;               /* average of coeff.s from adjacent curves. */\n  double c1,c2,c3;              /* Three B-spline coefficients.             */\n  double knotdiff1,knotdiff2;   /* numbers                                  */\n  double lambda,denom;          /* more numbers                             */\n\n\n  *jstat = 0;\n\n  if( (curves2=newarray(nc,SISLCurve*)) == SISL_NULL) goto err101;\n  memzero(curves2, nc, SISLCurve*);\n\n  if (nc <= 0) goto err102;\n  if (nc == 1) goto out; /* nothing to heal */\n\n  dim = curves[0]->idim;\n\n  /* Check input data. */\n  for(i=0; i<nc; i++)\n  {\n    /* Check that the curves have the same dimension. */\n    if(curves[i]->idim != dim) goto err102;\n\n    /* Check that the curves are not rational. */\n    if(curves[i]->ikind == 2 || curves[i]->ikind == 4) goto err102;\n\n    /* Check that the curve has at least four control points\n       (because we're going to tweak the first two to get C1 continuity\n        with the previous curve and the last two to get C1 continuity\n        with the next curve). */\n    n = curves[i]->in;\n    if(n < 4) goto err102;\n  }\n\n  /* Scale each parameter interval to [0,1]. */\n  for(i=0; i<nc; i++)\n  {\n    /* Make a copy of the curve. */\n    curves2[i] = copyCurve(curves[i]);\n\n    /* Scale the knots to go from 0 to 1. */\n    n = curves2[i]->in;\n    k  = curves2[i]->ik;\n    startpar = curves2[i]->et[k-1];\n    endpar = curves2[i]->et[n];\n    len = endpar - startpar;\n\n    for(j=0; j<n+k; j++)\n    {\n      curves2[i]->et[j]  = (curves2[i]->et[j] - startpar) / len;\n    }\n  }\n\n  /* How many healing operations are there? */\n\n  nheal = (periodic == 0 ? nc - 1 : nc);\n\n  /* Heal curves to get C^0 continuity. */\n\n  for(i=0; i<nheal; i++)\n  {\n    inext = (i < nc-1 ? i+1 : 0);\n\n    n = curves2[i]->in;\n    for(k=0; k<dim; k++)\n    {\n      average = (curves2[i]->ecoef[dim*(n-1)+k] +\n                 curves2[inext]->ecoef[k]) * 0.5;\n      curves2[i]->ecoef[dim*(n-1)+k] = average;\n      curves2[inext]->ecoef[k] = average;\n    }\n  }\n\n\n  /* Heal curves to get C^1 continuity. */\n  /* For each consecutive pair of curves, alter the three\n     relevant control points c1, c2, c3\n     (where c1 and c2 are the last two control points of the previous curve and\n      c2 and c3 are the first two control points of the next curve:\n      remember we have already fixed C0 continuity earlier in this routine)\n     so that the three new points d1, d2, d3 are such that\n     (c1-d1)^2 + (c2-d2)^2 + (c3-d3)^2 is minimized subject to\n     the C1-continuity constraint which is of the form\n       d2 = (1-lambda) d1 + lambda d3\n     where lambda is a function of the two local knot intervals.\n     The formula for d1,d2,d3 can be found by hand is used directly\n     below. */\n\n  for(i=0; i<nheal; i++)\n  {\n    inext = (i < nc-1 ? i+1 : 0);\n\n    n = curves2[i]->in;\n    k1 = curves2[i]->ik;\n    k2 = curves2[inext]->ik;\n\n    knotdiff1 = (curves2[i]->et[n+k1-2] - curves2[i]->et[n-1])\n                    / (double)(k1-1);\n    knotdiff2 = (curves2[inext]->et[k2] - curves2[inext]->et[1])\n                    / (double)(k2-1);\n    lambda = knotdiff2 / (knotdiff1 + knotdiff2);\n    denom = 2.0 * (1.0 - lambda + lambda*lambda);\n\n    for(k=0; k<dim; k++)\n    {\n      c1 = curves2[i]->ecoef[dim*(n-2)+k];\n      c2 = curves2[inext]->ecoef[k];\n            /* = curves2[i]->ecoef[dim*(n-1)+k] by C0 continuity. */\n      c3 = curves2[inext]->ecoef[dim+k];\n\n      curves2[i]->ecoef[dim*(n-2)+k]\n        = ( (1.0 + lambda*lambda) * c1 + (1.0 - lambda) * c2\n           - lambda * (1.0 - lambda) * c3 ) / denom;\n\n      curves2[inext]->ecoef[dim+k]\n        = ( - lambda * (1.0 - lambda) * c1 + lambda * c2\n           + (1.0 + (1.0 - lambda)*(1.0 - lambda)) * c3 ) / denom;\n\n      curves2[i]->ecoef[dim*(n-1)+k]\n        = (1.0 - lambda) * curves2[i]->ecoef[dim*(n-2)+k]\n          + lambda * curves2[inext]->ecoef[dim+k];\n\n      curves2[inext]->ecoef[k]\n        = (1.0 - lambda) * curves2[i]->ecoef[dim*(n-2)+k]\n          + lambda * curves2[inext]->ecoef[dim+k];\n    }\n  }\n\n\n  *newcurves = curves2;\n\n  goto out;\n\n  /* Error in space allocation */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1507\", *jstat, kpos);\n  goto out;\n\n  /* Error in input. */\n\nerr102:\n  *jstat = -102;\n  goto out;\n\nout:\n\n  return;\n}\n"
  },
  {
    "path": "src/s1508.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n\n\n#define S1508\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1508(int inbcrv, SISLCurve **vpcurv, double par_arr[],\n       SISLSurf **rsurf, int *jstat)\n#else\nvoid\ns1508(inbcrv, vpcurv, par_arr,\n      rsurf, jstat)\n     int inbcrv;\n     SISLCurve **vpcurv;\n     double par_arr[];\n     SISLSurf **rsurf;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To create a rational B-spline lofted surface\n*              from a set of rational B-spline input-curves.\n*\n* INPUT      : inbcrv - Number of curves in the curve-set.\n*              vpcurv  - Array (length inbcrv) of pointers to the\n*                       curves in the curve-set.\n*              par_arr - The required parameterisation, must be\n*                        strictly increasing, length inbcrv.\n*\n* OUTPUT     : rsurf  - Pointer to the surface produced.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error.\n*\n* METHOD     : A common basis for all the B-spline curves are found.\n*              The curves are represented using this basis.\n*              The resulting curves are given to an interpolation\n*              routine that calculates the B-spline vertices of the\n*              resulting spline lofted surface.\n*              The surface will be C1 and cubic in the lofting direction.\n*              Throughout these routines, first parameter direction\n*              will be the interpolating direction, second parameter-\n*              direction will be along the input curves.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1931,s1917,s1918,s1358,s6err.\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, October 1993.\n*\n*********************************************************************\n*/\n{\n  int kind, kcopy, kdim;\n  int kn1, kord1;\n  int i,ki,kj,kk;         /* Loop variables. */\n  SISLCurve *qc;\t  /* Pointer to curve representing surface */\n  double *sknot1 = SISL_NULL;  /* Knot vector. */\n  double *scoef2 = SISL_NULL;  /* Pointer to vertices expressed in same basis  */\n  int kstat = 0;\t  /* Status variable. */\n  int kpos = 0;\t\t  /* Position of error. */\n  double *epcoef;\n  double *evcoef;\n  double *epweight;\n  double *evweight;\n  double *epweight2;\n  double *evweight2;\n  double *evnew;\n  double *hvcoef;\n\n  SISLCurve **ratcurves=SISL_NULL;\n\n\n\n  *jstat = 0;\n\n\n  /* Check input. */\n\n  if(inbcrv < 2) goto err179;\n\n  /* Initiate variables. */\n\n  kdim = vpcurv[0]->idim;\n\n  /* Convert the rational curves to homogeneous form.\n     The temporary homogeneous curves only point to\n     existing arrays so no major copying is required. */\n\n  ratcurves = newarray(inbcrv,SISLCurve*);\n  for(i=0; i<inbcrv; i++)\n  {\n    /* Just set pointers to the homogeneous coordinates. */\n    ratcurves[i] = newCurve(vpcurv[i]->in,vpcurv[i]->ik,vpcurv[i]->et,\n                            vpcurv[i]->rcoef,1,kdim+1,0);\n  }\n\n  /* Put the curves into common basis. */\n\n  s1931 (inbcrv, ratcurves, &sknot1, &scoef2, &kn1, &kord1, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* scoef2 now holds homogeneous coordinates.\n     Calculate control points and weights. */\n\n  /* Allocate array for points and weights */\n\n  epcoef    = newarray(kdim*inbcrv*kn1,DOUBLE);\n  if (epcoef == SISL_NULL) goto err101;\n\n  evcoef    = newarray(kdim*inbcrv*kn1,DOUBLE);\n  if (evcoef == SISL_NULL) goto err101;\n\n  epweight    = newarray(inbcrv*kn1,DOUBLE);\n  if (epweight == SISL_NULL) goto err101;\n\n  evweight    = newarray(inbcrv*kn1,DOUBLE);\n  if (evweight == SISL_NULL) goto err101;\n\n  epweight2    = newarray(inbcrv*kn1,DOUBLE);\n  if (epweight2 == SISL_NULL) goto err101;\n\n  evweight2    = newarray(inbcrv*kn1,DOUBLE);\n  if (evweight2 == SISL_NULL) goto err101;\n\n\n  for(ki=0,kj=0,kk=0; ki<inbcrv*kn1; ki++,kj+=(kdim+1),kk+=kdim)\n  {\n      for(i=0; i<kdim; i++)\n      {\n          epcoef[kk+i] = scoef2[kj+i] / scoef2[kj+kdim];\n      }\n\n      epweight[ki] = scoef2[kj+kdim];\n  }\n\n\n  /* Estimate derivative for control points and weights. */\n\n  s1516(epcoef,par_arr,inbcrv,kn1*kdim,&evcoef,&kstat);\n  if (kstat < 0) goto error;\n\n  s1516(epweight,par_arr,inbcrv,kn1,&evweight,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Adjust weight derivatives so that weight function is positive. */\n\n  /* First change parameter direction. */\n\n  s6chpar(epweight,kn1,inbcrv,1,epweight2);\n  s6chpar(evweight,kn1,inbcrv,1,evweight2);\n\n  for(ki=0,kk=0; ki<kn1; ki++,kk+=inbcrv)\n  {\n      s1517(epweight2+kk,evweight2+kk,par_arr,inbcrv,0.0,&evnew,&kstat);\n      if (kstat < 0) goto error;\n\n      memcopy(evweight2+kk,evnew,inbcrv,double);\n      freearray(evnew);\n\n  }\n\n  /* Change back parameter direction. */\n\n  s6chpar(evweight2,inbcrv,kn1,1,evweight);\n\n  /* Allocate array for homogeneous derivatives. */\n\n  hvcoef    = newarray(inbcrv*kn1*(kdim+1),DOUBLE);\n  if (hvcoef == SISL_NULL) goto err101;\n\n  /* Use product rule to estimate derivatives for\n     homogeneous coordinates. */\n\n  for(ki=0,kj=0,kk=0; ki<kn1*inbcrv; ki++,kj+=kdim,kk+=(kdim+1))\n  {\n      for(i=0; i<kdim; i++)\n      {\n          hvcoef[kk+i] = epcoef[kj+i] * evweight[ki]\n\t\t\t + evcoef[kj+i] * epweight[ki];\n      }\n\n      hvcoef[kk+kdim] = evweight[ki];\n  }\n\n\n  /* Create C^1 cubic B-splines coefficients of the Hermite interpolant\n     to the weights and control points. */\n\n  s1379(scoef2,hvcoef,par_arr,inbcrv,kn1*(kdim+1),&qc,&kstat);\n  if (kstat < 0) goto error;\n\n\n  /* Create the surface */\n\n  kind = 2;\n  kcopy = 1;\n\n  /* The surface is turned so that u is along the curves, v is across\n     the curves in the lofting direction. */\n\n  *rsurf = newSurf (kn1, qc->in, kord1, qc->ik, sknot1, qc->et, qc->ecoef,\n\t\t    kind, kdim, kcopy);\n  if (*rsurf == SISL_NULL)\n    goto err171;\n\n  /* Release the curve object */\n\n  if (qc != SISL_NULL)\n    freeCurve (qc);\n\n\n  /* Task done */\n\n  goto out;\n\n\n  /* Error in allocation. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1508\", *jstat, kpos);\n  goto out;\n\n  /* Could not create surface. */\n\nerr171:\n  *jstat = -171;\n  s6err (\"s1508\", *jstat, kpos);\n  goto out;\n\n  /* Error in interpolation conditions. No. of curves < 2. */\n\nerr179:\n  *jstat = -179;\n  s6err (\"s1508\", *jstat, kpos);\n  goto out;\n\n\n  /* Error in lower level routine.  */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1508\", *jstat, kpos);\n  goto out;\n\n  /* Free allocated scratch  */\n\nout:\n  if (sknot1 != SISL_NULL)\n    freearray (sknot1);\n  if (scoef2 != SISL_NULL)\n    freearray (scoef2);\n\n  if (ratcurves != SISL_NULL)\n  {\n    for(i=0; i<inbcrv; i++)\n    {\n      if(ratcurves[i] != SISL_NULL) freeCurve(ratcurves[i]);\n    }\n    freearray(ratcurves);\n  }\n  if (epcoef != SISL_NULL) freearray(epcoef);\n  if (evcoef != SISL_NULL) freearray(evcoef);\n  if (epweight != SISL_NULL) freearray(epweight);\n  if (evweight != SISL_NULL) freearray(evweight);\n  if (epweight2 != SISL_NULL) freearray(epweight2);\n  if (evweight2 != SISL_NULL) freearray(evweight2);\n  if (hvcoef != SISL_NULL) freearray(hvcoef);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1510.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1510.c,v 1.2 2001-03-19 15:58:50 afr Exp $\n *\n */\n\n\n#define S1510\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1510(SISLSurf * ps, double eyepoint[], int idim, double aepsco, \n\t   double aepsge, int *jpt, double **gpar, int *jcrv, \n\t   SISLIntcurve *** wcurve, int *jstat)\n#else\nvoid s1510(ps,eyepoint,idim, aepsco, aepsge, jpt, gpar, jcrv, wcurve, jstat)\n     SISLSurf *ps;\n     double eyepoint[];\n     int idim;\n     double aepsco;\n     double aepsge;\n     int *jpt;\n     double **gpar;\n     int *jcrv;\n     SISLIntcurve ***wcurve;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find the silhouette curves and points of a surface when\n*              the surface is viewed perspectively from a specific eye point. \n*              In addition to the points and curves found by this routine,\n*              break curves and edge-curves might be silhouette curves.\n*\n*\n*\n* INPUT      : ps  -       Pointer to the surface.\n*              eyepoint -  The eye point vector.\n*              idim   -    Dimension of the space in which eyepoint lies.\n*              aepsco -    Computational resolution.\n*              aepsge -    Geometry resolution.\n*\n*\n*\n* OUTPUT     : jpt    - Number of single silhouette points.\n*              gpar   - Array containing the parameter values of the\n*                       single silhouette points in the parameter\n*                       plane of the surface. The points lie continuous.\n*                       Silhouette curves are stored in wcurve.\n*              jcrv   - Number of silhouette curves.\n*              wcurve - Array containing descriptions of the silhouette\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n* REFERENCES : Main routine written by Mike Floater, SI, 1990.\n*\n* CALLS      : sh1510, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;           /* Local status variable.                       */\n  int kpos = 0;            /* Position of error.                           */\n  int i;\n  int trackflag = 0;\n  int jtrack;\n  int *pretop=SISL_NULL;\n  SISLTrack **wtrack=SISL_NULL;\n  int jsurf;\n  SISLIntsurf **wsurf=SISL_NULL;\n\n  sh1510(ps, eyepoint, idim, aepsco, aepsge,trackflag,&jtrack,&wtrack,\n\t jpt,gpar,&pretop,jcrv,wcurve,&jsurf,&wsurf,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  for(i=0; i<jsurf; i++)\n    freeIntsurf(wsurf[i]);\n  if(wsurf != SISL_NULL) freearray(wsurf);\n\n  if(jsurf > 0) \n    *jstat=10;\n  else \n    *jstat = kstat;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error:\n    *jstat = kstat;\n    s6err (\"s1510\", *jstat, kpos);\n    goto out;\n\n  out:\n    return;\n}\n"
  },
  {
    "path": "src/s1511.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1511.c,v 1.3 2001-03-19 15:58:50 afr Exp $\n *\n */\n\n\n#define S1511\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1511(SISLSurf *ps,double qpoint [],double bvec [],int idim,\n\t   double aepsco,double aepsge,int *jpt,double **gpar,int *jcrv,\n\t   SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1511(ps,qpoint,bvec,idim,aepsco,aepsge,jpt, gpar, jcrv, wcurve, jstat)\n     SISLSurf *ps;\n     double qpoint[];\n     double bvec[];\n     int idim;\n     double aepsco;\n     double aepsge;\n     int *jpt;\n     double **gpar;\n     int *jcrv;\n     SISLIntcurve ***wcurve;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find the circular silhouette curves and points of a surface.\n*              In addition to the points and curves found by this routine,\n*              break curves and edge-curves might be silhouette curves.\n*\n*\n*\n* INPUT      : ps  -      Pointer to the surface.\n*              qpoint -   A point on the spin axis.\n*              bvec  -    The circular silhouette axis direction.\n*              idim   -   Dimension of the space in which axis lies.\n*              aepsco -   Computational resolution.\n*              aepsge -   Geometry resolution.\n*\n*\n*\n* OUTPUT     : jpt    - Number of single silhouette points.\n*              gpar   - Array containing the parameter values of the\n*                       single silhouette points in the parameter\n*                       plane of the surface. The points lie continuous.\n*                       Silhouette curves are stored in wcurve.\n*              jcrv   - Number of silhouette curves.\n*              wcurve - Array containing descriptions of the silhouette\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES : Main routine written by Mike Floater, SI, 1990.\n*\n* CALLS      : sh1511, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;              /* Local status variable.                      */\n  int kpos = 0;               /* Position of error.                          */\n  int i;\n  int trackflag = 0;\n  int jtrack;\n  SISLTrack **wtrack=SISL_NULL;\n  int jsurf;\n  SISLIntsurf **wsurf=SISL_NULL;\n  int *pretop=SISL_NULL;\n\n  sh1511(ps,qpoint, bvec, idim, aepsco, aepsge, trackflag,&jtrack,\n\t &wtrack,jpt,gpar,&pretop,jcrv,wcurve,&jsurf,&wsurf,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  for(i=0; i<jsurf; i++)\n    freeIntsurf(wsurf[i]);\n  if(wsurf != SISL_NULL) freearray(wsurf);\n\n  if(jsurf > 0)\n    *jstat=10;\n  else\n    *jstat = kstat;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error:\n    *jstat = kstat;\n    s6err (\"s1511\", *jstat, kpos);\n    goto out;\n\n  out:\n    return;\n}\n"
  },
  {
    "path": "src/s1512.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1512.c,v 1.2 2001-03-19 15:58:50 afr Exp $\n *\n */\n\n\n#define S1512\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1512 (SISLSurf * psurf, double eyepoint[], int idim, \n\tSISLSurf ** rsurf, int *jstat)\n#else\nvoid \ns1512 (psurf, eyepoint, idim, rsurf, jstat)\n     SISLSurf *psurf;\n     double eyepoint[];\n     int idim;\n     SISLSurf **rsurf;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To make the function whose zeroes describes the perspective silhouette\n*              lines of a surface. The perspective silhouette lines are defined\n*              by an eyepoint.\n*\n*\n*\n* INPUT      : psurf  - Pointer to input surface\n*              eyepoint  - Eyepoint vector.\n*\n*\n*\n* OUTPUT     : rsurf  - The resulting surface\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : We first make the appropriate knot vector, then we calulate\n*              parameter values for the interpolation, then the positions and normal\n*              vectors of the surface are calculated at these parameter\n*              values. The function f(u,v)\n*              is calculated at the parameter values and these f values are interpolated\n*              to put f, which describes the silhouette lines, into B-spline form.\n*\n*              For nonrational surfaces the function whose zeroes form the\n*              silhouette is\n*\n*                      f = N . (P - eyepoint) = (P xP ) . (P - eyepoint)\n*                                                 U  V\n*\n*              which, if P is degree m x n, is degree 3m-1 x 3n-1\n*              or order 3(m+1)-3 x 3(n+1)-3.\n*              In the rational case, setting  P(U,V) = T(U,V) / w(U,V), we find\n*\n*                                                     4\n*                      P xP =(wT -w T) x (wT -w T) / w\n*                       U  V    U  U        V  V\n*\n*                                                      3\n*                           =(wT xT +w T xT+w TxT ) / w\n*                               U  V  U V    V   U\n*\n*              so we find the zeroes of\n*\n*                      f = (wT xT +w T xT+w TxT ) . (T - w*eyepoint)\n*                             U  V  U V    V   U\n*\n*              which, if P is degree m x n, is degree 4m-1 x 4n-1\n*              or order 4(m+1)-4 x 4(n+1)-4.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Mike Floater, SI, 1990-11\n* REVISED BY : Mike Floater, SI, 1991-04 for rational surfaces\n*\n*********************************************************************\n*/\n{\n  double diff[3];\t\t/* Difference between surface point and eye point   */\n  int kn1;\t\t\t/* Number of vertices of psurf in first par.dir     */\n  int kk1;\t\t\t/* Order in  psurf in first par.dir                 */\n  int kn2;\t\t\t/* Number of vertices of psurf in second par.dir    */\n  int kk2;\t\t\t/* Order in  psurf in second par.dir                */\n  int kjkk1;\t\t\t/* Order of interpolated basis in first par.dir     */\n  int kjkn1;\t\t\t/* Number of vertices in interpolated basis first.dr*/\n  int kjkk2;\t\t\t/* Order of interpolated basis in first par dir     */\n  int kjkn2;\t\t\t/* Number of vertices in interpolated basis secnd.dr*/\n  int kdim;\t\t\t/* Number of dimesions in psurf                     */\n  int kstat = 0;\t\t/* Local status variable                            */\n  int kpos = 0;\t\t\t/* Position indicator for errors                    */\n  int kzero = 0;\t\t/* Value 0                                          */\n  int kone = 1;\t\t\t/* Value 1                                          */\n  int cuopen;\t\t\t/* Open/Closed flag                                  */\n  int ki, kj;\t   \t        /* Loop control variable                            */\n  int kp;\t\t\t/* Index of points put into conic equation          */\n  int klfs = 0;\t\t\t/* Pointer into knot vector                         */\n  int klft = 0;\t\t\t/* Pointer into knot vector                         */\n\n  double *st1   = SISL_NULL;\t\t/* First knot vector is psurf                       */\n  double *st2   = SISL_NULL;\t\t/* Second knot vector is psurf                      */\n  double *sval1 = SISL_NULL;\t\t/* Array of values of surface put into torus eq.    */\n  double *sval2 = SISL_NULL;\n  double *sval3 = SISL_NULL;\n  \n  double *sgt1  = SISL_NULL;\t\t/* Knot vector in first parameter direction of\n\t\t\t\t   surface put into torus equation                  */\n  double *sgt2  = SISL_NULL;\t\t/* Knot vector in second parameter direction of\n\t\t\t\t   surface put into torus equation                  */\n  double sder[12];\t\t/* Point on the surface                             */\n  double spar[2];\t\t/* Current parameter pair                           */\n  double snorm[3];\t\t/* Normal vector                                    */\n  int i;\t\t\t/* a loop variable                                  */\n  int ikind;\t\t\t/* kind of surface psurf is                         */\n  double tutv[3];\t\t/* T_u x T_v  in rational case                      */\n  double tvt[3];\t\t/* T_v x T    in rational case                      */\n  double ttu[3];\t\t/* T   x T_u  in rational case                      */\n  SISLSurf *tempsurf = SISL_NULL;    /* only used for rational surfaces                  */\n  double *par1=SISL_NULL;\n  double *par2=SISL_NULL;\n  int    *der1=SISL_NULL;\n  int    *der2=SISL_NULL;\n\n  if (idim != psurf->idim) goto err104;\n  \n  /* Make local pointers */\n\n  kn1 = psurf->in1;\n  kk1 = psurf->ik1;\n  kn2 = psurf->in2;\n  kk2 = psurf->ik2;\n  kdim = psurf->idim;\n  st1 = psurf->et1;\n  st2 = psurf->et2;\n  ikind = psurf->ikind;\n\n  if (ikind == 2 || ikind == 4)\n    {\n      /* A tricky way to evaluate the derivatives of the HOMOGENEOUS form\n\t of psurf. In other words we need the derivs of T(u,v) where\n\t p(u,v) = T(u,v) / w(u,v).\n\t We should really have a separate evaluator for this\n\t but I didn't want to mess around with the existing evaluator\n\t which does the division automatically. MF 16/4/91 \n\t */\n      \n      tempsurf = newSurf (kn1, kn2, kk1, kk2, st1, st2, psurf->rcoef, ikind - 1, kdim + 1, 0);\n      if (tempsurf == SISL_NULL) goto err171;\n\t\t\t    \n      tempsurf->cuopen_1 = psurf->cuopen_1;\n      tempsurf->cuopen_2 = psurf->cuopen_2;\n      \n      kjkk1 = 4 * kk1 - 4;\n      kjkk2 = 4 * kk2 - 4;\n    }\n  else\n    {\n      tempsurf = psurf;\n      kjkk1 = 3 * kk1 - 3;\n      kjkk2 = 3 * kk2 - 3;\n    }\n\n  /* Test input */\n\n  if (kdim != 3)\n    goto err104;\n\n  /* Make description of knot array for interpolation in first parameter\n     direction */\n\n  s1381 (st1, kn1, kk1, &sgt1, &kjkn1, kjkk1, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Make parameter values and derivative indicators */\n\n  s1890(sgt1,kjkk1,kjkn1,&par1,&der1,&kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Make description of knot array for interpolation in second parameter\n     direction\n     */\n\n  s1381 (st2, kn2, kk2, &sgt2, &kjkn2, kjkk2, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Make parameter values and derivative indicators */\n\n  s1890(sgt2,kjkk2,kjkn2,&par2,&der2,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Allocate array for values of surface put into f(u,v) equation */\n\n  sval1 = newarray (kjkn1 * kjkn2, DOUBLE);\n  if (sval1 == SISL_NULL)\n    goto err101;\n\n  /* Calculate values to be interpolated */\n\n  /* Index of point to be stored */\n\n  kp = 0;\n\n  for (kj = 0; kj < kjkn2; kj++)\n    {\n\n      spar[1] = par2[kj];\n\n      for (ki = 0; ki < kjkn1; ki++)\n\t{\n\t  /* Calculate values on 3-D surface */\n\n\t  spar[0] = par1[ki];\n\n\t  s1421 (tempsurf, 1, spar, &klfs, &klft, sder, snorm, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  if (ikind == 2 || ikind == 4)\n\t    {\n\t      /* Calculate  (wT xT +w T xT+w TxT )\n\t                       U  V  U V    V   U\n                 instead of normal to surface in rational case. */\n\n\t      s6crss (sder + 4, sder + 8, tutv);\n\t      s6crss (sder + 8, sder, tvt);\n\t      s6crss (sder, sder + 4, ttu);\n\t      for (i = 0; i < 3; i++)\n\t\t{\n\t\t  snorm[i] = sder[3] * tutv[i] + sder[7] * tvt[i] + sder[11] * ttu[i];\n\t\t  diff[i] = sder[i] - sder[3] * eyepoint[i];\n\t\t}\n\t    }\n\t  else\n\t    {\n\t      s6diff (sder, eyepoint, kdim, diff);\n\t    }\n\n\t  /* Make function f(u,v) = N(u,v) . ( P(u,v) - eyepoint )    */\n\n\t  sval1[kp++] = s6scpr (snorm, diff, kdim);\n\t}\n    }\n\n  cuopen = TRUE;\n\n  /* Interpolate in second parameter direction, the first parameter direction\n     is treated as a point of dimension kjkn1 */\n\n  s1891(par2,sval1,kjkn1,kjkn2,kone,der2,cuopen,sgt2,&sval2,&kjkn2,kjkk2,kzero,kzero,&kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Interpolate in first parameter direction, perform kjkn2 interpolations\n     of one dimensional data */\n\n  s1891(par1,sval2,kone,kjkn1,kjkn2,der1,cuopen,sgt1,&sval3,&kjkn1,kjkk1,kzero,kzero,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  *rsurf = SISL_NULL;\n  *rsurf = newSurf (kjkn1, kjkn2, kjkk1, kjkk2, sgt1, sgt2, sval3, 1, 1, 1);\n\n  if (*rsurf == SISL_NULL)\n    goto err171;\n    \n  (*rsurf)->cuopen_1 = psurf->cuopen_1;  \n  (*rsurf)->cuopen_2 = psurf->cuopen_2;  \n\n  /* Ok ! */\n\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level function */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1512\", *jstat, kpos);\n  goto out;\n\n  /* Error in space allocation */\nerr101:\n  *jstat = -101;\n  s6err (\"s1512\", *jstat, kpos);\n  goto out;\n\n  /* Dimension not equal to 3 or conflicting dim   */\n\nerr104:\n  *jstat = -104;\n  s6err (\"s1512\", *jstat, kpos);\n  goto out;\n\n  /* Could not create surfe */\n\nerr171:\n  *jstat = -171;\n  s6err (\"s1512\", *jstat, kpos);\n  goto out;\n\nout:\n\n  /* Release allocated arrays */\n\n  if (sgt1 != SISL_NULL)\n    freearray (sgt1);\n  if (sgt2 != SISL_NULL)\n    freearray (sgt2);\n\n  if (sval1 != SISL_NULL)\n    freearray (sval1);\n  if (sval2 != SISL_NULL)\n    freearray (sval2);\n  if (sval3 != SISL_NULL)\n    freearray (sval3);\n  if (par1 != SISL_NULL)\n    freearray(par1);\n  if (par2 != SISL_NULL)\n    freearray(par2);\n  if (der1 != SISL_NULL)\n    freearray(der1);\n  if (der2 != SISL_NULL)\n    freearray(der2);\n  if ((ikind == 2 || ikind == 4) && (tempsurf != SISL_NULL))\n    freeSurf (tempsurf);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1513.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1513.c,v 1.2 2001-03-19 15:58:50 afr Exp $\n *\n */\n\n\n#define S1513\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1513 (SISLSurf * psurf, double qpoint[], double bvec[], int idim, \n\tSISLSurf ** rsurf, int *jstat)\n#else\nvoid \ns1513 (psurf, qpoint, bvec, idim, rsurf, jstat)\n     SISLSurf *psurf;\n     double qpoint[];\n     double bvec[];\n     int idim;\n     SISLSurf **rsurf;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To make the function whose zeroes describes the circular silhouette\n*              lines of a surface. The circular silhouette lines are defined\n*              by a point qpoint and an axis bvec.\n*                f(u,v) = N(u,v) x (P(u,v) - Q) . B = 0\n*\n*\n*\n* INPUT      : psurf  - Pointer to input surface\n*              qpoint  - Point on axis vector.\n*              bvec  - Spin axis vector.\nB\n*\n*\n*\n* OUTPUT     : rsurf  - The resulting surface\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : We first make the appropriate knot vector, then we calulate\n*              parameter values for the interpolation, then the positions and normal\n*              vectors of the surface are calculated at these parameter\n*              values. The function f(U,V)\n*              is calculated at the parameter values and these f values are interpolated\n*              to put f, which describes the silhouette lines, into B-spline form.\n*\n*              For nonrational surfaces the function whose zeroes form the\n*              silhouette is\n*\n*                      f = N(U,V) x (P(U,V) - Q) . B  = (P xP ) x (P - Q) . B\n*                                                         U  V\n*\n*              which, if P is degree m x n, is degree 3m-1 x 3n-1\n*              or order 3(m+1)-3 x 3(n+1)-3.\n*              In the rational case, setting  P(U,V) = T(U,V) / w(U,V), we find\n*\n*                                                     4\n*                      P xP =(wT -w T) x (wT -w T) / w\n*                       U  V    U  U        V  V\n*\n*                                                      3\n*                           =(wT xT +w T xT+w TxT ) / w\n*                               U  V  U V    V   U\n*\n*              so we find the zeroes of\n*\n*                      f = (wT xT +w T xT+w TxT ) x (T - wQ) . B\n*                             U  V  U V    V   U\n*\n*              which, if P is degree m x n, is degree 4m-1 x 4n-1\n*              or order 4(m+1)-4 x 4(n+1)-4.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Mike Floater, SI, 1990-11\n* REVISED BY : Mike Floater, SI, 1991-04 for rational surfaces\n*\n*********************************************************************\n*/\n{\n  double cross[3];\t\t/* Cross product of norm and diff                   */\n  double diff[3];\t\t/* Difference between surface point and eye point   */\n  int kn1;\t\t\t/* Number of vertices of psurf in first par.dir     */\n  int kk1;\t\t\t/* Order in  psurf in first par.dir                 */\n  int kn2;\t\t\t/* Number of vertices of psurf in second par.dir    */\n  int kk2;\t\t\t/* Order in  psurf in second par.dir                */\n  int kjkk1;\t\t\t/* Order of interpolated basis in first par.dir     */\n  int kjkn1;\t\t\t/* Number of vertices in interpolated basis first.dr*/\n  int kjkk2;\t\t\t/* Order of interpolated basis in first par dir     */\n  int kjkn2;\t\t\t/* Number of vertices in interpolated basis secnd.dr*/\n  int kdim;\t\t\t/* Number of dimesions in psurf                     */\n  int kstat;\t\t\t/* Local status variable                            */\n  int kpos = 0;\t\t\t/* Position indicator for errors                    */\n  int kzero = 0;\t\t/* Value 0                                          */\n  int kone = 1;\t\t\t/* Value 1                                          */\n  int cuopen;\t\t\t/* Open/Closed flag                                 */\n  int ki, kj;\t     \t        /* Loop control variable                            */\n  int kp;\t\t\t/* Index of points put into conic equation          */\n  int klfs = 0;\t\t\t/* Pointer into knot vector                         */\n  int klft = 0;\t\t\t/* Pointer into knot vector                         */\n\n  double *st1 = SISL_NULL;\t\t/* First knot vector is psurf                       */\n  double *st2 = SISL_NULL;\t\t/* Second knot vector is psurf                      */\n  double *sval1 = SISL_NULL;\t\t/* Array of values of surface put into torus eq.    */\n  double *sval2 = SISL_NULL;\n  double *sval3 = SISL_NULL;\n\n  double *sgt1 = SISL_NULL;\t\t/* Knot vector in first parameter direction of\n\t\t\t\t   surface put into torus equation                  */\n  double *sgt2 = SISL_NULL;\t\t/* Knot vector in second parameter direction of\n\t\t\t\t   surface put into torus equation                  */\n  double sder[12];\t\t/* Point on the surface                             */\n  double spar[2];\t\t/* Current parameter pair                           */\n  double snorm[3];\t\t/* Normal vector                                    */\n  int i;\t\t\t/* a loop variable                                  */\n  int ikind;\t\t\t/* kind of surface psurf is                         */\n  double tutv[3];\t\t/* T_u x T_v  in rational case                      */\n  double tvt[3];\t\t/* T_v x T    in rational case                      */\n  double ttu[3];\t\t/* T   x T_u  in rational case                      */\n  SISLSurf *tempsurf = SISL_NULL;\t/* only used for rational surfaces                  */\n  double *par1=SISL_NULL;\n  double *par2=SISL_NULL;\n  int    *der1=SISL_NULL;\n  int    *der2=SISL_NULL;\n\n\n  if (idim != psurf->idim) goto err104;\n\n  /* Make local pointers */\n\n  kn1 = psurf->in1;\n  kk1 = psurf->ik1;\n  kn2 = psurf->in2;\n  kk2 = psurf->ik2;\n  kdim = psurf->idim;\n  st1 = psurf->et1;\n  st2 = psurf->et2;\n  ikind = psurf->ikind;\n\n  /* Test input */\n\n  if (kdim != 3)\n    goto err104;\n\n  if (ikind == 2 || ikind == 4)\n    {\n      /* A tricky way to evaluate the derivatives of the HOMOGENEOUS form\n\t of psurf. In other words we need the derivs of T(u,v) where\n\t p(u,v) = T(u,v) / w(u,v).\n\t We should really have a separate evaluator for this\n\t but I didn't want to mess around with the existing evaluator\n\t which does the division automatically. MF 16/4/91 \n     */\n     \n      tempsurf = newSurf (kn1, kn2, kk1, kk2, st1, st2, psurf->rcoef, ikind - 1, kdim + 1, 0);\n      if (tempsurf == SISL_NULL) goto err171;\n\t\t\t    \n      tempsurf->cuopen_1 = psurf->cuopen_1;\t\t\t    \n      tempsurf->cuopen_2 = psurf->cuopen_2;\t\t\t    \n      kjkk1 = 4 * kk1 - 4;\n      kjkk2 = 4 * kk2 - 4;\n    }\n  else\n    {\n      tempsurf = psurf;\n      kjkk1 = 3 * kk1 - 3;\n      kjkk2 = 3 * kk2 - 3;\n    }\n\n  /* Make description of knot array for interpolation in first parameter\n     direction */\n\n  s1381 (st1, kn1, kk1, &sgt1, &kjkn1, kjkk1, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Make parameter values and derivative indicators */\n\n  s1890(sgt1,kjkk1,kjkn1,&par1,&der1,&kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Make description of knot array for interpolation in second parameter\n     direction\n     */\n\n  s1381 (st2, kn2, kk2, &sgt2, &kjkn2, kjkk2, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Make parameter values and derivative indicators */\n\n  s1890(sgt2,kjkk2,kjkn2,&par2,&der2,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Allocate array for values of surface put into torus equation */\n\n  sval1 = newarray (kjkn1 * kjkn2, DOUBLE);\n  if (sval1 == SISL_NULL)\n    goto err101;\n\n  /* Calculate values to be interpolated */\n\n  /* Index of point to be stored */\n\n  kp = 0;\n\n  for (kj = 0; kj < kjkn2; kj++)\n    {\n\n      spar[1] = par2[kj];\n\n      for (ki = 0; ki < kjkn1; ki++)\n\t{\n\t  /* Calculate values on 3-D surface */\n\n\t  spar[0] = par1[ki];\n\n\t  s1421 (tempsurf, 1, spar, &klfs, &klft, sder, snorm, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  if (ikind == 2 || ikind == 4)\n\t    {\n\t      /* Calculate (wT xT +w T xT+w TxT )\n\t                      U  V  U V    V   U\n                 instead of normal to surface in rational case. */\n\n\t      s6crss (sder + 4, sder + 8, tutv);\n\t      s6crss (sder + 8, sder, tvt);\n\t      s6crss (sder, sder + 4, ttu);\n\t      for (i = 0; i < 3; i++)\n\t\t{\n\t\t  snorm[i] = sder[3] * tutv[i] + sder[7] * tvt[i] + sder[11] * ttu[i];\n\t\t  diff[i] = sder[i] - sder[3] * qpoint[i];\n\t\t}\n\t    }\n\t  else\n\t    {\n\t      s6diff (sder, qpoint, kdim, diff);\n\t    }\n\n\t  /* Make function f(u,v) = N(u,v) x ( P(u,v) - Q ) . B   */\n\n\t  s6crss (snorm, diff, cross);\n\t  sval1[kp++] = s6scpr (cross, bvec, kdim);\n\t}\n    }\n\n  cuopen = TRUE;\n\n  /* Interpolate in second parameter direction, the first parameter direction\n     is treated as a point of dimension kjkn1 */\n\n  s1891(par2,sval1,kjkn1,kjkn2,kone,der2,cuopen,sgt2,&sval2,&kjkn2,kjkk2,kzero,kzero,&kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Interpolate in first parameter direction, perform kjkn2 interpolations\n     of one dimensional data */\n\n  s1891(par1,sval2,kone,kjkn1,kjkn2,der1,cuopen,sgt1,&sval3,&kjkn1,kjkk1,kzero,kzero,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  if (kstat < 0)\n    goto error;\n\n  *rsurf = SISL_NULL;\n  *rsurf = newSurf (kjkn1, kjkn2, kjkk1, kjkk2, sgt1, sgt2, sval3, 1, 1, 1);\n\n  if (*rsurf == SISL_NULL)\n    goto err171;\n\n  (*rsurf)->cuopen_1 = psurf->cuopen_1;  \n  (*rsurf)->cuopen_2 = psurf->cuopen_2; \n  \n  /* Ok ! */\n\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level function */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1513\", *jstat, kpos);\n  goto out;\n\n  /* Error in space allocation */\nerr101:\n  *jstat = -101;\n  s6err (\"s1513\", *jstat, kpos);\n  goto out;\n\n  /* Error in dimension */\nerr104:\n  *jstat = -104;\n  s6err (\"s1513\", *jstat, kpos);\n  goto out;\n\n  /* Could not create surfe */\n\nerr171:\n  *jstat = -171;\n  s6err (\"s1513\", *jstat, kpos);\n  goto out;\n\nout:\n\n  /* Release allocated arrays */\n\n  if (sgt1 != SISL_NULL)\n    freearray (sgt1);\n  if (sgt2 != SISL_NULL)\n    freearray (sgt2);\n  if (sval1 != SISL_NULL)\n    freearray (sval1);\n  if (sval2 != SISL_NULL)\n    freearray (sval2);\n  if (sval3 != SISL_NULL)\n    freearray (sval3);\n  if (par1 != SISL_NULL)\n    freearray(par1);\n  if (par2 != SISL_NULL)\n    freearray(par2);\n  if (der1 != SISL_NULL)\n    freearray(der1);\n  if (der2 != SISL_NULL)\n    freearray(der2);\n  if ((ikind == 2 || ikind == 4) && (tempsurf != SISL_NULL))\n    freeSurf (tempsurf);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1514.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1514.c,v 1.4 2001-03-19 15:58:50 afr Exp $\n *\n */\n\n\n#define S1514\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1514 (SISLSurf * ps1, double eyepoint[], int idim, double aepsco, double aepsge,\n       double amax, SISLIntcurve * pintcr, int icur, int igraph, int *jstat)\n#else\nvoid\ns1514 (ps1, eyepoint, idim, aepsco, aepsge, amax, pintcr, icur, igraph, jstat)\n     SISLSurf *ps1;\n     double eyepoint[];\n     int idim;\n     double aepsco;\n     double aepsge;\n     double amax;\n     SISLIntcurve *pintcr;\n     int icur;\n     int igraph;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To march the perspective silhouette curve described by an intersection\n*              curve object, a B-spline surface and an eye point.\n*\n*\n* INPUT      : ps1    - Pointer to surface.\n*              eyepoint  - Eye point for perspective view\n*              idim   - Dimension of the space in which the eyepoint\n*                       lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              amax   - Maximal allowed step length. If amax <=aepsge\n*                       amax is neglected.\n*              icur   - Indicator telling if a 3-D curve is to be made\n*                        0 - Don't make 3-D curve\n*                        1 - Make 3-D curve\n*                        2 - Make 3-D curve and curves in parameter plane\n*              igraph - Indicator telling if the curve is to be outputted\n*                       through function calls:\n*                        0 - don't output curve through function call\n*                        1 - output as straight line segments through\n*                            s6move and s6line.\n*\n*\n*\n* INPUT/OUTPUT:pintcr - The intersection curve. When coming in as input\n*                       only parameter values in the parameter plane\n*                       exist. When coming as output the 3-D geometry\n*                       and possibly the curve in the parameter plane\n*                       of the surface is added.\n*\n* OUTPUT:      jstat  - status messages\n*                         = 3      : Iteration stopped due to singular\n*                                    point or degenerate surface. A part\n*                                    of intersection curve may have been\n*                                    traced out. If no curve is traced out\n*                                    the curve pointers in the Intcurve\n*                                    object point to SISL_NULL.\n*                         = 0      : ok\n*                         < 0      : error\n*                         = -185   : No points produced on intersection curve.\n*\n*\n* METHOD     : An implicit description of the problem is made and then\n*              a routine for intersecting implicit represented geometry\n*              by a B-spline surface is used.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err, s1313\n* WRITTEN BY : Mike Floater, SI, Oslo, Norway, 31 . January 1991\n*                a modification of s1319\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\t\t\t/* Position of error                                  */\n  int kdeg = 1004;\t\t/* The degree of the implicit equation                */\n  /* of the perspective silhouette                      */\n  int kstat;\t\t\t/* Local status variable                              */\n  double simpli[3];\t\t/* Array containing the implicit description          */\n  /* of the perspective silhouette                      */\n\n\n\n  if (idim != 3)\n    goto err104;\n\n\n  simpli[0] = eyepoint[0];\n  simpli[1] = eyepoint[1];\n  simpli[2] = eyepoint[2];\n\n  /* Make intersection of implicit surface and B-spline surface */\n\n  s1313 (ps1, simpli, kdeg, aepsco, aepsge, amax, pintcr, icur, igraph, &kstat);\n  if (kstat == -185)\n    goto err185;\n  if (kstat < 0)\n    goto error;\n\n  *jstat = kstat;\n  goto out;\n\n  /* Dimension not 3 */\n\nerr104:\n  *jstat = -104;\n  s6err (\"s1514\", *jstat, kpos);\n  goto out;\n\n  /* Couldn't march */\n\nerr185:\n  *jstat = -185;\n  goto out;\n\n  /* Error in lower level routine.  */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1514\", *jstat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1515.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1515.c,v 1.6 2001-03-19 15:58:50 afr Exp $\n *\n */\n\n\n#define S1515\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1515 (SISLSurf * ps1, double qpoint[], double bvec[], int idim, double aepsco, double aepsge,\n       double amax, SISLIntcurve * pintcr, int icur, int igraph, int *jstat)\n#else\nvoid\ns1515 (ps1, qpoint, bvec, idim, aepsco, aepsge, amax, pintcr, icur, igraph, jstat)\n     SISLSurf *ps1;\n     double qpoint[];\n     double bvec[];\n     int idim;\n     double aepsco;\n     double aepsge;\n     double amax;\n     SISLIntcurve *pintcr;\n     int icur;\n     int igraph;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To march the circular silhouette curve described by an intersection\n*              curve object, a B-spline surface, point Q and direction B\n*              i.e. solution of  f(u,v) = N(u,v) x (P(u,v) - Q) . B\n*\n*\n* INPUT      : ps1    - Pointer to surface.\n*              qpoint  - Point Q for circular silhouette\n*              bvec  - Direction B for circular silhouette\n*              idim   - Dimension of the space in which Q lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              amax   - Maximal allowed step length. If amax <=aepsge\n*                       amax is neglected.\n*              icur   - Indicator telling if a 3-D curve is to be made\n*                        0 - Don't make 3-D curve\n*                        1 - Make 3-D curve\n*                        2 - Make 3-D curve and curves in parameter plane\n*              igraph - Indicator telling if the curve is to be outputted\n*                       through function calls:\n*                        0 - don't output curve through function call\n*                        1 - output as straight line segments through\n*                            s6move and s6line.\n*\n*\n*\n* INPUT/OUTPUT:pintcr - The intersection curve. When coming in as input\n*                       only parameter values in the parameter plane\n*                       exist. When coming as output the 3-D geometry\n*                       and possibly the curve in the parameter plane\n*                       of the surface is added.\n*\n* OUTPUT:      jstat  - status messages\n*                         = 3      : Iteration stopped due to singular\n*                                    point or degenerate surface. A part\n*                                    of intersection curve may have been\n*                                    traced out. If no curve is traced out\n*                                    the curve pointers in the Intcurve\n*                                    object point to SISL_NULL.\n*                         = 0      : ok\n*                         < 0      : error\n*                         = -185   : No points produced on intersection curve.\n*\n*\n* METHOD     : An implicit description of the problem is made and then\n*              a routine for intersecting implicit represented geometry\n*              by a B-spline surface is used.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err, s1313\n* WRITTEN BY : Mike Floater, SI, Oslo, Norway, 31 . January 1991\n*                a modification of s1319\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\t\t\t/* Position of error                                  */\n  int kdeg = 1005;\t\t/* The degree of the implicit equation                */\n  /* of the circular silhouette                         */\n  int kstat;\t\t\t/* Local status variable                              */\n  double simpli[6];\t\t/* Array containing the implicit description          */\n  /* of the circular silhouette                         */\n  double snorm[3];\t\t/* Normalized version of direction vector bvec        */\n\n\n\n  if (idim != 3)\n    goto err104;\n\n  /* Normalize bvec direction vector */\n\n  (void) s6norm (bvec, idim, snorm, &kstat);\n\n\n  simpli[0] = qpoint[0];\n  simpli[1] = qpoint[1];\n  simpli[2] = qpoint[2];\n\n  simpli[3] = snorm[0];\n  simpli[4] = snorm[1];\n  simpli[5] = snorm[2];\n\n  /* Make intersection of implicit surface and B-spline surface */\n\n  s1313 (ps1, simpli, kdeg, aepsco, aepsge, amax, pintcr, icur, igraph, &kstat);\n  if (kstat == -185)\n    goto err185;\n  if (kstat < 0)\n    goto error;\n\n  *jstat = kstat;\n  goto out;\n\n  /* Dimension not 3 */\n\nerr104:\n  *jstat = -104;\n  s6err (\"s1515\", *jstat, kpos);\n  goto out;\n\n  /* Couldn't march */\n  /* Only degenerate or singular guide points */\nerr185:\n  *jstat = -185;\n  goto out;\n\n  /* Error in lower level routine.  */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1515\", *jstat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1516.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n *\n *\n */\n\n\n#define S1516\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1516(double ep[],double epar[],int im,int idim,\n           double **ev,int *jstat)\n#else\nvoid s1516(ep,epar,im,idim,ev,jstat)\n     double ep[];\n     double epar[];\n     int    im;\n     int    idim;\n     double **ev;\n     int    *jstat;\n#endif\n/*\n************************************************************************\n*\n* Purpose:   To estimate the first derivative at each point in a sequence.\n*\n* Input:\n*          ep     - Array containing the point in sequence\n*                   (x,y,..,x,y,..), length idim * im.\n*          epar   - Parametrization array. The array should be increasing\n*                   in value.\n*          im     - Number of point and derivatives\n*          idim   - The dimension of the space the points and derivatives\n*                   lie in\n* Output:\n*          ev     - Pointer to array containing the derivatives in sequence\n*                   (x,y,..,x,y,..), length idim * im.\n*          jstat  - Status variable\n*                    < 0 - Error.\n* Method:\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Michael Floater, SI 1993-10\n*\n*********************************************************************\n*/\n{\n  int ki,kj;          /* Loop variables                              */\n  int kk;             /* Polynomial order                            */\n  int kpos=0;         /* Position of error                           */\n  int kstat=0;        /* Status variable                             */\n  double *gpar;\n  int kcnsta;\n  int kcnend;\n  int iopen;\n  int iorder;\n  int ileft;\n  double *ntype;\n  SISLCurve *qc;\n  int knbpar;\n  double *evtemp;\n  double cendpar;\n  double *eder;\n\n\n\n\n  /* Check input */\n\n  if (idim < 1 || im < 2) goto err102;\n\n\n  /* Allocate array for derivatives */\n\n  evtemp    = newarray(idim*im,DOUBLE);\n  if (evtemp == SISL_NULL) goto err101;\n\n  ntype    = newarray(im,DOUBLE);\n  if (ntype == SISL_NULL) goto err101;\n\n  for(ki=0; ki<im; ki++)\n  {\n      ntype[ki] = 1.0;\n  }\n\n  eder    = newarray(2 * idim,DOUBLE);\n  if (eder == SISL_NULL) goto err101;\n\n\n\n  kcnsta = 1;\n  kcnend = 1;\n  iopen = 1;\n  iorder = 4;\n\n  s1358(ep, im, idim, ntype, epar, kcnsta, kcnend, iopen, iorder,\n        epar[0],&cendpar, &qc, &gpar, &knbpar, &kstat);\n     if(kstat < 0) goto error;\n\n  for(ki=0,kk=0; ki<im; ki++,kk+=idim)\n  {\n      s1221(qc,1,epar[ki],&ileft,eder,&kstat);\n      if(kstat < 0) goto error;\n\n      for(kj=0; kj<idim; kj++)\n      {\n          evtemp[kk+kj] = eder[idim+kj];\n      }\n  }\n\n\n  /* Calculation completed */\n\n  /* Set result. */\n\n  (*ev) = evtemp;\n\n  *jstat = 0;\n  goto out;\n\n\n\n  /* Error in space allocation */\n\n err101: *jstat = -101;\n  s6err(\"s1516\",*jstat,kpos);\n  goto out;\n\n\n  /* Error in input. */\n\n err102: *jstat = -102;\n  s6err(\"s1516\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine. */\n\n error:  *jstat =kstat;\n  s6err(\"s1516\",*jstat,kpos);\n  goto out;\n\n out:\n  if (ntype != SISL_NULL) freearray(ntype);\n  if (gpar != SISL_NULL) freearray(gpar);\n  if (eder != SISL_NULL) freearray(eder);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1517.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n *\n *\n */\n\n\n#define S1517\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1517(double ep[],double ev[],double epar[],int im, double mu,\n           double **evnew,int *jstat)\n#else\nvoid s1517(ep,ev,epar,im,mu,evnew,jstat)\n     double ep[];\n     double ev[];\n     double epar[];\n     int    im;\n     double mu;\n     double **evnew;\n     int    *jstat;\n#endif\n/*\n************************************************************************\n*\n* Purpose:   Given positive values and arbitrary derivatives, adjust\n*            the derivatives so that the cubic Hermite interpolant will\n*            be positive (in fact so that the coefficients of each\n*            cubic Bezier segment will be positive).\n*\n* Input:\n*          ep     - Array containing the point in sequence\n*                   (x,y,..,x,y,..), length im.\n*          ev     - Pointer to array containing the derivatives in sequence\n*                   (x,y,..,x,y,..), length im.\n*          epar   - Parametrization array. The array should be increasing\n*                   in value, length im.\n*          im     - Number of point and derivatives\n*          mu     - Factor used for adjustment (0 <= mu < 1):\n*                    mu = 0 => all derivatives will be zero,\n*                    mu = 1 => all Bezier coeffs will be >=0, some\n*                               can be exactly 0.\n*\n* Output:\n*          evnew  - Pointer to array containing the adjusted derivatives\n*                   in sequence (x,y,..,x,y,..), length im.\n*          jstat  - Status variable\n*                    < 0 - Error.\n* Method:\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Micahel Floater, SI 1993-10\n*\n*********************************************************************\n*/\n{\n  int ki;             /* Loop variables                              */\n  int kpos=0;         /* Position of error                           */\n  double *evtemp;\n  double mu3;\n  double knotint1;\n  double knotint2;\n\n\n\n\n  /* Check input */\n\n  if (im < 2) goto err102;\n  if(mu < 0.0 || mu >= 1.0) goto err102;\n\n  mu3 = 3.0 * mu;\n\n  /* Allocate array for derivatives */\n\n  evtemp    = newarray(im,DOUBLE);\n  if (evtemp == SISL_NULL) goto err101;\n\n  /* Adjust the derivatives. */\n\n\n  knotint2 = epar[1] - epar[0];\n\n  if(ev[0] < - mu3 * ep[0] / knotint2)\n  {\n      evtemp[0] = - mu3 * ep[0] / knotint2;\n  }\n  /* @JKA: This is copied from the uncommented version. */\n  else if (mu == DZERO)\n  {\n     evtemp[0] = mu;\n  }\n  /* @JKA */\n  else\n  {\n      evtemp[0] = ev[0];\n  }\n\n\n  for(ki=1; ki<im-1; ki++)\n  {\n      knotint1 = epar[ki] - epar[ki-1];\n      knotint2 = epar[ki+1] - epar[ki];\n\n      if(ev[ki] >  mu3 * ep[ki] / knotint1)\n      {\n          evtemp[ki] = mu3 * ep[ki] / knotint1;\n      }\n      else if(ev[ki] < - mu3 * ep[ki] / knotint2)\n      {\n          evtemp[ki] = - mu3 * ep[ki] / knotint2;\n      }\n      else\n      {\n          evtemp[ki] = ev[ki];\n      }\n  }\n\n  knotint1 = epar[im-1] - epar[im-2];\n\n  if(ev[im-1] > mu3 * ep[im-1] / knotint1)\n  {\n      evtemp[im-1] = mu3 * ep[im-1] / knotint1;\n  }\n  /* @JKA: This is copied from the uncommented version. */\n  else if (mu == DZERO)\n  {\n     evtemp[im-1] = mu;\n  }\n  /* @JKA */\n  else\n  {\n      evtemp[im-1] = ev[im-1];\n  }\n\n\n  /* Calculation completed */\n\n  /* Set result. */\n\n  (*evnew) = evtemp;\n\n  *jstat = 0;\n  goto out;\n\n\n\n  /* Error in space allocation */\n\n err101: *jstat = -101;\n  s6err(\"s1517\",*jstat,kpos);\n  goto out;\n\n\n  /* Error in input. */\n\n err102: *jstat = -102;\n  s6err(\"s1517\",*jstat,kpos);\n  goto out;\n\n\n out:\n\n  return;\n}\n"
  },
  {
    "path": "src/s1518.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $$\n *\n */\n#define S1518\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1518(SISLSurf *surf, double point[], double dir[], double epsge,\n\t   double start[], double end[], double parin[], double parout[],\n\t   int *stat)\n#else\nvoid s1518(surf, point, dir, epsge, start, end, parin, parout, stat)\n     SISLSurf   *surf;\n     double point[];\n     double dir[];\n     double epsge;\n     double start[];\n     double end[];\n     double parin[];\n     double parout[];\n     int    *stat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Newton iteration on the intersection between\n*              a 3D NURBS surface and a line.\n*              If a good initial guess is given, the intersection will\n*              be found quickly. However if a bad initial guess is given,\n*              the iteration might not converge.\n*              We only search in the rectangular subdomain specified\n*              by \"start\" and \"end\". This can be the whole domain if desired.\n*\n*\n* INPUT      : surf    - The NURBS surface.\n*              point   - A point on the line.\n*              dir     - The vector direction of the line\n*                        (not necessarily normalized).\n*              epsge   - Geometric resolution.\n*              start   - Lower limits of search rectangle (umin, vmin).\n*              end     - Upper limits of search rectangle (umax, vmax).\n*              parin   - Initial guess (u0,v0) for parameter point of\n*                        intersection (which should be inside the\n*                        search rectangle).\n*\n*\n*\n* OUTPUT     : parout  - Parameter point (u,v) of intersection.\n*              jstat   - status messages  \n*                                = 1   : Intersection found.\n*                                < 0   : error.\n*\n*\n* METHOD     : Newton iteration: we assume the surface is close to\n*              the tangent plane through the current estimate s(u_0,v_0)\n*              and use the intersection of the line with that (parametric)\n*              plane to make the next estimate (u_1,v_1).\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Michael Floater, SINTEF Oslo, September 2001.\n*\n*********************************************************************\n*/                       \n{ \n  int i,j;                  /* For loops. */\n  int kstat = 0;            /* Local status variable. */\n  int kpos = 0;             /* Error indicator. */\n  int num_its = 30;         /* Max number of Newton iterations allowed. */\n  double norm1[3];          /* 1st vector normal to dir. */\n  double norm2[3];          /* 2nd vector normal to dir. */\n  int kleft1=0;             /* Index of knot interval. */\n  int kleft2=0;             /* Index of knot interval. */\n  int nder=1;               /* evaluate up to derivs of order 1. */\n  double parpoint[3];       /* current parameter point. */\n  double der[9];            /* surface position and two partial derivatives. */\n  double norm[3];           /* surface normal. */\n  double a11,a12,a21,a22;   /* Elements of matrix A. */\n  double b1,b2;             /* Elements of column vector b. */\n  double det;               /* Determinant of A. */\n  double du,dv;             /* Increment in parameter point. */\n  double su[3],sv[3];       /* two partial derivatives of surface. */\n  double pminuss[3];        /* p - s. */\n  double epsge2;            /* square of epsge. */\n\n  if(surf->idim != 3) { kstat = -1; goto error; }\n  if(start[0] < surf->et1[surf->ik1 - 1]) { kstat = -1; goto error; }\n  if(end[0] > surf->et1[surf->in1]) { kstat = -1; goto error; }\n  if(start[1] < surf->et2[surf->ik2 - 1]) { kstat = -1; goto error; }\n  if(end[1] > surf->et2[surf->in2]) { kstat = -1; goto error; }\n  if(parin[0] < start[0] || parin[0] > end[0]) { kstat = -1; goto error; }\n  if(parin[1] < start[1] || parin[1] > end[1]) { kstat = -1; goto error; }\n\n  /* Represent line as intersection of two planes, i.e. find\n     two vectors norm1 and norm2 of length one,\n     perpendicular to the line. */\n\n  s6twonorm(dir,norm1,norm2,&kstat);\n    if(kstat < 0) goto error;\n\n  /* printf(\"norm1 = %lf %lf %lf\\n\",norm1[0],norm1[1],norm1[2]); */\n  /* printf(\"norm2 = %lf %lf %lf\\n\",norm2[0],norm2[1],norm2[2]); */\n\n  epsge2 = epsge * epsge;\n\n  parpoint[0] = parin[0];\n  parpoint[1] = parin[1];\n\n  /* printf(\"parpoint = %lf %lf\\n\",parpoint[0],parpoint[1]); */\n\n  for(i=0; i< num_its; i++)\n  {\n    /* Evaluate position and 1st derivatives of surface */\n  \n    s1421(surf,nder,parpoint,&kleft1,&kleft2,der,norm,&kstat);\n    if (kstat < 0) goto error;\n\n    /* printf(\"pos = %lf %lf %lf\\n\",der[0],der[1],der[2]); */\n    /* printf(\"s_u = %lf %lf %lf\\n\",der[3],der[4],der[5]); */\n    /* printf(\"s_v = %lf %lf %lf\\n\",der[6],der[7],der[8]); */\n    /* printf(\"norm = %lf %lf %lf\\n\",norm[0],norm[1],norm[2]); */\n    \n    /* We assume that s(u,v) is close to the\n       parametric plane s(u_0,v_0) + (u-u_0) * s_u + (v-v_0) * s_v,\n       i.e. the tangent plane to s at (u_0,v_0).\n       We then find (u_1,v_1) where this plane intersects the\n       given straight line. We have represented the line as\n       those points x in 3D such that\n      \n         (x - p) . n1 = 0   (1)\n         (x - p) . n2 = 0   (2)\n       \n       where p is \"point\" and n1 = \"norm1\", \"n2 = norm2\".\n       Thus we solve\n       \n         (s(u_0,v_0) + (u_1-u_0) * s_u + (v_1-v_0) * s_v - p) . n1 = 0   (3)\n         (s(u_0,v_0) + (u_1-u_0) * s_u + (v_1-v_0) * s_v - p) . n2 = 0   (4)\n    \n       which is a 2*2 linear system in the unknowns u_1,v_1.\n       This can be written as\n  \n         A u = b\n  \n       where A = | s_u . n1   s_v . n1 |    b =  | (p - s) . n1 |\n                 | s_u . n2   s_v . n2 |         | (p - s) . n2 |\n  \n       and u = | du |\n               | dv |\n    \n       and where du = u_1 - u_0, dv = v_1 - v_0.\n       We solve the system for du, dv and find u_1 and v_1 afterwards.\n\n       Note that the distance of the point s(u0,v0) to\n       the line is precisely the Euclidean norm of the\n       right hand side b. Thus if this is within the\n       geometric tolerance, we can stop iterating.\n    */\n\n    for(j=0; j<3; j++)\n    {\n      su[j] = der[j+3];\n      sv[j] = der[j+6];\n      pminuss[j] = point[j] - der[j];\n    }\n  \n    b1 = s6scpr(pminuss,norm1,3);\n    b2 = s6scpr(pminuss,norm2,3);\n\n    if(b1 * b1 + b2 * b2 <= epsge2) break;\n\n    a11 = s6scpr(su,norm1,3);\n    a12 = s6scpr(sv,norm1,3);\n    a21 = s6scpr(su,norm2,3);\n    a22 = s6scpr(sv,norm2,3);\n  \n    det = a11 * a22 - a21 * a12;\n    du =  (b1 * a22 - b2 * a12) / det;\n    dv =  (a11 * b2 - a21 * b1) / det;\n  \n    /* Having now found the increments du,dv, update\n       the current parameter point. */\n  \n    parpoint[0] += du;    /* u1 = u0 + du; */\n    parpoint[1] += dv;    /* v1 = v0 + dv; */\n\n    /* printf(\"parpoint = %lf %lf\\n\",parpoint[0],parpoint[1]); */\n\n   if(surf->cuopen_1 == 1)\n   {\n     if(parpoint[0] < start[0]) parpoint[0] = start[0];\n     if(parpoint[0] > end[0]) parpoint[0] = end[0];\n   }\n   else // closed in u direction\n   {\n     if(parpoint[0] < start[0]) parpoint[0] = end[0];\n     if(parpoint[0] > end[0]) parpoint[0] = start[0];\n   }\n\n   if(surf->cuopen_2 == 1)\n   {\n   if(parpoint[1] < start[1]) parpoint[1] = start[1];\n   if(parpoint[1] > end[1]) parpoint[1] = end[1];\n   }\n   else // closed in v direction\n   {\n     if(parpoint[1] < start[1]) parpoint[1] = end[1];\n     if(parpoint[1] > end[1]) parpoint[1] = start[1];\n   }\n\n  }\n\n  *stat = 1;\n  parout[0] = parpoint[0];\n  parout[1] = parpoint[1];\n\n  /* printf(\"parout = %lf %lf\\n\\n\",parout[0],parout[1]); */\n\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error :\n  *stat = kstat;\n  s6err(\"s1518\", *stat, kpos);\n  goto out;\n\n  out:    \n\n  return;\n}\n\n"
  },
  {
    "path": "src/s1520.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1520.c,v 1.3 2001-03-19 15:58:50 afr Exp $\n *\n */\n\n\n#define S1520\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1520 (SISLCurve * pc, double angle, double ep[], double eaxis[],\n       SISLSurf ** rs, int *jstat)\n#else\nvoid\ns1520 (pc, angle, ep, eaxis, rs, jstat)\n     SISLCurve *pc;\n     double angle;\n     double ep[];\n     double eaxis[];\n     SISLSurf **rs;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To create a NURBS rotational surface by rotating\n*              the curve *pc around the axis defined by ep[] and eaxis[]\n*              the given angle. This will be an exact representation.\n*\n*\n* INPUT      : pc     - Pointer to curve to be rotated (NURBS or B-spline).\n*              angle  - The rotational angle. Counter clockwise around axis.\n*                       If the absolute value of the angle is greater than\n*                       2 PI then a rotational surface closed in the\n*                       rotation direction is made.\n*              ep     - SISLPoint on rotational axis\n*              eaxis  - Direction of rotational axis\n*\n*\n* OUTPUT     :\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*              rs     - Pointer to the surface produced (NURBS or B-spline).\n*\n* METHOD     : First a normalized circle segment spanning the actual angle\n*              is generated. This circle is then translated to generate\n*              the actual rows of control vertices of the surface\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1713, s6rotax, s6mvec, newCurve, newSurf, s6err\n*\n* WRITTEN BY : Johannes Kaasa, SI, Oslo, Norway. 09. Aug. 1991\n*              Based on s1302 with use of NURBS instead of B-splines.\n* Revised by : Christophe Rene Birkeland, SINTEF Oslo, May 1993.\n*              SISL_NULL tests included\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Dec. 1994.  Added\n*              initialization and check for allocation error of 'rs'.\n*              The 'cuopen_1' flag is now set to CLOSED if angle >= 2PI, it\n*              should really have been made periodic - and might at a later\n*              date be updated.\n*\n*********************************************************************\n*/\n{\n  double *st1;\t\t\t/* Pointer to knot vector of circle segment   */\n  double *scoef1;\t\t/* Pointer to vertices of circle segment      */\n  double *rcoef1;\t\t/* Pointer to rational vertices of circle seg */\n  int kn1;\t\t\t/* Number of vertice of circle segment        */\n  int kk1;\t\t\t/* Order of circle segment                    */\n  double *st2;\t\t\t/* Pointer to knot vector of input curve      */\n  double *scoef2;\t\t/* Pointer to vertices of input curve         */\n  double *rcoef2;\t\t/* Pointer to rational vertices of input curve */\n  int kn2;\t\t\t/* Number of vertice of input curve           */\n  int kk2;\t\t\t/* Order of input curve                       */\n  int kdim;\t\t\t/* Dimension of space in which curve lies     */\n  int ksurfdim;\t\t\t/* Dimension of space in which surface lies   */\n  int ki;\t\t\t/* Control variable in loop                   */\n  int kj;\t\t\t/* Control variable in loop                   */\n  int kl;\t\t\t/* Control variable in loop                   */\n  int kn;\t\t\t/* Number of vertices in total circle         */\n  int kk;\t\t\t/* Order of total circle                      */\n  double *st;\t\t\t/* Pointer to knots of total circle           */\n  double *scoef;\t\t/* Pointer to vertices of total circle        */\n  int kind;\t\t\t/* Kind of total circle curve                 */\n  int kcopy;\t\t\t/* Copy flag for total circle curve           */\n  double tangle;\t\t/* Local positive rotational angle            */\n  int quadrant;\t\t\t/* Quadrant of the rotational angle           */\n  double resang;\t\t/* Residue angle in the actual quadrant       */\n  double spar;\t\t\t/* Start parameter of circle segment          */\n  double epar;\t\t\t/* End parameter of circle segment            */\n  SISLCurve *totcurve=SISL_NULL;\t/* Pointer to total normalized circle         */\n  SISLCurve *pnorm;\t\t/* Pointer to normalized circle segment       */\n  double weight = (double) 1. / sqrt ((double) 2.);\t/* Rational weight                         */\n  double tfac;\t\t\t/* Weights along the profile curve.           */\n  double *sucof = SISL_NULL;\t\t/* Pointer to vertex array for surface        */\n  double smat[16];\t\t/* Transformation matrix                      */\n  int kstat;\t\t\t/* Status variable                            */\n  double *srow;\t\t\t/* Pointer to row of vertices in surface      */\n  double *scirc;\t\t/* Pointer to vertices in circular arc        */\n  int nbvec = 1;\t\t/* Number of vectors                          */\n\n  int kpos = 1;\t\t\t/* Position of error                          */\n\n\n\n  /* Ensure a valid output surface. */\n\n  *rs = SISL_NULL;\n\n\n  /* Make local pointers to description of curve */\n\n  st2      = pc->et;\n  kn2      = pc->in;\n  kk2      = pc->ik;\n  scoef2   = pc->ecoef;\n  rcoef2   = pc->rcoef;\n  kdim     = pc->idim;\n  ksurfdim = kdim + 1;\n\n  /* The routine is only working for dimension=3 */\n\n  if (kdim != 3)\n    goto err104;\n\n  /* Calculate normalized NURBS circle */\n\n  kn = 9;\n  kk = 3;\n  st = newarray (kn + kk, DOUBLE);\n  scoef = newarray (kn * ksurfdim, DOUBLE);\n  kind = 4;\n  kcopy = 2;\n  st[0] = (double) 0.;\n  for (ki = 1; ki < kk; ki++)\n    {\n      st[ki]     = (double) 0.;\n      st[2 + ki] = PIHALF;\n      st[4 + ki] = PI;\n      st[6 + ki] = THREEPIHALF;\n      st[8 + ki] = TWOPI;\n    }\n  st[11] = TWOPI;\n  for (ki = 0; ki < 36; ki++)\n    {\n      switch (ki)\n\t{\n\tcase 1:\n\tcase 2:\n\tcase 6:\n\tcase 8:\n\tcase 10:\n\tcase 14:\n\tcase 17:\n\tcase 18:\n\tcase 22:\n\tcase 24:\n\tcase 26:\n\tcase 30:\n\tcase 33:\n\tcase 34:\n\t  scoef[ki] = (double) 0.0;\n\t  break;\n\tcase 0:\n\tcase 3:\n\tcase 9:\n\tcase 11:\n\tcase 19:\n\tcase 27:\n\tcase 32:\n\tcase 35:\n\t  scoef[ki] = (double) 1.0;\n\t  break;\n\tcase 16:\n\tcase 25:\n\t  scoef[ki] = (double) -1;\n\t  break;\n\tcase 4:\n\tcase 5:\n\tcase 7:\n\tcase 13:\n\tcase 15:\n\tcase 23:\n\tcase 28:\n\tcase 31:\n\t  scoef[ki] = weight;\n\t  break;\n\tcase 12:\n\tcase 20:\n\tcase 21:\n\tcase 29:\n\t  scoef[ki] = -weight;\n\t  break;\n\t}\n    }\n\n  totcurve = newCurve (kn, kk, st, scoef, kind, kdim, kcopy);\n  if(totcurve == SISL_NULL) goto err101;\n\n  /* Pick out a part of the total curve */\n\n  tangle = fabs (angle);\n  if (tangle > TWOPI)\n    tangle = TWOPI;\n  quadrant = (int) floor (tangle / PIHALF);\n  resang = tangle - quadrant * PIHALF;\n  spar = (double) 0.;\n  epar = PIHALF * (quadrant + ((double) 1. + (sqrt ((double) 2.) + (double) 1.) * tan ((resang - PI / (double) 4.) / (double) 2.)) / (double) 2.);\n  s1713 (totcurve, spar, epar, &pnorm, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Make local variables for curve description */\n\n  st1    = pnorm->et;\n  scoef1 = pnorm->ecoef;\n  rcoef1 = pnorm->rcoef;\n  kn1    = pnorm->in;\n  kk1    = pnorm->ik;\n\n  if (angle < DZERO)\n    for (ki = 0; ki < kn1; ki++)\n      scoef1[kdim * ki + 1] = -scoef1[kdim * ki + 1];\n\n  /* Allocate vertex array for surface */\n\n  sucof = newarray (kn1 * kn2 * ksurfdim, DOUBLE);\n  if (sucof == SISL_NULL)\n    goto err101;\n\n  /* Make the surface vertices circle segment by circle segment */\n\n  for (ki = 0; ki < kn2; ki++)\n    {\n\n      /*  Check for profile weights */\n\n      if (pc->ikind == 2 || pc->ikind == 4)\n\ttfac = rcoef2[(ki + 1) * ksurfdim - 1];\n      else\n\ttfac = (double) 1.;\n\n      /*  Make transformation matrix for first vertex on curve to be rotated */\n\n      s6rotax (ep, eaxis, &scoef2[ki * kdim], smat, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /*  Transform the vertices of this row into right position */\n\n      for (kj = 0; kj < kn1; kj++)\n\t{\n\t  srow  = sucof + ki * (kn1 * ksurfdim) + kj * ksurfdim;\n\t  scirc = scoef1 + kj * kdim;\n\t  s6mvec (smat, scirc, nbvec, srow);\n\t  weight = rcoef1[(kj + 1) * ksurfdim - 1] * tfac;\n\t  for (kl = 0; kl < kdim; kl++)\n\t    srow[kl] *= weight;\n\t  srow[kdim] = weight;\n\t}\n    }\n\n  /* Create the surface */\n\n  *rs = newSurf (kn1, kn2, kk1, kk2, st1, st2, sucof, 2, kdim, 1);\n  if ( *rs == SISL_NULL )  goto err101;\n\n  if ( tangle >= TWOPI )\n  {\n    /* Set the flag indicating that the surface is closed in the first\n       parameter direction.  It should really have been made cyclic/periodic. */\n\n    (*rs)->cuopen_1 = SISL_SURF_CLOSED;\n  }\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n  err101:*jstat = -101;\n    s6err (\"s1520\", *jstat, kpos);\n    goto out;\n\n  /* Error in input, dimension not equal to 3 */\n\n  err104:*jstat = -104;\n    s6err (\"s1520\", *jstat, kpos);\n    goto out;\n\n  /* Error in lower level routine.  */\n\n  error:*jstat = kstat;\n    s6err (\"s1520\", *jstat, kpos);\n    goto out;\n\n  out:\n    /* Free allocated arrays */\n\n    if (sucof != SISL_NULL) freearray (sucof);\n    if (totcurve != SISL_NULL) freeCurve (totcurve);\n    if (pnorm != SISL_NULL) freeCurve (pnorm);\n    return;\n}\n"
  },
  {
    "path": "src/s1521.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1521.c,v 1.2 2001-03-19 15:58:50 afr Exp $\n *\n */\n\n\n#define S1521\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nSISLCurve* \ns1521(SISLCurve *pc,int *jstat)\n#else\nSISLCurve* s1521(pc,jstat)\n     SISLCurve *pc;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To convert a (non-rational) B-spline curve\n*              to rational form.\n*\n*\n* INPUT      : pc    - Pointer to input curve.\n*\n*\n* OUTPUT     : s1521  - Pointer to new output curve.\n*              jstat  - status messages  \n*                     = 1      : OK. The input curve is already rational.\n*                                Output curve is simplya copy.\n*                     = 0      : OK.  New curve made.\n*                     < 0      : error\n*\n*\n* METHOD     : The weights are set to 1 and a new curve is made.\n*\n*\n* REFERENCES :\n*\n* CALLS      : newCurve\n*\n* WRITTEN BY : Michael Floater, SI, 91-09.\n* Revised by : Christophe Rene Birkeland, SINTEF Oslo, May 1993.\n*              rcoef is free'd only when ikind == 1 or 3\n*\n*********************************************************************\n*/\n{\n  int in;                /* Number of vertices of curve.            */\n  int ik;                /* Order of curve.                         */\n  int ikind;             /* Kind of curve.                          */\n  int idim;              /* Dimension of the curve's space.         */\n  double *et;            /* Pointer to knot vector.                 */\n  double *ecoef;         /* Pointer to vertices.                    */\n  double *rcoef=SISL_NULL;    /* Pointer to homogeneous vertices.        */\n  SISLCurve *ratpc=SISL_NULL; /* Output SISLCurve.                       */\n  int i,j,J,jj;          /* loop variables                          */\n \n  *jstat=0;\n  in    = pc -> in;\n  ik    = pc -> ik;\n  ikind = pc -> ikind;\n  idim  = pc -> idim;\n  et    = pc -> et;\n  ecoef = pc -> ecoef;\n  \n  if (ikind == 2 || ikind == 4)\n  {\n      *jstat=1;\n\n      /* Pointer to the homogeneous vertices. */\n\n      rcoef = pc -> rcoef;\n  }\n  else\n  {\n      /* Calculate the homogeneous vertices. */\n    \n      rcoef = newarray(in*(idim+1),DOUBLE);\n      if(rcoef == SISL_NULL) goto err101;\n    \n      for(i=0, j=0, J=0; i<in; i++, j++)\n      {\n          for (jj=0; jj<idim; jj++, j++, J++) \n          {\n              rcoef[j]=ecoef[J];\n          }\n    \n          rcoef[j]=(double)1.0;\n      } \n      ikind++;\n  }\n\n  /* Make new rational curve. */\n\n  ratpc=newCurve(in,ik,et,rcoef,ikind,idim,1);\n  if(ratpc == SISL_NULL) goto err101;\n\n\n  /* New curve made. */\n  \n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1521\",*jstat,0);\n  goto out;\n  \n out: \n  /* Free space occupied by local array.  */\n  \n  if(pc->ikind == 1 || pc->ikind == 3)\n    if (rcoef != SISL_NULL) freearray(rcoef);\n  \n  return ratpc;\n}\n"
  },
  {
    "path": "src/s1522.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1522\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1522(double normal[], double centre[], double ellipaxis[],\n           double ratio, int dim, SISLCurve** ellipse, int *jstat)\n#else\nvoid s1522(normal, centre, ellipaxis, ratio, dim, ellipse, jstat)\n     double normal[];\n     double centre[];\n     double ellipaxis[];\n     double ratio;\n     int dim;\n     SISLCurve** ellipse;\n     int *jstat;\n#endif\n/*\n***************************************************************************\n*\n*  PURPOSE      : Convert a 2D or 3D Ellipse to non-uniform rational B-spline\n*                 (nurbs) format.\n*\n*  INPUT        :\n*        normal - 3D normal to ellipse plane (not necessarily normalized).  Used\n*                 if dim = 3.\n*        centre - centre of ellipse (2D if dim = 2 and 3D if dim = 3).\n*     ellipaxis - One axis of the ellipse -- will be used as starting point\n*                 for the ellipse curve (2D if dim = 2 and 3D if dim = 3).\n*         ratio - The ratio between the length of the given ellipaxis and the\n*                 length of the other axis, i.e. |ellipaxis| / |other axis| (a\n*                 compact representation format).\n*           dim - dimension of the space in which the elliptic nurbs curve\n*                 lies (2 or 3).\n*\n*  OUTPUT       :\n*   ellipse - ellipse in nurbs format (2D if dim = 2 and 3D if dim = 3).\n*   jstat   - status messages\n*                         > 0      : warning\n*                         = 0      : ok\n*                         < 0      : error\n*\n*  METHOD       : The length of the parameter interval is approximately\n*                 equal to the length of the ellipse so that the\n*                 parametrization is approximately arc length.\n*\n*  CALLS        : newCurve().\n*\n*\n*  REFERENCES   :\n*\n*\n* WRITTEN BY    :  Michael Floater, based on earlier version by\n*                  Paul Fugelli.      SINTEF SI (Norway), August 1994.\n*\n****************************************************************************/\n{\n  int kstat;       /* Status variable.                    */\n  int kpos=0;      /* Position of error.                  */\n  double cross[3]; /* Cross vector (the other axis). */\n  int i;           /* For-loop indices.   */\n  double et[12];   /* Knot vector.        */\n  double coef[36]; /* Vertices.           */\n  double elliplen; /* Length of ellipaxis. */\n  double otherlen; /* Length of the other axis. */\n  double factor;   /* Length multiplication factor. */\n  double tworoot = sqrt ((double) 2.0);  /* Square root of 2. */\n  double weight  = (double) 1.0 / tworoot;  /* One over square root of 2. */\n\n  *jstat = 0;\n\n  /* Check input. */\n  if ( ratio == 0.0 )  ratio = 1.0;\n\n  if ( dim != 2  &&  dim != 3 )  goto err105;\n\n\n  /* Find the length of the given axis. */\n\n  elliplen = s6length(ellipaxis, dim, &kstat);\n  if ( kstat < 0  ||  elliplen == 0.0 )  goto error;\n\n  /* Find the other axis. */\n  if ( dim == 2 )\n  {\n    cross[0] = -ellipaxis[1] / ratio;\n    cross[1] = ellipaxis[0] / ratio;\n\n    /* Find the length of the other axis. */\n    otherlen = elliplen / ratio;\n  }\n  else\n  {\n    cross[0] = normal[1]*ellipaxis[2] - normal[2]*ellipaxis[1];\n    cross[1] = normal[2]*ellipaxis[0] - normal[0]*ellipaxis[2];\n    cross[2] = normal[0]*ellipaxis[1] - normal[1]*ellipaxis[0];\n\n    /* Find the length of the other axis. */\n    otherlen = s6length(cross, 3, &kstat);\n    if ( kstat < 0  ||  otherlen == 0.0 )  goto error;\n\n    /* Normalise the length of the other axis. */\n    for ( i=0;  i < 3;  i++ )  cross[i] /= otherlen;\n\n    /* Find the length of the other axis. */\n    otherlen = elliplen / ratio;\n\n    /* Adjust the length of the other axis. */\n    for ( i=0;  i < 3;  i++ )  cross[i] *= otherlen;\n  }\n\n\n  /* Build the nurbs representation. */\n\n  factor = PI*tworoot * sqrt( elliplen*elliplen + otherlen*otherlen );\n  et[0] = (DOUBLE) 0.0;  /* The knot vector. */\n  for ( i=1;  i < 3;  i++ ) {\n    et[i]     = (DOUBLE) 0.0;\n    et[2 + i] = factor * 0.25;\n    et[4 + i] = factor * 0.5;\n    et[6 + i] = factor * 0.75;\n    et[8 + i] = factor;\n  }\n  et[11] = factor;\n\n  if ( dim == 2 )\n  {\n    for ( i=0;  i < 2;  i++ )\n    {\n      coef[     i] = centre[i] + ellipaxis[i];\n      coef[3 +  i] = weight*(centre[i] + ellipaxis[i] + cross[i]);\n      coef[6 +  i] = centre[i] + cross[i];\n      coef[9 + i] = weight*(centre[i] - ellipaxis[i] + cross[i]);\n      coef[12 + i] = centre[i] - ellipaxis[i];\n      coef[15 + i] = weight*(centre[i] - ellipaxis[i] - cross[i]);\n      coef[18 + i] = centre[i] - cross[i];\n      coef[21 + i] = weight*(centre[i] + ellipaxis[i] - cross[i]);\n      coef[24 + i] = centre[i] + ellipaxis[i];\n    }\n\n    coef[2] = 1.0;  /* The rational weights. */\n    coef[5] = weight;\n    coef[8] = 1.0;\n    coef[11] = weight;\n    coef[14] = 1.0;\n    coef[17] = weight;\n    coef[20] = 1.0;\n    coef[23] = weight;\n    coef[26] = 1.0;\n  }\n  else\n  {\n    for ( i=0;  i < 3;  i++ )\n    {\n      coef[     i] = centre[i] + ellipaxis[i];\n      coef[4 +  i] = weight*(centre[i] + ellipaxis[i] + cross[i]);\n      coef[8 +  i] = centre[i] + cross[i];\n      coef[12 + i] = weight*(centre[i] - ellipaxis[i] + cross[i]);\n      coef[16 + i] = centre[i] - ellipaxis[i];\n      coef[20 + i] = weight*(centre[i] - ellipaxis[i] - cross[i]);\n      coef[24 + i] = centre[i] - cross[i];\n      coef[28 + i] = weight*(centre[i] + ellipaxis[i] - cross[i]);\n      coef[32 + i] = centre[i] + ellipaxis[i];\n    }\n\n    coef[3] = 1.0;  /* The rational weights. */\n    coef[7] = weight;\n    coef[11] = 1.0;\n    coef[15] = weight;\n    coef[19] = 1.0;\n    coef[23] = weight;\n    coef[27] = 1.0;\n    coef[31] = weight;\n    coef[35] = 1.0;\n  }\n\n  (*ellipse) = newCurve(9, 3, et, coef, 2, dim, 1);\n  if ( (*ellipse) == SISL_NULL )  goto err101;\n\n  (*ellipse)->cuopen = 0;\n\n  goto out;\n\n\n  /* Error in curve allocation.  */\n\nerr101:\n  *jstat = -101;\n  s6err(\"s1522\", *jstat, kpos);\n  goto out;\n\n\n  /* Error in input. Dimension not equal to 2 or 3. */\n\nerr105:\n  *jstat = -105;\n  s6err(\"s1522\", *jstat, kpos);\n  goto out;\n\n\n  /* Error in lower level routine. */\n\nerror:\n  *jstat = kstat;\n  s6err(\"s1522\", *jstat, kpos);\n  goto out;\n\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1528.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1528\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1528(int idim, int m1, int m2, double points[], int ipar, \n\t   int iopen1, int iopen2, double **par1, double **par2, int *jstat)\n#else\nvoid s1528(idim,m1,m2,points,ipar,iopen1,iopen2,par1,par2,jstat)\n     int idim;\n     int m1;\n     int m2;\n     double points[];\n     int ipar;\n     int iopen1;\n     int iopen2;\n     double **par1;\n     double **par2;\n     int *jstat;\n#endif\n/*\n************************************************************************\n*\n* PURPOSE: To compute a suitable parametrization for a given set of points\n*          according to descriptor ipar.\n*\n* INPUT:\n*          idim   - The space dimension.\n*          m1     - The number of points in first par. direction\n*          m2     - The number of points in second par. direction\n*          points - Array of dimension idim*m1*m2 containing the\n*                   points.\n*          ipar   - Flag showing the desired parametrization to be used:\n*                   = 1: Mean accumulated cord-length parameterization.\n*                   = 2: Uniform parametrization.\n*          iopen1 - Flag telling if the surface should be open in 1. par. dir.:\n*                     1 : The curve should be open.\n*                     0 : The curve should be closed.\n*                    -1 : The curve should be closed and periodic.\n*          iopen2 - Flag telling if the curve should be open in 2. par. dir.\n*\n* OUTPUT:\n*          par1   - Array containing parametrization for first direction.\n*                   The dimension is m1+(iopen1!=1).\n*          par2   - Array containing parametrization for second direction.\n*                   The dimension is m2+(iopen2!=1).\n*          jstat  - Status variable\n*                    < 0 - Memory allocation error.\n*\n* METHOD:\n*\n* REFERENCES :\n*\n* CALLS:\n*\n* WRITTEN BY: Christophe Rene Birkeland, SINTEF, May 1993.\n* REVISED BY: Vibeke Skytt, SINTEF, 0394. Introduced open/closed parameter.\n*\n*********************************************************************\n*/\n{\n  int i,j;             /* Loop variables                              */\n  int kpek1, kpek2, kpek3; /* Loop variables                          */\n  int kpr1, kpr2;      /* Type of parametrization flag                */\n  int kpos=0;          /* Position of error                           */\n  int idimm1;          /*  =  idim * m1                               */\n  double tdist;        /* Help parameter.                             */\n  double *local_par1=SISL_NULL; /* Parametrization arrays used in routine  */\n  double *local_par2=SISL_NULL;\n\n\n  /* Allocate arrays for parametrizations */\n\n  local_par1 = newarray(m1+(iopen1 != SISL_CRV_OPEN), DOUBLE); \n  local_par2 = newarray(m2+(iopen2 != SISL_CRV_OPEN), DOUBLE); \n  if(local_par1 == SISL_NULL || local_par2 == SISL_NULL) goto err101; \n  local_par1[0] = (double) 0.0;\n  local_par2[0] = (double) 0.0;\n\n  /* Compute parametrization */\n\n  kpr1 = ipar; kpr2 = ipar;\n\n  if (ipar == 1)    \n    {\n      /* Chord length parametrization in\n       * first direction */\n\n      kpek1 = 0;    \n      idimm1 = idim*m1; \n      for (i=1; i<m1; i++)\n\t{    \n\t  local_par1[i] = local_par1[i-1];      \n\t  kpek2 = kpek1 + idim;\n\t  tdist = (double)0;\n\t  for (j=0, kpek3=0 ; j<m2; j++, kpek3+=idimm1) \n\t    {\n\t      tdist += s6dist(&points[kpek2 + kpek3],\n\t\t\t\t      &points[kpek1 + kpek3], idim);          \n\t    }\n\t  local_par1[i] += tdist/(double)m2;\n\t  kpek1 = kpek2;\n\t} \n      \n      if (iopen1 != SISL_CRV_OPEN)\n      {\n\t local_par1[m1] = local_par1[m1-1];      \n\t kpek2 = 0;\n\t tdist = (double)0;\n\t for (j=0, kpek3=0 ; j<m2; j++, kpek3+=idimm1) \n\t {\n\t    tdist += s6dist(&points[kpek2 + kpek3],\n\t\t\t\t    &points[kpek1 + kpek3], idim);          \n\t }\n\t local_par1[m1] += tdist/(double)m2;\n      } \n      \n      if (local_par1[m1-1] == (double)0.) kpr1 = 2;\n      \n      /* Chord length parametrization in second direction */\n      \n      kpek1 = 0; \n      for (j=1; j<m2; j++)\n\t{    \n\t  local_par2[j] = local_par2[j-1];\n\t  kpek2 = kpek1 + idimm1; \n\t  tdist = (double)0;\n\t  for (i=0, kpek3=0 ;i<m1 ; i++, kpek3+=idim)      \n\t    {                \n\t      tdist += s6dist(&points[kpek2 + kpek3],\n\t\t\t\t      &points[kpek1 + kpek3], idim);\n\t    }\n\t  local_par2[j] += tdist/(double)m1;\n\t  kpek1 = kpek2;     \n\t}\n      \n      if (iopen2 != SISL_CRV_OPEN)\n      {\n\t local_par2[m2] = local_par2[m2-1];      \n\t kpek2 = 0;\n\t tdist = (double)0;\n\t for (i=0, kpek3=0 ; i<m1; i++, kpek3+=idim) \n\t {\n\t    tdist += s6dist(&points[kpek2 + kpek3],\n\t\t\t\t    &points[kpek1 + kpek3], idim);          \n\t }\n\t local_par2[m2] += tdist/(double)m1;\n      } \n      \n      if(local_par2[m2-1] == (double)0.) kpr2 = 2; \n    }\n  if (kpr1 == 2)    \n    {\n      /*Uniform parametrization in first direction */\n      \n      for (i=1; i<m1+(iopen1!=SISL_CRV_OPEN); i++)\n\tlocal_par1[i] = i; \n    }\n  if (kpr2 == 2)\n    {\n      /* Uniform parametrization in second direction */\n      \n      for (i=1; i<m2+(iopen2!=SISL_CRV_OPEN); i++) \n\tlocal_par2[i] = i;\n    }\n\n\n  /* Success */\n\n  *par1 = local_par1;\n  *par2 = local_par2;\n  *jstat = 0;\n  goto out;\n\n\n  /* Error in space allocation */\n\n  err101: *jstat = -101;\n    s6err(\"s1531\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}\n"
  },
  {
    "path": "src/s1529.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1529\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1529(double ep[],double eder10[],double eder01[],double eder11[],\n\t   int im1,int im2,int idim,int ipar,\n\t   SISLSurf **rsurf,int *jstat)\n#else\nvoid s1529(ep,eder10,eder01,eder11,\n\t   im1,im2,idim,ipar,rsurf,jstat)\n     double ep[];\n     double eder10[];\n     double eder01[];\n     double eder11[];\n     int    im1;\n     int    im2;\n     int    idim;\n     int    ipar;\n     SISLSurf  **rsurf;\n     int    *jstat;\n#endif\n/*\n************************************************************************\n*\n* PURPOSE: To compute the cubic Hermite interpolant to the data given.\n*          More specifically, given positions, 10, 01, and 11\n*          derivatives at points of a rectangular grid, the routine\n*          computes a cubic tensor-product B-spline interpolant to\n*          the given data with double knots at each data (the first\n*          knot vector will have double knots at all interior points\n*          in epar1, quadruple knots at the first and last points,\n*          and similarly for the second knot vector).\n*\n* INPUT:\n*          ep     - Array of dimension idim*im1*im2 containing\n*                   the positions of the nodes (using the same ordering\n*                   as ecoef in the SISLSurf structure).\n*\n*          eder10 - Array of dimension idim*im1*im2 containing the\n*                   first derivative in the first parameter direction.\n*\n*          eder01 - Array of dimension idim*im1*im2 containing the\n*                   first derivative in the second parameter direction.\n*\n*          eder11 - Array of dimension idim*im1*im2 containing\n*                   the cross derivative (twist vector).\n*\n*          ipar   - Flag showing the desired parametrization to be used:\n*                   = 1: Mean accumulated cord-length parameterization.\n*                   = 2: Uniform parametrization.\n*\n*          im1    - The number of interpolation points in the\n*                   first parameter direction.\n*\n*          im2    - The number of interpolation points in the\n*                   second parameter direction.\n*\n*          idim   - Dimension of the space we are working in.\n*\n* Output:\n*          rsurf - Pointer to the surf produced\n*          jstat  - Status variable\n*                    < 0 - Error.\n*\n* Method:\n*     The interpolation is accomplished by using a one dimensional\n*     routine for cubic Hermite spline interpolation. First, the data\n*     is considered to be im2 positional and derivative vectors on\n*     two curves in idim * im1 dimensional space sampled at the\n*     points of epar2.\n*     The first of these has position vectors given by ep and\n*     derivative vectors given by eder01, the second position vectors\n*     given by eder10 and derivative vectors given by eder11.\n*     Running these curves through the one dimensional cubic Hermite\n*     spline interpolation routine then produces two cubic splines rpos\n*     and rder with coefficients of dimension (idim * im1) * (2 * im2)\n*     on the knot vector et2 which is just the points of epar2 with\n*     multiplicity 2 for the interior points and 4 for the\n*     end points.\n*     These coefficients are then considered to be im1 position vectors\n*     and derivative vectors on a curve in 2*idim*im2 dimensional\n*     space (after an appropriate tranposition) sampled at the\n*     points of epar1. Running this data through the one dimensional\n*     cubic Hermite spline routine results in a cubic spline\n*     with coefficients of dimension (2 * idim * im2) * (2 * im1)\n*     with knot vector et1 similar to et2.\n*     A transposition of these coefficients yields the B-spline\n*     coefficients of the bicubic Hermite tensor-product spline\n*     interpolant.\n\n* REFERENCES :\n*\n* CALLS      : s1528, s1530\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, May 1993.\n*\n*********************************************************************\n*/                                                               \n{\n  int kstat=0;        /* Status variable                             */\n  int kpos=0;         /* Position of error                           */\n  double *par1=SISL_NULL;    /* Transposed positions (in rpos)              */\n  double *par2=SISL_NULL;    /* Transposed derivatives (in rder)            */\n  \n  \n  /* Check input */        \n  \n  if (ipar < 1 || ipar > 3) goto err102;\n  \n  /* Generate parametrizations */\n  \n  s1528(idim, im1, im2, ep, ipar, SISL_CRV_OPEN, SISL_CRV_OPEN,\n\t&par1, &par2, &kstat);\n  if(kstat < 0) goto error;\n\n  /* Hermite interpolation */\n\n  s1530(ep,eder10,eder01,eder11,par1,par2,\n\tim1,im2,idim,rsurf,&kstat);\n  if(kstat < 0) goto error;\n\n  /* Success */\n  \n  *jstat = 0;\n  goto out;  \n  \n  /* Error in input data. */\n\n  err102: *jstat = -102;\n    s6err(\"s1530\",*jstat,kpos);\n    goto out;\n    \n  /* Error in lower level routine. */\n\n  error:  *jstat =kstat;\n    s6err(\"s1530\",*jstat,kpos);\n    goto out;\n  \n  out:\n    if(par1 != SISL_NULL) freearray(par1);\n    if(par2 != SISL_NULL) freearray(par2);\n    return;\n}\n"
  },
  {
    "path": "src/s1530.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1530.c,v 1.2 2001-03-19 15:58:50 afr Exp $\n *\n */\n\n\n#define S1530\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1530(double ep[],double eder10[],double eder01[],double eder11[],\n\t    double epar1[],double epar2[],\n\t    int im1,int im2,int idim,\n\t   SISLSurf **rsurf,int *jstat)\n#else\nvoid s1530(ep,eder10,eder01,eder11,epar1,epar2,\n\t    im1,im2,idim,rsurf,jstat)\n     double ep[];\n     double eder10[];\n     double eder01[];\n     double eder11[];\n     double epar1[];\n     double epar2[];\n     int    im1;\n     int    im2;\n     int    idim;\n     SISLSurf  **rsurf;\n     int    *jstat;\n#endif\n/*\n************************************************************************\n*\n* PURPOSE: To compute the cubic Hermite interpolant to the data given.\n*          More specifically, given positions, 10, 01, and 11\n*          derivatives at points of a rectangular grid, the routine\n*          computes a cubic tensor-product B-spline interpolant to\n*          the given data with double knots at each data (the first\n*          knot vector will have double knots at all interior points\n*          in epar1, quadruple knots at the first and last points,\n*          and similarly for the second knot vector).\n*\n* INPUT:\n*          ep     - Array of dimension idim*im1*im2 containing\n*                   the positions of the nodes (using the same ordering\n*                   as ecoef in the SISLSurf structure).\n*\n*          eder10 - Array of dimension idim*im1*im2 containing the\n*                   first derivative in the first parameter direction.\n*\n*          eder01 - Array of dimension idim*im1*im2 containing the\n*                   first derivative in the second parameter direction.\n*\n*          eder11 - Array of dimension idim*im1*im2 containing\n*                   the cross derivative (twist vector).\n*\n*          epar1  - Array of dimension im1 containing the\n*                   parametrization in the first direction.\n*\n*          epar2  - Array of dimension im2 containing the\n*                   parametrization in the first direction.\n*\n*          im1    - The number of interpolation points in the\n*                   first parameter direction.\n*\n*          im2    - The number of interpolation points in the\n*                   second parameter direction.\n*\n*          idim   - Dimension of the space we are working in.\n*\n* Output:\n*          rsurf - Pointer to the surf produced\n*          jstat  - Status variable\n*                    < 0 - Error.\n*\n* Method:\n*     The interpolation is accomplished by using a one dimensional\n*     routine for cubic Hermite spline interpolation. First, the data\n*     is considered to be im2 positional and derivative vectors on\n*     two curves in idim * im1 dimensional space sampled at the\n*     points of epar2.\n*     The first of these has position vectors given by ep and\n*     derivative vectors given by eder01, the second position vectors\n*     given by eder10 and derivative vectors given by eder11.\n*     Running these curves through the one dimensional cubic Hermite\n*     spline interpolation routine then produces two cubic splines rpos\n*     and rder with coefficients of dimension (idim * im1) * (2 * im2)\n*     on the knot vector et2 which is just the points of epar2 with\n*     multiplicity 2 for the interior points and 4 for the\n*     end points.\n*     These coefficients are then considered to be im1 position vectors\n*     and derivative vectors on a curve in 2*idim*im2 dimensional\n*     space (after an appropriate tranposition) sampled at the\n*     points of epar1. Running this data through the one dimensional\n*     cubic Hermite spline routine results in a cubic spline\n*     with coefficients of dimension (2 * idim * im2) * (2 * im1)\n*     with knot vector et1 similar to et2.\n*     A transposition of these coefficients yields the B-spline\n*     coefficients of the bicubic Hermite tensor-product spline\n*     interpolant.\n\n* REFERENCES :\n*\n* CALLS      : \n*\n* WRITTEN BY : Michael Floater, SI, June 1992.\n*\n*********************************************************************\n*/                                                               \n{\n  SISLCurve *rpos;    /* Curve of positions of dimension idim*im1    */\n  SISLCurve *rder;    /* Curve of derivatives of dimension idim*im1  */\n  SISLCurve *rcurve;  /* Curve of dimension idim*im2                 */\n  int kstat=0;        /* Status variable                             */\n  int kpos=0;         /* Position of error                           */\n  double *ph=SISL_NULL;    /* Transposed positions (in rpos)              */\n  double *dh=SISL_NULL;    /* Transposed derivatives (in rder)            */\n  double *scoef=SISL_NULL; /* Transposed positions in rcurve              */\n  \n  \n  \n  /* Check input */        \n  \n  if (im1 < 2 || im2 < 2 || idim < 1)   goto err102;\n  \n\n  /* Interpolate position and derivative\n     in the second parameter direction. */\n\n  s1379(ep,eder01,epar2,im2,idim * im1,&rpos,&kstat);\n  if(kstat < 0) goto error;\n\n  s1379(eder10,eder11,epar2,im2,idim * im1,&rder,&kstat);\n  if(kstat < 0) goto error;\n\n\n\n  /* Transpose the matrices (ecoef arrays) of the curves. */\n\n  s1531(rpos->ecoef, idim, im1, rpos->in, &ph, &kstat);\n  if(kstat < 0) goto error;\n\n  s1531(rder->ecoef, idim, im1, rder->in, &dh, &kstat);\n  if(kstat < 0) goto error;\n\n\n\n  /* Interpolate in the first parameter direction. */\n\n  s1379(ph,dh,epar1,im1,idim * rpos->in,&rcurve,&kstat);\n  if(kstat < 0) goto error;\n\n  /* Transpose coefficient matrix of rcurve. */\n\n  s1531(rcurve->ecoef, idim, rpos->in, rcurve->in, &scoef, &kstat);\n  if(kstat < 0) goto error;\n\n  /* Create instance of surface. */\n\n  (*rsurf) = newSurf(rcurve->in,rpos->in,rcurve->ik,rpos->ik,\n\t\t\trcurve->et,rpos->et,scoef,1,idim,1);\n  if((*rsurf) == SISL_NULL) goto err101;\n  \n  /* Set periodicity flag. */\n  \n  (*rsurf)->cuopen_1 = rcurve->cuopen;\n  (*rsurf)->cuopen_2 = rpos->cuopen;\n\n  /* Bicubic surface made. */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation. */\n\n err101: *jstat = -101;\n  s6err(\"s1530\",*jstat,kpos);\n  goto out;\n  \n  \n  /* Error in input data. */\n\n err102: *jstat = -102;\n  s6err(\"s1530\",*jstat,kpos);\n  goto out;\n  \n  \n  /* Error in lower level routine. */\n\n error:  *jstat =kstat;\n  s6err(\"s1530\",*jstat,kpos);\n  goto out;\n  \n out:\n  if (rpos != SISL_NULL) freeCurve(rpos);\n  if (rder != SISL_NULL) freeCurve(rder);\n  if (rcurve != SISL_NULL) freeCurve(rcurve);\n  if (scoef != SISL_NULL) freearray(scoef);\n  if (ph != SISL_NULL) freearray(ph);\n  if (dh != SISL_NULL) freearray(dh);\n  \n  return;\n}\n"
  },
  {
    "path": "src/s1531.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1531.c,v 1.3 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1531\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1531(double ea[],int idim,int in1,int in2,double **eb,int *jstat)\n#else\nvoid s1531(ea,idim,in1,in2,eb,jstat)\n     double ea[];\n     int idim;\n     int in1;\n     int in2;\n     double **eb;\n     int    *jstat;\n#endif\n/*\n************************************************************************\n*\n* PURPOSE: To compute the transpose in the last two indices, of the\n*          matrix given by ea and to output it as eb.\n*\n* INPUT:\n*          ea     - Array of dimension idim*in1*in2 containing the\n*                   matrix to be transformed.\n*          idim   - The length of the first index of ea.\n*          in1    - The length of the second index of ea.\n*          in2    - The length of the third index of ea.\n*\n* OUTPUT:\n*          eb     - Pointer to the output array containing the\n*                   transposed matrix (dimension idim*in1*in2).\n*          jstat  - Status variable\n*                    < 0 - Memory allocation error.\n* METHOD:\n*\n* REFERENCES :\n*\n* CALLS:\n*\n* WRITTEN BY: Michael Floater, SI, June 1992.\n*\n*********************************************************************\n*/\n{\n  int i,j,jbase;       /* Loop variable                             */\n  int ki,kj,kk;        /* Loop variable                             */\n  int idiff;           /*                                           */\n  int kpos=0;          /* Position of error                         */\n  double *mat=SISL_NULL;    /* Temporary output matrix                   */\n\n\n  mat = newarray(idim*in1*in2, DOUBLE);\n  if(mat == SISL_NULL) goto err101;\n\n  i = 0;\n  jbase = 0;\n  idiff = (in1 - 1) * idim;\n\n  for(ki=0; ki<in1; ki++,jbase+=idim)\n  {\n      for(kj=0,j=jbase; kj<in2; kj++,j+=idiff)\n      {\n          for(kk=0; kk<idim; kk++,i++,j++)\n          {\n\t      mat[i] = ea[j];\n          }\n      }\n  }\n\n  (*eb) = mat;\n\n  /* Calculation completed */\n\n  *jstat = 0;\n  goto out;\n\n\n  /* Error in space allocation */\n err101: *jstat = -101;\n  s6err(\"s1531\",*jstat,kpos);\n  goto out;\n\n\n out:\n\n  return;\n}\n"
  },
  {
    "path": "src/s1534.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1534\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1534(double points[],double der10[], double der01[],\n\t   double der11[],int im1,int im2,int idim,int ipar,\n\t   int con1,int con2,int con3,int con4, int order1,\n\t   int order2,int iopen1,int iopen2,SISLSurf **rsurf,int *jstat)\n#else\nvoid s1534(points,der10,der01,der11,im1,im2,idim,ipar,con1,con2,con3,\n\t   con4,order1, order2,iopen1,iopen2,rsurf,jstat)\n     double points[];\n     double der10[];\n     double der01[];\n     double der11[];\n     int im1;\n     int im2;\n     int idim;\n     int ipar;\n     int con1;\n     int con2;\n     int con3;\n     int con4;\n     int order1;\n     int order2;\n     int iopen1;\n     int iopen2;\n     SISLSurf **rsurf;\n     int *jstat;\n#endif\n/*\n************************************************************************\n*\n* PURPOSE: To compute a B-spline tensor surface interpolating a set\n*          of points.\n*\n* INPUT:\n*          points - Array of dimension idim*im1*im2 containing\n*                   the positions of the nodes (using the same ordering\n*                   as ecoef in the SISLSurf structure).\n*\n*          der10  - Array of dimension idim*im1*im2 containing the first\n*                   derivatives in the first parameter direction.\n*\n*          der01  - Array of dimension idim*im1*im2 containing the first\n*                   derivatives in the second parameter direction.\n*\n*          der11  - Array of dimension idim*im1*im2 containing the cross\n*                   derivatives (the twists).\n*\n*          im1    - The number of interpolation points in the\n*                   first parameter direction.\n*\n*          im2    - The number of interpolation points in the\n*                   second parameter direction.\n*\n*          idim   - Dimension of the space we are working in.\n*\n*          ipar   - Flag showing the desired parametrization to be used:\n*                   = 1: Mean accumulated cord-length parameterization.\n*                   = 2: Uniform parametrization.\n*\n*\n*                          ^ Second par. direction \n*                          |     \n*                          |    (2.)\n*                          |-----------|\n*                          |           |\n*                     (3.) |           | (4.) \n*                          |           |\n*                          |           |\n*                          |-----------|-> First par. direction\n*                               (1.)\n*\n*          con1      - Additional condition along edge 1:\n*                           = 0: No additional condition.\n*                           = 1: Zero curvature.\n*\n*          con2      - Additional condition along edge 2:\n*                           = 0: No additional condition.\n*                           = 1: Zero curvature.\n*\n*          con3      - Additional condition along edge 3:\n*                           = 0: No additional condition.\n*                           = 1: Zero curvature.\n*\n*          con4      - Additional condition along edge 4:\n*                           = 0: No additional condition.\n*                           = 1: Zero curvature.\n*\n*          order1    - Order of surface in first parameter direction.\n*\n*          order2    - Order of surface in second parameter direction.\n*\n*          iopen1    - Open/closed parameter in first parameter direction.\n*                      =  1 : open surface.\n*                      =  0 : closed surface.\n*                      = -1 : closed, periodic surface.\n*\n*          iopen2    - Open/closed parameter in second parameter direction.\n*                      =  1 : open surface.\n*                      =  0 : closed surface.\n*                      = -1 : closed, periodic surface.\n*\n*\n* Output:\n*          rsurf - Pointer to the surf produced\n*          jstat  - Status variable\n*                    < 0 - Error.\n*\n* Method:\n*     First, a suitable parametrization is calculated according\n*     to indicator variable ipar.\n*     Then the interpolation is accomplished by using a one dimensional\n*     routine for spline interpolation called several times. \n*     First, the datapoints\n*     are considered to be idim*im1 dimentional and so on...\n*\n*\n* REFERENCES :\n*\n* CALLS      : s1528, s1535.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, May 1993.\n*\n*********************************************************************\n*/                                                               \n{\n  int kstat=0;        /* Status variable                             */\n  int kpos=0;         /* Position of error                           */\n  double *par1=SISL_NULL;    /* Transposed positions (in rpos)              */\n  double *par2=SISL_NULL;    /* Transposed derivatives (in rder)            */\n  \n  \n  /* Check input */        \n  \n  if (ipar < 1 || ipar > 3) goto err102;\n  \n  /* Generate parametrizations */\n  \n  s1528(idim, im1, im2, points, ipar, iopen1, iopen2, &par1, &par2, &kstat);\n  if(kstat < 0) goto error;\n\n  /* Interpolation */\n\n  s1535(points,der10,der01,der11,im1,im2,idim,par1,par2,\n\tcon1,con2,con3,con4,order1, order2, iopen1, iopen2, rsurf,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Success */\n  \n  *jstat = 0;\n  goto out;  \n  \n  /* Error in input data. */\n\n  err102: *jstat = -102;\n    s6err(\"s1534\",*jstat,kpos);\n    goto out;\n    \n  /* Error in lower level routine. */\n\n  error:  *jstat =kstat;\n    s6err(\"s1534\",*jstat,kpos);\n    goto out;\n  \n  out:\n    if(par1 != SISL_NULL) freearray(par1);\n    if(par2 != SISL_NULL) freearray(par2);\n    return;\n}\n"
  },
  {
    "path": "src/s1535.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1535\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1535(double points[],double der10[],double der01[],double der11[],\n\t   int im1,int im2,int idim,double par1[],\n\t   double par2[],int con1,int con2,int con3,int con4, \n\t   int order1, int order2, int iopen1, int iopen2,\n\t   SISLSurf **rsurf,int *jstat)\n#else\nvoid s1535(points,der10, der01,der11,im1,im2,idim,par1, par2,\n\t   con1,con2,con3,con4,order1, order2,iopen1,iopen2,rsurf,jstat)\n     double points[];\n     double der10[];\n     double der01[];\n     double der11[];\n     int im1;\n     int im2;\n     int idim;\n     double par1[];\n     double par2[];\n     int con1;\n     int con2;\n     int con3;\n     int con4;\n     int order1;\n     int order2;\n     int iopen1;\n     int iopen2;\n     SISLSurf **rsurf;\n     int *jstat;\n#endif\n/*\n************************************************************************\n*\n* PURPOSE: To compute a B-spline tensor surface interpolating a set\n*          of points.\n*\n* INPUT:\n*          points - Array of dimension idim*im1*im2 containing\n*                   the positions of the nodes (using the same ordering\n*                   as ecoef in the SISLSurf structure).\n*\n*          der10  - Array of dimension idim*im1*im2 containing the first\n*                   derivatives in the first parameter direction.\n*\n*          der01  - Array of dimension idim*im1*im2 containing the first\n*                   derivatives in the second parameter direction.\n*\n*          der11  - Array of dimension idim*im1*im2 containing the cross\n*                   derivatives (the twists).\n*\n*          im1    - The number of interpolation points in the\n*                   first parameter direction.\n*\n*          im2    - The number of interpolation points in the\n*                   second parameter direction.\n*\n*          idim   - Dimension of the space we are working in.\n*\n*          par1   - Parametrization in first parameter direction.\n*                   For closed curves, one additional parameter value\n*                   must be spesified. The last entry contains\n*                   the parametrization of the repeted start point.\n*                   (if the endpoint is equal to the startpoint of\n*                   the interpolation the lenght of the array could\n*                   be equal to im1 also in the closed case).\n*\n*          par2   - Parametrization in second parameter direction.\n*                   For closed curves, one additional parameter value\n*                   must be spesified. The last entry contains\n*                   the parametrization of the repeted start point.\n*                   (if the endpoint is equal to the startpoint of\n*                   the interpolation the lenght of the array could\n*                   be equal to im2 also in the closed case).\n*\n*\n*                          ^ Second par. direction \n*                          |     \n*                          |    (2.)\n*                          |-----------|\n*                          |           |\n*                     (3.) |           | (4.) \n*                          |           |\n*                          |           |\n*                          |-----------|-> First par. direction\n*                               (1.)\n*\n*          con1      - Additional condition along edge 1:\n*                           = 0: No additional condition.\n*                           = 1: Zero curvature.\n*\n*          con2      - Additional condition along edge 2:\n*                           = 0: No additional condition.\n*                           = 1: Zero curvature.\n*\n*          con3      - Additional condition along edge 3:\n*                           = 0: No additional condition.\n*                           = 1: Zero curvature.\n*\n*          con4      - Additional condition along edge 4:\n*                           = 0: No additional condition.\n*                           = 1: Zero curvature.\n*\n*          order1    - Order of surface in first parameter direction.\n*\n*          order2    - Order of surface in second parameter direction.\n*\n*          iopen1    - Open/close parameter in first parameter direction.\n*                      =  1 : open surface.\n*                      =  0 : closed, non-periodic surface.\n*                      = -1 : periodic surface\n*\n*          iopen2    - Open/close parameter in second parameter direction.\n*                      =  1 : open surface.\n*                      =  0 : closed, non-periodic surface.\n*                      = -1 : periodic surface\n*\n*\n* Output:\n*          rsurf - Pointer to the surf produced\n*          jstat  - Status variable\n*                    < 0 - Error.\n*\n* Method:\n*     The interpolation is accomplished by using a one dimensional\n*     routine for spline interpolation called several times. \n*     First, the datapoints\n*     are considered to be idim*im1 dimentional and so on...\n*\n*\n* REFERENCES :\n*\n* CALLS      : s1357, s6chpar.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, June 1993.\n* CHANGED BY : Vibeke Skytt, SINTEF, 0394. Introduced iopen1 and iopen2.\n*\n*********************************************************************\n*/                                                               \n{\n  int i, j, k, len;   /* Loop control parameter                      */\n  int kpek1, kpek2, kpek3;\n  int idimm1, newindim;\n  int maxim;          /* Max (im1, im2)                              */\n  int kstat=0;        /* Status variable                             */\n  int kpos=0;         /* Position of error                           */\n  int newin1, newin2; /* Number of vertices along par. dir. 1 & 2    */\n  int numpt;              /* Needed in call to s1357                 */\n  double start=0.;        /* Needed in call to s1357                 */\n  double end;\n  int *typept=SISL_NULL;       /* Array needed for call to s1357          */\n  double *pointpar=SISL_NULL;  /* Array needed for call to s1357          */\n  double *coeffpos=SISL_NULL;  /* Array needed for call to s1357          */\n  double *coeffder=SISL_NULL;  /* Array needed for call to s1357          */\n  double *coeffposder=SISL_NULL; /* Array needed for call to s1357          */\n  double *newpoint=SISL_NULL;\n  double *newder=SISL_NULL;\n  SISLCurve *curve1a=SISL_NULL, *curve1b=SISL_NULL;\n  SISLCurve *curve2=SISL_NULL;\n\n  /* Allocate and initialize necessary arrays for call to s1357 */\n\n  maxim = 2 * MAX(im1, im2);\n  if((typept = newarray(maxim, INT))==SISL_NULL) goto err101;\n  for(i=0; i<maxim; i+=2)\n    {\n      typept[i] = 1;\n      typept[i+1] = 4;\n    }\n    \n  idimm1 = idim*im1;\n  len = 2*im2*idimm1;\n  if((newpoint = newarray(len, DOUBLE))==SISL_NULL) goto err101;\n  if((newder = newarray(len, DOUBLE))==SISL_NULL) goto err101;\n  for(i=0, kpek1=0, kpek2=0, kpek3 = idimm1; \n      i<im2; \n      i++, kpek1+=(2*idimm1), kpek3+=(2*idimm1), kpek2+=idimm1)\n    {\n      for(k=0; k<idimm1; k++)\n\t{\n\t  newpoint[kpek1+k] = points[kpek2+k];\n\t  newpoint[kpek3+k] = der01[kpek2+k];\n\t  newder[kpek1+k] = der10[kpek2+k];\n\t  newder[kpek3+k] = der11[kpek2+k];\n\t}\n    }\n\n  /* INTERPOLATION in SECOND direction : position. */\n\n  s1357(newpoint, im2*2, idimm1, typept, par2, con1, con2, iopen2, order2, \n\tstart, &end, &curve1a, &pointpar, &numpt, &kstat);\n  if(kstat < 0) goto error;\n  if(pointpar != SISL_NULL) \n    {\n      freearray(pointpar);\n      pointpar = SISL_NULL;\n    }\n  newin2 = curve1a->in;\n\n  /* INTERPOLATION in SECOND direction : derivative. */\n\n  s1357(newder, im2*2, idimm1, typept, par2, con1, con2, iopen2, order2, \n\tstart, &end, &curve1b, &pointpar, &numpt, &kstat);\n  if(kstat < 0) goto error;\n  if(pointpar != SISL_NULL) \n    {\n      freearray(pointpar);\n      pointpar = SISL_NULL;\n    }\n  if(curve1b->in != newin2) goto err116;\n\n  /* Transpose results, store new coefficients in \n   * arrays coeffpos and coeffder */\n\n  newindim = newin2 * idim;\n  if((coeffpos = newarray(im1*newindim, DOUBLE)) == SISL_NULL)\n    goto err101;\n  if((coeffder = newarray(im1*newindim, DOUBLE)) == SISL_NULL)\n    goto err101;\n  s6chpar(curve1a->ecoef, im1, newin2, idim, coeffpos);\n  s6chpar(curve1b->ecoef, im1, newin2, idim, coeffder);\n\n  if((coeffposder = newarray(2*im1*newindim, DOUBLE)) == SISL_NULL)\n    goto err101;\n  for(j=0, kpek1=0, kpek2=newindim, kpek3=0; \n      j<im1; \n      j++, kpek1+=(2*newindim), kpek2+=(2*newindim), kpek3+=newindim)\n    {\n      for(k=0; k<newindim; k++)\n\t{\n\t  coeffposder[kpek1+k] = coeffpos[kpek3+k];\n\t  coeffposder[kpek2+k] = coeffder[kpek3+k];\n\t}\n    }\n\n  /* Interpolation in FIRST parameter direction */\n\n  s1357(coeffposder, 2*im1, idim*newin2, typept, par1, con3, con4, iopen1, \n\torder1, start, &end, &curve2, &pointpar, &numpt, &kstat);\n  if(kstat < 0) goto error;\n  if(pointpar != SISL_NULL) \n    {\n      freearray(pointpar);\n      pointpar = SISL_NULL;\n    }\n  newin1 = curve2->in;\n\n  /* Transpose back coefficients */\n\n  if((coeffposder=increasearray(coeffposder, idim*newin1*newin2, DOUBLE)) \n     == SISL_NULL)  goto err101;\n  s6chpar(curve2->ecoef, newin2, newin1, idim, coeffposder);\n\n  /* Create instance of surface */\n\n  if (((*rsurf) = newSurf(newin1, newin2, order1, order2, curve2->et,\n\t\t     curve1a->et, coeffposder, 1, idim, 1)) == SISL_NULL) \n     goto err101;\n  \n  /* Set periodicity flag. */\n  \n  (*rsurf)->cuopen_1 = curve2->cuopen;\n  (*rsurf)->cuopen_2 = curve1a->cuopen;\n\n  /* Success */\n  \n  *jstat = 0;\n  goto out;  \n  \n  /* Allocation error. */\n\n  err101: \n    *jstat = -101;\n    s6err(\"s1535\",*jstat,kpos);\n    goto out;\n      \n  /* Error. */\n\n  err116: \n    *jstat = -116;\n    s6err(\"s1535\",*jstat,kpos);\n    goto out;\n      \n  /* Error in lower level routine. */\n\n  error:  *jstat =kstat;\n    s6err(\"s1535\",*jstat,kpos);\n    goto out;\n  \n  out:\n    /* Free arrays */\n  \n     if (typept != SISL_NULL) freearray(typept);\n    if(newpoint != SISL_NULL) freearray(newpoint);\n    if(newder != SISL_NULL) freearray(newder);\n    if(coeffpos != SISL_NULL) freearray(coeffpos);\n    if(coeffder != SISL_NULL) freearray(coeffder);\n    if(coeffposder != SISL_NULL) freearray(coeffposder);\n\n    /* Free local SISL-curve objects */\n   \n    if(curve1a != SISL_NULL) freeCurve(curve1a);\n    if(curve1b != SISL_NULL) freeCurve(curve1b);\n    if(curve2 != SISL_NULL) freeCurve(curve2);\n  \n    return;\n}\n"
  },
  {
    "path": "src/s1536.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1536\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1536(double points[],int im1,int im2,int idim,int ipar,\n\t   int con1,int con2,int con3,int con4, int order1,\n\t   int order2,int iopen1,int iopen2,SISLSurf **rsurf,int *jstat)\n#else\nvoid s1536(points,im1,im2,idim,ipar,con1,con2,con3,\n\t   con4,order1, order2,iopen1,iopen2,rsurf,jstat)\n     double points[];\n     int im1;\n     int im2;\n     int idim;\n     int ipar;\n     int con1;\n     int con2;\n     int con3;\n     int con4;\n     int order1;\n     int order2;\n     int iopen1;\n     int iopen2;\n     SISLSurf **rsurf;\n     int *jstat;\n#endif\n/*\n************************************************************************\n*\n* PURPOSE: To compute a B-spline tensor surface interpolating a set\n*          of points.\n*\n* INPUT:\n*          points - Array of dimension idim*im1*im2 containing\n*                   the positions of the nodes (using the same ordering\n*                   as ecoef in the SISLSurf structure).\n*\n*          im1    - The number of interpolation points in the\n*                   first parameter direction.\n*\n*          im2    - The number of interpolation points in the\n*                   second parameter direction.\n*\n*          idim   - Dimension of the space we are working in.\n*\n*          ipar   - Flag showing the desired parametrization to be used:\n*                   = 1: Mean accumulated cord-length parameterization.\n*                   = 2: Uniform parametrization.\n*\n*\n*                          ^ Second par. direction \n*                          |     \n*                          |    (2.)\n*                          |-----------|\n*                          |           |\n*                     (3.) |           | (4.) \n*                          |           |\n*                          |           |\n*                          |-----------|-> First par. direction\n*                               (1.)\n*\n*          con1      - Additional condition along edge 1:\n*                           = 0: No additional condition.\n*                           = 1: Zero curvature.\n*\n*          con2      - Additional condition along edge 2:\n*                           = 0: No additional condition.\n*                           = 1: Zero curvature.\n*\n*          con3      - Additional condition along edge 3:\n*                           = 0: No additional condition.\n*                           = 1: Zero curvature.\n*\n*          con4      - Additional condition along edge 4:\n*                           = 0: No additional condition.\n*                           = 1: Zero curvature.\n*\n*          order1    - Order of surface in first parameter direction.\n*\n*          order2    - Order of surface in second parameter direction.\n*\n*          iopen1    - Open/closed parameter in first parameter direction.\n*                      =  1 : open surface.\n*                      =  0 : closed surface.\n*                      = -1 : closed, periodic surface.\n*\n*          iopen2    - Open/closed parameter in second parameter direction.\n*                      =  1 : open surface.\n*                      =  0 : closed surface.\n*                      = -1 : closed, periodic surface.\n*\n*\n* Output:\n*          rsurf - Pointer to the surf produced\n*          jstat  - Status variable\n*                    < 0 - Error.\n*\n* Method:\n*     First, a suitable parametrization is calculated according\n*     to indicator variable ipar.\n*     Then the interpolation is accomplished by using a one dimensional\n*     routine for spline interpolation called several times. \n*     First, the datapoints\n*     are considered to be idim*im1 dimentional and so on...\n*\n*\n* REFERENCES :\n*\n* CALLS      : s1536\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, May 1993.\n*\n*********************************************************************\n*/                                                               \n{\n  int kstat=0;        /* Status variable                             */\n  int kpos=0;         /* Position of error                           */\n  double *par1=SISL_NULL;    /* Transposed positions (in rpos)              */\n  double *par2=SISL_NULL;    /* Transposed derivatives (in rder)            */\n  \n  \n  /* Check input */        \n  \n  if (ipar < 1 || ipar > 3) goto err102;\n  \n  /* Generate parametrizations */\n  \n  s1528(idim, im1, im2, points, ipar, iopen1, iopen2, &par1, &par2, &kstat);\n  if(kstat < 0) goto error;\n\n  /* Interpolation */\n\n  s1537(points,im1,im2,idim,par1,par2,con1,con2,con3,\n\tcon4,order1, order2,iopen1,iopen2,rsurf,&kstat);\n  if(kstat < 0) goto error;\n\n  /* Success */\n  \n  *jstat = 0;\n  goto out;  \n  \n  /* Error in input data. */\n\n  err102: *jstat = -102;\n    s6err(\"s1536\",*jstat,kpos);\n    goto out;\n    \n  /* Error in lower level routine. */\n\n  error:  *jstat =kstat;\n    s6err(\"s1536\",*jstat,kpos);\n    goto out;\n  \n  out:\n    if(par1 != SISL_NULL) freearray(par1);\n    if(par2 != SISL_NULL) freearray(par2);\n    return;\n}\n"
  },
  {
    "path": "src/s1537.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1537\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1537(double points[],int im1,int im2,int idim,double par1[],\n\t   double par2[],int con1,int con2,int con3,int con4, \n\t   int order1, int order2,int iopen1,int iopen2,\n\t   SISLSurf **rsurf,int *jstat)\n#else\nvoid s1537(points,im1,im2,idim,par1, par2,con1,con2,con3,\n\t   con4,order1, order2,iopen1,iopen2,rsurf,jstat)\n     double points[];\n     int im1;\n     int im2;\n     int idim;\n     double par1[];\n     double par2[];\n     int con1;\n     int con2;\n     int con3;\n     int con4;\n     int order1;\n     int order2;\n     int iopen1;\n     int iopen2;\n     SISLSurf **rsurf;\n     int *jstat;\n#endif\n/*\n************************************************************************\n*\n* PURPOSE: To compute a B-spline tensor surface interpolating a set\n*          of points.\n*\n* INPUT:\n*          points - Array of dimension idim*im1*im2 containing\n*                   the positions of the nodes (using the same ordering\n*                   as ecoef in the SISLSurf structure).\n*\n*          im1    - The number of interpolation points in the\n*                   first parameter direction.\n*\n*          im2    - The number of interpolation points in the\n*                   second parameter direction.\n*\n*          idim   - Dimension of the space we are working in.\n*\n*          par1   - Parametrization in first parameter direction.\n*                   For closed curves, one additional parameter value\n*                   must be spesified. The last entry contains\n*                   the parametrization of the repeted start point.\n*                   (if the endpoint is equal to the startpoint of\n*                   the interpolation the lenght of the array could\n*                   be equal to im1 also in the closed case).\n*\n*          par2   - Parametrization in second parameter direction.\n*                   For closed curves, one additional parameter value\n*                   must be spesified. The last entry contains\n*                   the parametrization of the repeted start point.\n*                   (if the endpoint is equal to the startpoint of\n*                   the interpolation the lenght of the array could\n*                   be equal to im2 also in the closed case).\n*\n*\n*                          ^ Second par. direction \n*                          |     \n*                          |    (2.)\n*                          |-----------|\n*                          |           |\n*                     (3.) |           | (4.) \n*                          |           |\n*                          |           |\n*                          |-----------|-> First par. direction\n*                               (1.)\n*\n*          con1      - Additional condition along edge 1:\n*                           = 0: No additional condition.\n*                           = 1: Zero curvature.\n*\n*          con2      - Additional condition along edge 2:\n*                           = 0: No additional condition.\n*                           = 1: Zero curvature.\n*\n*          con3      - Additional condition along edge 3:\n*                           = 0: No additional condition.\n*                           = 1: Zero curvature.\n*\n*          con4      - Additional condition along edge 4:\n*                           = 0: No additional condition.\n*                           = 1: Zero curvature.\n*\n*          order1    - Order of surface in first parameter direction.\n*\n*          order2    - Order of surface in second parameter direction.\n*\n*          iopen1    - Open/close parameter in first parameter direction.\n*                      =  1 : open surface.\n*                      =  0 : closed, non-periodic surface.\n*                      = -1 : periodic surface.\n*\n*          iopen2    - Open/close parameter in second parameter direction.\n*                      =  1 : open surface.\n*                      =  0 : closed, non-periodic surface.\n*                      = -1 : periodic surface.\n*\n*\n* Output:\n*          rsurf - Pointer to the surf produced\n*          jstat  - Status variable\n*                    < 0 - Error.\n*\n* Method:\n*     The interpolation is accomplished by using a one dimensional\n*     routine for spline interpolation called several times. \n*     First, the datapoints\n*     are considered to be idim*im1 dimentional and so on...\n*\n*\n* REFERENCES :\n*\n* CALLS      : s1357\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, May 1993.\n* REWISED BY : Vibeke Skytt, SINTEF, 0394. Introduced iopen1, iopen2.\n*\n*********************************************************************\n*/                                                               \n{\n  int i;              /* Loop control parameter                      */\n  int maxim;          /* Max (im1, im2)                              */\n  int kstat=0;        /* Status variable                             */\n  int kpos=0;         /* Position of error                           */\n  int newin1, newin2; /* Number of vertices along par. dir. 1 & 2    */\n  int numpt;              /* Needed in call to s1357                 */\n  double start=0;         /* Needed in call to s1357                 */\n  double end;\n  int *typept=SISL_NULL;       /* Array needed for call to s1357          */\n  double *pointpar=SISL_NULL;  /* Array needed for call to s1357          */\n  double *newcoeff=SISL_NULL;  /* Array needed for call to s1357          */  \n  SISLCurve *curve1=SISL_NULL, *curve2=SISL_NULL;\n  \n  /* Allocate necessary array for call to s1357 */\n\n  maxim = MAX( im1, im2 );\n  if((typept = newarray(maxim, INT))==SISL_NULL) goto err101;\n  for(i=0; i<maxim; i++)\n    typept[i] = 1;\n\n  /* Interpolation in second direction */\n\n  s1357(points, im2, idim*im1, typept, par2, con1, con2, iopen2, order2, \n\tstart, &end, &curve1, &pointpar, &numpt, &kstat);\n  if(kstat < 0) goto error;\n  if(pointpar != SISL_NULL) \n    {\n      freearray(pointpar);\n      pointpar = SISL_NULL;\n    }\n\n  newin2 = curve1->in;\n\n  /* Transpose result, store new coefficients in \n   * array newcoeff */\n\n  if( (newcoeff = newarray(idim * im1 * newin2, DOUBLE)) == SISL_NULL )\n    goto err101;\n  s6chpar(curve1->ecoef, im1, newin2, idim, newcoeff);\n\n  /* Interpolation in first parameter direction */\n\n  s1357(newcoeff, im1, idim*newin2, typept, par1, con3, con4, iopen1, order1, \n\tstart, &end, &curve2, &pointpar, &numpt, &kstat);\n  if(kstat < 0) goto error;\n  if(pointpar != SISL_NULL) \n    {\n      freearray(pointpar);\n      pointpar = SISL_NULL;\n    }\n\n  newin1 = curve2->in;\n\n  /* Transpose back coefficients */\n\n  if( (newcoeff=increasearray(newcoeff, idim*newin1*newin2, DOUBLE)) \n     == SISL_NULL )  goto err101;\n  s6chpar(curve2->ecoef, newin2, newin1, idim, newcoeff);\n\n  /* Create instance of surface */\n\n  if (((*rsurf) = newSurf(newin1, newin2, order1, order2, curve2->et,\n\t\t     curve1->et, newcoeff, 1, idim, 1)) == SISL_NULL)\n     goto err101;\n  \n  /* Set periodicity flag.  */\n  \n  (*rsurf)->cuopen_1 = curve2->cuopen;\n  (*rsurf)->cuopen_2 = curve1->cuopen;\n\n  /* Success */\n  \n  *jstat = 0;\n  goto out;  \n  \n  /* Allocation error. */\n\n  err101: \n    *jstat = -101;\n    s6err(\"s1537\",*jstat,kpos);\n    goto out;\n      \n  /* Error in lower level routine. */\n\n  error:  *jstat =kstat;\n    s6err(\"s1537\",*jstat,kpos);\n    goto out;\n  \n  out:\n    /* Free arrays */\n  \n    if (newcoeff != SISL_NULL) freearray(newcoeff);\n    if (typept != SISL_NULL) freearray(typept);\n\n    /* Free local SISL-curve objects */\n   \n    if (curve1 != SISL_NULL) freeCurve(curve1);\n    if (curve2 != SISL_NULL) freeCurve(curve2);\n  \n    return;\n}\n"
  },
  {
    "path": "src/s1538.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1538\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1538(int inbcrv,SISLCurve *vpcurv[],int nctyp[],double astpar,\n\t   int iopen,int iord2,int iflag,\n\t   SISLSurf **rsurf,double **gpar,int *jstat)\n#else\nvoid s1538(inbcrv,vpcurv,nctyp,astpar,iopen,iord2,\n           iflag,rsurf,gpar,jstat)\n     int    \tinbcrv;\n     SISLCurve  *vpcurv[];\n     int   \tnctyp[];\n     double\tastpar;\n     int    \tiopen;\n     int    \tiord2;\n     int    \tiflag;\n     SISLSurf   **rsurf;\n     double \t**gpar;\n     int    \t*jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To create a spline lofted surface\n*              from a set of input-curves.\n*\n* INPUT      : inbcrv - Number of curves in the curve-set.\n*              vpcurv  - Array (length inbcrv) of pointers to the\n*                       curves in the curve-set.\n*              nctyp  - Array (length inbcrv) containing the types\n*                       of curves in the curve-set.\n*                        1 - Ordinary curve.\n*                        2 - Knuckle curve. Treated as ordinary curve.\n*                        3 - Tangent to next curve.\n*                        4 - Tangent to prior curve.\n*                       (5 - Double derivative to prior curve.)\n*                       (6 - Double derivative to next curve.)\n*                       13 - SISLCurve giving start of tangent to next curve.\n*                       14 - SISLCurve giving end of tengent to prior curve.\n*              astpar - Start-parameter for spline lofting direction.\n*              iopen  - Flag telling if the resulting surface should\n*                       be closed or open.\n*                       -1 - The surface should be closed and periodic.\n*                        0 - The surface should be closed.\n*                        1 - The surface should be open.\n*              iord2  - Maximal order of the B-spline basis in the\n*                       lofting direction.\n*              iflag  - Flag telling if the size of the tangents in the\n*                       derivative curves should be adjusted or not.\n*                        0 - Do not adjust tangent-sizes.\n*                        1 - Adjust tangent-sizes.\n*\n* OUTPUT     : rsurf  - Pointer to the surface produced.\n*              gpar   - The input-curves are constant parameter-lines\n*                       in the parameter-plane of the produced surface.\n*                       (i) - contains the (constant) value of this\n*                             parameter of input-curve no. i.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : A common basis for all the B-spline curves are found.\n*              The curves are represented using this basis.\n*              The resulting curves are given to an interpolation\n*              routine that calculates the B-spline vertices of the\n*              resulting spline lofted surface.\n*              Throughout these routines, first parameterdirection\n*              will be the interpolating direction, second parameter-\n*              direction will be along the input curves.\n*-\n* CALLS      : s1931,s1917,s1918,s1358,s6err.\n*\n* WRITTEN BY : A. M. Ytrehus   SI  Oslo,Norway. Sep. 1988\n* Revised by : Tor Dokken, SI, Oslo, Norway, 26-feb-1989\n* Revised by : Trond Vidar Stensby, SI, 91-08\n* REVISED BY: Vibeke Skytt, 03.94. This routine corresponds to s1333,\n*                                  but differ in the use of the parameter\n*                                  iopen.\n* Revised by : Paal Fugelli, 17/08-1994.  Fixed memory leak from 'gpar'\n*              allocated in s1357().\n*\n*********************************************************************\n*/\n{\n  int kind,kcopy,kdim;\n  int kn1,kord1,knbcrv;\n  int kcnsta,kcnend;         /* Interpolation condition at start or end */\n  int ki,kj,kl,km;\n  int kleng;                 /* Number of doubles describing a curve  */\n  int ktype;                 /* Kind of interpolation condition.      */\n  int kopen;                 /* Open/closed parameter in curve direction. */\n  SISLCurve *qc;             /* Pointer to curve representing surface */\n  int *lder = SISL_NULL;\t     /* Derivative indicators from s1915. */\n  double *spar=SISL_NULL; \t     /* Param. values of point conditions. */\n  double *spar2=SISL_NULL; \t     /* Parameter values from s1915. */\n  double *sknot1=SISL_NULL;       /* Knot vector.                 */\n  double *scoef2=SISL_NULL;       /* Pointer to vertices expressed in same basis  */\n  double tstpar;             /* Parameter value of last curve                */\n  int kstat = 0;             /* Status variable. */\n  int kpos = 0;              /* Position of error. */\n  int knbpar;                /* Number of parameter values produced          */\n  int kdimcrv;               /* kdim multiplied with number of vertices kn1  */\n  int kcont;                 /* Continuity at end of curves */\n\n\n  /* Initiate variables. */\n\n  kdim = vpcurv[0]->idim;\n\n  if (inbcrv < 2) goto err179;\n\n  /* Put the curves into common basis. */\n\n  s1931 (inbcrv, vpcurv, &sknot1, &scoef2, &kn1, &kord1, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Create the parameter-values for the knot-vector\n     (in lofting direction) for a lofted surface, allocate array for\n     parameter values.    */\n\n  s1917 (inbcrv, scoef2, kn1, kdim, nctyp, astpar, iopen,\n\t &spar2, &lder, &knbcrv, &kstat);\n\n  if (kstat < 0)\n    goto error;\n\n  /* Convert condition 13 and 14 to 3 and 4 */\n\n  kleng = kn1*kdim;\n  for (ki=0 ; ki<knbcrv ; ki++)\n    {\n       ktype = nctyp[ki];\n\n      if (ktype == 13 && ki+1<knbcrv)\n        {\n\t  /*\n\t   * Start of tangent to next curve,\n\t   * make difference of next curve and this curve\n\t   */\n\n\t  for (kj=ki*kleng,kl=kj+kleng,km=0; km <kleng ; kj++,kl++,km++)\n\t      scoef2[kj] = scoef2[kl] - scoef2[kj];\n\t  nctyp[ki] = 3;\n        }\n      else if (ktype == 14 && ki>0)\n        {\n\t  /* End of tangent to prior curve,\n\t   * make difference of this curve\n\t   * and prior curve\n\t   */\n\n\t  for (kj=ki*kleng,kl=kj-kleng,km=0; km <kleng ; kj++,kl++,km++)\n\t      scoef2[kj] = scoef2[kj] - scoef2[kl];\n\t  nctyp[ki] = 4;\n        }\n    }\n\n  spar = newarray(knbcrv+1,DOUBLE);\n  if (spar==SISL_NULL) goto err101;\n\n  /*  Only copy parameter values of point conditions */\n\n  for (ki=0,kl=0; ki<knbcrv ; ki++)\n    {\n      if (nctyp[ki] == 1 || nctyp[ki] == 2)\n        {\n\t  spar[kl] = spar2[ki];\n\t  kl++;\n        }\n    }\n\n  /* Add one extra parameter value if closed curve */\n\n  if (iopen != SISL_CRV_OPEN) spar[kl] = spar2[knbcrv];\n\n  /* Adjust tangent-lengths if wanted. */\n\n  if (iflag)\n    {\n      s1918 (knbcrv, sknot1, scoef2, kn1, kord1, kdim, spar2, lder, &kstat);\n      if (kstat < 0) goto error;\n    }\n\n  /* Interpolate with point interpolation method */\n\n  kcnsta = 0;\n  kcnend = 0;\n  kdimcrv = kdim*kn1;\n\n  s1357(scoef2,knbcrv,kdimcrv,nctyp,spar,kcnsta,kcnend,iopen,iord2,astpar,\n\t&tstpar,&qc,gpar,&knbpar,&kstat);\n  if (kstat<0) goto error;\n\n  /* The knot vector in the lofting direction and the coefficients are\n     now contained in the curve object pointed to by qc */\n\n  /* Create the surface */\n\n  kind = 1;\n  kcopy = 1;\n  *rsurf = newSurf(kn1,qc->in,kord1,qc->ik,sknot1,qc->et,qc->ecoef,\n\t\t   kind,kdim,kcopy);\n  if (*rsurf == SISL_NULL) goto err101;\n\n  /* Copy cuopen flag from curve */\n  (*rsurf)->cuopen_2 = qc->cuopen;\n\n  /* Release the curve object */\n\n  freeCurve(qc);\n\n  /* Output parametervalues according to the input curves, but must\n     remember to free the space allocated in call to s1357() first.  */\n\n  if ( (*gpar) != SISL_NULL ) freearray(*gpar);  /* PFU 17/08-94. */\n  *gpar = spar;\n\n  /* Decide if the surface should have a cyclic behaviour in first\n     parameter direction i.e. the direction of the curves */\n\n  s1333_count(inbcrv,vpcurv,&kcont,&kstat);\n  if (kstat<0) goto error;\n\n  if (kcont>=0)\n      {\n        s1333_cyclic(*rsurf,kcont,&kstat);\n\tif (kstat<0) goto error;\n\n\t/* Set periodic flag */\n\t(*rsurf)->cuopen_1 = SISL_SURF_PERIODIC;\n      }\n      else\n      {\n         /* Test if the surface should be closed and non-periodic.  */\n\n         for (kopen=-2, ki=0; ki<inbcrv; ki++)\n           kopen = MAX(kopen,vpcurv[ki]->cuopen);\n         if (kopen == SISL_CRV_CLOSED) (*rsurf)->cuopen_1 = SISL_SURF_CLOSED;\n      }\n\n  /* Task done */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in allocation. */\n\n err101:\n  *jstat = -101;\n  s6err(\"s1538\",*jstat,kpos);\n  goto out;\n\n\n  /* Error in interpolation conditions. No. of curves < 2. */\n\n err179:\n  *jstat = -179;\n  s6err(\"s1538\",*jstat,kpos);\n  goto out;\n\n\n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n  s6err(\"s1538\",*jstat,kpos);\n  goto out;\n out:\n\n  /* Free allocated scratch  */\n\n  if (sknot1 != SISL_NULL) freearray(sknot1);\n  if (scoef2 != SISL_NULL) freearray(scoef2);\n  if (spar2 != SISL_NULL) freearray(spar2);\n  if (lder != SISL_NULL) freearray(lder);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1539.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1539\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1539(int inbcrv,SISLCurve *vpcurv[],int nctyp[],double epar[],\n\t   double astpar,int iopen,int iord2,int iflag,\n\t   SISLSurf **rsurf,double **gpar,int *jstat)\n#else\nvoid s1539(inbcrv,vpcurv,nctyp,epar,astpar,iopen,iord2,\n           iflag,rsurf,gpar,jstat)\n     int    \tinbcrv;\n     SISLCurve  *vpcurv[];\n     int   \tnctyp[];\n     double     epar[];\n     double\tastpar;\n     int    \tiopen;\n     int    \tiord2;\n     int    \tiflag;\n     SISLSurf   **rsurf;\n     double \t**gpar;\n     int    \t*jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To create a spline lofted surface\n*              from a set of input-curves. The parametrization\n*              of the psosition curves are given in epar.\n*\n* INPUT      : inbcrv - Number of curves in the curve-set.\n*              vpcurv  - Array (length inbcrv) of pointers to the\n*                       curves in the curve-set.\n*              nctyp  - Array (length inbcrv) containing the types\n*                       of curves in the curve-set.\n*                        1 - Ordinary curve.\n*                        2 - Knuckle curve. Treated as ordinary curve.\n*                        3 - Tangent to next curve.\n*                        4 - Tangent to prior curve.\n*                       (5 - Double derivative to prior curve.)\n*                       (6 - Double derivative to next curve.)\n*                       13 - SISLCurve giving start of tangent to next curve.\n*                       14 - SISLCurve giving end of tengent to prior curve.\n*              epar   - Array containing the wanted parametrization. Only\n*                       parametervalues corresponding to position\n*                       curves are given. For closed curves, one additional\n*                       parameter value must be spesified. The last entry\n*                       contains the parametrization of the repeted start\n*                       curve. (if the endpoint is equal to the startpoint\n*                       of the interpolation the lenght of the array should\n*                       be equal to inpt1 also in the closed case). The\n*                       number of entries in the array is thus equal to\n*                       the number of position curves (number plus one\n*                       if the curve is closed).\n*              astpar - Start-parameter for spline lofting direction.\n*              iopen  - Flag telling if the resulting surface should\n*                       be closed or open.\n*                       -1 - The surface should be closed and periodic.\n*                        0 - The surface should be closed.\n*                        1 - The surface should be open.\n*              iord2  - Maximal order of the B-spline basis in the\n*                       lofting direction.\n*              iflag  - Flag telling if the size of the tangents in the\n*                       derivative curves should be adjusted or not.\n*                        0 - Do not adjust tangent-sizes.\n*                        1 - Adjust tangent-sizes.\n*\n* OUTPUT     : rsurf  - Pointer to the surface produced.\n*              gpar   - The input-curves are constant parameter-lines\n*                       in the parameter-plane of the produced surface.\n*                       (i) - contains the (constant) value of this\n*                             parameter of input-curve no. i.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : A common basis for all the B-spline curves are found.\n*              The curves are represented using this basis.\n*              The resulting curves are given to an interpolation\n*              routine that calculates the B-spline vertices of the\n*              resulting spline lofted surface.\n*              Throughout these routines, first parameterdirection\n*              will be the interpolating direction, second parameter-\n*              direction will be along the input curves.\n*-\n* CALLS      : s1931,s1917,s1918,s1358,s6err.\n*\n* WRITTEN BY : A. M. Ytrehus   SI  Oslo,Norway. Sep. 1988\n* Revised by : Tor Dokken, SI, Oslo, Norway, 26-feb-1989\n* Revised by : Trond Vidar Stensby, SI, 91-08\n* REVISED BY: Vibeke Skytt, 03.94. This routine corresponds to s1333,\n*                                  but differ in the use of the parameter\n*                                  iopen.\n* Revised by : Paal Fugelli, 17/08-1994.  Fixed memory leak from 'gpar'\n*              allocated in s1357().\n* Revised by : Tor Dokken, SINTEF, 03.95. Renamed s1538 to s1539 and\n*                                         introdused the epar array.\n*\n*********************************************************************\n*/\n{\n  int kind,kcopy,kdim;\n  int kn1,kord1,knbcrv;\n  int kcnsta,kcnend;         /* Interpolation condition at start or end */\n  int ki,kj,kl,km;\n  int kdum;                  /* Used to indicate if curve is open/closed*/\n  int kleng;                 /* Number of doubles describing a curve  */\n  int ktype;                 /* Kind of interpolation condition.      */\n  int kopen;                 /* Open/closed parameter in curve direction. */\n  SISLCurve *qc;             /* Pointer to curve representing surface */\n  int *lder = SISL_NULL;\t     /* Derivative indicators from s1915. */\n  double *spar=SISL_NULL; \t     /* Param. values of point conditions. */\n  double *spar2=SISL_NULL; \t     /* Parameter values from s1915. */\n  double *sknot1=SISL_NULL;       /* Knot vector.                 */\n  double *scoef2=SISL_NULL;       /* Pointer to vertices expressed in same basis  */\n  double tstpar;             /* Parameter value of last curve */\n  double tprevs;             /* Previous value in spar */\n  int kstat = 0;             /* Status variable. */\n  int kpos = 0;              /* Position of error. */\n  int knbpar;                /* Number of parameter values produced          */\n  int kdimcrv;               /* kdim multiplied with number of vertices kn1  */\n  int kcont;                 /* Continuity at end of curves */\n\n\n  /* Initiate variables. */\n\n  kdim = vpcurv[0]->idim;\n\n  if (inbcrv < 2) goto err179;\n\n  /* Put the curves into common basis. */\n\n  s1931 (inbcrv, vpcurv, &sknot1, &scoef2, &kn1, &kord1, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Create the parameter-values for the knot-vector\n     (in lofting direction) for a lofted surface, allocate array for\n     parameter values.    */\n\n  s1917 (inbcrv, scoef2, kn1, kdim, nctyp, astpar, iopen,\n\t &spar2, &lder, &knbcrv, &kstat);\n\n  if (kstat < 0)\n    goto error;\n\n  /* Replace the values in spar with the input values given by\n     epar */\n\n  tprevs = spar2[0];\n  kdum =0;\n  if (iopen != SISL_CRV_OPEN) kdum=1;\n\n  for (ki=0,kj=0 ; ki<knbcrv+kdum; ki++)\n    {\n      if(tprevs<spar2[ki]) kj++;\n      tprevs=spar2[ki];\n      spar2[ki]=epar[kj];\n    }\n\n\n/* Convert condition 13 and 14 to 3 and 4 */\n\n  kleng = kn1*kdim;\n  for (ki=0 ; ki<knbcrv ; ki++)\n    {\n       ktype = nctyp[ki];\n\n      if (ktype == 13 && ki+1<knbcrv)\n        {\n\t  /*\n\t   * Start of tangent to next curve,\n\t   * make difference of next curve and this curve\n\t   */\n\n\t  for (kj=ki*kleng,kl=kj+kleng,km=0; km <kleng ; kj++,kl++,km++)\n\t      scoef2[kj] = scoef2[kl] - scoef2[kj];\n\t  nctyp[ki] = 3;\n        }\n      else if (ktype == 14 && ki>0)\n        {\n\t  /* End of tangent to prior curve,\n\t   * make difference of this curve\n\t   * and prior curve\n\t   */\n\n\t  for (kj=ki*kleng,kl=kj-kleng,km=0; km <kleng ; kj++,kl++,km++)\n\t      scoef2[kj] = scoef2[kj] - scoef2[kl];\n\t  nctyp[ki] = 4;\n        }\n    }\n\n  spar = newarray(knbcrv+1,DOUBLE);\n  if (spar==SISL_NULL) goto err101;\n\n  /*  Only copy parameter values of point conditions */\n\n  for (ki=0,kl=0; ki<knbcrv ; ki++)\n    {\n      if (nctyp[ki] == 1 || nctyp[ki] == 2)\n        {\n\t  spar[kl] = spar2[ki];\n\t  kl++;\n        }\n    }\n\n  /* Add one extra parameter value if closed curve */\n\n  if (iopen != SISL_CRV_OPEN) spar[kl] = spar2[knbcrv];\n\n  /* Adjust tangent-lengths if wanted. */\n\n  if (iflag)\n    {\n      s1918 (knbcrv, sknot1, scoef2, kn1, kord1, kdim, spar2, lder, &kstat);\n      if (kstat < 0) goto error;\n    }\n\n  /* Interpolate with point interpolation method */\n\n  kcnsta = 0;\n  kcnend = 0;\n  kdimcrv = kdim*kn1;\n\n  s1357(scoef2,knbcrv,kdimcrv,nctyp,spar,kcnsta,kcnend,iopen,iord2,astpar,\n\t&tstpar,&qc,gpar,&knbpar,&kstat);\n  if (kstat<0) goto error;\n\n  /* The knot vector in the lofting direction and the coefficients are\n     now contained in the curve object pointed to by qc */\n\n  /* Create the surface */\n\n  kind = 1;\n  kcopy = 1;\n  *rsurf = newSurf(kn1,qc->in,kord1,qc->ik,sknot1,qc->et,qc->ecoef,\n\t\t   kind,kdim,kcopy);\n  if (*rsurf == SISL_NULL) goto err101;\n\n  /* Copy cuopen flag from curve */\n  (*rsurf)->cuopen_2 = qc->cuopen;\n\n  /* Release the curve object */\n\n  freeCurve(qc);\n\n  /* Output parametervalues according to the input curves, but must\n     remember to free the space allocated in call to s1357() first.  */\n\n  if ( (*gpar) != SISL_NULL ) freearray(*gpar);  /* PFU 17/08-94. */\n  *gpar = spar;\n\n  /* Decide if the surface should have a cyclic behaviour in first\n     parameter direction i.e. the direction of the curves */\n\n  s1333_count(inbcrv,vpcurv,&kcont,&kstat);\n  if (kstat<0) goto error;\n\n  if (kcont>=0)\n      {\n        s1333_cyclic(*rsurf,kcont,&kstat);\n\tif (kstat<0) goto error;\n\n\t/* Set periodic flag */\n\t(*rsurf)->cuopen_1 = SISL_SURF_PERIODIC;\n      }\n      else\n      {\n         /* Test if the surface should be closed and non-periodic.  */\n\n         for (kopen=-2, ki=0; ki<inbcrv; ki++)\n           kopen = MAX(kopen,vpcurv[ki]->cuopen);\n         if (kopen == SISL_CRV_CLOSED) (*rsurf)->cuopen_1 = SISL_SURF_CLOSED;\n      }\n\n  /* Task done */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in allocation. */\n\n err101:\n  *jstat = -101;\n  s6err(\"s1539\",*jstat,kpos);\n  goto out;\n\n\n  /* Error in interpolation conditions. No. of curves < 2. */\n\n err179:\n  *jstat = -179;\n  s6err(\"s1539\",*jstat,kpos);\n  goto out;\n\n\n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n  s6err(\"s1539\",*jstat,kpos);\n  goto out;\n out:\n\n  /* Free allocated scratch  */\n\n  if (sknot1 != SISL_NULL) freearray(sknot1);\n  if (scoef2 != SISL_NULL) freearray(scoef2);\n  if (spar2 != SISL_NULL) freearray(spar2);\n  if (lder != SISL_NULL) freearray(lder);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1540.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n#define S1540\n\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1540  ( double   et[],\n\t int      ik,\n\t int      in,\n\t double   ax[],\n\t int      im,\n\t int      ider,\n\t double   ebder[],\n\t int      ileft[],\n\t int     *jstat )\n#else\nvoid\ns1540 ( et, ik, in, ax, im, ider, ebder, ileft, jstat )\n  double   et[];\n  int      ik;\n  int      in;\n  double   ax[];\n  int      im;\n  int      ider;\n  double   ebder[];\n  int      ileft[];\n  int     *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE:\tGiven a (polynomial) spline basis\n*\t\t(with k-regular knot vector)\n*\t\tand an array of parameters ax[0, ..., im-1]\n*\t\tcalculate the basis values (and first derivatives if ider = 1)\n*\t\tand fill them in the array ebder[].\n*\n* INPUT:\tik     -  spline order\n*\t\tin     -  number of spline functions (only for checking ax).\n*\t\tax     -  array of parameters\n*\t\tim     -  length of the array ax[]\n*\n* OUTPUT:\tebder  -  array containing the basis values\n*\t\t          ider = 0:  B(ax[0   ],i),...,B(ax[0   ],i+ik-1)\n*\t\t                     B(ax[1   ],i),...,B(ax[1   ],i+ik-1)\n*\t\t                     B(ax[im-1],i),...,B(ax[im-1],i+ik-1)\n*\n*\t\t          ider = 1:  B (ax[0   ],i),...,B (ax[0   ],i+ik-1)\n*\t\t                     B'(ax[0   ],i),...,B'(ax[0   ],i+ik-1)\n*\t\t                     B (ax[1   ],i),...,B (ax[1   ],i+ik-1)\n*\t\t                     B'(ax[1   ],i),...,B'(ax[1   ],i+ik-1)\n*\t\t\t\t\t\t...............\n*\t\t                     B (ax[im-1],i),...,B (ax[im-1],i+ik-1)\n*\t\t                     B'(ax[im-1],i),...,B'(ax[im-1],i+ik-1)\n*\n*\t\tIe. if we have positions and derivatives, then\n*\t\tfor each ax[i] first the positions come and then the\n*\t\tderivatives.\n*              jstat    - Status messages\n*\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n* IMPORTANT:\tebder is filled differently by the corresponding SISL routine\n*\t\t(s1504):\n*\t\t\t B (ax[0   ],i     ), B'(ax[0   ],i     ),\n*\t\t\t B (ax[0   ],i+1   ), B'(ax[0   ],i+1   ),\n*\t\t\t        ...............\n*\t\t         B (ax[0   ],i+ik-1), B'(ax[0   ],i+ik-1),\n*\t\t\t B (ax[1   ],i     ), B'(ax[1   ],i     ),\n*\t\t\t        ...............\n*\t\t\t B (ax[im-1],i+ik-1), B'(ax[im-1],i+ik-1),\n*\n*\n* WRITTEN BY: \tGeir Westgaard, SINTEF, Oslo, November 1999\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;      /* Local status variable.                          */\n  int kpos  = 0;      /* The position of error.                          */\n  int i, k;           /* Control variables in for loops and for stepping\n                         through arrays.                                 */\n  int size;           /* (ider+1) * ik.                                  */\n  double *eder = SISL_NULL;/* B-spline evaluationas at a single value.        */\n  double tmpeder[10]; /* meaning: tmpeder[(ider+1)*ik]\n\t\t\t and assuming: ider <= 1 and ik <= 5             */\n\n\n\n   /* Check the input. */\n\n    if ( ider < 0 || ider > 1        ) goto err10;\n    if ( ik < 2 || ik > 5            ) goto err10;\n    if ( im  < 0                     ) goto err10;\n\n\n   /* Set local variables. */\n\n   size = (ider + 1)*ik;\n\n   eder = ebder;\n\n\n   if ( ider == 0 )\n   {\n      for( k = 0; k < im; k++, eder += ik )\n      {\n\t s1220( et, ik, in, ileft + k, ax[k], ider, eder, &kstat );\n\n\t if ( kstat < 0 ) goto error;\n      }\n   }\n   else\n   {\n\n      for( k = 0; k < im; k++, eder += size )\n      {\n\t s1220( et, ik, in, ileft + k, ax[k], ider, tmpeder, &kstat );\n\n\t if ( kstat < 0 ) goto error;\n\n\t for ( i = 0; i < ik; ++i )\n\t {\n\t    eder[i     ] = tmpeder[2*i    ];\n\t    eder[i+ik  ] = tmpeder[2*i + 1];\n\t }\n      }\n   }\n\n\n\n\n  /* Successful computations.  */\n\n   *jstat = 0;\n   goto out;\n\n/* Error in input. */\nerr10: *jstat = -10;\ns6err( \"s1540\", *jstat, kpos );\ngoto out;\n\n/* Error in lower level routine.  */\nerror:  *jstat = kstat;\ns6err( \"s1540\", *jstat, kpos );\ngoto out;\n\n\n\n\nout: return;\n\n}\n"
  },
  {
    "path": "src/s1541.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n#define S1541\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1541   ( SISLCurve  *pc1,\n\t  int         npol,\n\t  double      ebder[],\n\t  int         ileft[],\n\t  double      eder[],\n\t  int        *jstat )\n\n#else\nvoid\ns1541 ( pc1, npol, ebder, ileft, eder, jstat )\n     SISLCurve*  pc1;\n     int         npol;\n     double      ebder[];\n     int         ileft[];\n     double      eder[];\n     int        *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE:\tGiven a (polynomial) spline curve pc1 and\n*\t\tpreevaluated basis functions (using s1540()) on an\n*               npol polyline, calculate the 3D positions on\n*\t\tthat polyline (eder).\n*\n* INPUT:\tpc1  \t-  the spline curve\n*\t\tnpol    -  the number of polyline points\n*              ebder   -  array containing the basis values\n*                           B(ax[0   ],i0-k+1),...,B(ax[0   ],i0)\n*                           B(ax[1   ],i1-k+1),...,B(ax[1   ],i1)\n*                            :                :\n*                           B(ax[m1-1],im1-1-k+1),...,B(ax[m1-1],im1-1)\n*\n*         \tileft   -  ileft[i] <= ti < ileft[i] + 1\n*\t\t\t   (exception for ti == in : ileft[ti] = n-1)\n*\n* OUTPUT:\teder\t-  contains the 3D polyline points\n*              jstat    - Status messages\n*\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*\n* METHOD:\n*\n* WRITTEN BY:\tGeir Westgaard, SINTEF, Oslo, November 1999\n* REVISED BY:   Vibeke Skytt, SINTEF, Dec. 2006. Allow dimension different from 3\n*                                                and rational curves\n*\n*********************************************************************\n*/\n{\n   int m = 0, m1 = 0;\n   int my, my1;\n   int np, i, j;\n   int ik;\n   double bas;\n   double* ecoef = SISL_NULL;\n   int kdim = pc1->idim;\n   double scratch[4];\n   double *xyz = NULL;\n   int krat = (pc1->ikind == 2 || pc1->ikind == 4);\n\n\n   /* Check the input. */\n\n   //if ( pc1->idim != 3 ) goto err104;\n\n   if (krat)\n       kdim++;\n\n   if (kdim > 4)\n   {\n       if ((xyz = newarray(kdim, DOUBLE)) == SISL_NULL)\n\t   goto err101;\n   }\n   else xyz = scratch;\n\n\n   /* Set input to local variables. */\n\n   ik    = pc1 -> ik;\n   ecoef = (krat) ? pc1->rcoef : pc1 -> ecoef;\n\n\n   for ( np = 0; np < npol; np++ )\n   {\n     my  = ileft[ np ] - ik;\n     \n     for (j=0; j<kdim; j++)\n\t xyz[j] = 0.0;\n\n     for ( i = 0; i < ik; i++ )\n     {\n       my++;\n       my1 = kdim*my;\n       bas = ebder[ m1++ ];\n\n       for (j=0; j<kdim; j++)\n\t   xyz[j] += ecoef[my1+j]*bas;\n     }\n\n     if (krat)\n     {\n\t for (j=0; j<pc1->idim; j++)\n\t     xyz[j] /= xyz[pc1->idim];\n     }\n\n     for (j=0; j<pc1->idim; j++)\n\t eder[m++] = xyz[j];\n   }\n\n\n  /* Successful computations.  */\n\n   *jstat = 0;\n   goto out;\n\n/* Error in input, crv->idim != 3 */\n //err104: *jstat = -104;\n //        s6err( \"s1541\", *jstat, 0 );\n //        goto out;\n\n err101: *jstat = -101;\n         s6err( \"s1541\", *jstat, 0 );\n         goto out;\n\nout: \n\t if (xyz != SISL_NULL && xyz != scratch)\n\t     freearray(xyz);\n\t return;\n\n}\n"
  },
  {
    "path": "src/s1542.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n#define S1542\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1542(SISLCurve *pc1,int m,double x[],double eder[],int *jstat)\n#else\nvoid s1542(pc1,m,x,eder,jstat)\n     SISLCurve *pc1;\n     int      m;\n     double   x[];\n     double   eder[];\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate the curve pointed at by pc1 over a m grid\n*              of points (x[i]). Only positions are evaluated.\n*              This does not work for in the rational case.\n*\n* INPUT      : pc1    - Pointer to the curve to evaluate.\n*              m      - Number of grid points.\n*              x      - Array of parameter values of the grid.\n*\n* OUTPUT     : eder   - Array where the derivatives of the curve\n*                       are placed, dimension\n*                         idim * (ider+1) * m.\n*                       The sequence is position at point x[0],\n*                       followed by the same information at x[1],\n*                       etc.\n*              jstat  - status messages\n*                          = 0      : Ok.\n*                          < 0      : Error.\n*\n* METHOD     : We call s1540 to pre-evaluate the B-splines then call\n*              s1541 to multiply them with the coefficients.\n*\n*-\n* CALLS      : s1540, s1541.\n*\n* WRITTEN BY : Johannes Kaasa, SINTEF, Nov. 1999.\n*********************************************************************\n*/\n{\n  int ider = 0;        /* Only evaluate position.                         */\n  int kstat=0;         /* Local status variable.                          */\n  int kpos=0;          /* The position of error.                          */\n  int in;              /* The number of B-splines accociated with the knot\n\t\t \t vector.                                          */\n  int ik;              /* The polynomial order of the curve.              */\n  int kdim;            /* The space dimension of the surface. */\n  double *ebder=SISL_NULL;  /* Triple array of dimension (ider+1)*ik*m\n                         containing dericatives of B-splines. */\n  int *ileft=SISL_NULL;     /* Array of dimension m containing the left knots\n                         of the B-splines. */\n  double *et = SISL_NULL;   /* The knot vector. */\n\n  in = pc1 -> in;\n  ik = pc1 -> ik;\n  et = pc1 -> et;\n  kdim = pc1 -> idim;\n\n  /* Check the input. */\n  if (kdim < 1) goto err102;\n  if (ik < 1) goto err115;\n  if (in < ik) goto err116;\n  if (ider < 0) goto err178;\n\n  /* Pre-evaluate B-splines. */\n  ebder = newarray((ider+1)*ik*m, DOUBLE);\n  if(ebder == SISL_NULL) goto err101;\n\n  ileft = newarray(m,INT);\n  if(ileft == SISL_NULL) goto err101;\n\n  s1540(et,ik,in,x,m,ider,ebder,ileft,&kstat);\n  if(kstat < 0) goto error;\n\n  /* Multiply out with the coefficients. */\n\n  s1541(pc1,m,ebder,ileft,eder,&kstat);\n  if(kstat < 0) goto error;\n\n  /* Free memory. */\n  if(ebder != SISL_NULL) freearray(ebder);\n  if(ileft != SISL_NULL) freearray(ileft);\n\n  *jstat = 0;\n  goto out;\n\n  /* Not enough memory. */\n err101: *jstat = -101;\n  s6err(\"s1542\",*jstat,kpos);\n  goto out;\n\n  /* kdim less than 1. */\n err102: *jstat = -102;\n  s6err(\"s1542\",*jstat,kpos);\n  goto out;\n\n  /* Polynomial order less than 1. */\n err115: *jstat = -115;\n  s6err(\"s1542\",*jstat,kpos);\n  goto out;\n\n  /* Fewer B-splines than the order. */\n err116: *jstat = -116;\n  s6err(\"s1542\",*jstat,kpos);\n  goto out;\n\n  /* Illegal derivative requested. */\n err178: *jstat = -178;\n  s6err(\"s1221\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n error:  *jstat = kstat;\n  s6err(\"s1542\",*jstat,kpos);\n  goto out;\n\n out:\n    return;\n}\n"
  },
  {
    "path": "src/s1600.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1600.c,v 1.2 2001-03-19 15:58:51 afr Exp $\n *\n */\n\n\n#define S1600\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1600(SISLCurve *pc,double epoint[],double enorm[],int idim,SISLCurve **rc,int *jstat)\n#else\nvoid s1600(pc,epoint,enorm,idim,rc,jstat)\n     SISLCurve  *pc;\n     double epoint[];\n     double enorm[];\n     int    idim;\n     SISLCurve  **rc;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To mirror a B-spline curve about a plane\n*             \n*\n* INPUT      : pc     - The input B-spline curve.   \n*              epoint - a point in the plane\n*              enorm  - normal vector to the plane  \n*              idim   - The dimension of the space\n*\n* OUTPUT     : rc     - Pointer to the mirrored curve\n*              jstat  - status messages\n  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : The vertices are mirrored. All other curve data are \n*              copied into the new curve. \n*\n* EXAMPLE OF USE:\n*\n* REFERENCES :\n*\n*-                                                 \n* CALLS      : s6norm,s6diff,s6scpr,newCurve,s6err\n*\n*\n* WRITTEN BY : Qyvind Hjelle, SI, Oslo, Norway. 10. Nov 1988\n* REVISED BY : Johannes Kaasa, SI, Oslo, Norway April 1992 (Introduced NURBS)\n*\n*********************************************************************\n*/\n{\n  int kstat;          /* Status variable                                 */\n  int kiv;            /* Counter for vertices                            */\n  int kid;            /* Counter for dimension                           */\n  int kn;             /* The number of B-splines, i.e., the dimension of\n\t\t\t the spline space associated with the knot\n\t\t\t vector.                                         */\n  int kk;             /* The polynomial order of the curve.              */\n  int kind;           /* Type of curve, 2 and 4 are rational curves.     */\n  int kdim;           /* The dimension of the space in which the curve\n\t\t\t lies. Equivalently, the number of components\n\t\t\t of each B-spline coefficient.                   */\n  int kvert;          /* Counter for position in mirrored vertex array   */\n  int kpos=0;         /* Position of error                               */\n  \n  double *snorm=SISL_NULL; /* Pointer to normalized normal                    */\n  double *svecpv=SISL_NULL;/* Pointer to vector from pointin plane to vertex  */\n  double *smirr=SISL_NULL; /* Pointer to mirrored vertex array                */\n  double *st;         /* Pointer to the first element of the knot vector\n\t\t\t of the curve. The knot vector has [kn+kk]\n\t\t\t elements.                                       */\n  double *svert;      /* Pointer to a vertex                             */\n  double *scoef;      /* Pointer to the first element of the curve's\n\t\t\t B-spline coefficients. This is assumed to be an\n\t\t\t array with [kn*kdim] elements stored in the\n\t\t\t following order:\n\t\t\t First the kdim components of the first B-spline\n\t\t\t coefficient, then the kdim components of the\n\t\t\t second B-spline coefficient and so on.          */\n  \n  double tdist;       /* Distance */\n  \n  /* Check if curve is correct */\n  \n  s1707(pc,&kstat);\n  if (kstat < 0) goto error;\n  \n  \n  /* Describe curve with local parameters.  */\n  kn = pc -> in;\n  kk = pc -> ik;\n  st = pc -> et;\n  kind = pc->ikind;\n  if (kind == 2 || kind == 4)\n    scoef = pc->rcoef;\n  else\n    scoef = pc->ecoef;\n  kdim = pc -> idim;          \n  \n  /* Check if conflicting dimensions */  \n  \n  if (kdim != idim) goto err106;\n  if (kind == 2 || kind == 4)\n    kdim++;\n  \n  /* Allocate space for normalized normalvector , vector from point in\n     plane to vertex and new vertex array */\n  \n  snorm = newarray(idim,DOUBLE);\n  if (snorm == SISL_NULL) goto err101;\n  \n  svecpv = newarray(idim,DOUBLE);\n  if (svecpv == SISL_NULL) goto err101;\n  \n  smirr = newarray(kdim*kn,DOUBLE);\n  if (svecpv == SISL_NULL) goto err101;\n  \n  /* Normalize normal vector */\n  \n  (void)s6norm(enorm,idim,snorm,&kstat);     \n  if (kstat < 0) goto error;\n  \n  /* Do for all vertices */\n  \n  kvert = 0;\n  for (kiv=0; kiv<kn; kiv++) \n    {\n      /* Find vector from point in plane to vertex */\n      \n      svert = scoef + kiv*kdim;\n      s6diff(svert,epoint,idim,svecpv);\n      \n      /* Find distance between the vertex and the plane */\n      \n      tdist  =  s6scpr(svecpv,snorm,idim);\n      tdist *= (double)2.0;\n      \n      /* Find the mirrored vertex */\n      \n      for (kid=0; kid<idim; kid++,kvert++)\n\t{\n\t  smirr[kvert] = scoef[kvert] - tdist*snorm[kid];\n\t}  \n      if (kind == 2 || kind == 4)\n\t{\n\t   smirr[kvert] = scoef[kvert];\n\t   kvert++;\n\t}\n    }\n  \n  /* Make the mirrored curve */\n  \n  *rc = SISL_NULL;              \n  *rc = newCurve(kn,kk,st,smirr,kind,idim,1);\n  if (*rc == SISL_NULL) goto err101;                \n  \n  /* Copy cuopen flag.  */\n  \n  (*rc)->cuopen = pc->cuopen;\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in memory allocation */\n  \n err101: *jstat = -101;\n  s6err(\"s1600\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input, conflicting dimensions */\n  \n err106: *jstat = -106;\n  s6err(\"s1600\",*jstat,kpos);\n  goto out;\n  \n  \n  /* Error in lower level function */  \n  \n error:  *jstat = kstat;\n  s6err(\"s1600\",*jstat,kpos); \n  goto out;\n  \n out:\n  if (snorm  != SISL_NULL) freearray(snorm);\n  if (svecpv != SISL_NULL) freearray(svecpv);\n  if (smirr  != SISL_NULL) freearray(smirr);\n  return;\n}\n                    \n"
  },
  {
    "path": "src/s1601.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1601.c,v 1.2 2001-03-19 15:58:51 afr Exp $\n *\n */\n\n\n#define S1601\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1601(SISLSurf *psurf,double epoint[],double enorm[],int idim,SISLSurf **rsurf,int *jstat)\n#else\nvoid s1601(psurf,epoint,enorm,idim,rsurf,jstat)\n     SISLSurf   *psurf;\n     double epoint[];\n     double enorm[];\n     int    idim;\n     SISLSurf   **rsurf;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To mirror a B-spline surface about a plane\n*             \n*\n* INPUT      : psurf  - The input B-spline surface   \n*              epoint - a point in the plane\n*              enorm  - normal vector to the plane  \n*              idim   - The dimension of the space\n*\n* OUTPUT     : rsurf  - Pointer to the mirrored surface\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : The vertices are mirrored. All other surface data\n*              are copied into the new surface.  \n*\n* EXAMPLE OF USE:\n*\n* REFERENCES :\n*\n*-                                                 \n* CALLS      : s6norm,s6diff,s6scpr,newSurf,s6err\n*\n*\n* WRITTEN BY : Qyvind Hjelle, SI, Oslo, Norway. 10. Nov 1988\n* REVISED BY : Johannes Kaasa, SI, Oslo, Norway April 1992 (Introduced NURBS)\n*\n*********************************************************************\n*/\n{\n  int kstat=0;        /* Status variable                                 */\n  int kiv;            /* Counter for vertices                            */\n  int kid;            /* Counter for dimension                           */\n  \n  int kn1;            /* Number of vertices in first direction of psurf  */\n  int kn2;            /* Number of vertices in second direction of psurf */\n  int kk1;            /* Order in first direction of input psurf         */\n  int kk2;            /* Order in second direction of input psurf        */\n  int kind;           /* Type of surface, 2 and 4 are rational surfaces. */\n  int kdim;           /* The dimension of the space in which the curve\n\t\t\t lies. Equivalently, the number of components\n\t\t\t of each B-spline coefficient.                   */\n  int kvert;          /* Counter for position in mirrored vertex array   */\n  int kpos=0;         /* Position of error                               */\n  \n  double *snorm=SISL_NULL; /* Pointer to normalized normal                    */\n  double *svecpv=SISL_NULL;/* Pointer to vector from pointin plane to vertex  */\n  double *smirr=SISL_NULL; /* Pointer to mirrored vertex array                */\n  double *st1;        /* First knot vector is psurf                       */\n  double *st2;        /* Second knot vector is psurf                      */\n  double *svert;      /* Pointer to a vertex                             */\n  double *scoef;      /* Pointer to the first element of the curve's\n\t\t\t B-spline coefficients. This is assumed to be an\n\t\t\t array with [kn*kdim] elements stored in the\n\t\t\t following order:\n\t\t\t First the kdim components of the first B-spline\n\t\t\t coefficient, then the kdim components of the\n\t\t\t second B-spline coefficient and so on.          */\n  \n  double tdist;       /* Distance */\n  \n  /* Make local pointers */\n  \n  kn1   = psurf -> in1;\n  kn2   = psurf -> in2;\n  kk1   = psurf -> ik1;\n  kk2   = psurf -> ik2;\n  kdim  = psurf -> idim;\n  st1   = psurf -> et1;\n  st2   = psurf -> et2;\n  kind  = psurf -> ikind;\n  if (kind == 2 || kind == 4)\n    scoef = psurf -> rcoef;\n  else\n    scoef = psurf -> ecoef;\n  \n  /* Check if conflicting dimensions */  \n  \n  if (kdim != idim) goto err106;\n  if (kind == 2 || kind == 4)\n    kdim++;\n  \n  /* Allocate space for normalized normalvector , vector from point in\n     plane to vertex and new vertex array */\n  \n  snorm = newarray(idim,DOUBLE);\n  if (snorm == SISL_NULL) goto err101;\n  \n  svecpv = newarray(idim,DOUBLE);\n  if (svecpv == SISL_NULL) goto err101;\n  \n  smirr = newarray(kdim*kn1*kn2,DOUBLE);\n  if (svecpv == SISL_NULL) goto err101;\n  \n  \n  /* Normalize normal vector */\n  \n  (void)s6norm(enorm,idim,snorm,&kstat);     \n  if (kstat < 0) goto error;\n  \n  /* Do for all vertices */\n  \n  kvert = 0;\n  for (kiv=0; kiv<kn1*kn2; kiv++) \n    {\n      \n      /* Find vector from point in plane to vertex */\n      \n      svert = scoef + kiv*kdim;\n      s6diff(svert,epoint,idim,svecpv);\n      \n      /* Find distance between the vertex and the plane */\n      \n      tdist =  s6scpr(svecpv,snorm,idim);\n      tdist *=(double)2.0;\n      \n      /* Find the mirrored vertex */\n      \n      for (kid=0; kid<idim; kid++,kvert++)\n\t{\n\t  smirr[kvert] = scoef[kvert] - tdist*snorm[kid];\n\t}\n      if (kind == 2 || kind == 4)\n\t{\n\t   smirr[kvert] = scoef[kvert];\n\t   kvert++;\n\t}\n    }\n  \n  \n  /* Make the mirrored surface. */\n  \n  *rsurf = SISL_NULL;              \n  *rsurf = newSurf(kn1,kn2,kk1,kk2,st1,st2,smirr,psurf->ikind,idim,1);\n  if (*rsurf == SISL_NULL) goto err101;                \n  \n  /* Set periodicity flag. */\n  \n  (*rsurf)->cuopen_1 = psurf->cuopen_1;\n  (*rsurf)->cuopen_2 = psurf->cuopen_2;\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in memory allocation */\n  \n err101: \n  *jstat = -101;\n  s6err(\"s1601\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input, conflicting dimensions */\n  \n err106: \n  *jstat = -106;\n  s6err(\"s1601\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level function */  \n  \n error:  \n  *jstat = kstat;\n  s6err(\"s1601\",*jstat,kpos); \n  goto out;\n  \n out:\n  if (snorm  != SISL_NULL) freearray(snorm);\n  if (svecpv != SISL_NULL) freearray(svecpv);\n  if (smirr  != SISL_NULL) freearray(smirr);\n  return;\n}    \n                    \n"
  },
  {
    "path": "src/s1602.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1602.c,v 1.3 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1602\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1602(double estapt[],double endpt[],int ik,int idim,double astpar,\n\t   double *cendpar,SISLCurve **rc,int *jstat)\n#else\nvoid s1602(estapt,endpt,ik,idim,astpar,cendpar,rc,jstat)\n     double estapt[];\n     double endpt[];\n     int    ik;\n     int    idim;\n     double astpar;\n     double *cendpar;\n     SISLCurve  **rc;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Convert a straight line to a B-spline described curve.\n*             \n*\n* INPUT      : estapt - start point of the straight line \n*              endpt  - end point of the straight line\n*              ik     - the order of the B-spline curve to be found\n*              idim   - The dimension of the space\n*              astpar - start value of parameterization of the curve\n*             \n* OUTPUT\n*            : cendpar - parameter used at the end of the curve\n*              rc      - Pointer to the found curve\n*              jstat  - status messages\n  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : First the knots are found with ik knots in the start\n*              and ik knots in the end of the curve. Then a modified\n*              Marsdens identity is used to find ik vertices equally \n*              spaced on the straight line.\n*\n* EXAMPLE OF USE:\n*\n* REFERENCES :\n*\n*-                                                 \n* CALLS      : s6dist,newCurve,s6err\n*\n*\n* WRITTEN BY : Qyvind Hjelle, SI, Oslo, Norway. 10. Nov 1988\n*\n*********************************************************************\n*/\n{\n  int kit;            /* Loop control                                    */\n  int kit2;           /* Loop contero                                    */\n  int kvert;          /* Counter for position in vertex array            */\n  int kpos=0;         /* Position of error                               */\n  \n  double *st=SISL_NULL;    /* Pointer to the first element of the knot vector\n\t\t\t of the curve.                                   */\n  double *scoef=SISL_NULL; /* Pointer to the first element of the curve's\n\t\t\t B-spline coefficients.                          */\n  double tdist;       /* Distance                                        */\n  double tdel;        /* Delta x, y , ....                               */\n  \n  /* Check input */          \n  \n  if (idim <  1) goto err102;\n  if (ik   <  2) goto err109;\n  \n  /* Find distance between start nd end point */\n  tdist = s6dist(estapt,endpt,idim);\n  \n  \n  /* Make knots. First allocate space */\n  \n  st = newarray(ik*2,DOUBLE);\n  if (st == SISL_NULL) goto err101;\n  \n  for (kit=0; kit<ik; kit++) \n    {\n      st[kit]    = astpar;\n      st[kit+ik] = astpar + tdist;\n    }\n  \n  /* calculate the vertices. First allocate space */ \n  \n  /* First allocate space for vertices */ \n  \n  scoef = newarray(ik*idim,DOUBLE);\n  if (scoef == SISL_NULL) goto err101;\n  \n  /* Find first and last vertex. */ \n  \n  kvert = (ik-1) * idim;\n  for (kit=0; kit<idim; kit++,kvert++) \n    {\n      scoef[kit]   = estapt[kit];\n      scoef[kvert] = endpt[kit];\n    }\n  \n  /* Find other vertices */ \n  \n  for (kit=0; kit<idim; kit++)\n    {   \n      tdel = (endpt[kit] - estapt[kit])/(ik - 1);\n      for (kit2=2; kit2<ik; kit2++)\n\tscoef[(kit2-1)*idim + kit] = scoef[(kit2-2)*idim + kit] + tdel; \n    }\n  \n  /* Make the curve */\n  \n  *rc = SISL_NULL;              \n  *rc = newCurve(ik,ik,st,scoef,1,idim,1);\n  if (*rc == SISL_NULL) goto err101;                \n  \n  *cendpar = st[ik];\n  *jstat = 0;\n  goto out;\n  \n  /* Error in memory allocation */\n  \n err101: \n  *jstat = -101;\n  s6err(\"s1602\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Dimension less than 1 */\n  \n err102: \n  *jstat = -102;\n  s6err(\"s1602\",*jstat,kpos);\n  goto out;                          \n  /* Error in input. Order less than 2 */\n  \n err109: \n  *jstat = -109;\n  s6err(\"s1602\",*jstat,kpos);\n  goto out;                          \n    \n out:\n  if (st     != SISL_NULL) freearray(st);\n  if (scoef  != SISL_NULL) freearray(scoef);\n  return;\n}          \n                    \n"
  },
  {
    "path": "src/s1603.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1603.c,v 1.2 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1603\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1603(SISLSurf *psurf,double *cmin1,double *cmin2,double *cmax1,double *cmax2,int *jstat)\n#else\nvoid s1603(psurf,cmin1,cmin2,cmax1,cmax2,jstat)\n     SISLSurf   *psurf;\n     double *cmin1;\n     double *cmin2;\n     double *cmax1;\n     double *cmax2;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To pick the parametrization of a B-spline surface\n*\n* INPUT      : pc     - The B-spline surface.   \n*\n* OUTPUT     : cmin1  - Start parameter in first parameter directon. \n*              cmin2  - Start parameter in second parameter directon.\n*              cmax1  - End   parameter in first parameter directon. \n*              cmax2    End   parameter in second parameter directon.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error  \n*             \n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-                                                 \n* CALLS      : s6err\n*              \n*\n* WRITTEN BY : Qyvind Hjelle SI, Oslo, Norway. Nov 1988\n*\n*********************************************************************\n*/\n{\n  int kpos=0;              /* Position of error          */\n  \n  /* Check surf pointer */\n  \n  if (!psurf) goto err118;\n  \n  /* Pick parametrization */\n  \n  *cmin1 = psurf->et1[psurf->ik1-1];\n  *cmax1 = psurf->et1[psurf->in1];\n  *cmin2 = psurf->et2[psurf->ik2-1];\n  *cmax2 = psurf->et2[psurf->in2];\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in input, no B-spline surface given */\n  \n err118: \n  *jstat = -118;\n  s6err(\"s1603\",*jstat,kpos);\n  goto out;\n  \n out:\n  \n  return;\n}          \n"
  },
  {
    "path": "src/s1604.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1604.c,v 1.3 2001-03-19 15:58:51 afr Exp $\n *\n */\n\n\n#define S1604\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1604(double epoint[],int inbpnt,double astpar,int iopen,int idim,int ik,\n\t   SISLCurve **rc,int *jstat)\n#else\nvoid s1604(epoint,inbpnt,astpar,iopen,idim,ik,rc,jstat)\n\t   double epoint[];\n\t   int    inbpnt;\n\t   double astpar;\n\t   int    iopen;\n\t   int    idim;\n\t   int    ik;\n\t   SISLCurve  **rc;\n\t   int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To calculate a B-spline curve using the input points as\n*              controlling vertices. The distances between the points are\n*              used as parametrization.\n*\n*\n* INPUT      : epoint - The array containing the points to be used as\n*                       controlling vertices of the B-spline curve.\n*              inbpnt - No. of points in epoint.\n*              astpar - Parameter value to be used at the start of the curve.\n*              iopen  - Open/close condition (Open=1,Close=0)\n*              idim   - The dimension of the space\n*              ik     - The order of the B-spline curve to be produced.\n*\n* OUTPUT     : rc     - Pointer to the curve\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : First the parametrization of the curve is calculated.\n*              If more than ik adjacent vertices are equal then the\n*              superfluous vertices are removed. Then the knots are\n*              calculated.\n*\n* EXAMPLE OF USE:\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6dist,s1902,s1713,s1750,newCurve,s6err\n*\n*\n* WRITTEN BY : Qyvind Hjelle, SI, Oslo, Norway. 22. Nov 1988\n* REVISED BY : Bjoern Olav Hoset, SI, Oslo, Norway, Feb. 1992\n*              Calls s1902 instead of fortran functions.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway. 24/08-1994. Changed\n*              icopy param. (from 0 to 2) to fix memory leak.\n*********************************************************************\n*/\n{\n  int kstat;          /* Status variable                                 */\n  int kn;             /* The number of B-splines, i.e., the dimension of\n\t\t\t the spline space associated with the knot\n\t\t\t vector.                                         */\n  int kk;             /* The polynomial order of the curve.              */\n  int kpos=0;         /* Position of error                               */\n  int ki;             /* Counter for loop control                        */\n\n  double *spara=SISL_NULL; /* Pointer to parameterization array               */\n  double *scoef=SISL_NULL; /* Pointer to vertex array                         */\n  double *sknot=SISL_NULL; /* Pointer to knot vector                          */\n  double tdist;       /* Distance */\n  double tlastpar;    /* Last value in the parameterization array        */\n  SISLCurve *qc=SISL_NULL;\n  SISLCurve *qc2 = SISL_NULL;\n\n\n  /* Control input     */\n\n/* -> new statement guen & ujk Thu Jul  2 14:59:05 MESZ 1992 */\n\n/* make compatible to old use of s1604 */\n  if (iopen==SISL_CRV_CLOSED) iopen = SISL_CRV_PERIODIC;\n\n/* a new version with input-iopen == rc->cuopen\n   should be made, with a name different from any\n   other.\n  NOTE: There is an error in this function when iopen = 0\n\tqc as input to s1713 (and s1750) then has wrong flag !!*/\n\n/* <- new statement guen & ujk Thu Jul  2 14:59:05 MESZ 1992 */\n\n  kk = ik;\n  if  (inbpnt < kk)\n    kk = inbpnt;\n\n  if  (kk < 2) goto err109;\n\n  if  (iopen != SISL_CRV_OPEN && iopen != SISL_CRV_CLOSED\n       && iopen != SISL_CRV_PERIODIC) goto err113;\n\n  /* Allocate space for parameterization    */\n\n  spara = newarray(inbpnt+1,DOUBLE);\n  if (spara == SISL_NULL) goto err101;\n\n  /* Calculate parameterization  */\n\n  spara[0] = astpar;\n  tlastpar = astpar;\n\n  for (ki=1; ki<inbpnt; ki++)\n    {\n      tdist = s6dist(&epoint[ki*idim-idim],&epoint[ki*idim],idim);\n      tlastpar = tlastpar + tdist;\n      spara[ki] = tlastpar;\n    }\n\n\n  /* Calculate distance from first to last point and update\n     parameterization array. To be useded if closed curve   */\n\n  tdist = s6dist(epoint,&epoint[(inbpnt-1)*idim],idim);\n  tlastpar = tlastpar + tdist;\n  spara[inbpnt] = tlastpar;\n\n\n  /* Find the knot vector     */\n\n  s1902(spara,inbpnt,kk,iopen,&sknot,&kstat);\n  if (kstat < 0 || sknot == SISL_NULL) goto error;\n\n  /* Allocate space for verice array   */\n\n  scoef = newarray((inbpnt+kk-1)*idim,DOUBLE);\n  if (scoef == SISL_NULL) goto err101;\n\n  /* Copy vertices */\n\n  memcopy (scoef,epoint,inbpnt*idim,DOUBLE);\n  kn = inbpnt;\n\n  /* In case of closed curve, add the (kk-1) first points to the vertice\n     array.    */\n\n  if (!(iopen == SISL_CRV_OPEN))\n    {\n      memcopy(&scoef[inbpnt*idim],epoint,(kk-1)*idim,DOUBLE);\n      kn = kn + kk - 1;\n    }\n\n  /* Make curve */\n  /* VSK, MESZ. Do not copy arrays.\n  qc = newCurve(kn,kk,sknot,scoef,1,idim,1);  */\n  qc = newCurve(kn,kk,sknot,scoef,1,idim,2); /* icopy=2, PFU 24/08-94 */\n  if (!qc) goto err101;\n\n  qc->cuopen = iopen;\n\n  if (iopen == SISL_CRV_CLOSED)\n    {\n      /* A closed, non-periodic curve is expected. Pick the part of the\n\t interpolation curve that has got a full basis.  */\n\n      s1713 (qc, sknot[kk - 1], sknot[kn], &qc2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      if (qc != SISL_NULL)\n\tfreeCurve (qc);\n      qc = qc2;\n    }\n\n  /* Increase the order if the order was lowered when controlling input */\n\n  if (kk < ik)\n    {\n\t\t\t\t/* -> guen: inserted acc. to SCCS */\n      s1750(qc,ik,rc,&kstat);\n\t\t\t\t/* <- guen: inserted acc. to SCCS */\n\n\t\t\t\t/* -> guen: removed acc. to SCCS  */\n\t\t\t\t/*      s1750(qc,ik,&qc,&kstat);  */\n\t\t\t\t/* <- guen: removed acc. to SCCS  */\n      if (kstat< 0) goto error;\n    }\n\t\t\t\t/* -> guen: inserted acc. to SCCS */\n  else\n    {\n      *rc = qc;\n      qc = SISL_NULL;\n    }\n\t\t\t\t/* <- guen: inserted acc. to SCCS */\n\t\t\t\t/* -> guen: removed acc. to SCCS  */\n\t\t\t\t/*  if (qc) *rc = qc;             */\n\t\t\t\t/* -> guen: inserted acc. to SCCS */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in memory allocation */\n\n err101:\n  *jstat = -101;\n  s6err(\"s1604\",*jstat,kpos);\n  goto out;\n\n  /* Error in input, order less than 2 */\n\n err109:\n  *jstat = -109;\n  s6err(\"s1604\",*jstat,kpos);\n  goto out;\n\n  /* Error in input, unknown kind of curve */\n\n err113:\n  *jstat = -113;\n  s6err(\"s1604\",*jstat,kpos);\n  goto out;\n\n\n  /* Error in lower level function */\n\n error:\n  *jstat = kstat;\n  s6err(\"s1604\",*jstat,kpos);\n  goto out;\n\n out:\n  if (spara  != SISL_NULL) freearray(spara);\n  /* if (scoef  != SISL_NULL) freearray(scoef); (Freed by freeCurve(qc). */\n  if (qc != SISL_NULL) freeCurve(qc);\n  return;\n}\n"
  },
  {
    "path": "src/s1605.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1605.c,v 1.2 2001-03-19 15:58:51 afr Exp $\n *\n */\n\n\n#define S1605\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   s1605(SISLCurve *pc,double aepsge,double **gpoint,int *jnbpnt,int *jstat)\n#else\nvoid s1605(pc,aepsge,gpoint,jnbpnt,jstat)\n     SISLCurve  *pc;\n     double aepsge;\n     double **gpoint;\n     int    *jnbpnt;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate a set of points on a B-spline curve. \n*              The straight lines between the points will not deviate\n*              more than aepsge from the B-spline curve at any point.\n*             \n* INPUT      : pc     - The input B-spline curve.   \n*              aepsge - Geometry resolution, maximum distance allowed between\n*                       the curve and the straight lines to be calculated. \n*\n* OUTPUT     : gpoint - Calculated points\n*              jnbpnt - No. of calculated points  \n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : The error in approximating a given function f on an interval\n*              [a,b] by linear spline approximation is bounded by\n*                      (b-a)**2*max(abs(D2(f)))/8\n*              where max(abs(D2(f))) denotes the maximum of the absolute value\n*              of the 2. derivative of f on the interval [a,b].\n*              In order to approximate a derivative curve, we get the bound\n*                      (b-a)**2*max(abs(D(2)(f))/8\n*              For a spline curve this estimate applies on each of the \n*              component of the geometry space.\n*              To determine the sampling points, we start from the left of the\n*              given spline and consider one knot interval at the time. On each\n*              knot interval the 2. derivative is a spline of order \n*              ik-2 (ik is the order of f), the coefficients of which \n*              is 2. order divided differences of the original coefficients. \n*              The div. diff. of largest absolute value then gives an estimate \n*              of the maximum of the absolute value of  the 2. derivative \n*              so that the error in linear interpolation becomes less than the \n*              tolerance. This can be done in each of the geometry components \n*              and to be on the safe side we choose the smallest of the \n*              resulting step lengths. This step length is then adjusted so \n*              that the sampling points can be distributed uniformly in \n*              the interval, and always with one sampling point at \n*              the beginning of the interval and one at the end, i.e. \n*              all original knots become sampling points.\n*              At break points, two sampling points will be placed.\n*\n* USE        : Array gpoint is allocated inside this routine and must \n*              be made free after use.\n*\n* REFERENCES :\n*\n*-                                                 \n* CALLS      : s1221,s6err\n*\n*\n* WRITTEN BY : Qyvind Hjelle, SI, Oslo, Norway. 10. Nov 1988\n*\n* REWRITTEN BY : Bjoern Olav Hoset, SI, Oslo, Norway, feb. 1992.\n*                The code is identical to s1613 which Arne Laksaa \n*                wrote,.\n*********************************************************************\n*/\n{\n  int kstat = 0;           /* Status variable.  */\n  int kpos  = 0;           /* Position of error reported. */\n  int ki,kj,kk,kh,kr,kl;   /* Counters.         */\n  int kikr;                /* Order of current derivative curve. */\n  int kih;                 /* Current location in sdd2.          */\n  int kihn;                /* Next location in sdd2.             */\n  int kjh;                 /* Index in sdd2.                     */\n  int kstop;               /* Number of divided differences to compute.   */\n  int kdim = pc->idim;     /* Dimension of space in which the curve lies. */\n  int kncoef = pc->in;     /* Number of vertices of curve.  */\n  int korder = pc->ik;     /* Order of curve.               */\n  int kordnew = korder-2;  /* Order of derivative curve of which \n\t\t\t      to find an upper bound.         */\n  int knmbel = 100;        /* Number of elements with which the output\n\t\t\t      array is to be increased.                   */       \n  int kmaxpar = knmbel;    /* Length of output parameter array.           */\n  int kpar = 0;            /* Number of parameter values computed.        */\n  int kant;                /* Number of sampling points at a knot interval. */\n  int left = 0;            /* Help index to evaluator.                    */\n  double tant;             /* Number of sampling points at a knot interval. */\n  double tfac;             /* Factor used in taking divided differences.    */\n  double ta;               /* Start value of parameter interval.          */\n  double tb;               /* End value of parameter interval.            */\n  double th;               /* Distance between output parameter values.   */\n  double *st;              /* Pointer to knot vector of curve.            */\n  double *par = SISL_NULL;      /* Array used to store parameter values.       */\n  double *sh  = SISL_NULL;      /* Work array.    */\n  double *sh1 = SISL_NULL;      /* Work array.    */\n  double *sdd = SISL_NULL;      /* Work array used to compute divided differences. */\n  double *sdd2 = SISL_NULL;     /* Array used to store final divided differences.  */\n  double *smaxd = SISL_NULL;    /* Array used to store maximum divided differences.*/\n  \n  /* Test input.  */\n  \n  if (korder < 1) goto err110;\n  if (kncoef < korder) goto err111;\n  if (kdim < 1) goto err102;\n  \n  if (korder == 1)\n    {\n      kpar = kncoef;\n      if ((*gpoint = newarray(kpar*kdim,DOUBLE)) == SISL_NULL) goto err101;\n      memcopy(gpoint,pc->ecoef,kpar*kdim,DOUBLE);\n      *jnbpnt = kpar;\n      *jstat = 0;\n      goto out;\n    }\n  \n  \n  /* Set local pointer to knot vector of curve.  */\n  \n  st = pc->et;\n  \n  /* Allocate some scratch for output array.  */\n  \n  if ((par = newarray(knmbel,DOUBLE)) == SISL_NULL) goto err101;\n  \n  /* Allocate scratch for internal arrays.  */\n  \n  if ((sdd = new0array((kordnew+6)*kdim,DOUBLE)) == SISL_NULL) goto err101;\n  sdd2 = sdd+3*kdim;\n  smaxd = sdd2+kordnew*kdim;\n  sh = smaxd+kdim;\n  sh1 = sh+kdim;\n  \n  /* Main loop to determine the interpolation points in each knot interval\n     by computing 2. order differences and taking the maximum of the \n     appropriate kordnew 2. order differences on each knot interval. The\n     number of uniform interplation points in the knot interval can then\n     by estimated using the bound described in METHOD.\n     In the following the index ki will point at the next coefficient to be \n     included in the computation of the 2. order derivatives.\n     kpar points to the location in the array par where the parameter value\n     of the next interpolation point is to be stored.\n     kih points to the location in sdd2 where the next 2. order difference\n     is to be stored.        */\n  \n  kpar=0;\n  tb = st[korder-1];\n  \n  for (kih=0, ki=0; ki<kncoef; ki=kj)\n    {\n      /* Compute the index of the first knot greater than tb.  */\n      \n      for (kj=MAX(korder-1,ki)+1; st[kj]==tb; kj++);\n      ta = tb;\n      tb = st[kj];\n      \n      /* Check if the multiplisity of the knot is greater than \n\t korder-2. */\n      \n      if (kj-ki >= korder-1)\n\t{\n\t  if (kpar+1 > kmaxpar)\n\t    if ((par = increasearray(par,(kmaxpar+=knmbel),DOUBLE)) \n\t\t== SISL_NULL) goto err101;\n\t  par[kpar] = ta;\n\t  kpar++;\n\t}\n      \n      /* If the 2. order differences may be different from zero, \n\t Compute them.   */\n      \n      for (kk=ki; korder>2 && kk<kj; kk++)\n\t{\n\t  /* Pick the next coefficient.  */\n\t  \n\t  memcopy(sh,pc->ecoef+kk*kdim,kdim,DOUBLE);\n\t  \n\t  /* Compute the 1, 2 difference at kk.  */\n\t  \n\t  kikr = korder - 1;\n\t  kstop = MIN(2,korder-kj+kk);\n\t  for (kr=0; kr<kstop; kr++)\n\t    {\n\t      tfac = (double)kikr/(st[kk+kikr] - ta);\n\t      kikr--;\n\t      for (kh=0; kh<kdim; kh++)\n\t\tsh1[kh] = (sh[kh] - sdd[kr*kdim+kh])*tfac;\n\t      memcopy(sdd+kr*kdim,sh,kdim,DOUBLE);\n\t      memcopy(sh,sh1,kdim,DOUBLE);\n\t    }\n\t  memcopy(sdd+kr*kdim,sh,kdim,DOUBLE);\n\t  \n\t  /* Compute the maximum of the 2. order difference. The\n\t     kordnew previous 2. order differences are stored in\n\t     sdd2 and the current one (sdd+3*kdim) is to overwrite\n\t     sdd2+kih*kdim. The fact that only one new element enters\n\t     sdd2 at a time can be taken advantage of in computing \n\t     the maximum difference.   */\n\t  \n\t  if (kstop == 2)\n\t    {\n\t      for (kihn=(kih+1)%kordnew, kh=0; kh<kdim; kh++)\n\t\t{\n\t\t  sh[kh] = fabs(sh[kh]);\n\t\t  if (sdd2[kih*kdim+kh] < smaxd[kh])\n\t\t    smaxd[kh] = MAX(smaxd[kh],sh[kh]);\n\t\t  else if (sh[kh] >= smaxd[kh])\n\t\t    smaxd[kh] = sh[kh];\n\t\t  else\n\t\t    {\n\t\t      for (kjh=kihn, smaxd[kh]=sh[kh], kl=0;\n\t\t\t   kl<kordnew-1; kl++, kjh=(kjh+1)%kordnew)\n\t\t\tsmaxd[kh] = MAX(smaxd[kh],sdd2[kjh*kdim+kh]);\n\t\t    }\n\t\t  sdd2[kih*kdim+kh] = sh[kh];\n\t\t}\n\t      kih = kihn;\n\t    }\n\t}\n      \n      /* Compute the number of interpolation points.  */\n      \n      for (kant=0, kh=0; kh<kdim; kh++)\n\t{\n\t  tant = (tb-ta)*sqrt(smaxd[kh]/((double)8.0*aepsge));\n\t  kant = MAX(MAX(kant,(int)tant),1);\n\t}\n      \n      /* Make sure that par is great enough.  */\n      \n      if (kpar+kant >= kmaxpar)\n\tif ((par = increasearray(par,(kmaxpar+=MAX(kant,knmbel)),DOUBLE)) \n\t    == SISL_NULL) goto err101;\n      \n      /* Compute the parameter values of the interpolation points.  */\n      \n      for (th=(tb-ta)/(double)(kant+1), kk=0; kk<kant; kpar++,kk++)\n\tpar[kpar] = ta + (double)(kk+1)*th;\n      par[kpar] = tb;\n      kpar++;\n    }\n  \n  /* Make the points.  */\n  \n  if ((*gpoint = newarray(kpar*kdim,DOUBLE)) == SISL_NULL) goto err101;\n  \n  for (kh=kk=0; kk<kpar; kk++,kh+=kdim)\n    {\n      s1221(pc,0,par[kk],&left,*gpoint+kh,&kstat);\n      if (kstat < 0) goto err101;\n    }\n  \n  /* Task performed.  */\n  \n  *jnbpnt = kpar;\n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error in scratch allocation.  */\n  \n  err101 :\n    *jstat = -101;\n    s6err(\"s1605\",*jstat,kpos);\n    goto out;\n  \n  /* Error in input. Dimension less than one.  */\n  \n  err102 :\n    *jstat = -102;\n    s6err(\"s1605\",*jstat,kpos);\n    goto out;\n  \n  /* Error in input. Order less than one.  */\n  \n  err110 :\n    *jstat = -110;\n    s6err(\"s1605\",*jstat,kpos);\n    goto out;\n  \n  /* Error in input. Number of coefficients less than order.  */\n  \n  err111 :\n    *jstat = -111;\n    s6err(\"s1605\",*jstat,kpos);\n    goto out;\n  \n  out :\n    /* Free scratch occupied by local arrays.  */\n    \n    if (sdd != SISL_NULL) freearray(sdd);\n    if (par != SISL_NULL) freearray(par);\n}\n\n\n"
  },
  {
    "path": "src/s1606.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1606.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1606\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1606 (SISLCurve * pc1, SISLCurve * pc2, double aepsge, double epoint1[], double epoint2[],\n       int itype, int idim, int ik, SISLCurve ** rc, int *jstat)\n#else\nvoid\ns1606 (pc1, pc2, aepsge, epoint1, epoint2, itype, idim, ik, rc, jstat)\n     SISLCurve *pc1;\n     SISLCurve *pc2;\n     double aepsge;\n     double epoint1[];\n     double epoint2[];\n     int itype;\n     int idim;\n     int ik;\n     SISLCurve **rc;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To calculate a blending curve between two curves.\n*              Points indicate between which ends the blend is to be\n*              produced. the blending curve produced is a conic section\n*              if possible, else it is a quadratic polynomial spline curve.\n*\n* INPUT      : pc1    - The first input B-spline curve.\n*              pc2    - The second input B-spline curve.\n*              aepsge - Geometry resolution.\n*              epnt1  - SISLPoint near the end of curve 1 where the blend starts.\n*              epnt2  - SISLPoint near the end of curve 2 where the blend starts.\n*              itype  - Type of blending:\n*                     = 1  - circle, interpolating tangent on first curve,\n*                       not on curve 2.\n*                     = 2  - conic if possible\n*                     else - polynomial segment\n*              idim   - Dimension of space.\n*              ik     - order of blending curve.\n*\n* OUTPUT     : rc     - Blending curve produced\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : The input points are used to find between which ends\n*              the blending curve is to be calculated. Then the\n*              parameter values of these ends are used for calculating\n*              the end points and tangents. The next step is to interpolate\n*              these points and tangents with the curve type specified\n*              by the blend type indicator. If a conic blend is specified\n*              and can not be produced, then a quadratic blend is calculated\n*              instead.\n*\n*\n* USE        :\n*\n* REFERENCES :\n*\n* CALLS      : s1707,s1607,s6err.\n*\n* WRITTEN BY : Christophe Birkeland, SI, 1991-07\n* REVISED BY : Johannes Kaasa, SI, Aug. 92 (Removed call to s1707, this is\n*              called from s1607).\n*\n*********************************************************************\n*/\n{\n  int ki;\t\t\t/* Loop control variable\t\t\t   */\n  int kstat = 0;\t\t/* Status variable                                 */\n  int kpos = 0;\t\t\t/* Position of error                               */\n  int in1;\t\t\t/* The number of B-splines, i.e., the dimension of\n\t\t\t\t   the spline space associated with the knot\n\t\t\t\t   vector. Curve 1 and 2.\t\t\t   */\n  int in2;\n  int ik1;\t\t\t/* The polynomial order of the curves.             */\n  int ik2;\n  double fil1, end1;\t\t/* Used to store start and end of curve 1\t   */\n  double fil2, end2;\t\t/* Used to store start and end of curve 2\t   */\n  double sum11, sum12;\t\t/* Variables used to find end od curves\t\t   */\n  double sum21, sum22;\n  double dum;\t\t\t/* Dummy variable\t\t                   */\n\n  *jstat = 0;\n\n\n  /* Check if conflicting dimensions. */\n\n  if (pc1->idim != idim || pc2->idim != idim)\n    goto err106;\n\n  /* Find ends of curve. */\n\n  sum11 = (double) 0.0;\n  sum12 = (double) 0.0;\n  sum21 = (double) 0.0;\n  sum22 = (double) 0.0;\n\n  in1 = pc1->in -1;\n  in2 = pc2->in -1;\n\n  for (ki = 0; ki < idim; ki++)\n    {\n      dum = epoint1[ki] - pc1->ecoef[ki];\n      sum11 += dum * dum;\n      dum = epoint1[ki] - pc1->ecoef[in1 * idim + ki];\n      sum12 += dum * dum;\n      dum = epoint2[ki] - pc2->ecoef[ki];\n      sum21 += dum * dum;\n      dum = epoint2[ki] - pc2->ecoef[in2 * idim + ki];\n      sum22 += dum * dum;\n    }\n  in1++;\n  in2++;\n\n  ik1 = pc1->ik - 1;\n  ik2 = pc2->ik - 1;\n  if (sum11 < sum12)\n    {\n      /* Start of curve 1 closer than end of curve 1. */\n\n      fil1 = pc1->et[ik1];\n      end1 = pc1->et[in1];\n    }\n  else\n    {\n      /* End of curve 1 closer than start of curve 1. */\n\n      end1 = pc1->et[ik1];\n      fil1 = pc1->et[in1];\n    }\n  if (sum21 < sum22)\n    {\n      /* Start of curve 2 closer than end of curve 2. */\n\n      fil2 = pc2->et[ik2];\n      end2 = pc2->et[in2];\n    }\n  else\n    {\n      /* End of curve 2 closer than start of curve 2. */\n\n      end2 = pc2->et[ik2];\n      fil2 = pc2->et[in2];\n    }\n\n  /* Make blend */\n\n  s1607 (pc1, pc2, aepsge, end1, fil1, end2, fil2, itype, idim, ik,\n\t rc, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  goto out;\n\n\n  /* Conflicting dimensions */\n\nerr106:\n  *jstat = -106;\n  s6err (\"s1606\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level function */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1606\", *jstat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1607.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1607.c,v 1.3 2001-03-19 15:58:51 afr Exp $\n *\n */\n\n\n#define S1607\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1607 (SISLCurve * pc1, SISLCurve * pc2, double aepsge,\n       double aend1, double afil1, double aend2, double afil2,\n       int itype, int idim, int ik, SISLCurve ** rc, int *jstat)\n#else\nvoid\ns1607 (pc1, pc2, aepsge, aend1, afil1, aend2, afil2, itype,\n       idim, ik, rc, jstat)\n     SISLCurve *pc1;\n     SISLCurve *pc2;\n     double aepsge;\n     double aend1;\n     double afil1;\n     double aend2;\n     double afil2;\n     int itype;\n     int idim;\n     int ik;\n     SISLCurve **rc;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To calculate a fillet curve between two curves.\n*              Parameter values indicate between which points\n*              the fillet is to be produced.\n*\n* INPUT      : pc1    - The first input curve.\n*              pc2    - The second input curve.\n*              aepsge - Geometry resolution.\n*              aend1  - Parameter value on the first curve telling that\n*                       the part of the curve lying on this side of afil1\n*                       shall not be replaced by the fillet.\n*              afil1  - Parameter value of the starting point of the fillet\n*                       on the first curve.\n*              aend2  - Parameter value on the second curve telling that the\n*                       part of the curve lying on this side of afil2 shall\n*                       not be replaced by the fillet.\n*              afil2  - Parameter value of the starting point of the fillet on\n*                       the second curve.\n*              itype  - Indicator of type of fillet.\n*                     = 1  - Circle, interpolating tangent on first curve,\n*                            not on curve 2.\n*                     = 2  - Conic if possible\n*                     else - Polynomial segment\n*              idim   - Dimension of space.\n*              ik     - Order of fillet curve.\n*\n* OUTPUT     : rc     - Fillet curve produced\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : The points and tangents specified by the input parameter values\n*              are calculated, then the interpolation curve of type given by\n*              the  fillet indicator is calculated if possible. If a conic is\n*              specified and not possible to make, a qubic spline segment is\n*              made in stead.\n*\n* USE        :\n*\n* REFERENCES :\n*\n* NOTE\t     : Routine s1611 has been changed to ensure\n*\t       that output status value may be positive (=9005).\n*              The test line 201-219 in this routine might\n*\t       be changed. The limit is to be evaluated more\n*\t       precisely.\n*\n* CALLS      : s1707,s1221,s1227,s6norm,s6dist,s6crss,s1611,s1334,s6err.\n*\n*\n* WRITTEN BY : Christophe Birkeland, SI, 1991-07\n* REVISED BY : Christophe Birkeland, SI, July 92 (parameter TYPE changed\n*              back to DOUBLE)\n* REVISED BY : Johannes Kaasa, SI, Aug. 1992 (Changed status 9005 to 105\n*              and -9006 to -104).\n* REVISED BY : Johannes Kaasa, SI, Aug. 1992 (Made planar curve even if\n*              start and end tangents are parallell. I also checked if we\n*              in fact have circular conditions and itype != 1, to prevent\n*              a singular matrix equation in s1616 I set itype = 1 in such\n*              a case).\n* Revised by : Christophe Rene Birkeland, SINTEF Oslo, May 1993.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Sept. 1994.  Fixed memory\n*              leak from 'rc'.\n*\n*********************************************************************\n*/\n{\n  int ki;\t\t      /* Loop control parameter\t\t\t*/\n  int plane;\t\t      /* Shape indicator for curve:\n\t\t\t\t = 1  : Planar curve\n\t\t\t\t else : Not planar\t\t\t*/\n  int kstat = 0;\t      /* Status variable\t \t\t*/\n  int kpos = 0;\t\t      /* Position of error  \t\t\t*/\n  int left;\t\t      /* Array index used in call s1221 & s1227\t*/\n  int iopen;\t\t      /* Used as a boolean variable:\n\t\t\t       * TRUE (=1) : open curve\n\t\t\t       * FALSE(=0) : closed curve\t\t*/\n  int knpoin;\t\t      /* # of points to be used in interpolation */\n  int knbpar;\t\t      /* Number of different parameter values\n\t\t\t       * (Not used in this routine)\t\t*/\n  double sum1, sum2, sum3;    /* Used in normalization of vector algorithm  */\n  double dum;\n  double limit, dist;\n  double tstpar;\t      /* Parameter value to be used at the start\n\t\t\t       * of the curve (routine s1611)\t\t*/\n  double cndpar;\t      /* Parameter value used at the end of the curve\n\t\t\t       * (Routine s1611)\t\t\t*/\n  double *ipar = SISL_NULL;\t      /* Array containing the parameter values of the\n\t\t\t       * points in the curve. (not used)\t*/\n  double *kpoint1 = SISL_NULL;     /* Contains position and tangen of curve1\t*/\n  double *kpoint2 = SISL_NULL;     /* Contains position and tangen of curve2\t*/\n  double *type = SISL_NULL;\t      /* Array (length inbpnt)containing type indicator\n\t\t\t       * for points/tangents :\n\t\t\t       *     1 - Ordinary point.\n\t\t\t       *     2 - Knuckle point. (Is treated as an\n\t\t\t       *\t   ordinary point.)\n\t\t\t       *     3 - Tangent to next point.\n\t\t\t       *     4 - Tangent to prior point.\t*/\n  double *sdum = SISL_NULL;\t      /* Is used to store cross product of tangent\n\t\t\t       * vectors\t\t\t\t*/\n  double tresol;\t      /* Relative resulution of double precision\n\t\t\t       * numbers\t\t\t\t*/\n  double norder1[3];\n  double norder2[3];\n  double tcos, sang;\n  int kstat1, kstat2;\n\n  *jstat = 0;\n\n  /* Check if curves are  correct. */\n\n  s1707 (pc1, &kstat);\n  if (kstat < 0) goto error;\n\n  s1707 (pc2, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Check if conflicting dimensions. */\n\n  if (pc1->idim != pc2->idim) goto err106;\n  if (pc1->idim != idim) goto err106;\n\n  /* Perform filleting. */\n\n  tresol = REL_COMP_RES;\n\n  /* Calculate position and tangent of fillet point on curve1. */\n\n  if((kpoint1 = newarray (2 * idim, DOUBLE)) == SISL_NULL) goto err101;\n\n  left = 0;\n  if (aend1 >= afil1)\n    {\n      /* Right hand position and tangent is to be calculated. */\n\n      s1221 (pc1, 1, afil1, &left, kpoint1, &kstat);\n      if (kstat < 0) goto error;\n\n      /* Turn direction of tangent. */\n\n      for (ki = idim; ki < 2 * idim; ki++)\n\tkpoint1[ki] = -kpoint1[ki];\n    }\n  else\n    {\n      /* Left hand position and tangent is to be calculated. */\n\n      s1227 (pc1, 1, afil1, &left, kpoint1, &kstat);\n      if (kstat < 0) goto error;\n    }\n\n  /* Calculate position and tangent of fillet point on curve2. */\n\n  if((kpoint2 = newarray (2 * idim, DOUBLE)) == SISL_NULL) goto err101;\n\n  left = 0;\n  if (aend2 >= afil2)\n    {\n      /* Right hand position and tangent is to be calculated. */\n\n      s1221 (pc2, 1, afil2, &left, kpoint2, &kstat);\n      if (kstat < 0) goto error;\n    }\n  else\n    {\n      /* Left hand position and tangent is to be calculated. */\n\n      s1227 (pc2, 1, afil2, &left, kpoint2, &kstat);\n      if (kstat < 0) goto error;\n\n      /* Turn direction of tangent. */\n\n      for (ki = idim; ki < 2 * idim; ki++)\n\tkpoint2[ki] = -kpoint2[ki];\n    }\n\n  /* Find if conic arc choice will result in too refined B-spline. */\n\n  if (itype == 2)\n    {\n      limit = (double) 0.0001;\n\n      s6norm (&kpoint1[idim], idim, norder1, &kstat);\n      s6norm (&kpoint2[idim], idim, norder2, &kstat);\n      dist = s6dist (kpoint1, kpoint2, idim);\n\n      for (ki = 0; ki < idim; ki++)\n\t{\n\t  norder1[ki] = kpoint1[ki] + dist * norder1[ki];\n\t  norder2[ki] = kpoint2[ki] - dist * norder2[ki];\n\t}\n      if (aepsge / s6dist (norder1, norder2, idim) < limit)\n\titype = 0;\n    }\n\n  /* Set type indicator. */\n\n  type = newarray (4, DOUBLE);\n  if (type == SISL_NULL) goto err101;\n\n  type[0] = 1;\n  type[1] = 4;\n  type[2] = 1;\n  type[3] = 4;\n\n  /* Test if the points and tangents describe a planar curve\n   * if we have 3-D curves. */\n\n  plane = 0;\n  if (idim == 3)\n    {\n      if((sdum = newarray (3, DOUBLE)) == SISL_NULL) goto err101;\n\n      /* Compute cross product between tangent vectors. */\n\n      s6crss (&kpoint1[idim], &kpoint2[idim], sdum);\n\n      /* Normalize tangents and normal vector. */\n\n      sum1 = (double) 0.0;\n      sum2 = (double) 0.0;\n      sum3 = (double) 0.0;\n\n      for (ki = 0; ki < 3; ki++)\n\t{\n\t  dum = kpoint1[idim + ki];\n\t  sum1 += dum * dum;\n\t  dum = kpoint2[idim + ki];\n\t  sum2 += dum * dum;\n\t  sum3 += sdum[ki] * sdum[ki];\n\t}\n      sum1 = sqrt (sum1);\n      sum2 = sqrt (sum2);\n      sum3 = sqrt (sum3);\n      for (ki = 0; ki < 3; ki++)\n\t{\n\t  if (sum1 > (double) 0.0)\n\t    kpoint1[idim + ki] /= sum1;\n\t  else\n\t    kpoint1[idim + ki] = 0.0;\n\t  if (sum2 > (double) 0.0)\n\t    kpoint2[idim + ki] /= sum2;\n\t  else\n\t    kpoint2[idim + ki] = 0.0;\n\t  if (sum3 > (double) 0.0)\n\t    sdum[ki] /= sum3;\n\t  else\n\t    sdum[ki] = 0.0;\n\t}\n\n      /* Find deviation from plane */\n\n      dum = (double) 0.0;\n      for (ki = 0; ki < 3; ki++)\n\tdum += (kpoint1[ki] - kpoint2[ki]) * sdum[ki];\n      if (fabs (dum) < aepsge)\n\tplane = 1;\n    }\n\n  /* Test if a conic in fact is a circle. */\n\n  if ((plane == 1 || idim == 2) && itype != 1)\n     {\n        dum = s6scpr(&kpoint1[idim], &kpoint2[idim], idim);\n\n        sum1 = s6length(&kpoint1[idim], idim, &kstat1);\n        sum2 = s6length(&kpoint2[idim], idim, &kstat2);\n\n        if (!kstat1 || !kstat2)\n          sang = DZERO;\n        else\n          {\n            tcos = dum/(sum1*sum2);\n            tcos = MIN((double)1.0,tcos);\n            sang = acos(tcos);\n          }\n\n        if ((PI - sang) < ANGULAR_TOLERANCE)\n\t   {\n\t      /* Opposite parallell start and end tangents. */\n\n\t      for (ki = 0; ki < idim; ki++)\n\t\t norder1[ki] = kpoint2[ki] - kpoint1[ki];\n\t      if (fabs(s6ang(norder1, &kpoint1[idim], idim) - PIHALF)\n\t\t  < ANGULAR_TOLERANCE)\n\t\t itype = 1;\n\t   }\n\telse if (sang > ANGULAR_TOLERANCE)\n\t   {\n\t      /* Not parallell start and end tangents. */\n\n\t      if (idim == 2)\n\t\t {\n\t\t    norder1[0] = kpoint1[idim + 1];\n\t\t    norder1[1] = -kpoint1[idim];\n\t\t    norder2[0] = kpoint2[idim + 1];\n\t\t    norder2[1] = -kpoint2[idim];\n\t\t    sum1 = (double) 0.0;\n\t\t    sum2 = (double) 0.0;\n\t\t    for (ki = 0; ki < idim; ki++)\n\t\t    {\n\t\t       sum1 += norder1[ki]*norder1[ki];\n\t\t       sum2 += norder2[ki]*norder2[ki];\n\t\t    }\n\t\t    sum1 = sqrt(sum1);\n\t\t    sum2 = sqrt(sum2);\n\t\t    for (ki = 0; ki < idim; ki++)\n\t\t    {\n\t\t       norder1[ki] /= sum1;\n\t\t       norder2[ki] /= sum2;\n\t\t    }\n\t\t }\n\t      else\n\t\t {\n\t\t    s6crss(sdum, &kpoint1[idim], norder1);\n\t\t    s6crss(sdum, &kpoint2[idim], norder2);\n\t\t }\n\n\t      for (ki = 0; ki < idim; ki++)\n\t      {\n\t\t norder1[ki] -= norder2[ki];\n\t\t norder2[ki] = kpoint2[ki] - kpoint1[ki];\n\t      }\n              if (s6ang(norder1, norder2, idim) < ANGULAR_TOLERANCE)\n\t\t itype = 1;\n\t   }\n     }\n\n  /* Copy kpoint1 and kpoint2 into one array only kpoint1 */\n\n  kpoint1 = increasearray (kpoint1, idim * 4, DOUBLE);\n  if (kpoint1 == SISL_NULL)\n    goto err101;\n\n  memcopy (&kpoint1[2 * idim], kpoint2, 2 * idim, DOUBLE);\n\n  if ((idim == 2 || (idim == 3 && plane == 1)) && (itype == 2 || itype == 1))\n    {\n      /* The curve is planar, interpolate with a conic. */\n\n      if (itype == 1)\n\tknpoin = 3;\n      else\n\tknpoin = 4;\n      tstpar = (double) 0.0;\n      iopen = SISL_CRV_OPEN;\n\n      s1611 (kpoint1, knpoin, idim, type, iopen, ik, tstpar, aepsge, &cndpar,\n\t     rc, &kstat);\n      if (kstat < 0 && kstat != -104)\n\tgoto error;\n\n      if ((*rc)->in >(*rc)->ik)\n\tgoto out;\n\n      if (kstat == 105)\n\t{\n\t  knpoin = 3;\n\t  tstpar = (double) 0.0;\n\n\t  if (*rc)  freeCurve(*rc);  /* Re-use of 'rc' (PFU 05/09-94) */\n\t  *rc = SISL_NULL;\n\n\t  s1611 (kpoint1, knpoin, idim, type, iopen, ik, tstpar, aepsge,\n\t\t &cndpar, rc, &kstat);\n\t  if (kstat != -104 && (*rc)->in >(*rc)->ik)\n\t    {\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      /* Fillet produced */\n\n\t      goto out;\n\t    }\n\t}\n    }\n\n  /* Produce polynomial fillet */\n\n  knpoin = 4;\n  iopen = SISL_CRV_OPEN;\n  tstpar = (double) 0.0;\n\n  if (*rc)  freeCurve(*rc);  /* Re-use of 'rc' (PFU 05/09-94) */\n  *rc = SISL_NULL;\n\n\n  s1334 (kpoint1, knpoin, idim, type, 0, 0, iopen, ik, tstpar, &cndpar,\n\t rc, &ipar, &knbpar, &kstat);\n  if (ipar != SISL_NULL) freearray (ipar);\n  if (kstat < 0) goto error;\n\n  goto out;\n\n  /* Error in input, conflicting dimensions */\n\n  err106:\n    *jstat = -106;\n    s6err (\"s1607\", *jstat, kpos);\n    goto out;\n\n  /* Error in memory allocation */\n\n  err101:\n    *jstat = -101;\n    s6err (\"s1607\", *jstat, kpos);\n    goto out;\n\n  /* Error in lower level function */\n\n  error:\n    *jstat = kstat;\n    s6err (\"s1607\", *jstat, kpos);\n    goto out;\n\n  out:\n    if (kpoint1 != SISL_NULL) freearray(kpoint1);\n    if (kpoint2 != SISL_NULL) freearray(kpoint2);\n    if (type != SISL_NULL) freearray(type);\n    if (sdum != SISL_NULL) freearray(sdum);\n    return;\n}\n"
  },
  {
    "path": "src/s1608.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1608.c,v 1.2 2001-03-19 15:58:51 afr Exp $\n *\n */\n\n\n#define S1608\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1608(SISLCurve *pc1,SISLCurve *pc2,double aepsge,\n\t   double ep11[],double epf1[],double ep21[],double epf2[],\n\t   int itype,int idim,int ik,SISLCurve **rc,\n\t   double *ct11,double *ctf1,double *ct21,double *ctf2, int *jstat)\n#else\nvoid s1608(pc1,pc2,aepsge,ep11,epf1,ep21,epf2,itype,idim,ik,rc,\n           ct11,ctf1,ct21,ctf2,jstat) \n\t   SISLCurve  *pc1;\n\t   SISLCurve  *pc2;\n\t   double aepsge;\n\t   double ep11[];\n\t   double epf1[];\n\t   double ep21[];\n\t   double epf2[];\n\t   int    itype;\n\t   int    idim;\n\t   int    ik;\n\t   SISLCurve  **rc;\n\t   double *ct11;\n\t   double *ctf1;\n\t   double *ct21;\n\t   double *ctf2; \n\t   int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate a fillet curve between two curves.\n*              Points indicate between which points on the input curve \n*              the fillet is to be produced.\n*\n* INPUT      : pc1    - The first input curve.   \n*              pc2    - The second input curve.   \n*              aepsge - Geometry resolution.         \n*              ep11   - SISLPoint close to curve 1 telling that the part of the \n*                       curve lying on this side of epf1 is not to be \n*                       replaced by the fillet.\n*              epf1   - SISLPoint close to curve 1, indicating where the fillet is\n*                       to start. The tangent at the start of the fillet will\n*                       have the same orientation as the curve from ep11 \n*                       to epf1.\n*              ep21   - SISLPoint close to curve 2 telling that the part of the\n*                       curve lying on this side of epf2 is not to be \n*                       replaced by the fillet.\n*              epf2   - SISLPoint close to curve two, indicating where the fillet\n*                       is to end. the tangent at the end of the fillet will\n*                       have the same orientation as the curve from epf2\n*                       to ep21.\n*              itype  - Indicator of type of fillet.\n*                     = 1  - Circle, interpolating tangent on first curve,\n*                            not on curve 2.\n*                     = 2  - Conic if possible\n*                     else - Polynomial segment\n*              idim   - Dimension of space.  \n*              ik     - Order of fillet curve.\n*\n* OUTPUT     : rc     - Fillet curve produced\n*              ct11   - parameter value of point ep11 on curve 1.\n*              ctf1   - parameter value of point epf1 on curve 1.\n*              ct21   - parameter value of point ep21 on curve 2.\n*              ctf2   - parameter value of point epf1 on curve 2.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                                         =-1      : No fillet produced\n*\n* METHOD     : First the parameter values  at11, atf1, at21, atf2\n*              corresponding respectively to ep11, epf1, ep21 and epf2\n*              are found. Then S1607 is used for calculating the actual fillet.\n*\n* USE        : \n*             \n* REFERENCES :\n*                   \n*-                                                 \n* CALLS      : \n*\n*\n* WRITTEN BY : Qyvind Hjelle, SI, Oslo, Norway. 28. Nov 1988\n* Reviced by : Tor Dokken, SI, Oslo, Norway, August 1989\n*              \n*********************************************************************\n*/\n{\n  SISLIntcurve **qic1=SISL_NULL;  /* SISLObject containing intervals if any      */\n  SISLIntcurve **qic2=SISL_NULL;  /* SISLObject containing intervals if any      */\n  SISLIntcurve **qic3=SISL_NULL;  /* SISLObject containing intervals if any      */\n  SISLIntcurve **qic4=SISL_NULL;  /* SISLObject containing intervals if any      */\n  \n  int kstat;          /* Status variable                                   */\n  int kpos=0;         /* Position of error                                 */\n  \n  int kcrv1,kcrv2;\n  int kcrv3,kcrv4;    /* Number of intervals                               */\n  int kpt1,kpt2,kpt3; /* Number of points                                  */\n  int kpt4;           /* Loop variable                                     */\n  double *spar1=SISL_NULL; /* Pointer to parameter values                       */\n  double *spar2=SISL_NULL; /* Pointer to parameter values                       */\n  double *spar3=SISL_NULL; /* Pointer to parameter values                       */\n  double *spar4=SISL_NULL; /* Pointer to parameter values                       */\n  \n  /* Check dimensions */\n  \n  if (idim != 2 && idim != 3) goto err105;\n  if (pc1->idim != pc2->idim) goto err106;\n  \n  /* Check if curves are  correct */\n  \n  s1707(pc1,&kstat);\n  if (kstat < 0) goto error;\n  \n  s1707(pc2,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Calculate closest point to ep11 */\n  \n  s1953(pc1,ep11,idim,REL_COMP_RES,aepsge,&kpt1,&spar1,&kcrv1,&qic1,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Remember closest point */\n  \n  if (kpt1  > 0)\n    *ct11 = spar1[0];\n  else if (kcrv1>0)\n    {\n      SISLIntcurve *q1= *qic1;\n      if (q1->ipar1 ==1)\n        *ct11 = q1 -> epar1[0];\n      else if (q1->ipar2 ==1)\n        *ct11 = q1 -> epar2[0];\n      else\n        goto errxxx;\n    }\n  \n  /* Calculate closest point to epf1 */\n  \n  s1953(pc1,epf1,idim,REL_COMP_RES,aepsge,&kpt2,&spar2,&kcrv2,&qic2,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Remember closest point */\n  \n  if (kpt2  > 0)\n    *ctf1 = spar2[0];\n  else if (kcrv2>0)\n    {\n      SISLIntcurve *q2= *qic2;\n      if (q2->ipar1 ==1)\n        *ctf1 = q2 -> epar1[0];\n      else if (q2->ipar2 ==1)\n        *ctf1 = q2 -> epar2[0];\n      else\n        goto errxxx;\n    }\n  \n  /* Calculate closest point to ep21 */\n  \n  s1953(pc2,ep21,idim,REL_COMP_RES,aepsge,&kpt3,&spar3,&kcrv3,&qic3,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Remember closest point */\n  \n  if (kpt3  > 0)\n    *ct21 = spar3[0];\n  else if (kcrv3>0)\n    {\n      SISLIntcurve *q3= *qic3;\n      if (q3->ipar1 ==1)\n        *ct21 = q3 -> epar1[0];\n      else if (q3->ipar2 ==1)\n        *ct21 = q3 -> epar2[0];\n      else\n        goto errxxx;\n    }\n  \n  /* Calculate closest point to epf2 */\n  \n  s1953(pc2,epf2,idim,REL_COMP_RES,aepsge,&kpt4,&spar4,&kcrv4,&qic4,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Remember closest point */\n  \n  if (kpt4 > 0)\n    *ctf2 = spar4[0];\n  else if (kcrv1>0)\n    {\n      SISLIntcurve *q4= *qic4;\n      if (q4->ipar1 ==1)\n        *ctf2 = q4 -> epar1[0];\n      else if (q4->ipar2 ==1)\n        *ctf2 = q4 -> epar2[0];\n      else\n        goto errxxx;\n    }\n  \n  s1607(pc1,pc2,aepsge,*ct11,*ctf1,*ct21,*ctf2,itype,idim,ik,rc,&kstat);\n  if (kstat<0) goto error;\n  \n  *jstat = 0;\n  \n  goto out;\n  \n  /* Error in memory allocation */\n  \n  /* Error in input, conflicting dimensions */\n  \n err106: *jstat = -106;\n  s6err(\"s1608\",*jstat,kpos);\n  goto out;\n  \n  /* Dimension nmot equal to 2 or 3 */\n  \n err105: *jstat = -105;\n  s6err(\"s1608\",*jstat,kpos);\n  goto out;\n  \n  \n  /*      No fillet produced */\n  \n errxxx: *jstat = -1;\n  goto out;\n  \n  /* Error in lower level function */  \n  \n error:  *jstat = kstat;\n  s6err(\"s1608\",*jstat,kpos); \n  goto out;\n  \n out:\n  if (qic1  != SISL_NULL) freeIntcrvlist(qic1,kcrv1);\n  if (qic2  != SISL_NULL) freeIntcrvlist(qic2,kcrv2);\n  if (qic3  != SISL_NULL) freeIntcrvlist(qic3,kcrv3);\n  if (qic4  != SISL_NULL) freeIntcrvlist(qic4,kcrv4);\n  if (spar1 != SISL_NULL) freearray(spar1);\n  if (spar2 != SISL_NULL) freearray(spar2);\n  if (spar3 != SISL_NULL) freearray(spar3);\n  if (spar4 != SISL_NULL) freearray(spar4);\n  \n  return;\n}       \n"
  },
  {
    "path": "src/s1609.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1609.c,v 1.2 2001-03-19 15:58:51 afr Exp $\n *\n */\n\n\n#define S1609\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1609(SISLCurve *pc1,SISLCurve *pc2,double aepsge,\n\t   double eps1[],double epf[],double eps2[],double aradius,\n\t   double enorm[],int itype,int idim,int ik,SISLCurve **rc,\n\t   double *ct11,double *ctf1,double *ct21,double *ctf2,\n\t   int *jstat)\n#else\nvoid s1609(pc1,pc2,aepsge,eps1,epf,eps2,aradius,enorm,itype,idim,ik,rc,\n           ct11,ctf1,ct21,ctf2,jstat)\n     SISLCurve  *pc1;\n     SISLCurve  *pc2;\n     double aepsge;\n     double eps1[];\n     double epf[];\n     double eps2[];\n     double aradius;\n     double enorm[];\n     int    itype;\n     int    idim;\n     int    ik;\n     SISLCurve  **rc;\n     double *ct11;\n     double *ctf1;\n     double *ct21;\n     double *ctf2;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate a fillet curve given radius between two curves.\n*\n* INPUT      : pc1    - The first input curve.   \n*              pc2    - The second input curve.   \n*              aepsge - Geometry resolution.         \n*              eps1   - SISLPoint telling that the fillet should be put on \n*                       the side of curve 1 where eps1 is situated.\n*              epf    - SISLPoint indicating where the fillet curve should go. \n*                       eps1 together with epf indicates the direction of \n*                       the start tangent of the curve, while epf together\n*                       with eps2 indicates the direction of the end tangent\n*                       of the curve. If more than one position of the fillet \n*                       curve is possible, the closest curve to epf is chosen.\n*              eps2   - SISLPoint telling that the fillet should be put on the \n*                       side of curve 2 where eps2 is situated.\n*              aradius - The radius to be used on the fillet if a circular\n*                       fillet possible, else a conic or a quadratic \n*                       polynomial curve is used, approximating the circular\n*                       fillet.\n*              enorm  - Direction normal to the plane the fillet curve \n*                       should lie close to. (only used in 3-d fillet \n*                       calculations).\n*              itype  - Indicator of type of fillet.\n*                     = 1  - Circle, interpolating tangent on first curve,\n*                            not on curve 2.\n*                     = 2  - Conic if possible\n*                     else - Polynomial segment\n*              idim   - Dimension of space.  \n*              ik     - Order of fillet curve.\n*\n* OUTPUT     : rc     - Fillet curve produced\n*              ct11   - Parameter value of the end of curve 1 not affected by \n*                       the fillet.\n*              ctf1   - Parameter value of the point on curve 1 where the \n*                       fillet starts.\n*              ct21   - Parameter value of the end of curve 2 not affected by \n*                       the fillet.\n*              ctf2   - Parameter value of the point on curve 2 where the \n*                       fillet ends.\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                        \n* METHOD     : \n*\n* USE        : \n*             \n* REFERENCES :\n*                   \n*-                                                 \n* CALLS      : \n*\n*\n* WRITTEN BY : Qyvind Hjelle, SI, Oslo, Norway. 28. Nov 1988\n* Reviced by : Tor Dokken, SI, Oslo, Norway, August 1989\n*              \n*********************************************************************\n*/\n{\n  SISLIntcurve **qic1=SISL_NULL;  /* SISLObject containing intervals if any     */\n  SISLIntcurve **qic2=SISL_NULL;  /* SISLObject containing intervals if any     */\n  SISLIntcurve **qic3=SISL_NULL;  /* SISLObject containing intervals if any     */\n  SISLCurve    *qc1=SISL_NULL;    /* Offset of first curve                  */\n  SISLCurve    *qc2=SISL_NULL;    /* Offset of second curve                 */\n  \n  int kstat;          /* Status variable                                  */\n  int kpos=0;         /* Position of error                                */\n  int kleft=0;        /* Pointer in knot vector                           */\n  int kn;             /* The number of B-splines vertices                 */\n  int kk;             /* The polynomial order of the curve.               */\n  double *st;         /* Pointer to the first element of the knot vector\n\t\t\t of the curve. The knot vector has [kn+kk]\n\t\t\t elements.                                        */\n  \n  int kcrv1,kcrv2;\n  int kcrv3    ;      /* Number of intervals                              */\n  int kpt1,kpt2,kpt3; /* Number of points                                 */\n  int ki;             /* Loop variable                                    */\n  double tpar1,tpar2; /* Parameter values                                 */\n  double spnt1[6];    /* SISLPoint and derivate                               */\n  double spnt2[6];    /* SISLPoint and derivate                               */\n  double *spar1=SISL_NULL; /* Pointer to parameter values                      */\n  double *spar2=SISL_NULL; /* Pointer to parameter values                      */\n  double *spar3=SISL_NULL; /* Pointer to parameter values                      */\n  double *spar4=SISL_NULL; /* Pointer to parameter values                      */\n  double snorm[3];    /* Normal vector                                    */\n  double sdiff[3];    /* Difference vector                                */\n  double tprod;       /* Scalar product                                   */\n  double tdir1,tdir2; /* Direction of curves                              */\n  double trad1,trad2; /* Offsets with correct direction                   */\n  double tmin;        /* Minimum distance                                 */\n  double tdist;       /* Distance                                         */\n  \n  /* Check dimensions */\n  \n  if (idim != 2 && idim != 3) goto err105;\n  if (pc1->idim != pc2->idim) goto err106;\n  \n  /* Check if curves are  correct */\n  \n  s1707(pc1,&kstat);\n  if (kstat < 0) goto error;\n  \n  s1707(pc2,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Calculate closest point to eps1 */\n  \n  s1953(pc1,eps1,idim,REL_COMP_RES,aepsge,&kpt1,&spar1,&kcrv1,&qic1,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Remember closest point */\n  \n  if (kpt1  > 0)\n    tpar1 = spar1[0];\n  else if (kcrv1>0)\n    {\n      SISLIntcurve *q1= *qic1;\n      if (q1->ipar1 ==1)\n        tpar1 = q1 -> epar1[0];\n      else if (q1->ipar2 ==1)\n        tpar1 = q1 -> epar2[0];\n      else\n        goto errxxx;\n    }\n  \n  /* Calculate point and tangent on curve at tpar1 */\n  \n  s1221(pc1,1,tpar1,&kleft,spnt1,&kstat);\n  if (kstat < 0) goto error;\n  \n  \n  /* Calculate closest point to eps2 */\n  \n  s1953(pc2,eps2,idim,REL_COMP_RES,aepsge,&kpt2,&spar2,&kcrv2,&qic2,&kstat);\n  if (kstat < 0) goto error;\n  \n  \n  /* Remember closest point */\n  \n  if (kpt2  > 0)\n    tpar2 = spar2[0];\n  else if (kcrv1>0)\n    {\n      SISLIntcurve *q1= *qic2;\n      if (q1->ipar1 ==1)\n        tpar2 = q1 -> epar1[0];\n      else if (q1->ipar2 ==1)\n        tpar2 = q1 -> epar2[0];\n      else\n        goto errxxx;\n    }\n  \n  /* Calculate point and tangent on curve at tpar1 */\n  \n  s1221(pc2,1,tpar2,&kleft,spnt2,&kstat);\n  if (kstat<0) goto error;\n  \n  \n  /* Determine if offset to be used on curve 1 is positive or negative */\n  \n  if (idim==2)\n    {\n      snorm[0] = -spnt1[3];\n      snorm[1] =  spnt1[2];\n      s6diff(eps1,spnt1,idim,sdiff);\n      tprod = s6scpr(snorm,sdiff,idim);\n      s6diff(epf,spnt1,idim,sdiff);\n      tdir1 = s6scpr(sdiff,spnt1+idim,idim);\n    }\n  else\n    {\n      s6diff(epf,spnt1,idim,sdiff);\n      tdir1 = s6scpr(spnt1+idim,sdiff,idim);\n      s6crss(sdiff,spnt1+idim,snorm);\n      tprod = s6scpr(snorm,enorm,idim);\n    }\n  \n  /* Set direction of offset of curve 1 */\n  \n  if (tprod >= DZERO)\n    trad1 = aradius;\n  else\n    trad1 = -aradius;\n  \n  /* Determine if offset to be used on curve 1 is positive or negative */\n  \n  if (idim==2)\n    {\n      snorm[0] = -spnt2[3];\n      snorm[1] =  spnt2[2];\n      s6diff(eps2,spnt2,idim,sdiff);\n      tprod = s6scpr(snorm,sdiff,idim);\n      s6diff(epf,spnt2,idim,sdiff);\n      tdir2 = s6scpr(sdiff,spnt2+idim,idim);\n    }\n  else\n    {\n      s6diff(epf,spnt2,idim,sdiff);\n      tdir2 = s6scpr(spnt2+idim,sdiff,idim);\n      s6crss(sdiff,spnt2+idim,snorm);\n      tprod = s6scpr(snorm,enorm,idim);\n    }\n  \n  \n  /* Determine if offset to be used on curve 1 is positive or negative */\n  \n  if (tprod >= DZERO)\n    trad2 = aradius;\n  else\n    trad2 = -aradius;\n  \n  /* Make curve offset from curve 1 */\n  \n  s1360(pc1,trad1,aepsge,enorm,(double)0.0,idim,&qc1,&kstat);\n  if (kstat<0) goto error;\n  \n  \n  /* Make curve offset from curve 2 */\n  \n  s1360(pc2,trad2,aepsge,enorm,(double)0.0,idim,&qc2,&kstat);\n  if (kstat<0) goto error;\n  \n  /* Find closest point between the two curves, \n     if intersection does not succeed\n     use closest point between curves */\n  \n  s1857(qc1,qc2,REL_COMP_RES,aepsge,&kpt3,&spar3,&spar4,&kcrv3,&qic3,&kstat);\n  if (kstat<0) goto error;\n  \n  if (kpt3 == 0 && kcrv3 == 0)\n    {\n      s1955(qc1,qc2,REL_COMP_RES,aepsge,\n\t    &kpt3,&spar3,&spar4,&kcrv3,&qic3,&kstat);\n      if (kstat<0) goto error;\n    }\n  \n  /* Find point closest to ept */\n  \n  tmin=HUGE;\n  \n  if (kpt3>0)\n    {\n      /*  Find intersection point closest to epf */\n      \n      for (ki=0;ki<kpt3;ki++)\n        {\n\t  s1221(pc1,0,spar3[ki],&kleft,spnt1,&kstat);\n\t  if (kstat<0) goto error;\n\t  \n\t  tdist = s6dist(spnt1,epf,idim);\n\t  if (tdist<=tmin)\n            {\n\t      *ctf1 = spar3[ki];\n\t      *ctf2 = spar4[ki];\n\t      tmin = tdist;\n            }\n        }\n    }\n  else if (kcrv3>0)\n    {\n      SISLIntcurve *q1= *qic3;\n      for (ki=0; ki < q1->ipoint ; ki++)\n        {\n\t  s1221(pc1,0,q1->epar1[ki],&kleft,spnt1,&kstat);\n\t  if (kstat<0) goto error;\n\t  tdist = s6dist(spnt1,epf,idim);\n\t  if (tdist<=tmin)\n            {\n\t      *ctf1 = q1->epar1[ki];\n\t      *ctf2 = q1->epar2[ki];\n\t      tmin = tdist;\n            }\n        }\n    }\n  \n  if (tdist == HUGE) goto errxxx;\n  \n  /* Set parameter values indicating which part of curves remains after\n     the fillet */\n  \n  st = pc1->et;\n  kk = pc1->ik;\n  kn = pc1->in;\n  \n  if (tdir1>=0)\n    *ct11 = st[kk-1];\n  else\n    *ct11 = st[kn];\n  \n  /* Set parameter values indicating which part of curve two remains after\n     the fillet */\n  \n  st = pc2->et;\n  kk = pc2->ik;\n  kn = pc2->in;\n  \n  if (tdir2>=0)\n    *ct21 = st[kk-1];\n  else\n    *ct21 = st[kn];\n  \n  s1607(pc1,pc2,aepsge,*ct11,*ctf1,*ct21,*ctf2,itype,idim,ik,rc,&kstat);\n  if (kstat<0) goto error;\n  \n  *jstat = 0;\n  \n  goto out;\n  \n  \n  /* Error in input, conflicting dimensions */\n  \n err106: \n  *jstat = -106;\n  s6err(\"s1609\",*jstat,kpos);\n  goto out;\n  \n  /* Dimension nmot equal to 2 or 3 */\n  \n err105: \n  *jstat = -105;\n  s6err(\"s1609\",*jstat,kpos);\n  goto out;\n\n  \n  /* No fillet produced */\n  \n errxxx: \n  *jstat = -1;\n  goto out;\n  \n  /* Error in lower level function */  \n  \n error:  \n  *jstat = kstat;\n  s6err(\"s1609\",*jstat,kpos); \n  goto out;\n  \n out:\n  if (qc1   != SISL_NULL) freeCurve(qc1);\n  if (qc2   != SISL_NULL) freeCurve(qc2);\n  if (qic1  != SISL_NULL) freeIntcrvlist(qic1,kcrv1);\n  if (qic2  != SISL_NULL) freeIntcrvlist(qic2,kcrv2);\n  if (qic3  != SISL_NULL) freeIntcrvlist(qic3,kcrv3);\n  if (spar1 != SISL_NULL) freearray(spar1);\n  if (spar2 != SISL_NULL) freearray(spar2);\n  if (spar3 != SISL_NULL) freearray(spar3);\n  if (spar4 != SISL_NULL) freearray(spar4);\n  \n  return;\n}       \n"
  },
  {
    "path": "src/s1611.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1611.c,v 1.2 2001-03-19 15:58:51 afr Exp $\n *\n */\n\n\n#define S1611\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1611 (double epoint[], int inbpnt, int idim, double eptyp[], int iopen,\n       int ik, double astpar, double aepsge,\n       double *cendpar, SISLCurve ** rc, int *jstat)\n#else\nvoid \ns1611 (epoint, inbpnt, idim, eptyp, iopen, ik, astpar, aepsge,\n       cendpar, rc, jstat)\n     double epoint[];\n     int inbpnt;\n     int idim;\n     double eptyp[];\n     int iopen;\n     int ik;\n     double astpar;\n     double aepsge;\n     double *cendpar;\n     SISLCurve **rc;\n     int *jstat;\n#endif\n/*\n*************************************************************************\n*\n* PURPOSE: To approximate a conic arc with a b-spline curve in the two or\n*          the three dimensional space. If two points are given a straight\n*          line is produced, if three a circular arc and if four or five\n*          a conic arc.\n*\n* INPUT:\n*        Epoint - Array (length idim*inbpnt) containing the points/\n*                 tangents to be interpolated.\n*        Inbpnt - No. of points/tangents in the epoint array.\n*        Idim   - The dimension of the space in which the points lie.\n*        Eptyp  - Array (length inbpnt) containing type indicator for\n*                 points/tangents :\n*                  1 - Ordinary point.\n*                  2 - Knuckle point. (Is treated as an ordinary point.)\n*                  3 - Tangent to next point.\n*                  4 - Tangent to prior point.\n*        Iopen  - Flag telling if the curve should be open or closed:\n*                  0 : Closed curve.\n*                  1 : Open curve.\n*                 NOT IN USE!\n*        Ik     - The order of the B-spline curve to be produced.\n*        Astpar - Parameter-value to be used at the start of the curve.\n*        Aepsge - The geometry resolution.\n*\n* Output:\n*        Cendpar - Parameter-value used at the end of the curve.\n*        Rc      - Pointer to output-curve.\n*        Jstat   - Status variable:\n*                  < 0 : Error.\n*                  = 0 : Ok.\n*                  > 0 : Warning.\n*\n* Method: First we find the conic curve on which the points lie.\n*         Then a b-spline curve describing the conic is produced.\n*-\n* Calls: s1614, s6crss, s6rotmat, s6inv4, s6mulvec, s1615, s1616, s1617,\n*        s1385, s1602, s6err.\n*\n* Written by: A.M. Ytrehus, SI Oslo Oct.91.\n* After FORTRAN (P19506), written by: T. Dokken  SI.\n* REVISED BY : Christophe Birkeland, SI, July 1992 (eptyp is now DOUBLE)\n* REVISED BY : Johannes Kaasa, SI, Aug. 1992 (transported status 105 from\n*              s1616 upwards)\n* REVISED BY : Johannes Kaasa, SI, Aug. 1992 (Fixed bug in production of\n*              the rotational matrix, and made a seperate handling of\n*              circular arcs)\n*****************************************************************\n*/\n{\n  double *spoint = SISL_NULL;\n  int    *sptyp = SISL_NULL;\n  double smatrix[16];\n  double sinv[16];\n  double *st = SISL_NULL;\n  double sbeg[3], slutt[3], svect1[3], svect2[3], snorm[3];\n  int knbpnt = 0;\n  int ktyp;\n  int kp, ki, kk, kn;\n  double tdum, tpar;\n  double tshape;\n  double spnt[3], sdum[3];\n  double start[3], stang[3], stop[3];\n  double strans[3];\n  double smul[3];\n  double sconic[6];\n  int kpos = 0;\n  int krem = 0;\n  int kstat = 0;\n  int *ieptyp = SISL_NULL; /* The point type descriptions (eptyp) in integer form. */\n  double centerpt[3], axis[3], sdir[3];\n  double angle, sdot, tlength1, tlength2, tcos;\n  int kstat1, kstat2;\n\n  *jstat = 0;\n\n  \n  /* Copy eptyp to ieptyp. */\n\n  ieptyp = newarray(inbpnt,INT);\n  if (ieptyp == SISL_NULL)\n     goto err101;\n  \n  for(ki=0; ki<inbpnt; ki++)\n  {\n      ieptyp[ki] = (int)eptyp[ki];\n  }\n  \n\n  /* Test if legal input. */\n\n  if (idim < 2 || idim > 3 || ik < 3)\n    goto err104;\n\n\n  /* Allocate new arrays. */\n\n  spoint = newarray (inbpnt * idim, DOUBLE);\n  if (spoint == SISL_NULL)\n    goto err101;\n\n  sptyp = newarray (inbpnt, INT);\n  if (sptyp == SISL_NULL)\n    goto err101;\n\n\n  /* Check the types of the data/points. */\n\n  s1614 (epoint, inbpnt, idim, ieptyp,spoint, &knbpnt, sptyp, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Save the start- and end-points, in case of straight line. */\n\n  kk = idim * (knbpnt - 1);\n\n  for (kp = 0; kp < idim; kp++)\n    {\n      sbeg[kp] = spoint[kp];\n      sdir[kp] = spoint[idim + kp];\n      slutt[kp] = spoint[kk + kp];\n    }\n\n\n  /* Test if straight line is to be produced. */\n\n  if (knbpnt == 2)\n    goto straight;\n\n\n  /* The calculations on the conic are performed two-dimensionally.\n     Obtain a 2D description if the conic lies in a 3D space. */\n\n  if (idim == 3)\n    {\n\n      /* Translate the points (and not the tangents) such that\n         the first point lies in the origin. Remember translation. */\n\n      for (kp = 0; kp < idim; kp++)\n\tstrans[kp] = spoint[kp];\n\n      for (ki = 0; ki < knbpnt; ki++)\n\t{\n\t  ktyp = sptyp[ki];\n\t  if (ktyp < 3)\n\t    {\n\t      kk = idim * ki;\n\n\t      for (kp = 0; kp < idim; kp++)\n\t\tspoint[kk + kp] = spoint[kk + kp] - strans[kp];\n\t    }\n\t}\n\n      /* Produce rotational matrix. */\n\n      kk = idim * (knbpnt - 1);\n\n      for (kp = 0; kp < idim; kp++)\n\tspnt[kp] = spoint[kk + kp];\n\n      for (ki = 1; ki < knbpnt - 1; ki++)\n\t{\n\t  kk = idim * ki;\n\n\t  for (kp = 0; kp < idim; kp++)\n\t    sdum[kp] = spoint[kk + kp];\n\n\t  for (kp = 0; kp < idim; kp++)\n\t    {\n\t      svect1[kp] = spnt[kp] - spoint[kp];\n\t      svect2[kp] = sdum[kp] - spoint[kp];\n\t    }\n\n\t  s6crss (svect1, svect2, snorm);\n\n\t  s6rotmat (spoint, spnt, snorm, smatrix, &kstat);\n\t  if (kstat == 0)\n\t    break;\n\t}\n\n      /* If we are here with kstat< 0, we have not been able\n         to produce rotational matrix. Make straight line. */\n\n      if (kstat < 0)\n\tgoto straight;\n\n\n      /* Invert the matrix to prepare for rotation of points. */\n\n      s6inv4 (smatrix, sinv, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n\n      /* Use the inverted matrix on the points and tangents. */\n\n      for (ki = 0; ki < knbpnt; ki++)\n\t{\n\t  kk = idim * ki;\n\n\t  for (kp = 0; kp < idim; kp++)\n\t    sdum[kp] = spoint[kk + kp];\n\n\t  s6mulvec (sinv, sdum, smul);\n\n\t  for (kp = 0; kp < idim; kp++)\n\t    spoint[kk + kp] = smul[kp];\n\t}\n    }\n\n\n  /* Test if the points lie on the same branch if the curve\n     is a hyperbola. If kstat = 1, different branches, create straight line. */\n\n  s1615 (spoint, knbpnt, idim, sptyp, &kstat);\n  if (kstat < 0)\n    goto error;\n  if (kstat == 1)\n    goto straight;\n\n\n  /* Find the conic equation of the points. */\n\n  s1616 (spoint, knbpnt, idim, sptyp, sconic, &kstat);\n  if (kstat < 0)\n    goto error;\n  if (kstat > 0)\n    krem = kstat;\n\n  if (knbpnt == 3)\n    {\n       \n       /* Circle segment */\n       \n       /* Establish centerpoint. */\n       \n       centerpt[0] = - sconic[3];\n       centerpt[1] = - sconic[4];\n       centerpt[2] = (double) 0.0;\n\n      /* If the dimension is 3, rotate the centerpoint\n         back into the 3D space and translate. */\n\n      if (idim == 3)\n        {\n          s6mulvec (smatrix, centerpt, smul);\n\n          for (kp = 0; kp < idim; kp++)\n\t    centerpt[kp] = smul[kp] + strans[kp];\n        }\n\n\n      /* Establish rotational angle and axis. */\n\t\n      s6diff(sbeg, centerpt, idim, svect1);\n      s6diff(slutt, centerpt, idim, svect2);\n\n      sdot = s6scpr(svect1, svect2, idim);\n  \n      tlength1 = s6length(svect1, idim, &kstat1);\n      tlength2 = s6length(svect2, idim, &kstat2);\n  \n      if (!kstat1 || !kstat2)\n        angle = DZERO;\n      else\n      {\n        tcos = sdot/(tlength1*tlength2);\n        tcos = MIN((double)1.0,tcos);\n        angle = acos(tcos);\n      }\n\n      if (idim == 3)\n        s6crss(svect1, sdir, axis);\n      else if ((svect1[0]*sdir[1] - svect1[1]*sdir[0]) < 0.)\n\t angle = -angle;\n      \n      s6diff(slutt, sbeg, idim, svect1);\n      sdot = 0.0;\n      for (kp = 0; kp < idim; kp++)\n\t sdot += sdir[kp]*svect1[kp];\n      if (sdot < 0.0)\n      {\n\t if (idim == 3)\n\t    angle = TWOPI - angle;\n\t else\n\t {\n\t if (angle < 0)\n\t   angle = - (angle + TWOPI);\n\t else\n\t   angle = TWOPI - angle;\n\t }\n      }\n\n      s1303 (sbeg, aepsge, angle, centerpt, axis, idim, rc, &kstat);\n      if (kstat < 0)\n        goto error;\n    \n    }\n  else\n    {\n       \n      /* Produce knots for interpolation. */\n\n      s1617 (spoint, knbpnt, idim, sptyp, aepsge, sconic,\n\t     start, stang, stop, &tshape, &kstat);\n      if (kstat < 0)\n        goto error;\n      if (kstat == 1)\n\tgoto straight;\n\n\n      /* If the dimension is 3, rotate the points\n         back into the 3D space and translate. */\n\n      if (idim == 3)\n        {\n          s6mulvec (smatrix, start, smul);\n\n          for (kp = 0; kp < idim; kp++)\n\t    start[kp] = smul[kp] + strans[kp];\n\n          s6mulvec (smatrix, stang, smul);\n\n          for (kp = 0; kp < idim; kp++)\n\t    stang[kp] = smul[kp] + strans[kp];\n\n          s6mulvec (smatrix, stop, smul);\n\n          for (kp = 0; kp < idim; kp++)\n\t    stop[kp] = smul[kp] + strans[kp];\n        }\n\n\n      /* Make description of conic curve as\n         B-spline within user defined tolerance */\n\n      s1385 (start, stang, stop, tshape, idim, aepsge, rc, &kstat);\n      if (kstat < 0)\n        goto error;\n    \n    }\n\n\n  /* Adjust knot vector to match input start parameter value */\n\n  kk = (*rc)->ik;\n  kn = (*rc)->in;\n\n  st = (*rc)->et;\n\n  tdum = astpar - st[kk - 1];\n\n  for (ki = 0; ki < kn + kk; ki++)\n    st[ki] += tdum;\n\n\n  /* Find end parameter value of curve */\n\n  *cendpar = st[kn];\n\n  goto out;\n\nstraight:\n\n  /* Create straight line, based on first and last real point. */\n\n  s1602 (sbeg, slutt, ik, idim, astpar, &tpar, rc, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Find end parameter value of curve */\n\n  *cendpar = tpar;\n\n  goto out;\n\n\n  /* Error in allocation. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1611\", *jstat, kpos);\n  goto out;\n\n  /* Dimension error. */\n\nerr104:\n  *jstat = -104;\n  s6err (\"s1611\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine. */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1611\", *jstat, kpos);\n  goto out;\n\nout:\n\n  /* Free space occupied by local arrays. */\n\n  if (spoint != SISL_NULL)\n    freearray (spoint);\n  if (sptyp != SISL_NULL)\n    freearray (sptyp);\n  if (ieptyp != SISL_NULL)\n     freearray (ieptyp);\n\n  if (*jstat >= 0)\n     *jstat = krem;\n  return;\n}\n"
  },
  {
    "path": "src/s1612.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1612.c,v 1.2 2001-03-19 15:58:51 afr Exp $\n *\n */\n\n\n#define S1612\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1612(SISLCurve *pc,double aepsge,double **gpoint,int *jnbpnt,int *jleng,int *jstat)\n#else\nvoid s1612(pc,aepsge,gpoint,jnbpnt,jleng,jstat)\n     SISLCurve  *pc;\n     double aepsge;\n     double **gpoint;\n     int    *jnbpnt;\n     int    *jleng;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate a set of points on a B-spline curve. \n*              The straight lines between the points will not deviate\n*              more than aepsge from the B-spline curve at any point.\n*             \n* INPUT      : pc     - The input B-spline curve.   \n*              aepsge - Geometry resolution, maximum distance allowed between\n*                       the curve and the straight lines to be calculated. \n*\n* INPUT/OUTPUT :\n*              jnbpnt - No. of calculated points until now \n*              jleng  - no. of allocated doubles in gpoint until now\n*              gpoint - Calculated points    \n*\n* OUTPUT     : jstat  - status messages         \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : This routine recursively calls itself.\n*              First the curve is split at kk-1 internal multiple knots.\n*              Each curve segment is then treated: \n*              The distance between the control polygon and a straight\n*              line from the first to the last vertex is found. If the \n*              distance is grater than aepsge, the curve is split again\n*              as follows: \n*              If any internal knots exist the curve is split in the\n*              middlemost knot; if not, the curve is split in the middle of\n*              the parameter interval. \n*              If the distance is less than aepsge the last vertex is \n*              saved in array.\n*\n* ASSUMTIONS  :kk multiple knots in start and end of parameterintervall.\n*\n* USE        :       \n*\n* REFERENCES :\n*\n*-                                                 \n* CALLS      : s1840,s1710,s1612(recursive),s1235,s6err\n*\n*\n* WRITTEN BY : Qyvind Hjelle, SI, Oslo, Norway. 31. Jan 1989\n*\n*********************************************************************\n*/\n{\n  int kstat;          /* Status variable                                 */\n  int kn;             /* The number of B-splines, i.e., the dimension of\n\t\t\t the spline space associated with the knot\n\t\t\t vector.                                         */\n  int kk;             /* The polynomial order of the curve.              */\n  int kdim;           /* The dimension of the space in which the curve\n\t\t\t lies. Equivalently, the number of components\n\t\t\t of each B-spline coefficient.                   */\n  int ki;             /* Local counter                                   */\n  int kleft;          /* Pointer into knot vector array                  */\n  int knbreak=0;      /* No. of kk-1 multiple knots                      */\n  int knbpnt;         /* Local for jnbpnt                                */\n  int kleng;          /* Local for jleng                                 */\n  int kvlast;         /* Position of last vertex in vertex array         */\n  int kpos=0;         /* Position of error                               */\n  \n  double *spoint=SISL_NULL;/* Pointer to array of points                      */\n  double tdist;       /* Distance                                        */\n  double tpar;        /* A parameter value of the curve                  */\n  double *sbreak = SISL_NULL;  /* Array containing kk-1 multiple knot         */\n  double *st;         /* Pointer to the first element of the knot vector\n\t\t\t of the curve. The knot vector has [kn+kk]\n\t\t\t elements.                                       */\n  \n  \n  SISLCurve *qcnew1=SISL_NULL; /* Pointer to first new  curve-object       */\n  SISLCurve *qcnew2=SISL_NULL; /* Pointer to second new curve-objec        */\n  \n  \n  /* Check input   */\n  \n  if (aepsge <= (double)0.0) goto err120;\n  \n  /* Make locals  */\n  \n  spoint = *gpoint;\n  knbpnt = *jnbpnt;\n  kleng  = *jleng;\n  \n  /* Describe curve with local parameters.  */\n  \n  kn    = pc -> in;\n  kk    = pc -> ik;\n  kdim  = pc -> idim;          \n  st    = pc -> et;\n  \n  /* Find all kk-1 multiple knots including start and endpoint */\n  \n  s1235(st,kn,kk,&knbreak,&sbreak,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Always split curve at kk-1 multiple knots */\n  \n  if (knbreak > 2) \n    {\n      for (ki=1; ki<knbreak-1; ki++)\n\t{\n\t  tpar = sbreak[ki];\n\t  \n\t  s1710(pc,tpar,&qcnew1,&qcnew2,&kstat);\n\t  if(kstat < 0) goto error;\n\t  \n\t  /* Recursion on first part */\n\t  \n\t  if (qcnew1)\n\t  {\n\t     s1612(qcnew1,aepsge,&spoint,&knbpnt,&kleng,&kstat);\n\t     if (kstat < 0) goto error;\n\t  }\n\t  \n\t  /* Recursion on second part */\n\t  \n\t  if (qcnew2)\n\t  {\n\t     s1612(qcnew2,aepsge,&spoint,&knbpnt,&kleng,&kstat);\n\t     if (kstat < 0) goto error;\n\t  }\n\t}\n    }\n  else      \n    /* If no internal kk-1 multiple knots */\n    {\n      /* Find distance between control polygon and a straight line beetween\n\t first and last vertex*/\n      \n      s1840(pc,&tdist,&kstat);\n      if (kstat < 0) goto error;\n      \n      if (tdist < aepsge)\n\t{\n\t  /* Save last vertex */\n\t  \n\t  kvlast = (kn-1) * kdim;\n\t  \n\t  knbpnt += 1;\n\t  \n\t  /* Allocate place for 100 more points in gpoint if not enought place */\n\t  \n\t  if (kleng < (knbpnt+1)*kdim )\n\t    {\n\t      kleng  += 100*kdim;\n\t      spoint = increasearray(spoint,kleng,DOUBLE);\n\t      if (!spoint) goto err101;\n\t    }\n\t  \n\t  /* Save point in array */\n\t  \n\t  memcopy (&spoint[(knbpnt-1)*kdim],&pc->ecoef[kvlast],kdim,DOUBLE);\n\t}\n      else\n\t{\n\t  /* Split curve in two parts. If any internal knots, split in the \n\t     midlemost */\n\t  \n\t  tpar = (st[0] + st[kn+kk-1]) / (double)2.0; \n\t  \n\t  if (kn > kk) \n\t    {    \n\t      /* Localize the parameter value */\n\t      \n\t      kleft = 0;\n\t      s1219(st,kk,kn,&kleft,tpar,&kstat);\n\t      if (kstat < 0) goto error;\n\t      \n\t      /* Find the knot nearest to the midle of the parameter interval */\n\t      \n\t      if (fabs(tpar-st[kleft]) < fabs(st[kleft+1]-tpar)) \n\t\t{\n\t\t  tpar = st[kleft];\n\t\t}\n\t      else\n\t\t{\n\t\t  tpar = st[kleft+1];\n\t\t}\n\t    }\n\t  \n\t  s1710(pc,tpar,&qcnew1,&qcnew2,&kstat);\n\t  if(kstat < 0) goto error;\n\t  \n\t  /* Recursion on first part */\n\t  \n\t  if (qcnew1)\n\t  {\n\t     s1612(qcnew1,aepsge,&spoint,&knbpnt,&kleng,&kstat);\n\t     if (kstat < 0) goto error;\n\t  }\n\t  \n\t  /* Recursion on second part */\n\t  \n\t  if (qcnew2)\n\t  {\n\t     s1612(qcnew2,aepsge,&spoint,&knbpnt,&kleng,&kstat);\n\t     if (kstat < 0) goto error;\n\t  }\n\t}\n    }\n  \n  *gpoint = spoint;\n  *jnbpnt = knbpnt;\n  *jleng  = kleng;\n  *jstat = 0;\n  goto out;\n  \n  /* Error in memory allocation */\n  \n err101: \n  *jstat = -101;\n  s6err(\"s1612\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Relative tollerance <=0  */\n  \n err120: \n  *jstat = -120;\n  s6err(\"s1612\",*jstat,kpos);\n  goto out;\n  \n  \n  /* Error in lower level function */  \n  \n error:  \n  *jstat = kstat;\n  s6err(\"s1612\",*jstat,kpos); \n  goto out;\n  \n  \n out:\n  \n  /* Free space occupied by local arrays and objects.  */\n  \n  if (sbreak) freearray(sbreak);\n  if (qcnew1) freeCurve(qcnew1);\n  if (qcnew2) freeCurve(qcnew2);\n  \n  return;\n}       \n   \n          \n"
  },
  {
    "path": "src/s1613.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1613.c,v 1.3 2001-03-19 15:58:51 afr Exp $\n *\n */\n\n\n#define S1613\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1613(SISLCurve *pc,double aepsge,double **gpoint,int *jnbpnt,int *jstat)\n#else\nvoid s1613(pc,aepsge,gpoint,jnbpnt,jstat)\n     SISLCurve  *pc;\n     double aepsge;\n     double **gpoint;\n     int    *jnbpnt;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n* \n* PURPOSE    : To compute an aproximation of a curve with a sequence\n*              of lines inside a tolerance of aepsge.\n*              All vertices are on the curve.\n* \n* \n* INPUT      : pc    - Given spline curve.\n*              aepsge    - Tolerance.\n*\n* \n* OUTPUT     : gpoint   - Array containing the points.\n*                         Array are allocated inside this function,\n*              jnbpnt - Number of sampling points.\n*              jstat     - status messages \n*                          > 0 : warning \n*                          = 0 : ok \n*                          < 0 : error \n* \n* \n* METHOD     : The error in approximating a given function f on an interval\n*              [a,b] by linear spline approximation is bounded by\n*                      (b-a)**2*max(abs(D2(f)))/8\n*              where max(abs(D2(f))) denotes the maximum of the absolute value\n*              of the 2. derivative of f on the interval [a,b].\n*              In order to approximate a derivative curve, we get the bound\n*                      (b-a)**2*max(abs(D(2)(f))/8\n*              For a spline curve this estimate applies on each of the \n*              component of the geometry space.\n*              To determine the sampling points, we start from the left of the\n*              given spline and consider one knot interval at the time. On each\n*              knot interval the 2. derivative is a spline of order \n*              ik-2 (ik is the order of f), the coefficients of which \n*              is 2. order divided differences of the original coefficients. \n*              The div. diff. of largest absolute value then gives an estimate \n*              of the maximum of the absolute value of  the 2. derivative \n*              so that the error in linear interpolation becomes less than the \n*              tolerance. This can be done in each of the geometry components \n*              and to be on the safe side we choose the smallest of the \n*              resulting step lengths. This step length is then adjusted so \n*              that the sampling points can be distributed uniformly in \n*              the interval, and always with one sampling point at \n*              the beginning of the interval and one at the end, i.e. \n*              all original knots become sampling points.\n*              At break points, two sampling points will be placed.\n*              \n*\n* REFERENCES : \n*              \n*\n* USE        : \n*\n*-\n* CALLS      : \n*              \n*\n* WRITTEN BY : Arne Laksaa, SI, 10.90.\n* REWISED BY : Vibeke Skytt, SI, 10.92. No multiple points as output\n*                                       at breakpoints.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;           /* Status variable.  */\n  int kpos  = 0;           /* Position of error reported. */\n  int ki,kj,kk,kh,kr,kl;   /* Counters.         */\n  int kikr;                /* Order of current derivative curve. */\n  int kih;                 /* Current location in sdd2.          */\n  int kihn;                /* Next location in sdd2.             */\n  int kjh;                 /* Index in sdd2.                     */\n  int kstop;               /* Number of divided differences to compute.   */\n  int kdim = pc->idim;  /* Dimension of space in which the curve lies. */\n  int kncoef = pc->in;  /* Number of vertices of curve.  */\n  int korder = pc->ik;  /* Order of curve.               */\n  int kordnew = korder-2;  /* Order of derivative curve of which \n\t\t\t      to find an upper bound.         */\n  int knmbel = 100;        /* Number of elements with which the parameter\n\t\t\t      array is to be increased.                   */       \n  int kmaxpar = 20*kncoef;    /* Length of parameter array.           */\n  int kpar = 0;            /* Number of parameter values computed.        */\n  int kant;                /* Number of sampling points at a knot interval. */\n  int left = 0;            /* Help index to evaluator.                    */\n  double *spar = SISL_NULL;        /* Parameter values corresponding to Bezier\n\t\t\t      segment.                                    */\n  double tmaxint = (double)10; /* Try alternative method if the number of\n\t\t\t      linear segments of a Bezier segment is\n\t\t\t      larger than tmaxint.                     */\n  double tant;             /* Number of sampling points at a knot interval. */\n  double tfac;             /* Factor used in taking divided differences.    */\n  double ta;               /* Start value of parameter interval.          */\n  double tb;               /* End value of parameter interval.            */\n  double th;               /* Distance between output parameter values.   */\n  double *st;              /* Pointer to knot vector of curve.            */\n  double *par = SISL_NULL;      /* Array used to store parameter values.       */\n  double *sh  = SISL_NULL;      /* Work array.    */\n  double *sh1 = SISL_NULL;      /* Work array.    */\n  double *sdd = SISL_NULL;      /* Work array used to compute divided differences. */\n  double *sdd2 = SISL_NULL;     /* Array used to store final divided differences.  */\n  double *smaxd = SISL_NULL;    /* Array used to store maximum divided differences.*/\n  SISLCurve *qc = SISL_NULL;    /* Curve representing Bezier segment.              */\n  \n  /* Test input.  */\n  \n  if (korder < 1) goto err110;\n  if (kncoef < korder) goto err111;\n  if (kdim < 1) goto err102;\n  \n  if (korder == 1)\n    {\n      kpar = kncoef;\n      if ((*gpoint = newarray(kpar*kdim,DOUBLE)) == SISL_NULL) goto err101;\n      memcopy(*gpoint,pc->ecoef,kpar*kdim,DOUBLE);\n      *jnbpnt = kpar;\n      *jstat = 0;\n      goto out;\n    }\n  \n  \n  /* Set local pointer to knot vector of curve.  */\n  \n  st = pc->et;\n  \n  /* Allocate some scratch for output array.  */\n  \n  if ((par = newarray(kmaxpar,DOUBLE)) == SISL_NULL) goto err101;\n  \n  /* Allocate scratch for internal arrays.  */\n  \n  if ((sdd = new0array((kordnew+6)*kdim,DOUBLE)) == SISL_NULL) goto err101;\n  sdd2 = sdd+3*kdim;\n  smaxd = sdd2+kordnew*kdim;\n  sh = smaxd+kdim;\n  sh1 = sh+kdim;\n  \n  /* Main loop to determine the interpolation points in each knot interval\n     by computing 2. order differences and taking the maximum of the \n     appropriate kordnew 2. order differences on each knot interval. The\n     number of uniform interplation points in the knot interval can then\n     by estimated using the bound described in METHOD.\n     In the following the index ki will point at the next coefficient to be \n     included in the computation of the 2. order derivatives.\n     kpar points to the location in the array par where the parameter value\n     of the next interpolation point is to be stored.\n     kih points to the location in sdd2 where the next 2. order difference\n     is to be stored.        */\n  \n  kpar=0;\n  tb = st[korder-1];\n  \n  /* Store startparameter of curve. */\n  \n  par[kpar] = tb;\n  kpar++;\n  \n  for (kih=0, ki=0; ki<kncoef; ki=kj)\n    {\n      /* Compute the index of the first knot greater than tb.  */\n      \n      for (kj=MAX(korder-1,ki)+1; st[kj]==tb; kj++);\n      ta = tb;\n      tb = st[kj];\n      \n      /* If the 2. order differences may be different from zero, \n\t Compute them.   */\n      \n      for (kk=ki; korder>2 && kk<kj; kk++)\n\t{\n\t  /* Pick the next coefficient.  */\n\t  \n\t  memcopy(sh,pc->ecoef+kk*kdim,kdim,DOUBLE);\n\t  \n\t  /* Compute the 1, 2 difference at kk.  */\n\t  \n\t  kikr = korder - 1;\n\t  kstop = MIN(2,korder-kj+kk);\n\t  for (kr=0; kr<kstop; kr++)\n\t    {\n\t      tfac = (double)kikr/(st[kk+kikr] - ta);\n\t      kikr--;\n\t      for (kh=0; kh<kdim; kh++)\n\t\tsh1[kh] = (sh[kh] - sdd[kr*kdim+kh])*tfac;\n\t      memcopy(sdd+kr*kdim,sh,kdim,DOUBLE);\n\t      memcopy(sh,sh1,kdim,DOUBLE);\n\t    }\n\t  memcopy(sdd+kr*kdim,sh,kdim,DOUBLE);\n\t  \n\t  /* Compute the maximum of the 2. order difference. The\n\t     kordnew previous 2. order differences are stored in\n\t     sdd2 and the current one (sdd+3*kdim) is to overwrite\n\t     sdd2+kih*kdim. The fact that only one new element enters\n\t     sdd2 at a time can be taken advantage of in computing \n\t     the maximum difference.   */\n\t  \n\t  if (kstop == 2)\n\t    {\n\t      for (kihn=(kih+1)%kordnew, kh=0; kh<kdim; kh++)\n\t\t{\n\t\t  sh[kh] = fabs(sh[kh]);\n\t\t  if (sdd2[kih*kdim+kh] < smaxd[kh])\n\t\t    smaxd[kh] = MAX(smaxd[kh],sh[kh]);\n\t\t  else if (sh[kh] >= smaxd[kh])\n\t\t    smaxd[kh] = sh[kh];\n\t\t  else\n\t\t    {\n\t\t      for (kjh=kihn, smaxd[kh]=sh[kh], kl=0;\n\t\t\t   kl<kordnew-1; kl++, kjh=(kjh+1)%kordnew)\n\t\t\tsmaxd[kh] = MAX(smaxd[kh],sdd2[kjh*kdim+kh]);\n\t\t    }\n\t\t  sdd2[kih*kdim+kh] = sh[kh];\n\t\t}\n\t      kih = kihn;\n\t    }\n\t}\n      \n      /* Compute the number of interpolation points.  */\n      \n      for (kant=0, kh=0; kh<kdim; kh++)\n\t{\n\t  tant = (tb-ta)*sqrt(smaxd[kh]/((double)8.0*aepsge));\n\t  if (tant > tmaxint) break;\n\t  kant = MAX(MAX(kant,(int)tant),1);\n\t}\n      \n      if (kh < kdim)\n      {\n\t /* Alternative linearization necessary due to large amount \n\t    of data. First pick Bezier curve. */\n\t \n\t s1712(pc,ta,tb,&qc,&kstat);\n\t if (kstat < 0) goto error;\n\t\t\t\n \t /* Approximate curve by linear segments.  */\n\t\t\t\n         s1613bez(qc,(int)tmaxint,aepsge,&spar,&kant,&kstat);\n\t if (kstat < 0) goto error;\n\t\t\t\n         if (qc != SISL_NULL) freeCurve(qc);\n         qc = SISL_NULL;\n\t \n\t if (kstat == 2)\n\t {\n\t    /* No linearization is performed.  */\n\t    \n\t    goto err160;\n\t }\n      }\n      \n      /* Make sure that par is great enough.  */\n      \n      if (kpar+kant+1 >= kmaxpar)\n\tif ((par = increasearray(par,(kmaxpar+=MAX(kant+1,knmbel)),DOUBLE)) \n\t    == SISL_NULL) goto err101;\n      \n      if (spar == SISL_NULL)\n      {\n\t /* Compute the parameter values of the interpolation points.  */\n\t \n\t for (th=(tb-ta)/(double)(kant+1), kk=0; kk<kant; kpar++,kk++)\n\t    par[kpar] = ta + (double)(kk+1)*th;\n\t par[kpar] = tb;\n\t kpar++;\n      }\n      else\n      {\n\t for (kk=0; kk<kant; kk++, kpar++)\n\t    par[kpar] = spar[kk];\n\t par[kpar] = tb;\n\t kpar++;\n\t \n\t freearray(spar);\n\t spar = SISL_NULL;\n      }\n    }\n  \n  /* Make the points.  */\n  \n  if ((*gpoint = newarray(kpar*kdim,DOUBLE)) == SISL_NULL) goto err101;\n  \n  for (kh=kk=0; kk<kpar; kk++,kh+=kdim)\n    {\n      s1221(pc,0,par[kk],&left,*gpoint+kh,&kstat);\n      if (kstat < 0) goto err101;\n    }\n  \n  /* Task performed.  */\n  \n  *jnbpnt = kpar;\n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error in scratch allocation.  */\n  \n  err101 :\n    *jstat = -101;\n    s6err(\"s1613\",*jstat,kpos);\n    goto out;\n  \n  /* Error in input. Dimension less than one.  */\n  \n  err102 :\n    *jstat = -102;\n    s6err(\"s1613\",*jstat,kpos);\n    goto out;\n  \n  /* Error in input. Order less than one.  */\n  \n  err110 :\n    *jstat = -110;\n    s6err(\"s1613\",*jstat,kpos);\n    goto out;\n  \n  /* Error in input. Number of coefficients less than order.  */\n  \n  err111 :\n    *jstat = -111;\n    s6err(\"s1613\",*jstat,kpos);\n    goto out;\n    \n    /* Curve too complicated. No linearization is performed.  */\n    \n    err160:\n       *jstat = -160;\n    s6err(\"s1613\",*jstat,kpos);\n    goto out;\n    \n    /* Error in lower level routine.  */\n    \n    error :\n       *jstat = kstat;\n    s6err(\"s1613\",*jstat,kpos);\n    goto out;\n  \n  out :\n    /* Free scratch occupied by local arrays.  */\n    \n    if (sdd != SISL_NULL) freearray(sdd);\n    if (par != SISL_NULL) freearray(par);\n}\n\n\n"
  },
  {
    "path": "src/s1613bez.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1613bez.c,v 1.2 2001-03-19 15:58:52 afr Exp $\n *\n */\n\n\n#define S1613BEZ\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1613bez(SISLCurve *pc,int idiv,double aepsge,double **gpar,int *jnpar,\n\t      int *jstat)\n#else\nvoid s1613bez(pc,idiv,aepsge,gpar,jnpar,jstat)\n     SISLCurve  *pc;\n     int idiv;\n     double aepsge;\n     double **gpar;\n     int    *jnpar;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n* \n* PURPOSE    : To compute an aproximation of a Bezier curve with a \n*              sequence of lines inside a tolerance of aepsge.\n* \n* \n* INPUT      : pc    - Given spline curve.\n*              idiv  - Inital number into which to divide the curve.\n*              aepsge    - Tolerance.\n*\n* \n* OUTPUT     : gpar     - Array containing the parameter values of the points.\n*                         Array are allocated inside this function,\n*              jnpar    - Number of sampling points.\n*              jstat     - status messages \n*                          = 2 : warning. Level of recursion too deep.\n*                          = 0 : ok \n*                          < 0 : error \n* \n* \n* METHOD     :\n*              \n*\n* REFERENCES : \n*              \n*\n* USE        : \n*\n*-\n* CALLS      : newknots, s1018, s6dline, newCurve, s1613bez,\n*              s6takeunion, freeCurve\n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 08.92.\n*\n*********************************************************************\n*/\n{\n   static int klevel = 0;  /* Level of recursion.                    */\n   int kstat = 0;        /* Local status varaible.                   */\n   int ki;               /* Counter.                                 */\n   int kord = pc->ik;    /* Order of curve.                          */\n   int kdim = pc->idim;  /* Dimension of geometry space.             */\n   int knpar;            /* Number of par. values in refinement.     */\n   int kbez = 3;         /* Polynomial Bezier curve.                 */\n   int kdiv = 10;        /* Initial division of subcurve.            */\n   int kparout;          /* Number of divisions of subcurve.         */\n   int knunion;          /* Number of parameter values in union vector. */\n   int knparts = idiv;   /* Number of division parameter values.     */\n   double tstart = *(pc->et+kord-1);   /* Start par. value of curve. */\n   double tend = *(pc->et+pc->in);     /* End par. value of curve.   */\n   double tint = (tend - tstart)/(double)(idiv+1);  /* Parameter interval\n\t\t\t\t\t\t       between div. points. */\n   double tpar;             /* Current parameter values.                */\n   double *sparout = SISL_NULL;  /* Array of parameter values from subcurve. */\n   double *spar = SISL_NULL;     /* Array of parameter values.        */\n   double *sparunion = SISL_NULL;  /* Union of parameter arrays.      */\n   double *spar2 = SISL_NULL;    /* Array of parameter values.        */\n   double *sta,*stb,*s1;    /* Pointers into coefficient arrays. */\n   SISLCurve *qc = SISL_NULL;    /* Refined curve.                    */\n   SISLCurve *qbez = SISL_NULL;  /* Bezier segment of refined curve.  */\n\n   /* Check level of recursion.  */\n   \n   klevel++;\n   if (klevel > 200)\n   {\n      *jstat = 2;\n      goto out;\n   }\n   \n   /* Check if the curve is a Bezier curve.  */\n   \n   if (pc->ik != pc->in) goto err111;\n\n   /* Set up array of division parameter values. First allocate scratch.  */\n      \n   if ((spar = newarray(idiv,DOUBLE)) == SISL_NULL) goto err101;\n     \n   for (ki=0, tpar=tstart+tint; ki<idiv; ki++, tpar+=tint)\n      spar[ki] = tpar;\n   \n   /* Fetch the new knots with which to refine the curve. */\n   \n   newknots(pc->et,pc->in,pc->ik,spar,idiv,REL_PAR_RES,&spar2,&knpar,&kstat);\n   if (kstat < 0) goto error;\n\t\t  \n   /* Refine the curve.  */\n\t\t  \n   s1018(pc,spar2,knpar,&qc,&kstat);\n   if (kstat < 0) goto error;\n\t\t  \n   /* Traverse Bezier segments and test if linearization is ok, i.e.\n      the distance between inner vertices and the line segment between\n      the first and last vertex, is less than aepsge.       */\n\t\t  \n   for (sta=qc->ecoef, ki=0; ki<=idiv; sta=stb+kdim, ki++)\n   {\n      for (stb=sta+(kord-1)*kdim, s1=sta+kdim; s1<stb; s1+=kdim)\n      {\n\t if (s6dline(sta,stb,s1,kdim,&kstat) > aepsge) break;\n\t if (kstat < 0) goto error;\n      }\n      if (kstat < 0) goto error;\n\t\t     \n      if (s1 < stb)\n      {\n\t /* Precision in linearization not good enough. Divide the\n\t    Bezier segment and try again. First express the Bezier\n\t    segment as a curve.   */\n\t \n\t if ((qbez = newCurve(kord,kord,qc->et+ki*kord,sta,kbez,kdim,0))\n\t     == SISL_NULL) goto err101;\n\t \n\t /* Linearize.  */\n\t \n\t s1613bez(qbez,kdiv,aepsge,&sparout,&kparout,&kstat);\n\t if (kstat < 0) goto error;\n\t \n\t if (kstat == 2)\n\t {\n\t    /* Return to top level.  */\n\t    \n\t    if (spar != SISL_NULL) freearray(spar);\n\t    if (qbez != SISL_NULL) freeCurve(qbez);\n\t    \n\t    *jstat = kstat;\n\t    goto out;\n\t }\n\t \n\t /* Take union of parameter values.    */\n\t \n\t s6takeunion(spar,knparts,sparout,kparout,&sparunion,&knunion,&kstat);\n\t if (kstat < 0) goto error;\n\t \n\t freearray(spar);\n\t spar = sparunion;\n\t sparunion = SISL_NULL;\n\t knparts = knunion;\n\t \n\t if (sparout != SISL_NULL) freearray(sparout);\n\t sparout = SISL_NULL;\n\t \n\t freeCurve(qbez);\n\t qbez = SISL_NULL;\n      }\n   }\n   \n   /* Return parameter values.  */\n   \n   *gpar = spar;\n   *jnpar = knparts;\n   \n   *jstat = 0;\n   goto out;\n   \n   /* Error in scratch allocation.  */\n   \n   err101 :\n      *jstat = -101;\n   goto out;\n   \n   /* Error. The curve is not of Bezier type.  */\n   \n   err111 :\n      *jstat = -111;\n   goto out;\n      \n   /* Error in lower order routine.  */\n   \n   error :\n      *jstat = kstat;\n   goto out;\n   \n   out:\n      /* Reduce level parameter.  */\n      \n      klevel--;\n   \n      /* Free scratch used for local arrays.  */\n      \n      if (spar2 != SISL_NULL) freearray(spar2);\n      if (qc != SISL_NULL) freeCurve(qc);\n\t\t      \n      return;\n}\n     \n"
  },
  {
    "path": "src/s1614.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1614.c,v 1.2 1994-12-07 12:05:37 pfu Exp $\n *\n */\n\n\n#define S1614\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1614(double epoint[], int inbpnt, int idim, int eptyp[],\n\t   double spoint[], int *jnbpnt, int sptyp[], int *jstat)\n\n#else\nvoid s1614(epoint, inbpnt, idim, eptyp,spoint, jnbpnt, sptyp, jstat)\n     double epoint[];\n     int    inbpnt;\n     int    idim;\n     int    eptyp[];\n     double spoint[];\n     int    *jnbpnt;\n     int    sptyp[];\n     int    *jstat;\n#endif\n/*\n*************************************************************************\n*\n* PURPOSE: To check the point description vector to ensure that the\n*          points returned from this routine can be used directly in the\n*          conversion of conics to B-spline representation.\n*\n* INPUT:\n*        Epoint - The points/tangents describing the conic.\n*        Inbpnt - No. of points/tangents in the epoint array.\n*        Idim   - The dimension of the space in which the points lie.\n*        Eptyp  - Type indicator for points/tangents :\n*                  1 - Ordinary point.\n*                  2 - Knuckle point. (Is treated as an ordinary point.)\n*                  3 - Tangent to next point.\n*                  4 - Tangent to prior point.\n*\n* Output:\n\n*        Spoint - The corrected points.\n*        Jnbpnt - No. of corrected points.\n*        Sptyp  - Type indicator for corrected points.\n*        Jstat  - status messages:\n*                  < 0 : Error.\n*                  = 0 : Ok.\n*                  > 0 : Warning.\n*\n* Method:\n* \tThe point description is run through, to check if some points are\n*\t assigned two tangents. If two tangents are detected, the first is\n* \tused and the second discarded. In addition, the first points\n* \tinterpolation-condition detected is put in the start of the output\n* \tarray, and the last points interpolation-condition is put in the end\n* \tof the output array.\n*-\n* Calls: s6err.\n*\n* Written by: A.M. Ytrehus, SI  Oslo Oct.91.\n* After FORTRAN (P1614) written by: T. Dokken  SI.\n* Revised by: J. Kaasa, SI, Aug. 92 (Fixed bugs in connection with\n*             type handling).\n*****************************************************************\n*/\n{\n  int ki, kp, kk, kki;\n  int khelp;\n  int ktell = 0;\n  int kflag = 0;\n  int knbpnt = 0;\n  int ktyp = 1;\n  int ktypm1;\n  double tdum;\n  int kpos = 0;\n\n  *jstat = 0;\n\n\n  /* Run through and test the type of the data points. Copy\n     approved points and tangents into output variables. */\n\n  for (ki = 0; ki < inbpnt; ki++)\n    {\n      ktypm1 = ktyp;\n      ktyp = eptyp[ki];\n\n      if (!((ktyp < 1 || ktyp > 4) ||\n\t    (knbpnt == 0 && ktyp == 4) ||\n\t    (ktyp == 3 && ktypm1 == 3) ||\n\t    (ktyp == 4 && ktypm1 == 4) ||\n\t    (ktyp == 4 && ktypm1 == 3)))\n\t{\n\t  /* Save this point or tangent in spoint and sptyp. */\n\n\t  sptyp[knbpnt] = ktyp;\n\n\t  kki = idim * ki;\n\t  kk = idim * knbpnt;\n\n\t  for (kp = 0; kp < idim; kp++)\n\t    spoint[kk + kp] = epoint[kki + kp];\n\t  knbpnt++;\n\t}\n    }\n\n  /* Remove last point if the type is 3 (which means tangent to next point. */\n\n  if (ktyp == 3)\n    knbpnt--;\n\n\n  /* We cannot make use of more than five points.\n     Choose the first five points. */\n\n  if (knbpnt > 5)\n    {\n      knbpnt = 5;\n\n      /* Check the type of (new) last point. */\n\n      if (sptyp[knbpnt - 1] == 3)\n\t{\n\t  /* Cut out this point, and use point no. 6 instead. */\n\n\t  sptyp[knbpnt - 1] = sptyp[knbpnt];\n\n\t  kk = idim * (knbpnt - 1);\n\n\t  for (kp = 0; kp < idim; kp++)\n\t    spoint[kk + kp] = spoint[kk + idim + kp];\n\t}\n    }\n\n\n  /* Ensure that first entry is a point. */\n\n  ktyp = sptyp[0];\n\n  if (ktyp > 2)\n    {\n      /* Interchange the two first conditions. */\n\n      kflag = 1;\n\n      sptyp[0] = 1;\n      sptyp[1] = 4;\n\n      for (kp = 0; kp < idim; kp++)\n\t{\n\t  tdum = spoint[kp];\n\t  spoint[kp] = spoint[kp + idim];\n\t  spoint[kp + idim] = tdum;\n\t}\n    }\n\n  /* Ensure that last entry is a point. */\n\n  ktyp = sptyp[knbpnt - 1];\n\n  if (ktyp > 2)\n    {\n\n      /* Interchange the two last conditions. */\n\n      kflag = 1;\n\n      sptyp[knbpnt - 1] = 1;\n      sptyp[knbpnt - 2] = 3;\n\n      kk = idim * (knbpnt - 1);\n\n      for (kp = 0; kp < idim; kp++)\n\t{\n\t  tdum = spoint[kk + kp];\n\t  spoint[kk + kp] = spoint[kk - idim + kp];\n\t  spoint[kk - idim + kp] = tdum;\n\t}\n    }\n\n  /* Count no. of points. If less than two, we cannot even\n     create a straight line. */\n\n  for (ki = 0; ki < knbpnt; ki++)\n    {\n      ktyp = sptyp[ki];\n      if (ktyp < 3)\n\tktell++;\n    }\n\n  if (ktell <= 1)\n    goto err181;\n\n\n  /* Run through and remove double tangents that may be introduced by\n     the interchange of end-point/end-tangents. */\n\n  ktyp = 1;\n\n  if (kflag == 1)\n    {\n      khelp = knbpnt;\n\n      ktypm1 = ktyp;\n\n      for (ki = 0; ki < khelp; ki++)\n\t{\n\t  ktyp = sptyp[ki];\n\n\t  if ((ktyp == 3 && ktypm1 == 3) ||\n\t      (ktyp == 4 && ktypm1 == 4) ||\n\t      (ktyp == 4 && ktypm1 == 3))\n\t    {\n\t      /* Remove last of doble tangent. */\n\n\t      knbpnt--;\n\n\t      for (kk = ki; kk < knbpnt; kk++)\n\t\t{\n\t\t  sptyp[kk] = sptyp[kk + 1];\n\n\t\t  kki = idim * kk;\n\n\t\t  for (kp = 0; kp < idim; kp++)\n\t\t    spoint[kki + kp] = spoint[kki + idim + kp];\n\t\t}\n\t    }\n\t}\n    }\n\n\n  *jnbpnt = knbpnt;\n\n  goto out;\n\n\n  /* Error in input, less than two points given in problem formulation. */\n\nerr181:\n  *jstat = -181;\n  s6err (\"s1614\", *jstat, kpos);\n  goto out;\n\nout:\n\n  return;\n}\n"
  },
  {
    "path": "src/s1615.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1615.c,v 1.2 2001-03-19 15:58:52 afr Exp $\n *\n */\n\n\n#define S1615\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1615(double epoint[], int inbpnt, int idim, int eptyp[],int *jstat)\n#else\nvoid s1615(epoint, inbpnt, idim, eptyp, jstat)\n     double epoint[];\n     int    inbpnt;\n     int    idim;\n     int    eptyp[];\n     int    *jstat;\n#endif\n/*\n*************************************************************************\n*\n* PURPOSE: To test if the points lie on two branches of a hyperbola\n*\n* INPUT:\n*        Epoint - Points/tangents describing the conic.\n*        Inbpnt - No. of points/tangents in the epoint array.\n*        Idim   - The dimension of the space in which the points lie.\n*        Eptyp  - Type indicator for points/tangents :\n*                  1 - Ordinary point.\n*                  2 - Knuckle point. (Is treated as an ordinary point.)\n*                  3 - Tangent to next point.\n*                  4 - Tangent to prior point.\n*\n* Output:\n*        Jstat - status messages:\n*                  < 0 : Error.\n*                  = 0 : Ok.\n*                  > 0 : Warning.\n*\n* Method:\n* \tIf 3D points, the subroutine assumes that the third coordinate\n* \tis zero, and that the first entry in Epoint is a point.\n*\t Derivative vectors and vectors between the points are extracted\n*\t and put into a temporary array. Then the cross product between\n* \tadjacent ones of these are calculated. If both positive and negative\n* \tcross products are found, the points lie on different branches\n*\tof a hyperbola.\n*-\n* Calls: s6err.\n*\n* Written by: A.M. Ytrehus, SI Oslo, Oct.91.\n* After FORTRAN, (P1615), written by: T. Dokken  SI.\n*****************************************************************\n*/\n{\n  double svector[8];\n  double *spoint = SISL_NULL;\n  int ki, kk, kp, kki;\n  int ktyp;\n  double tcross;\n  int kant = 4;\n  int kpluss = 0;\n  int kneg = 0;\n  int kdim = 2;\n  int kstore = 0;\n  int kpos = 0;\n\n  *jstat = 0;\n\n\n  /* Allocate local array. */\n\n  spoint = newarray (kdim * inbpnt, DOUBLE);\n  if (spoint == SISL_NULL)\n    goto err101;\n\n\n  /* Kant is the no. of segments between the points (that is inbpnt-1).\n     We can have max. 5 points. */\n\n  if (inbpnt < 5)\n    kant = inbpnt - 1;\n\n\n  /* If the no. of segments is two or less, the points cannot\n     belong to two different conic branches. (Ok, go out). */\n\n  if (kant < 3)\n    goto out;\n\n\n  /* Store the positions of points and tangents (next/prior point\n     minus/plus tangent/vector) in the working array spoit. */\n\n\n  for (ki = 0; ki < inbpnt; ki++)\n    {\n      ktyp = eptyp[ki];\n      kki = idim * ki;\n\n      if (ktyp == 1 || ktyp == 2)\n\t{\n\t  /* Store this point directly. */\n\n\t  kk = kdim * kstore;\n\n\t  for (kp = 0; kp < kdim; kp++)\n\t    spoint[kk + kp] = epoint[kki + kp];\n\n\t  kstore++;\n\t}\n      else if (ktyp == 3)\n\t{\n\t  /* Tangent to next point. Store the coordinates of\n\t     next point minus this one. */\n\n\t  kk = kdim * kstore;\n\n\t  for (kp = 0; kp < kdim; kp++)\n\t    spoint[kk + kp] = epoint[kki + idim + kp] - epoint[kki + kp];\n\n\t  kstore++;\n\n\t}\n      else if (ktyp == 4)\n\t{\n\t  /* Tangent to prior point. Store the coordinates of\n\t     last point plus this one. */\n\n\t  kk = kdim * kstore;\n\n\t  for (kp = 0; kp < kdim; kp++)\n\t    spoint[kk + kp] = epoint[kki - idim + kp] + epoint[kki + kp];\n\n\t  kstore++;\n\t}\n    }\n\n\n  /* Run through the points/derivatives and put difference\n     vectors into the svector-array. */\n\n\n  kstore = 0;\n\n  for (ki = 1; ki < inbpnt; ki++)\n    {\n      kk = kdim * kstore;\n      kki = kdim * ki;\n\n      for (kp = 0; kp < kdim; kp++)\n\tsvector[kk + kp] = spoint[kki + kp] - spoint[kki - kdim + kp];\n\n      kstore++;\n    }\n\n\n  /* If the cross product of adjacent vectors all have the same\n     direction, then the points all lie on the same conic branch. */\n\n  for (ki = 0; ki < kant - 1; ki++)\n    {\n      kk = kdim * ki;\n\n      tcross = svector[kk] * svector[kk + 3]\n\t- svector[kk + 1] * svector[kk + 2];\n\n      if (tcross > 0)\n\tkpluss++;\n      if (tcross < 0)\n\tkneg++;\n    }\n\n  /* If both kpluss and kneg are nonzero, then the points\n     lie on different branches. */\n\n  if (kpluss > 0 && kneg > 0)\n    *jstat = 1;\n\n  goto out;\n\n  /* Allocation error. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1615\", *jstat, kpos);\n  goto out;\n\nout:\n\n  /* Free local arrays. */\n\n  if (spoint != SISL_NULL)\n    freearray (spoint);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1616.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1616.c,v 1.2 2001-03-19 15:58:52 afr Exp $\n *\n */\n\n\n#define S1616\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1616(double epoint[], int inbpnt, int idim, int eptyp[],\n\t   double econic[], int *jstat)\n#else\nvoid s1616(epoint, inbpnt, idim, eptyp, econic, jstat)\n     double epoint[];\n     int    inbpnt;\n     int    idim;\n     int    eptyp[];\n     double econic[];\n     int    *jstat;\n#endif\n/*\n*************************************************************************\n*\n* PURPOSE: To find if the conic equation of the points in the array\n*          epoint. The first and last points must be of type 1 or 2. The\n*          intermediate points can be points or tangents, but no tangents\n*          can be doubly defined. The routine s1614 should be run before this\n*          routine to ensure that the description of the points/tangents in the\n*          eptyp array are ok.\n*\n* INPUT:\n*        Epoint - The points/tangents describing the conic.\n*        Inbpnt - No. of points/tangents in the epoint array.\n*        Idim   - The dimension of the space in which the points lie.\n*        Eptyp  - Type indicator for the points/tangents :\n*                  1 - Ordinary point.\n*                  2 - Knuckle point. (Is treated as an ordinary point.)\n*                  3 - Tangent to next point.\n*                  4 - Tangent to prior point.\n*\n* Output:\n*        Econic - The conic coefficients of the points in Epoint.\n*        Jstat  - status messages:\n*                  < 0 : Error.\n*                  = 0 : Ok.\n*                  > 0 : Warning.\n*\n* Method:\n*\t If Inbpnt is 3, a circle is produced.\n* \t If Inbpnt is 4, a conic with the coeficient of x*y equal to\n* \t zero is produced.\n* \t If Inbpnt is 5, a general conic is produced.\n* \t The coeficients econic have the following meaning:\n*\t econic(0)*x*x + 2*econic(1)*x*y + econic(2)*y*y +\n* \t econic(3)*x + 2*econic(4)*y + econic(5) = 0.0.\n*-\n* Calls: s6lufacp, s6lusolp, s1618, s6err.\n*\n* Written by: A.M. Ytrehus, SI Oslo Oct.91.\n* After FORTRAN, (P10634), written by: T. Dokken  SI.\n* Revised by: J. Kaasa, SI, Aug. 1992 (Transposed smatrix and fixed the\n*                         handling of singular matrix equations.)\n* Revised by: J. Kaasa, SI, Aug. 1992 (Changed status 9005 to 105).\n*****************************************************************\n*/\n{\n  int ki, kj, kk;\n  int kdim;\n  int kn;\n  double tmax = (double) HUGE;\n  int kperm = 0;\n  int ktyp;\n  int kdir;\n  double *smatrix = SISL_NULL;\n  double *save = SISL_NULL;\n  double *sright = SISL_NULL;\n  double tx, ty, tdx, tdy;\n  int *npiv = SISL_NULL;\n  double solu[6];\n  double tdiff;\n  double tdum;\n  int kpos = 0;\n  int kstat = 0;\n\n  *jstat = 0;\n\n\n  /* Allocate local arrays. */\n\n  smatrix = newarray (inbpnt * inbpnt, DOUBLE);\n  if (smatrix == SISL_NULL)\n    goto err101;\n\n  sright = newarray (inbpnt, DOUBLE);\n  if (sright == SISL_NULL)\n    goto err101;\n\n  save = newarray (inbpnt * inbpnt, DOUBLE);\n  if (save == SISL_NULL)\n    goto err101;\n\n  npiv = newarray (inbpnt, INT);\n  if (npiv == SISL_NULL)\n    goto error;\n\n  kn = inbpnt + 1;\n  kdim = inbpnt * inbpnt;\n\n\n  /* Build interpolation matrix to find the coeficients of the conic. */\n\n  if (inbpnt == 3)\n    {\n\n      /* A circle is to be produced. We put econic(0) = econic(2) = 1.0,\n\t and econic(1) = 0.0. (This is not done now but later.) */\n\n      for (ki = 0; ki < inbpnt; ki++)\n\t{\n\t  kk = idim * ki;\n\t  ktyp = eptyp[ki];\n\n\t  if (ktyp < 3)\n\t    {\n\t      tx = epoint[kk];\n\t      ty = epoint[kk + 1];\n\n\t      smatrix[inbpnt*ki] = ((double) 2.0) * tx;\n\t      smatrix[inbpnt*ki + 1] = ((double) 2.0) * ty;\n\t      smatrix[inbpnt*ki + 2] = (double) 1.0;\n\t      sright[ki] = -(tx * tx + ty * ty);\n\t    }\n\t  else if (ktyp > 2)\n\t    {\n\n\t      /* Derivative condition. */\n\n\t      kdir = 1;\n\t      if (ktyp == 4)\n\t\tkdir = -1;\n\n\t      tx = epoint[kk + idim * kdir];\n\t      ty = epoint[kk + idim * kdir + 1];\n\t      tdx = epoint[kk];\n\t      tdy = epoint[kk + 1];\n\n\t      smatrix[inbpnt*ki] = ((double) 2.0) * tdx;\n\t      smatrix[inbpnt*ki + 1] = ((double) 2.0) * tdy;\n\t      smatrix[inbpnt*ki + 2] = (double) 0.0;\n\t      sright[ki] = -tdx * tx * ((double) 2.0) - tdy * ty * ((double) 2.0);\n\t    }\n\t}\n    }\n  else if (inbpnt == 4)\n    {\n      /* A conic with xy term equal to zero is to be produced.\n         We put econic(1) = 0.0. (This is not done now but later.) */\n\n      for (ki = 0; ki < inbpnt; ki++)\n\t{\n\t  kk = idim * ki;\n\t  ktyp = eptyp[ki];\n\t  if (ktyp < 3)\n\t    {\n\t      tx = epoint[kk];\n\t      ty = epoint[kk + 1];\n\n\t      smatrix[inbpnt*ki] = tx * tx;\n\t      smatrix[inbpnt*ki + 1] = ty * ty;\n\t      smatrix[inbpnt*ki + 2] = ((double) 2.0) * tx;\n\t      smatrix[inbpnt*ki + 3] = ((double) 2.0) * ty;\n\t      sright[ki] = -(double) 1.0;\n\t    }\n\t  else if (ktyp > 2)\n\t    {\n\n\t      /* Derivative condition. */\n\n\t      kdir = 1;\n\t      if (ktyp == 4)\n\t\tkdir = -1;\n\n\t      tx = epoint[kk + idim * kdir];\n\t      ty = epoint[kk + idim * kdir + 1];\n\t      tdx = epoint[kk];\n\t      tdy = epoint[kk + 1];\n\n\t      smatrix[inbpnt*ki] = ((double) 2.0) * tdx * tx;\n\t      smatrix[inbpnt*ki + 1] = ((double) 2.0) * tdy * ty;\n\t      smatrix[inbpnt*ki + 2] = ((double) 2.0) * tdx;\n\t      smatrix[inbpnt*ki + 3] = ((double) 2.0) * tdy;\n\t      sright[ki] = (double) 0.0;\n\t    }\n\t}\n    }\n  else if (inbpnt == 5)\n    {\n\n      /* A general conic is to be produced. */\n\n      for (ki = 0; ki < inbpnt; ki++)\n\t{\n\t  kk = idim * ki;\n\t  ktyp = eptyp[ki];\n\t  if (ktyp < 3)\n\t    {\n\t      tx = epoint[kk];\n\t      ty = epoint[kk + 1];\n\n\t      smatrix[inbpnt*ki] = tx * tx;\n\t      smatrix[inbpnt*ki + 1] = ((double) 2.0) * tx * ty;\n\t      smatrix[inbpnt*ki + 2] = ty * ty;\n\t      smatrix[inbpnt*ki + 3] = ((double) 2.0) * tx;\n\t      smatrix[inbpnt*ki + 4] = ((double) 2.0) * ty;\n\t      sright[ki] = -(double) 1.0;\n\t    }\n\t  else if (ktyp > 2)\n\t    {\n\n\t      /* Derivative condition. */\n\n\t      kdir = 1;\n\t      if (ktyp == 4)\n\t\tkdir = -1;\n\n\t      tx = epoint[kk + idim * kdir];\n\t      ty = epoint[kk + idim * kdir + 1];\n\t      tdx = epoint[kk];\n\t      tdy = epoint[kk + 1];\n\n\t      smatrix[inbpnt*ki] = ((double) 2.0) * tdx * tx;\n\t      smatrix[inbpnt*ki + 1] = ((double) 2.0) * tdy * tx + ((double) 2.0) * tdx * ty;\n\t      smatrix[inbpnt*ki + 2] = ((double) 2.0) * tdy * ty;\n\t      smatrix[inbpnt*ki + 3] = ((double) 2.0) * tdx;\n\t      smatrix[inbpnt*ki + 4] = ((double) 2.0) * tdy;\n\t      sright[ki] = (double) 0.0;\n\t    }\n\t}\n    }\n\n  /* Solve the equation system. If the system is not solvable, interchange\n     the r.h.side with one of the colomns on the l.h. side. */\n\n  for (ki = 0; ki < kn; ki++)\n    {\n      /* Remember interpolation matrix. */\n\n      for (kj = 0; kj < kdim; kj++)\n\tsave[kj] = smatrix[kj];\n\n\n      /* Find solution.\n\t s6lusolp put the soltion into the r.h. side array given as input,\n\t thus store the right hand side in econic. */\n\n      for (kj = 0; kj < inbpnt; kj++)\n\teconic[kj] = sright[kj];\n\n      s6lufacp (smatrix, npiv, inbpnt, &kstat);\n\n      if (kstat >= 0 && kstat != 1)\n        s6lusolp (smatrix, econic, npiv, inbpnt, &kstat);\n      kstat = 0;\n\n      /* If we are here, we have been able to find a solution, econic.\n\t Test this. First, restore smatrix and sright. */\n\n      for (kj = 0; kj < kdim; kj++)\n\tsmatrix[kj] = save[kj];\n\n      s1618 (smatrix, sright, econic, inbpnt, &tdiff);\n\n      if (tdiff < tmax)\n\t{\n\t  /* If we are here, we have found the best solution until now. */\n\n\t  tmax = tdiff;\n\t  kperm = ki;\n\n\t  for (kj = 0; kj < inbpnt; kj++)\n\t    solu[kj] = econic[kj];\n\t  \n          if (inbpnt == 3) break;\n\t}\n\t\n      if (ki < (kn - 1))\n\t{\n\t  /* Change the right hand side with one column of the matrix. */\n\n\t  for (kj = 0; kj < inbpnt; kj++)\n\t    {\n\t      kk = inbpnt * kj;\n\t      tdum = -sright[kj];\n\t      sright[kj] = -smatrix[kk + ki];\n\t      smatrix[kk + ki] = tdum;\n\t    }\n\t}\n    }\n\n  /* If no solution found, make straight line. */\n\n  if (tmax > 0.0001)\n    {\n      *jstat = 105;\n      econic[0] = 0.;\n      econic[1] = 0.;\n      econic[2] = 0.;\n      econic[3] = (epoint[1] - epoint[2*inbpnt - 1])/2.;\n      econic[4] = (epoint[2*inbpnt - 2] - epoint[0])/2.;\n      econic[5] = epoint[0]*epoint[2*inbpnt - 1] - \n\t epoint[1]*epoint[2*inbpnt - 2];\n      goto out;\n    }\n\n  /* Get the remembered best solution. */\n\n  for (kj = 0; kj < inbpnt; kj++)\n    econic[kj] = solu[kj];\n\n  econic[inbpnt] = (double) 1.0;\n\n\n  /* If the order of the colomns were changed, substitute back again. */\n\n  if (kperm != 0)\n    {\n      for (ki = 1; ki <= kperm; ki++)\n\t{\n\t  kj = kperm - ki;\n\t  tdum = econic[kj];\n\t  econic[kj] = econic[inbpnt];\n\t  econic[inbpnt] = tdum;\n\t}\n    }\n\n  /* Expand to full conic description when Inbpnt is less than 5. */\n\n  if (inbpnt == 3)\n    {\n      /* Circle. Only x, y and constant coeff. calculated. */\n\n      for (ki = 0; ki < inbpnt; ki++)\n\teconic[ki + inbpnt] = econic[ki];\n\n      econic[0] = (double) 1.0;\n      econic[1] = (double) 0.0;\n      econic[2] = (double) 1.0;\n    }\n  else if (inbpnt == 4)\n    {\n      /* Conic with xy constant zero. */\n\n      for (ki = 5; ki > 1; ki--)\n\teconic[ki] = econic[ki - 1];\n\n      econic[1] = (double) 0.0;\n    }\n\n  goto out;\n\n  /* Error in allocation. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1616\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine. */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1616\", *jstat, kpos);\n  goto out;\n\nout:\n\n  /* Free arrays. */\n\n  if (smatrix != SISL_NULL)\n    freearray (smatrix);\n  if (save != SISL_NULL)\n    freearray (save);\n  if (sright != SISL_NULL)\n    freearray (sright);\n  if (npiv != SISL_NULL)\n    freearray (npiv);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1617.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1617.c,v 1.2 2001-03-19 15:58:52 afr Exp $\n *\n */\n\n\n#define S1617\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1617(double epoint[], int inbpnt, int idim, int eptyp[],\n\t   double aepsge, double econic[],\n\t   double estart[], double etang[], double estop[],\n\t   double *ashape, int *jstat)\n#else\nvoid s1617(epoint, inbpnt, idim, eptyp, aepsge, econic,\n\t   estart, etang, estop, ashape, jstat)\n     double epoint[];\n     int    inbpnt;\n     int    idim;\n     int    eptyp[];\n     double aepsge;\n     double econic[];\n     double estart[];\n     double etang[];\n     double estop[];\n     double *ashape;\n     int    *jstat;\n#endif\n/*\n*************************************************************************\n*\n* PURPOSE: To produce interpolation conditions to interpolate the\n*          conic curve described by Epoint, Eptyp and Econic.\n*\n* INPUT:\n*        Epoint - The points/tangents describing the conic.\n*        Inbpnt - No. of points/tangents in the epoint array.\n*        Idim   - The dimension of the space in which the points lie.\n*        Eptyp  - Type indicator for the points/tangents :\n*                  1 - Ordinary point.\n*                  2 - Knuckle point. (Is treated as an ordinary point.)\n*                  3 - Tangent to next point.\n*                  4 - Tangent to prior point.\n*        Aepsge - The geometry reolution.\n*        Econic - The conic coefficients of the points in the Epoint array.\n*\n* Output:\n*        Estart - Start-point of conic segment.\n*        Etang  - Intersection point of tangents from start- and endpoint.\n*        Estop   - End-point of conic segment.\n*        Ashape - Shape factor.\n*        Jstat  - Status variable.\n*\n* Method:\n* \tThe conics are classified into ellipses, parabolas and hyperbolas.\n* \tThe description of the arc by the output type of parameters is produced.\n*-\n* Calls: s1619,s6err.\n*\n* Written by: A.M. Ytrehus, si Oslo, Oct.91.\n* After FORTRAN, (P1617), written by: T. Dokken  SI.\n*****************************************************************\n*/\n{\n  int kk, kp;\n  double ta11, ta12, ta13, ta22, ta23, ta33;\n  double td13, td23, td33, tda;\n  double tshape;\n  int ktyp;\n  int kstat = 0;\n  int kpos = 0;\n\n  *jstat = 0;\n\n\n  /* Initiate variables. */\n\n  ta11 = econic[0];\n  ta12 = econic[1];\n  ta13 = econic[3];\t\t/* ? */\n  ta22 = econic[2];\t\t/* ? */\n  ta23 = econic[4];\n  ta33 = econic[5];\n\n\n  /* Calculate determinants. */\n\n  td13 = ta12 * ta23 - ta22 * ta13;\n  td23 = ta11 * ta23 - ta12 * ta13;\n  td33 = ta11 * ta22 - ta12 * ta12;\n  tda = ta13 * td13 - ta23 * td23 + ta33 * td33;\n\n\n  /* Discussion of the conic. */\n\n  if (DEQUAL(tda + (double) 1.0, (double) 1.0))\n    {\n      /* Degenerate conic. Produce straight line. */\n\n      *jstat = 1;\n      goto out;\n    }\n\n  /* Decide if ellipse, parabola or hyperbola. */\n\n  if (td33 > (double) 0.0)\n    {\n      /* Ellipse, decide if imaginary or real. */\n\n      if (tda * ta11 > (double) 0.0)\n\t{\n\t  /* Imaginary ellipse. Produce straight line. */\n\n\t  *jstat = 1;\n\t  goto out;\n\t}\n      else\n\t{\n\t  /* Real eelipse. */\n\n\t  ktyp = 2;\n\t}\n    }\n  else\n    {\n      /* Parabola or hyperbola. */\n\n      if (td33 < (double) 0.0)\n\t{\n\t  /* Hyperbola. */\n\n\t  ktyp = 4;\n\t}\n      else\n\t{\n\t  /* Parabola. */\n\n\t  ktyp = 3;\n\t}\n    }\n\n\n  /* Find rational description of conic. */\n\n  s1619 (epoint, inbpnt, idim, eptyp, econic, ktyp,\n\t etang, &tshape, &kstat);\n  if (kstat < 0)\n    goto error;\n  if (kstat == 1)\n    {\n      /* Create straight line. */\n\n      *jstat = 1;\n      goto out;\n    }\n\n  kk = idim * (inbpnt - 1);\n\n  for (kp = 0; kp < idim; kp++)\n    {\n      estart[kp] = epoint[kp];\n      estop[kp] = epoint[kk + kp];\n    }\n\n  *ashape = tshape;\n\n  goto out;\n\n\n  /* Error in lower level routine. */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1617\", *jstat, kpos);\n  goto out;\n\nout:\n\n  return;\n}\n"
  },
  {
    "path": "src/s1618.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1618.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1618\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1618(double ematrix[], double eright[], double esol[], int in,\n\t   double *adiff)\n#else\nvoid s1618(ematrix, eright, esol, in, adiff)\n     double ematrix[];\n     double eright[];\n     double esol[];\n     int    in;\n     double *adiff;\n#endif\n/*\n*************************************************************************\n*\n* PURPOSE: To test the result of the solution of an equation system.\n*\n* INPUT:\n*        Ematrix - The interpolation matrix. (length in*in.)\n*        Eright  - The right hand side of the equation system.\n*                  (length in.)\n*        Esol    - The solutiuon of the equation system. (length in.)\n*        In      - The dimension of the equation system.\n*\n* OUTPUT:\n*        Adiff   - The maximal difference between left and right hand side.\n*\n* METHOD:\n*        The product of the matrix and the solution is calculated\n*        and subtracted from the right hand side.\n*-\n* Calls: No.\n*\n* Written by: A.M. Ytrehus, SI Oslo Oct.91.\n* After FORTRAN (P1618), written by: T. Dokken  SI.\n*****************************************************************\n*/\n{\n  int ki, kj;\n  int kdim;\n  double tdiff, tdum;\n  double tmax = (double) 0.0;\n  double tmxel = (double) 0.0;\n\n\n  /* Find greatest element of matrix. */\n\n  kdim = in *in;\n\n  for (ki = 0; ki < kdim; ki++)\n    {\n      tdum = fabs (ematrix[ki]);\n      if (tdum > tmxel)\n\ttmxel = tdum;\n    }\n  if (tmxel == (double) 0.0)\n    tmxel = (double) 1.0;\n\n\n  /* Calculate product of matrix and solution, and\n     subract from r.h.side. */\n\n  for (ki = 0; ki < in; ki++)\n    {\n      tdum = (double) 0.0;\n\n      for (kj = 0; kj < in; kj++)\n\ttdum += ematrix[ki * in +kj] *esol[kj];\n\n      tdiff = tdum - eright[ki];\n\n      tdum = fabs (tdiff) / tmxel;\n      if (tdum > tmax)\n\ttmax = tdum;\n    }\n\n  *adiff = tmax;\n\n  return;\n}\n"
  },
  {
    "path": "src/s1619.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1619.c,v 1.2 1995-01-26 08:44:48 pfu Exp $\n *\n */\n\n\n#define S1619\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1619(double epoint[], int inbpnt, int idim, int eptyp[],\n\t   double econic[], int ityp, double etang[],\n\t   double *ashape, int *jstat)\n#else\nvoid s1619(epoint, inbpnt, idim, eptyp, econic, ityp,etang, ashape, jstat)\n     double epoint[];\n     int    inbpnt;\n     int    idim;\n     int    eptyp[];\n     double econic[];\n     int    ityp;\n     double etang[];\n     double *ashape;\n     int    *jstat;\n#endif\n/*\n*************************************************************************\n*\n* PURPOSE: To Produce the intersection point of the start- and end-tangent,\n*          the midpoint of the line from the start to the endpoint\n*          and a \"shape factor\".\n* INPUT:\n*        Epoint - The points/tangents describing the conic.\n*        Inbpnt - No. of points/tangents in the epoint array.\n*        Idim   - The dimension of the space in which the points lie.\n*        Eptyp  - Type indicator for the points/tangents :\n*                  1 - Ordinary point.\n*                  2 - Knuckle point. (Is treated as an ordinary point.)\n*                  3 - Tangent to next point.\n*                  4 - Tangent to prior point.\n*        Econic - The conic coefficients of the points in the Epoint array.\n*        Ityp   - Type of conic to be produced.\n*                  1 - Straight line.\n*                  2 - Ellipse.\n*                  3 - Parabola.\n*                  4 - Hyperbola.\n*\n* Output:\n*        Etang   -The intersection point of start and end tangents.\n*        Ashape - Shape factor of the conic.\n*        Jstat  - status variable:\n*                  < 0 : Error.\n*                  = 0 : Ok.\n*                  > 0 : Warning.\n*\n* Method:\n*        The points are calculated using the equation of lines and\n*        the equation of the conic.\n*-\n* Calls: No.\n*\n* Written by: A.M. Ytrehus, si Oslo, Oct.91.\n* After FORTRAN, (P1619), written by: T. Dokken  SI.\n*****************************************************************\n*/\n{\n  double ta11, ta12, ta13, ta22, ta23, ta33;\n  double tx, ty, tx1, ty1, tx2, ty2, axt, ayt;\n  double tv1, tv2, tvx, tvy, tnx, tny, tix, tiy;\n  double ta, tb, tc, te1, te2, te3;\n  double tys1, tys2, txs1, txs2;\n  double as, ts1, ts2;\n  double tlong, tlength;\n  double tdum;\n  int ktyp;\n\n  int ki, kk;\n  int kki = 0;\n\n  int krem = 0;\n  int ksam = 0;\n\n  *jstat = 0;\n\n\n  /* Initiate variables. */\n\n  kk = idim * (inbpnt - 1);\n\n  ta11 = econic[0];\n  ta12 = econic[1];\n  ta13 = econic[3];\t\t/* ? */\n  ta22 = econic[2];\t\t/* ? */\n  ta23 = econic[4];\n  ta33 = econic[5];\n\n  tx = (epoint[0] + epoint[kk]) / ((double) 2.0);\n  ty = (epoint[1] + epoint[kk + 1]) / ((double) 2.0);\n\n\n  /* Calculate tangent vectors in start- and end-point. */\n\n  tx1 = -ta22 * epoint[1] - ta12 * epoint[0] - ta23;\n  ty1 = ta11 * epoint[0] + ta12 * epoint[1] + ta13;\n  tlong = sqrt (tx1 * tx1 + ty1 * ty1);\n  tx1 = tx1 / tlong;\n  ty1 = ty1 / tlong;\n\n  tx2 = -ta22 * epoint[kk + 1] - ta12 * epoint[kk] - ta23;\n  ty2 = ta11 * epoint[kk] + ta12 * epoint[kk + 1] + ta13;\n  tlong = sqrt (tx2 * tx2 + ty2 * ty2);\n  tx2 = tx2 / tlong;\n  ty2 = ty2 / tlong;\n\n\n  /* Calculate intersection point of tangents (axt,ayt). */\n\n  tdum = ty1 * tx2 - ty2 * tx1;\n\n\n  /* Remember if parallel tangents. */\n\n  krem = 0;\n\n  if (fabs (tdum) <= REL_PAR_RES)\n    {\n      /* Parallel tangents. */\n\n      krem = 1;\n      tv1 = tx1;\n      tv2 = ty1;\n    }\n  else\n    {\n      axt = (epoint[0] * ty1 * tx2 - epoint[kk] * ty2 * tx1 +\n\t     tx1 * tx2 * (epoint[kk + 1] - epoint[1])) / tdum;\n      ayt = (ty1 * ty2 * (epoint[0] - epoint[kk]) -\n\t     epoint[1] * tx1 * ty2 + epoint[kk + 1] * tx2 * ty1) / tdum;\n\n\n      /* Calculate the intersection point(s) between the conic\n\t and the line from (axt,ayt) to (tx,ty). */\n\n      tv1 = tx - axt;\n      tv2 = ty - ayt;\n      tlong = sqrt (tv1 * tv1 + tv2 * tv2);\n      tv1 = tv1 / tlong;\n      tv2 = tv2 / tlong;\n    }\n\n  ta = -tv2;\n  tb = tv1;\n  tc = -tx * ta - ty * tb;\n\n  if (fabs (ta) >= fabs (tb))\n    {\n      /* We put the straight line into the equation\n\t of the conic and get: te1*y*y + te2*y + te3 = 0. */\n\n      te1 = ta11 * tb * tb / (ta * ta) - ((double) 2.0) * ta12 * tb / ta + ta22;\n      te2 = ((double) 2.0) * tb * tc * ta11 / (ta * ta) - ((double) 2.0) * ta12 * tc / ta\n\t- ((double) 2.0) * ta13 * tb / ta + ((double) 2.0) * ta23;\n      te3 = ta11 * tc * tc / (ta * ta) - ((double) 2.0) * ta13 * tc / ta + ta33;\n      tdum = te2 * te2 - ((double) 4.0) * te1 * te3;\n\n\n      /* If tdum < 0.0 no intersection point. Produce straight line. */\n\n      if (tdum < 0.0)\n\t{\n\t  /* Produce straight line; */\n\n\t  *jstat = 1;\n\t  goto out;\n\t}\n\n      tdum = sqrt (tdum);\n      tys1 = (-te2 - tdum) / (((double) 2.0) * te1);\n      tys2 = (-te2 + tdum) / (((double) 2.0) * te1);\n      txs1 = -(tb * tys1 + tc) / ta;\n      txs2 = -(tb * tys2 + tc) / ta;\n    }\n  else\n    {\n      /* ta equal to zero. We put the straight line into the conic\n\t equation and get: te1*x*x + te2*x + te3 = 0; */\n\n      te1 = ta11 - ((double) 2.0) * ta12 * ta / tb + ta22 * ta * ta / (tb * tb);\n      te2 = ((double) 2.0) * ta * tc * ta22 / (tb * tb) - ((double) 2.0) * ta12 * tc / tb\n\t- ((double) 2.0) * ta23 * ta / tb + ((double) 2.0) * ta13;\n      te3 = ta22 * tc * tc / (tb * tb) - ((double) 2.0) * ta23 * tc / tb + ta33;\n      tdum = te2 * te2 - ((double) 4.0) * te1 * te3;\n\n\n      /* If tdum < 0.0, no intersection point. Produce straight line. */\n\n      if (tdum < (double) 0.0)\n\t{\n\t  /* Produce straight line. */\n\n\t  *jstat = 1;\n\t  goto out;\n\t}\n\n      tdum = sqrt (tdum);\n      txs1 = (-te2 - tdum) / (((double) 2.0) * te1);\n      txs2 = (-te2 + tdum) / (((double) 2.0) * te1);\n      tys1 = -(ta * txs1 + tc) / tb;\n      tys2 = -(ta * txs2 + tc) / tb;\n    }\n\n  /* Calculate shape factors, and find the shape factor to be used.\n     Special treatment if parallel tangents. */\n\n  if (krem == 1)\n    {\n      /* Parallel tangents. One of the intersection points is to be\n\t used tshape tangent intersection point. We try the first. */\n\n      axt = txs1;\n      ayt = tys1;\n    }\n\n  tlength = (tx - axt) * (tx - axt) + (ty - ayt) * (ty - ayt);\n\n\n  /* If the tangent point and the midpoint\n     are the same, produce straight line. */\n\n  if (tlength < (double) 0.0)\n    {\n      /* Produce straight line. */\n\n      *jstat = 1;\n      goto out;\n    }\n\n\n  ts1 = ((txs1 - tx) * (axt - tx) + (tys1 - ty) * (ayt - ty)) / tlength;\n  ts2 = ((txs2 - tx) * (axt - tx) + (tys2 - ty) * (ayt - ty)) / tlength;\n\n  if (ts1 >= (double) 1.0 && ts2 >= (double) 1.0)\n    {\n      /* Produce straight line. */\n\n      *jstat = 1;\n      goto out;\n    }\n\n  /* Treat parabolas and hyperbolas. */\n\n  if (ityp >= 3)\n    {\n      /* Hyperbola or parabola. */\n\n      as = ts1;\n\n      if (as >= (double) 1.0)\n\tas = ts2;\n\n      if (as >= (double) 1.0)\n\t{\n\t  /* Produce straight line. */\n\n\t  *jstat = 1;\n\t  goto out;\n\t}\n\n      ts1 = as;\n      ts2 = as;\n    }\n\n  /* The variable Ksam is assigned the value 1 if the elliptic arc\n     search is on the same side as the tangent point, else 0.\n     Search for internal point. */\n\n  for (ki = 1; ki < inbpnt - 1; ki++)\n    {\n      ktyp = eptyp[ki];\n      if (ktyp < 3)\n\tbreak;\n    }\n\n  /* If we are here and ktyp < 3, internal point found.\n     Create normal-vector for line from start-point to endpoint. */\n\n  if (ktyp < 3)\n    {\n      /* Internal point. */\n\n      tnx = -epoint[1] + epoint[kk + 1];\n      tny = epoint[0] - epoint[kk];\n\n\n      /* Vector from end-point to internal point. */\n\n      kki = idim * ki;\n      tix = epoint[kki] - epoint[0];\n      tiy = epoint[kki + 1] - epoint[1];\n\n\n      /* Vector from start-point to tangent point. */\n\n      tvx = axt - epoint[0];\n      tvy = ayt - epoint[1];\n\n      ksam = 1;\n      if ((tnx * tix + tny * tiy) * (tnx * tvx + tny * tvy) < (double) 0.0)\n\tksam = 0;\n    }\n  else if (ktyp > 3)\n    {\n      /* No internal points. Look for start-vector. */\n\n      ktyp = eptyp[1];\n\n      if (ktyp == 4)\n\t{\n\t  /* Start-tangent. Vector from start-point to tangent point. */\n\n\t  tvx = axt - epoint[0];\n\t  tvy = ayt - epoint[1];\n\t  ksam = 1;\n\t  if ((epoint[idim] * tvx + epoint[idim + 1] * tvy) < (double) 0.0)\n\t    ksam = 0;\n\t}\n      else\n\t{\n\t  /* No internal point or start-tangent. Look for end-tangent.\n             If no end-tangent, produce a straight line. */\n\n\t  ktyp = eptyp[inbpnt - 2];\n\n\t  if (ktyp != 3)\n\t    {\n\t      /* Produce straight line. */\n\n\t      *jstat = 1;\n\t      goto out;\n\t    }\n\n\t  /* Vector from tangent intersection point to end-point. */\n\n\t  tvx = epoint[kk] - axt;\n\t  tvy = epoint[kk + 1] - ayt;\n\t  ksam = 1;\n\t  if ((epoint[kki - idim] * tvx + epoint[kki - idim + 1] * tvy)\n\t      < (double) 0.0)\n\t    ksam = 0;\n\t}\n    }\n\n  /* Find which branch of the ellipse to use. */\n\n  if (ksam == 1)\n    {\n      /* Special treatment if parallel tangents. We will use\n\t the found tangent intersection point. */\n\n      if (krem == 0)\n\t{\n\n\t  /* Use branch of same side as tangent intersection point.\n\t     Positive shape factor. */\n\n\t  as = ts1;\n\t  if (as < (double) 0.0)\n\t    as = ts2;\n\t  if (as < (double) 0.0)\n\t    {\n\t      /* Create straight line. */\n\n\t      *jstat = 0;\n\t      goto out;\n\t    }\n\t  else\n\t    {\n\t      /* Special treatment if parallel tangents. Use\n\t\t (txs2,tys2) as tangent intersection point. */\n\n\t      if (krem == 1)\n\t\t{\n\t\t  /* Parallel tangents. */\n\n\t\t  axt = txs2;\n\t\t  ayt = tys2;\n\t\t}\n\t      else\n\t\t{\n\t\t  /* use branch on opposite side as tangent intersection\n\t\t     point. Negative shape factor. */\n\n\t\t  as = ts1;\n\t\t  if (as > (double) 0.0)\n\t\t    as = ts2;\n\t\t  if (as > (double) 0.0)\n\t\t    {\n\t\t      /* Create straight line. */\n\n\t\t      *jstat = 1;\n\t\t      goto out;\n\t\t    }\n\t\t}\n\t    }\n\t}\n    }\n\n  /* Shape factor for ellipse found. */\n\n  /* If parallel tangent, subtract the middle of the line from the\n     start-point to the end-point from the tangent-point. */\n\n  if (krem == 1)\n    {\n      axt = axt - (epoint[0] + epoint[kk]) / ((double) 2.0);\n      ayt = ayt - (epoint[1] + epoint[kk + 1]) / ((double) 2.0);\n      as = (double) 0.0;\n    }\n\n  *ashape = as;\n  etang[0] = axt;\n  etang[1] = ayt;\n  if (idim == 3)\n    etang[2] = (double) 0.0;\n\n  goto out;\n\nout:\n\n  return;\n}\n"
  },
  {
    "path": "src/s1620.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1620.c,v 1.3 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n#define S1620\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1620(double epoint[],int inbpnt1, int inbpnt2, int ipar,\n\t   int iopen1, int iopen2, int ik1, int ik2, int idim,\n\t   SISLSurf **rs,int *jstat)\n#else\nvoid s1620(epoint,inbpnt1,inbpnt2,ipar,\n\t   iopen1,iopen2,ik1,ik2,idim,rs,jstat)\n     double epoint[];\n     int inbpnt1;\n     int inbpnt2;\n     int ipar;\n     int iopen1;\n     int iopen2;\n     int ik1;\n     int ik2;\n     int idim;\n     SISLSurf **rs;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate a B-spline surface using the input points as\n*              control vertices. The parametrization is calculated\n*              according to ipar.\n*\n* INPUT      : epoint   - The array containing the points to be used as\n*                         controlling vertices of the B-spline curve.\n*              inbpnt1  - The number of points in first par. direction\n*              inbpnt2  - The number of points in second par. direction\n*              ipar     - Flag showing the desired parametrization to be \n*                         used:\n*                          = 1: Mean accumulated cord-length parameterization.\n*                          = 2: Uniform parametrization.\n*              iopen1   - Open/close condition (Open=1,Close=0,Periodic=-1)\n*              iopen2   - Open/close condition (Open=1,Close=0,Periodic=-1)\n*              ik1      - The order of the surface in first direction.\n*              ik2      - The order of the surface in second direction.\n*              idim     - The dimension of the space\n*\n* OUTPUT     : rs       - Pointer to the surface.\n*              jstat    - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : First the parametrization of the surface is calculated.\n*              If more than ik adjacent vertices are equal then the\n*              superfluous vertices are removed. Then the knots are\n*              calculated.\n*\n* REFERENCES : See 'equivalent routine' for curves: s1620\n*\n*                                                 \n* CALLS      : s1902,s1750,newSurf,s6err\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF OSLO, June 1993.\n* REWISED BY : Vibeke Skytt, SINTEF, 9403. Change in input parameters\n*                                          iopen1 and iopen2.\n*\n*********************************************************************\n*/\n{\n  int kstat;          /* Status variable                                 */\n  int kn1, kn2;       /* The number of B-splines in each directions, \n\t\t\t i.e., the dimension of the spline space \n\t\t\t associated with the knot vector.                */\n  int kk1, kk2;       /* The polynomial orders of the surafce.           */\n  int kpos=0;         /* Position of error                               */\n  int j;              /* Counter for loop control                        */\n  int kopen1, kopen2; /* Local open/closed parameter. Closed,\n\t\t\t non-periodic is treated as an open curve.       */\n  double *par1=SISL_NULL;  /* Pointer to parameterization array in first\n\t\t       * direction. */\n  double *par2=SISL_NULL;  /* Pointer to parameterization array in second\n\t\t       * direction. */\n  double *scoef=SISL_NULL; /* Pointer to vertex array                         */\n  double *knot1=SISL_NULL; /* Pointer to knot vector in first par. direction  */\n  double *knot2=SISL_NULL; /* Pointer to knot vector in second par. direction */\n  SISLSurf *qs=SISL_NULL;\n  \n  /* Set local open/closed parameter. */\n  \n  kopen1 = (iopen1 == SISL_CRV_PERIODIC) ? 0 : 1;\n  kopen2 = (iopen2 == SISL_CRV_PERIODIC) ? 0 : 1;\n  \n  /* Control input     */\n  \n  kk1 = MIN(inbpnt1,ik1);\n  kk2 = MIN(inbpnt2,ik2);\n  if (ik1 < 2 || ik2 < 2) goto err109;\n  if  (iopen1 != SISL_CRV_OPEN && iopen1 != SISL_CRV_CLOSED &&\n       iopen1 != SISL_CRV_PERIODIC) goto err109;\n  if  (iopen2 != SISL_CRV_OPEN && iopen2 != SISL_CRV_CLOSED &&\n       iopen2 != SISL_CRV_PERIODIC) goto err109;\n  \n  /* Generate parametrizations */\n  \n  s1528(idim, inbpnt1, inbpnt2, epoint, ipar, iopen1, iopen2,\n\t&par1, &par2, &kstat);\n  if(kstat < 0) goto error;\n\n  /* Find knot vector in first parameter direction */\n\n  s1902(par1,inbpnt1+(iopen1==SISL_CRV_CLOSED),kk1,kopen1,&knot1,&kstat);\n  if (kstat < 0 || knot1 == SISL_NULL) goto error;\n\n  /* Find knot vector in second parameter direction */\n\n  s1902(par2,inbpnt2+(iopen2==SISL_CRV_CLOSED),kk2,kopen2,&knot2,&kstat);\n  if (kstat < 0 || knot2 == SISL_NULL) goto error;\n  \n  /* Allocate space for vertice array   */\n  \n  scoef = newarray((inbpnt1+kk1-1)*(inbpnt2+kk2-1)*idim,DOUBLE);\n  if (scoef == SISL_NULL) goto err101;\n  \n  /* Check if closed surface in first direction. If closed, add the \n     (ik-1) first points to the vertice array for each j=1..inbpnt2. */\n  \n  if (iopen1 == SISL_CRV_PERIODIC)\n    {\n      kn1 = inbpnt1 + kk1 - 1;\n      for (j=0; j<inbpnt2; j++)\n\t{\n\t  memcopy (&scoef[j*kn1*idim],&epoint[j*inbpnt1*idim],\n\t\t   inbpnt1*idim,DOUBLE);  \n\t  memcopy(&scoef[(j*kn1+inbpnt1)*idim],&epoint[j*inbpnt1*idim],\n\t\t  (kk1-1)*idim,DOUBLE);\n\t}\n    }\n  else if (iopen1 == SISL_CRV_CLOSED)\n  {\n      kn1 = inbpnt1 + 1;\n      for (j=0; j<inbpnt2; j++)\n\t{\n\t  memcopy (&scoef[j*kn1*idim],&epoint[j*inbpnt1*idim],\n\t\t   inbpnt1*idim,DOUBLE);  \n\t  memcopy(&scoef[(j*kn1+inbpnt1)*idim],&epoint[j*inbpnt1*idim],\n\t\t  idim,DOUBLE);\n\t}\n  }\n  else\n    {\n      /* Surface is open in first direction */\n\n      kn1 = inbpnt1;\n      memcopy (scoef,epoint,inbpnt1*inbpnt2*idim,DOUBLE);\n    }\n\n  /* Check if closed surface in second direction. If closed, add the \n     (kk2-1)*kn1 first points to the vertice array. */\n  \n  if (iopen2 == SISL_CRV_PERIODIC)\n    {\n      kn2 = inbpnt2 + kk2 - 1;\n      memcopy(&scoef[inbpnt2*kn1*idim],scoef,\n\t      (kk2-1)*kn1*idim,DOUBLE);\n    }\n  else if (iopen2 == SISL_CRV_CLOSED)\n  {\n     kn2 = inbpnt2 + 1;\n     memcopy(&scoef[inbpnt2*kn1*idim],scoef,\n\t     kn1*idim,DOUBLE);\n  }\n  else\n     \n    /* Surface is open in first direction */\n    \n    kn2 = inbpnt2;\n  \n\n  /* Make surface */\n  \n  qs = newSurf(kn1, kn2, kk1, kk2, knot1, knot2, scoef, 1, idim, 1);\n  if (!qs) goto err101;                \n\n  /* Set peridicity parameters. */\n  \n  qs->cuopen_1 = iopen1;\n  qs->cuopen_2 = iopen2;\n  \n  /* Increase the orders if the orders were lowered when controlling input */\n  \n  if (kk1 < ik1 || kk2 < ik2)\n    {\n      s1387(qs, ik1, ik2, &qs, &kstat);\n      if (kstat< 0) goto error;\n    }\n  \n  if (qs != SISL_NULL) *rs = qs;\n  *jstat = 0;\n  goto out;\n  \n  /* Error in memory allocation */\n  \n  err101: \n    *jstat = -101;\n    s6err(\"s1620\",*jstat,kpos);\n    goto out;\n  \n  /* Error in input, order less than 2 */\n  \n  err109: \n    *jstat = -109;\n    s6err(\"s1620\",*jstat,kpos);\n    goto out;\n  \n  /* Error in lower level function */  \n  \n  error:  \n    *jstat = kstat;\n    s6err(\"s1620\",*jstat,kpos); \n    goto out;\n  \n  out:\n    if (knot1 != SISL_NULL) freearray(knot1);\n    if (knot2 != SISL_NULL) freearray(knot2);\n    if (par1  != SISL_NULL) freearray(par1);\n    if (par2  != SISL_NULL) freearray(par2);\n    if (scoef != SISL_NULL) freearray(scoef);\n    return;\n}    \n\n\n"
  },
  {
    "path": "src/s1630.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1630\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1630(double epoint[],int inbpnt,double astpar,int iopen,int idim,int ik,\n\t   SISLCurve **rc,int *jstat)\n#else\nvoid s1630(epoint,inbpnt,astpar,iopen,idim,ik,rc,jstat)\n\t   double epoint[];\n\t   int    inbpnt;\n\t   double astpar;\n\t   int    iopen;\n\t   int    idim;\n\t   int    ik;\n\t   SISLCurve  **rc;\n\t   int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To calculate a B-spline curve using the input points as\n*              controlling vertices. The distances between the points are\n*              used as parametrization.\n*\n*\n* INPUT      : epoint - The array containing the points to be used as\n*                       controlling vertices of the B-spline curve.\n*              inbpnt - No. of points in epoint.\n*              astpar - Parameter value to be used at the start of the curve.\n*              iopen  - Open/close condition (Open=1,Closed=0,Periodic=-1)\n*              idim   - The dimension of the space\n*              ik     - The order of the B-spline curve to be produced.\n*\n* OUTPUT     : rc     - Pointer to the curve\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : First the parametrization of the curve is calculated.\n*              If more than ik adjacent vertices are equal then the\n*              superfluous vertices are removed. Then the knots are\n*              calculated.\n*\n* EXAMPLE OF USE:\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6dist,s1902,s1713,s1750,newCurve,s6err\n*\n*\n* WRITTEN BY : Qyvind Hjelle, SI, Oslo, Norway. 22. Nov 1988\n* REVISED BY : Bjoern Olav Hoset, SI, Oslo, Norway, Feb. 1992\n*              Calls s1902 instead of fortran functions.\n* REWISED BY: Vibeke Skytt, 03.94. This routine corresponds to s1604,\n*                                  but differ in the use of the parameter\n*                                  iopen.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway. 24/08-1994. Changed\n*              icopy param. (from 0 to 2) to fix memory leak.\n*********************************************************************\n*/\n{\n  int kstat;          /* Status variable                                 */\n  int kn;             /* The number of B-splines, i.e., the dimension of\n\t\t\t the spline space associated with the knot\n\t\t\t vector.                                         */\n  int kk;             /* The polynomial order of the curve.              */\n  int kpos=0;         /* Position of error                               */\n  int ki;             /* Counter for loop control                        */\n  int kopen;          /* Local open/closed parameter. Closed,\n\t\t\t non-periodic is treated as an open curve.       */\n\n  double *spara=SISL_NULL; /* Pointer to parameterization array               */\n  double *scoef=SISL_NULL; /* Pointer to vertex array                         */\n  double *sknot=SISL_NULL; /* Pointer to knot vector                          */\n  double tdist;       /* Distance */\n  double tlastpar;    /* Last value in the parameterization array        */\n  SISLCurve *qc=SISL_NULL;\n\n  /* Set local open/closed parameter. */\n\n  kopen = (iopen == SISL_CRV_PERIODIC) ? 0 : 1;\n\n\n  /* Control input     */\n\n  kk = ik;\n  if  (inbpnt < kk)\n    kk = inbpnt;\n\n  if  (kk < 2) goto err109;\n\n  if  (iopen != SISL_CRV_OPEN && iopen != SISL_CRV_CLOSED\n       && iopen != SISL_CRV_PERIODIC) goto err113;\n\n  /* Allocate space for parameterization    */\n\n  spara = newarray(inbpnt+1,DOUBLE);\n  if (spara == SISL_NULL) goto err101;\n\n  /* Calculate parameterization  */\n\n  spara[0] = astpar;\n  tlastpar = astpar;\n\n  for (ki=1; ki<inbpnt; ki++)\n    {\n      tdist = s6dist(&epoint[ki*idim-idim],&epoint[ki*idim],idim);\n      tlastpar = tlastpar + tdist;\n      spara[ki] = tlastpar;\n    }\n\n\n  /* Calculate distance from first to last point and update\n     parameterization array. To be useded if closed curve   */\n\n  tdist = s6dist(epoint,&epoint[(inbpnt-1)*idim],idim);\n  tlastpar = tlastpar + tdist;\n  spara[inbpnt] = tlastpar;\n\n\n  /* Find the knot vector     */\n\n  s1902(spara,inbpnt+(iopen==SISL_CRV_CLOSED),kk,kopen,&sknot,&kstat);\n  if (kstat < 0 || sknot == SISL_NULL) goto error;\n\n  /* Allocate space for verice array   */\n\n  scoef = newarray((inbpnt+kk-1)*idim,DOUBLE);\n  if (scoef == SISL_NULL) goto err101;\n\n  /* Copy vertices */\n\n  memcopy (scoef,epoint,inbpnt*idim,DOUBLE);\n  kn = inbpnt;\n\n  /* In case of closed curve, add the (kk-1) first points to the vertice\n     array.    */\n\n  if (iopen == SISL_CRV_PERIODIC)\n    {\n      memcopy(&scoef[inbpnt*idim],epoint,(kk-1)*idim,DOUBLE);\n      kn = kn + kk - 1;\n    }\n  else if (iopen == SISL_CRV_CLOSED)\n  {\n     memcopy(&scoef[inbpnt*idim],epoint,idim,DOUBLE);\n     kn += 1;\n  }\n\n  /* Make curve */\n  /* VSK, MESZ. Do not copy arrays.\n  qc = newCurve(kn,kk,sknot,scoef,1,idim,1);  */\n  qc = newCurve(kn,kk,sknot,scoef,1,idim,2); /* icopy=2, PFU 24/08-94 */\n  if (!qc) goto err101;\n\n  qc->cuopen = iopen;\n\n  /* Increase the order if the order was lowered when controlling input */\n\n  if (kk < ik)\n    {\n\t\t\t\t/* -> guen: inserted acc. to SCCS */\n      s1750(qc,ik,rc,&kstat);\n\t\t\t\t/* <- guen: inserted acc. to SCCS */\n\n\t\t\t\t/* -> guen: removed acc. to SCCS  */\n\t\t\t\t/*      s1750(qc,ik,&qc,&kstat);  */\n\t\t\t\t/* <- guen: removed acc. to SCCS  */\n      if (kstat< 0) goto error;\n    }\n\t\t\t\t/* -> guen: inserted acc. to SCCS */\n  else\n    {\n      *rc = qc;\n      qc = SISL_NULL;\n    }\n\t\t\t\t/* <- guen: inserted acc. to SCCS */\n\t\t\t\t/* -> guen: removed acc. to SCCS  */\n\t\t\t\t/*  if (qc) *rc = qc;             */\n\t\t\t\t/* -> guen: inserted acc. to SCCS */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in memory allocation */\n\n err101:\n  *jstat = -101;\n  s6err(\"s1630\",*jstat,kpos);\n  goto out;\n\n  /* Error in input, order less than 2 */\n\n err109:\n  *jstat = -109;\n  s6err(\"s1630\",*jstat,kpos);\n  goto out;\n\n  /* Error in input, unknown kind of curve */\n\n err113:\n  *jstat = -113;\n  s6err(\"s1630\",*jstat,kpos);\n  goto out;\n\n\n  /* Error in lower level function */\n\n error:\n  *jstat = kstat;\n  s6err(\"s1630\",*jstat,kpos);\n  goto out;\n\n out:\n  if (spara  != SISL_NULL) freearray(spara);\n  /* if (scoef  != SISL_NULL) freearray(scoef); (Freed by freeCurve(qc). */\n  if (qc != SISL_NULL) freeCurve(qc);\n  return;\n}\n"
  },
  {
    "path": "src/s1631.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S1631\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1631(SISLCurve *pc,double epoint[],double enorm[],double projdir[],int idim,SISLCurve **rc,int *jstat)\n#else\nvoid s1631(pc,epoint,enorm,projdir,idim,rc,jstat)\n     SISLCurve  *pc;\n     double epoint[];\n     double enorm[];\n     double projdir[];\n     int    idim;\n     SISLCurve  **rc;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To project a B-spline curve to a plane along a given direction\n*             \n*\n* INPUT      : pc      - The input B-spline curve.   \n*              epoint  - a point in the plane\n*              enorm   - normal vector to the plane  \n*              projdir - projection direction vector\n*              idim    - The dimension of the space\n*\n* OUTPUT     : rc     - Pointer to the projected curve\n*              jstat  - status messages\n  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : The vertices are projected. All other curve data are \n*              copied into the new curve. \n*\n* EXAMPLE OF USE:\n*\n* REFERENCES :\n*\n*-                                                 \n* CALLS      : s6diff,s6scpr,newCurve,s6err\n*\n*\n* WRITTEN BY : Kjell Fredrik Pettersen, SINTEF IKT, Oslo, Norway. 28. Jan 2009\n* REVISED BY : \n*\n*********************************************************************\n*/\n\n\n{\n  int kstat;          /* Status variable                                 */\n  int kiv;            /* Counter for vertices                            */\n  int kid;            /* Counter for dimension                           */\n  int kn;             /* The number of B-splines, i.e., the dimension of\n\t\t\t the spline space associated with the knot\n\t\t\t vector.                                         */\n  int kk;             /* The polynomial order of the curve.              */\n  int kind;           /* Type of curve, 2 and 4 are rational curves.     */\n  int kdim;           /* The dimension of the space in which the curve\n\t\t\t lies. Equivalently, the number of components\n\t\t\t of each B-spline coefficient.                   */\n  int kvert;          /* Counter for position in projected vertex array   */\n  int kpos=0;         /* Position of error                               */\n  \n  double *svecpv=SISL_NULL;/* Pointer to vector from pointin plane to vertex  */\n  double *sproj=SISL_NULL; /* Pointer to projected vertex array                */\n  double *st;         /* Pointer to the first element of the knot vector\n\t\t\t of the curve. The knot vector has [kn+kk]\n\t\t\t elements.                                       */\n  double *svert;      /* Pointer to a vertex                             */\n  double *scoef;      /* Pointer to the first element of the curve's\n\t\t\t B-spline coefficients. This is assumed to be an\n\t\t\t array with [kn*kdim] elements stored in the\n\t\t\t following order:\n\t\t\t First the kdim components of the first B-spline\n\t\t\t coefficient, then the kdim components of the\n\t\t\t second B-spline coefficient and so on.          */\n  \n  double recnormproj; /* The reciprocal of the scalar product of the\n\t\t\t plane normal vector and the projection vector */\n  double tdist;       /* Distance */\n  \n  /* Check if curve is correct */\n  \n  s1707(pc,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Describe curve with local parameters.  */\n  kn = pc -> in;\n  kk = pc -> ik;\n  st = pc -> et;\n  kind = pc->ikind;\n  if (kind == 2 || kind == 4)\n    scoef = pc->rcoef;\n  else\n    scoef = pc->ecoef;\n  kdim = pc -> idim;          \n\n  /* Check if conflicting dimensions */  \n  \n  if (kdim != idim) goto err106;\n  if (kind == 2 || kind == 4)\n    kdim++;\n  \n  svecpv = newarray(idim,DOUBLE);\n  if (svecpv == SISL_NULL) goto err101;\n  \n  sproj = newarray(kdim*kn,DOUBLE);\n  if (sproj == SISL_NULL) goto err101;\n  \n  /* Find reciprocal of scalar product */\n  recnormproj = 1.0 / s6scpr(enorm,projdir,idim);\n  \n  /* Do for all vertices */\n  \n  kvert = 0;\n  for (kiv=0; kiv<kn; kiv++) \n    {\n      /* Find vector from point in plane to vertex */\n      \n      svert = scoef + kiv*kdim;\n      s6diff(svert,epoint,idim,svecpv);\n      \n      /* Find distance between the vertex and the plane\n\t along the projection vector */\n      \n      tdist  =  s6scpr(svecpv,enorm,idim) * recnormproj;\n      \n      /* Find the projected vertex */\n      \n      for (kid=0; kid<idim; kid++,kvert++)\n\t{\n\t  sproj[kvert] = scoef[kvert] - tdist*projdir[kid];\n\t}  \n      if (kind == 2 || kind == 4)\n\t{\n\t   sproj[kvert] = scoef[kvert];\n\t   kvert++;\n\t}\n    }\n  \n  /* Make the projected curve */\n  \n  *rc = SISL_NULL;              \n  *rc = newCurve(kn,kk,st,sproj,kind,idim,1);\n  if (*rc == SISL_NULL) goto err101;                \n  \n  /* Copy cuopen flag.  */\n  \n  (*rc)->cuopen = pc->cuopen;\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in memory allocation */\n  \n err101: *jstat = -101;\n  s6err(\"s1631\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input, conflicting dimensions */\n  \n err106: *jstat = -106;\n  s6err(\"s1631\",*jstat,kpos);\n  goto out;\n  \n  \n  /* Error in lower level function */  \n  \n error:  *jstat = kstat;\n  s6err(\"s1631\",*jstat,kpos); \n  goto out;\n  \n out:\n  if (svecpv != SISL_NULL) freearray(svecpv);\n  if (sproj  != SISL_NULL) freearray(sproj);\n  return;\n}\n"
  },
  {
    "path": "src/s1700.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1700.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1700\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1700(int imy,int ik,int in,int iv,\n\t   int *jpl,int *jfi,int *jla,double *et,double apar,double *galfa,int *jstat)\n#else\nvoid s1700(imy,ik,in,iv,jpl,jfi,jla,et,apar,galfa,jstat)\n     int    imy;\n     int    ik;\n     int    in;\n     int    iv;\n     int    *jpl;\n     int    *jfi;\n     int    *jla;\n     double *et;\n     double apar;\n     double *galfa;\n     int    *jstat;\n#endif\n/*\n********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE  : To compute in a compact format a line in the discrete\n*            B-spline matrix converting between an orginal basis\n*            \"et\" and a new basis consisting of \"et\" and one p-tuppel\n*            knot, where 0 < p <= ik.\n*            To insert one p-tuppel knot the function must be called\n*            ik - (multiplicity of the knot) + 2*(p-1) times.\n*            The function can also be used for inserting knots at\n*            more than one value if at least ik-1 knots exist in \"et\"\n*            between the values in question.\n*            In this case apar must be changed and the index of the\n*            new vertices must be adjusted in the proper manner\n*            by the calling function.\n*\n*\n*\n* INPUT    : imy   - If one p-tuppel knot are to be inserted, and\n*                    the index of the new vertice are j then\n*                    imy = j when et[j] < apar and then unchanged\n*                    for the rest of j.\n*                    If knots are to be inserted in more than one\n*                    value, index the new vertices as it is only\n*                    one value to be insert, and adjust the index\n*                    after calling this function.\n*            ik    - The order of the B-spline.\n*            in    - The number of the orginal vertices.\n*            iv    - The number of new knots to insert in the\n*                    area between knot number j and knot number j+ik\n*                    in the new knot vector.\n*            et    - The knot vector.\n*            apar  - The value where to insert new knots.\n*\n*\n*\n* OUTPUT   : jpl   - The negativ difference between the index in galfa\n*                    and the real knot inserten matrix.\n*            jfi   - The index of the first element in the line j in the\n*                    the real knot inserten matrix whice is not zero.\n*                    The element with the index (jfi+jpl) in galfa\n*                    is the same as the element with index jfi in\n*                    the real line j in the knot inserten matrix.\n*            jla   - The index of the last element in the line j in the\n*                    real knot inserten matrix whice is not zero.\n*                    The element with the index (jla+jpl) in galfa\n*                    is the same as the element with index jla in\n*                    the real line j in the knot inserten matrix.\n*            galfa - A compressed line in the knot inserten matrix.\n*            jstat - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Using the Oslo-algorithm\n*\n*\n* REFERENCES : Making The Oslo algorithm more efficient.\n*              by  T.Lyche and K.Moerken.\n*              SIAM J.NUMER.ANAL  Vol. 23, No. 3, June 1986.\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-06.\n*\n**********************************************************************/\n{\n  int kpos=0;              /* Posisjon of error.           */\n  int kj,kv;               /* Help variable                */\n  int kp;                  /* Control variable in loop.    */\n  double *salfa;           /* Help pointer to galfa.       */\n  double tbeta,tbeta1;     /* Help variabels               */\n  double td1,td2;          /* Help variabels               */\n  double *t1,*t2;          /* Pointers to the knot vector. */\n  \n  \n  /* Check that the number of knots we insert is not to large */\n  \n  if (iv >= ik) goto err152;\n  \n  \n  /* Compute the negativ difference between the index in galfa and\n     the real knot inserten matrix. */\n  \n  *jpl=ik-imy-1;\n  \n  \n  /* Changing the galfa so we may use the index in the real matrix. */\n  \n  galfa += *jpl;\n  \n  \n  /* Initialise the last element. */\n  \n  galfa[imy] = 1;\n  \n  \n  /* Here we go one time for each new knot we insert. */\n  \n  for (kj=in+iv-2,in+=ik-1,kv=ik-iv,kp=0; kp<iv; kp++,kv++)\n    {\n      /* The initialising:  The two first are not changing.\n\t kj = in+iv-2, minus the maximum of kp it\n\t gives the index of the last\n\t orginal vertices.\n\t in = in+ik-1, the index of the last element in et.\n\t kv = ik-iv ,  the nuber of old knots in the field.\n\t This variabel is counting up to ik\n\t (the order) during the loops. */\n      \n      \n      /* Here we note the special case where we are at the\n\t start of the matrix and we does not have a k-touple\n\t knot at this end. */\n      \n      if (kp>=imy) tbeta1=(apar - *et)* *galfa/(et[kv] - *et);\n      else         tbeta1=(double)0.0;\n      \n      \n      *jfi=max(1,imy-kp); *jla=min(imy,kj-kp);\n      \n      \n      /* For details about this loop look in the reference. */\n      \n      for (salfa=galfa+*jfi,t1=et+*jfi,t2=et+*jla; t1<=t2; t1++,salfa++)\n\t{\n\t  td1 = apar - *t1;\n\t  td2 = t1[kv] - apar;\n\t  tbeta = *salfa/(td1 + td2);\n\t  salfa[-1] = td2*tbeta + tbeta1;\n\t  tbeta1 = td1*tbeta;\n\t}\n      \n      \n      /* Here we note the special case where we are at the\n\t end of the matrix and we does not have a k-touple\n\t knot at this end. */\n      \n      if (*jla<imy)\n\t{\n\t  t1 = et + in;\n\t  *(salfa-1) = tbeta1+(*t1-apar)* *salfa/(*t1 - *(t2+1));\n\t} else  *(salfa-1) = tbeta1;\n    }\n  \n  \n  /* Adjusting the index of first and last in galfa. */\n  \n  if (iv) (*jfi)--;\n  else   *jfi = *jla = imy;\n  \n  \n  /* Updating output. */\n  \n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error, to many insertions knots. */\n  \n err152:\n  *jstat = -152;\n  s6err(\"s1700\",*jstat,kpos);\n  goto out;\n  \n out: \n  return;\n}\n"
  },
  {
    "path": "src/s1701.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1701.c,v 1.2 2007-08-06 13:09:12 vsk Exp $\n *\n */\n\n\n#define S1701\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1701(int ij,int imy,int ik,int in,int *jpl,int *jfi,int *jla,\n\t   double *et,double *etau,double *ep,double *galfa,int *jstat)\n#else\nvoid s1701(ij,imy,ik,in,jpl,jfi,jla,et,etau,ep,galfa,jstat)\n     int    ij;\n     int    imy;\n     int    ik;\n     int    in;\n     int    *jpl;\n     int    *jfi;\n     int    *jla;\n     double *et;\n     double *etau;\n     double *ep;\n     double *galfa;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To compute in a compact format a line in the discrete\n*              B-spline matrix converting between an orginal basis\n*              \"etau\" and a new basis \"et\".\n*\n*\n*\n* INPUT    : ij     - The index of the new vertice\n*            imy    - An index on etau, where the input value are to be\n*                     etau(imy) <= et(ij) < etau(imy + 1).\n*            ik     - The order of the B-spline.\n*            in     - The number of the orginal vertices.\n*            et     - The new knot vector.\n*            etau   - The old knot vector.\n*            ep     - An array ep(ik) to local use. Such that we\n*                     do not need to allocate the array locally after\n*                     each call.\n*\n*\n*\n* OUTPUT   : jpl    - The negativ difference between the index in galfa\n*                     and the real knot inserten matrix.\n*            jfi    - The index of the first element in the line j in the\n*                     the real knot inserten matrix whice is not zero.\n*                     The element with the index (jfi+jpl) in galfa\n*                     is the same as the element with index jfi in\n*                     the real line j in the knot inserten matrix.\n*            jla    - The index of the last element in the line j in the\n*                     real knot inserten matrix whice is not zero.\n*                     The element with the index (jla+jpl) in galfa\n*                     is the same as the element with index jla in\n*                     the real line j in the knot inserten matrix.\n*            galfa  - A compressed line in the knot inserten matrix.\n*            jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Using the Oslo-algorithm\n*\n*\n* REFERENCES : Making The Oslo algorithm more efficient.\n*              by  T.Lyche and K.Moerken.\n*              SIAM J.NUMER.ANAL  Vol. 23, No. 3, June 1986.\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-11.\n*\n**********************************************************************/\n{\n  int kp;                  /* Control variable in loop.     */\n  int kv,kkv;              /* Help variables.               */\n  double *ah;              /* Help pointer to galfa.        */\n  double tbeta,tbeta1;     /* Help variables.               */\n  double td1,td2;          /* Help variables.               */\n  double *tu;              /* Pointer to the knot vector.   */\n  \n  \n  /* Correction of imy to be sure that the the old knot etau(imy)\n     is not passing the new knot et(ij). */\n  \n  kp=ij+1; kkv=ij+ik; in--;\n  while ((et[kp] == etau[imy]) && kp<kkv) {kp++; imy--;}\n  \n  \n  /* Counting the old and the new knot and copying the new knots\n     in the area between et(ij) and et(ij+ik) in the array ep. */\n  \n  for (kp=imy+1,kv=0,ij++; ij<kkv; ij++)\n    if (et[ij] == etau[kp]) kp++;\n    else      ep[kv++] = et[ij];\n  \n  \n  /* Compute the negativ difference between the index in galfa and\n     the real knot inserten matrix. */\n  \n  *jpl=ik-imy-1;\n\n//----> KYS 990414. Replaced the following lines:\n//  /* Changing the galfa so we may use the index in the real matrix. */\n//\n//  galfa += *jpl;\n//\n//\n//  /* Initialise the last element. */\n//\n//  galfa[imy] = 1;   \t\n//\t\t\t\n//\n// Replacement:\n\n  galfa[ik-1] = 1;\t// since ik-1 = imy+ *jpl\n\n// <--- end kys 990414\n\n  /* Here we go one time for each new knot from et(j+1)\n     until et(j+k) we insert. */\n  \n  for (kp=0,kkv=ik-kv,ij=in+kv-1,in +=ik; kp<kv; kp++,kkv++,ep++)\n    {\n      /* The initialising:  The two first are not changing.\n\t kkv = ik-kv , the nuber of old knots in the field.\n\t This variabel is counting up to ik\n\t (the order) during the loops.\n\t ij = in+kv-1, minus the maximum of kp it\n\t gives the index of the last\n\t orginal vertices.\n\t in = in+kv-1, the index of the last element in et. */\n      \n      \n      /* Here we note the special case where we are at the\n\t start of the matrix and we does not have a k-touple\n\t knot at this end. */\n      // KYS 990414: Replaced \"(*galfa)\" by \"(galfa[*jpl])\" in next line\n\n      if (kp>=imy) tbeta1=(*ep - *etau)*(galfa[*jpl])/(etau[kkv] - *etau);\n      else         tbeta1=0;\n      \n      *jfi=max(1,imy-kp); *jla=min(imy,ij-kp);\n      \n      \n      /* For details about this loop look in the reference. */\n      // KYS 990414: Replaced \"galfa\" by \"galfa+ *jpl\" in next line\n\n      for (et=etau+ *jfi,tu=etau+ *jla,ah=galfa+ *jpl+ *jfi;\n\t   et<=tu;\n\t   et++,ah++)\n\t{\n\t  td1 = *ep - *et;\n\t  td2 = et[kkv] - *ep;\n\t  tbeta = *ah/(td1+td2);\n\t  *(ah-1) = td2*tbeta + tbeta1;\n\t  tbeta1 = td1*tbeta;\n\t}\n      \n      \n      /* Here we note the special case where we are at the\n\t end of the matrix and we does not have a k-touple\n\t knot at this end. */\n      \n      if (*jla<imy)\n\t{\n\t  et = etau + in;\n\t  *(ah-1) = tbeta1+(*et-*ep)*(*ah)/(*et - *(tu+1));\n\t} else  *(ah-1) = tbeta1;\n    }\n\n\n  /* Adjusting the global indices corresponding to first and last\n     nonzero element in galfa. */\n\n  if (kv) (*jfi)--;\n  else   *jfi = *jla = imy;\n  \n  if ((*jfi)<0) *jfi = 0;\n  if ((*jla)>in-ik) *jla = in-ik;\n  \n  \n  /* Updating output. */\n  \n  *jstat = 0;\n  goto out;\n  \n  \n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1705.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1705.c,v 1.2 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1705\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1705(SISLCurve *pc,int *jstat)\n#else\nvoid s1705(pc,jstat)\n     SISLCurve *pc;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Remove unnessesary knots and vertices of a B-spline curve.\n*\n*\n*\n* INPUT      : pc     - SISLCurve to treat.\n*\n*\n*\n* OUTPUT     : jstat     - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Traverse the knot vector and remove multiplisety higher than\n*              the order of the curve, which give zero basis.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-06.\n* REVISED BY : Johannes Kaasa, SI, 92-04 (Introduced NURBS).\n* REVISED BY : Christophe Birkeland, SINTEF, 93-05 (*jstat = 0 in start).\n*\n**********************************************************************/\n{\n  int kk=pc->ik;           /* Order of the input curve.                  */\n  int kn=pc->in;           /* Number of the vertices in input curves.    */\n  int kdim=pc->idim;       /* Dimensjon of the space in whice curve lies.*/\n  int rdim = kdim + 1;     /* Rational dimension.                        */\n  int knnew=0;             /* Number of vertices in the new curves.      */\n  register int ki;                  /* Control variable in loop.         */\n  register double *s1,*s2,*s3,*s4;  /* Pointers used in loop.            */\n  register double *st=pc->et;       /* The first new knot-vector.        */\n  register double *scoef=pc->ecoef; /* The first new vertice.            */\n  double *rcoef = pc->rcoef; /* The rational vertices.                    */\n  int kind = pc->ikind;    /* The type of curve, 2 and 4 are rational.   */\n\n  *jstat = 0;\n  \n  /* s1 is used to traverse scoef, s2 is used to traverse st.\n     We just remove unnecesary knots by kompressing the arraies. */\n  \n  s4 = rcoef;\n  for (s1=scoef,s2=st,s3=s2+kn; s2<s3; s1+=kdim,s4+=rdim,s2++)\n    if (s2[kk] > *s2)\n      {\n\t/* Here we copies nessecary vertices to compress the vector. */\n\t\n\tfor (ki=0; ki<kdim; ki++)  \n\t  scoef[knnew*kdim+ki] = s1[ki];\n\t\n        /* Here we copy rational vertices. */\n\t\n\tif (kind == 2 || kind == 4)\n\t  {\n            for (ki=0; ki<rdim; ki++)  \n\t      rcoef[knnew*rdim+ki] = s4[ki];\n\t  }\n\t\n\t/* Here we copies nessecary knots to compress the vector. */\n\t\n\tst[knnew] = *s2;\n\t\n\t/* Updating number of copied knots. */\n\t\n\tknnew++;\n      }\n  \n  /* At last we have to copy the last kk knots. */\n  \n  for (ki=0; ki<kk; ki++) \n    st[knnew+ki] = s3[ki];\n  \n  /* If some knots are removed we have to update the size of the vectors.*/\n  \n  if (knnew == 0) \n    goto err111;\n  else\n    if (knnew < kn)\n      {\n\tpc->in = knnew;\n      }\n  goto out;\n  \n  err111:\n    *jstat = -111;\n  \n  out: \n    return;\n}\n"
  },
  {
    "path": "src/s1706.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1706.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1706\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1706(SISLCurve *pc)\n#else\nvoid s1706(pc)\n     SISLCurve *pc;\n#endif\n/*\n*******************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Turn the direction of a curve.\n*              The start of the new parameter is the same as the start\n*              of the old parameter.\n*              This rutine turn the direction of the orginal curve.\n*              If you want a copy with a turned direction, just\n*              make a copy and turn the direction of the copy.\n*\n*\n*\n* INPUT      : pc      -The curve.\n*\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-06.\n* REVISED BY : Johannes Kaasa, SI, Sep 1991 (Introduced NURBS).\n*\n********************************************************************/\n{\n  int  kk=pc->ik;             /* Order of the input curve.             */\n  int  kn=pc->in;             /* Number of vertices in the input curve.*/\n  int  kdim=pc->idim;         /* Dimensjon of the space in whice curve\n\t\t\t\t lies.                                 */\n  register double *s1,*s2;\n  register double *s3; \t       /* Pointers used in loop.               */\n  register double t1,t2;       /* Help variables.                      */\n  \n  /* Now curve to turn. */\n  \n  if (!pc) goto out;\n  \n  /* Here we are turning the knot vector such that the first\n     element have the same value as the old first element. */\n  \n  for (s1=pc->et,s2=s1+kk+kn-1,t1=(*s1)+(*s2); s1<=s2; s1++,s2--)\n    {\n      t2 = *s1;\n      *s1 = t1 - *s2;\n      *s2 = t1 - t2;\n    }\n  \n  /* Here we just turn the vertices. */\n  \n  for (s1=pc->ecoef,s2=s1+kdim*(kn-1); s1<s2; s2-=2*kdim)\n    for (s3=s1+kdim; s1<s3; s1++,s2++)\n      {\n\tt1 = *s1;\n\t*s1 = *s2;\n\t*s2 = t1;\n      }\n\n  /* If necessary turn rational vertices. */\n\n  if (pc->ikind == 2 || pc->ikind == 4)\n    {\n      kdim++;\n      for (s1=pc->rcoef,s2=s1+kdim*(kn-1); s1<s2; s2-=2*kdim)\n        for (s3=s1+kdim; s1<s3; s1++,s2++)\n          {\n\t    t1 = *s1;\n            *s1 = *s2;\n\t    *s2 = t1;\n          }\n    }\n  \n out:\n  return;\n}\n\n"
  },
  {
    "path": "src/s1707.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1707.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1707\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1707(SISLCurve *pc,int *jstat)\n#else\nvoid s1707(pc,jstat)\n     SISLCurve *pc;\n     int   *jstat;\n#endif\n/*\n********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Check if a B-spline curve is correct.\n*\n* INPUT      : pc     - SISLCurve to treat.\n*\n* OUTPUT     : jstat     - status messages\n*                        > 0      : warning (1&2 only used when \n*                                            cuopen=SISL_CRV_PERIODIC)\n*                                      = 1: Cyclic but not full freedom.\n*                                      = 2: Not cyclic.\n*                                      = 8: Non-positive rational weights.\n*                       = 0      : ok\n*                       < 0      : error\n*\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-06.\n* REVISED BY : Christophe Rene Birkeland, SI-SINTEF, May 1993.\n*\n**********************************************************************/\n{\n\n  int kpos=0;              /* Position of error. */\n  int kstat=0;\n  int step = 0;\n  register double *s1,*s2; /* Pointers used in loop. */\n  \n  if (!pc) goto err150;\n\n  if (pc->ik > pc->in) goto err111;\n  \n  if (pc->ik <= 0) goto err110;\n  \n  if (pc->in <= 0) goto err159;\n  \n  if (pc->idim <= 0) goto err102;\n  \n  if (pc->et[pc->in+pc->ik-1] <= *pc->et) goto err112;\n  \n  for (s1=pc->et,s2=pc->et+pc->in+pc->ik-1; s1<s2; s1++)\n    if (s1[1] < *s1) goto err112;\n\n  /* Check rational coefficients */\n  if(pc->ikind == 2 || pc->ikind == 4)\n    {\n      step = pc->idim + 1;\n      for (s1 = pc->rcoef + pc->idim, s2 = pc->rcoef + pc->in*step; \n\t   s1 < s2; \n\t   s1+= step)\n\tif (*s1 <= 0) goto war08;\n    }\n\n  /* Check if curve really is cyclic */\n  if(pc->cuopen == SISL_CRV_PERIODIC)\n    {\n      test_cyclic_knots(pc->et,pc->in,pc->ik,&kstat);\n      if (kstat < 0) goto error;\n      if (kstat == 0) goto war02;\n      if (kstat == 1) goto war01;\n    }\n      \n\n  /* Updating output. No errors ! */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Warning: Cuopen = SISL_CRV_PERIODIC, but knotvector does not give\n   * full freedom. */\n  \n  war01:\n    *jstat = 1;\n    goto out;\n  \n  /* Warning: Cuopen = SISL_CRV_PERIODIC, but knotvector not cyclic. */\n  \n  war02:\n    *jstat = 2;\n    goto out;\n  \n  /* Warning: Non-positive rational coefficients. */\n  \n  war08:\n    *jstat = 8;\n    goto out;\n  \n  /* Dimension less than 1. */\n  \n  err102:\n    *jstat = -102;\n    s6err(\"s1707\",*jstat,kpos);\n    goto out;\n  \n  /* Error. Order less than 1. */\n  \n  err110:\n    *jstat = -110;\n    s6err(\"s1707\",*jstat,kpos);\n    goto out;\n  \n  /* Error. Order greater than number of vertices. */\n   \n  err111:\n    *jstat = -111;\n    s6err(\"s1707\",*jstat,kpos);\n    goto out;\n\n  /* Error. Error in knotvector. */\n  \n  err112:\n    *jstat = -112;\n    s6err(\"s1707\",*jstat,kpos);\n    goto out;\n\n  /* Error. Null pointer. */\n  \n  err150:\n    *jstat = -150;\n    s6err(\"s1707\",*jstat,kpos);\n    goto out;\n  \n  /* Error. Number of vertices less than 1. */\n  \n  err159:\n    *jstat = -159;\n    s6err(\"s1707\",*jstat,kpos);\n    goto out;\n  \n  /* Error in lower level routine */\n      \n  error:\n    *jstat = kstat;\n    s6err(\"s1707\",*jstat,kpos);\n    goto out;\n\n  out: \n    return;\n}\n"
  },
  {
    "path": "src/s1708.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1708\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1708(SISLSurf *ps,int *jstat)\n#else\nvoid s1708(ps,jstat)\n     SISLSurf *ps;\n     int   *jstat;\n#endif\n/*\n********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Check if a B-spline surface is correct.\n*\n* INPUT      : ps      - SISLSurf to treat.\n*\n* OUTPUT     : jstat   - status messages\n*                        > 0      : warning (1&2 only used when \n*                                            cuopen==SISL_CRV_PERIODIC in at\n*                                            least one direction)\n*                                      = 1: Cyclic but not full freedom.\n*                                      = 2: Not cyclic.\n*                                      = 8: Non-positive rational weights.\n*                       = 0      : ok\n*                       < 0      : error\n*\n* CALLS      :\n*\n* WRITTEN BY : Christophe Rene Birkeland, SI-SINTEF, May 1993.\n*\n**********************************************************************/\n{\n  int type = 1;\n  int stat = 0;              /* Status for lower level routines   */\n  int kstat1= 0;\n  int kstat2= 0;\n  int kpos = 2;              /* Indicator of parameter direction\n\t\t\t      * for error message.                */\n  int step = 0;\n  register double *s1,*s2;   /* Pointers used in loop.            */\n  SISLCurve *curve=SISL_NULL;     /* Local curve                       */\n\n  if(ps->ikind == 3) type = 3;\n\n\n  /*\n   *  Check second parameter direction \n   *  \n   */\n\n  curve = newCurve(ps->in2, ps->ik2, ps->et2, ps->ecoef,\n\t\t   type, ps->idim * ps->in1, 0);\n  if(curve == SISL_NULL) goto err101;\n\n  s1707( curve, &stat);\n  if(stat<0) goto error;\n\n  /* Free curve element used in 2. par. direction */\n\n  freeCurve(curve);\n  curve = SISL_NULL;\n  \n\n  /*\n   *  Check first parameter direction\n   *\n   */\n\n  kpos = 1;\n\n  /*\n   * NOT necessary to transpose coefficient array. \n   * Coefficients are not checked\n   * in routine s1707 for curve-kind 1 || 3\n   *\n   */\n\n  curve = newCurve(ps->in1, ps->ik1, ps->et1, ps->ecoef,\n\t\t   type, ps->idim * ps->in2, 0);\n  if (curve == SISL_NULL) goto err101;\n\n  s1707( curve, &stat);\n  if(stat<0) goto error;\n\n  kpos = 0;\n\n  /* Check weights in case of rational surface */\n  if(ps->ikind == 2 || ps->ikind == 4)\n    {\n      step = ps->idim + 1;\n      for (s1 = ps->rcoef + ps->idim, s2 = ps->rcoef + ps->in1*ps->in2*step; \n           s1 < s2;\n           s1+= step)\n        if (*s1 <= 0) goto war08;\n    }\n\n  /* Check if surface really is cyclic */\n  if(ps->cuopen_1 == SISL_CRV_PERIODIC || ps->cuopen_2 == SISL_CRV_PERIODIC)\n    {\n      kpos = 1;\n      test_cyclic_knots(ps->et1,ps->in1,ps->ik1,&kstat1);\n      if (kstat1 < 0) goto error;\n      kpos = 2;\n      test_cyclic_knots(ps->et2,ps->in2,ps->ik2,&kstat2);\n      if (kstat2 < 0) goto error;\n      if ((kstat1 == 0 && ps->cuopen_1 == SISL_CRV_PERIODIC)\n\t  || (kstat2 == 0 && ps->cuopen_2 == SISL_CRV_PERIODIC))\n\tgoto war02;\n      if ((kstat1 == 1 && ps->cuopen_1 == SISL_CRV_PERIODIC)\n\t  || (kstat2 == 1 && ps->cuopen_2 == SISL_CRV_PERIODIC))\n\tgoto war01;\n    }\n      \n  /* SUCCESS. */\n\n  *jstat = 0;\n  goto out;\n\n  /* Warning: Cuopen = SISL_CRV_PERIODIC, but knotvector does not give\n   * full freedom. */\n  \n  war01:\n    *jstat = 1;\n    goto out;\n  \n  /* Warning: Cuopen = SISL_CRV_PERIODIC, but knotvector not cyclic. */\n  \n  war02:\n    *jstat = 2;\n    goto out;\n  \n  /* Warning: Non-positive rational coefficients. */\n  \n  war08:\n    *jstat = 8;\n    goto out;\n  \n  /* Error in allocations */\n\n  err101:\n    *jstat = -101;\n    s6err(\"s1708\", *jstat, kpos);\n    goto out;\n\n  /* Lower level error */\n\n  error:\n    *jstat = stat;\n    s6err(\"s1708\",*jstat,kpos);\n    goto out;\n\n out: \n  if (curve != SISL_NULL) freeCurve( curve );\n  return;\n}\n"
  },
  {
    "path": "src/s1710.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1710.c,v 1.3 2001-03-19 15:58:52 afr Exp $\n *\n */\n\n\n#define S1710\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1710 (SISLCurve * pc1, double apar, SISLCurve ** rcnew1, SISLCurve ** rcnew2, int *jstat)\n#else\nvoid\ns1710 (pc1, apar, rcnew1, rcnew2, jstat)\n     SISLCurve *pc1;\n     double apar;\n     SISLCurve **rcnew1;\n     SISLCurve **rcnew2;\n     int *jstat;\n#endif\n/*\n*******************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Subdivide a B-spline curve at a given parameter-value.\n*              NOTE: When the curve is periodic (ie. cuopen is\n*                    set to SISL_CRV_PERIODIC and open basis\n*                    with order-mult repeated knots and coeffic.)\n*                    this function will return only ONE curve\n*                    through rcnew1. This curve is the same\n*                    geometric curve as pc1, but is represented on\n*                    a closed basis with start and end at pc(apar).\n*                    Cuopen is set to SISL_CRV_CLOSED.\n*                    jstat equals 2 when this occurs.\n*\n*\n*\n* INPUT      : pc1      - SISLCurve to subdivide.\n*              apar     - Parameter-value at which to subdivide.\n*\n*\n*\n* OUTPUT     : rcnew1    - First part of the subdivided curve.\n*              rcnew2    - Second part of the subdivided curve.\n*                          If the parameter value is at the end of a\n*                          curve SISL_NULL pointers might be returned\n*              jstat     - status messages\n*                                         = 2      : pc1 periodic, rcnew2=SISL_NULL\n*                                         = 5      : parameter value at end of\n*                                                    curve, rcnew1=SISL_NULL or\n*                                                    rcnew2=SISL_NULL.\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Inserting knots at the subdividing-point until\n*              we have a ktuple-knot. Then we may separate the\n*              curve into two parts.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newCurve  - Allocate space for a new curve-object.\n*              freeCurve - Free space occupied by given curve-object.\n*              S1700.C   - Making the knot-inserten-transformation matrix.\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-06.\n* Revised by : Tor Dokken,  SI, 89-03. Can be used for converting\n*              from closed to open description\n* MODIFIED BY : Mike Floater, SI, 91-01. Subdivide rational curves.\n* MODIFIED BY : Ulf J. Krystad, SI, 92-01. Subdivide periodic crvs.\n* MODIFIED BY : Arne Laksaa, SI, 92-09. Move apar to closest knot\n*\t\tif it is close to a knot. Using D(N)EQUAL().\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, 94-08. Added error propagation.\n*\n*\n**********************************************************************/\n{\n  int kind = pc1->ikind;\t/* Type of curve pc1 is.                   */\n  int kstat;\t\t\t/* Local status variable.                  */\n  int kpos = 0;\t\t\t/* Position of error.                      */\n  int kmy;\t\t\t/* An index to the knot-vector.            */\n  int kv, kv1;\t\t\t/* Number of knots we have to insert.      */\n  int kpl, kfi, kla;\t\t/* To posisjon elements in trans.-matrix.  */\n  int kk = pc1->ik;\t\t/* Order of the input curve.               */\n  int kn = pc1->in;\t\t/* Number of the vertices in input curves. */\n  int kdim = pc1->idim;\t\t/* Dimensjon of the space in whice\n\t\t\t\t * the curve lies.                         */\n  int kn1, kn2;\t\t\t/* Number of vertices in the new curves.   */\n  int knum;\t\t\t/* Number of knots less and equal than\n\t\t\t           the intersection point.                 */\n  int ki, ki1;\t\t\t/* Control variable in loop.               */\n  int kj, kj1, kj2;\t\t/* Control variable in loop.               */\n  int newkind = 1;\t\t/* Type of curve the subcurves are         */\n  double *s1, *s2, *s3, *s4;\t/* Pointers used in loop.                  */\n  double *st1 = SISL_NULL;\t\t/* The first new knot-vector.              */\n  double *st2 = SISL_NULL;\t\t/* The second new knot-vector.             */\n  double *salfa = SISL_NULL;\t\t/* A line of the trans.-matrix.            */\n  double *scoef;\t\t/* Pointer to vertices.                    */\n  double *scoef1 = SISL_NULL;\t/* The first new vertice.                  */\n  double *scoef2 = SISL_NULL;\t/* The second new vertice.                 */\n  SISLCurve *q1 = SISL_NULL;\t\t/* Pointer to new curve-object.            */\n  SISLCurve *q2 = SISL_NULL;\t\t/* Pointer to new curve-object.            */\n  int incr;\t\t\t/* Number of extra knots copied\n\t\t\t\t * during periodicity                      */\n  int mu;\t\t\t/* Multiplisity at the k'th knot           */\n  int kleft = kk-1;\t\t/* Knot navigator                          */\n  double delta;                 /* Period size in knot array.              */\n  double salfa_local[5];\t/* Local help array.\t\t\t   */\n\n  *rcnew1 = SISL_NULL;\n  *rcnew2 = SISL_NULL;\n\n  /* if pc1 is rational, do subdivision in homogeneous coordinates */\n  /* just need to set up correct dim and kind for the new curves at end of routine */\n  if (kind == 2 || kind == 4)\n    {\n      scoef = pc1->rcoef;\n      kdim++;\n      newkind++;\n    }\n  else\n    {\n      scoef = pc1->ecoef;\n    }\n\n  /* Check that we have a curve to subdivide. */\n\n  if (!pc1)\n    goto err150;\n\n\n  /* Periodic curve treatment, UJK jan 92--------------------------------- */\n  if (pc1->cuopen == SISL_CRV_PERIODIC)\n    {\n      delta = (pc1->et[kn] - pc1->et[kk - 1]);\n\n      /* Check that the intersection point is an interior point. */\n      /*if (apar < *(pc1->et) || apar > *(pc1->et + kn + kk - 1))*/\n      if ((apar < pc1->et[0] && DNEQUAL(apar, pc1->et[0])) ||\n\t  (apar > pc1->et[kn+kk-1] && DNEQUAL(apar, pc1->et[kn+kk-1])))\n\t goto err158;\n\n      /* If inside the knot vector, but outside well define\n\t intervall, we shift the parameter value one period. */\n      if (apar < pc1->et[kk - 1] && DNEQUAL(apar, pc1->et[kk - 1]))\n\tapar += delta;\n      if (apar > pc1->et[kn] || DEQUAL(apar, pc1->et[kn]))\n\tapar -= delta;\n\n      /* Now we create a new curve that is a copy of pc1,\n\t but with the period repeated once,\n\t this allows us to pick a whole period. */\n\n      /* Get multiplisity at start of full basis interval */\n      mu = s6knotmult(pc1->et, kk, kn, &kleft, pc1->et[kk-1], &kstat);\n      if (kstat < 0) goto err153;\n      if (mu >= kk) goto errinp;\n\n      /* Copy ----------------------------------- */\n      incr = kn - kk + mu;\n      if ((scoef1 = newarray ((kn + incr) * kdim, double)) == SISL_NULL)\n\tgoto err101;\n      if ((st1 = newarray (kn + kk + incr, double)) == SISL_NULL)\n\tgoto err101;\n\n      memcopy (scoef1, scoef, kn * kdim, double);\n      memcopy (st1, pc1->et, kn + kk, double);\n      memcopy (scoef1 + kn * kdim, scoef + (kk - mu) * kdim,\n\t       incr * kdim, double);\n\n\n      for (ki = 0; ki < incr; ki++)\n\tst1[kn + kk + ki] = st1[kn + kk + ki - 1] +\n\t  (st1[2*kk - mu + ki] - st1[2*kk - mu + ki - 1]);\n\n      if ((q1 = newCurve (kn + incr, kk, st1, scoef1,\n\t\t\t  newkind, pc1->idim, 2)) == SISL_NULL)\n\tgoto err101;\n      q1->cuopen = SISL_CRV_OPEN;\n\n      /* Pick part (one period)------------------ */\n      s1712 (q1, apar, apar + delta,\n\t     rcnew1, &kstat);\n      if (kstat < 0)\n\tgoto err153;\n      freeCurve (q1);\n      if (*rcnew1)\n\t(*rcnew1)->cuopen = SISL_CRV_CLOSED;\n\n      /* Finished, exit */\n      *jstat = 2;\n      goto out;\n\n    }\n\n  /* End of periodic curve treatment, UJK jan 92------------- */\n\n    /* Check that the intersection point is an interior point. */\n  /* Changed by UJK and later ALA*/\n  /*if (apar < *(pc1->et) || apar > *(pc1->et+kn+kk-1)) goto err158; */\n\n  if ((apar < pc1->et[kk - 1] && DNEQUAL(apar, pc1->et[kk - 1]))||\n      (apar > pc1->et[kn] && DNEQUAL(apar, pc1->et[kn])))\n    goto err158;\n\n  /* Allocate space for the kk elements which may not be zero in eache\n     line of the basic transformation matrix.*/\n\n  if (kk > 5)\n  {\n     if ((salfa = newarray (kk, double)) == SISL_NULL)\tgoto err101;\n  }\n  else salfa = salfa_local;\n\n\n  /* Find the number of the knots which is smaller or like\n     the intersection point, and how many knots we have to insert.*/\n\n  s1 = pc1->et;\n  kv = kk;\t/* The maximum number of knots we may have to insert. */\n\n  if ((apar > s1[0] && DNEQUAL(apar, s1[0])) &&\n      (apar < s1[kn+kk-1] && DNEQUAL(apar, s1[kn+kk-1])))\n  {\n     /* Using binear search*/\n     kj1=0;\n     kj2=kk+kn-1;\n     knum = (kj1+kj2)/2;\n     while (knum != kj1)\n     {\n\tif ((s1[knum] < apar) && DNEQUAL (s1[knum], apar))\n\t   kj1=knum;\n\telse\n\t   kj2=knum;\n\tknum = (kj1+kj2)/2;\n     }\n     knum++;    /* The smaller knots. */\n\n     while (DEQUAL (s1[knum], apar))\n      \t/* The knots thats like the intersection point. */\n     {\n\tapar = s1[knum];\n\tknum++;\n\tkv--;\n     }\n  }\n  else if (DEQUAL(apar,s1[0]))\n  {\n     apar = s1[0];\n     knum = 0;\n     while (s1[knum] == apar)\n\t/* The knots thats like the intersection point. */\n\tknum++;\n  }\n  else if (DEQUAL(apar,s1[kn+kk-1]))\n  {\n     apar = s1[kn+kk-1];\n     knum = kn+kk-1;\n     while (s1[knum-1] == apar)\n\t/* The knots thats like the intersection point. */\n\tknum--;\n  }\n\n  /* Find the number of vertices in the two new curves. */\n\n  kn1 = knum + kv - kk;\n  kn2 = kn + kk - knum;\n\n\n\n  /* Allocating the new arrays to the two new curves. */\n\n  if (kn1 > 0)\n  {\n     if ((scoef1 = newarray (kn1 * kdim, double)) == SISL_NULL)\n\tgoto err101;\n     if ((st1 = newarray (kn1 + kk, double)) == SISL_NULL)\n\tgoto err101;\n  }\n  if (kn2 > 0)\n  {\n     if ((scoef2 = newarray (kn2 * kdim, double)) == SISL_NULL)\n\tgoto err101;\n     if ((st2 = newarray (kn2 + kk, double)) == SISL_NULL)\n\tgoto err101;\n  }\n\n\n  /* Copying the knotvectors, all but the intersection point from\n     the old curve to the new curves */\n\n  memcopy (st1, pc1->et, kn1, double);\n  memcopy (st2 + kk, pc1->et + knum, kn2, double);\n\n\n  /* Updating the knotvectors by inserting a k-touple knot in\n     the intersection point at each curve.*/\n\n  for (s2 = st1 + kn1, s3 = st2, s4 = s3 + kk; s3 < s4; s2++, s3++)\n    *s2 = *s3 = apar;\n\n\n  /* Copying the coefisientvectors to the new curves.*/\n\n  memcopy (scoef1, scoef, kdim * kn1, double);\n  memcopy (scoef2, scoef + kdim * (knum - kk), kdim * kn2, double);\n\n\n  /* Updating the coefisientvectors to the new curves.*/\n\n  /* Updating the first curve. */\n  knum -= kk - 1;\n  for (ki=max(0, knum), kv1=max(0,-knum), s1=scoef1+ki*kdim; ki < kn1; ki++)\n  {\n     /* Initialising:\n\tknum = knum-kk+1, Index of the first vertice to change.\n\tki = knum,        Index of the vertices we are going to\n\tchange. Starting with knum, but if\n\tknum is negativ we start at zero.\n\tkv1 = 0,          Number if new knots between index ki\n\tand ki+kk. We are starting one below\n\tbecase we are counting up before using\n\tit. If knum is negativ we are not\n\tstarting at zero but at -knum.\n\ts1=scoef1+ki*kdim,SISLPointer at the first vertice to\n\tchange. */\n\n\n     /* Using the Oslo-algorithm to make a transformation-vector\n\tfrom the old vertices to one new vertice. */\n\n     kmy = ki;\n     s1700 (kmy, kk, kn, ++kv1, &kpl, &kfi, &kla, pc1->et, apar, salfa, &kstat);\n     if (kstat)\n\tgoto err153;\n\n\n     /* Compute the kdim vertices with the same \"index\". */\n\n     for (kj = 0; kj < kdim; kj++, s1++)\n\tfor (*s1 = 0, kj1 = kfi, kj2 = kfi + kpl; kj1 <= kla; kj1++, kj2++)\n\t   *s1 += salfa[kj2] * scoef[kj1 * kdim + kj];\n  }\n\n  /* And the second curve. */\n\n  for (ki1 = min (kn1 + kv - 1, kn + kv), s1 = scoef2; ki < ki1; ki++)\n    {\n      /* Initialising:\n\t ki1 = kn1+kv-1,   the index of the vertice next to the\n\t last vertice we have to change.\n\t If we do not have so many vertices,\n\t we have to use the index next to the\n\t last vertice we have, kn+kv.\n\t s1=scoef2         Pointer at the first vertice to\n\t change. */\n\n\n      /* Using the Oslo-algorithm to make a transformation-vector\n\t from the old vertices to one new vertice. */\n\n      s1700 (kmy, kk, kn, kv1--, &kpl, &kfi, &kla, pc1->et, apar, salfa, &kstat);\n      if (kstat)\n\tgoto err153;\n\n\n      /* Compute the kdim vertices with the same \"index\". */\n\n      for (kj = 0; kj < kdim; kj++, s1++)\n\tfor (*s1 = 0, kj1 = kfi, kj2 = kfi + kpl; kj1 <= kla; kj1++, kj2++)\n\t  *s1 += salfa[kj2] * scoef[kj1 * kdim + kj];\n    }\n\n\n  /* Allocating new curve-objects.*/\n\n  if (kn1 > 0)\n    q1 = newCurve (kn1, kk, st1, scoef1, newkind, pc1->idim, 2);\n\n  if (kn2 > 0)\n    q2 = newCurve (kn2, kk, st2, scoef2, newkind, pc1->idim, 2);\n\n  if (q1 == SISL_NULL && q2 == SISL_NULL)       goto err101;\n\n  /* Updating output. */\n\n  *rcnew1 = q1;\n  *rcnew2 = q2;\n  if (q1 == SISL_NULL || q2 == SISL_NULL)\n     *jstat = 5;  /* The curve is subdivided in an endpoint. */\n  else\n     *jstat = 0;\n  goto out;\n\n\n  /* Error. Error in low level routine. */\n\nerr153:\n  *jstat = kstat;\n  s6err (\"s1710\", *jstat, kpos);\n  goto outfree;\n\n  /* Error. Error in input */\nerrinp:\n  *jstat = -154;\n  s6err (\"s1710\", *jstat, kpos);\n  goto outfree;\n\n\n  /* Error. No curve to subdivide.  */\n\nerr150:\n  *jstat = -150;\n  s6err (\"s1710\", *jstat, kpos);\n  goto out;\n\n\n  /* Error. The parameter value is outside the curve.  */\n\nerr158:\n  *jstat = -158;\n  s6err (\"s1710\", *jstat, kpos);\n  goto out;\n\n\n  /* Error. Allocation error, not enough memory.  */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1710\", *jstat, kpos);\n  goto outfree;\n\n\noutfree:\n   if (q1)\n      freeCurve (q1);\n\n   if (q2)\n      freeCurve (q2);\n\n\n   /* Free local used memory. */\n\nout:\n   if (!q1)\n   {\n      if (st1)\n\t freearray (st1);\n      if (scoef1)\n\t freearray (scoef1);\n   }\n\n   if (!q2)\n   {\n      if (st2)\n\t freearray (st2);\n      if (scoef2)\n\t freearray (scoef2);\n   }\n\n   if (kk > 5 && salfa)\n      freearray (salfa);\n   return;\n}\n"
  },
  {
    "path": "src/s1711.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1711.c,v 1.4 2001-03-19 15:58:52 afr Exp $\n *\n */\n\n\n#define S1711\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1711(SISLSurf *ps,int ipar,double apar,SISLSurf **rsnew1,SISLSurf **rsnew2,int *jstat)\n#else\nvoid s1711(ps,ipar,apar,rsnew1,rsnew2,jstat)\n     SISLSurf   *ps;\n     int    ipar;\n     double apar;\n     SISLSurf   **rsnew1;\n     SISLSurf   **rsnew2;\n     int    *jstat;\n#endif\n/*\n********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Subdivide a B-spline surface at a given parameter-value\n*\t       and a given direction.\n*\n*\n*\n* INPUT      : ps\t- Surface to subdivide.\n*\t       ipar\t- 1 means first direction, 2 means second direction.\n*   \t       apar\t- Parameter-value at which to subdivide.\n*\n*\n*\n* OUTPUT     : rsnew1\t- First part of the subdivided surface.\n*              rsnew2\t- Second part of the subdivided surface.\n*              jstat\t- status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Inserting knots at the subdividing-point until\n*\t       we have a ktuple-knot. Then we may separate the\n*\t       surface into two parts.\n*\t       The problem is to treat a three dimensional array that\n*\t       is locatet in a one dimensional array (coeffisients).\n*\t       To solve this problem we use constants to marsch in different\n*\t       direction in the array, and to mark end of lines or columns.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newSurf  - Allocate space for a new curve-object.\n*\t       freeSurf - Free space occupied by given curve-object.\n*\t       S1700.C  - Making the knot-inserten-transformation matrix.\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-06.\n* MODIFIED BY : Mike Floater, SI, 90-12. Subdivide rational surfaces.\n* MODIFIED BY : Arne Laksaa, SI, 92-09. Move apar to closest knot\n*\t\tif it is close to a knot. Using D(N)EQUAL().\n* MODIFIED BY : Paal Fugelli, SINTEF, Oslo 15/07-1994. Changed from icopy==0\n*               to icopy==2 in creation of output surface - memory leak.\n*\n**********************************************************************/\n{\n  int kstat;\t\t/* Local status variable.\t\t*/\n  int kpos=0;\t\t/* Position of error.\t\t\t*/\n  int kmy;\t\t/* An index to the knot-vector.\t\t*/\n  int kv,kv1;\t\t/* Number of knots we have to insert.\t*/\n  int kpl,kfi,kla;\t/* To posisjon elements in trans.-matrix.*/\n  int kk,kksec;\t\t/* Order of the input surface.\t\t*/\n  int kn,knsec;\t\t/* Number of the vertices in input curves.*/\n  int kdim=ps->idim;\t/* Dimensjon of the space in whice surface\n\t\t\t   lies.\t\t\t\t*/\n  int kind=ps->ikind;\t/* Type of surface ps is.               */\n  int kn1,kn2;\t\t/* Number of vertices in the new surfaces.*/\n  int knum;\t\t/* Number of knots less and equal than\n\t\t\t   the intersection point.\t\t*/\n  int ki,ki1,ki2;\t/* Control variable in loop.\t\t*/\n  int kj,kj1,kj2;\t/* Control variable in loop.\t\t*/\n  int k1m,k2m,k3m,k4m;\t/* Variables to mark directons in array.*/\n  int newkind=1;\t/* Type of surface subsurfaces are.     */\n  double *s1,*s2,*s3,*s4;/* Pointers used in loop.\t\t*/\n  double *st,*stsec;\t/* The old knot-vectors.\t\t*/\n  double *st1=SISL_NULL;\t/* The first first new knot-vector.\t*/\n  double *st1sec=SISL_NULL;\t/* The first second new knot-vector.\t*/\n  double *st2=SISL_NULL;\t/* The second first new knot-vector.\t*/\n  double *st2sec=SISL_NULL;\t/* The second second new knot-vector.\t*/\n  double *salfa=SISL_NULL;\t/* A line of the trans.-matrix.\t\t*/\n  double *scoef;\t/* Pointer to vertices.   \t\t*/\n  double *scoef1=SISL_NULL;\t/* The first new vertice.\t\t*/\n  double *scoef2=SISL_NULL;\t/* The second new vertice.\t\t*/\n  SISLSurf *q1=SISL_NULL;\t/* Pointer to new surface-object.\t*/\n  SISLSurf *q2=SISL_NULL;\t/* Pointer to new surface-object.\t*/\n  double salfa_local[5];/* Local help array.\t\t\t*/\n\n /* if ps is rational, do subdivision in homogeneous coordinates */\n /* just need to set up correct dim and kind for the new surfaces at end of routine */\n  if(kind == 2 || kind == 4)\n  {\n       scoef = ps->rcoef;\n       kdim++;\n       newkind++;\n  }\n  else\n  {\n       scoef = ps->ecoef;\n  }\n\n  /* Check that we have a surface to subdivide. */\n\n  if (!ps) goto err150;\n\n  /* Making constants and ponters to mark direction.  */\n\n  if (ipar==1)\n    {\n      /* If ipar is 1 we have to split the \"three\" dimentional\n\t coeffisient matrix along a column. In this case k4m is\n\t the distance beetween each element in the clumn.\n\t For each element in the column we have to treat a part\n\t of a line, to march along the line we use k1m.*/\n\n      st = ps->et1;\n      stsec = ps->et2;\n      kn = ps->in1;\n      knsec = ps->in2;\n      kk = ps->ik1;\n      kksec = ps->ik2;\n      k1m = kdim;\n      k4m = kdim*kn;\n    }\n  else\n    {\n      /* If ipar is 2 we have to split the \"three\" dimentional\n\t coeffisient matrix along a line. In this case k4m is\n\t the distance beetween each element in the line.\n\t For each element in the line we have to treat a part\n\t of a column, to march along the column we use k1m.*/\n\n      st = ps->et2;\n      stsec = ps->et1;\n      kn = ps->in2;\n      knsec = ps->in1;\n      kk = ps->ik2;\n      kksec = ps->ik1;\n      k1m = kdim*knsec;\n      k4m = kdim;\n    }\n\n  /* Check that the intersection point is an interior point. */\n\n  if ((apar < *st  && DNEQUAL(apar, *st)) ||\n      (apar > st[kn+kk-1] && DNEQUAL(apar, st[kn+kk-1])))\n\t  \t\t\t\t\t\tgoto err158;\n\n  /* Allocate space for the kk elements which may not be zero in eache\n     line of the basic transformation matrix.*/\n\n  if (kk > 5)\n  {\n     if ((salfa = newarray (kk, double)) == SISL_NULL)\tgoto err101;\n  }\n  else salfa = salfa_local;\n\n  /* Find the number of the knots which is smaller or like\n     the intersection point, and how many knots we have to insert.*/\n\n  s1 = st;\n  kv = kk;\t/* The maximum number of knots we have to insert. */\n\n  if ((apar > s1[0] && DNEQUAL(apar, s1[0])) &&\n      (apar < s1[kn+kk-1] && DNEQUAL(apar, s1[kn+kk-1])))\n  {\n     /* Using binear search*/\n     kj1=0;\n     kj2=kk+kn-1;\n     knum = (kj1+kj2)/2;\n     while (knum != kj1)\n     {\n\tif ((s1[knum] < apar ) && DNEQUAL(s1[knum], apar))\n\t   kj1=knum; else kj2=knum;\n\tknum = (kj1+kj2)/2;\n     }\n     knum++;           /* The smaller knots.*/\n\n     while (DEQUAL(s1[knum], apar))\n     {\n\tapar = s1[knum];\n\tknum++;\n\tkv--;\n     }\n     /* The knots thats like the */\n     /*     intersection point.  */\n  }\n  else if (DEQUAL(apar,s1[0]))\n  {\n     apar = s1[0];\n     knum = 0;\n     while (s1[knum] == apar)\n\t/* The knots thats like the intersection point. */\n\tknum++;\n  }\n  else if (DEQUAL(apar,s1[kn+kk-1]))\n  {\n     apar = s1[kn+kk-1];\n     knum = kn+kk-1;\n     while (s1[knum-1] == apar)\n\t/* The knots thats like the intersection point. */\n\tknum--;\n  }\n  /* Find the number of vertices in the two new curves. */\n\n  kn1 = knum + kv - kk;\n  kn2 = kn + kk - knum;\n\n  /* Allocating the new arrays to the two new curves. */\n\n  if ((st1=newarray(kn1+kk,double))==SISL_NULL) goto err101;\n  if ((st1sec=newarray(knsec+kksec,double))==SISL_NULL) goto err101;\n  if ((st2=newarray(kn2+kk,double))==SISL_NULL) goto err101;\n  if ((st2sec=newarray(knsec+kksec,double))==SISL_NULL) goto err101;\n  if ((scoef1=newarray(kn1*kdim*knsec,double))==SISL_NULL) goto err101;\n  if ((scoef2=newarray(kn2*kdim*knsec,double))==SISL_NULL) goto err101;\n\n  /* Copying the knotvectors from the old curve to the new curves */\n\n  memcopy(st1,st,kn1,double);\n  memcopy(st2+kk,st+knum,kn2,double);\n  memcopy(st1sec,stsec,knsec+kksec,double);\n  memcopy(st2sec,stsec,knsec+kksec,double);\n\n  /* Updating the knotvectors by inserting the new k-touple knot */\n\n  for(s2=st1+kn1,s3=st2,s4=s3+kk;s3<s4;s2++,s3++) *s2 = *s3 = apar;\n\n  /* Copying the coefisientvectors to the new curves.*/\n\n  if (ipar == 1)\n    for (ki=0; ki<knsec; ki++)\n      {\n\tmemcopy(scoef1+ki*kdim*kn1,scoef+ki*kdim*kn,\n\t\tkdim*kn1,double);\n\tmemcopy(scoef2+ki*kdim*kn2,scoef+kdim*(ki*kn+knum-kk),\n\t\tkdim*kn2,double);\n      }\n  else\n    {\n      memcopy(scoef1,scoef,kdim*kn1*knsec,double);\n      memcopy(scoef2,scoef+kdim*(knum-kk)*knsec,\n\t      kdim*kn2*knsec,double);\n    }\n\n  /* Updating the coefisientvectors to the new surfaces.*/\n\n  /* Updating the first surface. */\n\n  /* If we imagine that the matrix is turned in such a way that we are\n     splitting it along a column, then for each element in the column\n     we have to treat a par of a line, to march along the line\n     in the first new matrix we use k1m, And we use k3m as a mark\n     at the end of the column in this new matrix.*/\n\n  if(ipar==1)\n    {\n      k2m=kdim*kn1;\n      k3m=kdim*kn1*knsec;\n    }\n  else\n    {\n      k2m=kdim;\n      k3m=kdim*knsec;\n    }\n  knum -= kk - 1;\n  for (ki=max(0,knum),kv1=max(0,-knum),s1=scoef1+ki*k1m;ki<kn1;ki++,s1+=k1m)\n    {\n      /* Initialising:\n\t knum = knum-kk+1, Index of the first vertice to change.\n\t ki = knum, \t  Index of the vertices we are going to\n\t change. Starting with knum, but if\n\t knum is negativ we start at zero.\n\t kv1 = 0,\t  Number if new knots between index ki\n\t and ki+kk. We are starting one below\n\t becase we are counting up before using\n\t it. If knum is negativ we are not\n\t starting at zero but at -knum.\n\t s1=scoef1+ki*k1m  Pointer at the first vertice to\n\t change. */\n\n      /* Using the Oslo-algorithm to make a transformation-vector\n\t from the old vertices to one new vertice. */\n\n      kmy=ki;\n      s1700(kmy,kk,kn,++kv1,&kpl,&kfi,&kla,st,apar,salfa,&kstat);\n      if (kstat) goto err153;\n\n      /* Compute the knsec*kdim vertices with the \"same index\". */\n\n      for (s2=s1,s3=s2+k3m,ki2=0; s2<s3; s2+=k2m,ki2+=k4m)\n\tfor (kj=0,s4=s2; kj<kdim; kj++,s4++)\n\t  for (*s4=0,kj1=kfi,kj2=kfi+kpl; kj1<=kla;kj1++,kj2++)\n\t    *s4 += salfa[kj2] * scoef[k1m*kj1+ki2+kj];\n    }\n\n  /* And the second surface. */\n\n  /* If we imagine that the matrix is turned in such a way that we are\n     splitting it along a column, then for each element in the column\n     we have to treat a par of a line, to march along the line\n     in the second new matrix we use k1m, And we use k3m as a mark\n     at the end of the column in this new matrix.*/\n\n  if(ipar==1)\n    {\n      k2m=kdim*kn2;\n      k3m=kdim*kn2*knsec;\n    }\n  else\n    {\n      k2m=kdim;\n      k3m=kdim*knsec;\n    }\n\n  for (ki1=min(kn1+kv-1,kn+kv),s1=scoef2; ki<ki1; ki++,s1+=k1m)\n    {\n      /* Initialising:\n\t ki1 = kn1+kv-1,\t  the index of the vertice next to the\n\t last vertice we have to change.\n\t If we do not have so many vertices,\n\t we have to use the index next to the\n\t last vertice we have, kn+kv.\n\t s1=scoef2\t  Pointer at the first vertice to\n\t change. */\n\n\n      /* Using the Oslo-algorithm to make a transformation-vector\n\t from the old vertices to one new vertice. */\n\n      s1700(kmy,kk,kn,kv1--,&kpl,&kfi,&kla,st,apar,salfa,&kstat);\n      if (kstat) goto err153;\n\n\n      /* Compute the knsec*kdim vertices with the \"same index\". */\n\n      for (s2=s1,s3=s2+k3m,ki2=0; s2<s3; s2+=k2m,ki2+=k4m)\n\tfor (kj=0,s4=s2; kj<kdim; kj++,s4++)\n\t  for (*s4=0,kj1=kfi,kj2=kfi+kpl; kj1<=kla;kj1++,kj2++)\n\t    *s4 += salfa[kj2] * scoef[k1m*kj1+ki2+kj];\n    }\n\n\n  /* Allocating new surface-objects.*/\n /* use ps->idim rather than kdim in case ps is rational  */\n\n\n  if (ipar==1)\n  {\n    if ((q1=newSurf(kn1,knsec,kk,kksec,st1,st1sec,     /* PFU 15/07-94 */\n                    scoef1,newkind,ps->idim,2)) == SISL_NULL) goto err101;\n    if ((q2=newSurf(kn2,knsec,kk,kksec,st2,st2sec,     /* PFU 15/07-94 */\n                    scoef2,newkind,ps->idim,2)) == SISL_NULL) goto err101;\n  }\n  else\n  {\n    if ((q1=newSurf(knsec,kn1,kksec,kk,st1sec,st1,     /* PFU 15/07-94 */\n                    scoef1,newkind,ps->idim,2)) == SISL_NULL) goto err101;\n    if ((q2=newSurf(knsec,kn2,kksec,kk,st2sec,st2,     /* PFU 15/07-94 */\n                    scoef2,newkind,ps->idim,2)) == SISL_NULL) goto err101;\n  }\n\n\n  /* Updating output. */\n\n  *rsnew1 = q1;\n  *rsnew2 = q2;\n  *jstat = 0;\n  goto out;\n\n\n  /* Error. Error in lower level function. */\n\n err153: *jstat = kstat;\n  goto outfree;\n\n\n  /* Error. No surface to subdevice.  */\n\n err150: *jstat = -150;\n  s6err(\"s1711\",*jstat,kpos);\n  goto out;\n\n\n  /* Error. The intersection-point is outside the surface.  */\n\n err158: *jstat = -158;\n  s6err(\"s1711\",*jstat,kpos);\n  goto out;\n\n\n  /* Error. Allocation error, not enough memory.  */\n\n err101: *jstat = -101;\n  s6err(\"s1711\",*jstat,kpos);\n  goto outfree;\n\noutfree:\n   if(q1) freeSurf(q1);\n   q1 = SISL_NULL;\n   if(q2) freeSurf(q2);\n   q2 = SISL_NULL;\n\n   /* Free local used memory. */\n\nout:\n   /* if(!q1) */\n   /*   { */\n   /*    if (st1) freearray(st1); */\n   /*    if (st1sec) freearray(st1sec); */\n   /*    if (scoef1) freearray(scoef1); */\n   /*   } */\n\n   /* if(!q2) */\n   /*   { */\n   /*    if (st2) freearray(st2); */\n   /*    if (st2sec) freearray(st2sec); */\n   /*    if (scoef2) freearray(scoef2); */\n   /*   } */\n\n   if (kk > 5 && salfa)\n      freearray (salfa);\n   return;\n}\n"
  },
  {
    "path": "src/s1712.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1712.c,v 1.3 2001-03-19 15:58:52 afr Exp $\n *\n */\n\n\n#define S1712\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1712 (SISLCurve * pc, double abeg, double aend, SISLCurve ** rcnew, int *jstat)\n#else\nvoid\ns1712 (pc, abeg, aend, rcnew, jstat)\n     SISLCurve *pc;\n     double abeg;\n     double aend;\n     SISLCurve **rcnew;\n     int *jstat;\n#endif\n/*\n********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE     :To take one part of a open B-spline curve and make a new\n*              curve of the part, if aend < abeg  the new curve is turned.\n*\n*\n*\n* INPUT      : pc     - SISLCurve to take a part of.\n*              abeg     - Start parameter-value of the curve part picked.\n*              aend     - End parameter-value of the curve part picked.\n*\n*\n*\n* OUTPUT     : rcnew      -The new curve that is a part of the orginal curve.\n*              jstat     - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : freeCurve - Free space occupied by given curve-object.\n*              s1710     - Divide a curve into two parts.\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-06.\n* Revised by : Tor Dokken, SI, 26-feb-1988.\n*              Allow for converting from closed to open bases\n* MODIFIED BY : Arne Laksaa, SI, 92-09. Using D(N)EQUAL() insted of (!=)/==.\n*\n**********************************************************************/\n{\n  int kstat;\t\t\t/* Local status variable.           */\n  int kpos = 0;\t\t\t/* Position of error.               */\n  double tbeg, tend;\t\t/* The less and greater point.      */\n  SISLCurve *q1 = SISL_NULL;\t\t/* Pointer to new curve-object.     */\n  SISLCurve *q2 = SISL_NULL;\t\t/* Pointer to new curve-object.     */\n  SISLCurve *q3 = SISL_NULL;\t\t/* Pointer to new curve-object.     */\n  int kturn = 0;\n\n  /* Check that we have a curve to pick a part of. */\n\n  if (!pc)\n    goto err150;\n\n  /* Check that the intersection points are interior points. */\n\n  if ((abeg < pc->et[0] && DNEQUAL(abeg,pc->et[0])) ||\n      (abeg > pc->et[pc->in+pc->ik-1] && DNEQUAL(abeg,pc->et[pc->in+pc->ik-1])))\n    goto err151;\n  if ((aend < pc->et[0] && DNEQUAL(aend,pc->et[0])) ||\n      (aend > pc->et[pc->in+pc->ik-1] && DNEQUAL(aend,pc->et[pc->in+pc->ik-1])))\n    goto err151;\n\n  /* Check that abeg is not like aend. */\n\n  if (DEQUAL(abeg,aend))\n    goto err151;\n\n  if (pc->cuopen == SISL_CRV_PERIODIC)\n  {\n      double delta = pc->et[pc->in] - pc->et[pc->ik - 1];\n\n      if (abeg > aend)\tkturn = 1;\n\n      if (abeg < pc->et[pc->ik - 1] && DNEQUAL(abeg, pc->et[pc->ik - 1]))\n\tabeg += delta;\n      if (abeg > pc->et[pc->in] || DEQUAL(abeg, pc->et[pc->in]))\n\tabeg -= delta;\n\n      if (aend < pc->et[pc->ik - 1] && DNEQUAL(aend, pc->et[pc->ik - 1]))\n\taend += delta;\n      if (aend > pc->et[pc->in] && DNEQUAL(aend, pc->et[pc->in]))\n\taend -= delta;\n\n      if ((abeg > aend && !kturn) || (abeg < aend && kturn))\n\t kturn = 1;\n      else\n\t kturn = 0;\n  }\n\n  /* Find the smaller and greater of the intersection points. */\n\n  if (abeg < aend)\n    {\n      tbeg = abeg;\n      tend = aend;\n    }\n  else\n    {\n      tbeg = aend;\n      tend = abeg;\n    }\n\n  /* Divide into two at each point. The new curve is\n     the middelmost curve.*/\n\n  /* We start with dividing at the first point, and free the curv at\n     left. */\n\n  s1710 (pc, tbeg, &q1, &q2, &kstat);\n  if (kstat < 0)\n    goto err153;\n  /* UJK, periodicity */\n  if (kstat && q1 && !q2)\n    {\n      q2 = q1;\n      q1 = SISL_NULL;\n    }\n  else if (q1)\n    {\n      freeCurve (q1);\n      q1 = SISL_NULL;\n    }\n\n  /* Then we divide at the last point. The curve to left is the new curve.*/\n\n  s1710 (q2, tend, &q1, &q3, &kstat);\n  if (kstat < 0)\n    goto err153;\n  /* BOH, periodicity */\n  if (kstat && !q1 && q3)\n  {\n    q1 = q3;\n    q3 = SISL_NULL;\n  }\n\n  /* The curve is turned if nessesary. */\n\n  if ((abeg > aend && !kturn) || (abeg < aend && kturn))\n    s1706 (q1);\n\n  /* Updating output. */\n\n  *rcnew = q1;\n  *jstat = 0;\n  goto out;\n\n\n/* Error. Error at low level function. */\n\nerr153:\n  *jstat = kstat;\n  goto outfree;\n\n\n/* Error. No curve to pick a part of.  */\n\nerr150:\n  *jstat = -150;\n  s6err (\"s1712\", *jstat, kpos);\n  goto out;\n\n\n/* Error. No part, abeg and aend has illegal values.  */\n\nerr151:\n  *jstat = -151;\n  s6err (\"s1712\", *jstat, kpos);\n  goto out;\n\n\n/* Error in output. */\n\noutfree:\n  if (q1)\n    freeCurve (q1);\n\n\n/* Free local used memory. */\n\nout:\n   if (q2)\n      freeCurve (q2);\n   if (q3)\n      freeCurve (q3);\n   return;\n}\n"
  },
  {
    "path": "src/s1713.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1713.c,v 1.2 2001-03-19 15:58:52 afr Exp $\n *\n */\n\n\n#define S1713\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1713(SISLCurve *pc,double abeg,double aend,SISLCurve **rcnew,int *jstat)\n#else\nvoid s1713(pc,abeg,aend,rcnew,jstat)\n     SISLCurve  *pc;\n     double abeg;\n     double aend;\n     SISLCurve  **rcnew;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE     :To take one part of a closed B-spline curve and make a new\n*              curve of the part. If the routine is used on an open curve\n*              and aend<=abeg then the portion between aend and abeg is\n*              removed by translating the last part of the new curve.\n*              Works also over the seem for periodic curves.\n*\n*\n* INPUT      : pc       - SISLCurve to take a part of.\n*              abeg     - Start parameter-value of the curve part picked.\n*              aend     - End parameter-value of the curve part picked.\n*\n*\n*\n* OUTPUT     : rcnew    - The new curve that is a part of the orginal curve.\n*              jstat    - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : freeCurve - Free space occupied by given curve-object.\n*              s1710     - Divide a curve into two parts.\n*              s1714     - Subdivide closed (periodic) crvs in two.\n*              s1715     - Join two curves into one.\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-06.\n* MODIFIED BY : Ulf J. Krystad, SI, 92-01. Periodic crvs.\n* MODIFIED BY : Arne Laksaa, SI, 92-09. Using D(N)EQUAL() insted of (!=)/==.\n*\n**********************************************************************/\n{\n  int kstat;          /* Local status variable.          */\n  int kpos=0;         /* Position of error.              */\n  double tbeg,tend;   /* The smaller and greater point.  */\n  SISLCurve *q1=SISL_NULL; /* Pointer to new curve-object.    */\n  SISLCurve *q2=SISL_NULL; /* Pointer to new curve-object.    */\n  SISLCurve *q3=SISL_NULL; /* Pointer to new curve-object.    */\n  SISLCurve *q4=SISL_NULL; /* Pointer to new curve-object.    */\n  \n  /* Check that we have a curve to pick a part of. */\n  \n  if (!pc) goto err150;\n  \n  /* Treating periodicity UJK, jan.92 ------- */\n  if (pc->cuopen == SISL_CRV_PERIODIC)\n  {\n     s1714 (pc, abeg, aend, rcnew, &q1, jstat);\n     if (q1) freeCurve(q1);q1=SISL_NULL;\n     goto out;\n  }\n\n  /* Check that the intersection points is interior points. */\n  \n  if ((abeg < pc->et[0] && DNEQUAL(abeg,pc->et[0])) || \n      (abeg > pc->et[pc->in+pc->ik-1] && DNEQUAL(abeg,pc->et[pc->in+pc->ik-1])))\n     goto err151;\n  if ((aend < pc->et[0] && DNEQUAL(aend,pc->et[0])) || \n      (aend > pc->et[pc->in+pc->ik-1] && DNEQUAL(aend,pc->et[pc->in+pc->ik-1])))\n    goto err151;\n      \n  /* Find the smaller and greater of the intersection points. */\n  \n  if (abeg<aend)\n    {\n      tbeg = abeg;\n      tend = aend;\n    } \n  else\n    if (abeg>aend)\n      {\n\ttbeg = aend;\n\ttend = abeg;\n      }\n  \n  if (DEQUAL(abeg,aend))\n  {\n     /* In this case we have just one point to\n\tdevide at. The result is two curves, q1 q1. */\n     \n     s1710(pc,abeg,&q1,&q3,&kstat);\n     if (kstat<0 || kstat==2) goto err153;\n  } \n  else\n  {\n     /* Devide into two at each point,\n\twe than have tree curves, q1 q2 q3.*/\n     \n     s1710(pc,tbeg,&q1,&q4,&kstat);\n     if (kstat<0 || kstat==2) goto err153;\n     \n     s1710(q4,tend,&q2,&q3,&kstat);\n     if (kstat<0 || kstat==2) goto err153;\n     \n     freeCurve(q4);  q4 = SISL_NULL;\n  }\n  \n  /* If nessesary we have to join curve q3 and q1 to get the new curve.*/\n  \n  if (abeg > aend || DEQUAL(abeg,aend))\n  {\n     if (q2) \n     {\n\tfreeCurve(q2);\n\tq2 = SISL_NULL;\n     }\n     if (!q1)\n     {\n\tq2 = q3;\n\tq3 = SISL_NULL;\n     }\n     else if (!q3)\n     {\n\tq2 = q1;\n\tq1 = SISL_NULL;\n     }\n     else\n     {\n\ts1715(q3,q1,1,0,&q2,&kstat);\n\tif (kstat) goto err153;\n     }\n  }\n  \n  /* Updating output. */\n  \n  *rcnew = q2;\n  *jstat = 0;\n  goto out;\n  \n  /* Error. Subrutine error. */\n  \n err153:\n  *jstat = kstat;\n  goto outfree;\n  \n  /* Error. No curve to pick a part of.  */\n  \n err150:\n  *jstat = -150;\n  s6err(\"s1713\",*jstat,kpos);\n  goto out;\n  \n  /* Error. No part, abeg and aend has illegal values.  */\n  \n err151:\n  *jstat = -151;\n  s6err(\"s1713\",*jstat,kpos);\n  goto out;\n  \n  /* Error in output. */\n  \n outfree:\n  if(q2) freeCurve(q2);\n  \n  /* Free local used memory. */\n  \n out:\n  if(q1) freeCurve(q1);\n  if(q3) freeCurve(q3);\n  if(q4) freeCurve(q4);\n  return;\n}\n\n"
  },
  {
    "path": "src/s1714.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1714.c,v 1.2 2001-03-19 15:58:52 afr Exp $\n *\n */\n\n\n#define S1714\n\n#define SISL_CRV_PERIODIC -1\n#define SISL_CRV_OPEN 1\n#define SISL_CRV_CLOSED 0\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1714 (SISLCurve * pc, double apar1, double apar2, SISLCurve ** rcnew1, SISLCurve ** rcnew2, int *jstat)\n#else\nvoid \ns1714 (pc, apar1, apar2, rcnew1, rcnew2, jstat)\n     SISLCurve *pc;\n     double apar1;\n     double apar2;\n     SISLCurve **rcnew1;\n     SISLCurve **rcnew2;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE   :Divide a closed B-spline curve in two parts at two\n*            spesified values. The first curve start at apar1.\n*            If the curve is open the last part of the curve\n*            that is going through the gap between end and start\n*            of the orginal curve is translating .\n*            NOTE: For periodic curves when apar2 < apar1,\n*                  the second curve will hav startparameter\n*                  value shifted one period.\n*\n*\n* INPUT      : pc        - SISLCurve to divide\n*              apar1     - Start parameter-value of the first new curve.\n*              apar2     - Start parameter-value of the second new curve.\n*\n*\n*\n* OUTPUT     : rcnew1    - The first new curve.\n*              rcnew2    - The second new curve.\n*              jstat     - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : freeCurve - Free space occupied by given curve-object.\n*              s1712     - Pick a part of an open curve.\n*              s1713     - Pick a part of a closed curve.\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-06.\n* MODIFIED BY : Ulf J. Krystad, SI, 92-01. Periodic crvs.\n* MODIFIED BY : Arne Laksaa, SI, 92-09. Using D(N)EQUAL() insted of (!=)/==.\n*\n**********************************************************************/\n{\n  int kstat;\t\t\t/* Local status variable.        */\n  int kpos = 0;\t\t\t/* Position of error.            */\n  SISLCurve *q1 = SISL_NULL;\t\t/* Pointer to new curve-object.  */\n  SISLCurve *q2 = SISL_NULL;\t\t/* Pointer to new curve-object.  */\n\n  /* Check that we have a curve to devide. */\n\n  if (!pc)\n    goto err150;\n\n  /* Check that apar1 is not equal apar2. */\n\n  if (DEQUAL (apar1, apar2))\n    goto err151;\n\n  /* Treating periodicity UJK, jan.92 and later ALA, sep.92 ------- */\n  if (pc->cuopen == SISL_CRV_PERIODIC)\n    {\n      double delta = pc->et[pc->in] - pc->et[pc->ik - 1];\n      \n      while(apar1 < pc->et[pc->ik - 1] && DNEQUAL(apar1, pc->et[pc->ik - 1]))\n\t apar1 += delta;\n      while(apar1 > pc->et[pc->in] || DEQUAL(apar1, pc->et[pc->in]))\n\t apar1 -= delta;\n\n      while (apar2 < apar1 || DEQUAL(apar2, apar1))\n\tapar2 += delta;\n      \n      while (apar2 > (apar1+delta) && DNEQUAL(apar2, (apar1+delta)))\n\tapar2 -= delta;\n\n      /* Shift startpoint of curve (and make it ordinary closed )*/\n      s1710 (pc, apar1, &q1, &q2, &kstat);\n      if (kstat < 0)\n\tgoto err153;\n\n      if (q2)\n\tfreeCurve (q2);\n      q2 = SISL_NULL;\n\n      /* Split into two */\n      s1710 (q1, apar2, rcnew1, rcnew2, &kstat);\n      if (kstat < 0)\n\tgoto err153;\n\n\tif (q1)\n\tfreeCurve (q1);\n      q1 = SISL_NULL;\n\n\n      *jstat = 0;\n      goto out;\n    }\n  /* End of treating periodicity UJK, jan.92 ------- */\n\n\n    /* Divide the curve into two at each point.\n     Join the two end curves at each end.*/\n\nif (apar1 < apar2)\n  {\n    s1712 (pc, apar1, apar2, &q1, &kstat);\n    if (kstat)\n      goto err153;\n\n    s1713 (pc, apar2, apar1, &q2, &kstat);\n    if (kstat)\n      goto err153;\n  }\n\nelse\n  {\n    s1712 (pc, apar2, apar1, &q2, &kstat);\n    if (kstat)\n      goto err153;\n\n    s1713 (pc, apar1, apar2, &q1, &kstat);\n    if (kstat)\n      goto err153;\n  }\n\n /* Updating output. */\n\n*rcnew1 = q1;\n*rcnew2 = q2;\n*jstat = 0;\ngoto out;\n\n\n /* Error. Subrutine error. */\n\nerr153:\n*jstat = kstat;\ngoto outfree;\n\n\n /* Error. No curve to pick a part of.  */\n\nerr150:\n*jstat = -150;\ns6err (\"s1714\", *jstat, kpos);\ngoto out;\n\n\n /* Error. No part, apar1 and apar2 has illegal values.  */\n\nerr151:\n*jstat = -151;\ns6err (\"s1714\", *jstat, kpos);\ngoto out;\n\n\n /* Error in output. */\n\noutfree:\nif (q1)\n  freeCurve (q1);\nif (q2)\n  freeCurve (q2);\n\nout:\nreturn;\n}\n"
  },
  {
    "path": "src/s1715.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1715.c,v 1.2 2001-03-19 15:58:52 afr Exp $\n *\n */\n\n\n#define S1715\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1715(SISLCurve *pc1,SISLCurve *pc2,int iend1,int iend2,SISLCurve **rcnew,int *jstat)\n#else\nvoid s1715(pc1,pc2,iend1,iend2,rcnew,jstat)\n     SISLCurve *pc1;\n     SISLCurve *pc2;\n     int   iend1;\n     int   iend2;\n     SISLCurve **rcnew;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To join one end of one B-spline curve with one end of\n*              another B-spline curve by translating the second curve.\n*              If pc1 is to be joined at the start the direction of the\n*              curve is turned, and if pc2 is to be joined at the end\n*              the direction of this curve is turned. This means that\n*              pc1 always is at the beginning at the new curve.\n*\n*\n*\n* INPUT      : pc1     - First curve to join.\n*              pc2     - Second curv to join.\n*              iend1   - True(1) if the first curv is to be\n*                        joined et the end, else false(0).\n*              iend2   - True(1) if the second curv is to be\n*                        joined at the end, else false(0).\n*\n*\n*\n* OUTPUT     : rcnew   - The new joined curve.\n*              jstat   - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : We have to turn the first curve if iend1=0\n*              and the second curve if iend2=1.\n*              Then we translate the second curve so the gap\n*              between the first and second curvde disappear.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newCurve  - Allocate space for a new curve-object.\n*              freeCurve - Free space occupied by given curve-object.\n*              S1750.C   - Making one curve at a higer degree.\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-06.\n* REVISED BY : Johannes Kaasa, SI, Sep 1991 (Introduced NURBS)\n*\n**********************************************************************/\n{\n  int kstat=0;            /* Local status variable.                     */\n  int kpos=0;             /* Position of error.                         */\n  int kcopy=0;            /* To mark if pc1 (1) or pc2 (2) is\n\t\t\t     changed to point at a local copy.          */\n  int km1=0,km2=0;        /* Knot mutiplicety at the end to join.       */\n  int km2end=0;           /* Knot mutiplicety at the end of the\n\t\t\t     second curve.                              */\n  int kk;                 /* Order of the new curve.                    */\n  int kn;                 /* Number of the vertices in the new curve.   */\n  int kdim;               /* Dimensjon of the space in whice curve lies.*/\n  int routdim;            /* Rational dimension of the output curve.    */\n  int kn1=pc1->in;        /* Number of vertices in the old curves.      */\n  int kn2=pc2->in;        /* Number of vertices in the old curves.      */\n  int ki,kj;              /* Control variable in loop, and others.      */\n  double tdel;            /* The translation of the knots to the\n\t\t\t     second curve.                              */\n  double *s1,*s2,*s3; \t  /* Pointers used in loop.                     */\n  double *stran=SISL_NULL;     /* The translation vector to vertices.        */\n  double *st=SISL_NULL;        /* The new knot-vector.                       */\n  double *scoef=SISL_NULL;     /* The new vertice.                           */\n  SISLCurve *qc=SISL_NULL;     /* Pointer to the new curve-object.           */\n  \n  int ktype;              /* Type of curves:                            */\n                          /* = 1 : Both are B-splines                   */\n                          /* = 2 : pc1 is B-spline and pc2 is NURBS     */\n                          /* = 3 : pc1 is NURBS and pc2 is B-spline     */\n                          /* = 4 : Both are NURBS                       */\n  int knumb;              /* Number of vertices.                        */\n  double weight;          /* Rational weight.                           */\n  double *u1,*u2;         /* Utility pointers into the vertices.        */\n\n  /* Check that we have curves to join. */\n  \n  if (!pc1 || !pc2) goto err150;\n\n  /* Check that The curves is in the same room, have the same kdim. */\n  \n  if (pc1->idim != pc2->idim) goto err106;\n  else kdim = pc1->idim;\n\n  /* Check the type of the curves. */\n\n  if (pc1->ikind == 2 || pc1->ikind == 4)\n    {\n      if (pc2->ikind == 2 || pc2->ikind == 4)\n        {\n          ktype = 4;\n          routdim = kdim + 1;\n        }\n      else\n        {\n          ktype = 3;\n          routdim = kdim + 1;\n        }\n    }\n  else\n    {\n      if (pc2->ikind == 2 || pc2->ikind == 4)\n        {\n          ktype = 2;\n          routdim = kdim + 1;\n        }\n      else\n        {\n          ktype = 1;\n          routdim = kdim;\n        }\n    }\n  \n  /* Allocate a kdim array to store the translation of the second curv.*/\n  \n  if ((stran=newarray(kdim,double)) == SISL_NULL) goto err153;\n  \n  /* Checking the order of the curves, and raise the order if nessesary.*/\n  \n  if (pc1->ik < pc2->ik)\n    {\n      kcopy=1;\n      kk=pc2->ik;\n      s1750(pc1,kk,&pc1,&kstat);\n      if (kstat) goto err153;\n    } \n  else\n    if (pc2->ik < pc1->ik)\n      {\n\tkcopy=2;\n\tkk=pc1->ik;\n\ts1750(pc2,kk,&pc2,&kstat);\n\tif (kstat) goto err153;\n      } \n    else\n      kk = pc1->ik;\n  \n  /* Finding the knot multiplicity at the juinction, km1 km2.\n     At the end thats  going to be the end of the new curve\n     we also need to know the knot mutiticeply, km2end. */\n  \n  /* Having raised the order of the curves if necessary,\n     remember the number of vertices in the two curves. */\n\n  kn1=pc1->in;\n  kn2=pc2->in;\n\n  if (iend1) \n    while (pc1->et[kn1+kk-1-km1] == pc1->et[kn1+kk-1]) km1++;\n  else        \n    while (pc1->et[km1] == *pc1->et) km1++;\n  if (iend2)\n    {\n      while (pc2->et[kn2+kk-1-km2] == pc2->et[kn2+kk-1]) km2++;\n      while (pc2->et[km2end] == *pc2->et) km2end++;\n    } \n  else\n    {\n      while (pc2->et[km2] == *pc2->et) km2++;\n      while (pc2->et[kn2+kk-1-km2end] == pc2->et[kn2+kk-1]) km2end++;\n    }\n  \n  /* Find the number of vertices in the new curve. */\n  \n  kn = kn1 + kn2 + 3*kk - km1 - km2 - km2end -1;\n  \n  /* Allocating the new arrays to the new curve. */\n  \n  if ((st=newarray(kn+kk,double))==SISL_NULL) goto err101;\n  if ((scoef=newarray(kn*routdim,double))==SISL_NULL) goto err101;\n  \n  /* Copying the knotvectors from the old curve to the new curves */\n  /****************************************************************/\n  \n  /* The first curve. */\n  \n  if (iend1)     /* The junction is at the end of the first curve. */\n    {\n      /* Copying all knots from the first curve that is different\n\t from the last knot. */\n      \n      memcopy(st,pc1->et,kn1+kk-km1,double);\n      \n      /* Making a kk-1 touple knot at the junction. */\n      \n      for (s1=st+kn1+kk-km1,s2=s1+kk-1; s1<s2; s1++)\n\t*s1=pc1->et[kn1+kk-1];\n      \n    } \n  else     /* The junction is at the beginning of the first curve. */\n    {\n      /* Computing the factor to turn the first knotvector. */\n      \n      tdel = *pc1->et + pc1->et[kn1+kk-1];\n\t\n      /* Copying and turning the first knot vector except the\n\t knots at the junction. */\n      \n      for (s1=st,s2=pc1->et+km1,s3=pc1->et+kn1+kk-1; s2<=s3; s1++,s3--)\n\t*s1 = tdel - *s3;\n      \n      /* Making a kk-1 touple knot at the junction. */\n      \n      for (s2--,s3=s1+kk-1; s1<s3; s1++) *s1= tdel - *s2;\n    }\n  \n  /* The second curve. */\n  \n  s2 = st+kn+kk-max(0,kk-km2end); /* The border for the last exsisting knot \n\t\t\t\t     in the new knot vector. */\n  \n  if (!iend2)  /* The junction is at the begining of the second curve. */\n    {\n      /* Computing what the second knot vector has to be translated\n\t to get a kontinue total knotvector. */\n      \n      tdel = s1[-1] - *pc2->et;\n      \n      /* copying and translating all knots except the knots\n\t at the junction. */\n      \n      for (s3=pc2->et+km2; s1<s2; s1++,s3++) *s1 = *s3 + tdel;\n    } \n  else\n    {\n      /* Coputing a factor to both translate and turn the knots. */\n      \n      tdel = pc2->et[kn2+kk-1] + s1[-1];\n      \n      /* Turning and translating all knots exept the knots\n\t at the junction. */\n\t\n      for (s3=pc2->et+kn2+kk-km2-1; s1<s2; s1++,s3--) *s1 =tdel- *s3;\n    }\n  \n  /* Inserting new knots such that we have a kk touple knot at the end.*/\n  \n  for (ki=0; ki<kk-km2end; ki++)  s1[ki] = s1[-1];\n  \n  /* Copying the coeffesientvectors to the new curves.*/\n  /***************************************************/\n  \n  /* Copying the first coeffisientvector. */\n  \n  knumb = min(kn1,kn1+kk-km1);\n  ki = routdim*knumb;\n  if (iend1)                        /* Just copying. */\n    {\n      if (ktype == 1)\n        memcopy(scoef,pc1->ecoef,ki,double);\n      else if (ktype == 2)\n        {\n          for (kj=0; kj<knumb; kj++)\n            {\n              u1 = scoef + kj*routdim;\n              u2 = pc1->ecoef + kj*kdim;\n              memcopy(u1,u2,kdim,double);\n              scoef[kj*routdim + kdim] = 1.;\n            }\n        }\n      else if (ktype == 3 || ktype == 4) \n        memcopy(scoef,pc1->rcoef,ki,double);\n      s1 = scoef +ki;\n    }\n  else                              /* Copying back to front. */\n    {\n      if (ktype == 2)\n        {\n          s2 = pc1->ecoef;\n          s3 = s2 + kdim*(knumb - 1);\n          for (s1=scoef; s2<=s3; s3-=2*kdim)\n            {\n              for (ki=0; ki<kdim; ki++,s1++,s3++)  *s1 = *s3;\n              *s1 = 1.;\n              s1++;\n            } \n        }\n      else\n        {\n          if (ktype == 1)\n            s2 = pc1->ecoef;\n          else\n            s2 = pc1->rcoef; \n          for (s1=scoef,s3=s2+ki-routdim; s2<=s3; s3-=2*routdim)\n            for (ki=0; ki<routdim; ki++,s1++,s3++)  *s1 = *s3;\n        }\n    }\n\n  /* If there is less than a kk touple knot at the end of the first curve\n     than we have to inserte zeroes. */\n  \n  for (s2=s1+routdim*max(0,kk-km1); s1<s2; s1+=routdim)\n    {\n      for (ki=0; ki<kdim; ki++)\n        s1[ki] = DZERO;\n      if (ktype != 1)\n        s1[kdim] = 1.;\n    }\n  \n  /* Compute the translation of the second curv. */\n  \n  for (ki=0; ki<kdim; ki++)\n    {\n      if (km2<kk) stran[ki] = DZERO;\n      else\n\tstran[ki] = iend2? pc2->ecoef[kdim*(kn2-max(0,km2-kk)-1)+ki]:\n\t  pc2->ecoef[kdim*max(0,km2-kk)+ki];\n      if (km1>=kk)\n\tstran[ki] -= iend1? pc1->ecoef[kdim*(kn1-max(0,km1-kk)-1)+ki]:\n\t  pc1->ecoef[kdim*max(0,km1-kk)+ki];\n    }\n  \n  \n  /* Copying the second coefficientvector. */\n  \n  /* Findig the startpoint for copying in the old coeffisient vector. */\n  \n  if (iend2)\n    {\n      if (ktype == 1 || ktype == 3)\n        s3=pc2->ecoef+kdim*(kn2-max(0,km2-kk)-1);\n      else\n        s3=pc2->rcoef+routdim*(kn2-max(0,km2-kk)-1);\n    }\n  else\n    {\n      if (ktype == 1 || ktype == 3) \n        s3=pc2->ecoef+kdim*max(0,km2-kk);\n      else\n        s3=pc2->rcoef+routdim*max(0,km2-kk);\n    }\n  \n  if (km2<kk)\n    {\n      /* If km2<kk-1 we have to insert zeroes and than transform. */\n      \n      for (kj=km2+1; kj<kk; kj++,s2+=routdim)\n        {\n\t  for (ki=0; ki<kdim; ki++,s1++) *s1 = -stran[ki];\n          if (ktype != 1)\n            {\n              *s1 = 1.;\n              s1++;\n            }\n        }       \n\n      /* Copying and transforming the first coeffisients. */\n      \n      if (ktype == 1) \n        for (ki=0; ki<kdim; ki++,s1++,s3++) *s1 = *s3 - stran[ki];\n      else\n        {\n          if (ktype == 3)\n            weight = 1.;\n          else\n            weight = s3[kdim];\n          for (ki=0; ki<kdim; ki++,s1++,s3++) *s1 = *s3 - stran[ki]*weight;\n          *s1 = weight;\n          s1++;\n          if (ktype != 3) s3++;\n        } \n    } \n  else\n    if (ktype == 1 || ktype == 3)\n      s3+=kdim;     /* Skiping the first coeffisients. */\n    else  \n      s3+=routdim;     /* Skiping the first coeffisients. */\n\n  /* Copying and transforming the coeffisient from the second curve. */\n  \n  for (s2=scoef+routdim*min(kn,kn-kk+km2end); s1<s2;)\n    {\n      if (iend2)\n        {\n          if (ktype == 1 || ktype == 3)\n            s3-=2*kdim;\n          else\n            s3-=2*routdim;\n        } \n      if (ktype == 1) \n        for (ki=0; ki<kdim; ki++,s1++,s3++) *s1 = *s3 - stran[ki];\n      else\n        {\n          if (ktype == 3)\n            weight = 1.;\n          else\n            weight = s3[kdim];\n          for (ki=0; ki<kdim; ki++,s1++,s3++) *s1 = *s3 - stran[ki]*weight;\n          *s1 = weight;\n          s1++;\n          if (ktype != 3) s3++;\n        }\n    }\n  \n  /* Insert and transform from zeroes if we do not have a kk touple\n     knot at the end of the second curve. */\n  \n  for (kj=0; kj<kk-km2end; kj++)\n    {\n      for (ki=0; ki<kdim; ki++,s1++)  *s1 = -stran[ki];\n      if (ktype != 1)\n        {\n          *s1 = 1.;\n          s1++;\n        }\n    }\n  \n  /* Create the new curve. */\n  \n  if (ktype == 1)\n    {\n      if ((qc=newCurve(kn,kk,st,scoef,1,kdim,2)) == SISL_NULL) goto err101;\n    }\n  else\n      if ((qc=newCurve(kn,kk,st,scoef,2,kdim,2)) == SISL_NULL) goto err101;\n  \n  /* Updating output. */\n  \n  *rcnew = qc;\n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error. Subrutine error. */\n  \n err153:\n  *jstat = kstat;\n  goto outfree;\n  \n  \n  /* Error. No curve to subdevice.  */\n  \n err150:\n  *jstat = -150;\n  s6err(\"s1715\",*jstat,kpos);\n  goto out;\n  \n  \n  /* Error. Different dimensjon of the room.  */\n  \n err106:\n  *jstat = -106;\n  s6err(\"s1715\",*jstat,kpos);\n  goto out;\n  \n  \n  /* Error. Allocation error, not enough memory.  */\n  \n err101:\n  *jstat = -101;\n  s6err(\"s1715\",*jstat,kpos);\n  goto outfree;\n  \n  \n outfree:\n  if(qc) \n    freeCurve(qc);\n  else\n    {\n      if (st) freearray(st);\n      if (scoef) freearray(scoef);\n    }\n  \n  /* Free local used memory. */\n  \n out: \n  if (stran) \n    freearray(stran);\n  if (kcopy == 1) \n    freeCurve(pc1);\n  else\n    if (kcopy == 2) freeCurve(pc2);\n  return;\n}\n\n"
  },
  {
    "path": "src/s1716.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1716.c,v 1.3 2001-03-19 15:58:52 afr Exp $\n *\n */\n\n\n#define S1716\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1716(SISLCurve *pc1,SISLCurve *pc2,\n\t   double aeps,SISLCurve **rcnew,int *jstat)\n#else\nvoid s1716(pc1,pc2,aeps,rcnew,jstat)\n     SISLCurve  *pc1;\n     SISLCurve  *pc2;\n     double aeps;\n     SISLCurve  **rcnew;\n     int    *jstat;\n#endif\n/*\n********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To join the closest of one B-spline curve with the closest\n*              end of another B-spline curve by translating the second curve\n*              if the curves are closer to each other than aeps.\n*              If pc1 is to be joined at the start the direction of the\n*              curve is turned, and if pc2 is to be joined at the end\n*              the direction of this curve is turned. This means that\n*              pc1 always is at the beginning at the new curve.\n*              If aeps is to small to any joining a SISL_NULL pointer is returned.\n*\n*\n* INPUT      : pc1     - First curve to join.\n*              pc2     - Second curv to join.\n*              aeps    - The curves is to be joined if aeps is greater or\n*                        like the distance between the closest end.\n*                        If aeps is negativ the curve automaticaly is joined.\n*\n*\n*\n* OUTPUT     : rcnew   - The new joined curve.\n*              jstat   - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : First we are finding the smallest distens between\n*              curves. If this distens is smaller than aeps the curves\n*              are joining at the closest ends\n*\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newCurve  - Allocate space for a new curve-object.\n*              freeCurve - Free space occupied by given curve-object.\n*              s1715.c   - Join two curves at specified ends.\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-06.\n* Revised by : Paal Fugelli. SINTEF, Oslo, Norway, Sept. 1994.  Fixed array\n*              bounds over-running.\n*\n**********************************************************************/\n{\n  int kstat;              /* Local status variable.                  */\n  int kpos=0;             /* Position of error.                      */\n  int knr;                /* Number to mark type of junction.        */\n  int km11=0,km12=0;      /* Knot mutiplicety at the ends of\n\t\t\t     the first curve.                        */\n  int km21=0,km22=0;      /* Knot mutiplicety at the ends of\n\t\t\t     the second curve.                       */\n  int kdim;               /* Dimensjon of the space in whice curves\n\t\t\t     lies.                                   */\n  int kk1=pc1->ik;        /* The order of the first old curve.       */\n  int kk2=pc2->ik;        /* The order of the second old curve.      */\n  int kn1=pc1->in;        /* Number of vertices in the old curves.   */\n  int kn2=pc2->in;        /* Number of vertices in the old curves.   */\n  int ki,kj1,kj2;      /* Control variable in loop, and others.   */\n  double t1,tdel,tdelmin; /* The translation of the knots to the\n\t\t\t     second curve.                           */\n  SISLCurve *qc=SISL_NULL;         /* Pointer to the new curve-object.        */\n\n  /* Check that we have curves to join. */\n\n  if (!pc1 || !pc2) goto err150;\n\n  /* Check that The curves is in the same room, have the same kdim. */\n\n  if (pc1->idim != pc2->idim) goto err106;\n  else kdim = pc1->idim;\n\n  /* Finding the knot multiplicity at the ends. */\n\n  while (pc1->et[km11] == *pc1->et) km11++;\n  while (pc1->et[kn1+kk1-1-km12] == pc1->et[kn1+kk1-1]) km12++;\n  while (pc2->et[km21] == *pc2->et) km21++;\n  while (pc2->et[kn2+kk2-1-km22] == pc2->et[kn2+kk2-1]) km22++;\n\n  /* Finding the smallest distance between the ends. */\n\n  /* First we compute the square distance between the start of both\n     curves, Then we mark this to be the shortest. */\n\n  for (tdel=DZERO,ki=0; ki<kdim; ki++)\n    {\n      if (km11<kk1)  t1 = DZERO;\n      else           t1 = pc1->ecoef[kdim*(km11-kk1)+ki];\n      if (km21>=kk2) t1 -= pc2->ecoef[kdim*(km21-kk2)+ki];\n      tdel += t1*t1;\n    }\n  tdelmin = tdel;\n  knr = 0;\n\n  /* The start of the first curve and the end of the second curve. */\n\n  for (tdel=DZERO,ki=0; ki<kdim; ki++)\n    {\n      if (km11<kk1)  t1 = DZERO;\n      else           t1 = pc1->ecoef[kdim*(km11-kk1)+ki];\n      if (km22>=kk2) t1 -= pc2->ecoef[kdim*(kn2-1-km22+kk2)+ki];\n      tdel += t1*t1;\n    }\n  if (tdel<tdelmin)\n    {\n      tdelmin = tdel;\n      knr = 1;\n    }\n\n  /* The end of the first curve and the start of the second curve. */\n\n  for (tdel=DZERO,ki=0; ki<kdim; ki++)\n    {\n      if (km12<kk1)  t1 = DZERO;\n      else           t1 = pc1->ecoef[kdim*(kn1-1-km12+kk1)+ki];\n      if (km21>=kk2) t1 -= pc2->ecoef[kdim*(km21-kk2)+ki];\n      tdel += t1*t1;\n    }\n  if (tdel<tdelmin)\n    {\n      tdelmin = tdel;\n      knr = 2;\n    }\n\n  /* The end of the first curve and the end of the second curve. */\n\n  for (tdel=DZERO,ki=0; ki<kdim; ki++)\n    {\n      if (km12<kk1)  t1 = DZERO;\n      else           t1 = pc1->ecoef[kdim*(kn1-1-km12+kk1)+ki];\n      if (km22>=kk2) t1 -= pc2->ecoef[kdim*(kn2-1-km22+kk2)+ki];\n      tdel += t1*t1;\n    }\n  if (tdel<tdelmin)\n    {\n      tdelmin = tdel;\n      knr = 3;\n    }\n\n\n  if (aeps < DZERO || aeps >= sqrt(tdelmin))\n    {\n      /* We mark what ends we are going to use in the junction.\n\t and then call a function to join the curves. */\n\n      if (knr<2) kj1 = 0;\n      else        kj1 = 1;\n\n      if (knr==0 || knr==2) kj2 = 0;\n      else                kj2 = 1;\n\n\n      s1715(pc1,pc2,kj1,kj2,&qc,&kstat);\n      if (kstat) goto err153;\n    } else\n      {\n\t/* Aeps was to small We just have to return SISL_NULL. */\n\n\tqc = SISL_NULL;\n      }\n\n\n  /* Updating output. */\n\n  *rcnew = qc;\n  *jstat = 0;\n  goto out;\n\n\n  /* Error. Subrutine error. */\n\n err153:\n  *jstat = kstat;\n  goto outfree;\n\n\n  /* Error. No curve to subdevice.  */\n\n err150:\n  *jstat = -150;\n  s6err(\"s1716\",*jstat,kpos);\n  goto out;\n\n\n  /* Error. Different dimensjon of the room.  */\n\n err106:\n  *jstat = -106;\n  s6err(\"s1716\",*jstat,kpos);\n  goto out;\n\n\n outfree:\n  if(qc) freeCurve(qc);\n\n\n out:\n  return;\n}\n"
  },
  {
    "path": "src/s1720.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1720.c,v 1.3 2001-03-19 15:58:52 afr Exp $\n *\n */\n\n\n#define S1720\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1720(SISLCurve *pc,int ider,SISLCurve **rcnew,int *jstat)\n#else\nvoid s1720(pc,ider,rcnew,jstat)\n     SISLCurve *pc;\n     int   ider;\n     SISLCurve **rcnew;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To express the ider-th derivative of a B-pline curve\n*              as a B-spline curve with order ider less than the\n*              orginal B-spline curve.\n*\n*\n*\n* INPUT      : pc       - SISLCurve to make a derivative from.\n*              ider     - The derevative to be produced. 0 <= ider < pc->ik.\n*\n*\n*\n* OUTPUT     : rcnew    - The result of the ider differentiation of pc.\n*              jstat    - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : For each ider differentiation we go through the vertices and\n*              compute new vertices with use of a recursion formula.\n*              At last the curve is checked removing redundant knots and\n*              vertices.\n*\n*\n* REFERENCES : Larry L. Schumaker, Spline Functions:Basic Theory.  p.195.\n*              Carl de Boor, A Practial Guide to Spline.           p.139.\n*\n*-\n* CALLS      : newCurve  - Allocate space for a new curve-object.\n*              freeCurve - Free space occupied by given curve-object.\n*              s1705.c   - Remove unnecesery knots and vertices from a curve.\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-06.\n* REVISED BY : Johannes Kaasa, SI, May 1992 (Added the NURBS handling.\n*              Remark that the ider-th derivate of a NURBS curve of order\n*              k has order (ider + 1)*k - ider. Remark also that we have to\n*              use a completely different method for NURBS).\n* REVISED BY : Christophe Birkeland, SI, 92-07 (remove unnecessary\n*              knots in this routine (not in s1905), also testing if\n*              ider=0).\n* REVISED BY : Christophe Rene Birkeland, SINTEF, May 1993.\n*              *jstat = 0   in start of routine.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Oct. 1994.  Changed icopy\n*              flag from '1' to '2' for 'qc1' in the NURBS case - to reduce\n*              memory needs and remove memory leak from 'scoef' and 'st'.\n*              NOTE: this routine doesn't handle closed case correctly and\n*              it also doesn't handle the periodic NURBS case correctly.\n*\n**********************************************************************/\n{\n  int kstat;             /* Local status variable.                  */\n  int kpos=0;            /* Error posision.                         */\n  int kk;                /* Order of the output curve.              */\n  int kn;                /* Number of the vertices in output curves.*/\n  int kdim=pc->idim;     /* Dimension of the space in which\n\t\t\t    the curves lies.                        */\n  int kj;                /* Control variable in loop.               */\n  double tdel;           /* Help variabel.                          */\n  double *s1,*s2,*s3;    /* Pointers used in loop.                  */\n  double *st=SISL_NULL;       /* The first new knot-vector.              */\n  double *scoef=SISL_NULL;    /* The first new vertice.                  */\n  SISLCurve *q1=SISL_NULL;    /* Pointer to new curve-object.            */\n\n  /* NURBS variables: */\n  SISLCurve *rat=SISL_NULL;   /* The denominator curve.                  */\n  double *ratcoef=SISL_NULL;  /* The vertices of rat.                    */\n  int rdim;              /* Rational dimension.                     */\n  double eps;            /* Knot equality resolution.               */\n  int multadd;           /* Added multiplicity of interior knots.   */\n  int mult;              /* Original multiplicity of the knots.     */\n  int oldprev;           /* Previous index in the original knots.   */\n  int oldcurr;           /* Current index in the original knots.    */\n  int newcurr;           /* Current index in the new knots.         */\n  double *par = SISL_NULL;    /* Parameter values used for interpolation */\n  int *der = SISL_NULL;       /* The derivative indicators (= 0).        */\n  double *deriv = SISL_NULL;  /* The derivates returned by s1221.        */\n  double *tau = SISL_NULL;    /* Interpolation points.                   */\n  double denom;          /* The denominator.                        */\n  int left = 0;          /* Interval indicator.                     */\n  int ki;                /* Index in for loop.                      */\n\n  /* Initialization */\n\n  *jstat = 0;\n\n  /* Check that we have a curve to differentiable. */\n\n  if (!pc) goto err150;\n\n  /* Check that the number of derivation is legal. */\n\n  if (ider < 0) goto err156;\n\n  /* If ider = 0; just copy input-curve to output and return */\n\n  if (ider == 0)\n  {\n     if (pc->ikind == 2 || pc->ikind == 4)\n     {\n\tif ((*rcnew=newCurve(pc->in,pc->ik,pc->et,pc->rcoef,\n\t\t\t    pc->ikind,pc->idim,1)) == SISL_NULL)\n\t   goto err101;\n     }\n     else\n     {\n\tif ((*rcnew=newCurve(pc->in,pc->ik,pc->et,pc->ecoef,\n\t\t\t    pc->ikind,pc->idim,1)) == SISL_NULL)\n\t   goto err101;\n     }\n     goto out;\n  }\n\n  if (pc->ikind == 2 || pc->ikind == 4)\n  {\n\n     /* NURBS curve. */\n\n     rdim = kdim + 1;\n\n     /* Make the denominator curve. */\n\n     ratcoef = newarray(pc->in, DOUBLE);\n     for (kj=0; kj<pc->in; kj++)\n\tratcoef[kj] = pc->rcoef[(kj + 1)*rdim - 1];\n     rat = newCurve(pc->in, pc->ik, pc->et, ratcoef, 1, 1, 1);\n\n     /* Make resolution for testing of knot equality. */\n\n     eps = fabs(pc->et[pc->in] - pc->et[pc->ik - 1])*REL_PAR_RES;\n\n     /* Make the new knot vector. */\n\n     kn = 0;\n     kk = (ider + 1)*pc->ik - ider;\n     multadd = ider*pc->ik;\n     st = newarray((2 + pc->in - pc->ik)*kk, DOUBLE);\n\n     for (newcurr=0; newcurr<kk; newcurr++)\n     {\n\tst[newcurr] = pc->et[pc->ik - 1];\n        kn++;\n     }\n\n     oldcurr = pc->ik;\n     oldprev = oldcurr;\n     while ((pc->et[oldcurr] + eps) < pc->et[pc->in])\n     {\n\tmult = 0;\n\twhile ((pc->et[oldcurr] - pc->et[oldprev]) < eps)\n\t{\n\t   oldcurr++;\n\t   mult++;\n\t}\n\tmult += multadd;\n\tif (mult > kk) mult = kk;\n\tfor (kj=0; kj<mult; kj++)\n\t{\n\t   st[newcurr + kj] = pc->et[oldprev];\n\t   kn++;\n\t}\n\tnewcurr += mult;\n\toldprev = oldcurr;\n     }\n\n     for (kj=0; kj<kk; kj++)\n\tst[newcurr + kj] = pc->et[pc->in];\n\n     /* Calculate parameter values and derivate indicators. */\n\n     s1890(st, kk, kn, &par, &der, &kstat);\n     if (kstat < 0) goto error;\n\n     /* Calculate interpolation points. */\n\n     deriv = newarray((ider + 1)*kdim, DOUBLE);\n     tau = newarray(kn*rdim, DOUBLE);\n\n     for (kj=0; kj<kn; kj++)\n     {\n\ts1221(rat, 0, par[kj], &left, &denom, &kstat);\n\tif (kstat < 0) goto error;\n\tdenom = pow(denom, (ider + 1));\n\ts1221(pc, ider, par[kj], &left, deriv, &kstat);\n\tif (kstat < 0) goto error;\n\tfor (ki=0; ki<kdim; ki++)\n           tau[kj*rdim + ki] = deriv[ider*kdim + ki]*denom;\n        tau[kj*rdim + kdim] = denom;\n     }\n\n     /* Make the new curve description. */\n\n     s1891(par, tau, rdim, kn, 1, der, TRUE, st, &scoef, &kn,\n\t   kk, 0, 0, &kstat);\n     if (kstat < 0) goto error;\n\n     q1 = newCurve(kn, kk, st, scoef, pc->ikind, pc->idim, 2);\n     /* (Note, copy == 2, so don't free 'st' or 'scoef' on exit). */\n\n     /* Free allocated geometry. */\n\n     if (rat != SISL_NULL) freeCurve(rat);\n     rat = SISL_NULL;\n     if (ratcoef != SISL_NULL) freearray(ratcoef);\n     ratcoef = SISL_NULL;\n     if (par != SISL_NULL) freearray(par);\n     par = SISL_NULL;\n     if (der != SISL_NULL) freearray(der);\n     der = SISL_NULL;\n     if (deriv != SISL_NULL) freearray(deriv);\n     deriv = SISL_NULL;\n     if (tau != SISL_NULL) freearray(tau);\n     tau = SISL_NULL;\n\n  }\n  else\n  {\n     /* Not NURBS. */\n\n     /* Find the number of vertices kn and the order kk for\n        the derivative curve. */\n\n     if (ider >= pc->ik)\n       {\n         kn = pc->in + pc->ik -1;\n         kk = 1;\n       }\n     else\n       {\n         kn = pc->in + ider;\n         kk = pc->ik - ider;\n       }\n\n     /* Allocating the new arrays to the new curve. */\n\n     if ((st=newarray(kn+kk,double))==SISL_NULL) goto err101;\n     if ((scoef=new0array(kn*kdim,double))==SISL_NULL) goto err101;\n\n     /* Copying the knot vectors from the old curve to the new curve. */\n\n     memcopy(st,pc->et,kn+kk,double);\n\n     /* Copying the coeffisient vector from the old curve to the new curve.*/\n\n     if (ider < pc->ik) memcopy(scoef,pc->ecoef,pc->in*kdim,double);\n\n     /* Here we are computing a new coeffecient vector for each round. */\n\n     if (ider < pc->ik)\n       for (kj=1; kj<=ider; kj++)\n         {\n\t   kk =pc->ik - kj;      /* The new order of the curve. */\n\n\t   s1 = scoef + (pc->in-1+kj)*kdim; /* The last new vertice. */\n\n\t   /* Here I just refere to the referenses.\n\t      The new vertices are computig from back to front,\n\t      and the \"last\" kdim vertices is beeing computed outside\n\t      the main loop because we did not have scoef[-1],\n\t      instead we use zeroes. */\n\n\t   for (s3=st+pc->in-1+kj; st<s3; s3--,s1-=2*kdim)\n             {\n\t       tdel = s3[kk] - *s3;\n\n\t       if (DNEQUAL(tdel,DZERO))\n\t         for (s2=s1+kdim; s1<s2; s1++)\n\t\t   *s1=(*s1-s1[-kdim])*kk/tdel;\n\t       else\n\t         for (s2=s1+kdim; s1<s2; s1++) *s1 = DZERO;\n             }\n\n\t   tdel = s3[kk] - *s3;\n\n\t   if (DNEQUAL(tdel,DZERO))\n\t     for (s2=s1+kdim; s1<s2; s1++) *s1 = *s1*kk/tdel;\n\t   else\n             for (s2=s1+kdim; s1<s2; s1++) *s1 = DZERO;\n\n         }\n\n     /* Allocating new curve-object.*/\n\n     if ((q1=newCurve(kn-2,kk,&st[1],&scoef[pc->idim],1,pc->idim,1))\n\t == SISL_NULL) goto err101;\n     freearray(st);\n     freearray(scoef);\n  }\n\n\n  /* Remove unnessesary internal knots and vertises. */\n\n  s1705(q1,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Set periodicity flag if cyclic curve.  */\n\n  test_cyclic_knots(q1->et,q1->in,q1->ik,&kstat);\n  if (kstat<0) goto error;\n  if (kstat == 2) q1->cuopen = SISL_CRV_PERIODIC;\n\n  /* Updating output. */\n\n  *rcnew = q1;\n  goto out;\n\n  /* Error. Error in lower level function. */\n\n error:\n  *jstat = kstat;\n  goto outfree;\n\n  /* Error. No curve to subdevice.  */\n\n err150:\n  *jstat = -150;\n  s6err(\"s1720\",*jstat,kpos);\n  goto out;\n\n  /* Error. Ileagal number of derevatives.  */\n\n err156:\n  *jstat = -156;\n  s6err(\"s1720\",*jstat,kpos);\n  goto out;\n\n  /* Error. Allocation error, not enough memory.  */\n\n err101:\n  *jstat = -101;\n  s6err(\"s1720\",*jstat,kpos);\n  goto outfree;\n\n outfree:\n  if(q1) freeCurve(q1);\n  else\n    {\n      if (st) freearray(st);\n      if (scoef) freearray(scoef);\n    }\n\n  /* Free local used memory. */\n\n out: return;\n}\n"
  },
  {
    "path": "src/s1730.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1730.c,v 1.3 2001-03-19 15:58:52 afr Exp $\n *\n */\n\n\n#define S1730\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1730(SISLCurve *pc,SISLCurve **rcnew,int *jstat)\n#else\nvoid s1730(pc,rcnew,jstat)\n     SISLCurve *pc;\n     SISLCurve **rcnew;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To convert a B-spline curve to a sequence of Bezier\n*              curves.\n*\n*\n* INPUT      : pc        - SISLCurve to convert.\n*\n*\n*\n* OUTPUT     : rcnew     - The new Bezier represented curve .\n*              jstat     - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Inserting knots until all knots\n*              have multiplisity pc->ik.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newarray  - Allocate space for array of given type.\n*              new0array - Allocate space whith zero values.\n*              freearray - Free space occupied by given array.\n*              newCurve  - Allocate space for a new curve-object.\n*              freeCurve - Free space occupied by given curve-object.\n*              S1701.C   - Making the knot-inserten-transformation matrix.\n*              make_cv_kreg - Ensure that the input curve is k-regular.\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-11.\n* REVISED BY : Johannes Kaasa, SI, May 1992 (Inroduced NURBS)\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Sept. 1994. Moved free'ing\n*              of 'qkreg' from label 'outfree' to label 'out'.\n*\n**********************************************************************/\n{\n  register int ki,ki1,ki2; /* Control variable in loop.                */\n  register int kj,kj1,kj2; /* Control variable in loop.                */\n  register double *s1;   /* Pointers used in loop.                     */\n  int kstat;             /* Local status variable.                     */\n  int kpos=0;            /* Position of error.                         */\n  int kmy;               /* An index to the knot-vector.               */\n  int kpl,kfi,kla;       /* To posisjon elements in trans.-matrix.     */\n  int kk=pc->ik;         /* Order of the input curve.                  */\n  int kn=pc->in;         /* Number of the vertices in input curves.    */\n  int kdim=pc->idim;     /* Dimensjon of the space in whice curve lies.*/\n  int kn1;               /* Number of vertices in the new curve .      */\n  double *st=SISL_NULL;       /* The new knot-vector.                       */\n  double *sp=SISL_NULL;       /* To use in s1701.c                          */\n  double *salfa=SISL_NULL;    /* A line of the trans.-matrix.               */\n  double *scoef=SISL_NULL;    /* The new vertice.                           */\n  SISLCurve *qkreg = SISL_NULL;   /* Input curve made k-regular.            */\n  SISLCurve *q1=SISL_NULL;    /* Pointer to new curve-object.               */\n\n  double *rcoef;         /* Potential rational coefficients.           */\n\n  /* Check that we have a curve to treat. */\n\n  if (!pc) goto err150;\n\n  if (pc->cuopen == SISL_CRV_PERIODIC)\n  {\n     make_cv_kreg(pc,&qkreg,&kstat);\n     if (kstat < 0) goto err153;\n  }\n  else qkreg = pc;\n\n  /* Check if this is a rational curve. */\n\n  if (qkreg->ikind == 2 || qkreg->ikind == 4)\n    {\n       kdim++;\n       rcoef = qkreg->rcoef;\n    }\n  else\n    rcoef = qkreg->ecoef;\n\n  /* Allocate space for the kk elements which may not be zero in eache\n     line of the basic transformation matrix, and space for new knots\n     to use in s1701.c */\n\n  if ((salfa=newarray(kk,double))==SISL_NULL) goto err101;\n  if ((sp=newarray(kk,double))==SISL_NULL) goto err101;\n\n  /* Find the number of vertices in the new curve. */\n\n  for(ki=0,kn1=0;ki<kn+kk;ki+=kj,kn1+=kk)\n    for(kj=1;ki+kj<kn+kk && (qkreg->et[ki] == qkreg->et[ki+kj]);kj++);\n  kn1 -= kk;\n\n  /* Allocating the new arrays to the new curve. */\n\n  if ((st=newarray(kn1+kk,double))==SISL_NULL) goto err101;\n  if ((scoef=new0array(kn1*kdim,double))==SISL_NULL) goto err101;\n\n  /* Making the new knotvectors. */\n\n  for(ki=0,ki1=0;ki<kn+kk;ki+=kj)\n    {\n      for(kj=1;ki+kj<kn+kk && (qkreg->et[ki] == qkreg->et[ki+kj]);kj++);\n      for(kj1=0;kj1<kk;kj1++,ki1++) st[ki1] = qkreg->et[ki];\n    }\n\n  /* Updating the coefisientvector to the new curve.*/\n\n  for(s1=scoef,ki=0,kmy=0;ki<kn1;ki++)\n    {\n      /* Here we compute a new line with line number ki of\n\t the knot inserten matrix. */\n\n      while(qkreg->et[kmy+1] <= st[ki]) kmy++;\n      s1701(ki,kmy,kk,kn,&kpl,&kfi,&kla,st,qkreg->et,sp,salfa,&kstat);\n      if (kstat) goto err153;\n\n      /* Compute the kdim vertices with the same \"index\". */\n\n      for (kj=0; kj<kdim; kj++,s1++)\n\tfor (*s1=0,kj1=kfi,kj2=kfi+kpl; kj1<=kla; kj1++,kj2++)\n\t  {\n\t    ki2=kj1*kdim+kj;\n\t    *s1 += salfa[kj2] * rcoef[ki2];\n\t  }\n    }\n\n  /* Allocating new curve-objects.*/\n\n  if ((q1=newCurve(kn1,kk,st,scoef,qkreg->ikind,qkreg->idim,2)) == SISL_NULL) goto err101;\n\n  /* Updating output. */\n\n  *rcnew = q1;\n  *jstat = 0;\n  goto out;\n\n\n  /* Error. Subrutine error. */\n\n err153: *jstat = kstat;\n  goto outfree;\n\n\n  /* Error. No curve to treat.  */\n\n err150: *jstat = -150;\n  s6err(\"s1730\",*jstat,kpos);\n  goto out;\n\n\n\n  /* Error. Allocation error, not enough memory.  */\n\n err101: *jstat = -101;\n  s6err(\"s1730\",*jstat,kpos);\n  goto outfree;\n\n\n outfree:\n  if(q1) freeCurve(q1);\n  else\n    {\n      if (st) freearray(st);\n      if (scoef) freearray(scoef);\n    }\n\n\n  /* Free local used memory. */\n\n out:\n  if (qkreg != SISL_NULL && qkreg != pc) freeCurve(qkreg);\n  if (salfa) freearray(salfa);\n  if (sp) freearray(sp);\n}\n"
  },
  {
    "path": "src/s1731.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1731.c,v 1.3 2001-03-19 15:58:52 afr Exp $\n *\n */\n\n\n#define S1731\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1731(SISLSurf *ps,SISLSurf **rsnew,int *jstat)\n#else\nvoid s1731(ps,rsnew,jstat)\n     SISLSurf *ps;\n     SISLSurf **rsnew;\n     int  *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To convert a B-spline surface to Bezier surfaces.\n*\n*\n* INPUT      : ps     - Surface to convert.\n*\n*\n*\n* OUTPUT     : rsnew     - The new Bezier represented surface.\n*              jstat     - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Inserting knots until all knots\n*              have multiplisity pc->ik.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newarray  - Allocate space for array of given type.\n*              new0array - Allocate space whith zero values.\n*              freearray - Free space occupied by given array.\n*              newSurf   - Allocate space for a new surf-object.\n*              freeSurf  - Free space occupied by given surf-object.\n*              S1701.C   - Making the knot-inserten-transformation matrix.\n*              make_sf_kreg - Ensure that the input surface is k-regular.\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-11.\n* REVISED BY : Johannes Kaasa, SI, May 1992 (Introduced NURBS).\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Oct. 1994. Moved free'ing\n*              of 'qkreg' from 'outfree:' to 'out:' to remove memory leak.\n*\n**********************************************************************/\n{\n  register int ki,ki1,ki2;       /* Control variable in loop.                   */\n  register int kj,kj1,kj2,kj3;   /* Control variable in loop.                   */\n  int kstat;                     /* Local status variable.                      */\n  int kpos=0;                    /* Position of error.                          */\n  int kmy;                       /* An index to the knot-vector.                */\n  int kpl,kfi,kla;               /* To posisjon elements in trans.-matrix.      */\n  int kk1=ps->ik1;               /* Order one of the input surface.             */\n  int kk2=ps->ik2;               /* Order two of the input surface.             */\n  int kn=ps->in1;                /* Number of the vertices in input curves.     */\n  int kdim=ps->idim;             /* Dimensjon of the space in whice surf lies.  */\n  int kn1,kn2;                   /* Number of vertices in the new surface.      */\n  double *s1,*s2,*s3;            /* Pointers used in loop.                      */\n  double *st1=SISL_NULL;              /* The new knot-vector.                        */\n  double *st2=SISL_NULL;              /* The new knot-vector.                        */\n  double *sp=SISL_NULL;               /* To use in s1701.c                           */\n  double *salfa=SISL_NULL;            /* A line of the trans.-matrix.                */\n  double *scoef=SISL_NULL;            /* The new vertice.                            */\n  double *scoefh=SISL_NULL;           /* A new vertice for help.                     */\n  SISLSurf *q1=SISL_NULL;             /* Pointer to new surf-object.                 */\n\n  double *rcoef;                 /* Potential rational vertices.                */\n  int rdim;                      /* Potential rational dimension.               */\n  SISLSurf *qkreg=SISL_NULL;          /* Input surface made k-regular.               */\n\n  /* Check that we have a surface to treat. */\n\n  if (!ps) goto err150;\n\n  /* Make sure that the surface is k-regular.  */\n\n  if (ps->cuopen_1 == SISL_SURF_PERIODIC ||\n      ps->cuopen_2 == SISL_SURF_PERIODIC)\n  {\n     make_sf_kreg(ps,&qkreg,&kstat);\n     if (kstat < 0) goto err153;\n  }\n  else qkreg = ps;\n\n\n  /* Check if the surface is rational. */\n\n  if (qkreg->ikind == 2 || qkreg->ikind == 4)\n  {\n     rcoef = qkreg->rcoef;\n     rdim = kdim + 1;\n  }\n  else\n  {\n     rcoef = qkreg->ecoef;\n     rdim = kdim;\n  }\n\n  /* Allocate space for the kk elements which may not be zero in eache\n     line of the basic transformation matrix, and space for new knots\n     to use in s1701.c */\n\n  if ((salfa=newarray(kk1+kk2,double))==SISL_NULL) goto err101;\n  if ((sp=newarray(kk1+kk2,double))==SISL_NULL) goto err101;\n\n  /* Find the number of vertices in the first direction\n     in the new surface. */\n\n  for(ki=0,kn1=0;ki<kn+kk1;ki+=kj,kn1+=kk1)\n    for(kj=1;ki+kj<kn+kk1 && (qkreg->et1[ki] == qkreg->et1[ki+kj]);kj++);\n  kn1 -= kk1;\n\n  /* Find the number of vertices in the second direction\n     in the new surface. */\n\n  for(kn=qkreg->in2,ki=0,kn2=0;ki<kn+kk2;ki+=kj,kn2+=kk2)\n    for(kj=1;ki+kj<kn+kk2 && (qkreg->et2[ki] == qkreg->et2[ki+kj]);kj++);\n  kn2 -= kk2;\n\n  /* Allocating the new arrays to the new surface. */\n\n  if ((st1=newarray(kn1+kk1,double))==SISL_NULL) goto err101;\n  if ((st2=newarray(kn2+kk2,double))==SISL_NULL) goto err101;\n  if ((scoefh=new0array(kn1*kn*rdim,double))==SISL_NULL) goto err101;\n  if ((scoef=new0array(kn1*kn2*rdim,double))==SISL_NULL) goto err101;\n\n  /* Making the new knotvectors in the first direction */\n\n  for(kn=qkreg->in1,ki=0,ki1=0;ki<kn+kk1;ki+=kj)\n    {\n      for(kj=1;ki+kj<kn+kk1 && (qkreg->et1[ki] == qkreg->et1[ki+kj]);kj++);\n      for(kj1=0;kj1<kk1;kj1++,ki1++) st1[ki1] = qkreg->et1[ki];\n    }\n\n  /* Making the new knotvectors in the second direction. */\n\n  for(kn=qkreg->in2,ki=0,ki1=0;ki<kn+kk2;ki+=kj)\n    {\n      for(kj=1;ki+kj<kn+kk2 && (qkreg->et2[ki] == qkreg->et2[ki+kj]);kj++);\n      for(kj1=0;kj1<kk2;kj1++,ki1++) st2[ki1] = qkreg->et2[ki];\n    }\n\n  /* Updating the coefisientvector to the new surface in the first\n     direction.*/\n\n  for(s1=scoefh,ki2=kn1*kn*rdim,ki=0,kmy=0;ki<kn1;ki++)\n    {\n      /* Here we compute a new line with line number ki of\n\t the knot inserten matrix. */\n\n      while(qkreg->et1[kmy+1] <= st1[ki]) kmy++;\n      s1701(ki,kmy,kk1,qkreg->in1,&kpl,&kfi,&kla,st1,qkreg->et1,sp,salfa,&kstat);\n      if (kstat) goto err153;\n\n      /* Compute the kn2*rdim vertices with the same \"index\". */\n\n      for (kj=0; kj<rdim; kj++,s1++)\n\tfor (s2=s1,s3=s2+ki2,kj3=kj;s2<s3;s2+=rdim*kn1,kj3+=rdim*qkreg->in1)\n\t  for (*s2=0,kj1=kfi,kj2=kfi+kpl; kj1<=kla; kj1++,kj2++)\n\t    *s2 += salfa[kj2] * rcoef[kj1*rdim+kj3];\n    }\n\n  /* Updating the coefisientvector to the new surface in the second\n     direction.*/\n\n  for(s1=scoef,ki2=kn1*rdim,ki=0,kmy=0;ki<kn2;ki++,s1+=kn1*rdim)\n    {\n      /* Here we compute a new line with line number ki of\n\t the knot inserten matrix. */\n\n      while(qkreg->et2[kmy+1] <= st2[ki]) kmy++;\n      s1701(ki,kmy,kk2,kn,&kpl,&kfi,&kla,st2,qkreg->et2,sp,salfa,&kstat);\n      if (kstat) goto err153;\n\n      /* Compute the kn1*rdim vertices with the same \"index\". */\n\n      for (kj=0; kj<rdim; kj++)\n\tfor (s2=s1+kj,s3=s2+ki2,kj3=kj;s2<s3;s2+=rdim,kj3+=rdim)\n\t  for (*s2=0,kj1=kfi,kj2=kfi+kpl; kj1<=kla; kj1++,kj2++)\n\t    *s2 += salfa[kj2] * scoefh[kj1*kn1*rdim+kj3];\n    }\n\n\n  /* Allocating new surface-objects.*/\n\n  if ((q1=newSurf(kn1,kn2,kk1,kk2,st1,st2,scoef,qkreg->ikind,kdim,2)) == SISL_NULL)\n    goto err101;\n\n  /* Updating output. */\n\n  *rsnew = q1;\n  *jstat = 0;\n  goto out;\n\n  /* Error. Subrutine error. */\n\n err153: *jstat = kstat;\n  goto outfree;\n\n  /* Error. No surface to treat.  */\n\n err150: *jstat = -150;\n  s6err(\"s1731\",*jstat,kpos);\n  goto out;\n\n  /* Error. Allocation error, not enough memory.  */\n\n err101: *jstat = -101;\n  s6err(\"s1731\",*jstat,kpos);\n  goto outfree;\n\n outfree:\n  if(q1) freeSurf(q1);\n  else\n    {\n      if (st1)   freearray(st1);\n      if (st2)   freearray(st2);\n      if (scoef) freearray(scoef);\n    }\n\n  /* Free local used memory. */\n\n out:\n  if (qkreg != SISL_NULL && qkreg != ps) freeSurf(qkreg);\n  if (salfa)  freearray(salfa);\n  if (sp)     freearray(sp);\n  if (scoefh) freearray(scoefh);\n}\n"
  },
  {
    "path": "src/s1732.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1732.c,v 1.2 1994-10-19 14:55:31 pfu Exp $\n *\n */\n\n\n#define S1732\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1732(SISLCurve *pc,int icont,double *cstart,double *cend,double *gcoef,int *jstat)\n#else\nvoid s1732(pc,icont,cstart,cend,gcoef,jstat)\n     SISLCurve  *pc;\n     int    icont;\n     double *cstart;\n     double *cend;\n     double *gcoef;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To pick out the next Bezier curve of a B-spline curve.\n*              This function requere a B_spline curve that is the\n*              result of s1730. This rutine do not check that the\n*              curve is correct.\n*\n*\n*\n* INPUT      : pc      - B-spline curve to convert.\n*              icont   - The number of the Bezier curve to pick.\n*\n*\n*\n* OUTPUT     : cstart  - The start parameter value to the Bezier curve.\n*              cend    - The end parameter value to the Bezier curve.\n*              gcoef   - The vertices to the Bezier curve.\n*              jstat   - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-11.\n* REVISED BY : Johannes Kaasa, SI, May 1992 (Introduced NURBS)\n* REVISED BY : Christophe Birkeland, July 1992 (Test line 97)\n* Revised by : Christophe Rene Birkeland, SINTEF Oslo, May 1993.\n*              *jstat = 0  in begining\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Oct. 1994.\n*              Added check on 'icont' lower bound.\n*\n*********************************************************************\n*/\n{\n  int kpos=0;      /* Position of error.                  */\n  int kfi,kla;     /* Index to the first and last element\n\t\t      in the knot-vector with the start\n\t\t      value to the Bezier curve.          */\n  double *rcoef;   /* Potential rational vertices.        */\n  int kdim;        /* Potential rational dimension.       */\n\n  *jstat = 0;\n\n  /* Check if this is a rational curve. */\n\n  if (pc->ikind == 2 || pc->ikind ==4)\n    {\n       rcoef = pc->rcoef;\n       kdim = pc->idim + 1;\n    }\n  else\n    {\n       rcoef = pc->ecoef;\n       kdim = pc->idim;\n    }\n\n  /* Check that we have a Bezier curve to treat. */\n\n  if ( icont >= 0  &&  icont < pc->in/pc->ik )\n    {\n      /* The first and last element in pc->et with the\n\t start value. */\n\n      kfi = icont*pc->ik;\n      kla = kfi + pc->ik;\n\n      /* Updating the start and the end parameter value\n\t to the curve. */\n\n      *cstart = pc->et[kfi];\n      *cend = pc->et[kla+1];\n\n      /* Updating the vertices to the Bezier curve. */\n\n      memcopy(gcoef,&rcoef[kfi*kdim],kdim*pc->ik,double);\n    }\n  else\n    {\n      /* Error, no curve to return. */\n\n      *jstat = -151;\n      s6err(\"s1732\",*jstat,kpos);\n    }\n}\n"
  },
  {
    "path": "src/s1733.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1733.c,v 1.2 1994-10-19 15:30:55 pfu Exp $\n *\n */\n\n\n#define S1733\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1733(SISLSurf *ps,int icont1,int icont2,double *cstart1,double *cend1,\n\t   double *cstart2,double *cend2,double *gcoef,int *jstat)\n#else\nvoid s1733(ps,icont1,icont2,cstart1,cend1,cstart2,cend2,gcoef,jstat)\n     SISLSurf   *ps;\n     int    icont1;\n     int    icont2;\n     double *cstart1;\n     double *cend1;\n     double *cstart2;\n     double *cend2;\n     double *gcoef;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To pick out the next Bezier patch of a B-spline surface.\n*              This function requere a B_spline surface that is the\n*              result of s1731. This rutine do not check that the\n*              surface is correct.\n*\n*\n*\n* INPUT      : ps         - B-spline surface to convert.\n*              icont1     - The horisontal number of the Bezier patch to pick.\n*              icont2     - The vertical number of the Bezier patch to pick.\n*\n*\n*\n* OUTPUT     : cstart1    - The horisontal start parameter value to\n*                           the Bezier patch.\n*              cend1      - The horisontal end parameter value to\n*                           the Bezier patch.\n*              cstart2    - The vertical start parameter value to\n*                           the Bezier patch.\n*              cend2      - The vertical end parameter value to\n*                           the Bezier patch.\n*              gcoef      - The vertices of the Bezier surface.\n*              jstat      - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 88-11.\n* REVISED BY : Johannes Kaasa, SI, May 1992 (Introduced NURBS).\n* REVISED BY : Christophe Birkeland, SI, July 92\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Oct. 1994. Added lower\n*              bound checks on 'icont1' and 'icont2' and corrected upper\n*              bound checks from \"<=\" to \"<\" - caused memory problems.\n*\n**********************************************************************/\n{\n  int kpos=0;       /* Position of error.                  */\n  int ki;           /* Control variable in loop.           */\n  int kfi1,kla1;    /* Index to the first and last element\n\t\t       in the knot-vector with the start\n\t\t       value to the Bezier curve.          */\n  int kfi2,kla2;    /* Index to the first and last element\n\t\t       in the knot-vector with the start\n\t\t       value to the Bezier curve.          */\n  int kdim;         /* Dimension of the geometry.          */\n  double *scoef;    /* Vertices.                           */\n\n  *jstat = 0;\n\n  /* Check if the surface is rational. */\n\n  if (ps->ikind == 2 || ps->ikind == 4)\n  {\n     kdim = ps->idim + 1;\n     scoef = ps->rcoef;\n  }\n  else\n  {\n     kdim = ps->idim;\n     scoef = ps->ecoef;\n  }\n\n  /* Check that we have a Bezier patch to treat. */\n\n  if ( icont1 >= 0  &&  icont2 >= 0  &&\n       icont1 < ps->in1/ps->ik1  &&  icont2 < ps->in2/ps->ik2 )\n    {\n      /* Finding the first and last element in ps->et1 with the\n\t start1 value. */\n\n      kfi1 = icont1*ps->ik1;\n      kla1 = kfi1 + ps->ik1;\n\n      /* Updating the start1 and the end1 parameter value\n\t to the patch. */\n\n      *cstart1 = ps->et1[kfi1];\n      *cend1 = ps->et1[kla1+1];\n\n      /* Finding the first and last element in ps->et2 with the\n\t start2 value. */\n\n      kfi2 = icont2*ps->ik2;\n      kla2 = kfi2 + ps->ik2;\n\n      /* Updating the start2 and the end2 parameter value\n\t to the patch. */\n\n      *cstart2 = ps->et2[kfi2];\n      *cend2 = ps->et2[kla2+1];\n\n      /* Updating the vertices to the Bezier curve. */\n\n      for (ki=0;ki < ps->ik2;ki++)\n\tmemcopy(gcoef+ki*kdim*ps->ik1,\n\t\t&scoef[((kfi2+ki)*ps->in1 + kfi1)*kdim],\n\t\tkdim*ps->ik1,double);\n    }\n  else\n    {\n      /* Error, no patch to return. */\n\n      *jstat = -152;\n      s6err(\"s1733\",*jstat,kpos);\n    }\n}\n"
  },
  {
    "path": "src/s1741.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1741.c,v 1.3 2001-03-19 15:58:53 afr Exp $\n *\n */\n\n\n#define S1741\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1741(SISLObject *po1,SISLObject *po2,double aepsge,int *jstat)\n#else\nvoid s1741(po1,po2,aepsge,jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Check if a object-object intersection is a simple case,\n*              i.e. the intersection will result in one single point.\n*\n*\n*\n* INPUT      : po1    - First curve in the intersection problem.\n*              po2    - Second curve in the intersection problem.\n*              aepsge - Geometry resolution.\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                                         = 1      : simpel case.\n*                                         = 0      : not simpel case.\n*                                         < 0      : error.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* CALLS      : s1990   - Making the direction cone of surface.\n*              s1991   - Making the direction cone of curve.\n*              sh1993  - Simple case of curve in one dimention.\n*              sh1994  - Simple case of surface in one dimention.\n*              s6err   - Gives error message.\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-05.\n* REVISED BY : Michael Floater, SI, May 1997 to agree with the HP version.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;    /* Local status variable.                          */\n  int kpos = 0;     /* Position of the error.                          */\n  int k1;           /* Control variable in loop.\t\t       */\n  double tang;\t    /* Angel between two vectors.\t\t       */\n  double small_tang;/* Smallest angle between two vectors.\t       */\n  \n  if (po1->iobj == SISLPOINT || po2->iobj == SISLPOINT)\n    {\n      SISLObject *qo1,*qo2;\n      \n      if(po1->iobj == SISLPOINT)\n\t{\n\t  qo1 = po1;\n\t  qo2 = po2;\n\t}\n      else\n\t{\n\t  qo1 = po2;\n\t  qo2 = po1;\n\t}\n      \n      if (qo2->iobj == SISLCURVE)\n\t{\n\t  /* Test if the curve lies in the same space as the point.  */\n\t  \n\t  if (qo1->p1->idim != qo2->c1->idim) goto err106;\n\t  \n\t  if (qo2->c1->idim == 1)\n\t    {\n\t      sh1993(qo2->c1,aepsge,&kstat);\n\t      \n\t      *jstat = kstat;\n\t      goto out;\n\t    }\n\t  \n\t  /* Computing the direction cone of the curve. If the curve\n\t     have cones greater then pi we just return not a simple case.  */\n\t  \n\t  s1991(qo2->c1,aepsge,&kstat);\n\t  if (kstat < 0) goto error;\n\t  else if (qo2->c1->pdir->igtpi != 0) goto out2;/* Not a simple case.*/\n\t  \n\t  \n\t  /* Performing a simple case check. */\n\t  \n\t  if (qo2->c1->pdir->aang<PIHALF)\n\t    {\n\t      /* A simpel case. The iteration is able to\n\t\t find intersection.*/\n\t      \n\t      *jstat = 1;\n\t      goto out;\n\t    }\n\t}\n      else if (qo2->iobj == SISLSURFACE)\n\t{\n\t  /* Test if the surface lies in the same space as the point.  */\n\t  \n\t  if (qo1->p1->idim != qo2->s1->idim) goto err106;\n\t  \n\t  \n\t  if (qo2->s1->idim == 1)\n\t    {\n\t      sh1994(qo2->s1,aepsge,&kstat);\n\t      \n\t      *jstat = kstat;\n\t      goto out;\n\t    }\n\t  else\n\t    {\n\t      /* Computing the direction cone of the surface. If the surface\n\t\t have cones greater then pi we just return not a simple case.*/\n\t      \n\t      s1990(qo2->s1,aepsge,&kstat);\n\t      if (kstat < 0) goto error;\n\t      else if (qo2->s1->pdir->igtpi != 0) goto out2; /*No simple case*/\n\t      \n\t      \n\t      /* Performing a simple case check. */\n\t      \n\t      if (qo2->s1->pdir->aang<PIHALF)\n\t\t{\n\t\t  /* A simpel case. The iteration is able to\n\t\t     find intersection.*/\n\t\t  \n\t\t  \n\t\t  *jstat = 1;\n\t\t  goto out;\n\t\t}\n\t    }\n\t}\n    }\n  else if (po1->iobj == SISLCURVE && po2->iobj == SISLCURVE)\n    {\n      /* Test if the curves lies in the same space.  */\n      \n      if (po2->c1->idim != po1->c1->idim) goto err106;\n      \n      \n      \n      /* Computing the direction cone of the two curves. If one of them\n\t have cones greater then pi we just return not a simple case.  */\n      \n      s1991(po1->c1,aepsge,&kstat);\n      if (kstat < 0) goto error;\n\n      s1991(po2->c1,aepsge,&kstat);\n      if (kstat < 0) goto error;\n\n      if (po1->c1->pdir->igtpi != 0) goto out2;  /* Not a simple case.*/\n      if (po2->c1->pdir->igtpi != 0) goto out2;  /* Not a simple case.*/\n      \n      \n      /* Computing the angle beetween the senters of the two cones. */\n      \n      for (tang=DZERO,k1=0;k1<po1->c1->idim;k1++)\n\ttang += po1->c1->pdir->ecoef[k1]*po2->c1->pdir->ecoef[k1];\n      \n      if (tang >= DZERO)  tang = min((double)1.0,tang);\n      else                tang = max((double)-1.0,tang);\n      \n      tang = acos(tang);\n      \n      if (tang > PIHALF)\n         small_tang = PI - tang;\n      else\n         small_tang = tang;\n      \n      /* Performing a simple case check. */\n      \n      if ((tang+po1->c1->pdir->aang+po2->c1->pdir->aang)<PI &&\n\t  (po1->c1->pdir->aang+po2->c1->pdir->aang)<tang)\n\t{\n\t  /* A simpel case. The two cones and their mirrors\n\t     are not intersecting.*/\n\t  \n\t  *jstat = 1;\n\t  goto out;\n\t}\n      else if (po1->c1->idim == 2)\n        {\n\t  *jstat = 0;\n\t  goto out;\n\t}\n      else if (tang < PI - ANGULAR_TOLERANCE && \n\t       tang > ANGULAR_TOLERANCE      &&\n\t       po1->c1->pdir->aang <= (double)1.3*small_tang &&\n\t       po2->c1->pdir->aang <= (double)1.3*small_tang)\n\t /*po1->c1->pdir->aang <= (double)1.3*tang &&\n\t       po2->c1->pdir->aang <= (double)1.3*tang)*/\n\t{\n\t  s1796(po1->c1,po2->c1,aepsge,tang,&kstat);\n\t  if (kstat<0) goto error;\n\t  else *jstat = kstat;\n\t  goto out;\n\t}\n    }\n  else if (po1->iobj == SISLSURFACE && po2->iobj == SISLSURFACE)\n    {\n      \n      /* Test if the surfaces lies in the same space.  */\n      \n      if (po2->s1->idim != po1->s1->idim) goto err106;\n      \n      \n      \n      /* Computing the direction cone of the two surfaces. If one of them\n\t have cones greater then pi we just return not a simple case.  */\n      \n      s1990(po1->s1,aepsge,&kstat);\n      if (kstat < 0) goto error;\n      \n      s1990(po2->s1,aepsge,&kstat);\n      if (kstat < 0) goto error;\n\n      if (po1->s1->pdir->igtpi != 0) goto out2;  /* Not a simple case.  */\n\n      if (po2->s1->pdir->igtpi != 0) goto out2;  /* Not a simple case.  */\n      \n      /* Computing the angle beetween the senters of the two cones. */\n      \n      for (tang=DZERO,k1=0;k1<po1->s1->idim;k1++)\n\ttang += po1->s1->pdir->ecoef[k1]*po2->s1->pdir->ecoef[k1];\n      \n      if (tang >= DZERO)  tang = min((double)1.0,tang);\n      else                tang = max((double)-1.0,tang);\n      \n      tang = acos(tang);\n      \n      \n      /* Performing a simple case check. */\n      \n      if ((tang+po1->s1->pdir->aang+po2->s1->pdir->aang)<PI &&\n\t  (po1->s1->pdir->aang+po2->s1->pdir->aang)<tang)\n\t{\n\t  /* A simpel case. The two cones and their mirrors\n\t     are not intersecting.*/\n\t  \n\t  po1->psimple = po2;\n\t  *jstat = 1;\n\t  goto out;\n\t}\n      else if (tang < PI - ANGULAR_TOLERANCE && \n\t       tang > ANGULAR_TOLERANCE      &&\n\t       po1->s1->pdir->aang <= (double)1.3*tang &&\n\t       po2->s1->pdir->aang <= (double)1.3*tang)\n\t{\n\t  s1795(po1->s1,po2->s1,aepsge,tang,&kstat);\n\t  if (kstat < 0) goto error;\n\t  if (kstat == 1) po1->psimple = po2;\n\t  *jstat = kstat;\n\t  goto out;\n\t}\n    }\n  else if (po1->iobj == SISLCURVE || po2->iobj == SISLCURVE)\n    {\n      SISLObject *qo1,*qo2;\n      \n      if(po1->iobj == SISLCURVE)\n\t{\n\t  qo1 = po1;\n\t  qo2 = po2;\n\t}\n      else\n\t{\n\t  qo1 = po2;\n\t  qo2 = po1;\n\t}\n      \n      \n      /* Test if the surface and curve lies in the same space.  */\n      \n      if (qo2->s1->idim != qo1->c1->idim) goto err106;\n      \n      \n      \n      /* Computing the direction cone of the curve and the surface. If one of\n\t them have cones greater then pi we just return not a simple case. */\n      \n      \n      s1990(qo2->s1,aepsge,&kstat);\n      if (kstat < 0) goto error;\n      \n      s1991(qo1->c1,aepsge,&kstat);\n      if (kstat < 0) goto error;\n\n      if (qo1->c1->pdir->igtpi != 0) goto out2;  /* Not a simple case.  */\n      if (qo2->s1->pdir->igtpi != 0) goto out2;  /* Not a simple case.  */\n\n      \n      \n      /* Computing the angle beetween the senters of the two cones. */\n      \n      for (tang=DZERO,k1=0;k1<qo2->s1->idim;k1++)\n\ttang += qo2->s1->pdir->ecoef[k1]*qo1->c1->pdir->ecoef[k1];\n      \n      if (tang >= DZERO) tang = min((double)1.0,tang);\n      else               tang = max((double)-1.0,tang);\n      \n      tang = acos(tang);\n      \n      \n      /* Performing a simple case check. */\n      \n      if (((tang + qo1->c1->pdir->aang) < (PIHALF - qo2->s1->pdir->aang)) ||\n\t  ((tang - PIHALF - qo1->c1->pdir->aang) > qo2->s1->pdir->aang)) \n\t{\n\t  /* A simpel case. The curve cone or the mirror cone\n\t     are tottally inside the inverted surface cone. */\n\t  \n\t  *jstat = 1;\n\t  goto out;\n\t}\n      else if (tang < PI - ANGULAR_TOLERANCE && \n\t       tang > ANGULAR_TOLERANCE      &&\n\t       min(tang,fabs(PI-tang)) < \n\t       (double)0.8*(PIHALF - qo2->s1->pdir->aang) &&\n\t       qo1->c1->pdir->aang < (double)0.8*(PIHALF-qo2->s1->pdir->aang))\n\t{\n\t  s1797(qo2->s1,qo1->c1,aepsge,tang,&kstat);\n\t  if (kstat<0) goto error;\n\t  else *jstat = kstat;\n\t  goto out;\n\t}\n    }\n  \n\n/* Not a simple case. */\n\nout2:\t*jstat = 0;\n\tgoto out;\n\n/* Error. Dimensions conflicting.  */\n\nerr106: *jstat = -106;\n        s6err(\"s1741\",*jstat,kpos);\n        goto out;\n\n/* Error in lower level routine.  */\n\nerror : *jstat = kstat;\n        s6err(\"s1741\",*jstat,kpos);\n        goto out;\n\nout:  ;\n}\n"
  },
  {
    "path": "src/s1750.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1750.c,v 1.2 2001-03-19 15:58:53 afr Exp $\n *\n */\n\n\n#define S1750\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1750(SISLCurve *pc,int ikh,SISLCurve **rc,int *jstat)\n#else\nvoid s1750(pc,ikh,rc,jstat)\n     SISLCurve *pc;\n     int   ikh;\n     SISLCurve **rc;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To describe a B-spline curve using a higher order\n*              B-spline basis.\n*             \n* INPUT      : pc     - The input B-spline curve.\n*              ikh    - Order of the new urve.\n*\n* OUTPUT     : rc     - Pointer to the higher order curve\n*              jstat  - status messages :\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     : The order of the curve is elevated one order at the time\n*              using the algorithm of COHEN, LYCHE and SCHUMAKER.\n*\n* REFERENCES :\n*\n*\n* CALLS      : s1754,s1753,s1755,s6err.\n*\n*\n* WRITTEN BY : \tQyvind Hjelle, SI, Oslo, Norway. 10. Nov 1988\n* REWRITTEN BY:\tChristophe R. Birkeland, SI, 1991-07\n* REVISED BY :  Johannes Kaasa, SI, May 1992 (Introduced NURBS)\n* Revised by : Christophe Rene Birkeland, SINTEF Oslo, May 1993.\n*              Error message corrected\n*\n*********************************************************************\n*/\n{\n  int ki, kn, kk;\t\t/* Loop control parameters\t\t\t*/\n  int kordr;\n  int inhrem;\t\t\t/* Used to store inh, for later use in last\n\t\t\t\t * call to s1753\t\t\t\t*/\n  int kpos = 0;\t\t\t/* Error position indicator\t\t\t*/\n  int kstat = 0;\t\t/* Status variable */\n  double *kcc = SISL_NULL;\n  double *kcw = SISL_NULL;\t\t/* Arrays for internal use only\t\t\t*/\n  double *orknot = SISL_NULL;\t/* Used to store 'original' knot vector\t\t*/\n  double *xtknot = SISL_NULL;\t/* Used to store extended knot vector\t\t*/\n  double *pointer = SISL_NULL;\n  double *orcoef = SISL_NULL;\t/* Used to store 'original' coefficient matrix\t*/\n  double *et = SISL_NULL;\t\t/* Original knot vector\t\t\t\t*/\n  double *ebcoef = SISL_NULL;\t/* Vertices of original curve\t\t\t*/\n  int in;\t\t\t/* Number of vertices of original curve\t\t*/\n  int ik;\t\t\t/* Order of original curve\t\t\t*/\n  int idim;\t\t\t/* Dimension of the space where the curve lie\t*/\n  int kdim;                     /* Potential rational dimension.                */\n  int kind;                     /* Kind of curve, 2 and 4 are rationals.        */\n  double *iknt = SISL_NULL;\t\t/* New knot vector\t\t\t\t*/\n  double *icoef = SISL_NULL;\t\t/* Coefficients of new curve\t\t\t*/\n  int inh;\t\t\t/* Number of vertices produced\t\t\t*/\n\n  *jstat = 0;\n\n  /* Initialization of variables. */\n\n  kind = pc->ikind;\n  idim = pc->idim;\n  et = pc->et;\n  if (kind == 2 || kind == 4)\n    {\n      ebcoef = pc->rcoef;\n      kdim = idim + 1;\n    }\n  else\n    {\n      ebcoef = pc->ecoef;\n      kdim = idim;\n    }\n  in = pc->in;\n  ik = pc->ik;\n\n  /* Test if legal input. */\n\n  if ((ik < 1) || (ikh < ik) || (in <ik)) goto err112;\n\n  /* If ikh=ik, copy input curve to output variables. */\n\n  if (ikh == ik)\n    {\n      *rc = newCurve (in, ik, et, ebcoef, pc->ikind, idim, 1);\n      if (*rc == SISL_NULL) goto err171;\n\n      /* If the input curve is periodic, the output curve is periodic. */\n      (*rc)->cuopen = pc->cuopen;\n      goto out;\n    }\n\n  /* Find size of knot vector and vertex vector,\n     and find knot vector expressed in order ikh. */\n\n  s1754 (et, in, ik, ikh, &iknt, &inh, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Allocate coefficients array for raised curve. */\n\n  if((icoef = newarray (inh * kdim, DOUBLE)) == SISL_NULL) goto err101;\n\n  /* Allocate arrays for internal use. */\n\n  if((kcc = newarray (kdim * ikh, DOUBLE)) == SISL_NULL) goto err101;\n  if((kcw = newarray (kdim * ikh, DOUBLE)) == SISL_NULL) goto err101;\n\n  /* Find vertices if  ikh = ik+1 */\n\n  if (ikh == ik + 1)\n    {\n      s1753 (et, ebcoef, in, ik, kdim, iknt, icoef, inh, kcc, kcw, &kstat);\n      if (kstat < 0) goto error;\n\n      *rc = newCurve (inh, ikh, iknt, icoef, pc->ikind, idim, 2);\n      if (*rc == SISL_NULL) goto err171;\n\n      /* If the input curve is periodic, the output curve is periodic. */\n      (*rc)->cuopen = pc->cuopen;\n \n      goto out;\n    }\n\n  /* Allocate arrays to store knot vector for use in s1755. */\n\n  orknot = newarray ((in +ik) *(ikh - ik + 1), DOUBLE);\n  if (orknot == SISL_NULL) goto err101;\n  xtknot = newarray ((in +ik) *(ikh - ik + 1), DOUBLE);\n  if (xtknot == SISL_NULL) goto err101;\n\n  /* Allocate array to store vertices. */\n\n  orcoef = newarray (inh * kdim, DOUBLE);\n  if (orcoef == SISL_NULL) goto err101;\n\n  /* Initialize orknot and orcoef. */\n\n  for (ki = 0; ki < (in +ik); ki++)\n    orknot[ki] = et[ki];\n\n  for (ki = 0; ki < (kdim * in); ki++)\n    orcoef[ki] = ebcoef[ki];\n\n\n  /* MAIN LOOP. Do the order raisings. */\n\n  inhrem = inh;\n  kn = in;\n  kk = ik;\n  for (kordr = ik + 1; kordr < ikh; kordr++)\n    {\n      /* Produce raised knots. */\n\n      s1755 (orknot, kn, kk, xtknot, &inh, &kstat);\n      if (kstat < 0) goto error;\n\n      /* Produce raised vertices. */\n\n      s1753 (orknot, orcoef, kn, kk, kdim, xtknot, icoef,\n\t     inh, kcc, kcw, &kstat);\n      if (kstat < 0) goto error;\n\n\n      if ((kordr + 1) < ikh)\n\t{\n\t  pointer = orknot;\n\t  orknot = xtknot;\n\t  xtknot = pointer;\n\t}\n      kk = kordr;\n      kn = inh;\n      pointer = orcoef;\n      orcoef = icoef;\n      icoef = pointer;\n    }\n\n  inh = inhrem;\n  s1753 (xtknot, orcoef, kn, kk, kdim, iknt, icoef, inh, kcc, kcw, &kstat);\n  if (kstat < 0) goto error;\n\n  /* OK.\n   * Create new curve */\n\n  *rc = newCurve (inh, ikh, iknt, icoef, pc->ikind, idim, 2);\n  if (*rc == SISL_NULL) goto err171;\n\n  /* If the input curve is periodic, the output curve is periodic. */\n  (*rc)->cuopen = pc->cuopen;\n\n  goto out;\n\n\n  /* Error in array allocation */\n\n  err101:\n    *jstat = -101;\n    s6err (\"s1750\", *jstat, kpos);\n    goto out;\n\n  /* Could not create curve. */\n\n  err171:\n    *jstat = -171;\n    s6err (\"s1750\", *jstat, kpos);\n    goto out;\n\n  /* Error in description of B-spline */\n\n  err112:\n    *jstat = -112;\n    s6err (\"s1750\", *jstat, kpos);\n    goto out;\n\n  /* Error in lower level routine */\n\n  error:\n    *jstat = kstat;\n    s6err (\"s1750\", *jstat, kpos);\n    goto out;\n\n  out:\n    if (kcc != SISL_NULL)    freearray (kcc);\n    if (kcw != SISL_NULL)    freearray (kcw);\n    if (orknot != SISL_NULL) freearray (orknot);\n    if (xtknot != SISL_NULL) freearray (xtknot);\n    if (orcoef != SISL_NULL) freearray (orcoef);\n    return;\n}\n"
  },
  {
    "path": "src/s1753.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1753.c,v 1.2 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1753\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1753 (double et[], double ecf[], int in, int ik, int idim, double etr[],\n       double ecfr[], int inr, double ecc[], double ecw[], int *jstat)\n\n#else\nvoid\ns1753 (et, ecf, in, ik, idim, etr, ecfr, inr, ecc, ecw, jstat)\n     double et[];\n     double ecf[];\n     int in;\n     int ik;\n     int idim;\n     double etr[];\n     double ecfr[];\n     int inr;\n     double ecc[];\n     double ecw[];\n     int *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : \tTo raise the description of a B-spline curve one order.\n*\n*\n* INPUT      : \tet\t- Description of knot vector of original description\n*\t\tecf\t- Coefficients of original description\n*\t\tin\t- Number of vertices of original description\n*\t\tik\t- Order of original description\n*\t\tidim\t- The dimension of the space in which the curve lies\n*\t\tetr\t- Knot vector of the raised basis\n*\t\tinr\t- Number of vertices in the raised curve\n*\t\tecc\t- Array for internal use only\n*\t\tecw\t-        ---- \" ----\n*\n* OUTPUT     : \tecfr\t- Knots of the raised curve\n*\t\tjstat\t- Status variable:\n*\t\t\t\t< 0  \t: error\n*\t\t\t\t= 0\t: OK.\n*\n* METHOD     : \tThe order raising algorithm of Cohen, Lyche and Schumaker\n*\t\tis used.\n*\n*\n* REFERENCES :\tFortran version:\n*\t\tT.Dokken, SI, 1984-06\n*\n*\n* CALLS      :  s6err.\n*\n*\n* WRITTEN BY : \tChristophe R. Birkeland, SI, 1991-07\n* REWRITTEN BY :\n* REVISED BY :\n*\n*********************************************************************\n*/\n{\n  int ki, kj, kk, kl, kr, kstop;/* Loop control variables \t\t*/\n  int kjmid, ikmid;\t\t/* kjmid=(kj-1)*idim  ikmid=(ik-1)*idim */\n  int kpos = 0;\t\t\t/* Error position indicator\t\t*/\n  double ty1, ty2, tyi, tyik;\t/* Parameters used in Main Loop\t\t*/\n  double dummy;\n  double tden;\n\n  *jstat = 0;\n\n\n  /* Check input values. */\n\n  if ((ik < 1) || (in <ik) ||(inr < (ik + 1)))\n    goto err112;\n\n\n  /* Initiate local variables. */\n\n  kr = 1;\n  for (kj = 1; kj <= inr; kj++)\n    {\n\n      /* Find kr, such that et[kr-1]<=etr[kj-1]<et[kr]\t*/\n\n      for (kr--; et[kr] <= etr[kj - 1]; kr++) ;\n\n\n      /* Set ecc and ecw to zero. */\n\n      for (ki = 0; ki < ik * idim; ki++)\n\t{\n\t  ecc[ki] = (double) 0.0;\n\t  ecw[ki] = (double) 0.0;\n\t}\n\n      /* Initialize the remaining ecc and ecw entries. */\n\n      kstop = MIN (ik, in +ik - kr);\n      for (ki = MAX (0, ik - kr); ki < kstop; ki++)\n\tfor (kl = 0; kl < idim; kl++)\n\t  {\n\t    dummy = ecf[(ki + kr - ik) * idim + kl];\n\t    ecc[ki * idim + kl] = dummy;\n\t    ecw[ki * idim + kl] = dummy;\n\t  }\n\n      /* MAIN LOOP. */\n\n      for (kk = ik - 1; kk > 0; kk--)\n\t{\n\t  ty1 = etr[kj + kk - 1];\n\t  ty2 = etr[kj + kk];\n\t  kstop = MAX (ik - kk, ik - kr);\n\n\t  for (ki = MIN (ik - 1, in +2 * ik - kk - kr - 1); ki >= kstop; ki--)\n\t    {\n\t      tyi = et[kr + ki - ik];\n\t      tyik = et[kr + ki + kk - ik];\n\t      tden = tyik - tyi;\n\n\t      for (kl = 0; kl < idim; kl++)\n\t\t{\n\t\t  ecc[ki * idim + kl] = ((ty2 - tyi) * ecc[ki * idim + kl] +\n\t\t\t   (tyik - ty2) * ecc[(ki - 1) * idim + kl]) / tden;\n\t\t  ecw[ki * idim + kl] = ((ty1 - tyi) * ecw[ki * idim + kl] +\n\t\t\t  (tyik - ty1) * ecw[(ki - 1) * idim + kl]) / tden +\n\t\t    ecc[ki * idim + kl];\n\t\t}\n\t    }\n\t}\n      kjmid = (kj - 1) * idim;\n      ikmid = (ik - 1) * idim;\n\n      for (kl = 0; kl < idim; kl++)\n\tecfr[kjmid + kl] = ecw[ikmid + kl] / ik;\n    }\n\n  goto out;\n\n\n  /* Error in description of bases */\n\nerr112:\n  *jstat = -112;\n  s6err (\"s1753\", *jstat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1754.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1754.c,v 1.3 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1754\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1754 (double *et, int in, int ik, int ikh, double **iknt,\n       int *inh, int *jstat)\n\n#else\nvoid\ns1754 (et, in, ik, ikh, iknt, inh, jstat)\n     double *et;\n     int in;\n     int ik;\n     int ikh;\n     double **iknt;\n     int *inh;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : \tTo produce a knot vector of order higher than an other knot\n*\t\tvector reflecting the same continuity as the original knot\n*\t\tvector.\n*\n*\n* INPUT      : \tet\t\t- The original knot vector.\n*\t\t\t\t  Dimension (1:in+ik).\n*\t\tin\t\t- The number of degrees of freedom in the\n*\t\t\t\t  B-spline given by the knot vector.\n*\t\tik\t\t- The order of the basis.\n*\t\tikh\t\t- The order of the knot vector to be produced.\n*\n* OUTPUT     :  iknt\t\t- The 'extended' knot vector.\n*\t\t\t\t  Dimension (1:inh+ikh).\n*\t\tinh\t\t- The number of degrees of freedom in the knot\n*\t\t\t\t  vector produced.\n*               jstat           - Output status:\n*                                  < 0: Error.\n*                                  = 0: Ok.\n*                                  > 0: Warning.\n*\n* METHOD     :\tAt et[ik-1], ikh knots are inserted. For internal knot values,\n*\t\tthe multiplicity 'M' is found, the continuity determined\n*\t\t'ik-M-1', and the new multiplicity 'ikh-ik+M' deternined.\n*\t\tAt et[in], ikh knots are inserted.\n*\n* REFERENCES :\tFortran version:\n*\t\tT.Dokken, SI, 1981-10\n*\n* CALLS      :  s6err.\n*\n* WRITTEN BY : \tChristophe R. Birkeland, SI, 1991-07\n* REWRITTEN BY :\n* REVISED BY :\n*\n*********************************************************************\n*/\n{\n  int ki, kj;\t\t\t/* Loop control parameters \t\t*/\n  int kstart, kstop;\n  int numb;\n  int kpos = 0;\t\t\t/* Position indicator for errors\t*/\n  int kant;\t\t\t/* Equals ikh-ik\t\t\t*/\n  double prev, par;\t\t/* Parameters used to find consecutive\n\t\t\t\t   distinct knotvector values\t\t*/\n  double tstart, tstop;\t\t/* tstart=et[ik-1], tstop=et[in]\t*/\n\n  *jstat = 0;\n\n\n  /* Test if legal input. */\n\n  if (ik < 1 || ikh < ik || in <ik)\n    goto err112;\n\n\n  /* Test if input knot vector degenerate. */\n\n  if (et[ik - 1] >= et[in])\n    goto err112;\n\n\n  /* Allocate internal array arr. */\n\n  *iknt = newarray ((in +ik) *(ikh - ik + 1), DOUBLE);\n  if (*iknt == SISL_NULL)\n    goto err101;\n\n\n  /* If ik=ikh, just copy knots. */\n\n  kstop = in +ik;\n  if (ik == ikh)\n    {\n      *inh = in;\n      memcopy (*iknt, et, kstop, DOUBLE);\n      goto out;\n    }\n\n  /* PRODUCTION OF KNOTS: First we fill in extra knots at each\n     distinct knot value, then we remove the superfluous knots. */\n\n  numb = 0;\n  kant = ikh - ik;\n  prev = et[0] - 1;\n  for (ki = 0; ki < kstop; ki++)\n    {\n      par = et[ki];\n      if (par < prev)\n\tgoto err112;\n\n      if (par != prev)\n\t{\n\t  /* New distinct knot value, insert additional knots. */\n\n\t  for (kj = 0; kj < kant; kj++, numb++)\n\t    (*iknt)[numb] = par;\n\t}\n      (*iknt)[numb] = par;\n      prev = par;\n      numb++;\n    }\n\n  /* Remove superfluous knots at start. Find greatest start knot. */\n\n  kstart = 0;\n  tstart = et[ik - 1];\n  while ((*iknt)[kstart] <= tstart)\n    kstart++;\n  kstart--;\n\n\n  /* Find smallest end knot. */\n\n  kstop = numb - 1;\n  tstop = et[in];\n  while ((*iknt)[kstop] >= tstop)\n    kstop--;\n  kstop++;\n\n\n  /* The knots from kstart-ikh+1 up to\n   * kstop+ikh-1 are the knots to be kept. */\n\n  *inh = kstop - kstart + ikh - 1;\n\n\n  /* Copy the knots to be kept to the start of the knot array. */\n\n  kstart -= ikh - 1;\n  kstop = *inh + ikh;\n  memcopy (*iknt, &(*iknt)[kstart], kstop, double);\n\n  goto out;\n\n  /* Memory error or error in allocation. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1754\", *jstat, kpos);\n  goto out;\n\n  /* Error in description of B-spline. */\n\nerr112:\n  *jstat = -112;\n  s6err (\"s1754\", *jstat, kpos);\n  goto out;\n\nout:\n  if (*iknt != SISL_NULL)\n    {\n      *iknt = increasearray (*iknt, *inh + ikh, DOUBLE);\n      if (*iknt == SISL_NULL)\n\tgoto err101;\n    }\n  return;\n}\n"
  },
  {
    "path": "src/s1755.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1755.c,v 1.2 2005-02-28 09:04:48 afr Exp $\n *\n */\n\n\n#define S1755\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1755 (double orknt[], int in, int ik, double extknt[],\n       int *inh, int *jstat)\n\n#else\nvoid\ns1755 (orknt, in, ik, extknt, inh, jstat)\n     double orknt[];\n     int in;\n     int ik;\n     double extknt[];\n     int *inh;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : \tTo produce a knot vector of one order higher than an other\n*\t\tknot vector reflecting the same continuity as the original\n*\t\tknot vector.\n*\n*\n* INPUT      : \torknt\t\t- The original knot vector.\n*\t\t\t\t  Dimension (1:in+ik).\n*\t\tin\t\t- The number of degrees of freedom in the\n*\t\t\t\t  B-spline given by the knot vector.\n*\t\tik\t\t- The order of the basis.\n*\n* OUTPUT     :  extknt\t\t- The 'extended' knot vector.\n*\t\t\t\t  Dimension (1:inh+ik+1).\n*\t\tinh\t\t- The number of degrees of freedom in the knot\n*\t\t\t\t  vector produced.\n*               jstat           - Output status:\n*                                  < 0: Error.\n*                                  = 0: Ok.\n*                                  > 0: Warning.\n*\n* METHOD     :\tAt orknt[ik-1], (ik+1) knots are inserted. For internal knot values,\n*\t\tthe multiplicity 'M' is found, the continuity determined\n*\t\t'ik-M-1', and the new multiplicity 'M+1' deternined.\n*\t\tAt orknt[in], (ik+1) knots are inserted.\n*\n* REFERENCES :\n*\n* CALLS      : s6err.\n*\n* WRITTEN BY : \tChristophe R. Birkeland, SI, 1991-07\n* REWRITTEN BY :\n* REVISED BY :\n*\n*********************************************************************\n*/\n{\n  int ki;\t\t\t/* Loop control parameters \t\t*/\n  int kstart, kstop;\n  int numb;\n  int kpos = 0;\t\t\t/* Position indicator for errors\t*/\n  double prev, par;\t\t/* Parameters used to find consecutive\n\t\t\t\t   distinct knotvector values\t\t*/\n  double tstart, tstop;\t\t/* tstart=orknt[ik-1], tstop=orknt[in]\t*/\n\n  *jstat = 0;\n\n\n  /* Test if legal input. */\n\n  if ((ik < 1) || (in <ik))\n    goto err112;\n\n\n  /* Test if input knot vector degenerate. */\n\n  if (orknt[ik - 1] >= orknt[in])\n    goto err112;\n\n  kstop = in +ik;\n\n\n  /* PRODUCTION OF KNOTS: First we fill in extra knots at each\n     distinct knot value, then we remove the superfluous knots.\t*/\n\n  numb = 0;\n  prev = orknt[0] - 1;\n  for (ki = 0; ki < kstop; ki++)\n    {\n      par = orknt[ki];\n      if (par < prev)\n\tgoto err112;\n\n      if (par != prev)\n\t{\n\t  /* New distinct knot value, insert additional knot. */\n\n\t  extknt[numb] = par;\n\t  numb++;\n\t}\n      extknt[numb] = par;\n      prev = par;\n      numb++;\n    }\n\n  /* Remove superfluous knots at start. Find greatest start knot. */\n\n  kstart = 0;\n  tstart = orknt[ik - 1];\n  while (extknt[kstart] <= tstart)\n    kstart++;\n  kstart--;\n\n\n  /* Find smallest end knot \t\t*/\n\n  kstop = numb - 1;\n  tstop = orknt[in];\n  while (extknt[kstop] >= tstop)\n    kstop--;\n  kstop++;\n\n\n  /* The knots from kstart-ik up to\n   * kstop+ik are the knots to be kept\t*/\n\n  *inh = kstop - kstart + ik;\n\n\n  /* Copy the knots to be kept to the start of the knot array */\n\n  memcopy (extknt, &extknt[kstart - ik], *inh + ik + 1, DOUBLE);\n  goto out;\n\n\n  /* Error in description of B-spline */\n\nerr112:\n  *jstat = -112;\n  s6err (\"s1755\", *jstat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1770.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1770.c,v 1.2 2001-03-19 15:58:53 afr Exp $\n *\n */\n#define S1770\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\ns1770_s9corr(double [],double,double,double,double,double,double);\nstatic\nvoid\ns1770_s9dir(double *,double *,double *,double [],double [],double [],int);\n#else\nstatic void s1770_s9corr();\nstatic void s1770_s9dir();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1770(SISLCurve *pcurve1,SISLCurve *pcurve2,double aepsge,\n\t   double astart1,double astart2,double aend1,double aend2,\n\t   double anext1,double anext2,double *cpos1,double *cpos2,int *jstat)\n#else\nvoid s1770(pcurve1,pcurve2,aepsge,astart1,astart2,\n\t   aend1,aend2,anext1,anext2,cpos1,cpos2,jstat)\n     SISLCurve  *pcurve1;\n     SISLCurve  *pcurve2;\n     double aepsge;\n     double astart1;\n     double astart2;\n     double aend1;\n     double aend2;\n     double anext1;\n     double anext2;\n     double *cpos1;\n     double *cpos2;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Newton iteration on the distance function between\n*              two curves to find a closest point or an intersection point.\n*\n*\n* INPUT      : pcurve1 - Pointer to the first curve in the intersection.\n*              pcurve2 - Pointer to the second curve in the intersection.\n*              aepsge  - Geometry resolution.\n*              astart1 - Start parameter value of the first curve.\n*              astart2 - Start parameter value of the second curve.\n*              aend1   - End parameter value of the first curve.\n*              aend2   - End parameter value of the second curve.\n*              anext1  - Start parameter value of the iteration on\n*                        the first curve.\n*              anext2  - Start parameter value of the iteration on\n*                        the second curve.\n*\n*\n*\n* OUTPUT     : cpos1   - Parameter value of of first curve in intersection\n*                        point.\n*              cpos2   - Parameter value of of second curve in intersection\n*                        point.\n*              jstat   - status messages  \n*                                = 2   : A minimum distanse found.\n*                                = 1   : Intersection found.\n*                                < 0   : error.\n*\n*\n* METHOD     : Newton iteration in two parameter directions.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/                       \n{                        \n  int kstat = 0;            /* Local status variable.                      */\n  int kpos = 0;             /* Position of error.                          */\n  int kleft1=0,kleft2=0;    /* Variables used in the evaluator.            */\n  int kder=1;               /* Order of derivatives to be calulated        */\n  int kdim;                 /* Dimension of space the curves lie in        */\n  int knbit;                /* Number of iterations                        */\n  int kdir;                 /* Changing direction.                         */\n  double tdelta1,tdelta2;   /* Parameter interval of the curves.           */\n  double tdist;             /* Distance between position and origo.        */\n  double td[2],t1[2],tdn[2];/* Distances between old and new parameter\n\t\t\t       value in the two parameter directions.      */\n  double tprev;             /* Previous difference between the curves.     */\n  double *sval1=SISL_NULL;       /* Value ,first and second derivatie on curve 1*/ \n  double *sval2;            /* Value ,first and second derivatie on curve 1*/ \n  double *sdiff;            /* Difference between the curves               */\n  \n  /* Test input.  */\n  \n  if (pcurve1->idim != pcurve2->idim) goto err106;\n  \n  kdim = pcurve1 -> idim;\n  if (kdim == 2)\n  {\n     s1770_2D(pcurve1,pcurve2,aepsge,astart1,astart2,\n           aend1,aend2,anext1,anext2,cpos1,cpos2,jstat);\n     goto out;\n  }\n  \n  /* Fetch endpoints and the intervals of parameter interval of curves.  */\n  \n  tdelta1 = pcurve1->et[pcurve1->in] - pcurve1->et[pcurve1->ik - 1];\n  tdelta2 = pcurve2->et[pcurve2->in] - pcurve2->et[pcurve2->ik - 1];\n  \n  /* Allocate local used memory */\n  \n  sval1 = newarray((2*kder+5)*kdim,double);\n  if (sval1 == SISL_NULL) goto err101;\n  \n  sval2 = sval1 + (kder+2)*kdim;\n  sdiff = sval2 + (kder+2)*kdim;\n  \n  /* Initiate variables.  */\n  \n  tprev = (double)HUGE;\n  \n  /* Evaluate 0-1.st derivatives of both curves */\n  \n  s1221(pcurve1,kder,anext1,&kleft1,sval1,&kstat);\n  if (kstat < 0) goto error;\n  \n  s1221(pcurve2,kder,anext2,&kleft2,sval2,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Compute the distanse vector and value and the new step. */\n  \n  s1770_s9dir(&tdist,td,td+1,sdiff,sval1,sval2,kdim);\n  \n  /* Correct if we are not inside the parameter intervall. */\n  \n  t1[0] = td[0];\n  t1[1] = td[1];\n  s1770_s9corr(t1,anext1,anext2,astart1,aend1,astart2,aend2);\n  \n  /* Iterate to find the intersection point.  */\n  \n  for (knbit = 0; knbit < 30; knbit++)\n    {\n      /* Evaluate 0-1.st derivatives of both curves */\n      \n      s1221(pcurve1,kder,anext1+t1[0],&kleft1,sval1,&kstat);\n      if (kstat < 0) goto error;\n      \n      s1221(pcurve2,kder,anext2+t1[1],&kleft2,sval2,&kstat);\n      if (kstat < 0) goto error;\n      \n      \n      /* Compute the distanse vector and value and the new step. */\n      \n      s1770_s9dir(&tdist,tdn,tdn+1,sdiff,sval1,sval2,kdim);\n      \n      /* Check if the direction of the step have change. */\n      \n      kdir = (s6scpr(td,tdn,2) >= DZERO);     /* 0 if changed. */\n      \n      /* Ordinary converging. */\n      \n      if (tdist < tprev*(double)0.9 || kdir)\n\t{\n          anext1 += t1[0];\n          anext2 += t1[1];\n\t  \n          td[0] = tdn[0];\n          td[1] = tdn[1];\n\t  \n\t  /* Correct if we are not inside the parameter intervall. */\n\t  \n\t  t1[0] = td[0];\n\t  t1[1] = td[1];\n\t  s1770_s9corr(t1,anext1,anext2,astart1,aend1,astart2,aend2);\n\t  \n          if ( (fabs(t1[0]/tdelta1) <= REL_COMP_RES) &&\n\t      (fabs(t1[1]/tdelta2) <= REL_COMP_RES) ) break;\n\t  \n          tprev = tdist;\n\t}\n      \n      /* Not converging, corrigate and try again. */\n      \n      else\n\t{\n          t1[0] /= (double)2;\n          t1[1] /= (double)2;\n          /* knbit--; */\n\t}\n    }\n  \n  /* Iteration stopped, test if point founds found is within resolution */\n  \n  if (tdist <= aepsge)\n    *jstat = 1;\n  else\n    *jstat = 2;\n  \n  *cpos1 = anext1;\n  *cpos2 = anext2;\n  \n  /* Iteration completed.  */\n  \n  \n  goto out;\n  \n  /* Error in allocation */\n  \n err101: *jstat = -101;\n  s6err(\"s1770\",*jstat,kpos);\n  goto out;                  \n  \n  /* Error in input. Conflicting dimensions.  */\n  \n err106: *jstat = -106;\n  s6err(\"s1770\",*jstat,kpos);\n  goto out;                  \n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"s1770\",*jstat,kpos);\n  goto out;                  \n  \n out:    if (sval1 != SISL_NULL) freearray(sval1);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\ns1770_s9corr(double gdn[],double acoef1,double acoef2,\n\t\t   double astart1,double aend1,double astart2,double aend2)\n#else\nstatic void s1770_s9corr(gdn,acoef1,acoef2,astart1,aend1,astart2,aend2)\n     double gdn[];\n     double acoef1;\n     double acoef2;\n     double astart1;\n     double aend1;\n     double astart2;\n     double aend2;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To be sure that we are inside the boorder of the\n*              parameter plan. If we are outside clipping is used\n*\t       to corrigate the step value.\n*\n*\n* INPUT      : acoef1  - Coeffisient in the first direction.\n*              acoef2  - Coeffisient in the second direction.\n*              astart1 - The lower boorder in first direction.\n*              aend1   - The higher boorder in first direction.\n*              astart2 - The lower boorder in second direction.\n*              aend2   - The higher boorder in second direction.\n*\n*\n*\n* INPUT/OUTPUT : gdn   - Old and new step value.\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/                       \n{\n  if (acoef1 + gdn[0] < astart1) \n    gdn[0] = astart1 - acoef1;\n  else if (acoef1 + gdn[0] > aend1)   \n    gdn[0] = aend1 - acoef1;\n\n  if (acoef2 + gdn[1] < astart2) \n    gdn[1] = astart2 - acoef2;\n  else if (acoef2 + gdn[1] > aend2)   \n    gdn[1] = aend2 - acoef2;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\ns1770_s9dir(double *cdist,double *cdiff1,double *cdiff2,\n\t\t  double gdiff[],double eval1[],double eval2[],int idim)\n#else\nstatic void s1770_s9dir(cdist,cdiff1,cdiff2,gdiff,eval1,eval2,idim)\n     double *cdist;\n     double *cdiff1;\n     double *cdiff2;\n     double eval1[];\n     double eval2[];\n     double gdiff[];\n     int    idim;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the distance vector and value beetween\n*\t       a points on the first curve and a point on the second\n*\t       curve. And to compute a next step on both curves.\n*\t       This is equivalent to the nearest way to the\n*\t       parameter plan in the tangent plan from a point in the\n*\t       distance surface between two curves.\n*\n*\n* INPUT      : eval1 - Value and derevative in first parameterdirection.\n*              eval2 - Value and derevative in second parameterdirection.\n*\t       idim  - Dimension of space the curves lie in.\n*\n*\n* OUTPUT     : gdiff   - Array to use when computing the differens vector.\n*\t       cdiff1  - Relative parameter value in intersection \n*                        point in first direction.\n*              cdiff2  - Relative parameter value in intersection \n*                        point in second direction.\n*              cdist   - The value to the point in the distance surface.\n*\n*\n* METHOD     : The method is to compute the parameter distance to the points\n*\t       on both tangents which is closest to each other.\n*\t       The differens vector beetween these points are orthogonal\n*\t       to both tangents. If the distance vector beetween the two\n*\t       points on the curve is \"diff\" and the two derevativ vectors\n*\t       are \"der1\" and \"der2\", and the two wanted parameter distance\n*\t       are \"dt1\" and \"dt2\", then we get the following system of \n*\t       equations:\n*\t\t <dt1*der1+dist-dt2*der2,der2> = 0\n*\t\t <dt1*der1+dist-dt2*der2,der1> = 0\n*\t       This is futher:\n*\n*\t\t | -<der1,der2>   <der2,der2> |  | dt1 |   | <dist,der2> |\n*\t\t |                            |  |     | = |             |\n*\t\t | -<der1,der1>   <der1,der2> |  | dt2 |   | <dist,der1> |\n*\n*\t       The solution of this matrix equation is the\n*\t       following function.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/                       \n{                        \n  int kstat;\t\t           /* Local status variable. */\n  register double tdet;\t\t   /* Determinant */\n  register double t1,t2,t3,t4,t5;  /* Variables in equation system */\n  \n  /* Computing the different vector */\n  \n  s6diff(eval1,eval2,idim,gdiff);\n  \n  /* Computing the length of the different vector. */\n  \n  *cdist = s6length(gdiff,idim,&kstat);\n  \n  t1 =  s6scpr(eval1+idim,eval1+idim,idim);\n  t2 =  s6scpr(eval1+idim,eval2+idim,idim);\n  t3 =  s6scpr(eval2+idim,eval2+idim,idim);\n  t4 =  s6scpr(gdiff,eval1+idim,idim);\n  t5 =  s6scpr(gdiff,eval2+idim,idim);\n  \n  /* Computing the determinant. */\n  \n  tdet = t2*t2 - t1*t3;\n  \n  if (DEQUAL(tdet,DZERO))\n    {\n      *cdiff1 = DZERO;\n      *cdiff2 = DZERO;\n    }\n  else \n    {\n      /* Using Cramer's rule to find the solution of the system. */\n      \n      *cdiff1 =  (t4*t3 - t5*t2)/tdet;\n      *cdiff2 =  (t2*t4 - t1*t5)/tdet;\n    }\n}\n"
  },
  {
    "path": "src/s17702d.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n *\n *\n */\n#define S1770_2D\n\n\n#include \"sislP.h\"\n\n#define SINGULAR 1.0e-16\n#define copy2(a,b,c) for (ki=0;ki<(c);ki++) (a)[ki]=(b)[ki]\n#define copy3(a,b,c,d) for (ki=0;ki<(d);ki++) (a)[ki]=(b)[ki]=(c)[ki]\n#define incr2(a,b,c) for (ki=0;ki<(c);ki++) (a)[ki]+=(b)[ki]\n#define decr2(a,b,c) for (ki=0;ki<(c);ki++) (a)[ki]-=(b)[ki]\n#define set_order(a)  {if((a)==1) order=0; else order=1;}\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   s1770_2D_s9corr(double [],double[],double,double,double,double,int*);\nstatic\nvoid\n   s1770_2D_s9dir(double *dist,double diff[],double delta[],\n\t    double c1[],double c1_t[],double c1_tt[],\n\t    double c2[],double c2_t[],double c2_tt[],\n\t    int dim, int second, double* det, int* jstat);\nstatic\nvoid\n   s1770_2D_s6sekant1(SISLCurve *pcurve1,SISLCurve *pcurve2,\n\t\t double  par_val[], double delta, double *dist, double aepsge,\n\t\t double astart1,double astart2,double aend1,double aend2,\n\t\t double c1[], double c2[], double norm[],\n\t\t int *jstat);\nstatic\nint\n   s1770_2D_s6local_pretop(double dist,double diff[],double normal[],\n\t\t     double c1[],double c1_t[],double c1_tt[],\n\t\t     double c2[],double c2_t[],double c2_tt[],\n\t\t     int dim, int*jstat);\n#else\nstatic void s1770_2D_s9corr();\nstatic void s1770_2D_s9dir();\nstatic void s1770_2D_s6sekant1();\nstatic int  s1770_2D_s6local_pretop();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1770_2D(SISLCurve *pcurve1,SISLCurve *pcurve2,double aepsge,\n\t   double astart1,double astart2,double aend1,double aend2,\n\t   double anext1,double anext2,double *cpos1,double *cpos2,int *jstat)\n#else\nvoid s1770_2D(pcurve1,pcurve2,aepsge,astart1,astart2,\n\t   aend1,aend2,anext1,anext2,cpos1,cpos2,jstat)\n     SISLCurve  *pcurve1;\n     SISLCurve  *pcurve2;\n     double aepsge;\n     double astart1;\n     double astart2;\n     double aend1;\n     double aend2;\n     double anext1;\n     double anext2;\n     double *cpos1;\n     double *cpos2;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Newton iteration on the distance function between\n*              two curves to find a closest point or an intersection point.\n*\n*\n* INPUT      : pcurve1 - Pointer to the first curve in the intersection.\n*              pcurve2 - Pointer to the second curve in the intersection.\n*              aepsge  - Geometry resolution.\n*              astart1 - Start parameter value of the first curve.\n*              astart2 - Start parameter value of the second curve.\n*              aend1   - End parameter value of the first curve.\n*              aend2   - End parameter value of the second curve.\n*              anext1  - Start parameter value of the iteration on\n*                        the first curve.\n*              anext2  - Start parameter value of the iteration on\n*                        the second curve.\n*\n*\n*\n* OUTPUT     : cpos1   - Parameter value of of first curve in intersection\n*                        point.\n*              cpos2   - Parameter value of of second curve in intersection\n*                        point.\n*              jstat   - status messages\n*                                = 2   : A minimum distanse found.\n*                                = 1   : Intersection found.\n*                                < 0   : error.\n*\n*\n* METHOD     : Newton iteration in two parameter directions.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n* REWISED BY : Arne Laksaa, SINTEF-SI, Sep 1993.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;            /* Local status variable.                      */\n  int kpos = 0;             /* Position of error.                          */\n  int ki;\n  int kleft1=0,kleft2=0;    /* Variables used in the evaluator.            */\n  int dim;                  /* Dimension of space the curves lie in        */\n  int knbit;                /* Number of iterations                        */\n  int p_dir;                /* Changing direction in par-space.            */\n  int g_up,ng_up,g_dir;     /* Changing direction in geometric space.      */\n  int order;\t\t    /* Order of methode.\t\t\t   */\n  int sing = 0;\t\t    /* Mark that singularity has ocured.\t   */\n  int keep_order = 0;\n  int max_it = 20;          /* Maximum number of iterations.               */\n  double delta[2];          /* Parameter interval of the curves.           */\n  double dist;              /* Distance between the positions.             */\n  double prev_dist;         /* Previous difference between the curves.     */\n  double d[2];\t\t    /* Clipped distances between old and new par.\n\t\t\t       value in the two parameter directions.      */\n  double det;\n  double c_d[2];\t    /* Computed distances ....\t\t\t   */\n  double nc_d[2];\t    /* New computed distances ....\t\t   */\n  double *c1=SISL_NULL;          /* Value  of first curve.\t\t\t   */\n  double *c1_t;\t\t    /* First derivatiev of curve.\t\t   */\n  double *c1_tt;\t    /* Second derivatiev of curve.\t\t   */\n  double *c2;               /* Value of second curve.   \t\t   */\n  double *c2_t;\t\t    /* First derivative of second curve. \t   */\n  double *c2_tt;       \t    /* Second  derivative of second curve.\t   */\n  double *diff;             /* Difference between the curves.              */\n  double *prev_diff;        /* Previous difference.\t\t\t   */\n  double *norm;\t\t    /* Normal to the second curve.\t\t   */\n  double *norm_1;\t    /* Normal to the first curve.\t\t   */\n  double par_val[2];        /* Parameter values                            */\n  double local[48];\n  int corr = 0, div2 = 0, quick = *jstat;\n\n  if (quick) max_it = 10;  /* Reduce requirement on exactness. */\n\n  /* Test input.  */\n\n  if (pcurve1->idim != pcurve2->idim) \n    goto err106;\n\n  dim = pcurve1 -> idim;\n\n  /* Fetch endpoints and the intervals of parameter interval of curves.  */\n\n  delta[0] = pcurve1->et[pcurve1->in] - pcurve1->et[pcurve1->ik - 1];\n  delta[1] = pcurve2->et[pcurve2->in] - pcurve2->et[pcurve2->ik - 1];\n\n  /* Allocate local used memory */\n\n    if (dim > 3)\n  {\n     c1 = newarray(10*dim,double);\n     if (c1 == SISL_NULL) \n       goto err101;\n  }\n  else\n     c1 = local;\n\n  c1_t  = c1 + dim;\n  c1_tt = c1_t + dim;\n  c2    = c1_tt + dim;\n  c2_t  = c2 + dim;\n  c2_tt = c2_t + dim;\n  diff  = c2_tt + dim;\n  prev_diff = diff + dim;\n  norm      = prev_diff + dim;\n  norm_1    = norm + dim;\n\n\n\n  /* Initiate variables.  */\n\n\n  par_val[0] = anext1;\n  par_val[1] = anext2;\n\n  for (ki=1; ki<3; ki++)\n  {\n     set_order(ki);\n\n     /* Evaluate 0-2.st derivatives of curve 1 */\n\n     if (par_val[0] == aend1)\n\ts1227(pcurve1,1+order,par_val[0],&kleft1,c1,&kstat);\n     else\n\ts1221(pcurve1,1+order,par_val[0],&kleft1,c1,&kstat);\n     if (kstat < 0) \n       goto error;\n\n\n     /* Evaluate 0-2.st derivatives of curve 2 */\n\n     if (par_val[1] == aend2)\n\ts1227(pcurve2,1+order,par_val[1],&kleft2,c2,&kstat);\n     else\n\ts1221(pcurve2,1+order,par_val[1],&kleft2,c2,&kstat);\n     if (kstat < 0) \n       goto error;\n\n\n     /* Compute the distanse vector and value and the new step. */\n\n     s1770_2D_s9dir(&dist,diff,c_d, c1,c1_t,c1_tt,\n\t\t    \t\t    c2,c2_t,c2_tt,dim,order,&det,&kstat);\n     if (kstat < 0) \n       goto error;\n     if (kstat == 1) \t\t/* Singular matrix. */\n     {\n\tif (order == 1 && dist > aepsge) \n\t  goto singular;\n\telse if (order == 1) \n\t  goto not_singular;\n     }\n     else break;\n  }\n\n  /* Correct if we are not inside the parameter intervall. */\n\n  d[0] = c_d[0];\n  d[1] = c_d[1];\n  norm_1[0] = -c1_t[1]; norm_1[1] = c1_t[0];\n  norm[0]   = -c2_t[1]; norm[1]   = c2_t[0];\n  g_up = (s6scpr(diff,norm,dim) >= DZERO) ? 1 : -1;\n  g_up += ((s6scpr(diff,norm_1,dim) >= DZERO) ? 10 : -10);\n  s1770_2D_s9corr(d,par_val,astart1,aend1,astart2,aend2,&corr);\n\n  prev_dist = dist;\n  prev_diff[0] = diff[0];\n  prev_diff[1] = diff[1];\n\n  /* Iterate to find the intersection point.  */\n\n  for (knbit = 0; knbit < max_it; knbit++)\n  {\n     incr2(par_val,d,2);\n\n     while (1)\n     {\n\t/* Evaluate 0-2.st derivatives of curve */\n\n\tif (par_val[0] == aend1)\n\t   s1227(pcurve1,1+order,par_val[0],&kleft1,c1,&kstat);\n\telse\n\t   s1221(pcurve1,1+order,par_val[0],&kleft1,c1,&kstat);\n\tif (kstat < 0) \n\t  goto error;\n\n\tif (par_val[1] == aend2)\n\t   s1227(pcurve2,1+order,par_val[1],&kleft2,c2,&kstat);\n\telse\n\t   s1221(pcurve2,1+order,par_val[1],&kleft2,c2,&kstat);\n\tif (kstat < 0) \n\t  goto error;\n\n\t/* Compute the distanse vector and value and the new step. */\n\n\ts1770_2D_s9dir(&dist,diff,nc_d,c1,c1_t,c1_tt,c2,c2_t,c2_tt,\n\t\t    dim,order,&det,&kstat);\n\tif (kstat < 0) \n\t  goto error;\n\tif (kstat == 1)             /* Singular matrix.  */\n\t{\n\t   sing++;\n\t   if (order == 1 && dist > aepsge) \n\t     goto singular;\n\t   else if (order == 1) \n\t     goto not_singular;\n\t   else set_order(2);               /* Change order to 2. */\n\t}\n\telse\n\t{\n\t   norm_1[0] = -c1_t[1]; norm_1[1] = c1_t[0];\n\t   norm[0]   = -c2_t[1]; norm[1]   = c2_t[0];\n\n\t   ng_up = (s6scpr(diff,norm,dim) >= DZERO) ? 1 : -1;\n\t   ng_up += ((s6scpr(diff,norm_1,dim) >= DZERO) ? 10 : -10);\n\t   g_dir = (ng_up+g_up != 0);\t\t\t/* 0 if changed. */\n\t   p_dir = (c_d[0]*nc_d[0] >= DZERO &&\n\t\t    c_d[1]*nc_d[1] >= DZERO);\t\t/* 0 if changed. */\n\n\t   if (!order && g_dir && (!p_dir || dist > 0.4*prev_dist)\n\t\t\t\t\t\t\t&& !keep_order)\n\t   {\n\t      if (!quick && div2) div2 = 0;\n\t      set_order(2);\n\t   }\n\t   else if (order && !g_dir)\n\t   {\n\t      if (sing && dist > aepsge) \n\t\tgoto singular;\n\t      else if (sing) \n\t\tgoto not_singular;\n\t      if (div2) div2 = 0;\n\t      set_order(1);\n\t   }\n \t   else\n\t   {\n              keep_order = 0;\n\t      if (sing) sing = 0;\n\t      break;\n\t   }\n\t}\n     }\n\n     if (corr)\n\tif (!(p_dir && g_dir)) \n\t  corr = 0;\n\n     if (dist < prev_dist || p_dir)\n     {\n\n\t/* Corrigate if we are not inside the parameter interval. */\n\n\tg_up = ng_up;\n\tcopy3(d,c_d,nc_d,2);\n\ts1770_2D_s9corr(d, par_val, astart1, aend1, astart2, aend2, &corr);\n\tprev_dist = dist;\n\tcopy2(prev_diff,diff,dim);\n\n\t/* if (corr > 3) break; */\n\n\tif (corr > 2 ||\n\t    ((fabs(d[0]/MAX(par_val[0],delta[0])) <= REL_COMP_RES) &&\n\t     (fabs(d[1]/MAX(par_val[1],delta[1])) <= REL_COMP_RES))) \n\t  break;\n\tif (div2) div2 = 0;\n\n\t     if (corr > 1 && order)\n\t     {\n\t\tkeep_order = 1;\n\t\tset_order(1);\n\t     }\n     }\n\n     else if (corr > 2 ||\n\t      ((fabs(d[0]/MAX(par_val[0],delta[0])) <= REL_COMP_RES) &&\n\t       (fabs(d[1]/MAX(par_val[1],delta[1])) <= REL_COMP_RES))) \n       break;\n     else\n     {\n\t/* Not converging, corrigate and try again.  */\n\n\tif (dist > prev_dist && div2 > 5) \n\t  break;\n\tif (quick && dist > prev_dist && div2 > 3) \n\t  break;\n\tdiv2++;\n\tdecr2(par_val,d,2);\n\td[0] /= (double)2; d[1] /= (double)2;\n\n/*\tprintf(\"XXX %d, dist=%f, orden=%d\\n\",div2,dist,order); */\n     }\n  }\n\n  /* Iteration stopped, test if point founds found is within resolution */\n\n\n  if (dim == 2 /*&& fabs(det)<0.1*/)\n  {\n    if (order < 1)\n    {\n      set_order(2);\n\n      if (par_val[0] == aend1)\n\ts1227(pcurve1,1+order,par_val[0],&kleft1,c1,&kstat);\n      else\n\ts1221(pcurve1,1+order,par_val[0],&kleft1,c1,&kstat);\n      if (kstat < 0) \n\tgoto error;\n\n      if (par_val[1] == aend2)\n\ts1227(pcurve2,1+order,par_val[1],&kleft2,c2,&kstat);\n      else\n\ts1221(pcurve2,1+order,par_val[1],&kleft2,c2,&kstat);\n      if (kstat < 0) \n\tgoto error;\n    }\n    goto singular;\n  }\n\n  goto not_singular;\n\n  singular:\n\n     /*  if (!quick && dist > aepsge) */\n     if (!quick && dist > aepsge && dim == 2)\n     {\n\tki = s1770_2D_s6local_pretop(dist,diff,norm,c1,c1_t,c1_tt,\n\t\t\t\t  c2,c2_t,c2_tt,dim,&kstat);\n\n\tif (kstat < 0) \n\t  goto error;\n\tif (ki == 0)\n\t{\n\t   s1770_2D_s6sekant1(pcurve1,pcurve2,par_val,c_d[0],&dist,aepsge,\n\t\t\t   astart1,astart2,aend1,aend2,c1,c2,norm,&kstat);\n\t   if (kstat < 0) \n\t     goto error;\n\n\t}\n     }\n\nnot_singular:\n\n  if (dist <= aepsge)\n  {\n    *jstat = 1;\n  }\n  else\n  {\n\n     s6diff(c1,c2,dim,norm);\n     if ((PIHALF-s6ang(c1_t,norm,dim)) < ANGULAR_TOLERANCE &&\n         (PIHALF-s6ang(c2_t,norm,dim)) < ANGULAR_TOLERANCE)\n\t*jstat = 3;\n     else\n\t*jstat = 2;\n  }\n\n  *cpos1 = par_val[0];\n  *cpos2 = par_val[1];\n\n  /* Iteration completed.  */\n\n\n  goto out;\n\n  /* Error in allocation */\n\n err101: *jstat = -101;\n  s6err(\"s1770_2D\",*jstat,kpos);\n  goto out;\n\n  /* Error in input. Conflicting dimensions.  */\n\n err106: *jstat = -106;\n  s6err(\"s1770_2D\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n  s6err(\"s1770_2D\",*jstat,kpos);\n  goto out;\n\n out:\n    if (c1 != local && c1 != SISL_NULL) freearray(c1);\n\n    return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   s1770_2D_s9corr(double gd[],double acoef[],double astart1,double aend1,\n\t     double astart2,double aend2,int *corr)\n#else\nstatic void s1770_2D_s9corr(gd,acoef,astart1,aend1,astart2,aend2,corr)\n     double gd[];\n     double acoef[];\n     double astart1;\n     double aend1;\n     double astart2;\n     double aend2;\n     int *corr;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To be sure that we are inside the boorder of the\n*              parameter plan. If we are outside clipping is used\n*\t       to corrigate the step value.\n*\n*\n* INPUT      : acoef[]   - Parameter values.\n*              astart1 - The lower boorder in first direction.\n*              aend1   - The higher boorder in first direction.\n*              astart2 - The lower boorder in second direction.\n*              aend2   - The higher boorder in second direction.\n*\n*\n*\n* INPUT/OUTPUT : gdn   - Old and new step value.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, sep. 1993.\n*\n*********************************************************************\n*/\n{\n  int lcorr = 0;\n  if (acoef[0] + gd[0] < astart1)\n    {\n       gd[0] = astart1 - acoef[0];\n       lcorr=1;\n    }\n  else if (acoef[0] + gd[0] > aend1)\n    {\n       gd[0] = aend1 - acoef[0];\n       lcorr=1;\n    }\n\n  if (acoef[1] + gd[1] < astart2)\n    {\n       gd[1] = astart2 - acoef[1];\n       lcorr=1;\n    }\n  else if (acoef[1] + gd[1] > aend2)\n    {\n       gd[1] = aend2 - acoef[1];\n       lcorr=1;\n    }\n\n  if (lcorr)\n    (*corr)++;\n  else\n    (*corr) = 0;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   s1770_2D_s9dir(double *dist,double diff[],double delta[],\n\t    double c1[],double c1_t[],double c1_tt[],\n\t    double c2[],double c2_t[],double c2_tt[],\n\t    int dim, int second, double* det,int* jstat)\n#else\nstatic void s1770_2D_s9dir(dist,diff,delta,c1,c1_t,c1_tt,c2,c2_t,c2_tt,\n\t\t\tdim,second,det,jstat)\n     double *dist;\n     double diff[];\n     double delta[];\n     double c1[];\n     double c1_t[];\n     double c1_tt[];\n     double c2[];\n     double c2_t[];\n     double c2_tt[];\n     int    dim;\n     int    second;\n     double* det;\n     int*   jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To compute the distance vector and value beetween\n*\t       a points on the first curve and a point on the second\n*\t       curve. And to compute a next step on both curves.\n*\t       This is equivalent to the nearest way to the\n*\t       parameter plan in the tangent plan from a point in the\n*\t       distance surface between two curves.\n*\n*\n* INPUT      : c1    - Value in point on curve 1.\n*              c1_t  - First derevative of the curve 1.\n*              c1_tt - Second derevative of the curve 1.\n*              c2    - Value in point on curve 2.\n*              c2_t  - First derevative of the curve 2.\n*              c2_tt - Second derevative of the curve 2.\n*\t       dim   - Dimension of space the curves lie in.\n*              second - 1 if we have to use second order method\n*\t\t\t0 if only first order method.\n*\n*\n* OUTPUT     : dist    - The lengt of the different vector.\n*\t       diff[]  - The differens vector.\n*\t       delta[] - Relative step parameter values towards intersection on\n*                        the curve 1 delta[0] and the curve 2 delta[1].\n*\n* METHOD     : The method is to compute the parameter distance to the points\n*\t       on both tangents which is closest to each other.\n*\t       The differens vector beetween these points are orthogonal\n*\t       to both tangents. If the distance vector beetween the two\n*\t       points on the curve is \"diff\" and the two derevativ vectors\n*\t       are \"der1\" and \"der2\", and the two wanted parameter distance\n*\t       are \"dt1\" and \"dt2\", then we get the following system of\n*\t       equations:\n*\t\t <dt1*der1+dist-dt2*der2,der1+dt1*der1_2> = 0\n*\t\t <dt1*der1+dist-dt2*der2,der2+dt2*der2_2> = 0\n*\t       This is futher:\n*\n*\t| -<dist,der1_2>-<der1,der1>   <der2,der1> |  | dt1 |   | <dist,der1> |\n*\t|                           \t\t   |  |     | = |             |\n*\t| -<der2,der1>\t <der2,der2>-<dist,der2_2> |  | dt2 |   | <dist,der2> |\n*\n*\t       The solution of this matrix equation is the\n*\t       following function.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989.\n* REWICED BY : Arne Laksaa, SINTEF-SI sep. 1993.\n*\n*********************************************************************\n*/\n{\n  int kstat;\t\t\t/* Local status variable. \t\t  */\n  double a1,a2,a3;\t\t/* The A matrix, diagonal and A12.\t  */\n  double b1,b2;\t\t\t/* The B matrix, diagonal.\t  \t  */\n  double A[4],mat[4];\t\t/* Matrix in linear equation to be solved */\n  double h[2];\t\t\t/* Left side in the equation.\t\t  */\n  double x[2];\t\t\t/* Left side in the equation.\t\t  */\n  double r[2];\t\t\t/* Left side in the equation.\t\t  */\n  long double ss,aa,xx,bb;\t/* For use in iterative improvement.      */\n  int    piv[2];\t\t/* Pivotation array                       */\n  int k,k3,j;\t\t\t/* Counters.\t\t\t\t  */\n\n\n  /* Computing the different vector */\n\n  s6diff(c1,c2,dim,diff);\n\n  /* Computing the length of the different vector. */\n\n  *dist = s6length(diff,dim,&kstat);\n  if (kstat<0) goto error;\n\n  if (second || dim != 2)\n  {\n     a1 = s6scpr(c1_t,c1_t,dim);\n     a2 = s6scpr(c2_t,c2_t,dim);\n     a3 = s6scpr(c1_t,c2_t,dim);\n  }\n\n  if (second)\n  {\n     b1 = s6scpr(diff,c1_tt,dim);\n     b2 = s6scpr(diff,c2_tt,dim);\n  }\n  else b1=b2=0.0;\n\n  if (second || dim != 2)\n  {\n     mat[0] = -a1-b1;\tmat[1] = a3;\n     mat[2] = -a3;\tmat[3] = a2-b2;\n\n     h[0] =  s6scpr(diff,c1_t,dim);\n     h[1] =  s6scpr(diff,c2_t,dim);\n  }\n  else\n  {\n     mat[0] = -c1_t[0];\tmat[1] = c2_t[0];\n     mat[2] = -c1_t[1];\tmat[3] = c2_t[1];\n\n     h[0] =  diff[0];\n     h[1] =  diff[1];\n  }\n\n  for (k=0;k<4;k++) A[k]=mat[k];\n  for (k=0;k<2;k++) x[k]=h[k];\n\n  *det = A[0]*A[3]-A[1]*A[2];\n  if (fabs(*det) < 1.0e-16)\n  {\n     *jstat = 1;\n     goto out;\n  }\n\n  /* solve the linear 2x2 system */\n\n  s6lufacp(mat,piv,2,&kstat);\n  if (kstat<0) goto error;\n  if (kstat == 1)\n  {\n     *jstat = 1;\n     goto out;\n  }\n\n  s6lusolp(mat,x,piv,2,&kstat);\n  if (kstat<0) goto error;\n  if (kstat == 1)\n  {\n     *jstat = 1;\n     goto out;\n  }\n\n  for (k=0;k<2;k++) delta[k] = x[k];\n\n\n  for (k=k3=0; k<2; k++,k3+=2)\n  {\n     for (ss=0.0,j=0; j<2; j++)\n     {\n\taa = A[j+k3];\n\txx = x[j];\n\tss += aa*xx;\n     }\n     bb = h[k];\n     ss = bb-ss;\n     r[k] = ss;\n  }\n  s6lusolp(mat,r,piv,2,&kstat);\n  if (kstat<0) goto error;\n  if (kstat == 1)\n  {\n     *jstat = 1;\n     goto out;\n  }\n\n  for (k=0;k<2;k++) delta[k] = x[k] + r[k];\n\n  *jstat = 0;\n  goto out;\n\n  error :\n    *jstat = kstat;\n    s6err(\"s1770_2D_s9dir\",*jstat,0);\n    goto out;\n\n  out:\n    return;\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\n   static\n      void\n\t    s1770_2D_s6sekant1(SISLCurve *pcurve1,SISLCurve *pcurve2,\n\t\t double  par_val[], double delta, double *dist, double aepsge,\n\t\t double astart1,double astart2,double aend1,double aend2,\n\t\t double c1[], double c2[], double norm[],\n\t\t int *jstat)\n#else\nstatic void s1770_2D_s6sekant1(pcurve1,pcurve2,par_val,delta,dist,aepsge,\n\t\t\t   astart1,astart2,aend1,aend2,c1,c2,norm,jstat)\n     SISLCurve  *pcurve1;\n     SISLCurve  *pcurve2;\n     double  par_val[];\n     double  delta;\n     double  *dist;\n     double aepsge;\n     double astart1;\n     double astart2;\n     double aend1;\n     double aend2;\n     double c1[];\n     double c2[];\n     double norm[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Sekant methode iteration on the distance function between\n*              two curves to find a closest point\n*              or an intersection point.\n*\n*\n* INPUT      : pcurve1   - Pointer to the first curve in the intersection.\n*              pcurve2   - Pointer to the second curve in the intersection.\n*              delta     - Parameter distance on first curve beetveen start values.\n*              aepsge    - Geometry resolution.\n*              c1        - Array for use in evaluation.\n*              c2        - Array for use in evaluation.\n*              norm      - Array for use in evaluation.\n* INPUT/\n* OUTPUT     : par_val[] - Parameter value of the curves in\n*                          intersection point.\n*              dist      - Distance in space.\n* OUTPUT     : jstat     - status messages\n*                                = 3   : A minimum distanse found.\n*                                = 2   : Nothing found.\n*                                = 1   : Intersection found.\n*                                < 0   : error.\n*\n*\n* METHOD     : Sekant mothode in two parameter directions.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, sep 1993.\n*\n*********************************************************************\n*/\n{\n  int ki,kj;\t\t    /* Counter.\t\t\t\t\t   */\n  int kstat = 0;            /* Local status variable.                      */\n  int kpos = 0;             /* Position of error.                          */\n  int dim;                  /* Dimension of space the curves lie in        */\n  int knbit;                /* Number of iterations                        */\n  double cu_val[2];\t    /* Parameter values on curve.\t\t   */\n  double new_cu_val;\t    /* New parameter value on curve.\t\t   */\n  double *diff;\t\t    /* Difference vector between curve surface.    */\n  double y[2],new_y,delta_y;/* Signed distance.\t\t\t\t   */\n  SISLPoint *pt=SISL_NULL;\t    /* Point for use in closest point point/surface*/\n  int cu1_left = 0;\t    /* Keep left knot information for evaluator.   */\n  int cu2_left = 0;\t    /* Keep left knot information for evaluator.   */\n  int shift = 0;\t    /* Mark that the diriction have been changed.  */\n\n  *jstat = 0;\n\n  /* Test input.  */\n\n  if (pcurve1->idim != pcurve2->idim) goto err106;\n  dim = pcurve1->idim;\n  diff = c1 + dim;\n\n  if ((pt = newPoint(c1,dim,0)) == SISL_NULL) goto err101;\n\n  if (delta == 0.0) delta =1e-15;\n\n  if (par_val[0] < astart1) par_val[0] = astart1;\n  else if (par_val[0] > aend1) par_val[0] = aend1;\n\n  if ((par_val[0] == astart1 && delta < 0.0) ||\n      (par_val[0] == aend1   && delta > 0.0))\n  {\n     delta = -delta;\n     shift++;\n  }\n\n  if (fabs(delta) < (aend1 -astart1)/100.0)\n  {\n     if (delta < 0.0)\n\tdelta = (astart1 - aend1)/100.0;\n     else\n\tdelta = (aend1 - astart1)/100.0;\n  }\n  else if (fabs(delta) > (aend1 -astart1)/10.0)\n  {\n     if (delta < 0.0)\n\tdelta = (astart1 - aend1)/10.0;\n     else\n\tdelta = (aend1 - astart1)/10.0;\n  }\n\n\n  cu_val[0] = par_val[0];\n  s1221(pcurve1,0,cu_val[0],&cu1_left,pt->ecoef,&kstat);\n  if (kstat < 0) goto error;\n  s1771(pt,pcurve2,aepsge,astart2,aend2,par_val[1],par_val+1,&kstat);\n  if (kstat < 0) goto error;\n  s1221(pcurve2,1,par_val[1],&cu2_left,c2,&kstat);\n  if (kstat < 0) goto error;\n  norm[0] = -c2[3]; norm[1] = c2[2];\n  for(kj=0; kj<dim; kj++) diff[kj] = c2[kj] - pt->ecoef[kj];\n  new_y = s6norm(norm,dim,norm,&kstat);\n  if (kstat == 0)\n  {\n     (*dist)=s6length(diff,dim,&kstat);\n     new_cu_val = cu_val[0];\n     goto out;\n  }\n  if (((*dist)=s6length(diff,dim,&kstat)) < aepsge)\n  {\n     new_cu_val = cu_val[0];\n     goto out;\n  }\n  y[0] = s6scpr(norm,diff,dim);\n  cu_val[1] = cu_val[0] + delta;\n  if (cu_val[1] < astart1) cu_val[1] = astart1;\n  else if (cu_val[1] > aend1) cu_val[1] = aend1;\n\n  for (ki=0; ki<20; ki++)\n  {\n    s1221(pcurve1,0,cu_val[1],&cu1_left,pt->ecoef,&kstat);\n    if (kstat < 0) goto error;\n    s1771(pt,pcurve2,aepsge,astart2,aend2,par_val[1],par_val+1,&kstat);\n    if (kstat < 0) goto error;\n    s1221(pcurve2,1,par_val[1],&cu2_left,c2,&kstat);\n    if (kstat < 0) goto error;\n    norm[0] = -c2[3]; norm[1] = c2[2];\n    for(kj=0; kj<dim; kj++) diff[kj] = c2[kj] - pt->ecoef[kj];\n    new_y = s6norm(norm,dim,norm,&kstat);\n    if (kstat == 0)\n    {\n      (*dist)=s6length(diff,dim,&kstat);\n      new_cu_val = cu_val[1];\n      goto out;\n    }\n    if (((*dist)=s6length(diff,dim,&kstat)) < aepsge)\n    {\n      new_cu_val = cu_val[1];\n      goto out;\n    }\n    y[1] = s6scpr(norm,diff,dim);\n    new_y = y[1]/y[0];\n    if (new_y > 1.0000000000001)\n    {\n      if (shift)\n      {\n\tnew_cu_val = cu_val[1];\n\tgoto out;\n      }\n      delta = -delta;\n      cu_val[1] = cu_val[0] + delta;\n      if (cu_val[1] < astart1) cu_val[1] = astart1;\n      else if (cu_val[1] > aend1) cu_val[1] = aend1;\n      shift++;\n    }\n    else if (y[0]*y[1] <= 0.0 || new_y < 0.6) break;\n    else\n    {\n      if (cu_val[1]+delta <= aend1 &&\n\t  cu_val[1]+delta >= astart1) cu_val[1] += delta;\n      else if (cu_val[1] < aend1)  \tcu_val[1] = aend1;\n      else if (cu_val[1] > astart1)   cu_val[1] = astart1;\n      else\n      {\n\tnew_cu_val = cu_val[1];\n\tgoto out;\n      }\n    }\n  }\n\n  if (ki == 20)\n  {\n     *jstat = 2;\n     new_cu_val = par_val[0];\n     goto out;\n  }\n\n  for (knbit=0; knbit < 25; knbit++)\n  {\n     delta_y = y[0]-y[1];\n     if (fabs(delta_y) < REL_COMP_RES) break;\n\n     if (y[0]*y[1] < 0.0 &&\n\t (fabs(y[0]) < 6*fabs(y[1]) || fabs(y[1]) < 6*fabs(y[0])))\n       new_cu_val = 0.5*(cu_val[1]+cu_val[0]);\n     else\n\tnew_cu_val = cu_val[1] + y[1]*(cu_val[1]-cu_val[0])/delta_y;\n     if (new_cu_val >= aend1)\n     {\n\tnew_cu_val = aend1;\n\tif (cu_val[0] == aend1 || cu_val[1] == aend1) goto out;\n     }\n     else if (new_cu_val <= astart1)\n     {\n\tnew_cu_val = astart1;\n\tif (cu_val[0] == astart1 || cu_val[1] == astart1) goto out;\n     }\n\n     s1221(pcurve1,0,new_cu_val,&cu1_left,pt->ecoef,&kstat);\n     if (kstat < 0) goto error;\n     s1771(pt,pcurve2,aepsge,astart2,aend2,par_val[1],par_val+1,&kstat);\n     if (kstat < 0) goto error;\n     s1221(pcurve2,1,par_val[1],&cu2_left,c2,&kstat);\n     if (kstat < 0) goto error;\n     for(kj=0; kj<dim; kj++) diff[kj] = c2[kj] - pt->ecoef[kj];\n     norm[0] = -c2[3]; norm[1] = c2[2];\n     new_y = s6norm(norm,dim,norm,&kstat);\n     if (kstat == 0)\n     {\n\t(*dist) = s6length(diff,dim,&kstat);\n\tgoto out;\n     }\n     if (((*dist)=s6length(diff,dim,&kstat)) < aepsge) goto out;\n     new_y = s6scpr(norm,diff,dim);\n\n     if ((y[0] < 0.0 && y[1] > 0.0) ||\n\t (y[0] > 0.0 && y[1] < 0.0))\n     {\n\tif ((new_y > 0.0 && y[0] > 0.0) ||\n\t    (new_y < 0.0 && y[0] < 0.0))\n\t{\n\t   cu_val[0] = new_cu_val;\n\t   y[0] = new_y;\n\t}\n\telse\n\t{\n\t   cu_val[1] = new_cu_val;\n\t   y[1] = new_y;\n\t}\n     }\n     else\n     {\n\tif ( y[0] < 0.0 && new_y > 0.0)\n\t{\n\t   if (y[0] < y[1])\n\t   {\n\t      cu_val[0] = new_cu_val;\n\t      y[0] = new_y;\n\t   }\n\t   else\n\t   {\n\t      cu_val[1] = new_cu_val;\n\t      y[1] = new_y;\n\t   }\n\t}\n\telse if ( y[0] > 0.0 && new_y < 0.0)\n\t{\n\t   if (y[0] > y[1])\n\t   {\n\t      cu_val[0] = new_cu_val;\n\t      y[0] = new_y;\n\t   }\n\t   else\n\t   {\n\t      cu_val[1] = new_cu_val;\n\t      y[1] = new_y;\n\t   }\n\t}\n\telse if (y[0] > 0.0)\n\t{\n\t   if (y[0] > y[1])\n\t   {\n\t      if (new_y >=  y[0]) break;\n\t      cu_val[0] = new_cu_val;\n\t      y[0] = new_y;\n\t   }\n\t   else\n\t   {\n\t      if (new_y >=  y[1]) break;\n\t      cu_val[1] = new_cu_val;\n\t      y[1] = new_y;\n\t   }\n\n\t}\n\telse if (y[0] < 0.0)\n\t{\n\t   if (y[0] < y[1])\n\t   {\n\t      if (new_y <=  y[0]) break;\n\t      cu_val[0] = new_cu_val;\n\t      y[0] = new_y;\n\t   }\n\t   else\n\t   {\n\t      if (new_y <=  y[1]) break;\n\t      cu_val[1] = new_cu_val;\n\t      y[1] = new_y;\n\t   }\n\t}\n     }\n  }\n\n  /* Iteration completed.  */\n\n  goto out;\n\n  /* Error in allocation */\n\n  err101:\n    *jstat = -101;\n    s6err(\"s1770_2D_s6sekant1\",*jstat,kpos);\n    goto out;\n\n  /* Error in input. Conflicting dimensions.  */\n\n  err106:\n    *jstat = -106;\n    s6err(\"s1770_2D_s6sekant1\",*jstat,kpos);\n    goto out;\n\n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n    s6err(\"s1770_2D_s6sekant1\",*jstat,kpos);\n    goto out;\n\n  out:\n    par_val[0] = new_cu_val;\n    if(pt) freePoint(pt);\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\n   static\n      int\n\t    s1770_2D_s6local_pretop(double dist,double diff[],double normal[],\n\t\t     double c1[],double c1_t[],double c1_tt[],\n\t\t     double c2[],double c2_t[],double c2_tt[],\n\t\t     int dim, int*jstat)\n#else\nstatic int s1770_2D_s6local_pretop(dist,diff,normal,c1,c1_t,c1_tt,c2,c2_t,c2_tt,\n\t\t\t\tdim,jstat)\n     double dist;\n     double diff[];\n     double normal[];\n     double c1[];\n     double c1_t[];\n     double c1_tt[];\n     double c2[];\n     double c2_t[];\n     double c2_tt[];\n     int    dim;\n     int    *jstat;\n#endif\n/*\n***********************************************************************\n*\n************************************************************************\n*\n*   PURPOSE : To find if we have a minimum or a maximum or a turning\n*             point situation. This function assume that it is a singular\n*\t      situation.\n*\n*\n*\n* INPUT      : dist     - The lengt of the different vector.\n*\t       diff[]   - The differens vector.\n*\t       normal[] - The normal vector of the second curve.\n*              c1    \t- Value in point on curve.\n*              c1_t  \t- First derevative of the curve.\n*              c1_tt \t- Second derevative of the curve.\n*              c2    \t- Value in point on curve.\n*              c2_t  \t- First derivative of the curve.\n*              c2_tt \t- Second derivative of the curve.\n*\t       dim   \t- Dimension of space the curves lie in. dim = 2.\n*\n*   OUTPUT  :  return value - \t= -1: degenerated system.\n*\t\t\t\t=  0: Max or turning point.\n*\t\t\t\t=  1: Minimum position.\n*\n*              jstat        - Status variable.\n*                       \t< 0 : error.\n*                       \t= 0 : ok.\n*                       \t> 0 : warning.\n*\n*\n*   METHOD  : Testing size and direction of the second derivatives\n*             of the curve.\n*\n*   REFERENCES :\n*-\n*   CALLS      :\n*\n*   WRITTEN BY : Arne Laksaa and Vibeke Skytt, SINTEF, Oslo, sep. 1993.\n*\n************************************************************************\n*/\n{\n  int kpos = 0;\n  int return_val;\t /* For return value.\t\t\t\t*/\n  double l_1,l_2;\n  double v_1,v_2;\n  double k_1,k_2;\n  double r_1,r_2;\n\n\n  *jstat = 0;\n\n  if (dim != 2) goto err101;\n\n  l_1 = s6scpr(c1_tt,diff,dim);\n  l_2 = s6scpr(c2_tt,diff,dim);\n\n  if (( l_1 < 0.0 && l_2 > 0.0) || (l_1 > 0.0 && l_2 < 0.0))\n  {\n    return_val = 1;\n    goto out;\n  }\n\n  v_1 = s6scpr(c1_t,c1_t,dim);\n  v_1 = v_1*sqrt(v_1);\n  k_1 = fabs(c1_t[0]*c1_tt[1] - c1_tt[0]*c1_t[1]);\n  if (k_1 < REL_COMP_RES)\tr_1 = 0.0;\n  else\t\t\t\tr_1 = v_1/k_1;\n\n  v_2 = s6scpr(c2_t,c2_t,dim);\n  v_2 = v_2*sqrt(v_2);\n  k_2 = fabs(c2_t[0]*c2_tt[1] - c2_tt[0]*c2_t[1]);\n  if (k_2 < REL_COMP_RES)\tr_2 = 0.0;\n  else\t\t\t\tr_2 = v_2/k_2;\n\n\n  if (( l_1 < 0.0 || l_2 < 0.0) && (r_1 > r_2 + dist))\n    return_val = 1;\n  else if (( l_1 > 0.0 || l_2 > 0.0) && (r_2 > r_1 + dist))\n    return_val = 1;\n  else\n    return_val = 0;\n\n  goto out;\n\n\n    /* Error in allocation */\n\n  err101:\n    *jstat = -101;\n    s6err(\"s1770_2D_s6local_pretop\",*jstat,kpos);\n    goto out;\n\n  out:\n    return return_val;\n}\n"
  },
  {
    "path": "src/s1771.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1771.c,v 1.5 2005-02-28 09:04:49 afr Exp $\n *\n */\n#define S1771\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\n   s1771_s9point(SISLCurve *,double [],double [],double [],double,double,\n\t\t int,double *,double *,double,double *,double,int,int *);\n/* static\nvoid\n s1771_s9corr(double[],double,double,double); */\nstatic\ndouble\ns1771_s9del(double *,double *,double *,int);\n#else\nstatic void s1771_s9point();\n/* static void s1771_s9corr(); */\nstatic double s1771_s9del();\n#endif\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1771(SISLPoint *ppoint,SISLCurve *pcurve,double aepsge,\n\t   double astart,double aend,double anext,double *cpos,int *jstat)\n#else\nvoid s1771(ppoint,pcurve,aepsge,astart,aend,anext,cpos,jstat)\n     SISLPoint  *ppoint;\n     SISLCurve  *pcurve;\n     double aepsge;\n     double astart;\n     double aend;\n     double anext;\n     double *cpos;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Newton iteration on the distance function between\n*              a curve and a point, to find a closest point or an\n*              intersection point.\n*              If a bad choice for the guess parameter is given in, the\n*              iteration may end at a local, not global closest point.\n*\n*\n* INPUT      : ppoint  - The point in the closest point problem.\n*              pcurve  - The curve in the closest point problem.\n*              aepsge  - Geometrical resolution.\n*              astart  - Curve parameter giving the start of the search\n*                        interval.\n*              aend    - Curve parameter giving the end of the search\n*                        interval.\n*              anext   - Curve guess parameter for the closest point\n*                        iteration.\n*\n*\n*\n* OUTPUT     : cpos    - Resulting curve parameter from the iteration.\n*              jstat   - status messages\n*                                = 2   : A minimum distanse found.\n*                                = 1   : Intersection found.\n*                                < 0   : error.\n*\n*\n* METHOD     : Newton iteration.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n* Revised by : Christophe Rene Birkeland, SINTEF Oslo, May 1993.\n*              Error message corrected\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;         /* Local status variable.                           */\n  int kpos = 0;          /* Position of error.                               */\n  int kleft=0;           /* Variables used in the evaluator.                 */\n  int kdim;              /* Dimension of space the curves lie in             */\n  double tdelta;         /* Parameter interval of the curve.                 */\n  double tdist;          /* Distance between position and origo.             */\n  double td;             /* Distances between old and new parameter value in\n\t\t\t    the two parameter directions.                    */\n  double tprev;          /* Previous difference between the curves.          */\n  double *sval=SISL_NULL;     /* Value ,first and second derivatie on curve 1    */\n  double *sdiff;         /* Difference between the curves                    */\n  int quick = (*jstat);  /* Indicates if the exactness requirement is\n                            relaxed.                                         */\n  int max_it = 20;       /* Maximum number of iterations.                    */\n\n  if (quick) max_it = 10;\n\n  /* Test input.  */\n\n  if (ppoint->idim != pcurve->idim) goto err106;\n\n  kdim = pcurve -> idim;\n\n  /* Fetch endpoints and the intervals of parameter interval of curves.  */\n\n  tdelta = pcurve->et[pcurve->in] - pcurve->et[pcurve->ik - 1];\n\n  /* Allocate local used memory */\n\n  sval = newarray(4*kdim,double);\n  if (sval == SISL_NULL) goto err101;\n\n  sdiff = sval + 3*kdim;\n\n  /* Initiate variable.  */\n\n  tprev = (double)HUGE;\n\n  /* Evaluate 0-2.st derivatives of the curve. */\n\n  s1221(pcurve,2,anext,&kleft,sval,&kstat);\n  if (kstat < 0) goto error;\n\n  s6diff(ppoint->ecoef,sval,kdim,sdiff);\n\n  tdist = s6length(sdiff,kdim,&kstat);\n\n  td = s1771_s9del(sdiff,sval+kdim,sval+kdim+kdim,kdim);\n\n  /* Correct if we are not inside the parameter intervall. */\n\n  if (anext + td < astart) td = astart - anext;\n  else if (anext + td > aend) td = aend - anext;\n\n  s1771_s9point(pcurve,ppoint->ecoef,sval,sdiff,astart,aend,max_it,&anext,\n\t  &td,tdelta,&tdist,tprev,kleft,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Iteration stopped, test if point found is within resolution */\n\n  if (tdist <= aepsge)\n    *jstat = 1;\n  else\n    *jstat = 2;\n\n  *cpos = anext;\n\n  /* Iteration completed.  */\n\n  goto out;\n\n  /* Error in allocation */\n\n err101: *jstat = -101;\n  s6err(\"s1771\",*jstat,kpos);\n  goto out;\n\n  /* Error in input. Conflicting dimensions.  */\n\n err106: *jstat = -106;\n  s6err(\"s1771\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n  s6err(\"s1771\",*jstat,kpos);\n  goto out;\n\n out:    if (sval != SISL_NULL) freearray(sval);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\ns1771_s9point(SISLCurve *pcurve,double eval1[],double eval2[],double ediff[],\n\t      double astart,double aend,int max_it,double *cnext,double *ad,\n\t      double adel,double *cdist,double aprev,int ileft,int *jstat)\n#else\nstatic void s1771_s9point(pcurve,eval1,eval2,ediff,astart,aend,max_it,cnext,ad,adel,\n\t\t\t  cdist,aprev,ileft,jstat)\n     SISLCurve  *pcurve;\n     double eval1[];\n     double eval2[];\n     double ediff[];\n     double astart;\n     double aend;\n     int    max_it;\n     double *cnext;\n     double *ad;\n     double adel;\n     double *cdist;\n     double aprev;\n     int    ileft;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Newton iteration on the distance function between\n*              a point and a curve to find a closest point or an\n*              intersection point.\n*\n*\n* INPUT      : pcurve  - Pointer to the curve.\n*              eval1[] - Array containing the coefisients to the point.\n*              eval2[] - Array containing the coefisients to a start\n*                        iteration point on the curve.\n*              ediff[] - The vector between the point and the start\n*                        point on the curve.\n*              astart  - Start parameter value on the curve.\n*              aend    - End parameter value on the curve.\n*              max_it  - Maximum number of iterations.\n*              ad      - A first computed parametric step.\n*              adel    - The differrence between start and end\n*                        parameter value.\n*              aprev    -A prevous distance between the curve and\n*                        the point.\n*              ileft   - An estimate of the knot number whice is\n*                        closest to the point on the curve.\n*\n*\n* OUTPUT     : cnext   - Parameter value of curve in the closest point.\n*              cdist    -The current distance between the curve and\n*                        the point.\n*              jstat   - status messages\n*                                >= 0   : OK.\n*                                <  0   : error.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, May 1989\n* MODIFIED BY : Vibeke Skytt, SINTEF SI, 10.93. Stop earlier when divergence.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;            /* Local status variable.                      */\n  int kdim = pcurve->idim;  /* Dimension of space the curves lie in        */\n  int knbit;                /* Number of iterations                        */\n  int kdiv = 0;             /* Counts number of diverging steps.           */\n  int kdiv2 = 0;            /* Counts number of almost divergence.         */\n\n  /* Correct if we are not inside the parameter intervall. */\n\n  if (*cnext + *ad < astart)    *ad = astart - *cnext;\n  else if (*cnext + *ad > aend) *ad = aend - *cnext;\n\n  for (knbit=0;knbit<max_it;knbit++)\n    {\n      /* Evaluate 0-2.st derivatives of the curve. */\n\n      s1221(pcurve,2,*cnext + *ad,&ileft,eval2,&kstat);\n      if (kstat < 0) goto error;\n\n      s6diff(eval1,eval2,kdim,ediff);\n\n      *cdist = s6length(ediff,kdim,&kstat);\n\n      if (*cdist -aprev  <= REL_COMP_RES)\n\t{\n\t   if (kdiv2 > 4) break;\n\t   if (*cdist -aprev >= DZERO) kdiv2++;\n\n\t   kdiv = 0;\n\t  aprev = *cdist;\n\t  *cnext += *ad;\n\n\t  *ad = s1771_s9del(ediff,eval2+kdim,eval2+kdim+kdim,kdim);\n\n\t  /* Correct if we are not inside the parameter intervall. */\n\n\t  if (*cnext + *ad < astart)    *ad = astart - *cnext;\n\t  else if (*cnext + *ad > aend) *ad = aend - *cnext;\n\t}\n      else\n\t{\n\t   kdiv++;\n\t   if (kdiv > 3) break;\n\t  (*ad) /= (double)2;\n\t  /** knbit--; */\n\t}\n      if (fabs((*ad)/MAX(fabs(*cnext),adel)) <= REL_COMP_RES) break;\n    }\n\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n  s6err(\"s1771_s9point\",*jstat,0);\n  goto out;\n\n out:   ;\n}\n/*\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\ns1771_s9corr(double gdn[],double acoef,double astart,double aend)\n#else\nstatic void s1771_s9corr(gdn,acoef,astart,aend)\n     double gdn[];\n     double acoef;\n     double astart;\n     double aend;\n#endif\n*/\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To be sure that we are inside the boorder of the\n*              parameter plan. If we are outside clipping is used\n*\t       to corrigate the step value.\n*\n*\n* INPUT      : acoef  - Coeffisient in the first direction.\n*              astart - The lower boorder in first direction.\n*              aend   - The higher boorder in first direction.\n*\n*\n*\n* INPUT/OUTPUT : gdn   - Old and new step value.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/\n/*\n{\n  if (acoef + gdn[0] < astart)\n    gdn[0] = astart - acoef;\n  else if (acoef + gdn[0] > aend)\n    gdn[0] = aend - acoef;\n}\n*/\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\ndouble\ns1771_s9del(double *eco,double *eco1,double *eco2,int idim)\n#else\nstatic double s1771_s9del(eco,eco1,eco2,idim)\n     double *eco;\n     double *eco1;\n     double *eco2;\n     int    idim;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To compute the distance on the parameter line to a point\n*            on the curve on which the tangent is orthogonal to the\n*            difference vector from this point on the curve to the\n*            point in the space.\n*\n*\n* INPUT      : eco   - The differens vector beetween the point and the\n*                      current posision on the curve.\n*              eco1  - The first derevative vector in the  current posision\n*                      on the curve.\n*              eco2  - The second derevative vector in the  current posision\n*                      on the curve.\n*              idim  - Dimension of space the vectors lie in.\n*\n*\n* OUTPUT     : s1771_s9del - The computed parameter distance.\n*\n*\n* METHOD     : We have to find the parameter distance \"dt\" from\n*              the equation:\n*                <ecoef-dt*ecoef1,ecoef1+dt*ecoef2> = 0.\n*              This may be written:\n*                  <ecoef,ecoef1> + <ecoef,ecoef2>*dt\n*                - <ecoef1,ecoef1>*dt + <ecoef1,ecoef2>*dt*dt = 0\n*              The following function is the solution of this second\n*              degree equation. We are always using the solution\n*              with the smallest absolute value.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Mar 1989\n*\n*********************************************************************\n*/\n{\n  double t1,t2,t3,t4,t5,t6;   /* Constants in equation.                    */\n  double tmax,tmax1;          /* Max values in equation.                   */\n  double ttol=(double)1e-10;  /* Relative tolerance in equation.           */\n\n  t1 =  s6scpr(eco,eco1,idim);\n  t3 =  s6scpr(eco1,eco1,idim);\n  t2 =  t3 - s6scpr(eco,eco2,idim);\n  t4 =  -(double)2 * s6scpr(eco1,eco2,idim);\n\n  tmax  = max(fabs(t1),fabs(t2));\n  tmax1 = max(fabs(t3),fabs(t4));\n  tmax  = max(tmax1,tmax);\n\n  if (DEQUAL(tmax,DZERO))                    return DZERO;\n\n  else if (fabs(t4)/tmax < ttol) /* The second degree part is degenerated. */\n    {\n      if (fabs(t2)/tmax < ttol)\n\t{\n          if (fabs(t3)/tmax < ttol)        return DZERO;\n          else                             return (t1/t3);\n\t}\n      else                                  return (t1/t2);\n    }\n  else  /* An ordinary second degree equation.    */\n    {\n      t5 = t2*t2 - (double)2*t4*t1;\n      if (t5 < DZERO)                       return (t1/t3);\n      else\n\t{\n          t6 = sqrt(t5);\n          t5 = (t2 + t6)/t4;\n          t6 = (t2 - t6)/t4;\n\t  t1 *= t3;\n\n\n          /* We have two solutions and we want to use the one\n\t     with the same sign as we get while using an other\n\t     metode t1/t3. If both solutions have the same\n\t     sign we use the one with smallest value. */\n\n          if (t1 < DZERO)\n\t    {\n\t      if (t5 <= DZERO && t6 <= DZERO)\n\t\t{\n\t\t  if (t5 > t6)             return t5;\n\t          else                     return t6;\n\t\t}\n\t      else if (t5 <= DZERO)        return t5;\n\t      else if (t6 <= DZERO)        return t6;\n              else                         return min(t5,t6);\n\t    }\n\t  else if (t1 > DZERO)\n\t    {\n\t      if (t5 >= DZERO && t6 >= DZERO)\n\t\t{\n\t\t  if (t5 < t6)             return t5;\n\t          else                     return t6;\n\t\t}\n\t      else if (t5 >= DZERO)        return t5;\n\t      else if (t6 >= DZERO)        return t6;\n              else                         return max(t5,t6);\n\t    }\n\t  else                             return min(fabs(t5),fabs(t6));\n\t}\n    }\n}\n"
  },
  {
    "path": "src/s1772.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1772.c,v 1.3 2005-02-28 09:04:49 afr Exp $\n *\n */\n#define S1772\n\n#include \"sislP.h\"\n\n#define SINGULAR 1.0e-16\n#define copy2(a,b,c) for (ki=0;ki<(c);ki++) (a)[ki]=(b)[ki]\n#define copy3(a,b,c,d) for (ki=0;ki<(d);ki++) (a)[ki]=(b)[ki]=(c)[ki]\n#define incr2(a,b,c) for (ki=0;ki<(c);ki++) (a)[ki]+=(b)[ki]\n#define decr2(a,b,c) for (ki=0;ki<(c);ki++) (a)[ki]-=(b)[ki]\n#define set_order(a) if((a)==1) {s_v=s_uu;order=0;} else {s_v=s_v1;order=1;}\n/* extern int debug_flag; */\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\ns1772_s9corr(double[],double[],double,double,double[],double[],int*);\nstatic\nvoid\ns1772_s9dir(double*,double[],double[],double[],double[],double[],double[],\n\t    double[],double[],double[],double[],double[],int,int,int*);\nstatic\nvoid\ns1772_s6sekant1(SISLCurve *,SISLSurf *,double[],double,double *,double,double,\n\t\tdouble[],double,double[],double[],double[],double[],int *);\nstatic\nint\ns1772_s6local_pretop(double,double[],double[],double[],double[],double[],\n\t\t     double[],double[],double[],double[],double[],double[],\n\t\t     int,int*);\n#else\nstatic void s1772_s9corr();\nstatic void s1772_s9dir();\nstatic void s1772_s6sekant1();\nstatic int s1772_s6local_pretop();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1772(SISLCurve *pcurve,SISLSurf *psurf,double aepsge,\n\t   double astart1,double estart2[],double aend1,double eend2[],\n\t   double anext1,double enext2[],double *cpos1,double gpos2[],\n\t   int *jstat)\n#else\nvoid s1772(pcurve,psurf,aepsge,astart1,estart2,aend1,eend2,\n\t   anext1,enext2,cpos1,gpos2,jstat)\n     SISLCurve  *pcurve;\n     SISLSurf   *psurf;\n     double aepsge;\n     double astart1;\n     double estart2[];\n     double aend1;\n     double eend2[];\n     double anext1;\n     double enext2[];\n     double *cpos1;\n     double gpos2[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Newton iteration on the distance function between\n*              a curve and a surface to find a closest point\n*              or an intersection point.\n*\n*\n* INPUT      : pcurve    - Pointer to the curve in the intersection.\n*              psurf     - Pointer to the surface in the intersection.\n*              aepsge    - Geometry resolution.\n*              astart1   - Start parameter value of the curve.\n*              estart2[] - Start parameter value of surface.\n*              aend1     - End parameter value of the curve.\n*              eend2[]   - End 1.st parameter value of the surface.\n*              anext1    - Start parameter value of the iteration on\n*                          the curve.\n*              enext2[]  - Start parameter value of the iteration on\n*                          the surface.\n*              jstat     -\t=1   : A quick version is to be used.  \n*\t\t\t\telse : Importent to find a solution.\n*\n*\n* OUTPUT     : cpos1   - Parameter value of the curve in intersection\n*                        point.\n*              gpos2[] - Parameter value of the surface in\n*                        intersection point.\n*              jstat   - status messages  \n*                                = 3   : A minimum distanse found.\n*                                = 2   : Nothing found.\n*                                = 1   : Intersection found.\n*                                < 0   : error.\n*\n*\n* METHOD     : Newton iteration in tree parameter directions.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Nov 1992\n*\n*********************************************************************\n*/                       \n{\n  int ki;\t\t    /* Counter.\t\t\t\t\t   */\n  int kstat = 0;            /* Local status variable.                      */\n  int kpos = 0;             /* Position of error.                          */\n  int left[3];              /* Variables used in the evaluator.            */\n  int dim;                  /* Dimension of space the curves lie in        */\n  int knbit;                /* Number of iterations                        */\n  int p_dir;                /* Changing direction in par-space.            */\n  int g_up,ng_up,g_dir;     /* Changing direction in geometric space.      */\n  int order;\t\t    /* Order of methode.\t\t\t   */\n  int sing = 0;\t\t    /* Mark that singularity has ocured.\t   */\t\n  double *c0=SISL_NULL;          /* Value  of curve.\t\t\t\t   */ \n  double *c_t;\t\t    /* First derivatiev of curve.\t\t   */ \n  double *c_tt;\t\t    /* Second derivatiev of curve.\t\t   */ \n  double *s0;               /* Value of surf. \t\t\t\t   */\n  double *s_u;\t\t    /* First derivatiev in first dir of surf. \t   */\n  double *s_v;\t\t    /* First derivatiev in second dir of surf.\t   */\n  double *s_uu;\t\t    /* Second derivatiev in first dir of surf. \t   */\n  double *s_vv;\t\t    /* Second derivatiev in second dir of surf.\t   */\n  double *s_uv;\t\t    /* Cross derivatiev of surf.\t   \t   */\n  double *s_v1;\t\t    /* First derivatiev in second dir of surf.\t   */\n  double *norm;\t\t    /* Normal to the surface.\t\t\t   */\n  double *diff;             /* Difference between the curve and the surf.  */\n  double *prev_diff;        /* Previous difference.\t\t\t   */\n  double delta[3];          /* Parameter interval of the curve and surface.*/\n  double d[3];\t\t    /* Clipped distances between old and new par.\n\t\t\t       value in the tree parameter directions.     */\n  double c_d[3];\t    /* Computed distances ....\t\t\t   */\n  double nc_d[3];\t    /* New computed distances ....\t\t   */\n  double dist;              /* Distance between position and origo.        */\n  double prev_dist;         /* Previous difference between the curves.     */\n  double par_val[3];        /* Parameter values                            */\n  double local[45];\n  int corr = 0, div2 = 0;\n\n\n  \n  \n  /* Test input.  */\n  \n  if (pcurve->idim != psurf->idim) goto err106;  \n  dim = pcurve->idim;\n  \n  /* Fetch endpoints and the intervals of parameter interval of curves.  */\n  \n  delta[0] = psurf->et1[psurf->in1] - psurf->et1[psurf->ik1 - 1];\n  delta[1] = psurf->et2[psurf->in2] - psurf->et2[psurf->ik2 - 1];\n  delta[2] = pcurve->et[pcurve->in] - pcurve->et[pcurve->ik - 1];\n  \n  /* Allocate local used memory and set value pointers.*/\n\n  if (dim > 3)\n  {\n     c0 = newarray((15)*dim,double);\n     if (c0 == SISL_NULL) goto err101;\n  }\n  else\n     c0 = local;\n  \n  s0 = c0 + 3*dim;\n  diff = s0 + 10*dim;\n  prev_diff = diff+dim;\n  c_t = c0+dim;\n  c_tt = c_t+dim;\n  s_u = s0+dim;\n  s_uu = s_u+dim;\n  s_v1 = s_uu+dim;\n  s_uv  = s_v1+dim;\n  s_vv = s_uv+dim+dim;\n  norm = s_vv+dim;\n    \n  /* Initiate variables.  */\n\n  copy2(par_val,enext2,2);\n  par_val[2] = anext1;\n  left[0]=left[1]=left[2]=0;  \n  \n  for (ki=1; ki<3; ki++)\n  {\n     set_order(ki);\n     \n     /* Evaluate 0-2.st derivatives of curve */\n     \n     if (par_val[2] == aend1)\n\ts1227(pcurve,1+order,par_val[2],left+2,c0,&kstat);\n     else\n\ts1221(pcurve,1+order,par_val[2],left+2,c0,&kstat);\n     if (kstat < 0) goto error;\n     \n     /* Evaluate 0-2.st derivatives of surface */\n     \n     s1424(psurf,1+order,1+order,par_val,left,left+1,s0,&kstat);\n     if (kstat < 0) goto error;\n     \n     /* Compute the distanse vector and value and the new step. */\n     \n     s1772_s9dir(&dist,diff,c_d, c0,c_t,c_tt,\n\t\t s0,s_u,s_v,s_uu,s_uv,s_vv, dim,order,&kstat);\n     if (kstat < 0) goto error;\n     if (kstat == 1) \t\t/* Singular matrix. */\n     {\n\tif (order == 1) goto singular;\n     }\n     else break;\n  }\n  \n  /* Correct if we are not inside the parameter intervall. */\n  \n  s6crss(s_u,s_v,norm);\n  g_up = ((s6scpr(diff,norm,dim) >= DZERO) ? 1 : -1);\n  copy2(d,c_d,3);\n  s1772_s9corr(d,par_val, astart1,aend1,estart2,eend2,&corr);\n  prev_dist = dist;\n  copy2(prev_diff,diff,dim);      \n  \n  /* Iterate to find the intersection point.  */\n  \n  for (knbit = 0; knbit < 30; knbit++)\n  {\n     incr2(par_val,d,3);\n     \n     while (1)\n     {\n\t/* Evaluate 0-2.st derivatives of curve */\n\t\n\tif (par_val[2] == aend1)\n\t   s1227(pcurve,1+order,par_val[2],left+2,c0,&kstat);\n\telse\n\t   s1221(pcurve,1+order,par_val[2],left+2,c0,&kstat);\n\tif (kstat < 0) goto error;\n\t\n\t/* Evaluate 0-2.st derivatives of surface */\n\t\n\ts1424(psurf,1+order,1+order,par_val,left,left+1,s0,&kstat);\n\tif (kstat < 0) goto error;\n\t\n\t/* Compute the distanse vector and value and the new step. */\n\t\n\t\n\ts1772_s9dir(&dist,diff,nc_d, c0,c_t,c_tt,\n\t\t    s0,s_u,s_v,s_uu,s_uv,s_vv, dim,order,&kstat);\n\tif (kstat < 0) goto error;      \n\tif (kstat == 1) \t\t/* Singular matrix. */\n\t{\n\t   sing++;\n\t   if (order == 1) goto singular;\n\t   else\t set_order(2);\t\t/* Change to order 2. */\n\t}\n\telse\n\t{\n\t   s6crss(s_u,s_v,norm);\n\t   ng_up = ((s6scpr(diff,norm,dim) >= DZERO) ? 1 : -1);\n\t   \n\t   g_dir = (ng_up+g_up != 0);\t\t\t/* 0 if changed. */\n\t   p_dir = (s6scpr(c_d,nc_d,3) >= DZERO);\t/* 0 if changed. */\n\t   \n\t   if (!order && g_dir && (!p_dir || dist > 0.3*prev_dist))\n\t   {\n\t      if (div2) div2 = 0;\n\t      set_order(2);\n\t      /*  if (debug_flag) printf(\"\\n order-2 \");*/\n\t   }\n\t   else if (order && !g_dir)\n\t   {\n\t      if (sing) goto singular;\n\t      if (div2) div2 = 0;\n\t      set_order(1);\n\t      /*  if (debug_flag) printf(\"\\n  order-1 \"); */\n\t   }\n\t   else\n\t   {\n\t      if (sing) sing = 0;\n\t      break;\n\t   }\n\t}\n     }\n     \n     if (corr)\n\tif (!(p_dir && g_dir)) corr = 0;\n\n     if (dist < prev_dist)\n     {\n\tif (div2) div2 = 0;\n\t\n\t/* Corrigate if we are not inside the parameter intervall. */\n\t\n\tg_up = ng_up;\n\tcopy3(d,c_d,nc_d,3);\n\ts1772_s9corr(d,par_val, astart1,aend1,estart2,eend2,&corr);\n\tprev_dist = dist;\n\tcopy2(prev_diff,diff,dim);\n\t\n\t/* Testing */\n\t/*\tif (quick && corr > 3) break; */\n\tif (corr > 3) break;\n     }    \n     else if ( corr > 3 ||\n\t     ((fabs(d[0]/delta[0]) <= REL_COMP_RES) &&\n\t      (fabs(d[1]/delta[1]) <= REL_COMP_RES) &&\n\t      (fabs(d[2]/delta[2]) <= REL_COMP_RES)))     break;\n     else\n     {\n\t/* Not converging, corrigate and try again. */\n\t/*  if (debug_flag) printf(\" *h*:%d \",knbit);*/\n\n\tif (corr) corr++;\n\tif (dist > prev_dist && div2) break;\n\tdiv2++;\n        decr2(par_val,d,3);\n\td[0] /= 2; d[1] /= 2; d[2] /= 2;\n     }\n  }\n\t\n\t/* Iteration stopped, test if point found is within resolution */\n  \n  goto not_singular;\n  \nsingular:\n   \n   /*  if (!quick && dist > aepsge) */\n     if (dist > aepsge)\n     {\n\tki = s1772_s6local_pretop(dist,diff,norm,c0,c_t,c_tt,\n\t\t\t    s0,s_u,s_v,s_uu,s_uv,s_vv,dim,&kstat);\n\tif (kstat < 0) goto error;\n\tif (ki == 0)\n\t{\n\t   s1772_s6sekant1(pcurve,psurf,par_val,c_d[2],&dist,aepsge,\n\t\t\t   astart1,estart2,aend1,eend2,c0,s0,norm,&kstat);  \n\t   if (kstat < 0) goto error;\n\t}\n     }\n     \nnot_singular:\t\n  if (dist <= aepsge)\n  {\n     /* if (debug_flag) printf(\"\\n FOUND: %d dist = %g\",knbit,dist); */\n\n    *jstat = 1;\n  }\n  else\n  {\n     /*if (debug_flag) printf(\"\\n no: %d dist = %g\",knbit,dist);*/\n\n     s6crss(s_u,s_v,norm);\n     if ((PIHALF-s6ang(c_t,norm,dim)) < ANGULAR_TOLERANCE)\n\t*jstat = 3;\n     else\n\t*jstat = 2;\n  }\n  \n  /* if (knbit > 25)\n     if (debug_flag) printf(\"\\n *****status: %d dist: %f \\tknbit: %d\",\n\t\t\t    *jstat,dist,knbit); */\n\n  *cpos1 = par_val[2];\n  gpos2[0] = par_val[0];\n  gpos2[1] = par_val[1];\n  \n  /* Iteration completed.  */\n  \n  goto out;\n  \n  /* Error in allocation */\n  \n  err101: \n    *jstat = -101;\n    s6err(\"s1772\",*jstat,kpos);\n    goto out;                  \n  \n  /* Error in input. Conflicting dimensions.  */\n  \n  err106: \n    *jstat = -106;\n    s6err(\"s1772\",*jstat,kpos);\n    goto out;                  \n  \n  /* Error in lower level routine.  */\n  \n  error : \n    *jstat = kstat;\n    s6err(\"s1772\",*jstat,kpos);\n    goto out;                  \n  \n  out:\n    if (c0 != local && c0 != SISL_NULL) freearray(c0);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\ns1772_s9corr(double gd[],double acoef[],double astart1,double aend1,\n\t     double astart2[],double aend2[],int *corr)\n#else\nstatic void s1772_s9corr(gd,acoef,astart1,aend1,astart2,aend2,corr)\n     double gd[];\n     double acoef[];\n     double astart1;\n     double aend1;\n     double astart2[];\n     double aend2[];\n     int *corr;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To be sure that we are inside the boorder of the\n*              parameter plan. If we are outside clipping is used\n*\t       to corrigate the step value.\n*\n*\n* INPUT      : acoef[]   - Parameter values.\n*              astart1   - The lower boorder in curve.\n*              aend1     - The higher boorder in curve.\n*              estart2[] - The lower boorder in surface.\n*              eend2[]   - The higher boorder in surface.\n*\n*\n*\n* INPUT/OUTPUT : gdn   - Old and new step value.\n*\n*\n* METHOD     : We are cutting a line inside a rectangle.\n*\t       In this case we always know that the startpoint of\n*\t       the line is inside the rectangel, and we may therfor\n*\t       use a simple kind of clipping.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Nov 1992.\n*\n*********************************************************************\n*/                       \n{\n  int lcorr = 0;\n  if (acoef[0] + gd[0] < astart2[0])  \n    {\n       gd[0] = astart2[0] - acoef[0]; \n       lcorr=1;\n    }\n  else if (acoef[0] + gd[0] > aend2[0]) \n    {\n       gd[0] = aend2[0] - acoef[0]; \n       lcorr=1;\n    }\n  \n  if (acoef[1] + gd[1] < astart2[1])  \n    {\n       gd[1] = astart2[1] - acoef[1]; \n       lcorr=1;\n    }\n  else if (acoef[1] + gd[1] > aend2[1]) \n    {\n       gd[1] = aend2[1] - acoef[1]; \n       lcorr=1;\n    }\n  \n  if (acoef[2] + gd[2] < astart1)  \n    {\n       gd[2] = astart1 - acoef[2]; \n       lcorr=1;\n    }\n  else if (acoef[2] + gd[2] > aend1) \n    {\n       gd[2] = aend1 - acoef[2]; \n       lcorr=1;\n    }\n  \n  if (lcorr) \n    (*corr)++;\n  else \n    (*corr) = 0;\n}\n   \n#if defined(SISLNEEDPROTOTYPES)\n   static\n      void\ns1772_s9dir(double *dist,double diff[],double delta[],\n\t\t  double f[],double f_t[],double f_tt[],\n\t\t  double g[],double g_u[],double g_v[],\n\t\t  double g_uu[],double g_uv[],double g_vv[],\n\t\t  int dim,int second,int* jstat)\n#else\nstatic void s1772_s9dir(dist,diff,delta,f,f_t,f_tt,g,g_u,g_v,g_uu,\n\t\t\tg_uv,g_vv,dim,second,jstat)\n     double *dist;\n     double diff[];\n     double delta[];\n     double f[];\n     double f_t[];\n     double f_tt[];\n     double g[];\n     double g_u[];\n     double g_v[];\n     double g_uu[];\n     double g_uv[];\n     double g_vv[];\n     int    dim;\n     int    second;\n     int*   jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the distance vector and the length of the\n*              distance vector.\n*\t       And to compute a next step on all tree parameter direction\n*\t       towards an intersection or a closest point.\n*\n*\n* INPUT      : f    - Value in point on curve.\n*              f_t  - First derevative of the curve.\n*              f_tt - Second derevative of the curve.\n*              g    - Value in point on surface.\n*\t       g_u  - Derevative of the surface in first par-dir.\n*\t       g_u  - Derevative of the surface in second par-dir.\n*\t       g_uu - Second derevative of the surface in first par-dir.\n*\t       g_uv - Cross derevative of the surface.\n*\t       g_vv - Second derevative of the surface in second par-dir.\n*\t       dim    - Dimension of space the curve/surface lie in.\n*              second - 1 if we have to use second order method \n*\t\t\t0 if only first order method.\n*\n* OUTPUT     : dist    - The lengt of the different vector.\n*\t       diff[]  - The differens vector.\n*\t       delta[] - Relative step parameter values towards intersection on\n*                        the curve delta[2] and the surface (delta[0],delta[1]).\n*\n*\n* METHOD     : We have a point on the curve and a point on the surface.\n*\t       The distance vector between this two point are going towards\n*\t       eider zero length or to be orthogonal to the derivative on\n*\t       the curve and the derivatives on the surface.\n*\t       The method is to use Newton itarations.\n*\t       The dot product between the distance vecore and the derivatives\n*\t       are going to be zero.\n*\t       We then use Taylor expasion bouth on the position and\n*\t       the derivatives. Then we just remove the second degree parts\n*\t       of the eqations. The matrix is then splited into a first order\n*\t       part A:\n*\t\t     | -g_u |\t\n*\t\t K = | -g_v |    ,and       A = K*K(transpost)\n*\t\t     |  f_t | \t\n*\n*\t         where f_t is the first derivative of the curve,\n*\t         and  g_u is the first derivative of the surface in first dir,\n*\t         and  g_v is the first derivative of the surface in second dir,\n*\n*\t       and a second order part B:\n*\t\t     | -<d,g_uu>   -<d,g_uv> \t\t |\n*\t\t B = | -<d,g_uv>   -<d,g_vv>\t\t |\n*\t\t     |  \t\t\t<d,f_tt> |\n*\n*\t         where d is the distance vector,\n*\t         and f_tt is second derivative of the curve,\n*\t         and  g_uu is second derivative of the surface in first dir,\n*\t         and  g_vv is second derivative of the surface in second dir,\n*\t         and  g_uv is cross derivative of the surface.\n*\n*\t       We then has the following possible eqations:\n*\n*\t                 (A+B)*delta = -K*d, or \n*\t\t             A*delta = -K*d, or\n*\t          K(transpost)*delta = -d.\n*\n*\n*\t       The solutions of these matrix equations are the\n*\t       following function.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Nov 1992.\n*\n*********************************************************************\n*/                       \n{                        \n  int kstat;\t\t\t/* Local status variable. \t\t  */\n  double a1,a2,a3,a4,a5,a6;\t/* The A matrix, diagonal and A12 A13 A23.*/\n  double b1,b2,b3,b4;\t\t/* The B matrix, diagonal and B23.\t  */\n  double A[9],mat[9];\t\t/* Matrix in linear equation to be solved */\n  double h[3];\t\t\t/* Left side in the equation.\t\t  */\n  double x[3];\t\t\t/* Left side in the equation.\t\t  */\n  double r[3];\t\t\t/* Left side in the equation.\t\t  */\n  double det;\t\t\t/* Determinant for matrix.\t\t  */\n  long double ss,aa,xx,bb;\t/* For use in iterative improvement.      */\n  int    piv[3];\t\t/* Pivotation array                       */\n  int k,k3,j;\t\t\t/* Counters.\t\t\t\t  */\n  \n  /* Initialize */\n  delta[0] = delta[1] = delta[2] = 0.0;\n  \n  /* Computing the different vector */\n  \n  s6diff(f,g,dim,diff);\n  \n  /* Computing the length of the different vector. */\n  \n  *dist = s6length(diff,dim,&kstat);\n  if (kstat<0) goto error;\n  \n  if (second || dim != 3)\n  {\n     a1 = s6scpr(f_t,f_t,dim);\n     a2 = s6scpr(g_u,g_u,dim);\n     a3 = s6scpr(g_v,g_v,dim);\n     a4 = s6scpr(f_t,g_u,dim);\n     a5 = s6scpr(f_t,g_v,dim);\n     a6 = s6scpr(g_u,g_v,dim);\n  }\n  \n  if (second)\n  {\n     b1 = s6scpr(diff,f_tt,dim);\n     b2 = s6scpr(diff,g_uu,dim);\n     b3 = s6scpr(diff,g_vv,dim);\n     b4 = s6scpr(diff,g_uv,dim);\n  }\n  else \n    b1=b2=b3=b4=0;\n\n  if (second || dim != 3)\n  {  \n     mat[0] = a2-b2;\tmat[1] = a6-b4;\t\tmat[2] = -a4;\n     mat[3] = a6-b4;\tmat[4] = a3-b3;\t\tmat[5] = -a5;\n     mat[6] = -a4;\tmat[7] = -a5;\t\tmat[8] = a1+b1;\n     \n     h[0] =  s6scpr(diff,g_u,dim);\n     h[1] =  s6scpr(diff,g_v,dim);\n     h[2] = -s6scpr(diff,f_t,dim);\n  }\n  else\n  {\n     mat[0] = g_u[0];\tmat[1] = g_v[0];\tmat[2] = -f_t[0];\n     mat[3] = g_u[1];\tmat[4] = g_v[1];\tmat[5] = -f_t[1];\n     mat[6] = g_u[2]; \tmat[7] = g_v[2];\tmat[8] = -f_t[2];\n     \n     h[0] =  diff[0];\n     h[1] =  diff[1];\n     h[2] =  diff[2];\n  }\n  \n  for (k=0;k<9;k++) A[k]=mat[k];\n  for (k=0;k<3;k++) x[k]=h[k];\n  \n  det = A[0]*(A[4]*A[8]-A[5]*A[7])\n      - A[1]*(A[3]*A[8]-A[5]*A[6])\n      + A[2]*(A[3]*A[7]-A[4]*A[6]);\n  if (fabs(det) < 1.0e-16)\n  {\n     *jstat = 1;\n     goto out;\n  }  \n     \n  /* solve the linear 3x3 system */\n\n  /*  s1772_s6lufacp(mat,piv,&kstat); */\n  s6lufacp(mat,piv,3,&kstat);\n  if (kstat<0) goto error;\n  if (kstat == 1)\n  {\n     *jstat = 1;\n     goto out;\n  }  \n  \n  s6lusolp(mat,x,piv,3,&kstat);\n  if (kstat<0) goto error;\n  if (kstat == 1)\n  {\n     *jstat = 1;\n     goto out;\n  }\n  \n  for (k=0;k<3;k++) delta[k] = x[k];\n\n  for (k=k3=0; k<3; k++,k3+=3)\n  {\n     for (ss=0.0,j=0; j<3; j++)\n     {\n\taa = A[j+k3];\n\txx = x[j];\n\tss += aa*xx;\n     }\n     bb = h[k];\n     ss = bb-ss;\n     r[k] = ss;\n  }\n  s6lusolp(mat,r,piv,3,&kstat);\n  if (kstat<0) goto error;\n  if (kstat == 1)\n  {\n     *jstat = 1;\n     goto out;\n  }\n\n  for (k=0;k<3;k++) delta[k] = x[k] + r[k];\n  \n  /* if (debug_flag) printf(\"\\nITERATIV IMPROVES: r = (%g %g %g) \",\n\t\t\t delta[0]-x[0],delta[1]-x[1],delta[2]-x[2]); */\n\n  *jstat = 0;\n  goto out;\n\n  error : \n    *jstat = kstat;\n    s6err(\"s1772_s9dir\",*jstat,0);\n    goto out;                  \n\t       \n  out: \n    return;\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\n   static\n      void\ns1772_s6sekant1(SISLCurve *pcurve,SISLSurf *psurf,\n\t\t double  par_val[], double delta, double *dist, double aepsge,\n\t\t double astart1,double estart2[],double aend1,double eend2[],\n\t\t double c0[], double s0[], double norm[],\n\t\t int *jstat)\n#else\nstatic void s1772_s6sekant1(pcurve,psurf,par_val,delta,dist,aepsge,\n\t\t\t   astart1,estart2,aend1,eend2,c0,s0,norm,jstat)\n     SISLCurve  *pcurve;\n     SISLSurf   *psurf;\n     double  par_val[];\n     double  delta;\n     double  *dist;\n     double aepsge;\n     double astart1;\n     double estart2[];\n     double aend1;\n     double eend2[];\n     double c0[];\n     double s0[];\n     double norm[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Sekant methode iteration on the distance function between\n*              a curve and a surface to find a closest point\n*              or an intersection point.\n*\n*\n* INPUT      : pcurve    - Pointer to the curve in the intersection.\n*              psurf     - Pointer to the surface in the intersection.\n*              delta     - Parameter distance on curve beetveen start values.\n*              aepsge    - Geometry resolution.\n*              c0        - Array for use in evaluation.\n*              s0        - Array for use in evaluation.\n*              norm      - Array for use in evaluation.\n* INPUT/\n* OUTPUT     : par_val[] - Parameter value of the surface in\n*                          intersection point.\n*              dist      - Distance in space.\n* OUTPUT     : jstat     - status messages  \n*                                = 3   : A minimum distanse found.\n*                                = 2   : Nothing found.\n*                                = 1   : Intersection found.\n*                                < 0   : error.\n*\n*\n* METHOD     : Sekant mothode in tree parameter directions.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Nov 1992\n* Revised by : Christophe Rene Birkeland, SINTEF Oslo, May 1993.\n*\n*********************************************************************\n*/                       \n{\n  int ki,kj;\t\t    /* Counter.\t\t\t\t\t   */\n  int kstat = 0;            /* Local status variable.                      */\n  int kpos = 0;             /* Position of error.                          */\n  int dim;                  /* Dimension of space the curves lie in        */\n  int knbit;                /* Number of iterations                        */\n  double cu_val[2];\t    /* Parameter values on curve.\t\t   */\n  double new_cu_val;\t    /* New parameter value on curve.\t\t   */\n  double *diff;\t\t    /* Difference vector between curve surface.    */\n  double y[2],new_y,delta_y;/* Signed distance.\t\t\t\t   */\n  SISLPoint *pt=SISL_NULL;\t    /* Point for use in closest point point/surface*/\n  int cu_left = 0;\t    /* Keep left knot information for evaluator.   */\n  int s_left1 = 0;\t    /* Keep left knot information for evaluator.   */\n  int s_left2 = 0;\t    /* Keep left knot information for evaluator.   */\n  int shift = 0;\t    /* Mark that the diriction have been changed.  */\n\n  *jstat = 0;\n  \n  /* Test input.  */\n  \n  if (pcurve->idim != psurf->idim) goto err106;  \n  dim = pcurve->idim;\n  diff = c0 + dim;\n   \n  if ((pt = newPoint(c0,dim,0)) == SISL_NULL) goto err101;\n\n  if (delta == 0.0) delta =1e-15;\n  \n  if ((par_val[2] == astart1 && delta < 0.0) ||\n      (par_val[2] == aend1   && delta > 0.0))\n  {\n     delta = -delta;\n     shift++;\n  }\n  \n  if (fabs(delta) < (aend1 -astart1)/100.0)\n  {\n     if (delta < 0.0)\n\tdelta = (astart1 - aend1)/100.0;\n     else\n\tdelta = (aend1 - astart1)/100.0;\n  }\n  else if (fabs(delta) > (aend1 -astart1)/10.0)\n  {\n     if (delta < 0.0)\n\tdelta = (astart1 - aend1)/10.0;\n     else\n\tdelta = (aend1 - astart1)/10.0;\n  }\n\n\n  cu_val[0] = par_val[2];\n  s1221(pcurve,0,cu_val[0],&cu_left,pt->ecoef,&kstat);\n  if (kstat < 0) goto error;      \n  s1773(pt,psurf,aepsge,estart2,eend2,par_val,par_val,&kstat);\n  if (kstat < 0) goto error;      \n  s1421(psurf,1,par_val,&s_left1,&s_left2,s0,norm,&kstat);\n  if (kstat < 0) goto error;\n  for(kj=0; kj<dim; kj++) diff[kj] = s0[kj] - pt->ecoef[kj];\n  new_y = s6norm(norm,dim,norm,&kstat);\n  if (kstat == 0)\n  {\n     (*dist)=s6length(diff,dim,&kstat);\n     new_cu_val = cu_val[0];\n     goto out;\n  }\n  if (((*dist)=s6length(diff,dim,&kstat)) < aepsge)\n  {\n     new_cu_val = cu_val[0];\n     goto out;\n  }\n  y[0] = s6scpr(norm,diff,dim);\n  cu_val[1] = cu_val[0] + delta;\n  \n  for (ki=0; ki<20; ki++)\n  {\n     s1221(pcurve,0,cu_val[1],&cu_left,pt->ecoef,&kstat);\n     if (kstat < 0) goto error;      \n     s1773(pt,psurf,aepsge,estart2,eend2,par_val,par_val,&kstat);\n     if (kstat < 0) goto error;      \n     s1421(psurf,1,par_val,&s_left1,&s_left2,s0,norm,&kstat);\n     if (kstat < 0) goto error;\n     for(kj=0; kj<dim; kj++) diff[kj] = s0[kj] - pt->ecoef[kj];\n     new_y = s6norm(norm,dim,norm,&kstat);\n     if (kstat == 0)\n     {\n\t(*dist)=s6length(diff,dim,&kstat);\n\tnew_cu_val = cu_val[1];\n\tgoto out;\n     }\n     if (((*dist)=s6length(diff,dim,&kstat)) < aepsge)\n     {\n\tnew_cu_val = cu_val[1];\n\tgoto out;\n     }\n     y[1] = s6scpr(norm,diff,dim);\n     new_y = y[1]/y[0];\n     if (new_y > 1.0000000000001)\n     {\n\tif (shift)\n\t{\n\t   new_cu_val = cu_val[1];\n\t   goto out;\n\t}\n\tdelta = -delta;\n\t/* ALA, UJK, sept 93, update cu_val[1]*/\n\tcu_val[1] = cu_val[0] + delta;\n\tshift++;\t\n     }\n     else if (y[0]*y[1] <= 0.0 || fabs(new_y) < 0.5) break;\n     else\n     {\n\tif (cu_val[1]+delta <= aend1 && \n\t    cu_val[1]+delta >= astart1) cu_val[1] += delta;\n\telse if (cu_val[1] < aend1)  \tcu_val[1] = aend1;\n\telse if (cu_val[1] > astart1)   cu_val[1] = astart1;\n\telse \n\t{\n\t   new_cu_val = cu_val[1];\n\t   goto out;\n\t}\n     }\n  }\n  \n  if (ki == 20)\n  {\n     *jstat = 2;\n     goto out;\n  }\n\n  for (knbit=0; knbit < 50; knbit++)\n  {\n     delta_y = y[0]-y[1];\n     if (fabs(delta_y) < REL_COMP_RES) break;\n     \n     new_cu_val = cu_val[1] + y[1]*(cu_val[1]-cu_val[0])/delta_y;\n     if (new_cu_val >= aend1)\n     {\n\tnew_cu_val = aend1;\n\tif (cu_val[0] == aend1 || cu_val[1] == aend1) goto out;\n     }\n     else if (new_cu_val <= astart1)\n     {\n\tnew_cu_val = astart1;\n\tif (cu_val[0] == astart1 || cu_val[1] == astart1) goto out;\n     }\n\n     s1221(pcurve,0,new_cu_val,&cu_left,pt->ecoef,&kstat);\n     if (kstat < 0) goto error;      \n     s1773(pt,psurf,aepsge,estart2,eend2,par_val,par_val,&kstat);\n     if (kstat < 0) goto error;      \n     s1421(psurf,1,par_val,&s_left1,&s_left2,s0,norm,&kstat);\n     if (kstat < 0) goto error;\n     for(kj=0; kj<dim; kj++) diff[kj] = s0[kj] - pt->ecoef[kj];\n     new_y = s6norm(norm,dim,norm,&kstat);\n     if (kstat == 0)\n     {\n\t(*dist) = s6length(diff,dim,&kstat);\n\tgoto out;\n     }\n     if (((*dist)=s6length(diff,dim,&kstat)) < aepsge) goto out;\n     new_y = s6scpr(norm,diff,dim);\n     \n     if ((y[0] < 0.0 && y[1] > 0.0) ||\n\t (y[0] > 0.0 && y[1] < 0.0))\n     {\n\tif ((new_y > 0.0 && y[0] > 0.0) ||\n\t    (new_y < 0.0 && y[0] < 0.0))\n\t{\n\t   cu_val[0] = new_cu_val;\n\t   y[0] = new_y;\n\t}\n\telse\n\t{\n\t   cu_val[1] = new_cu_val;\n\t   y[1] = new_y;\n\t}\n     }\n     else\n     {\n\tif ( y[0] < 0.0 && new_y > 0.0)\n\t{\n\t   if (y[0] < y[1])\n\t   {\n\t      cu_val[0] = new_cu_val;\n\t      y[0] = new_y;\n\t   }\n\t   else\n\t   {\n\t      cu_val[1] = new_cu_val;\n\t      y[1] = new_y;\n\t   }\n\t}\n\telse if ( y[0] > 0.0 && new_y < 0.0)\n\t{\n\t   if (y[0] > y[1])\n\t   {\n\t      cu_val[0] = new_cu_val;\n\t      y[0] = new_y;\n\t   }\n\t   else\n\t   {\n\t      cu_val[1] = new_cu_val;\n\t      y[1] = new_y;\n\t   }\n\t}\n\telse if (y[0] > 0.0)\n\t{\n\t   if (y[0] > y[1])\n\t   {\n\t      if (new_y >=  y[0]) break;\n\t      cu_val[0] = new_cu_val;\n\t      y[0] = new_y;\n\t   }\n\t   else \n\t   {\n\t      if (new_y >=  y[1]) break;\n\t      cu_val[1] = new_cu_val;\n\t      y[1] = new_y;\n\t   }\n\t     \n\t}\n\telse if (y[0] < 0.0)\n\t{\n\t   if (y[0] < y[1])\n\t   {\n\t      if (new_y <=  y[0]) break;\n\t      cu_val[0] = new_cu_val;\n\t      y[0] = new_y;\n\t   }\n\t   else \n\t   {\n\t      if (new_y <=  y[1]) break;\n\t      cu_val[1] = new_cu_val;\n\t      y[1] = new_y;\n\t   }   \n\t}\t   \n     }\n  }\n  \n  /* Iteration completed.  */\n  \n  goto out;\n  \n  /* Error in allocation */\n  \n  err101:\n    *jstat = -101;\n    s6err(\"s1772_s6sekant1\",*jstat,kpos);\n    goto out;                  \n    \n  /* Error in input. Conflicting dimensions.  */\n  \n  err106: \n    *jstat = -106;\n    s6err(\"s1772_s6sekant1\",*jstat,kpos);\n    goto out;                  \n  \n  /* Error in lower level routine.  */\n  \n  error : \n    *jstat = kstat;\n    s6err(\"s1772_s6sekant1\",*jstat,kpos);\n    goto out;                  \n  \n  out:\n    par_val[2] = new_cu_val;\n    if(pt) freePoint(pt);\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\n   static\n      int\ns1772_s6local_pretop(double dist,double diff[],double normal[],\n\t\t     double f[],double f_t[],double f_tt[],\n\t\t     double s[],double s_u[],double s_v[],\n\t\t     double s_uu[],double s_uv[],double s_vv[],\n\t\t     int dim, int*jstat)\n#else\nstatic int s1772_s6local_pretop(dist,diff,normal,f,f_t,f_tt,s,s_u,s_v,s_uu,\n\t\t\ts_uv,s_vv,dim,jstat)\n     double dist;\n     double diff[];\n     double normal[];\n     double f[];\n     double f_t[];\n     double f_tt[];\n     double s[];\n     double s_u[];\n     double s_v[];\n     double s_uu[];\n     double s_uv[];\n     double s_vv[];\n     int    dim;\n     int    *jstat;\n#endif \n/*\n***********************************************************************\n*\n************************************************************************\n*\n*   PURPOSE : To find if we have a minimum or a maximum or a turning\n*             point situation. This function assume that it is a singular \n*\t      situation.\n*\n*\n*\n* INPUT      : dist      - The lengt of the different vector.\n*\t       diff[]    - The differens vector.\n*\t       normal[]  - The normal vector on surface.\n*              f    - Value in point on curve.\n*              f_t  - First derevative of the curve.\n*              f_tt - Second derevative of the curve.\n*              s    - Value in point on surface.\n*\t       s_u  - Derevative of the surface in first par-dir.\n*\t       s_u  - Derevative of the surface in second par-dir.\n*\t       s_uu - Second derevative of the surface in first par-dir.\n*\t       s_uv - Cross derevative of the surface.\n*\t       s_vv - Second derevative of the surface in second par-dir.\n*\t       dim    - Dimension of space the curve/surface lie in.\n*   \n*   OUTPUT  :  return value - \t= -1: degenerated system.\n*\t\t\t\t=  0: Max or turning point.\n*\t\t\t\t=  1: Minimum position.\n*\n*              jstat        - Status variable.\n*                       \t< 0 : error.\n*                       \t= 0 : ok.\n*                       \t> 0 : warning.\n*\n*\n*   METHOD  : Computing and interpretation of curvatures.\n*\n*   REFERENCES : \n*-\n*   CALLS      :\n*\n*   WRITTEN BY : Arne Laksaa, SI, Oslo, des. 1992.\n*\n************************************************************************\n*/\n{\n  int kstat = 0;\t/* Status variable.\t\t\t\t*/\n  int ki;\t\t/* Counter.\t\t\t\t\t*/\n  int return_val;\t/* For return value.\t\t\t\t*/\n  double a1,a2,a3,a4;   /* Matrix.\t\t\t\t\t*/\n  double *S_u = SISL_NULL;\t/* Normalized s_u.\t\t\t\t*/\n  double *S_v;\t\t/* Normalized s_v.\t\t\t\t*/\n  double *S_uxS_v;\t/* Cross between S_u and S_v.\t\t\t*/\n  double *s_d;\t\t/* Second derevative in diriction f_t.\t\t*/\n  double *N;\t\t/* Normalized normal.\t\t\t\t*/\n  double *d_uv;\t\t/* Normalized direction vector in par-plane.\t*/\n  double local[17];\t/* Local array for allocations.\t\t\t*/\n  \n  *jstat = 0;\n  \n  if (s6ang(diff,normal,dim) > ANGULAR_TOLERANCE) goto warn1;\n  \n  /* Allocate local used memory and set value pointers.*/\n\n  if (dim > 3)\n  {\n     S_u = newarray(5*dim+2,double);\n     if (S_u == SISL_NULL) goto err101;\n  }\n  else\n     S_u  = local;\n  \n  S_v     = S_u+dim;\n  S_uxS_v = S_v+dim;\n  s_d     = S_uxS_v+dim;\n  N       = s_d+dim;\n  d_uv    = N+dim;\n  \n  s6norm(s_u,dim,S_u,&kstat);\n  if (kstat == 0)  goto warn1;\n  s6norm(s_v,dim,S_v,&kstat);\n  if (kstat == 0)  goto warn1;\n  s6crss(S_u,S_v,S_uxS_v);\n  a1 = s6scpr(S_u,S_v,dim);\n  a2 = s6scpr(f_t,S_u,dim);\n  a3 = s6scpr(f_t,S_v,dim);\n  if ((a4 = s6scpr(S_uxS_v,S_uxS_v,dim)) < SINGULAR) goto warn1;\n  \n  d_uv[0] = (a2 - a1*a3)/a4;\n  d_uv[1] = (a3 - a1*a2)/a4;\n  s6norm(d_uv,2,d_uv,&kstat);\n  if (kstat == 0)  goto warn1;\n  \n  a1 = d_uv[0]*d_uv[0];\n  a2 = d_uv[1]*d_uv[1];\n  a3 = 2*d_uv[0]*d_uv[1];\n  \n  for (ki=0; ki<dim; ki++)\n     s_d[ki] = a1*s_uu[ki] + a3*s_uv[ki] + a2*s_vv[ki];\n  \n  for (ki=0; ki<dim; ki++)\n     N[ki] = diff[ki]/dist;  \n  \n  a1 = s6scpr(N,f_tt,dim) - s6scpr(N,s_d,dim);\n\n  return_val = a1 > 1.0e-10;\n  goto out;\n\n  /* Error in allocation */\n\n  err101: \n    *jstat = -101;\n    s6err(\"s1772_s6local_pretop\",*jstat,0);\n    return_val = 0;                 \n    goto out;\n  \n  /* Degenerated system.  */\n\n  warn1: \n    return_val = -1;\n    goto out;\n\n  out:\n    if (S_u != local && S_u != SISL_NULL) freearray(S_u);\n    return return_val;\n}\n\n                                    \n\n                                        \n"
  },
  {
    "path": "src/s1773.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1773.c,v 1.3 2001-03-19 15:58:53 afr Exp $\n *\n */\n#define S1773\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\ns1773_s9corr(double [],double,double,double,double,double,double);\nstatic\nvoid\ns1773_s9dir(double *,double *,double *,double [],double [],double [],\n\t\t  double, int,int *);\n#else\nstatic void s1773_s9corr();\nstatic void s1773_s9dir();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1773(SISLPoint *ppoint,SISLSurf *psurf,double aepsge,\n\t   double estart[],double eend[],double enext[],double gpos[],int *jstat)\n#else\nvoid s1773(ppoint,psurf,aepsge,estart,eend,enext,gpos,jstat)\n     SISLPoint  *ppoint;\n     SISLSurf   *psurf;\n     double aepsge;\n     double estart[];\n     double eend[];\n     double enext[];\n     double gpos[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Newton iteration on the distance function between\n*              a surface and a point, to find a closest point or an\n*              intersection point.\n*              If a bad choice for the guess parameters is given in, the\n*              iteration may end at a local, not global closest point.\n*\n*\n* INPUT      : ppoint   - The point in the closest point problem.\n*              psurf    - The surface in the closest point problem.\n*              aepsge   - Geometry resolution.\n*              estart   - Surface parameters giving the start of the search\n*                         area (umin, vmin).\n*              eend     - Surface parameters giving the end of the search\n*                         area (umax, vmax).\n*              enext    - Surface guess parameters for the closest point\n*                         iteration.\n*\n*\n*\n* OUTPUT     : gpos    - Resulting surface parameters from the iteration.\n*              jstat   - status messages  \n*                                = 2   : A minimum distanse found.\n*                                = 1   : Intersection found.\n*                                < 0   : error.\n*\n*\n* METHOD     : Newton iteration in two parameter direction.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, May 1989\n* Revised by : Johannes Kaasa, SINTEF Oslo, August 1995.\n*              Introduced a local copy of enext, to avoid changes.\n*\n*********************************************************************\n*/                       \n{                        \n  int kstat = 0;            /* Local status variable.                      */\n  int kpos = 0;             /* Position of error.                          */\n  int kleft1=0;             /* Variables used in the evaluator.            */\n  int kleft2=0;             /* Variables used in the evaluator.            */\n  int kder=1;               /* Order of derivatives to be calulated        */\n  int kdim;                 /* Dimension of space the curves lie in        */\n  int knbit;                /* Number of iterations                        */\n  int kdir;                 /* Changing direction.                         */\n  int kdeg;                 /* Degenaracy flag.                            */\n  double tdelta[2];         /* Parameter intervals of the surface.         */\n  double tdist;             /* Distance between position and origo.        */\n  double td[2],t1[2],tdn[2];/* Distances between old and new parameter\n\t\t\t       value in the tree parameter directions.     */\n  double tprev;             /* Previous difference between the curves.     */\n  double *sval =SISL_NULL;       /* Value ,first and second derivatiev of surf. */ \n  double *sdiff;            /* Difference between the point and the surf.  */\n  double *snorm;            /* Normal vector of the surface, dummy.        */\n  double snext[2];          /* Parameter values                            */\n  double guess[2];          /* Local copy of enext.                        */\n  \n  guess[0] = enext[0];\n  guess[1] = enext[1];\n  \n  /* Test input.  */\n  \n  if (ppoint->idim != psurf->idim) goto err106;\n  \n  kdim = ppoint -> idim;\n  \n  if (kdim == 1)\n    {\n      s1173(ppoint,psurf,aepsge,estart,eend,guess,gpos,&kstat);\n      if (kstat < 0)\n        goto error;\n      else\n        {\n\t  if (DNEQUAL(gpos[0],estart[0]) &&\n\t      DNEQUAL(gpos[0],eend[0]) &&\n\t      DNEQUAL(gpos[1],estart[1]) &&\n\t      DNEQUAL(gpos[1],eend[1])) \n\t    *jstat = (kstat==1 ? 1:3);\n\t  else\n\t    *jstat = 0;\n\t  goto out;\n        }\n    }\n  \n  /* Fetch endpoints and the intervals of parameter interval of curves.  */\n  \n  tdelta[0] = psurf->et1[psurf->in1] - psurf->et1[psurf->ik1 - 1];\n  tdelta[1] = psurf->et2[psurf->in2] - psurf->et2[psurf->ik2 - 1];\n  \n  /* Allocate local used memory */\n  \n  sval = newarray(8*kdim,double);\n  if (sval == SISL_NULL) goto err101;\n  \n  sdiff = sval + 6*kdim;\n  snorm = sdiff + kdim;\n  \n  /* Initiate variables.  */\n  \n  tprev = (double)HUGE;\n  \n  /* Evaluate 0-1.st derivatives of surface */\n  /* printf(\"\\n lin: \\n %#20.20g %#20.20g\",\n     guess[0],guess[1]); */\n  \n  s1421(psurf,kder,guess,&kleft1,&kleft2,sval,snorm,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Compute the distanse vector and value and the new step. */\n  \n  s1773_s9dir(&tdist,td,td+1,sdiff,ppoint->ecoef,sval,\n\t      aepsge,kdim,&kdeg);\n  \n  /* Correct if we are not inside the parameter intervall. */\n  \n  t1[0] = td[0];\n  t1[1] = td[1];\n  s1773_s9corr(t1,guess[0],guess[1],estart[0],eend[0],estart[1],eend[1]);\n  \n  /* Iterate to find the intersection point.  */\n  \n  for (knbit = 0; knbit < 30; knbit++)\n    {\n      /* Evaluate 0-1.st derivatives of surface */\n      \n      snext[0] = guess[0] + t1[0];\n      snext[1] = guess[1] + t1[1];\n      \n      s1421(psurf,kder,snext,&kleft1,&kleft2,sval,snorm,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Compute the distanse vector and value and the new step. */\n      \n      s1773_s9dir(&tdist,tdn,tdn+1,sdiff,ppoint->ecoef,\n\t    sval,aepsge,kdim,&kdeg);\n      \n      /* Check if the direction of the step have change. */\n      \n      kdir = (s6scpr(td,tdn,2) >= DZERO);     /* 0 if changed. */\n      \n      /* Ordinary converging. */\n      \n      if (tdist < tprev/(double)2 || kdir)\n\t{\n\t   guess[0] += t1[0];\n\t   guess[1] += t1[1];\n  \n\t  /* printf(\"\\n %#20.20g %#20.20g\",\n\t     guess[0],guess[1]); */\n  \n\t  \n          td[0] = t1[0] = tdn[0];\n          td[1] = t1[1] = tdn[1];\n\t  \n\t  /* Correct if we are not inside the parameter intervall. */\n\t  \n\t  s1773_s9corr(t1,guess[0],guess[1],estart[0],eend[0],estart[1],eend[1]);\n          tprev = tdist;\n\n\t  if ( (fabs(t1[0]/tdelta[0]) <= REL_COMP_RES) &&\n\t      (fabs(t1[1]/tdelta[1]) <= REL_COMP_RES)) break;\n\t}\n      \n      /* Not converging, adjust and try again. */\n      \n      else\n\t{\n          t1[0] /= (double)2;\n          t1[1] /= (double)2;\n          /* knbit--;  */\n\t}\n      if (guess[0]==guess[0]+t1[0] &&\n\t  guess[1]==guess[1]+t1[1]) break;\n    }\n  \n  /* Iteration stopped, test if point founds found is within resolution */\n  \n  if (tdist <= aepsge)\n  {\n     *jstat = 1;\n     /* printf(\"\\n SUCCESS!!\"); */\n     \n  }\n  else if(kdeg)\n     *jstat = 9;\n  else\n     *jstat = 2;\n  \n  gpos[0] = guess[0];\n  gpos[1] = guess[1];\n  \n  /* Iteration completed.  */\n  \n  goto out;\n  \n  /* Error in allocation */\n  \n err101: *jstat = -101;\n  s6err(\"s1773\",*jstat,kpos);\n  goto out;                  \n  \n  /* Error in input. Conflicting dimensions.  */\n  \n err106: *jstat = -106;\n  s6err(\"s1773\",*jstat,kpos);\n  goto out;                  \n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"s1773\",*jstat,kpos);\n  goto out;                  \n  \n out:    if (sval != SISL_NULL) freearray(sval);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\ns1773_s9corr(double gd[],double acoef1,double acoef2,\n\t\t   double astart1,double aend1,double astart2,double aend2)\n#else\nstatic void s1773_s9corr(gd,acoef1,acoef2,astart1,aend1,astart2,aend2)\n     double gd[];\n     double acoef1;\n     double acoef2;\n     double astart1;\n     double aend1;\n     double astart2;\n     double aend2;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To be sure that we are inside the boorder of the\n*              parameter plan. If we are outside clipping is used\n*\t       to corrigate the step value.\n*\n*\n* INPUT      : acoef1  - Coeffisient in the first direction.\n*              acoef2  - Coeffisient in the second direction.\n*              astart1 - The lower boorder in first direction.\n*              aend1   - The higher boorder in first direction.\n*              estart2 - The lower boorder in second direction.\n*              eend2   - The higher boorder in second direction.\n*\n*\n*\n* INPUT/OUTPUT : gd    - Old and new step value.\n*\n*\n* METHOD     : We are cutting a line inside a rectangle.\n*\t       In this case we always know that the startpoint of\n*\t       the line is inside the rectangel, and we may therfor\n*\t       use a simple kind of clipping.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/                       \n{\n  if (acoef1 + gd[0] < astart1)  gd[0] = astart1 - acoef1;\n  else if (acoef1 + gd[0] > aend1) gd[0] = aend1 - acoef1;\n  \n  if (acoef2 + gd[1] < astart2)  gd[1] = astart2 - acoef2;\n  else if (acoef2 + gd[1] > aend2) gd[1] = aend2 - acoef2;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic\nvoid\ns1773_s9dir(double *cdist,double *cdiff1,double *cdiff2,\n\t\t  double PS[],double eval1[],double eval2[],\n\t\t  double aepsge, int idim,int *jstat)\n#else\nstatic void s1773_s9dir(cdist,cdiff1,cdiff2,PS,\n\t\t\teval1,eval2,aepsge,idim,jstat)\n     double *cdist;\n     double *cdiff1;\n     double *cdiff2;\n     double PS[];\n     double eval1[];\n     double eval2[];\n     double aepsge;\n     int    idim;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To compute the distance vector and value beetween\n*\t       a point and a point on a surface.\n*\t       And to compute a next step on both parameter direction\n*\t       This is equivalent to the nearest way to the\n*\t       parameter plan in the tangent plan from a point in the\n*\t       distance surface between a point and a surface.\n*\n*\n* INPUT      : eval1 - Value in point.\n*              eval2 - Value +1 and 2. der in surface.\n*\t       aepsge- Geometry tolerance.\n*\t       idim  - Dimension of space the surface lie in.\n*\n*\n* OUTPUT     : PS   - Array to use when computing the differens vector.\n*\t       cdiff1  - Relative parameter value in intersection \n*                        point in first direction.\n*              cdiff2  - Relative parameter value in intersection \n*                        point in second direction.\n*              cdist   - The value to the point in the distance surface.\n*              jstat   - 0 OK, new No degeneracy.\n*                        1 Degeneracy.\n*\n*\n* METHOD     : The method is to compute the parameter distance to the points\n*\t       on both tangents which is closest to the point.\n*\t       The difference vector beetween these points are orthogonal\n*\t       to both tangents. If the distance vector beetween the point and\n*\t       point on the surface is \"diff\" and the two derivativ vectors\n*\t       are \"der1\" and \"der2\", and the two wanted parameter distance\n*\t       are \"dt1\" and \"dt2\", then we get the following system of \n*\t       equations:\n*\t\t <-dist+dt1*der1+dt2*der2,der1> = 0\n*\t\t <-dist+dt1*der1+dt2*der2,der2> = 0\n*\t       This is futher:\n*\n*\t\t | <der1,der1>   <der1,der2> |  | dt1 |   | <dist,der1> |\n*\t\t |                           |  |     | = |     \t|\n*\t\t | <der1,der2>   <der2,der2> |  | dt2 |   | <dist,der2> |\n*\n*\t       The solution of this matrix equation is the\n*\t       following function.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Feb 1989\n*\n*********************************************************************\n*/                       \n{                        \n  int kstat=0;\t\t          /* Local status variable.       */\n  register double tdet;\t\t  /* Determinant                  */\n  register double t1,t2,t3,t4,t5; /* Variables in equation system */\n  register double *S, *Su, *Sv;\n  /* register double *Suv, *Suu, *Svv; */\n                                  /* Pointers to surf values      */\n  register double ref, ang;       /* Referance value, angle       */\n  register double l1, l2;         /* Vector norm                  */\n  register double min_ang=10e-11; /* Min angle                    */\n  /* ____________________________________________________________ */\n  \n  /* Init */\n  *jstat = 0;\n  *cdiff1 = DZERO;\n  *cdiff2 = DZERO;\n  \n  /* Set pointers */\n  S   = eval2;\n  Su  = S   + idim;\n  Sv  = Su  + idim;\n  /* Suu = Sv  + idim;\n  Suv = Suu + idim;\n  Svv = Suv + idim; */\n\n  /* Degenerate if Su=0 v Sv=0 v Su||Sv */\n  l1 = s6length(Su,idim,&kstat);\n  l2 = s6length(Sv,idim,&kstat);\n  ang = s6ang(Su,Sv,idim);\n  if (min(l1,l2) < aepsge || ang < min_ang) *jstat = 1;\n\n  /* Computing difference vector and lenght */\n  s6diff(eval1,S,idim,PS);\n  *cdist = s6length(PS,idim,&kstat);\n  \n  if (*jstat == 1)\n  {\n     if (l1 < aepsge)\n     {\n\tif (l2 > aepsge)\n\t   /* Su = 0 */\n\t   *cdiff2 = s6scpr(PS,Sv,idim)/l2*l2;\n     }\n     else if (l2 < aepsge)\n\t   /* Sv = 0 */\n\t   *cdiff1 = s6scpr(PS,Su,idim)/(l1*l1);\n     else /* Su,Sv || */\n     {\n\t/* Best strategy? */\n\t*cdiff1 = s6scpr(PS,Su,idim)/(l1*l1);\n      }\n\t\n  }\n  else /* *jstat == 0 */\n     \n  {\n     \n     t1 =  s6scpr(Su,Su,idim) ; /* - s6scpr(PS,Suu,idim);*/\n     t2 =  s6scpr(Su,Sv,idim) ; /* - s6scpr(PS,Suv,idim);*/\n     t3 =  s6scpr(Sv,Sv,idim) ; /* - s6scpr(PS,Svv,idim);*/\n     t4 =  s6scpr(PS,Su,idim);\n     t5 =  s6scpr(PS,Sv,idim);\n     \n     ref = max(fabs(t1),fabs(t2));\n     ref = max(ref,fabs(t3));\n     /* Computing the determinant. */\n     \n     tdet = t1*t3 - t2*t2;\n     \n     if (DEQUAL(ref+fabs(tdet),ref))\n     {\n\t*jstat = 1;\n     }\n     else \n     {\n\t/* Using Cramer's rule to find the solution of the system. */\n\t\n\t*cdiff1 =  (t4*t3-t5*t2)/tdet;\n\t*cdiff2 =  (t1*t5-t2*t4)/tdet;\n     }\n  }\n}\n"
  },
  {
    "path": "src/s1774.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1774.c,v 1.2 2001-03-19 15:58:53 afr Exp $\n *\n */\n#define S1774\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1774(SISLCurve *crv, double point[], int dim, double epsge,\n\t   double start, double end, double guess, double *clpar, int *stat)\n#else\nvoid s1774(crv, point, dim, epsge, start, end, guess, clpar, stat)\n     SISLCurve  *crv;\n     double point[];\n     int dim;\n     double epsge;\n     double start;\n     double end;\n     double guess;\n     double *clpar;\n     int    *stat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Newton iteration on the distance function between\n*              a curve and a point, to find a closest point or an\n*              intersection point.\n*              If a bad choice for the guess parameter is given in, the\n*              iteration may end at a local, not global closest point.\n*\n*\n* INPUT      : crv     - The curve in the closest point problem.\n*              point   - The point in the closest point problem.\n*              dim     - Dimension of the geometry.\n*              epsge   - Geometrical resolution.\n*              start   - Curve parameter giving the start of the search\n*                        interval.\n*              end     - Curve parameter giving the end of the search\n*                        interval.\n*              guess   - Curve guess parameter for the closest point\n*                        iteration.\n*\n*\n*\n* OUTPUT     : clpar   - Resulting curve parameter from the iteration.\n*              stat    - status messages\n*                                = 2   : A minimum distanse found.\n*                                = 1   : Intersection found.\n*                                < 0   : error.\n*\n*\n* METHOD     : Newton iteration.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Johannes Kaasa, SINTEF, Aug 1995\n*\n*********************************************************************\n*/\n{\n   int kpos = 0;             /* Error indicator. */\n   SISLPoint* ppoint = SISL_NULL; /* SISL point.      */\n   \n   /* Generate a SISL point. */\n   \n   ppoint = newPoint(point, dim, 0);\n   \n   /* Call s1771. */\n   \n   s1771(ppoint, crv, epsge, start, end, guess, clpar, stat);\n   if (*stat < 0) goto error;\n\n   goto out;\n\n   /* Error in lower level routine.  */\n\n   error :\n   s6err(\"s1774\", *stat, kpos);\n   goto out;\n\n out:    \n    if (ppoint != SISL_NULL) freePoint(ppoint);\n}\n\n"
  },
  {
    "path": "src/s1775.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1775.c,v 1.2 2001-03-19 15:58:53 afr Exp $\n *\n */\n#define S1775\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1775(SISLSurf *surf, double point[], int dim, double epsge,\n\t   double start[], double end[], double guess[], double clpar[],\n\t   int *stat)\n#else\nvoid s1775(surf, point, dim, epsge, start, end, guess, clpar, stat)\n     SISLSurf   *surf;\n     double point[];\n     int dim;\n     double epsge;\n     double start[];\n     double end[];\n     double guess[];\n     double clpar[];\n     int    *stat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Newton iteration on the distance function between\n*              a surface and a point, to find a closest point or an\n*              intersection point.\n*              If a bad choice for the guess parameters is given in, the\n*              iteration may end at a local, not global closest point.\n*\n*\n* INPUT      : surf    - The surface in the closest point problem.\n*              point   - The point in the closest point problem.\n*              dim     - Dimension of the geometry.\n*              epsge   - Geometry resolution.\n*              start   - Surface parameters giving the start of the search\n*                        area (umin, vmin).\n*              end     - Surface parameters giving the end of the search\n*                        area (umax, vmax).\n*              guess   - Surface guess parameters for the closest point\n*                        iteration.\n*\n*\n*\n* OUTPUT     : clpar   - Resulting surface parameters from the iteration.\n*              jstat   - status messages  \n*                                = 2   : A minimum distanse found.\n*                                = 1   : Intersection found.\n*                                < 0   : error.\n*\n*\n* METHOD     : Newton iteration in two parameter direction.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Johannes Kaasa, SINTEF Oslo, August 1995.\n*\n*********************************************************************\n*/                       \n{ \n   int kpos = 0;             /* Error indicator. */\n   SISLPoint* ppoint = SISL_NULL; /* SISL point.      */\n\n   /* Generate a SISL point. */\n   \n   ppoint = newPoint(point, dim, 0);\n   \n   /* Call s1773. */\n   \n   s1773(ppoint, surf, epsge, start, end, guess, clpar, stat);\n   if (*stat < 0) goto error;\n  \n   goto out;\n  \n   /* Error in lower level routine.  */\n\n   error :\n   s6err(\"s1775\", *stat, kpos);\n   goto out;\n\n out:    \n    if (ppoint != SISL_NULL) freePoint(ppoint);\n}\n\n"
  },
  {
    "path": "src/s1780.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1780.c,v 1.2 2001-03-19 15:58:53 afr Exp $\n *\n */\n\n\n#define S1780\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1780(SISLCurve *pc1,SISLCurve *pc2,SISLIntpt *vipt[],int *jstat)\n#else\nvoid s1780(pc1,pc2,vipt,jstat)\n     SISLCurve *pc1;\n     SISLCurve *pc2;\n     SISLIntpt *vipt[];\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Test if two curves originating from a curve/curve\n*              intersection problem, coincide beetween two\n*              intersection points. The part of curves beetween\n*              the intersection points must not have internal\n*              knots.\n*\n*\n* INPUT      : pc1     - First curve in intersection problem.\n*              pc2     - Second curve in intersection problem.\n*              vipt[]  - Array of structures of intersection points.\n*\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                                         = 1      : Coincide.\n*                                         = 0      : No coincide.\n*                                         < 0      : error\n*\n*\n* METHOD     : Let k be the maximum order of the two Bezier-curves.\n*              Test if the curves or derivatives of the curves are \n*              identical in k points. Then the curves coincide.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1221  - Evaluate curve in given parameter value.\n*              s6par  - Test if two vectors are parallel.\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-07.\n*\n*********************************************************************\n*/\n{ \n  int kstat = 0;     /* Local status variable.                            */\n  int kpos = 0;      /* Position of error;                                */\n  int ki,kj;         /* Counters.                                         */\n  int kdim;          /* Dimension of the space in which the curves lie.   */\n  int kord;          /* Number of points in which the curves have to be\n\t\t        equal if the curves coincide.                     */\n  int kder;          /* Number of derivatives of curve to evaluate.       */\n  int klefs = 0;     /* Parameter used when evaluating first curve.       */\n  int kleft = 0;     /* Parameter used when evaluating second curve.      */\n  double *sder1 = SISL_NULL; /* Value of first curve in given parameter value. */\n  double *sder2 = SISL_NULL; /* Value of second curve in given parameter value.*/\n  double tpar1,tpar2;   /* Parameter values in intersection points.       */\n  double tang;          /* An angel beetween to vectors.                  */\n\n\n  /* Initiate to no coincide. */\n\n  *jstat = 0;\n\n  kdim = pc1 -> idim;\n  if (kdim != pc2->idim) goto err106;\n\n  /* Test if Bezier curves beetween intersection points.  */\n\n  tpar1 = min(vipt[0]->epar[0],vipt[1]->epar[0]);\n  tpar2 = max(vipt[0]->epar[0],vipt[1]->epar[0]);\n\n  for (ki=0;  pc1->et[ki] <= tpar1; ki++);\n  ki--;\n\n  for (kj=0;  pc1->et[kj] < tpar2; kj++);\n\n  if (kj-ki > 1)\n    goto out;\n\n  tpar1 = min(vipt[0]->epar[1],vipt[1]->epar[1]);\n  tpar2 = max(vipt[0]->epar[1],vipt[1]->epar[1]);\n\n  for (ki=0;  pc2->et[ki] <= tpar1; ki++);\n  ki--;\n\n  for (kj=0;  pc2->et[kj] < tpar2; kj++);\n\n  if (kj-ki >1)\n    goto out;\n\n\n  /* Find number of points/derivatives in which the curves have to \n     be equal.                                                     */\n\n  kord = MAX(pc1->ik,pc2->ik);\n  kder = kord/2;\n  kder = MAX(kder,kord-kder);\n\n  /* Allocate space for local arrays.  */\n\n  if ((sder1 = newarray((2*(kder+1)*kdim),double)) == SISL_NULL) goto err101;\n  sder2 = sder1 + (kder+1)*kdim;\n\n\n\n  /* Test if curves coincide beetween intersection points.  */\n\n  if (kder > 1)\n    {\n\n      /* Test if the first kder derivatives of the curves are equal in\n\t the first intersection points of the curves.   */\n\n      /* Evaluate curves in first endpoint.  */\n\n      s1221(pc1,kder,vipt[0]->epar[0],&kleft,sder1,&kstat);\n      if (kstat < 0) goto error;\n\n      s1221(pc2,kder,vipt[0]->epar[1],&klefs,sder2,&kstat);\n      if (kstat < 0) goto error;\n\n      for (ki=1; ki<kder; ki++)\n\t{\n\n\t  /* Test if the ki'th derivatives of the curves are parallel. */\n\n\t  tang = s6ang(sder1+(ki*kdim),sder2+(ki*kdim),kdim);\n\n\t  tang = min(tang,fabs(PI - tang));\n\n\t  if (tang > ANGULAR_TOLERANCE) goto out;\n\t}\n    }\n\n  kder = kord - kder;\n  if (kder > 1)\n    {\n\n      /* Test if the first kder derivatives of the curves are equal in \n\t the endpoints of the curves.                                   */\n\n      /* Evaluate curves in second endpoint. */\n\n      s1221(pc1,kder,vipt[1]->epar[0],&kleft,sder1,&kstat);\n      if (kstat < 0) goto error;\n\n      s1221(pc2,kder,vipt[1]->epar[1],&klefs,sder2,&kstat);\n      if (kstat < 0) goto error;\n\n      for (ki=1; ki<kder; ki++)\n\t{\n\n\t/* Test if the ki'th derivatives of the curves are parallel. */\n\t  tang = s6ang(sder1+(ki*kdim),sder2+(ki*kdim),kdim);\n\n\t  tang = min(tang,fabs(PI - tang));\n\n\t  if (tang > ANGULAR_TOLERANCE) goto out;\n\t}\n    }\n\n  /* Test performed.  */\n\n  *jstat = 1;\n  goto out;\n\n  /* Error in space allocation.  */\n\nerr101: *jstat = -101;\n        s6err(\"s1780\",*jstat,kpos);\n        goto out;\n  \n  /* Error in input. Dimensions of curves conflicting. */\n\nerr106: *jstat = -106;\n        s6err(\"s1780\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine. */\n\nerror : *jstat = kstat;\n        s6err(\"s1780\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* Free space occupied by local arrays.  */\n\n  if (sder1 != SISL_NULL) freearray(sder1);\n}\n"
  },
  {
    "path": "src/s1785.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1785.c,v 1.3 2005-02-28 09:04:49 afr Exp $\n *\n */\n#define S1785\n\n#include \"sislP.h\"\n\n\n#if defined(SISLNEEDPROTOTYPES)\n/* static void s1785_s9eval(double [], double [], double [],double [], int, int *); */\n#else\n/* static void s1785_s9eval(); */\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n        s1785(SISLCurve *pcurve,SISLSurf *psurf,double aepsge,\n\t   double epar1[],double epar2[],int icur,int *jstat)\n#else\n   void s1785(pcurve,psurf,aepsge,epar1,epar2,icur,jstat)\n      SISLCurve  *pcurve;\n      SISLSurf   *psurf;\n      double     aepsge;\n      double     epar1[];\n      double     epar2[];\n      int        icur;\n      int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Test if a curve and a surface coincide beetween\n*              two intersection points.\n*              This function is used when the first derivative\n*              for the curve and the surface is matching in both\n*              intersection points.\n*\n*\n* INPUT      : pcurve   - Pointer to the curve.\n*              psurf    - Pointer to the surface.\n*              aepsge   - Geometry resolution.\n*              epar1[3] - Parameter values for the first intersection point.\n*              epar2[3] - Parameter values for the second intersection point.\n*              icur     -         = 1 , epar[0] is the parameter value\n*                                       for the curve and epar[1],epar[2] is\n*                                       the parameter values for the surface.\n*                                 = 0 , epar[2] is the parameter value\n*                                       for the curve and epar[0],epar[1] is\n*                                       the parameter values for the surface.\n*\n*\n*\n* OUTPUT     :  jstat   - status messages  \n*                                = 1   : Coincidence of curve and surface\n*                                = 0   : No coincidence.\n*                                < 0   : Error.\n*\n*\n* METHOD     : March along the curve and iterate down to the surface for\n*              each midpoint and endpoint of each step. The steplenght\n*              is computed from the curvature of the curve and the surface\n*              in the direction of the curve, and from the knot vector\n*              of the curve. If any knot lines of the surface are crossed,\n*              the marching are drawn back to the knot line, and a new\n*              step is initiated. NB. To speed up the marching, the step\n*              length estimate from the surface is commented out.\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. July 1989\n* REWISED BY : Vibeke Skytt, SI, Oslo, Norway. Oct. 1990\n*\n*********************************************************************\n*/\n{\n\t int kstat;          /* Status variable                                 */\n      int ki;             /* Counter.                                        */\n      int kleftc=0;       /* Left indicator for point calculation            */\n      int kleft1=0;       /* Left indicator for point calculation in 1. par.\n\t\t\t     direction of surface.                           */\n      int kleft2=0;       /* Left indicator for point calculation in 2. par dir.*/\n      int kleft1prev,kleft2prev;  /* Previous left indicators of surface.    */\n      int khelp;          /* Help index of knot vector.                      */\n      int kn;             /* The number of B-splines, i.e., the dimension of\n\t\t\t     the spline space associated with the knot\n\t\t\t     vector.                                         */\n      int kk;             /* The polynomial order of the curve.              */\n      int kk1,kk2,kn1,kn2;/* Orders and nu,ber of vertices of surface        */\n      int kdimc;          /* The dimension of the space in which the curve\n\t\t\t     lies. Equivalently, the number of components\n\t\t\t     of each B-spline coefficient.                   */\n      int kdims;          /* Dimension of space where the surface lies       */\n      int kpos=0;         /* Position of error                               */\n      int kderc=2;        /* Number of derivatives to be claculated on curve */\n      int kders=1;        /* Number of derivatives to be calculated on surface\n\t\t\t     If step lenght is to be generated from surface,\n\t\t\t     kders must be equal to 2.                       */\n      int kdum;           /* Temporary variable                              */\n      int kpar;           /* Parameter value of constant parameter curve.    */\n      double tclose1,tclose2;  /* Parameter values of closest point between curves. */\n      double snorm[3];    /* Normal vector of surface                        */\n      double s3dinf1[10]; /* Pointer to storage for point info of curve\n\t\t\t     (10 dobules prpoint when idim=3, 7 when idim=3) */\n      double *st;         /* Pointer to the first element of the knot vector\n\t\t\t     of the curve. The knot vector has [kn+kk]\n\t\t\t     elements.                                       */\n      double *st1;        /* First knot direction of surface                 */\n      double *st2;        /* Second knot direction of surface                */\n      double sfirst[2];   /* Start parameter par in surface                  */\n      double slast[2];    /* End parameter par in surface                    */\n      double tfirst;      /* Fist parameter on curve                         */\n      double tend;        /* Last parameter on curve                         */\n      double sderc[9];    /* Position, first and second derivative of curve  */\n      double sders[18];   /* Position, first and second derivatives of surface */\n      double tx,tx1,tx2;  /* Parameter value */\n      double tcstep;      /* Step length based on curvature of objects.   */\n      double tstep;       /* Final step length     */\n      double tmaxinc;     /* Maximal increment in parameter value along curve*/\n      double tlengthend;  /* Length of 1st derivative at end of segment */\n      double tincre;      /* Parameter value increment */\n      double tsmax,tcmax; /* Local maximal step length based of boxsizes of objects */\n      double tdist;       /* Distance */\n      double tref;        /* Referance value in equality test.               */\n      double sstart[2];   /* Lower boundary of parameter intervals */\n      double send[2];     /* Upper bounadry of parameter intervals */\n      double snext[3];    /* Existing iteration point on  surface            */\n      double spos[3];     /* New iteration  point on surface                 */\n      double snext2[2];   /* Help parameter values.                          */\n      SISLPoint *qpoint=SISL_NULL;\n      SISLCurve *qc = SISL_NULL;   /* Constant parameter curve.                       */\n      \n      *jstat = 0;\n      \n      /* Make maximal step length based on box-size of surface */\n      \n      sh1992su(psurf,0,aepsge,&kstat);\n      if (kstat < 0) goto error;\n      \n      tsmax = MAX(psurf->pbox->e2max[0][0] - psurf->pbox->e2min[0][0],\n\t\t  psurf->pbox->e2max[0][1] - psurf->pbox->e2min[0][1]);\n      tsmax = MAX(tsmax,psurf->pbox->e2max[0][2] - psurf->pbox->e2min[0][2]);\n      \n      /* Make maximal step length based on box-size of curve */\n      \n      sh1992cu(pcurve,0,aepsge,&kstat);\n      if (kstat < 0) goto error;\n      \n      tcmax = MAX(pcurve->pbox->e2max[0][0] - pcurve->pbox->e2min[0][0],\n\t\t  pcurve->pbox->e2max[0][1] - pcurve->pbox->e2min[0][1]);\n      tcmax = MAX(tcmax,pcurve->pbox->e2max[0][2] - pcurve->pbox->e2min[0][2]);\n      \n      /* Copy curve attributes to local parameters.  */\n      \n      kdimc = pcurve -> idim;\n      kk    = pcurve -> ik;\n      kn    = pcurve -> in;\n      st    = pcurve -> et;\n      \n      /* Copy surface attributes to local parameters.  */\n      \n      kdims = psurf -> idim;\n      kk1   = psurf -> ik1;\n      kk2   = psurf -> ik2;\n      kn1   = psurf -> in1;\n      kn2   = psurf -> in2;\n      st1   = psurf -> et1;\n      st2   = psurf -> et2;\n      \n      /* Set reference value.  */\n      \n      tref = MAX(st[kn]-st[kk-1],MAX(st1[kn1]-st1[kk1-1],st2[kn2]-st2[kk2-1]));\n\n      /* Check that dimensions are 3 */\n      \n      if (kdimc != 3 || kdims != 3) goto err105;\n      \n      sstart[0] = st1[kk1-1];\n      sstart[1] = st2[kk2-1];\n      send[0] = st1[kn1];\n      send[1] = st2[kn2];\n      \n      /* Copy interval description into local variables */\n      \n      if (icur ==1)\n\t if ( epar1[0]<epar2[0] )\n\t {\n\t    sfirst[0] = epar1[1];\n\t    sfirst[1] = epar1[2];\n\t    slast[0]  = epar2[1];\n\t    slast[1]  = epar2[2];\n\t    tfirst    = epar1[0];\n\t    tend      = epar2[0];\n\t }\n\t else\n\t {\n\t    sfirst[0] = epar2[1];\n\t    sfirst[1] = epar2[2];\n\t    slast[0]  = epar1[1];\n\t    slast[1]  = epar1[2];\n\t    tfirst    = epar2[0];\n\t    tend      = epar1[0];\n\t }\n      else\n\t if ( epar1[2]<epar2[2] )\n\t {\n\t    sfirst[0] = epar1[0];\n\t    sfirst[1] = epar1[1];\n\t    slast[0]  = epar2[0];\n\t    slast[1]  = epar2[1];\n\t    tfirst    = epar1[2];\n\t    tend      = epar2[2];\n\t }\n\t else\n\t {\n\t    sfirst[0] = epar2[0];\n\t    sfirst[1] = epar2[1];\n\t    slast[0]  = epar1[0];\n\t    slast[1]  = epar1[1];\n\t    tfirst    = epar2[2];\n\t    tend      = epar1[2];\n\t }\n      \n      /* To make sure we do not start outside or end outside the curve we\n\t truncate tstart and tend to the knot interval of the curve */\n      \n      tfirst = MAX(tfirst,st[kk-1]);\n      tend   = MIN(tend,st[kn]);\n      if (DEQUAL(tfirst,tend)) goto out;\n      \n      /* Set start point of iteration on surface */\n      \n      spos[0] = sfirst[0];\n      spos[1] = sfirst[1];\n      \n      /* Store knot values at start of curve */\n      \n      tx2 = tfirst;\n      kdum = MAX(kk1,kk2);\n      kdum = MAX(kdum,kk);\n      tmaxinc = (tend-tfirst)/(kdum*kdum);      \n      \n      /* Make start point of curve  */\n      \n      s1221(pcurve,kderc,tx2,&kleftc,sderc,&kstat);\n      if (kstat<0) goto error;\n      \n      /* Make start point of surface.  */\n      \n      s1421(psurf,kders,spos,&kleft1,&kleft2,sders,snorm,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* While end not reached */\n      \n      while (tx2 < tend)\n      {\n\t /* Save parameters of previous step.   */\n\t \n\t tx1 = tx2;\n\t snext[0] = spos[0];\n\t snext[1] = spos[1];\n\t kleft1prev = kleft1;\n\t kleft2prev = kleft2;\n\t \n\t /* Calculate unit tangent and radius of curvature of curve. */\n\t \n\t s1307(sderc,kdimc,s3dinf1,&kstat);\n\t if (kstat<0) goto error;\n\t \n\t /* Calculate step length based on curvature */\n\t \n\t tcstep = s1311(s3dinf1[3*kdimc],aepsge,tsmax,&kstat);\n\t if (kstat<0) goto error;\n\t \n\t /* Remember length of start tangent, end of zero segment */\n\t \n\t tlengthend = s6length(sderc+kdimc,kdimc,&kstat);\n\t if (kstat<0) goto error;     \n\t \n\t /* Compute position, first and second derivative of the curve in the\n\t    surface going through the evaluated point in this point. \n\t \n\t\t      s1785_s9eval(sders,snorm,sderc+kdimc,sder2,kdims,&kstat);\n\t if (kstat < 0) goto error;\n\t \n\t  Calculate unit tangent and radius of curvature of curve in surface. \n\t \n\t s1307(sder2,kdims,s3dinf2,&kstat);\n\t if (kstat<0) goto error;\n\t \n\t  Calculate step length based on curvature \n\t \n\t tsstep = s1311(s3dinf2[3*kdims],aepsge,tcmax,&kstat);\n\t if (kstat<0) goto error;\n\t \n\t  Compute minimum step length.  \n\t \n\t tstep = MIN(tcstep,tsstep);  */\n\n\t tstep = tcstep;\n\t \n\t /* Find candidate end point, make sure that no breaks in tangent or\n\t    curvature exists between start and endpoints of the segment      */\n\t \n\t /* Make step length equal to resolution if the length is zero */\n\t \n\t /* Find parameter value of candidate end point of segment */\n\t \n\t if (DEQUAL(tlengthend,DZERO))\n\t    tincre = REL_PAR_RES;\n\t else\n\t    tincre = tstep/tlengthend;\n\t \n\t /* Make sure that we don't pass any knots of the curve. */\n\t \n\t tincre = MIN(tincre,tmaxinc);\n\t tx2 = MIN(tx1 + tincre,st[kleftc+1]);\n\t \n\t for (ki=0, tx=(tx1+tx2)/(double)2.0; ki<2; ki++, tx=tx2)\n\t {\n\t    if (tx >= tend) break;\n\t    \n\t    /* Make point sderc at curve at tx */\n\t    \n\t    s1221(pcurve,kderc,tx,&kleftc,sderc,&kstat);\n\t    if (kstat<0) goto error;\n\t    \n\t    /* Find closest point on surface to sderc */\n\t    \n\t    qpoint = newPoint(sderc,kdimc,0);\n\t    if (qpoint==SISL_NULL) goto err101;\n\t    \n\t    snext2[0] = snext[0];\n\t    snext2[1] = snext[1];\n\t    s1773(qpoint,psurf,aepsge,sstart,send,snext2,spos,&kstat);\n\t    if(kstat<0) goto error;\n\t    \n\t    freePoint(qpoint);  qpoint = SISL_NULL;\n\t    \n\t    /* Calculate point and derivatives in surface */\n\t    \n\t    s1421(psurf,kders,spos,&kleft1,&kleft2,sders,snorm,&kstat);\n\t    if (kstat<0) goto error;\n\t    \n\t    /* Check if point on curve and surface are within positional and\n\t       angular tolerances */\n\t    \n\t    tdist = s6dist(sderc,sders,kdimc);\n\t    \n\t    if (tdist>aepsge)\n\t    {\n\t       /* Points not within tolerances, curve and surface do not\n\t\t  coincide */\n\t       goto war01;\n\t    }\n\t    \n\t    /* Check if any parameter lines of the surface is crossed in the 1. \n\t       parameter direction.  */\n\t    \n\t    /* changed by Michael Metzger, Feb 1993 */\n\t    /* for (khelp=kleft1prev-1; DEQUAL(st1[khelp],st1[kleft1prev]); khelp--); */\n\t    for (khelp=kleft1prev-1; khelp >= 0 && DEQUAL(st1[khelp],st1[kleft1prev]); khelp--);\n\t    if (kleft1 != kleft1prev && \n\t\t((DNEQUAL(spos[0]+tref,st1[kleft1]+tref) &&\n\t\t DNEQUAL(snext[0]+tref,st1[kleft1]+tref)) || \n\t\t kleft1 != kleft1prev+1) &&\n\t\t((DNEQUAL(snext[0]+tref,st1[kleft1prev]+tref) &&\n\t\t DNEQUAL(spos[0]+tref,st1[kleft1prev]+tref)) || kleft1 != khelp))\n\t    {\n\t       /* At least one parameter line is crossed. Fetch the constant parameter\n\t\t  curve at the closest parameter line in the direction of the marching. */\n\t       \n\t       if (kleft1 > kleft1prev) kpar = kleft1prev + 1;\n\t       else if (snext[0] != st1[kleft1prev]) kpar = kleft1prev;\n\t       else kpar = khelp;\n\t       \n\t       /* Pick constant parameter curve.   */\n\t       \n\t       s1437(psurf,st1[kpar],&qc,&kstat);\n\t       if (kstat < 0) goto error;\n\t       \n\t       /* Find the closest point between the input curve and the constant\n\t\t  parameter curve.    */\n\t       \n\t       s1770(pcurve,qc,aepsge,tx1,st2[kk2-1],tx,st2[kn2],(tx1+tx)/(double)2.0,\n\t\t     st2[kleft2],&tclose1,&tclose2,&kstat);\n\t       if (kstat < 0) goto error;\n\t       \n\t       /* Set new parameter values to the iteration.  */\n\t       \n\t       spos[0] = st1[kpar];\n\t       spos[1] = tclose2;\n\t       tx2 = tclose1;\n\t       \n              /* Test midpoint of reduced step. First evaluate curve in midpoint. */\n\t       \n\t       tx = (tx1 + tx2)/(double)2.0;\n\t       s1221(pcurve,kderc,tx,&kleftc,sderc,&kstat);\n\t       if (kstat<0) goto error;\n\t       \n\t       /* Find closest point on surface to sderc */\n\t       \n\t       qpoint = newPoint(sderc,kdimc,0);\n\t       if (qpoint==SISL_NULL) goto err101;\n\t       \n\t       snext2[0] = snext[0];\n\t       snext2[1] = snext[1];\n\t       s1773(qpoint,psurf,aepsge,sstart,send,snext2,snext2,&kstat);\n\t       if(kstat<0) goto error;\n\t       \n\t       freePoint(qpoint);  qpoint = SISL_NULL;\n\t       \n\t       /* Calculate point and derivatives in surface */\n\t       \n\t       s1421(psurf,kders,snext2,&kleft1,&kleft2,sders,snorm,&kstat);\n\t       if (kstat<0) goto error;\n\t       \n\t       /* Check if point on curve and surface are within positional and\n\t\t  angular tolerances */\n\t       \n\t       tdist = s6dist(sderc,sders,kdimc);\n\t       \n\t       if (tdist>aepsge)\n\t       {\n\t\t  /* Points not within tolerances, curve and surface do not\n\t\t     coincide */\n\t\t  goto war01;\n\t       }\n\n\t       /* Calculate point and derivatives in the curve in the endpoint of the step. */\n\t       \n\t       s1221(pcurve,kderc,tx2,&kleftc,sderc,&kstat);\n\t       if (kstat<0) goto error;\n\t       \n\t       /* Calculate point and derivatives in the surface.  */\n\t       \n\t       s1421(psurf,kders,spos,&kleft1,&kleft2,sders,snorm,&kstat);\n\t       if (kstat<0) goto error;\n\t       \n\t       /* Check if point on curve and surface are within positional and\n\t\t  angular tolerances */\n\t       \n\t       tdist = s6dist(sderc,sders,kdimc);\n\t       \n\t       if (tdist>aepsge)\n\t       {\n\t\t  /* Points not within tolerances, curve and surface do not\n\t\t     coincide */\n\t\t  goto war01;\n\t       }\n\t       \n\t       /* Mark that a new step is to be initiated.  */\n\t       \n\t       ki = 2;\n\t       \n\t       /* Free constant parameter curve.  */\n\t       \n\t       if (qc != SISL_NULL) freeCurve(qc);  qc = SISL_NULL;\n\t    }\n\t    \n\t    /* Check if any parameter lines of the surface is crossed in the 2. \n\t       parameter direction.  */\n\t    \n\t    /* changed by Michael Metzger, Feb 1993 */\n\t    /* for (khelp=kleft2prev-1; DEQUAL(st2[khelp],st2[kleft2prev]); khelp--); */\n\t    for (khelp=kleft2prev-1; khelp >= 0 && DEQUAL(st2[khelp],st2[kleft2prev]); khelp--);\n\t    if (kleft2 != kleft2prev && \n\t\t((DNEQUAL(spos[1]+tref,st2[kleft2]+tref) &&\n\t\t DNEQUAL(snext[1]+tref,st2[kleft2]+tref)) || \n\t\t kleft2 != kleft2prev+1) &&\n\t\t((DNEQUAL(snext[1]+tref,st2[kleft2prev]+tref) &&\n\t\t DNEQUAL(spos[1]+tref,st2[kleft2prev]+tref)) ||\n\t\t kleft2 != khelp))\n\t    {\n\t       /* At least one parameter line is crossed. Fetch the constant parameter\n\t\t  curve at the closest parameter line in the direction of the marching. */\n\t       \n\t       if (kleft2 > kleft2prev) kpar = kleft2prev + 1;\n\t       else if (snext[1] != st2[kleft2prev]) kpar = kleft2prev;\n\t       else kpar = khelp;\n\t       \n\t       /* Pick constant parameter curve.   */\n\t       \n\t       s1436(psurf,st2[kpar],&qc,&kstat);\n\t       if (kstat < 0) goto error;\n\t       \n\t       /* Find the closest point between the input curve and the constant\n\t\t  parameter curve.    */\n\t       \n\t       s1770(pcurve,qc,aepsge,tx1,st1[kk1-1],tx,st1[kn1],(tx1+tx)/(double)2.0,\n\t\t     st1[kleft1],&tclose1,&tclose2,&kstat);\n\t       if (kstat < 0) goto error;\n\t       \n\t       /* Set new parameter values to the iteration.  */\n\t       \n\t       spos[0] = tclose2;\n\t       spos[1] = st2[kpar];\n\t       tx2 = tclose1;\n\t       \n\t       /* Test midpoint of reduced step. First evaluate curve in midpoint. */\n\t       \n\t       tx = (tx1 + tx2)/(double)2.0;\n\t       s1221(pcurve,kderc,tx,&kleftc,sderc,&kstat);\n\t       if (kstat<0) goto error;\n\t       \n\t       /* Find closest point on surface to sderc */\n\t       \n\t       qpoint = newPoint(sderc,kdimc,0);\n\t       if (qpoint==SISL_NULL) goto err101;\n\t       \n\t       snext2[0] = snext[0];\n\t       snext2[1] = snext[1];\n\t       s1773(qpoint,psurf,aepsge,sstart,send,snext2,snext2,&kstat);\n\t       if(kstat<0) goto error;\n\t       \n\t       freePoint(qpoint);  qpoint = SISL_NULL;\n\t       \n\t       /* Calculate point and derivatives in surface */\n\t       \n\t       s1421(psurf,kders,snext2,&kleft1,&kleft2,sders,snorm,&kstat);\n\t       if (kstat<0) goto error;\n\t       \n\t       /* Check if point on curve and surface are within positional and\n\t\t  angular tolerances */\n\t       \n\t       tdist = s6dist(sderc,sders,kdimc);\n\t       \n\t       if (tdist>aepsge)\n\t       {\n\t\t  /* Points not within tolerances, curve and surface do not\n\t\t     coincide */\n\t\t  goto war01;\n\t       }\n\n\t       /* Calculate point and derivatives in the curve.    */\n\t       \n\t       s1221(pcurve,kderc,tx2,&kleftc,sderc,&kstat);\n\t       if (kstat<0) goto error;\n\t       \n\t       /* Calculate point and derivatives in the surface.  */\n\t       \n\t       s1421(psurf,kders,spos,&kleft1,&kleft2,sders,snorm,&kstat);\n\t       if (kstat<0) goto error;\n\t       \n\t       /* Check if point on curve and surface are within positional and\n\t\t  angular tolerances */\n\t       \n\t       tdist = s6dist(sderc,sders,kdimc);\n\t       \n\t       if (tdist>aepsge)\n\t       {\n\t\t  /* Points not within tolerances, curve and surface do not\n\t\t     coincide */\n\t\t  goto war01;\n\t       }\n\t       \n\t       /* Mark that a new step is to be initiated.  */\n\t       \n\t       ki = 2;\n\t       \n\t       /* Free constant parameter curve.  */\n\t       \n\t       if (qc != SISL_NULL) freeCurve(qc);  qc = SISL_NULL;\n\t    }\n\t }\n      }\n      \n      /* Curves within tolerance. Test on whether the start- and\n\t endpoint of the curve are identical.                      */\n      \n      *jstat = (DEQUAL(tfirst,tend)) ? 0 : 1;\n      goto out;\n      \n      /* Curve and surface not within tolerance */\n      war01: *jstat = 0;\n      goto out;\n      \n      /* Error in memory allocation */\n      \n      err101: *jstat = -101;\n      s6err(\"S1785\",*jstat,kpos);\n      goto out;\n      \n      /* Error in input, dimension not equal to 2 or 3 */\n      \n      err105: *jstat = -105;\n      s6err(\"S1785\",*jstat,kpos);\n      goto out;\n      \n      /* Error in lower level function */\n      \n      error:  *jstat = kstat;\n      s6err(\"S1785\",*jstat,kpos);\n      goto out;\n      \n      \n      out:\n\t \n\t return;\n      }          \n\t \n#if 0\n\t \n#if defined(SISLNEEDPROTOTYPES)\n   static\n      void\n            s1785_s9eval(double eders[],double enorms[],double etanc[], \n\t\t   double ederc[],int idim, int *jstat)\n#else\nstatic void s1785_s9eval(eders,enorms,etanc,ederc,idim,jstat)\n\tdouble eders[];\n\tdouble enorms[];\n\tdouble etanc[];\n\tdouble ederc[];\n\tint idim;\n\tint *jstat;\n#endif\n\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Compute the position, first and second derivative of \n*              a curve going through a given point of the surface when\n*              the 0-2'th derivatives of the surface is given. The\n*              tangent of the wanted curve is parallel to the projection\n*              of a given vector into the tangent plane of the surface.\n*\n*\n* INPUT      : eders    - 0-2'th derivatives of the surface. Dimension\n*                         is 6*idim.\n*              enorms   - Normal vector of the surface. Dimension is idim.\n*              etanc    - Vector to be projected into the tangent plane\n*                         of the surface. Dimension is idim.\n*              idim     - Dimension of geometry space.\n*\n*\n*\n* OUTPUT     : ederc   - 0-2'th derivative of the curve in the surface.\n*              jstat   - status messages  \n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SI, Oslo, Norway. Oct. 1990\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;         /* Status variable.  */\n   int ki;                /* Counter.          */\n   int ksign = 1;         /* Parameter used in s6findfac.     */\n   double tfac1,tfac2,tfac3;  /* Factors found by s6findfac.  */\n   \n   /* Copy position of surface to output array.   */\n   \n   memcopy(ederc,eders,idim,DOUBLE);\n   \n   /* Compute the factors used to express etanc by the derivatives and normal\n      of the surface.  */\n   \n   s6findfac(eders+idim,eders+2*idim,enorms,etanc,idim,ksign,&tfac1,&tfac2,\n\t     &tfac3,&kstat);\n   if (kstat < 0) goto error;\n   \n   /* Compute first and second derivative of the curve in the surface.  */\n   \n   for (ki=0; ki<idim; ki++)\n   {\n      ederc[idim+ki] = tfac1*eders[idim+ki] + tfac2*eders[2*idim+ki];\n      ederc[2*idim+ki] = tfac1*tfac1*eders[3*idim+ki] \n\t + (double)2.0*tfac1*tfac2*eders[4*idim+ki] + tfac2*tfac2*eders[5*idim+ki];\n   }\n   \n   *jstat = 0;\n   goto out;\n   \n   /* Error in lower level routine.  */\n   \n   error:\n      *jstat = kstat;\n   goto out;\n   \n   out:\n      return;\n}\n\n#endif /* if 0 */\n"
  },
  {
    "path": "src/s1786.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1786.c,v 1.5 2005-02-28 09:04:49 afr Exp $\n *\n */\n#define S1786\n\n#include \"sislP.h\"\n\ntypedef  void (*fevalcProc)(\n#if defined(SISLNEEDPROTOTYPES)\n                        SISLCurve *,\n                        int,\n                        double ,\n                        int *,\n                        double [],\n                        int *\n#endif\n);\n\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void s1786_s9relax(fevalcProc fevalc1,\n\t\t\t  fevalcProc fevalc2,\n\t\t\t  SISLCurve *,SISLCurve *,int,double,double,int *,\n\t\t\t  double [],double,double *,int *,double [],int *);\n#else\nstatic void s1786_s9relax();\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1786(SISLCurve *pc1,SISLCurve *pc2,double aepsge,double epar1[],double epar2[],int *jstat)\n#else\nvoid s1786(pc1,pc2,aepsge,epar1,epar2,jstat)\n   SISLCurve  *pc1;\n   SISLCurve  *pc2;\n     double aepsge;\n     double epar1[];\n     double epar2[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Test if the curves coincide between two intersection points.\n*              This function is used when the first derivative\n*              for the curves are matching in both intersection points.\n*\n*\n* INPUT      : pc1      - Pointer to the first curve.\n*              pc2      - Pointer to the second curve..\n*              aepsge   - Geometry resolution.\n*              epar1[2] - Parameter values for the first intersection point.\n*              epar2[2] - Parameter values for the second intersection point.\n*\n*\n* OUTPUT     :  jstat   - status messages\n*                                = 1   : Coincidence of curves\n*                                = 0   : No coincidence.\n*                                < 0   : Error.\n*\n*\n* METHOD     : March along one curve, and for each step iterate to\n*              the closest point of the other curve at the midpoint and\n*              the endpoint of the step. The geometry and knot vectors of\n*              both curves are considered when making the step, and we\n*              march along the curve that has set the step.\n*\n* CALLS      : s1221  - Evaluate B-spline curve.\n*              s1307  - Compute unit tangent and radius of curvature.\n*              s1311  - Find current step length.\n*              sh1992  - Find box-size of object.\n*              s6lenght - Length of vector.\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. July 1989\n* REWISED BY : Vibeke Skytt, SI, Oslo, Norway. Oct. 1990.\n*\n*********************************************************************\n*/\n{\n  int kstat;          /* Status variable                                 */\n  int ki;             /* Counter.                                        */\n  int kleftc1=0;      /* Left indicator for point calculation of curve 1.*/\n  int kleftc2=0;      /* Left indicator for point calculation of curve 2.*/\n  int kk1,kk2,kn1,kn2;/* Orders and number of vertices of curves         */\n  int kdim;           /* The dimension of the space in which the curves lie. */\n  int kpos=0;         /* Position of error                               */\n  int kderc=2;        /* Number of derivatives to be claculated on the curves */\n  int kdum;           /* Temporary variable                              */\n  int kchange;        /* Indicates which curve that is marched along.\n\t\t\t = 0 : First curve.\n\t\t\t = 1 : Second curve.                             */\n  int kknot;          /* Indicates if the next knot in the marching direction\n\t\t\t is before or after the current knot.            */\n  double s3dinf1[20]; /* Pointer to storage for point info of curve 1\n\t\t\t  (10 dobules pr point when idim=3, 7 when idim=3) */\n  double s3dinf2[20]; /* Pointer to storage for point info of curve 2\n\t\t\t  (10 dobules pr point when idim=3, 7 when idim=3) */\n  double *st1;        /* Knot vector of first curve                      */\n  double *st2;        /* Knot vector of second curve                     */\n  double tfirst1,tfirst2;/* First parameter value on curves              */\n  double tend1,tend2; /* Last parameter on curves                        */\n  double sderc1[20];  /* Position, first and second derivatives on curve 1 */\n  double sderc2[20];  /* Position, first and second derivatives on curve 2 */\n  double tx,tx1,tx2;  /* Parameter values of first curve.  */\n  double ty,ty1,ty2;  /* Parameter value of second curve.  */\n  double tminstep;    /* Referance value in parameter domain     */\n  double tstep;       /* Final step length     */\n  double txstep,tystep;  /* Step length     */\n  double txmaxinc,tymaxinc;  /* Maximal increment in parameter value along curve*/\n  double txlengthend,tylengthend;  /* Length of 1st derivative at start of segment */\n  double txincre,tyincre;      /* Parameter value increment */\n  double txmax,tymax;        /* Local maximal step length                       */\n  double tdist;       /* Distance */\n  double tpos;        /* New iteration  point on curve pc2     */\n\n /* Pointer to curve evaluator routine of 2. curve.  */\n\n  fevalcProc fevalc;\n/*\n #if defined(SISLNEEDPROTOTYPES)\n   void (*fevalc)(SISLCurve *, int, double , int *, double [], int *);\n #else\n      void (*fevalc)();\n #endif\n */\n     /* UJK, aug 93, make min step in parameter domain based on the\n\tmax parameter values */\n     tminstep  = max(fabs(pc1->et[pc1->ik-1]),fabs(pc1->et[pc1->in]));\n     tminstep += max(fabs(pc2->et[pc2->ik-1]),fabs(pc2->et[pc2->in]));\n     tminstep *= REL_PAR_RES;\n\n\n     /* Make maximal step length based on box-size of curve 1 */\n\n  sh1992cu(pc1,0,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  txmax = MAX(pc1->pbox->e2max[0][0] - pc1->pbox->e2min[0][0],\n\t     pc1->pbox->e2max[0][1] - pc1->pbox->e2min[0][1]);\n  txmax = MAX(txmax,pc1->pbox->e2max[0][2] - pc1->pbox->e2min[0][2]);\n\n  /* Make maximal step length based on box-size of curve 2 */\n\n  sh1992cu(pc2,0,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  tymax = MAX(pc2->pbox->e2max[0][0] - pc2->pbox->e2min[0][0],\n\t     pc2->pbox->e2max[0][1] - pc2->pbox->e2min[0][1]);\n  tymax = MAX(tymax,pc2->pbox->e2max[0][2] - pc2->pbox->e2min[0][2]);\n\n  /* Copy curve pc1 attributes to local parameters.  */\n\n  kdim = pc1 -> idim;\n  kk1    = pc1 -> ik;\n  kn1    = pc1 -> in;\n  st1    = pc1 -> et;\n\n  /* Copy curve pc2 attributes to local parameters.  */\n\n  kk2    = pc2 -> ik;\n  kn2    = pc2 -> in;\n  st2    = pc2 -> et;\n\n  /* Check that dimensions are equal */\n\n  if (kdim != pc2->idim || kdim > 3) goto err105;\n\n  /* Copy interval description into local variables */\n\n  if ( epar1[0]<epar2[0] )\n    {\n      tfirst1 = epar1[0];\n      tfirst2 = epar1[1];\n      tend1   = epar2[0];\n      tend2   = epar2[1];\n    }\n  else\n    {\n      tfirst1 = epar2[0];\n      tfirst2 = epar2[1];\n      tend1   = epar1[0];\n      tend2   = epar1[1];\n    }\n\n  /* To make sure we do not start outside or end outside the curve we\n     truncate tstart1 and tend1 to the knot interval of the curve */\n\n  tfirst1 = MAX(tfirst1,st1[kk1-1]);\n  tend1   = MIN(tend1,st1[kn1]);\n\n  /* To make sure we do not start outside or end outside the curve we\n     truncate tstart2 and tend2 to the knot interval of the curve */\n\n  if (tfirst2 <= tend2)\n  {\n     tfirst2 = MAX(tfirst2,st2[kk2-1]);\n     tend2   = MIN(tend2,st2[kn2]);\n     kknot = 1;\n  }\n  else\n  {\n     tfirst2 = MIN(tfirst2,st2[kn2]);\n     tend2 = MAX(tend2,st2[kk2-1]);\n     kknot = -1;\n  }\n\n  /* Set curve evaluator of 2. curve.  */\n\n  fevalc = (kknot == 1) ? s1221 : s1227;\n\n  /* Store knot values at start of curve */\n\n  tx1 = tfirst1;\n  kdum = MAX(kk1,kk2);\n  txmaxinc = (tend1-tfirst1)/(kdum*kdum);\n\n  /* Make start point and intital step length based on first curve  */\n\n  s1221(pc1,kderc,tx1,&kleftc1,sderc1,&kstat);\n  if (kstat<0) goto error;\n\n  ty1 = tfirst2;\n  tymaxinc = fabs(tend2-tfirst2)/(kdum*kdum);\n\n  /* Make start point and intital step length based on second curve  */\n\nfevalc(pc2,kderc,ty1,&kleftc2,sderc2,&kstat);\n  if (kstat<0) goto error;\n\n  if (DEQUAL(tfirst1,tend1) || DEQUAL(tfirst2,tend2))\n  {\n    *jstat = 0;\n    goto out;\n  }\n\n  /* While end not reached */\n\n\n  while (tx1 < tend1 && kknot*ty1 < kknot*tend2)\n    {\n      tpos = ty1;\n\n      /* Calculate unit tangent and radius of curvature of first curve. */\n\n      s1307(sderc1,kdim,s3dinf1,&kstat);\n      if (kstat<0) goto error;\n\n      /* Calculate step length based on curvature of first curve. */\n\n      txstep = s1311(s3dinf1[3*kdim],aepsge,tymax,&kstat);\n      if (kstat<0) goto error;\n\n      /* Remember length of start tangent, end of zero segment */\n\n      txlengthend = s6length(sderc1+kdim,kdim,&kstat);\n      if (kstat<0) goto error;\n\n      /* Calculate unit tangent and radius of curvature of second curve. */\n\n      s1307(sderc2,kdim,s3dinf2,&kstat);\n      if (kstat<0) goto error;\n\n      /* Calculate step length based on curvature */\n\n      tystep = s1311(s3dinf2[3*kdim],aepsge,txmax,&kstat);\n      if (kstat<0) goto error;\n\n      /* Remember length of start tangent, end of zero segment */\n\n      tylengthend = s6length(sderc2+kdim,kdim,&kstat);\n      if (kstat<0) goto error;\n\n      /*  Find minimum step length.  */\n\n      tstep = MIN(txstep,tystep);\n      kchange = (txstep <= tystep) ? 0 : 1;\n\n      /*  Find candidate end point, make sure that no breaks in tangent or\n\t  curvature exists between start and endpoints of the segment      */\n      /* Compute increment in the parameter values.  Use tminstep if the\n         tangent has zero length.  */\n\n      if (DEQUAL(txlengthend,DZERO))\n\t  txincre = tminstep;\n      else\n        txincre = MIN(tstep/txlengthend,txmaxinc);\n\n      if (DEQUAL(tylengthend,DZERO))\n\ttyincre = tminstep;\n      else\n        tyincre = MIN(tstep/tylengthend,tymaxinc);\n\n      /* Update step length */\n\n      if (txincre * txlengthend < tyincre * tylengthend)\n      {\n\t tstep = txincre * txlengthend;\n\t tyincre = (tylengthend > 0.0) ? tstep / tylengthend : REL_PAR_RES;\n\t kchange = 0;\n      }\n      else if (txincre * txlengthend > tyincre * tylengthend)\n      {\n\t tstep = tyincre * tylengthend;\n\t txincre = (txlengthend > 0.0) ? tstep / txlengthend : REL_PAR_RES;\n\t kchange = 1;\n      }\n\n      /*  Make sure that we don't pass any knots of curve 1. */\n\n      if (tx1 + txincre > st1[kleftc1+1] + tminstep &&\n\t  tx1 < st1[kleftc1+1] - tminstep)\n\t{\n\t  txincre = st1[kleftc1+1] - tx1;\n\t  tstep = txincre*txlengthend;\n\t  tyincre = (tylengthend > DZERO) ? tstep/tylengthend : tminstep;\n\t  kchange = 0;\n\t}\n\n       /* Avoid passing second next knot of curve 2. */\n\n      if (kknot*(ty1 + tyincre) > kknot*(st2[kleftc2+kknot]+tminstep) &&\n\t  kknot*ty1 > kknot*(st2[kleftc2+kknot]-tminstep))\n\t{\n\t  tyincre = kknot*(st2[kleftc2+kknot] - ty1);\n\t  tstep = tyincre*tylengthend;\n\t  txincre = (txlengthend > DZERO) ? tstep/txlengthend : tminstep;\n\t  kchange = 1;\n\t}\n\n       /* Avoid passing next knot of curve 2. */\n\n      if (kknot < 0 && (ty1 - tyincre < st2[kleftc2] - tminstep) &&\n\t  (ty1 < st2[kleftc2] + tminstep))\n\t{\n\t  tyincre = kknot*(st2[kleftc2+kknot] - ty1);\n\t  tstep = tyincre*tylengthend;\n\t  txincre = (txlengthend > DZERO) ? tstep/txlengthend : tminstep;\n\t  kchange = 1;\n\t}\n\n\n      /* Set endpoints of step.  */\n\n      tx2 = tx1 + txincre;\n      ty2 = ty1 + kknot*tyincre;\n\n      for (tx=(tx1+tx2)/(double)2.0, ty=(ty1+ty2)/(double)2.0, ki=0;\n       ki<2; ki++, tx=tx2, ty=ty2)\n      {\n\t if (kchange == 0)\n\t {\n\t    if (tx >= tend1) break;\n\n\t    /* March along first curve. Iterate down to the second.  */\n\n\t    s1786_s9relax(s1221,fevalc,pc1,pc2,kderc,aepsge,tx,&kleftc1,sderc1,ty,\n\t\t\t  &tpos,&kleftc2,sderc2,jstat);\n\t    if (kstat < 0) goto error;\n\t }\n\t else\n\t {\n\t    /* UJK, 05.05.91     if (kknot*tx >= kknot*tend2) break; */\n\t    if (kknot*ty >= kknot*tend2) break;\n\n\t    /* March along second curve. Iterate down to the first.  */\n\t    s1786_s9relax(fevalc,s1221,pc2,pc1,kderc,aepsge,ty,&kleftc2,sderc2,tx,\n\t\t\t  &tpos,&kleftc1,sderc1,jstat);\n\t    if (kstat < 0) goto error;\n\t }\n\n\t  /*  Check if point on curve and surface are within positional and\n\t      angular tolerances */\n\n\t  tdist = s6dist(sderc1,sderc2,kdim);\n\n\t  if (tdist>aepsge)\n\t    {\n\t      /*      Points not within tolerances, curve and surface do not\n\t\t      coincide */\n\t      goto war00;\n\t    }\n\t}\n\n      /*   Update start parameter value of segment, and calculate right\n\t   hand derivative */\n\n      if (kchange == 0)\n      {\n\t tx1 = tx2;\n\t ty1 = (kknot == 1) ? MAX(tpos,ty1) : MIN(tpos,ty1); /*tpos;*/\n      }\n      else\n      {\n\ttx1 = MAX(tpos,tx1); /*tpos; */\n\t ty1 = ty2;\n      }\n    }\n\n  /*  Curves within tolerance */\n\n  /*  Curves within tolerance. Test if the start- and endpoint of any\n     of the curves are equal.   */\n\n  *jstat = (DEQUAL(tfirst1,tend1) || DEQUAL(tfirst2,tend2)) ? 0 : 1;\n  goto out;\n\n/* Curve and surface not within tolerance */\nwar00: *jstat = 0;\ngoto out;\n\n/* Error in input, dimension not equal to 2 or 3 */\n\nerr105: *jstat = -105;\n        s6err(\"S1786\",*jstat,kpos);\n        goto out;\n\n/* Error in lower level function */\n\nerror:  *jstat = kstat;\n        s6err(\"S1786\",*jstat,kpos);\n        goto out;\n\nout:\n return;\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\n\nstatic void\n   s1786_s9relax(fevalcProc fevalc1,fevalcProc fevalc2,\n\t\t SISLCurve *pc1,SISLCurve *pc2,\n\t\t int ider,double aepsge,double ax1,int *jleft1,double eder1[],\n\t\t double anext,double *cx2,int *jleft2,double eder2[],int *jstat)\n#else\nstatic void s1786_s9relax(fevalc1,fevalc2,pc1,pc2,ider,aepsge,ax1,jleft1,eder1,anext,\n\t\t    cx2,jleft2,eder2,jstat)\n    fevalcProc \tfevalc1;\n    fevalcProc \tfevalc2;\n    SISLCurve \t*pc1;\n    SISLCurve \t*pc2;\n    int \tider;\n    double \taepsge;\n    double \tax1;\n    int \t*jleft1;\n    double \teder1[];\n    double \tanext;\n    double \t*cx2;\n    int \t*jleft2;\n    double \teder2[];\n    int \t*jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Iterate the first curve in a given parameter value and\n*              iterate down to the closest point on the second curve\n*              to the position on the first curve.\n*\n*\n* INPUT      : fevalc1 - Curve evaluator corresponding to first curve.\n*              fevalc1 - Curve evaluator corresponding to second curve.\n*              pc1     - Pointer to the first curve.\n*              pc2     - Pointer to the second curve.\n*              ider    - Number of derivatives to compute. 0 <= ider <= 2.\n*              aepsge  - Geometry resolution.\n*              ax1     - Parameter value at which to evaluate curve 1.\n*              anext   - Start parameter to the iteration on curve 2.\n*\n*\n* INPUT/OUTPUT : jleft1  - Parameter used to set knot interval of curve1.\n*                          Used in s1221.\n*                jleft2  - Parameter used to set knot interval of curve2.\n*\n*\n* OUTPUT     : eder1   - 0-ider'th derivative of curve 1 evaluated in ax1.\n*                        Dimension is (ider+1)*pc1->idim.\n*              cx2     - Parameter value of the point on curve 2 closest\n*                        to the point given by eder1.\n*              eder2   - 0-ider'th derivative of curve 2 evaluated in *cx2.\n*                        Dimension is (ider+1)*pc2->idim.\n*              jstat   - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n*\n* CALLS      :  s1221     - Evaluate curve.\n*               s1771     - Closest point between a curve and a point.\n*               newPoint  - Create new point object.\n*               freePoint - Free point object.\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SI, Oslo, Norway. Oct. 1990\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;         /* Status variable.  */\n   double tstart;         /* Start parameter value of curve 2.  */\n   double tend;           /* End parameter value of curve 2.    */\n   SISLPoint *qpoint = SISL_NULL;  /* SISLPoint instance used to represent point on curve 1. */\n\n   /* Find endpoints of the parameter interval of curve 2.  */\n\n   tstart = *(pc2->et + pc2->ik - 1);\n   tend = *(pc2->et + pc2->in);\n\n\n   /*  Make point sderc at curve at ax1 */\n\n   fevalc1(pc1,ider,ax1,jleft1,eder1,&kstat);\n\n   if (kstat<0) goto error;\n\n   /* Find closest point on curve 2 to eder1 */\n\n   qpoint = newPoint(eder1,pc1->idim,0);\n   if (qpoint==SISL_NULL) goto err101;\n\n   s1771(qpoint,pc2,aepsge,tstart,tend,anext,cx2,&kstat);\n   if(kstat<0) goto error;\n\n   /* Calculate point and derivatives in second curve */\n\n   fevalc2(pc2,ider,*cx2,jleft2,eder2,&kstat);\n\n   if (kstat<0) goto error;\n\n   *jstat = 0;\n   goto out;\n\n   /* Error in space allocation.  */\n\n   err101 :\n      *jstat = -101;\n   goto out;\n\n   /* Error in lower level routine.  */\n\n   error :\n      *jstat = kstat;\n   goto out;\n\n   out :\n     if (qpoint != SISL_NULL) freePoint(qpoint);\n\n      return;\n}\n"
  },
  {
    "path": "src/s1787.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1787.c,v 1.3 2005-02-28 09:04:49 afr Exp $\n *\n */\n\n\n#define S1787\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1787(SISLSurf *ps,double alevel,double aepsge,double epar[],\n\t   double gpar1[],double gpar2[],int *jstat)\n#else\nvoid s1787(ps,alevel,aepsge,epar,gpar1,gpar2,jstat)\n     SISLSurf   *ps;\n     double alevel;\n     double aepsge;\n     double epar[];\n     double gpar1[];\n     double gpar2[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : In surface-point intersection in dimention one.\n*              To search for endpoints on an intersection curve.\n*              The intersection curve must go through the parameter \n*              pair epar. If the function find a closed curve\n*              it will return a status message 2. \n*              Else if epar is an edge point the function\n*              will return parameter values for the other end point\n*              on the intersection curve in gpar1 and a status message\n*              1. If epar is an internal point the function will\n*              return the parameter values for the two endpoints on\n*              the intersection curve in gpar1 and gpar2 and a status\n*              message 0.\n*\n*\n* INPUT      : ps    - The surface in intersection.\n*              alevel   - The constant value the surface is intersected with.\n*              aepsge   - Geometry resolution.\n*              epar[2]  - Parameter values for the  intersection point.\n*\n*\n*\n* OUTPUT     : gpar1[2] - Parameter values for the first intersection point.\n*                         One of the ends are within computer tolerance from\n*                         epar, then this point is put in this variable and\n*                         the status 1 is returned.\n*              gpar2[2] - Parameter values for the second intersection point\n*                         on the edges. If closed curve found with no singular\n*                         point this point is equal to the first point.\n*              jstat   -  status messages  \n*                   < 0   : Error.\n*                   = 0   : The marching did not succeed.\n*                   = 11  : epar == gpar1. Open curve.\n*                   = 12  : epar == gpar1. Open curve. gpar2 inside.\n*                   = 13  : epar == gpar1. Open curve. gpar1 inside.\n*                   = 14  : epar == gpar1. Open curve. Both ends inside.\n*                   = 16  : epar == gpar1. Closed curve. gpar2 == gpar1\n*                   = 17  : epar == gpar1. Closed curve. gpar2 singular. \n*                   = 21  : epar != output points. Open curve.\n*                   = 22  : epar != output points. Open curve. gpar2 inside.\n*                   = 24  : epar != output points. Open curve.\n*                                                  Output points inside.\n*                   = 26  : epar != output points. Closed curve. gpar2 == gpar1\n*                   = 27  : epar != output points. Closed curve.\n*                                                  gpar2 singular. \n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. July 1989\n*\n*********************************************************************\n*/\n{\n  int kdeg=1;           /* Indicate that a plane is used               */\n  int kk1,kk2,kn1,kn2;  /* Orders and numbers of vertices              */\n  int kstat;            /* Status variable                             */\n  int kkm1,kkm2;        /* Orders minus 1                              */\n  int kincre;           /* Number of doubles in first vertex direction */\n  int kpos=0;           /* Position of error                           */\n  int ki,kj,kl,kstop;\n  int kcur,kgraph;      /* Indicators telling to control type of output\n\t\t\t   from marching                               */\n  int kmark1,kmark2,kclose,kmatch1,kmatch2; /* Flags                   */\n  double tmax;          /* Box size                                    */\n  double tstart,tlength;/* Variables used in Marsdens identity         */\n  double tfak;\n  double tdum1;         /* Max knot value used in DEQUAL comparing.    */\n  double tdum2;         /* Max knot value used in DEQUAL comparing.    */\n  double tsum,*sp,*sq;\n  double simpli[4];     /* Description of plane                        */\n  double *st1,*st2,*scoef; /* Knots and vertices of input surface      */\n  double *s3coef=SISL_NULL;  /* 3-D coeff                                   */\n\t\t\t   \n  double tepsco = REL_COMP_RES;\n  double tepsge;   \n  double sval1[2];      /* Limits of parameter plane in first SISLdir      */\n  double sval2[2];      /* Limits of parameter plane in second SISLdir     */\n  double *spar1,*spar2; /* Pointers to arrays                          */\n  double *spar=SISL_NULL;    /* Pointer to allocated values for parameter values*/\n  SISLSurf *qs=SISL_NULL;    /* 3-D version of surface                     */\n  SISLCurve *qcrv;          /* Curve in parameter plane                   */\n  SISLIntcurve *qintcr=SISL_NULL;/* Intersection curve object            */\n  kk1   = ps -> ik1;\n  kk2   = ps -> ik2;\n  kn1   = ps -> in1;\n  kn2   = ps -> in2;\n  st1   = ps -> et1;\n  st2   = ps -> et2;\n  scoef = ps -> ecoef;\n  sval1[0] = st1[kk1-1];\n  sval1[1] = st1[kn1];\n  sval2[0] = st2[kk2-1];\n  sval2[1] = st2[kn2];\n  \n  /* Allocate array for 3-D representation of surface */\n  \n  if((s3coef = newarray(kn1*kn2*3,DOUBLE)) == SISL_NULL) goto err101;\n  \n  sh1992su(ps,0,aepsge,&kstat);\n  if (kstat < 0) goto error;\n  \n  tmax = ps->pbox->e2max[0][0] - ps->pbox->e2min[0][0];\n  \n  /* Make description of plane */\n  \n  simpli[0] = (double)0.0;\n  simpli[1] = (double)0.0;\n  simpli[2] = (double)1.0;\n  simpli[3] = -alevel;\n  \n  /* Make 3-D description of the surface */\n  \n  \n  /* Make representation of coefficients from Marsdens identity for the\n   * function f(t) = t, with the knot vector in first parameter direction\n   * scaled to [0,tmax]. This will be used as the x-coordinate in the 3-D\n   * representation */\n  \n  tstart = st1[kk1-1];\n  tlength = st1[kn1] - tstart;\n  tfak = tmax/tlength;\n  kkm1 = kk1 - 1;\n  kincre = 3*kn1;\n  \n  for (ki=0,kl=0,sp=s3coef ; ki<kn1 ; ki++,kl+=3,sp+=3)\n    {\n      tsum = (double)0.0;\n      kstop = ki+kk1;\n      for (kj=ki+1;kj<kstop;kj++)\n        tsum +=st1[kj];\n      \n      tsum = (tsum/kkm1-tstart)*tfak;\n      \n      \n      /* Copy x-coordinate to the other vertex rows */\n      /*UJK,changed from kj<kn to kj<kn2.*/      \n      for (kj=0,sq=sp ; kj<kn2 ; kj++,sq+=kincre) *sq = tsum;\n      \n    }\n  \n  /* Make representation of coefficients from Marsdens identity for the\n   * function f(t) = t, with the knot vector in second parameter direction\n   * scaled to [0,tfak].  This will be used as the x-coordinate in the 3-D\n   * representation */\n  \n  kkm2 = kk2 - 1;\n  tstart = st2[kk2-1];\n  tlength = st2[kn2] - tstart;\n  tfak = tmax/tlength;\n  for (ki=0,sp=s3coef+1 ; ki< kn2 ; ki++)\n    {\n      tsum = (double)0.0;\n      kstop = ki+kk2;\n      for (kj=ki+1;kj<kstop;kj++)\n        tsum +=st2[kj];\n      \n      tsum  = (tsum/kkm2-tstart)*tfak;\n      \n      /*  Copy to remaining y-coordinates in first vertex row */\n      \n      for (kj=0 ; kj<kn1 ; kj++,sp+=3) *sp = tsum;\n      \n    }\n  \n  /* Copy z-coordinates */\n  \n  for (kj=0,sp=s3coef+2,sq=scoef ; kj < kn2 ; kj++)\n    for (ki=0 ; ki<kn1 ; ki++,sp+=3,sq++)\n      *sp = *sq;\n  \n  /* Make 3-D surface */\n  \n  if((qs = newSurf(kn1,kn2,kk1,kk2,st1,st2,s3coef,1,3,1)) == SISL_NULL) goto err101;\n  \n  kgraph = 0;\n  kcur   = 3;\n\n  /* Make an intersection curve object with the parameter value */\n  \n  if ((spar=newarray(2,DOUBLE))==SISL_NULL) goto err101;\n  memcopy(spar,epar,2,DOUBLE);\n  \n  if((qintcr = newIntcurve(1,2,0,spar,SISL_NULL,0)) == SISL_NULL) goto err101;\n  \n  kcur = 2;\n  kgraph = 0;\n  tepsge = tmax*(double)0.01;\n  s1313(qs,simpli,kdeg,tepsco,tepsge,tmax,qintcr,kcur,kgraph,&kstat);\n  if (kstat==-185) goto war00;\n  if (kstat<0) goto error;\n  \n  /* Identify first and last parameter pair in the intersection curve */\n  \n  qcrv = qintcr -> ppar1;\n  if (qcrv == SISL_NULL) goto war00;\n  \n  spar1 = qcrv -> ecoef;\n  spar2 = spar1 + 2*(qcrv->in)-2;\n  /* Check if any of the points lie on the boundary */\n  \n  kmark1 = 0;\n  tdum1 = (double)2.0*max(fabs(sval1[0]),fabs(sval1[1]));\n  tdum2 = (double)2.0*max(fabs(sval2[0]),fabs(sval2[1]));\n\n  if (DEQUAL(spar1[0]+tdum1,sval1[0]+tdum1) || DEQUAL(spar1[0]+tdum1,sval1[1]+tdum1) ||\n      DEQUAL(spar1[1]+tdum2,sval2[0]+tdum2) || DEQUAL(spar1[1]+tdum2,sval2[1]+tdum2) )\n    kmark1 = 1;\n  \n  kmark2 = 0;\n\n  if (DEQUAL(spar2[0]+tdum1,sval1[0]+tdum1) || DEQUAL(spar2[0]+tdum1,sval1[1]+tdum1) ||\n      DEQUAL(spar2[1]+tdum2,sval2[0]+tdum2) || DEQUAL(spar2[1]+tdum2,sval2[1]+tdum2) )\n    kmark2 = 1;\n  \n  /* Check if closed */\n  \n  kclose = 0;\n  if (spar1[0] == spar2[0] && spar1[1] == spar2[1]) kclose = 1;\n  \n  /* Check if first points matches start point */\n  \n  kmatch1 = 0;\n  if (DEQUAL(epar[0]+tdum1,spar1[0]+tdum1) && DEQUAL(epar[1]+tdum2,spar1[1]+tdum2) ) \n    kmatch1 = 1;\n  \n  /* Check if second points matches start point */\n  \n  kmatch2 = 0;\n  if (DEQUAL(epar[0]+tdum1,spar2[0]+tdum1) && DEQUAL(epar[1]+tdum2,spar2[1]+tdum2) ) \n    kmatch2 = 1;\n  \n  /* Check if any point matches start point */\n  \n  if (kmatch1 == 1 || kmatch2 == 1)\n    {\n      /*  Start point matches one of the end points, status values in\n\t  the range 11-19*/\n      \n      if (kmark1 == 1 && kmark2 == 1 && kclose == 0)\n        {\n\t  /* Open curve, status 11 */\n\t  *jstat = 11;\n\t  if(kmatch1==1)\n            goto copy;\n\t  else\n            goto invcopy;\n        }\n      else if (kmark1 ==1 || (kmark2 == 1 && kclose == 0))\n\t{\n\t  /* Open curve one point inside status 12 or 13 */\n\t  \n\t  if (kmark1 == 1 && kmatch1 == 1)\n\t    {\n\t      *jstat = 12;\n\t      goto copy;\n\t    }\n\t  else if (kmark2 == 1 && kmatch2 == 1)\n\t    {\n\t      *jstat = 12;\n\t      goto invcopy;\n\t    }\n\t  if (kmark1 == 1 && kmatch2 == 1)\n\t    {\n\t      *jstat = 13;\n\t      goto invcopy;\n\t    }\n\t  if (kmark2 == 1 && kmatch1 == 1)\n\t    {\n\t      *jstat = 13;\n\t      goto copy;\n\t    }\n        }\n      else if (kclose == 0)\n\t{\n\t  /* Both ends inside */\n\t  *jstat = 14;\n\t  if(kmatch1==1)\n            goto copy;\n\t  else\n            goto invcopy;\n\t}\n      else if(kmatch1 == 1)\n\t{\n\t  /* Closed curve, no singularity */\n\t  *jstat = 16;\n\t  memcopy(gpar1,spar1,2,DOUBLE);\n\t  memcopy(gpar2,spar1,2,DOUBLE);\n\t  goto out;\n\t}\n      else\n\t{\n\t  /* Closed curve, with singularity */\n\t  *jstat=17;\n\t  memcopy(gpar1,epar ,2,DOUBLE);\n\t  memcopy(gpar2,spar1,2,DOUBLE);\n\t  goto out;\n\t}\n    }\n  else\n    {\n      /* epar does not match produced end points, status messages in\n\t 21-29 the range  */\n      \n      if (kmark1 ==1 && kmark2 ==1 && kclose == 0)\n        {\n\t  /* Open curve, status 11 */\n\t  *jstat = 21;\n\t  memcopy(gpar1,spar1,2,DOUBLE);\n\t  memcopy(gpar2,spar2,2,DOUBLE);\n\t  goto out;\n        }\n      else if (kmark1 ==1 && kclose == 0)\n\t{\n\t  /* Open curve one point inside status 12 */\n\t  *jstat=22;\n\t  goto copy;\n\t}\n      else if (kmark2 ==1 && kclose == 0)\n\t{\n\t  /* Open curve one point inside status 12 */\n\t  *jstat=22;\n\t  goto invcopy;\n\t}\n      else if (kclose == 0)\n\t{\n\t  /* Both ends inside */\n\t  *jstat=24;\n\t  goto copy;\n\t}\n      else if(kmatch1 == 1)\n\t{\n\t  /* Closed curve, no singularity */\n\t  *jstat=26;\n\t  memcopy(gpar1,spar1,2,DOUBLE);\n\t  memcopy(gpar2,spar1,2,DOUBLE);\n\t}\n      else\n\t{\n\t  /* Closed curve, with singularity */\n\t  *jstat = 27;\n\t  memcopy(gpar1,epar ,2,DOUBLE);\n\t  memcopy(gpar2,spar1,2,DOUBLE);\n\t  goto out;\n\t}\n    }\n  /* Marching produced no curve */\n  \n war00: *jstat = 0;\n  memcopy(gpar1,epar,2,DOUBLE);\n  memcopy(gpar2,epar,2,DOUBLE);\n  goto out;\n  \n copy:\n  memcopy(gpar1,spar1,2,DOUBLE);\n  memcopy(gpar2,spar2,2,DOUBLE);\n  goto out;\n  \n invcopy:\n  memcopy(gpar1,spar2,2,DOUBLE);\n  memcopy(gpar2,spar1,2,DOUBLE);\n  goto out;\n  \n  /* Error in space allocation */\n err101: \n  *jstat = -101;\n  s6err(\"s1787\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level function */\n error:\n  *jstat = kstat;\n  s6err(\"s1787\",*jstat,kpos);\n  goto out;\n  \n out:\n  if (s3coef != SISL_NULL) freearray(s3coef);\n  if (qs     != SISL_NULL) freeSurf (qs);\n  if (qintcr != SISL_NULL) freeIntcurve(qintcr);\n}\n"
  },
  {
    "path": "src/s1788.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1788.c,v 1.3 2005-02-28 09:04:49 afr Exp $\n *\n */\n\n\n#define S1788\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1788(SISLSurf *ps1,SISLSurf *ps2,double aepsge,double epar[],\n\t   double gpar1[],double gpar2[],int *jstat)\n#else\nvoid s1788(ps1,ps2,aepsge,epar,gpar1,gpar2,jstat)\n     SISLSurf   *ps1;\n     SISLSurf   *ps2;\n     double aepsge;\n     double epar[];\n     double gpar1[];\n     double gpar2[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : In surface-surface intersection in dimention three.\n*              To search for endpoints on an intersection curve.\n*              The intersection curve must go through the parameter \n*              values epar. If the function find a closed curve\n*              it will return a status message 2. \n*              Else if epar is an edges point the function\n*              will return parameter values for the other end point\n*              on the intersection curve in gpar1 and a status message\n*              1. If epar is an intrnal point the function will\n*              return the parameter values for the two endpoints on\n*              the intersection curve in gpar1 and gpar2 and a status\n*              message 0.\n*\n*\n* INPUT      : ps1      - The first surface in intersection.\n*              ps2      - The second surface in intersection.\n*              aepsge   - Geometry resolution.\n*              epar[4]  - Parameter values for the  intersection point.\n*\n*\n*\n* OUTPUT     : gpar1[4] - Parameter values for the first intersection point.\n*                         One of the ends are within computer tolerance from\n*                         epar, then this point is put in this variable and\n*                         the status 1 is returned.\n*              gpar2[4] - Parameter values for the second intersection point\n*                         on the edges. If closed curve found with no singular\n*                         point this point is equal to the first point.\n*              jstat   - status messages    \n*                   < 0   : Error.\n*                   = 0   : The marching did not succeed.\n*                   = 11  : epar == gpar1. Open curve.\n*                   = 12  : epar == gpar1. Open curve. gpar2 inside.\n*                   = 13  : epar == gpar1. Open curve. gpar1 inside.\n*                   = 14  : epar == gpar1. Open curve. Both ends inside.\n*                   = 16  : epar == gpar1. Closed curve. gpar2 == gpar1\n*                   = 17  : epar == gpar1. Closed curve. gpar2 singular. \n*                   = 21  : epar != output points. Open curve.\n*                   = 22  : epar != output points. Open curve. gpar2 inside.\n*                   = 24  : epar != output points. Open curve.\n*                                                  Output points inside.\n*                   = 26  : epar != output points. Closed curve. gpar2 == gpar1\n*                   = 27  : epar != output points. Closed curve.\n*                                                  gpar2 singular. \n*\n*\n\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. July 1989\n* REVISED BY : UJK, November 1990 : Changed call to newIntcurve        \n*********************************************************************\n*/\n{\n  int kpos=0;           /* Position of error                           */\n  int kk1,kk2,kn1,kn2;  /* Orders and numbers of vertices              */\n  int kstat;            /* Status variable                             */\n  int kmark1,kmark2,kclose,kmatch1,kmatch2; /* Flags                   */\n  int kcur,kgraph;      /* Indicators telling to control type of output\n\t\t\t   from marching                               */\n  double sval1[2];      /* Limits of parameter plane in first SISLdir      */\n  double sval2[2];      /* Limits of parameter plane in second SISLdir     */\n  double sval3[2];      /* Limits of parameter plane in third SISLdir      */\n  double sval4[2];      /* Limits of parameter plane in fourth SISLdir     */\n  double *st1,*st2;     /* Knots and vertices of input surface         */\n  double tmax;          /* Box size                                    */\n  double tepsge;   \n  double *spar11,*spar12;/* Pointers to arrays                         */\n  double *spar21,*spar22;/* Pointers to arrays                         */\n\n  /* UJK, Nov 1990 */\n  /*  double *spar=SISL_NULL; */\n  double *spar1=SISL_NULL;     /* Pointer to allocated values for parameter values*/\n  double *spar2=SISL_NULL;     /* Pointer to allocated values for parameter values*/\n\n  SISLCurve *qcrv;           /* Curve in parameter plane                    */\n  SISLIntcurve *qintcr=SISL_NULL; /* Intersection curve object            */\n  \n  /* Find limits of parameter plane */\n  \n  kk1   = ps1 -> ik1;\n  kk2   = ps1 -> ik2;\n  kn1   = ps1 -> in1;\n  kn2   = ps1 -> in2;\n  st1   = ps1 -> et1;\n  st2   = ps1 -> et2;\n  sval1[0] = st1[kk1-1];\n  sval1[1] = st1[kn1];\n  sval2[0] = st2[kk2-1];\n  sval2[1] = st2[kn2];\n  \n  kk1   = ps2 -> ik1;\n  kk2   = ps2 -> ik2;\n  kn1   = ps2 -> in1;\n  kn2   = ps2 -> in2;\n  st1   = ps2 -> et1;\n  st2   = ps2 -> et2;\n  sval3[0] = st1[kk1-1];\n  sval3[1] = st1[kn1];\n  sval4[0] = st2[kk2-1];\n  sval4[1] = st2[kn2];\n  \n  \n  /* Make maximal step length based on box-size of surface */\n  \n  sh1992su(ps1,0,aepsge,&kstat);\n  if (kstat < 0) goto error;\n  \n  tmax = MAX(ps1->pbox->e2max[0][0] - ps1->pbox->e2min[0][0],\n\t     ps1->pbox->e2max[0][1] - ps1->pbox->e2min[0][1]);\n  tmax = MAX(tmax,ps1->pbox->e2max[0][2] - ps1->pbox->e2min[0][2]);\n  \n  sh1992su(ps2,0,aepsge,&kstat);\n  if (kstat < 0) goto error;\n  \n  tmax = MAX(tmax,ps2->pbox->e2max[0][0] - ps2->pbox->e2min[0][0]);\n  tmax = MAX(tmax,ps2->pbox->e2max[0][1] - ps2->pbox->e2min[0][1]);\n  tmax = MAX(tmax,ps2->pbox->e2max[0][2] - ps2->pbox->e2min[0][2]);\n  \n  tepsge = tmax * (double)0.01;\n  \n\n  kgraph = 0;\n  kcur   = 3;\n  \n  /* Make an intersection curve object with the parameter value */\n  /* UJK, Nov 1990 */  \n  /*  if ((spar=newarray(4,DOUBLE))==SISL_NULL) goto err101;\n      memcopy(spar,epar,4,DOUBLE); */\n  if ((spar1=newarray(2,DOUBLE))==SISL_NULL) goto err101;\n  memcopy(spar1,epar,2,DOUBLE);\n  if ((spar2=newarray(2,DOUBLE))==SISL_NULL) goto err101;\n  memcopy(spar2,epar+2,2,DOUBLE);\n  \n  /* UJK, Nov 1990 */  \n  /* if((qintcr = newIntcurve(1,2,2,epar,epar+2,0)) == SISL_NULL) goto err101; */\n  if((qintcr = newIntcurve(1,2,2,spar1,spar2,0)) == SISL_NULL) goto err101;\n  \n  kcur = 2;\n  kgraph = 0;\n  tmax = (double)0.0;\n\n  \n  s1310(ps1,ps2,qintcr,tepsge,tmax,kcur,kgraph,&kstat);\n  \n  if (kstat==-185) goto war00;\n  if (kstat<0) goto error;\n  \n  /* Identify first and last parameter pair in the intersection curve */\n  \n  qcrv = qintcr -> ppar1;\n  if (qcrv == SISL_NULL) goto war00;\n  \n  spar11 = qcrv -> ecoef;\n  spar21 = spar11 + 2*(qcrv->in)-2;\n  \n  \n  qcrv = qintcr -> ppar2;\n  if (qcrv == SISL_NULL) goto war00;\n  \n  spar12 = qcrv -> ecoef;\n  spar22 = spar12 + 2*(qcrv->in)-2;\n  \n  /* Check if any of the points lie on the boundary */\n  \n  kmark1 = 0;\n  if (spar11[0] == sval1[0] || spar11[0] == sval1[1] ||\n      spar11[1] == sval2[0] || spar11[1] == sval2[1] ||\n      spar12[0] == sval3[0] || spar12[0] == sval3[1] ||\n      spar12[1] == sval4[0] || spar12[1] == sval4[1] ) kmark1 = 1;\n  \n  kmark2 = 0;\n  if (spar21[0] == sval1[0] || spar21[0] == sval1[1] ||\n      spar21[1] == sval2[0] || spar21[1] == sval2[1] ||\n      spar22[0] == sval3[0] || spar22[0] == sval3[1] ||\n      spar22[1] == sval4[0] || spar22[1] == sval4[1] ) kmark2 = 1;\n  \n  \n  /* Check if closed */\n  \n  kclose = 0;\n  if (spar11[0] == spar21[0] && spar11[1] == spar21[1]  &&\n      spar12[0] == spar22[0] && spar12[1] == spar22[1]     ) kclose = 1;\n  \n  /* Check if first points matches start point */\n  \n  kmatch1 = 0;\n  if (DEQUAL(epar[0],spar11[0]) && DEQUAL(epar[1],spar11[1]) &&\n      DEQUAL(epar[2],spar12[0]) && DEQUAL(epar[3],spar12[1])   ) kmatch1 = 1;\n  \n  /* Check if second points matches start point */\n  \n  kmatch2 = 0;\n  if (DEQUAL(epar[0],spar21[0]) && DEQUAL(epar[1],spar21[1]) &&\n      DEQUAL(epar[2],spar22[0]) && DEQUAL(epar[3],spar22[1]) ) kmatch2 = 1;\n  \n  \n  /* Check if any point matches start point */\n  \n  if (kmatch1 == 1 || kmatch2 == 1)\n    {\n      /* Start point matches one of the end points, status values in\n\t the range 11-19*/\n      \n      if (kmark1 == 1 && kmark2 == 1 && kclose == 0)\n        {\n\t  /* Open curve, status 11 */\n\t  *jstat = 11;\n\t  if(kmatch1==1)\n            goto copy;\n\t  else\n            goto invcopy;\n        }\n      else if (kmark1 ==1 || (kmark2 == 1 && kclose == 0))\n\t{\n\t  /* Open curve one point inside status 12 or 13 */\n\t  \n\t  if (kmark1 == 1 && kmatch1 == 1)\n\t    {\n\t      *jstat = 12;\n\t      goto copy;\n\t    }\n\t  else if (kmark2 == 1 && kmatch2 == 1)\n\t    {\n\t      *jstat = 12;\n\t      goto invcopy;\n\t    }\n\t  if (kmark1 == 1 && kmatch2 == 1)\n\t    {\n\t      *jstat = 13;\n\t      goto invcopy;\n\t    }\n\t  if (kmark2 == 1 && kmatch1 == 1)\n\t    {\n\t      *jstat = 13;\n\t      goto copy;\n\t    }\n        }\n      else if (kclose == 0)\n\t{\n\t  /* Both ends inside */\n\t  *jstat = 14;\n\t  if(kmatch1==1)\n            goto copy;\n\t  else\n            goto invcopy;\n\t}\n      else if(kmatch1 == 1)\n\t{\n\t  /* Closed curve, no singularity */\n\t  *jstat = 16;\n\t  memcopy(gpar1,  spar11,2,DOUBLE);\n\t  memcopy(gpar1+2,spar12,2,DOUBLE);\n\t  memcopy(gpar2,  gpar1, 4,DOUBLE);\n\t  goto out;\n\t}\n      else\n\t{\n\t  /* Closed curve, with singularity */\n\t  *jstat=17;\n\t  memcopy(gpar1,  epar,  4,DOUBLE);\n\t  memcopy(gpar2,  spar11,2,DOUBLE);\n\t  memcopy(gpar2+2,spar12,2,DOUBLE);\n\t  goto out;\n\t}\n    }\n  else\n    {\n      /* epar does not match produced end points, status messages in\n\t 21-29 the range  */\n      \n      if (kmark1 ==1 && kmark2 ==1 && kclose == 0)\n        {\n\t  /* Open curve, status 11 */\n\t  *jstat = 21;\n\t  goto copy;\n        }\n      else if (kmark1 ==1 && kclose == 0)\n\t{\n\t  /* Open curve one point inside status 12 */\n\t  *jstat=22;\n\t  goto copy;\n\t}\n      else if (kmark2 ==1 && kclose == 0)\n\t{\n\t  /* Open curve one point inside status 12 */\n\t  *jstat=22;\n\t  goto invcopy;\n\t}\n      else if (kclose == 0)\n\t{\n\t  /* Both ends inside */\n\t  *jstat=24;\n\t  goto copy;\n\t}\n      else if(kmatch1 == 1)\n\t{\n\t  /* Closed curve, no singularity */\n\t  *jstat=26;\n\t  memcopy(gpar1,  spar11,2,DOUBLE);\n\t  memcopy(gpar1+2,spar12,2,DOUBLE);\n\t  memcopy(gpar2,  gpar1, 4,DOUBLE);\n\t}\n      else\n\t{\n\t  /* Closed curve, with singularity */\n\t  *jstat = 27;\n\t  memcopy(gpar1,  epar,  4,DOUBLE);\n\t  memcopy(gpar2  ,spar11,2,DOUBLE);\n\t  memcopy(gpar2+2,spar12,2,DOUBLE);\n\t  goto out;\n\t}\n    }\n\n  /* Marching produced no curve */\n\n war00: \n  *jstat = 0;\n  memcopy(gpar1,epar,4,DOUBLE);\n  memcopy(gpar2,epar,4,DOUBLE);\n  goto out;\n\n copy:\n  memcopy(gpar1,  spar11,2,DOUBLE);\n  memcopy(gpar1+2,spar12,2,DOUBLE);\n  memcopy(gpar2,  spar21,2,DOUBLE);\n  memcopy(gpar2+2,spar22,2,DOUBLE);\n  goto out;\n\n invcopy:\n  memcopy(gpar1,  spar21,2,DOUBLE);\n  memcopy(gpar1+2,spar22,2,DOUBLE);\n  memcopy(gpar2,  spar11,2,DOUBLE);\n  memcopy(gpar2+2,spar12,2,DOUBLE);\n  goto out;\n\n  /* Error in space allocation */\n err101: \n  *jstat = -101;\n  s6err(\"s1788\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level function */\n error:\n  *jstat = kstat;\n  s6err(\"s1788\",*jstat,kpos);\n  goto out;\n\n out:\n  if (qintcr != SISL_NULL) freeIntcurve(qintcr);\n}\n"
  },
  {
    "path": "src/s1789.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1789\n\n#include \"sislP.h\"\n\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void s1789_s9eval(double [], double [], double [],double [], int, int *);\nstatic int  s1789_s9knot(double [], int, int, double, double, int *, int *);\n#else\nstatic void s1789_s9eval();\nstatic int  s1789_s9knot();\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      s1789(SISLPoint *ppoint,SISLSurf *psurf,double aepsge,\n\t   double epar1[],double epar2[],int *jstat)\n#else\n   void s1789(ppoint,psurf,aepsge,epar1,epar2,jstat)\n      SISLPoint  *ppoint;\n      SISLSurf   *psurf;\n      double     aepsge;\n      double     epar1[];\n      double     epar2[];\n      int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Test if a point and a surface coincide beetween\n*              two intersection points.\n*              This function is used when the partial derivatives\n*              of the surface are matching for both\n*              intersection points.\n*\n*\n* INPUT      : ppoint   - Pointer to the point.\n*              psurf    - Pointer to the surface.\n*              aepsge   - Geometry resolution.\n*              epar1[3] - Parameter values for the first intersection point.\n*              epar2[3] - Parameter values for the second intersection point.\n*\n*\n*\n* OUTPUT     :  jstat   - status messages\n*                                = 1   : Coincidence.\n*                                = 0   : No coincidence.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF Oslo, Norway. 10.94\n* REVISED BY : Vibeke Skytt, 03.98.  Use test also in 3D case.\n*\n*********************************************************************\n*/\n{\n   int kstat;          /* Status variable                                 */\n   int ki;             /* Counter.                                        */\n   int kleft1=0;       /* Left indicator for point calculation in 1. par.\n\t\t\t  direction of surface.                           */\n   int kleft2=0;       /* Left indicator for point calculation in 2. par dir.*/\n   int kknot1, kknot2; /* Indicates whether there is a knot between the\n\t\t\t  input points in 1. and 2. parameter direction.  */\n   int kmy1, kmy2;     /* Index of an eventual knot.                      */\n   int kk1,kk2,kn1,kn2;/* Orders and nu,ber of vertices of surface        */\n   int kdims;          /* Dimension of space where the surface lies       */\n   int kpos=0;         /* Position of error                               */\n   int kders=2;        /* Number of derivatives to be calculated on surface\n\t\t\t  If step lenght is to be generated from surface,\n\t\t\t  kders must be equal to 2.                       */\n   int kpar;           /* Parameter value of constant parameter curve.    */\n   double snorm[3];    /* Normal vector of surface                        */\n   double *st1;        /* First knot direction of surface                 */\n   double *st2;        /* Second knot direction of surface                */\n   double sders[18];   /* Position, first and second derivatives of surface */\n   double tstep;       /* Final step length     */\n   double tlengthend;  /* Length of 1st derivative at end of segment */\n   double tincre;      /* Parameter value increment */\n   double tsmax;       /* Local maximal step length based of boxsizes of objects */\n   double tdist;       /* Distance */\n   double tref;        /* Referance value in equality test.               */\n   double sstart[2];   /* Lower boundary of parameter intervals */\n   double send[2];     /* Upper bounadry of parameter intervals */\n   double spos[2];     /* New iteration  point on surface                 */\n   double spos1[2];    /* New iteration  point on surface                 */\n   double spos2[2];    /* New iteration  point on surface                 */\n   double sint[2];     /* Interval between test points in par. space.     */\n   double snext[2];    /* Save previous intersection point.               */\n   double sdiff[2];    /* Difference vector between input int. pts.       */\n   double spardir[2];  /* Direction of coincidence curve in parameter area. */\n   double tbeta;       /* Scaling factor between partial derivatives of sf. */\n   double stanc[2];    /* Direction of coincidence curve in surface.        */\n   double sder2[10];   /* Information about curve in surface.               */\n   double tdot;        /* Scalar product to test direction of vectors.      */\n   double td;          /* Distance between current and last point.          */\n   double s3dinf2[10]; /* Marching information to decide step length.       */\n   SISLCurve *qc = SISL_NULL;   /* Constant parameter curve.                       */\n\n   *jstat = 0;\n\n   /* Make maximal step length based on box-size of surface */\n\n   sh1992su(psurf,0,aepsge,&kstat);\n   if (kstat < 0) goto error;\n\n   tsmax = MAX(psurf->pbox->e2max[0][0] - psurf->pbox->e2min[0][0],\n\t       psurf->pbox->e2max[0][1] - psurf->pbox->e2min[0][1]);\n\n   /* Copy surface attributes to local parameters.  */\n\n   kdims = psurf -> idim;\n   kk1   = psurf -> ik1;\n   kk2   = psurf -> ik2;\n   kn1   = psurf -> in1;\n   kn2   = psurf -> in2;\n   st1   = psurf -> et1;\n   st2   = psurf -> et2;\n\n   /* Set reference value.  */\n\n   tref = MAX(st1[kn1]-st1[kk1-1],st2[kn2]-st2[kk2-1]);\n\n   /* Check dimension  */\n\n   if (ppoint->idim != kdims || (kdims != 2 && kdims != 3))\n     goto err105;\n\n   sstart[0] = st1[kk1-1];\n   sstart[1] = st2[kk2-1];\n   send[0] = st1[kn1];\n   send[1] = st2[kn2];\n\n   /* Set start point for marching on surface */\n\n   spos1[0] = epar1[0];\n   spos1[1] = epar1[1];\n\n   /* Set difference vector between input points. */\n\n   s6diff(epar2, epar1, 2, sdiff);\n\n   /* Evaluate start point of surface.  */\n\n   s1421(psurf,kders,spos1,&kleft1,&kleft2,sders,snorm,&kstat);\n   if (kstat < 0) goto error;\n\n   /* While end not reached */\n\n   td = s6dist(spos1, epar2, 2);\n   while (td > REL_PAR_RES)\n   {\n      /* Compute direction of marching. The partial derivatives of the\n\t surface in this point must be almost parallel. Find the factor\n\t that makes the partial derivatives sum up to zero (approximately). */\n\n     if (kdims == 2)\n       {\n\t if (DEQUAL(sders[kdims]+tref,tref) && \n\t     DEQUAL(sders[kdims+1]+tref,tref) &&\n\t     DEQUAL(sders[kdims+2]+tref,tref)) break;\n\n\t if (sders[2] >= sders[3])\n\t   {\n\t     if (DEQUAL(sders[4]+tref,sders[2]+tref))\n\t       tbeta = (double)0.5;\n\t     else\n\t       tbeta = (double)1/((double)1 - (sders[4]/sders[2]));\n\t   }\n\t else\n\t   {\n\t     if (DEQUAL(sders[5]+tref,sders[3]+tref))\n\t       tbeta = (double)0.5;\n\t     else\n\t       tbeta = (double)1/((double)1 - (sders[5]/sders[3]));\n\t   } \n\n\n\t spardir[0] = (double)1-tbeta;\n\t spardir[1] = tbeta;\n       }\n     else\n       {\n\t spardir[0] = epar2[0]-epar1[0];\n\t spardir[1] = epar2[1]-epar1[1];\n       }\n\n      tdot = s6norm(spardir, 2, spardir,&kstat);\n      if (tdot < REL_PAR_RES)\n      {\n\t *jstat = 0;\n\t goto out;\n      }\n\n      for (ki=0; ki<kdims; ki++)\n\t stanc[ki] = spardir[0]*sders[kdims+ki] + spardir[1]*sders[2*kdims+ki];\n\n      tdot = s6scpr(stanc, sdiff, kdims);\n      if (tdot < DZERO)\n      {\n\t stanc[0] *= -(double)1;\n\t stanc[1] *= -(double)1;\n      }\n\n      /* Compute position, first and second derivative of the curve in the\n\t surface going through the evaluated point in this point. */\n\n      s1789_s9eval(sders,snorm,stanc,sder2,kdims,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Calculate unit tangent and radius of curvature of curve in surface.*/\n\n      s1307(sder2,kdims,s3dinf2,&kstat);\n      if (kstat<0) goto error;\n\n      /* Calculate step length based on curvature */\n\n      tstep = s1311(s3dinf2[3*kdims],aepsge,tsmax,&kstat);\n      if (kstat<0) goto error;\n\n      tlengthend = s6length(sder2+kdims,kdims,&kstat);\n      if (kstat<0) goto error;\n\n      /* Find candidate end point, make sure that no breaks in tangent or\n\t curvature exists between start and endpoints of the segment      */\n\n      /* Make step length equal to resolution if the length is zero */\n\n      /* Find parameter value of candidate end point of segment */\n\n      if (DEQUAL(tlengthend+tref,tref))\n\t tincre = REL_PAR_RES;\n      else\n\t tincre = tstep/tlengthend;\n\n      spos2[0] = spos1[0] + tincre*spardir[0];\n      spos2[1] = spos1[1] + tincre*spardir[1];\n\n     /* Make sure not to jump out of the surface */\n     if ((epar2[0] > epar1[0] && spos2[0] >= epar2[0]) ||\n\t (epar2[0] < epar1[0] && spos2[0] <= epar2[0]) ||\n\t (epar2[1] > epar1[1] && spos2[1] >= epar2[1]) ||\n\t (epar2[1] < epar1[1] && spos2[1] <= epar2[1]))\n       {\n\t spos2[0] = epar2[0];\n\t spos2[1] = epar2[1];\n       }\n\n      if (s6dist(spos1, spos2, kdims) > s6dist(spos1, epar2, kdims))\n\t memcopy(spos2, epar2, 2, DOUBLE);\n\n      /* Check if any knot line exist within the step. */\n\n      kknot1 = s1789_s9knot(st1, kk1, kn1, spos1[0], spos2[0], &kmy1, &kstat);\n      if (kstat < 0) goto error;\n\n      kknot2 = s1789_s9knot(st2, kk2, kn2, spos1[1], spos2[1], &kmy2, &kstat);\n      if (kstat < 0) goto error;\n\n      if ((kknot1 && !kknot2) ||\n\t  (kknot1 && kknot2 && spardir[1]*(st1[kmy1]-spos1[0]) <\n\t   spardir[0]*(st2[kmy2]-spos1[1])))\n      {\n\t /* Pull back to knotline in first parameter direction. */\n\n\t spos2[0] = psurf->et1[kmy1];   /* Parameter value of knotline. */\n\t spos2[1] = spos1[1] + (spos2[0]-spos1[0])*spardir[1]/spardir[0];\n\t kpar = 1;\n      }\n      else if (kknot2)\n      {\n\t /* Pull back to knot line in second parameter direction. */\n\n\t spos2[1] = psurf->et2[kmy2];\n\t spos2[0] = spos1[0] + (spos2[1] - spos1[1])*spardir[0]/spardir[1];\n\t kpar = 2;\n      }\n      else\n      {\n\t /* No knot line. Decide in which parameter direction to iterate. */\n\n\t if (spardir[1]*fabs(st1[kmy1]-spos1[0]) <\n\t     spardir[0]*fabs(st2[kmy2]-spos1[1]))\n\t    kpar = 1;\n\t else\n\t    kpar = 2;\n      }\n\n      sint[0] = (spos2[0]-spos1[0])/(double)3;\n      sint[1] = (spos2[1]-spos1[1])/(double)3;\n\n      for (ki=0, spos[0]=spos1[0]+sint[0], spos[1]=spos1[1]+sint[1];\n       ki<3; ki++, spos[0]+=sint[0], spos[1]+=sint[1])\n      {\n\n\t if (kpar == 1)\n\t {\n\t    /* Pick constant parameter curve in 1. par. dir. */\n\n\t    s1437(psurf, spos[0], &qc, &kstat);\n\t    if (kstat < 0) goto error;\n\n\t    /* Iterate down to the curve. */\n\n\t    s1771(ppoint, qc, aepsge, qc->et[qc->ik-1], qc->et[qc->in],\n\t\t  spos[1], &spos[1], &kstat);\n\t    if (kstat < 0) goto error;\n\t }\n\t else\n\t {\n\t    /* Pick constant parameter curve in 2. par. dir. */\n\n\t    s1436(psurf, spos[1], &qc, &kstat);\n\t    if (kstat < 0) goto error;\n\n\t    /* Iterate down to the curve. */\n\n\t    s1771(ppoint, qc, aepsge, qc->et[qc->ik-1], qc->et[qc->in],\n\t\t  spos[0], &spos[0], &kstat);\n\t    if (kstat < 0) goto error;\n\t }\n\n\t memcopy(snext, spos, 2, DOUBLE);\n\n\t /* Calculate point and derivatives in surface */\n\n\t s1421(psurf,kders,spos,&kleft1,&kleft2,sders,snorm,&kstat);\n\t if (kstat<0) goto error;\n\n\t /* Check if the input point and surface point are within positional\n\t    tolerance. */\n\n\t tdist = s6dist(ppoint->ecoef,sders,kdims);\n\n\t if (tdist>aepsge)\n\t {\n\t    /* Points not within tolerances, no coincide. */\n\n\t    goto war01;\n\t }\n\n\t /* Test whether the marching has advanced. */\n\n\t if (s6dist(spos1, spos, 2) < REL_PAR_RES) goto war01;\n\n         /* Free memory occupied by local curve. */\n\n        if (qc != SISL_NULL) freeCurve(qc);\n        qc = SISL_NULL;\n      }\n\n      /* Update start parameter of step. */\n\n      spos1[kpar-1] = spos2[kpar-1];\n      spos1[2-kpar] = snext[2-kpar];\n      td = s6dist(spos1, epar2, 2);\n   }\n\n   if (td > REL_PAR_RES) *jstat = 0;\n   else *jstat = 1;\n\n   goto out;\n\n   /* Point and surface not within tolerance */\n   war01: *jstat = 0;\n   goto out;\n\n   /* Error in input, dimension not equal to 2 or 3 */\n\n   err105: *jstat = -105;\n   s6err(\"s1789\",*jstat,kpos);\n   goto out;\n\n   /* Error in lower level function */\n\n   error:  *jstat = kstat;\n   s6err(\"s1789\",*jstat,kpos);\n   goto out;\n\n\n   out:\n      if (qc != SISL_NULL) freeCurve(qc);\n\n      return;\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\n   static void\n            s1789_s9eval(double eders[],double enorms[],double etanc[],\n\t\t\t double ederc[],int idim, int *jstat)\n#else\n\t       static void s1789_s9eval(eders,enorms,etanc,ederc,idim,jstat)\n\t\t  double eders[];\n\t\t  double enorms[];\n\t\t  double etanc[];\n\t\t  double ederc[];\n\t\t  int idim;\n\t\t  int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Compute the position, first and second derivative of\n*              a curve going through a given point of the surface when\n*              the 0-2'th derivatives of the surface is given. The\n*              tangent of the wanted curve is parallel to the projection\n*              of a given vector into the tangent plane of the surface.\n*\n*\n* INPUT      : eders    - 0-2'th derivatives of the surface. Dimension\n*                         is 6*idim.\n*              enorms   - Normal vector of the surface. Dimension is idim.\n*              etanc    - Vector to be projected into the tangent plane\n*                         of the surface. Dimension is idim.\n*              idim     - Dimension of geometry space.\n*\n*\n*\n* OUTPUT     : ederc   - 0-2'th derivative of the curve in the surface.\n*              jstat   - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SI, Oslo, Norway. Oct. 1990\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;         /* Status variable.  */\n   int ki;                /* Counter.          */\n   int ksign = 1;         /* Parameter used in s6findfac.     */\n   double tfac1,tfac2,tfac3;  /* Factors found by s6findfac.  */\n\n   /* Copy position of surface to output array.   */\n\n   memcopy(ederc,eders,idim,DOUBLE);\n\n   /* Compute the factors used to express etanc by the derivatives and normal\n      of the surface.  */\n\n   s6findfac(eders+idim,eders+2*idim,enorms,etanc,idim,ksign,&tfac1,&tfac2,\n\t     &tfac3,&kstat);\n   if (kstat < 0) goto error;\n\n   /* Compute first and second derivative of the curve in the surface.  */\n\n   for (ki=0; ki<idim; ki++)\n   {\n      ederc[idim+ki] = tfac1*eders[idim+ki] + tfac2*eders[2*idim+ki];\n      ederc[2*idim+ki] = tfac1*tfac1*eders[3*idim+ki]\n\t + (double)2.0*tfac1*tfac2*eders[4*idim+ki] + tfac2*tfac2*eders[5*idim+ki];\n   }\n\n   *jstat = 0;\n   goto out;\n\n   /* Error in lower level routine.  */\n\n   error:\n      *jstat = kstat;\n   goto out;\n\n   out:\n      return;\n}\n\n\n\n#if defined(SISLNEEDPROTOTYPES)\n   static int\n    s1789_s9knot(double et[], int ik, int in, double ax1, double ax2,\n\t\t int *jmy, int *jstat)\n#else\n    static int s1789_s9knot(et, ik, in, ax1, ax2, jmy, jstat)\n       double et[];\n       int    ik;\n       int    in;\n       double ax1;\n       double ax2;\n       int    *jmy;\n       int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Check if there is any knots between two parameter values\n*              on a given knot vector. In that case, return the knot index.\n*\n*\n* INPUT      : et       - Knot vector.\n*              ik       - Order of spline space.\n*              in       - Number of coefficients in spline space.\n*              ax1      - First parameter value.\n*              ax2      - Second parameter value.\n*\n*\n*\n* OUTPUT     : s9knot  - 1 if such a knot exist, 0 otherwise.\n*              jmy     - Index of knot. If s9knot == 0, not reliable.\n*              jstat   - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SI, Oslo, Norway. Nov. 1994\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;         /* Status variable.  */\n   int kleft1 = 0;\n   int kleft2 = 0;\n   int kknot;\n   double tref = et[in] - et[ik-1];\n\n   /* Initialize input. */\n\n   *jmy = 0;\n\n   /* Find position of the input parameter values in the given knot vector. */\n\n   s1219(et, ik, in, &kleft1, ax1, &kstat);\n   if (kstat < 0) goto error;\n\n   s1219(et, ik, in, &kleft2, ax2, &kstat);\n   if (kstat < 0) goto error;\n\n   if (kleft1 != kleft2)\n   {\n      /* Not the same knot interval. */\n\n      if (ax1 < ax2) (*jmy) = kleft1 + 1;\n      else\n      {\n\t (*jmy) = kleft1 - 1;\n\t while (DEQUAL(et[*jmy], et[kleft1])) (*jmy)--;\n      }\n   }\n\n   if (kleft1 == kleft2 ||\n       DEQUAL(et[*jmy]+tref, ax2+tref) ||\n       (DEQUAL(et[kleft1]+tref, ax1+tref) && kleft2 == (*jmy) &&\n\tDEQUAL(et[kleft2]+tref, ax2+tref)))\n      kknot = 0;     /* No knot found between the parameter values. */\n   else kknot = 1;   /* Knot with index (*jmy) found.               */\n\n   *jstat = 0;\n   goto out;\n\n   /* Error in lower level routine. */\n\n   error : *jstat = kstat;\n   goto out;\n\n   out:\n      return kknot;\n}\n"
  },
  {
    "path": "src/s1790.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1790.c,v 1.2 2001-03-19 15:58:54 afr Exp $\n *\n */\n\n\n#define S1790\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1790(SISLObject *po1,SISLObject *po2,double aepsge,int *jstat)\n#else\nvoid s1790(po1,po2,aepsge,jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Perform a box-test on the two object given by\n*              po1 and po2 and check if the boxes overlap.\n*\n*\n*\n* INPUT      : po1    - First object.\n*              po2    - Second object.\n*\t       aepsge - Geometry resolution.\n*                                                                     \n*\n* OUTPUT     : jstat  - status messages  \n*\t\t\t     = 4      : One SISLbox is collapsed into a point.\n*\t\t\t     = 3      : Both boxes inside geometry resolution.\n*                            = 2      : Overlap as closed sets only.\n*                            = 1      : Overlap as open sets.\n*                            = 0      : No overlap.\n*                            < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-03.\n*              Arne Laksaa, SI, 89-07.\n*\n*********************************************************************\n*/                                     \n{\n  int kstat = 0;        /* Local status error.                        */\n  int kpos = 0;         /* Position of error.                         */\n  int kant;             /* Number of vertices in all boxes.           */\n  int kbez = 0;         /* Flag to mark bezier curve or patch.         */\n  int kdim;\t      /* Dimension of space.\t\t\t    */\n  int ki,kj=0;          /* Counters.                                  */\n  double t1,t2,t3,t4;   /* Help variables.                            */\n  double *tmin1,*tmax1; /* Smallest and larges value of the vertices of\n\t\t\t   first object in each SISLbox in all dimension. */\n  double *tmin2,*tmax2; /* Smallest and larges value of the vertices of\n\t\t\t   second object in each SISLbox in all dimension.*/\n  \n  /* Check kind of first object. */\n  \n  if (po1->iobj == SISLPOINT)\n    {\n      /* Fetch dimention of the object. */\n      \n      kdim = po1->p1->idim;\n      \n      \n      /* Check if the SISLbox have been computed. */\n      \n      if (po1->p1->pbox == SISL_NULL)\n\t{\n\t  /* If not compute a box. */\n\t  \n\t  s1992(po1,&kstat);\n\t  if (kstat<0) goto error;\n\t}\n      \n      /* Fetch the SISLbox boarder. */\n      \n      tmax1 = po1->p1->pbox->emax;\n      tmin1 = po1->p1->pbox->emin;\n    }\n  else\n    if (po1->iobj == SISLCURVE)\n      {\n\t/* Fetch dimention of the object. */\n\t\n\tkdim = po1->c1->idim;\n\t\n\t/* Check if we have a bezier curve. */\n\t\n\tif (po1->c1->in == po1->c1->ik) kbez = 1;\n\t\n\t/* Check if the SISLbox have been computed. */\n\t\n\tif (po1->c1->pbox == SISL_NULL)\n\t  {\n\t    /* If not compute a box. */\n\t    \n\t    s1992(po1,&kstat);\n\t    if (kstat<0) goto error;\n\t  }\n\t\n\t/* Fetch the SISLbox boarder. */\n\t\n\ttmax1 = po1->c1->pbox->emax;\n\ttmin1 = po1->c1->pbox->emin;\n      }\n    else\n      if (po1->iobj == SISLSURFACE)\n\t{\n\t  /* Fetch dimention of the object. */\n\t  \n\t  kdim = po1->s1->idim;\n\t  \n\t  /* Check if we have a bezier patch. */\n\t  \n\t  if (po1->s1->in1 == po1->s1->ik1 &&\n\t      po1->s1->in2 == po1->s1->ik2)    kbez = 1;\n\t  \n\t  /* Check if the SISLbox have been computed. */\n\t  \n\t  if (po1->s1->pbox == SISL_NULL)\n\t    {\n\t      /* If not compute a box. */\n\t      \n\t      s1992(po1,&kstat);\n\t      if (kstat<0) goto error;\n\t    }\n\t  \n\t  /* Fetch the SISLbox boarder. */\n\t  \n\t  tmax1 = po1->s1->pbox->emax;\n\t  tmin1 = po1->s1->pbox->emin;\n\t}\n      else  goto err121;\n  \n  \n  /* Check kind of second object. */\n  \n  if (po2->iobj == SISLPOINT)\n    {\n      /* Fetch dimention of the object. */\n      \n      ki = po2->p1->idim;\n      \n      \n      /* Check if the SISLbox have been computed. */\n      \n      if (po2->p1->pbox == SISL_NULL)\n\t{\n\t  /* If not compute a box. */\n\t  \n\t  s1992(po2,&kstat);\n\t  if (kstat<0) goto error;\n\t}\n      \n      /* Fetch the SISLbox boarder. */\n      \n      tmax2 = po2->p1->pbox->emax;\n      tmin2 = po2->p1->pbox->emin;\n    }\n  else\n    if (po2->iobj == SISLCURVE)\n      {\n\t/* Fetch dimention of the object. */\n\t\n\tki = po2->c1->idim;\n\t\n\t/* Check if we have a bezier curve. */\n\t\n\tif (po2->c1->in == po2->c1->ik) kbez = 1;\n\t\n\t/* Check if the SISLbox have been computed. */\n\t\n\tif (po2->c1->pbox == SISL_NULL)\n\t  {\n\t    /* If not compute a box. */\n\t    \n\t    s1992(po2,&kstat);\n\t    if (kstat<0) goto error;\n\t  }\n\t\n\t/* Fetch the SISLbox boarder. */\n\t\n\ttmax2 = po2->c1->pbox->emax;\n\ttmin2 = po2->c1->pbox->emin;\n      }\n    else\n      if (po2->iobj == SISLSURFACE)\n\t{\n\t  /* Fetch dimention of the object. */\n\t  \n\t  ki = po2->s1->idim;\n\t  \n\t  /* Check if we have a bezier patch. */\n\t  \n\t  if (po2->s1->in1 == po2->s1->ik1 &&\n\t      po2->s1->in2 == po2->s1->ik2)    kbez = 1;\n\t  \n\t  /* Check if the SISLbox have been computed. */\n\t  \n\t  if (po2->s1->pbox == SISL_NULL)\n\t    {\n\t      /* If not compute a box. */\n\t      \n\t      s1992(po2,&kstat);\n\t      if (kstat<0) goto error;\n\t    }\n\t  \n\t  /* Fetch the SISLbox boarder. */\n\t  \n\t  tmax2 = po2->s1->pbox->emax;\n\t  tmin2 = po2->s1->pbox->emin;\n\t}\n      else goto err121;\n  \n  /* Check dimension. */\n  \n  if (ki != kdim ) goto err106;\n  else\n    if (kdim < 1 )   goto err105;\n  \n  \n  /* Compute total number of SISLbox edges. */\n  \n  if (kdim == 3) kant = 12;\n  else\n    if (kdim == 2) kant = 4;\n    else           kant = kdim;\n  \n  \n  /* For each dimension in all boxes perform box-test.  */\t\n  \n  for (ki=0; ki<kant; ki++,tmin1++,tmax1++,tmin2++,tmax2++)\n    {\n      /* Sorting: t1-t2 The SISLbox with largest max value.\n\t t3-t4 The other box. */\n      \n      if (*tmax1 > *tmax2)\n\t{\n\t  t1 = *tmax1;\n\t  t2 = *tmin1;\n\t  t3 = *tmax2;\n\t  t4 = *tmin2;\n\t}\n      else\n\t{\n\t  t1 = *tmax2;\n\t  t2 = *tmin2;\n\t  t3 = *tmax1;\n\t  t4 = *tmin1;\n\t}\n      \n      /* SISLPoint intersection in 3D must have a tolerance on the box. */\n      if ((po1->iobj == SISLPOINT || po2->iobj == SISLPOINT) && kdim != 1)\n\t{\n\t  t1 += 0.1 *  aepsge;\n\t  t2 -= 0.1 *  aepsge;\n\t}\n      \n      if (t1 - min(t2,t4) <= aepsge)\n\tkj++;                 /* Minibox is possible. */\n      else if (t3 < t2)\n\t{\n\t  *jstat = 0;           /* No overlap. */\n\t  goto out;\n\t}\n      else if (kdim != 1 && t3 - t2 <= aepsge && t3 - t4 > aepsge &&\n\t       t1 - t2 > aepsge && kbez)\n\t{\n\t  *jstat = 2;           /* Only edge touching possible.*/\n\t  goto degenerate;\n\t}\n      else if ( kdim == 1 && (t1 - t4 <= aepsge || t3 - t2 <= aepsge) &&\n\t       kbez)\n\t{\n\t  *jstat = 2;           /* Only edge touching possible.*/\n\t  goto out;\n\t}\n      /* else possible overlap. */\n    }\n  \n  if (kj == kant)\n    *jstat = 3;                   /* Minibox found. */\n  else\n    *jstat = 1;                   /* Overlap.  */\n  \n  \n  /* Box-test performed. */\n  \n degenerate:\n  /* Test if one of the objects has collapsed. */\n  if (kdim != 1 && po1->iobj > SISLPOINT)\n    {\n      if (po1->iobj == SISLCURVE)\n\t{\n\t  tmin1 = po1->c1->pbox->emin;\n\t  tmax1 = po1->c1->pbox->emax;\n\t}\n      \n      else if (po1->iobj == SISLSURFACE)\n\t{\n\t  tmin1 = po1->s1->pbox->emin;\n\t  tmax1 = po1->s1->pbox->emax;\n\t}\n      \n      for(ki=0;ki<kdim;ki++,tmin1++,tmax1++)\n\tif (DNEQUAL(*tmin1,*tmax1)) break;\n      \n      if (ki == kdim)\n\t{\n\t  *jstat = 4;\n\t  goto out;\n\t}\n    }\n  \n  if (kdim != 1 && po2->iobj > SISLPOINT)\n    {\n      if (po2->iobj == SISLCURVE)\n\t{\n\t  tmin1 = po2->c1->pbox->emin;\n\t  tmax1 = po2->c1->pbox->emax;\n\t}\n      \n      else if (po2->iobj == SISLSURFACE)\n\t{\n\t  tmin1 = po2->s1->pbox->emin;\n\t  tmax1 = po2->s1->pbox->emax;\n\t}\n      \n      for(ki=0;ki<kdim;ki++,tmin1++,tmax1++)\n\tif (DNEQUAL(*tmin1,*tmax1)) break;\n      \n      if (ki == kdim)\n\t{\n\t  *jstat = 4;\n\t  goto out;\n\t}\n    }\n  goto out;\n  \n  /* Dimensions conflicting. */\n  \n err106: *jstat = -106;\n  s6err(\"s1790\",*jstat,kpos);\n  goto out;\n  \n  /* Dimensions less than one. */\n  \n err105: *jstat = -105;\n  s6err(\"s1790\",*jstat,kpos);\n  goto out;\n  \n  /* Kind of object does not exist. */\n  \n err121: *jstat = -121;\n  s6err(\"s1790\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine. */\n  \n error:  *jstat = kstat;\n  s6err(\"s1790\",*jstat,kpos);\n  goto out;\n  \n out:\treturn;\n}\n\n\n\n\n\n"
  },
  {
    "path": "src/s1791.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1791.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1791\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nint \ns1791(double et[],int ik,int in)\n#else\nint s1791(et,ik,in)\n     double et[];\n     int    ik;\n     int    in;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Test if it is possible to insert new internal nots\n*              any further.\n*\n*\n*\n* INPUT      : et     - The knot vector.\n*              ik     - The order of the curve/surface.\n*              in     - The number of the basic functions.\n*\n*\n*\n* OUTPUT     : s1791  - Result of the test.\n*                       = 0 : It is not possible to insert new knots\n*                             any further.\n*                       = 1 : It is possible to insert new knots.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-04.\n*\n*********************************************************************\n*/                                     \n{\n  register double tstart= et[ik - 1];\n  register double tend  = et[in];\n  register double tmid  = (tstart+tend)*(double)0.5;\n  \n  /* Check if it is possible to divide the parameter interval.  */\n  \n  if (DEQUAL(tmid,tstart) || DEQUAL(tmid,tend)) \n    return  0;\n  else \n    return  1;\n}\n\n\n\n\n\n"
  },
  {
    "path": "src/s1792.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1792.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1792\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\ndouble \ns1792(double et[],int ik,int in)\n#else\ndouble s1792(et,ik,in)\n     double et[];\n     int    ik;\n     int    in;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Finding a good subdividing parametric value.\n*\n*\n*\n* INPUT      : et[]     - The knot vector.\n*              ik       - The order of the spline function.\n*              in       - The number of basic spline function.\n*\n*\n*\n* OUTPUT     : s1792    - The subdivision value.\n*\n*\n* METHOD     : This function is written to match s1791().\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-04.\n*\n*********************************************************************\n*/                                     \n{\n  if (in > ik)\n    {\n      int kpar = (in + ik)/2;\n      \n      if (DNEQUAL(et[ik-1],et[kpar]) || DNEQUAL(et[in],et[kpar]))\n        return  et[kpar];\n    }\n  \n  return (et[ik-1]+et[in])*(double)0.5;\n}\n"
  },
  {
    "path": "src/s1795.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1795.c,v 1.2 2001-03-19 15:58:54 afr Exp $\n *\n */\n\n\n#define S1795\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1795(SISLSurf *ps1,SISLSurf *ps2,double aepsge,double aang,int *jstat)\n#else\nvoid s1795(ps1,ps2,aepsge,aang,jstat)\n     SISLSurf   *ps1;\n     SISLSurf   *ps2;\n     double aepsge;\n     double aang;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To make the orientation surface on the unit sphere to\n*\t       a b-spline surface, the surface is representated with\n*\t       a surrounding cone piced from the unit sphere.\n*\n*\n*\n* INPUT      : ps1,ps2  - The B-spline surfaces.\n*              aang     - The angel beetween the center axes\n*                         in the direction cones.\n*              aepsge -   Geometry resolution.\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                                         = 1      : Simpel case\n*                                         = 0      : No simpel case\n*                                         < 0      : error\n*\n*\n* METHOD     : We are making a cone surrounding the orientating surface\n*\t       on the unit sphere. The cone is representated with senter\n*\t       coordinates and an angle. The orientation is computed\n*\t       from aproximation of the normal to the surface.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-01.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;     /* Position of the error.                             */\n  int kstat;        /* Local status variable.                             */\n  int ki;           /* Counter.                                           */\n  int kn1;          /* Number of vertices of surface in 1. par. direction.*/\n  int kn2;          /* Number of vertices of surface in 2. par. direction.*/\n  int kdim;\t   /* Dimension of the space in which the objects lie.   */\n  int kdim4;\t   /* Help variable to contain  4*kdim.\t\t\t */\n  int kver,khor;    /* The index to the vertice in the upper left corner \n\t\t       to the patch to treat.\t\t\t\t */\n  int k1,k2,k3,k4;  /* Control variables in loop. \t\t\t */\n  double *t=SISL_NULL;     /* Allocating t[5][kdim]. Five tangents around the\n\t\t\t patch, the first and the last is the same.         */\n  double *tn;         /* Allocating tn[4][kdim]. Four normals in the corner\n\t\t         of the patch.\t\t\t\t\t */\n  double *scen1;     /* The orginal basis vector to the projection plan. */\n  double *scen2;     /* The computed basis vector to the projection plan.*/\n  double tlen;       /* The length of a vector.\t\t\t\t */\n  double tang;\t     /* An angle between two vectors.\t\t\t */\n  double tang1=DZERO;/* An angle between two vectors.\t\t\t */\n  double tang2=DZERO;/* An angle between two vectors.\t\t\t */\n  double t1,t2;      /* Help variables.\t\t\t\t\t */\n  double slen[5];   /* Distances between coefficients.                    */\n  double scorn[4];  /* Angle between derivatives in corner of patch.      */\n  \n  \n  /* Initialate dimentions. */\n  \n  kdim = ps1 -> idim;\n  kdim4 = 4*kdim;\n  \n  \n  /* Allocate local used matrices, t[5][kdim] and tn[4][kdim]. */\n  \n  if ((t = newarray(10*kdim,double)) == SISL_NULL) goto err101;\n  \n  tn   = t + 5*kdim;\n  \n  \n  if (aang > PIHALF)\n    aang = PI - aang;\n  \n  scen1 = ps1->pdir->ecoef;\n  scen2 = tn + 4*kdim;\n  tlen = s6scpr(scen1,ps2->pdir->ecoef,kdim);\n  for (k1=0; k1 < kdim; k1++)\n    scen2[k1] = ps2->pdir->ecoef[k1] - tlen*scen1[k1];\n  tlen = s6length(scen2,kdim,&kstat);\n  for (k1=0; k1 < kdim; k1++)\n    scen2[k1] /= tlen;\n  \n  kn1  = ps1 -> in1;\n  kn2  = ps1 -> in2;\n  \n  /* Here we are treating each patch in the control polygon separately.*/\n  \n  for (kver=0; kver < (kn2-1); kver++)\n    for (khor=0; khor < (kn1-1); khor++)\n      {\n\tslen[0] = slen[1] = slen[2] = slen[3] = DZERO;\n\tscorn[0] = scorn[1] = scorn[2] = scorn[3] = DZERO;\n\t\n\t/* Here we make the tangents in each corner of the patch,\n           and in direction with the clock. The first and the last\n\t   vector contains both the first tangent. */\n\t\n\tk2 = (kver*kn1+khor)*kdim;\n\t\n\tfor (k1=0; k1 < kdim; k1++,k2++)\n\t  {\n\t    t[kdim+k1]   = ps1->pdir->esmooth[k2+kdim] - ps1->pdir->esmooth[k2];\n\t    t[2*kdim+k1] = ps1->pdir->esmooth[k2+(kn1+1)*kdim]-ps1->pdir->esmooth[k2+kdim];\n\t    t[3*kdim+k1] = ps1->pdir->esmooth[k2+kn1*kdim]-ps1->pdir->esmooth[k2+(kn1+1)*kdim];\n\t    t[kdim4+k1] = t[k1] = ps1->pdir->esmooth[k2]-ps1->pdir->esmooth[k2+kn1*kdim];\n\t    \n\t    slen[0] += t[k1]*t[k1];\n\t    slen[1] += t[k1+kdim]*t[k1+kdim];\n\t    slen[2] += t[k1+2*kdim]*t[k1+2*kdim];\n\t    slen[3] += t[k1+3*kdim]*t[k1+3*kdim];\n\t  }\n\tslen[4] = slen[0] = sqrt(slen[0]);\n\tslen[1] = sqrt(slen[1]);\n\tslen[2] = sqrt(slen[2]);\n\tslen[3] = sqrt(slen[3]);\n\t\n\tscorn[0] = s6ang(t,t+kdim,kdim);\n\tscorn[1] = s6ang(t+kdim,t+2*kdim,kdim);\n\tscorn[2] = s6ang(t+2*kdim,t+3*kdim,kdim);\n\tscorn[3] = s6ang(t+3*kdim,t,kdim);\n\n\t\n\t/* Here we makes the normales in each corner of the patch.\n\t   We are using a cross product between two tangents.\n\t   The normals is also normalized by deviding with its\n\t   own length. */\n\t\n\t\n\tfor (k1=0, ki=0; k1<kdim4; k1+=kdim, ki++)\n\t  {\n\t    \n\t    for (tlen=DZERO,k2=0,k3=1,k4=2; k2 < kdim; k2++,k3++,k4++)\n\t      {\n\t\t\n\t\tif(k3 == kdim) k3 = 0;\n\t\tif(k4 == kdim) k4 = 0;\n\t\ttn[k1+k2] = t[k1+k3]*t[k1+kdim+k4]-t[k1+k4]*t[k1+kdim+k3];\n\t\t\n\t\ttlen += tn[k1+k2]*tn[k1+k2];\n\t      }\n\t    \n\t    tlen = sqrt(tlen);\n\t    if (slen[ki]>aepsge && slen[ki+1]>aepsge &&\n\t\tscorn[ki] > ANGULAR_TOLERANCE)\n\t      for (k2=0; k2 < kdim; k2++) tn[k1+k2] /= tlen;\n\t    else \n\t      for (k2=0; k2 < kdim; k2++) tn[k1+k2] = scen1[k2];\n\t    \n\t  }\n\t\n\tfor (k1=0; k1<kdim4; k1+=kdim)\n\t  {\n\t    t2 = scen2[0]*tn[k1];\n\t    for (k2=1,k3=k1+1;k2<kdim;k2++,k3++)\n\t      t2 += scen2[k2]*tn[k3];\n\t    \n\t    if (t2 <= DZERO) continue;\n\t    \n\t    t1 = scen1[0]*tn[k1];\n\t    for (k2=1,k3=k1+1;k2<kdim;k2++,k3++)\n\t      t1 += scen1[k2]*tn[k3];\n\t    \n\t    tang = t1/sqrt(t1*t1 + t2*t2);\n\t    \n\t    if (tang >= DZERO) tang = min((double)1,tang);\n\t    else               tang = max((double)-1,tang);\n\t    \n\t    tang = acos(tang);\n\t    \n\t    tang1 = max(tang1,tang);\n\t  }\n      }\t\t\t\n  \n  scen1 = ps2 ->pdir-> ecoef;\n  tlen = s6scpr(scen1,ps1->pdir->ecoef,kdim);\n  for (k1=0; k1 < kdim; k1++)\n    scen2[k1] = ps1->pdir->ecoef[k1] - tlen*scen1[k1];\n  tlen = s6length(scen2,kdim,&kstat);\n  for (k1=0; k1 < kdim; k1++)\n    scen2[k1] /= tlen;\n  \n  kn1  = ps2 -> in1;\n  kn2  = ps2 -> in2;\n  \n  /* Here we are treating each patch in the control polygon separately.*/\n  \n  for (kver=0; kver < (kn2-1); kver++)\n    for (khor=0; khor < (kn1-1); khor++)\n      {\n\tslen[0] = slen[1] = slen[2] = slen[3] = DZERO;\n\tscorn[0] = scorn[1] = scorn[2] = scorn[3] = DZERO;\n\t\n\t/* Here we make the tangents in each corner of the patch,\n           and in direction with the clock. The first and the last\n\t   vector contains both the first tangent. */\n\t\n\tk2 = (kver*kn1+khor)*kdim;\n\t\n\tfor (k1=0; k1 < kdim; k1++,k2++)\n\t  {\n\t    t[kdim+k1]   = ps2->pdir->esmooth[k2+kdim] - ps2->pdir->esmooth[k2];\n\t    t[2*kdim+k1] = ps2->pdir->esmooth[k2+(kn1+1)*kdim]-ps2->pdir->esmooth[k2+kdim];\n\t    t[3*kdim+k1] = ps2->pdir->esmooth[k2+kn1*kdim]-ps2->pdir->esmooth[k2+(kn1+1)*kdim];\n\t    t[kdim4+k1] = t[k1] = ps2->pdir->esmooth[k2]-ps2->pdir->esmooth[k2+kn1*kdim];\n\t    \n\t    slen[0] += t[k1]*t[k1];\n\t    slen[1] += t[k1+kdim]*t[k1+kdim];\n\t    slen[2] += t[k1+2*kdim]*t[k1+2*kdim];\n\t    slen[3] += t[k1+3*kdim]*t[k1+3*kdim];\n\t  }\n\tslen[4] = slen[0] = sqrt(slen[0]);\n\tslen[1] = sqrt(slen[1]);\n\tslen[2] = sqrt(slen[2]);\n\tslen[3] = sqrt(slen[3]);\n\t\n\tscorn[0] = s6ang(t,t+kdim,kdim);\n\tscorn[1] = s6ang(t+kdim,t+2*kdim,kdim);\n\tscorn[2] = s6ang(t+2*kdim,t+3*kdim,kdim);\n\tscorn[3] = s6ang(t+3*kdim,t,kdim);\n\n\t\n\t/* Here we makes the normales in each corner of the patch.\n\t   We are using a cross product between two tangents.\n\t   The normals is also normalized by deviding with its\n\t   own length. */\n\t\n\t\n\tfor (k1=0, ki=0; k1<kdim4; k1+=kdim, ki++)\n\t  {\n\t    \n\t    for (tlen=DZERO,k2=0,k3=1,k4=2; k2 < kdim; k2++,k3++,k4++)\n\t      {\n\t\t\n\t\tif(k3 == kdim) k3 = 0;\n\t\tif(k4 == kdim) k4 = 0;\n\t\ttn[k1+k2] = t[k1+k3]*t[k1+kdim+k4]-t[k1+k4]*t[k1+kdim+k3];\n\t\t\n\t\ttlen += tn[k1+k2]*tn[k1+k2];\n\t      }\n\t    \n\t    tlen = sqrt(tlen);\n\t    if (slen[ki]>aepsge && slen[ki+1]>aepsge &&\n\t\tscorn[ki] > ANGULAR_TOLERANCE)\n\t      for (k2=0; k2 < kdim; k2++) tn[k1+k2] /= tlen;\n\t    else \n\t      for (k2=0; k2 < kdim; k2++) tn[k1+k2] = scen1[k2];\n\t    \n\t  }\n\t\n\t\n\tfor (k1=0; k1<kdim4; k1+=kdim)\n\t  {\n\t    t2 = scen2[0]*tn[k1];\n\t    for (k2=1,k3=k1+1;k2<kdim;k2++,k3++)\n\t      t2 += scen2[k2]*tn[k3];\n\t    \n\t    if (t2 <= DZERO) continue;\n\t    \n\t    t1 = scen1[0]*tn[k1];\n\t    for (k2=1,k3=k1+1;k2<kdim;k2++,k3++)\n\t      t1 += scen1[k2]*tn[k3];\n\t    \n\t    tang = t1/sqrt(t1*t1+t2*t2);\n\t    \n\t    if (tang >= DZERO) tang = min((double)1,tang);\n\t    else               tang = max((double)-1,tang);\n\t    \n\t    tang = acos(tang);\n\t    \n\t    tang2 = max(tang2,tang);\n\t  }\n      }\t\t\t\n  \n  \n  /* Performing a simple case check. */\n  \n  if (tang1 + tang2 <= aang)\n    *jstat = 1;       /* A simpel case.*/\n  else\n    *jstat = 0;\n  \n  goto out;\n  \n  \n  /* Error in space allacation.  */\n  \n  err101: *jstat = -101;\n  s6err(\"s1795\",*jstat,kpos);\n  goto out;\n  \n  \n  \n  /* Free local used memory. */\n  \n  out:    if (t != SISL_NULL) freearray(t);\n}\n"
  },
  {
    "path": "src/s1796.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1796.c,v 1.3 2001-03-19 15:58:54 afr Exp $\n *\n */\n#define S1796\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1796(SISLCurve *pc1,SISLCurve *pc2,double aepsge,double aang,int *jstat)\n#else\nvoid s1796(pc1,pc2,aepsge,aang,jstat)\n     SISLCurve  *pc1;\n     SISLCurve  *pc2;\n     double aepsge;\n     double aang;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To make an extra simple case test by using the\n*\t       projection of tangents into a plan span by\n*\t       the center axes of the direction cones.\n*\n*\n*\n* INPUT      : pc1,pc2  - The B-spline curves.\n*              aang     - The angel beetween the center axes\n*                         in the direction cones.\n*              aepsge -   Geometry resolution.\n*\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                                         > 1      : Simpel case\n*                                         = 0      : No simpel case\n*                                         < 0      : error\n*\n*\n* METHOD     : We are making a plan span by the center axes af the\n*              cones surrounding the orientating surfaces\n*\t       on the unit sphere. Then we project each tangent\n*\t       to this plan and compute the angel beetween these\n*\t       projection and the senter of the cone. If the new\n*              projected cones do not overlap we have simel case.\n*             \n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-07.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;     /* Local status variable.                           */\n  int kpos = 0;      /* Position of the error.                           */\n  int turned = 0;    /* Use as mark if dir of curve2 is turned.\t\t */\n  int kn;            /* Number of vertices of curve.                     */\n  int kdim;\t     /* Dimension of the space in which the objects lie. */\n  int kin;           /* The index to the vertice to treat.               */\n  int k1,k2;         /* Control variables in loop.                       */\n  double *t=SISL_NULL;    /* Tangent at each coeficient.                      */\n  double tlen;       /* The length of a vector.                          */\n  double *scen1;     /* The orginal basis vector to the projection plan. */\n  double *scen2;     /* The computed basis vector to the projection plan.*/\n  double tang;\t     /* An angle between two vectors.\t\t         */\n  double tang1=DZERO;/* An angle between two vectors.\t\t\t */\n  double tang2=DZERO;/* An angle between two vectors.\t\t\t */\n  double t1,t2;      /* Help variables.\t\t\t\t         */\n  \n  \n  /* Initialate space dimentions. */\n  \n  kdim = pc1 -> idim;\n  \n  \n  /* Allocate local used array. */\n  \n  if ((t = newarray(2*kdim,double)) == SISL_NULL) goto err101;\n  \n  /* We have to turn the direction into the smallest angel. */\n  \n  if (aang > PIHALF)\n  {\n    aang = PI - aang;\n    turned = 1;\n  }\n  \n  /* The first basis vector. */\n  \n  scen1 = pc1->pdir->ecoef;\n  \n  /* We must orthonormalize the second basis vector. */\n  \n  scen2 = t + kdim;\n  tlen = s6scpr(scen1,pc2->pdir->ecoef,kdim);\n  for (k1=0; k1 < kdim; k1++)\n    scen2[k1] = pc2->pdir->ecoef[k1] - tlen*scen1[k1];\n  tlen = s6length(scen2,kdim,&kstat);\n  for (k1=0; k1 < kdim; k1++)\n    scen2[k1] /= tlen;\n  \n  if (turned)  \n     for (k1=0; k1 < kdim; k1++)    scen2[k1] = -scen2[k1];\n  \n  \n  /* Here we are treating each patch in the control polygon separately.*/\n  \n  for (kn=pc1->in,k2=0,kin=0; kin < kn-1; kin++)\n    {\n      \n      /* Here we make an aproximative tangents to the curve\n\t using the control polygon. The tangents are also normalized\n\t by deviding with its own length. */\n      \n      for (tlen=DZERO,k1=0; k1 < kdim; k1++,k2++)\n\t{\n\t  t[k1] = pc1->pdir->esmooth[k2+kdim] - pc1->pdir->esmooth[k2];\n\t  tlen += t[k1]*t[k1];\n\t}\n      \n      tlen = sqrt(tlen);\n      \n      if (tlen > aepsge)\n\tfor (k1=0; k1 < kdim; k1++) t[k1] /= tlen;\n      else\n\tfor (k1=0; k1 < kdim; k1++) t[k1] = scen1[k1];\n      \n      t2 = scen2[0]*t[0];\n      for (k1=1; k1<kdim; k1++)\n\tt2 += scen2[k1]*t[k1];\n      \n      if (t2 <= DZERO) continue;\n      \n      t1 = scen1[0]*t[0];\n      for (k1=1; k1<kdim; k1++)\n\tt1 += scen1[k1]*t[k1];\n      \n      tang = t1/sqrt(t1*t1 + t2*t2);\n      \n      if (tang >= DZERO) tang = min((double)1,tang);\n      else               tang = max((double)-1,tang);\n      \n      tang = acos(tang);\n      \n      tang1 = max(tang1,tang);\n    }\n  \n  /* The first basis vector. */\n  \n  scen1 = pc2->pdir->ecoef;\n  \n  /* We must orthonormalize the second basis vector. */\n  \n  scen2 = t + kdim;\n  tlen = s6scpr(scen1,pc1->pdir->ecoef,kdim);\n  for (k1=0; k1 < kdim; k1++)\n    scen2[k1] = pc1->pdir->ecoef[k1] - tlen*scen1[k1];\n  tlen = s6length(scen2,kdim,&kstat);\n  for (k1=0; k1 < kdim; k1++)\n    scen2[k1] /= tlen;\n  \n  if (turned)  \n     for (k1=0; k1 < kdim; k1++)    scen2[k1] = -scen2[k1];\n  \n  /* Here we are treating each patch in the control polygon separately.*/\n  \n  for (kn =pc2->in,k2=0,kin=0; kin < kn-1; kin++)\n    {\n      \n      /* Here we make an aproximative tangents to the curve\n\t using the control polygon. The tangents are also normalized\n\t by deviding with its own length. */\n      \n      for (tlen=DZERO,k1=0; k1 < kdim; k1++,k2++)\n\t{\n\t  t[k1] = pc2->pdir->esmooth[k2+kdim] - pc2->pdir->esmooth[k2];\n\t  tlen += t[k1]*t[k1];\n\t}\n      \n      tlen = sqrt(tlen);\n      \n      if (tlen > aepsge)\n\tfor (k1=0; k1 < kdim; k1++) t[k1] /= tlen;\n      else\n\tfor (k1=0; k1 < kdim; k1++) t[k1] = scen1[k1];\n      \n      \n      t2 = scen2[0]*t[0];\n      for (k1=1; k1<kdim;k1++)\n\tt2 += scen2[k1]*t[k1];\n      \n      if (t2 <= DZERO) continue;\n      \n      t1 = scen1[0]*t[0];\n      for (k1=1; k1<kdim; k1++)\n\tt1 += scen1[k1]*t[k1];\n      \n      tang = t1/sqrt(t1*t1 + t2*t2);\n      \n      if (tang >= DZERO) tang = min((double)1,tang);\n      else               tang = max((double)-1,tang);\n      \n      tang = acos(tang);\n      \n      tang2 = max(tang2,tang);\n    }\n  \n  \n  \n  /* Performing a simple case check. */\n  \n  if (tang1 + tang2 <= aang)\n    *jstat = 1;       /* A simpel case.*/\n  else\n    *jstat = 0;\n  \n  goto out;\n  \n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1796\",*jstat,kpos);\n  goto out;\n    \n  \n  /* Free local used memory. */\n  \n out:    if (t != SISL_NULL) freearray(t);\n  \n}\n"
  },
  {
    "path": "src/s1797.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1797.c,v 1.2 2001-03-19 15:58:54 afr Exp $\n *\n */\n#define S1797\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1797(SISLSurf *ps1,SISLCurve *pc1,double aepsge,double aang,int *jstat)\n#else\nvoid s1797(ps1,pc1,aepsge,aang,jstat)\n     SISLSurf   *ps1;\n     SISLCurve  *pc1;\n     double aepsge;\n     double aang;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To make the orientation surface on the unit sphere to\n*\t       a b-spline surface, the surface is representated with\n*\t       a surrounding cone piced from the unit sphere.\n*\n*\n*\n* INPUT      : ps1      - The B-spline surface.\n*              pc1      - The B-spline curve.\n*              aang     - The angel beetween the center axes\n*                         in the direction cones.\n*              aepsge -   Geometry resolution.\n*\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                                         = 1      : Simpel case\n*                                         = 0      : No simpel case\n*                                         < 0      : error\n*\n*\n* METHOD     : We are making a cone surrounding the orientating surface\n*\t       on the unit sphere. The cone is representated with senter\n*\t       coordinates and an angle. The orientation is computed\n*\t       from aproximation of the normal to the surface.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-01.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;     /* Position of the error.                             */\n  int kstat;        /* Local status variable.                             */\n  int ki;           /* Counter.                                           */\n  int kn;           /* Number of vertices of curve.                       */\n  int kn1;          /* Number of vertices of surface in 1. par. direction.*/\n  int kn2;          /* Number of vertices of surface in 2. par. direction.*/\n  int kdim;\t   /* Dimension of the space in which the objects lie.   */\n  int kdim4;\t   /* Help variable to contain  4*kdim.\t\t\t */\n  int kver,khor;    /* The index to the vertice in the upper left corner \n\t\t       to the patch to treat.\t\t\t\t */\n  int k1,k2,k3,k4;  /* Control variables in loop. \t\t\t */\n  double *t=SISL_NULL;     /* Allocating t[5][kdim]. Five tangents around the\n\t\t\t patch, the first and the last is the same.         */\n  double *tn;         /* Allocating tn[4][kdim]. Four normals in the corner\n\t\t         of the patch.\t\t\t\t\t */\n  double *scen1;     /* The orginal basis vector to the projection plan. */\n  double *scen2;     /* The computed basis vector to the projection plan.*/\n  double tlen;       /* The length of a vector.\t\t\t\t */\n  double tang;\t     /* An angle between two vectors.\t\t\t */\n  double tang1=DZERO;/* An angle between two vectors.\t\t\t */\n  double tang2=DZERO;/* An angle between two vectors.\t\t\t */\n  double t1,t2;/* Help variables.\t\t\t\t\t */\n  double slen[5];   /* Distances between coefficients.                    */\n  double scorn[4];  /* Angle between derivatives in corner of patch.      */\n  \n  \n  \n  /* Initialate dimentions. */\n  \n  kdim = ps1 -> idim;\n  kdim4 = 4*kdim;\n  \n  \n  /* Allocate local used matrices, t[5][kdim] and tn[4][kdim]. */\n  \n  if ((t = newarray(10*kdim,double)) == SISL_NULL) goto err101;\n  \n  tn   = t + 5*kdim;  \n  \n  scen1 = ps1->pdir->ecoef;\n  scen2 = tn + 4*kdim;\n  tlen = s6scpr(scen1,pc1->pdir->ecoef,kdim);\n  for (k1=0; k1 < kdim; k1++)\n    scen2[k1] = pc1->pdir->ecoef[k1] - tlen*scen1[k1];\n  tlen = s6length(scen2,kdim,&kstat);\n  for (k1=0; k1 < kdim; k1++)\n    scen2[k1] /= tlen;\n  \n  kn1  = ps1 -> in1;\n  kn2  = ps1 -> in2;\n  \n  /* Here we are treating each patch in the control polygon separately.*/\n  \n  for (kver=0; kver < (kn2-1); kver++)\n     for (khor=0; khor < (kn1-1); khor++)\n     {\n\tslen[0] = slen[1] = slen[2] = slen[3] = DZERO;\n\tscorn[0] = scorn[1] = scorn[2] = scorn[3] = DZERO;\n\t\n\t/* Here we make the tangents in each corner of the patch,\n           and in direction with the clock. The first and the last\n\t   vector contains both the first tangent. */\n\t\n\tk2 = (kver*kn1+khor)*kdim;\n\t\n\tfor (k1=0; k1 < kdim; k1++,k2++)\n\t{\n\t   t[kdim+k1]   = ps1->pdir->esmooth[k2+kdim] - ps1->pdir->esmooth[k2];\n\t   t[2*kdim+k1] = ps1->pdir->esmooth[k2+(kn1+1)*kdim]-ps1->pdir->esmooth[k2+kdim];\n\t   t[3*kdim+k1] = ps1->pdir->esmooth[k2+kn1*kdim]-ps1->pdir->esmooth[k2+(kn1+1)*kdim];\n\t   t[kdim4+k1] = t[k1] = ps1->pdir->esmooth[k2]-ps1->pdir->esmooth[k2+kn1*kdim];\n\t   \n\t   slen[0] += t[k1]*t[k1];\n\t   slen[1] += t[k1+kdim]*t[k1+kdim];\n\t   slen[2] += t[k1+2*kdim]*t[k1+2*kdim];\n\t   slen[3] += t[k1+3*kdim]*t[k1+3*kdim];\n\t}\n\tslen[4] = slen[0] = sqrt(slen[0]);\n\tslen[1] = sqrt(slen[1]);\n\tslen[2] = sqrt(slen[2]);\n\tslen[3] = sqrt(slen[3]);\n\t\n\tscorn[0] = s6ang(t,t+kdim,kdim);\n\tscorn[1] = s6ang(t+kdim,t+2*kdim,kdim);\n\tscorn[2] = s6ang(t+2*kdim,t+3*kdim,kdim);\n\tscorn[3] = s6ang(t+3*kdim,t,kdim);\n\t\n\t\n\t/* Here we makes the normales in each corner of the patch.\n\t   We are using a cross product between two tangents.\n\t   The normals is also normalized by deviding with its\n\t   own length. */\n\t\n\t\n\tfor (k1=0, ki=0; k1<kdim4; k1+=kdim, ki++)\n\t{\n\t   \n\t   for (tlen=DZERO,k2=0,k3=1,k4=2; k2 < kdim; k2++,k3++,k4++)\n\t   {\n\t      \n\t      if(k3 == kdim) k3 = 0;\n\t      if(k4 == kdim) k4 = 0;\n\t      tn[k1+k2] = t[k1+k3]*t[k1+kdim+k4]-t[k1+k4]*t[k1+kdim+k3];\n\t      \n\t      tlen += tn[k1+k2]*tn[k1+k2];\n\t   }\n\t   \n\t   tlen = sqrt(tlen);\n\t   if (slen[ki]>aepsge && slen[ki+1]>aepsge &&\n\t       scorn[ki] > ANGULAR_TOLERANCE)\n\t      for (k2=0; k2 < kdim; k2++) tn[k1+k2] /= tlen;\n\t   else \n\t      for (k2=0; k2 < kdim; k2++) tn[k1+k2] = scen1[k2];\n\t   \n\t}\n\t\n\tfor (k1=0; k1<kdim4; k1+=kdim)\n\t{\n\t   t2 = scen2[0]*tn[k1];\n\t   for (k2=1,k3=k1+1;k2<kdim;k2++,k3++)\n\t      t2 += scen2[k2]*tn[k3];\n\t   \n\t   if (aang > PIHALF)\n\t   {\n\t      if (t2 <= DZERO) continue;\n\t   }\n\t   else if (t2 >= DZERO) continue;\n\t   \n\t   t1 = scen1[0]*tn[k1];\n\t   for (k2=1,k3=k1+1;k2<kdim;k2++,k3++)\n\t      t1 += scen1[k2]*tn[k3];\n\t   \n\t   tang = t1/sqrt(t1*t1 + t2*t2);\n\t   \n\t   if (tang >= DZERO) tang = min((double)1,tang);\n\t   else               tang = max((double)-1,tang);\n\t   \n\t   tang = acos(tang);\n\t   \n\t   tang1 = max(tang1,tang);\n\t}\n     }\t\t\t\n  \n  \n  /* The first basis vector. */\n  \n  scen1 = pc1 ->pdir-> ecoef;\n  \n  /* We must orthonormalize the second basis vector. */\n  \n  scen2 = t + kdim;\n  tlen = s6scpr(scen1,ps1->pdir->ecoef,kdim);\n  for (k1=0; k1 < kdim; k1++)\n     scen2[k1] = ps1->pdir->ecoef[k1] - tlen*scen1[k1];\n  tlen = s6length(scen2,kdim,&kstat);\n  for (k1=0; k1 < kdim; k1++)\n     scen2[k1] /= tlen;\n  \n  /* Here we are treating each part in the control polygon separately.*/\n  \n  for (kn=pc1->in,k2=0,khor=0; khor < kn-1; khor++)\n  {\n     \n     /* Here we make an aproximative tangents to the curve\n\tusing the control polygon. The tangents is also normalized\n\tby deviding with its own length. */\n     \n     for (tlen=DZERO,k1=0; k1 < kdim; k1++,k2++)\n     {\n\tt[k1] = pc1->pdir->esmooth[k2+kdim] - pc1->pdir->esmooth[k2];\n\ttlen += t[k1]*t[k1];\n     }\n     \n     tlen = sqrt(tlen);\n     \n     if (tlen > aepsge)\n\tfor (k1=0; k1 < kdim; k1++) t[k1] /= tlen;\n     else\n\tfor (k1=0; k1 < kdim; k1++) t[k1] = scen1[k1];\n     \n     t2 = scen2[0]*t[0];\n     for (k1=1; k1<kdim; k1++)\n\tt2 += scen2[k1]*t[k1];\n     \n     if (aang > PIHALF)\n     {\n\tif (t2 <= DZERO) continue;\n     }\n     else if (t2 >= DZERO) continue;\n     \n     t1 = scen1[0]*t[0];\n     for (k1=1; k1<kdim; k1++)\n\tt1 += scen1[k1]*t[k1];\n     \n     tang = t1/sqrt(t1*t1 + t2*t2);\n     \n     if (tang >= DZERO) tang = min((double)1,tang);\n     else               tang = max((double)-1,tang);\n     \n     tang = acos(tang);\n     \n     tang2 = max(tang2,tang);\n  }\n  \n  /* Performing a simple case check. */\n  \n  if (aang > PIHALF)\taang = PI - aang;\n  \n  if (tang1 + tang2 <= PIHALF - aang)\n    *jstat = 1;       /* A simpel case.*/\n  else\n    *jstat = 0;\n  \n  goto out;\n  \n  \n  /* Error in space allacation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1795\",*jstat,kpos);\n  goto out;\n    \n  /* Free local used memory. */\n  \n out:    if (t != SISL_NULL) freearray(t);\n}\n"
  },
  {
    "path": "src/s1830.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1830.c,v 1.2 2001-03-19 15:58:54 afr Exp $\n *\n */\n\n\n#define S1830\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1830(SISLSurf *psurf,SISLCurve *pcurve,int *jstat)\n#else\nvoid s1830(psurf,pcurve,jstat)\n     SISLSurf  *psurf;\n     SISLCurve *pcurve;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Perform improved box-test in curve/surface intersection.\n*              The test is based on the main tangent of the curve and\n*              the main normal of the surface.\n*\n*\n*\n* INPUT      : psurf  - Pointer to surface involved in intersection problem.\n*              pcurve - Pointer to curve involved in intersection problem.\n*\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                              = 2      : Only edge-intersections possible.\n*                              = 1      : Possibility of intersection.\n*                              = 0      : No possibility of intersection.\n*                              < 0      : error\n*\n*\n* METHOD     : Let the main tangent of the curve be the vector from the\n*              first to the last vertex, and let the main normal of the\n*              surface be the cross-product of the main diagonals. Perform\n*              rotated box-tests with respect to this two vectors.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1834  - Perform rotated box-test.\n*              s6diff - Difference vector between two vectors.\n*              s6crss - Cross-product of two vectors.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;         /* Local status variable.           */\n  int kpos = 0;          /* Position of error.               */\n  int kdim;              /* Dimension of space.              */\n  int knc;               /* Number of vertices of curve.     */\n  int kn1,kn2;           /* Number of vertices of surface.   */\n  double *scurve;        /* Vertices of curve.               */\n  double *ssurf;         /* Vertices of surface.             */\n  double *stan = SISL_NULL;   /* Main tangent of curve.           */\n  double *sdiag1 = SISL_NULL; /* First main diagonal of surface.  */\n  double *sdiag2 = SISL_NULL; /* Second main diagonal of surface. */\n  double *snorm = SISL_NULL;  /* Main normal of surface.          */\n  \n  /* Test input.  */\n  \n  kdim = psurf -> idim;\n  if (kdim != 3) goto err104;\n  if (kdim != pcurve -> idim) goto err106;\n  \n  /* Allocate space for local arrays.  */\n  \n  if ((stan = newarray(kdim,double)) == SISL_NULL) goto err101;\n  if ((sdiag1 = newarray(kdim,double)) == SISL_NULL) goto err101;\n  if ((sdiag2 = newarray(kdim,double)) == SISL_NULL) goto err101;\n  if ((snorm = newarray(kdim,double)) == SISL_NULL) goto err101;\n  \n  /* Describe curve with local parameters.  */\n  \n  knc = pcurve->in;\n  scurve = pcurve->ecoef;\n  \n  /* Describe surface with local parameters.  */\n  \n  kn1 = psurf->in1;\n  kn2 = psurf->in2;\n  ssurf = psurf->ecoef;\n  \n  /* Fetch main tangent of curve.  */\n  \n  s6diff(scurve+(knc-1)*kdim,scurve,kdim,stan);\n  \n  /* Fetch main diagonals of surface.  */\n  \n  s6diff(ssurf+(kn1*kn2-1)*kdim,ssurf,kdim,sdiag1);\n  \n  s6diff(ssurf+kn1*(kn2-1)*kdim,ssurf+(kn1-1)*kdim,kdim,sdiag2);\n  \n  /* Compute main normal of surface.  */\n  \n  s6crss(sdiag1,sdiag2,snorm);\n  \n  /* Perform rotated box-test.  */\n  \n  s1834(ssurf,kn1*kn2,scurve,knc,kdim,stan,snorm,&kstat);\n  if (kstat < 0) goto error;\n  \n  if (kstat == 1)\n    {\n      kstat = 0;\n      \n      s1834(ssurf,kn1*kn2,scurve,knc,kdim,snorm,stan,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* Improved box-test performed.  */\n  \n  *jstat = kstat;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1830\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Dimension not equal to 3.  */\n  \n err104: *jstat = -104;\n  s6err(\"s1830\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Dimensions conflicting.  */\n  \n err106: *jstat = -106;\n  s6err(\"s1830\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"s1830\",*jstat,kpos);\n  goto out;\n  \n out:\n  \n  /* Free space occupied by local arrays.  */\n  \n  if (stan != SISL_NULL) freearray(stan);\n  if (sdiag1 != SISL_NULL) freearray(sdiag1);\n  if (sdiag2 != SISL_NULL) freearray(sdiag2);\n  if (snorm != SISL_NULL) freearray(snorm);\n  \n  return;\n}\n"
  },
  {
    "path": "src/s1834.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1834.c,v 1.3 2005-02-28 09:04:49 afr Exp $\n *\n */\n\n\n#define S1834\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1834_s9mat2d(double [],double []);\nstatic void\ns1834_s9mat3d(double [],double [],double []);\n#else\nstatic void s1834_s9mat2d();\nstatic void s1834_s9mat3d();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1834(double ecoef1[],int in1,double ecoef2[],int in2,int idim,\n\t   double edir1[],double edir2[],int *jstat)\n#else\nvoid s1834(ecoef1,in1,ecoef2,in2,idim,edir1,edir2,jstat)\n     double ecoef1[];\n     int    in1;\n     double ecoef2[];\n     int    in2;\n     int    idim;\n     double edir1[];\n     double edir2[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Perform a box-test to check if two objects overlap in \n*              the rotated coordinate system where edir1 defines the \n*              x-axis and (edir1 x edir2) defines the z-axis if\n*              idim = 3.\n*\n*\n*\n* INPUT      : ecoef1 - Coefficients of the first object.\n*              in1    - Number of coefficients in the first object.\n*              ecoef2 - Coefficients of the second object.\n*              in2    - Number of coefficients in the second object.\n*              idim   - The dimension of the space in which the objects\n*                       lie. idim = 2 or idim = 3.\n*              edir1  - First direction vector. Defines x-axis in rotated\n*                       coordinate system.\n*              edir2  - Second direction vector.\n*\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                                 = 2      : Boundaries just touch.\n*                                 = 1      : Rotated SISLbox overlaps point.\n*                                 = 0      : No overlap.\n*                                 < 0      : error\n*\n*\n* METHOD     : The coordinate system is rotated such that if idim = 2,\n*              the x-axis of the new coordinate system is parallell to \n*              the vector edir1. If idim = 3, the cross-product of edir1\n*              and edir2 is rotated to be parallell to the z-axis and\n*              edir1 rotated to be parallell to the x-axis. The objects\n*              are moved into this rotated coordinate system and a \n*              box-test is performed.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6norm - Normalize vector and compute length of original\n*                       vector.\n*              s6scpr - Compute scalar product of two vectors.\n*              s6crss - Make cross product of two 3D vectors. \n*              s1834_s9mat2d - Set up rotation matrix for 2 dimensional space.\n*              s1834_s9mat3d - Set up rotation matrix for 3 dimensional space.\n*                              \n* WRITTEN BY : Vibeke Skytt, SI, 88-06.\n*\n*********************************************************************\n*/\n{                                   \n  int kpos = 0;    /* Position of error.                         */\n  int kopen;       /* Indicates if boxes overlap as open sets.   */\n  int kclose;      /* Indicates if boxes oberlap as closed sets. */\n  double tleng;    /* Scalar product between two vectors.        */\n  double *smat;    /* Rotation matrix.                           */\n  double *smin1,*smax1; /* Extremal values of first rotated box. */\n  double *smin2,*smax2; /* Extremal values of second rotated box. */\n  double *s1,*s2,*s3,*s4;  /* Pointers used to traverse arrays.  */\n  \n  smat = smin1 = smin2 = smax1 = smax2 = SISL_NULL;\n  \n  /* Test input.  */\n  \n  if (idim != 2 && idim != 3) goto err105;\n  \n  /* Allocate space for local parameters.  */\n  \n  smin1 = newarray(idim,double);\n  smin2 = newarray(idim,double);\n  smax1 = newarray(idim,double);\n  smax2 = newarray(idim,double);\n  smat = new0array(idim*idim,double);\n  if (smin1 == SISL_NULL || smin2 == SISL_NULL || smax1 == SISL_NULL ||\n      smax2 == SISL_NULL || smat == SISL_NULL) goto err101;\n  \n  /* Initialize min and max vectors.  */\n  \n  for (s2=smin1+idim; smin1<s2; smin1++,smin2++,smax1++,smax2++)\n    {\n      *smin1 = *smin2 = (double)9999999999.0;\n      *smax1 = *smax2 = (double)-9999999999.0;\n    }\n  smin1 -= idim;\n  smin2 -= idim;\n  smax1 -= idim;\n  smax2 -= idim;\n  \n  /* Find the rotation matrix.  */\n  \n  if (idim == 2)\n    \n    /* After normalization edir1[0] will contain the cosine of the \n       rotation angle and edir1[1] will contain the sine.           */\n    \n    s1834_s9mat2d(smat,edir1);\n  else\n    \n    /* Set up the rotation matrix when idim = 3. (edir1 x edir2) is\n       rotated to be parallell to the z-axis and edir1 to be parallell\n       to the x-axis.                                                   */\n    \n    s1834_s9mat3d(smat,edir1,edir2);\n  \n  /* The objects is moved into the new coordinate system by rotating\n     them using the rotation matrix.                                 */\n  \n  /* Rotate first object and make a SISLbox around the object. */\n  \n  for (s1=smat,s3=smat+idim*idim; s1<s3; s1+=idim,smin1++,smax1++)\n    for (s2=ecoef1,s4=s2+idim*in1; s2<s4; s2+=idim)\n      {\n\ttleng = s6scpr(s1,s2,idim);\n\t*smin1 = MIN(*smin1,tleng);\n\t*smax1 = MAX(*smax1,tleng);\n      }\n  smin1 -= idim;\n  smax1 -= idim;\n  \n  /* Rotate second object and make a SISLbox around the object. */\n  \n  for (s1=smat,s3=smat+idim*idim; s1<s3; s1+=idim,smin2++,smax2++)\n    for (s2=ecoef2,s4=s2+idim*in2; s2<s4; s2+=idim)\n      {\n\ttleng = s6scpr(s1,s2,idim);\n\t*smin2 = MIN(*smin2,tleng);\n\t*smax2 = MAX(*smax2,tleng);\n      }\n  smin2 -= idim;\n  smax2 -= idim;\n  \n  /* Check if the boxes overlap.  */\n  \n  kopen = 0;\n  kclose = 1;\n  for (s2=smin1+idim; smin1<s2; smin1++,smax1++,smin2++,smax2++)\n    {\n      if (DEQUAL(MIN(*smin1,*smin2),MAX(*smax1,*smax2)))\n\tcontinue;\n      \n      if (*smin1 > *smax2 || *smin2 > *smax1)\n\t\n\t/* The objects do not intersect as closed sets.  */\n\t\n\tkclose = 0;\n      else if (DEQUAL(*smin1,*smax2) || DEQUAL(*smin2,*smax1))\n\t\n\t/* The objects do not intersect as open sets.  */\n\t\n\tkopen = 1;\n    }\n  smin1 -= idim;\n  smax1 -= idim;\n  smin2 -= idim;\n  smax2 -= idim;\n  \n  if (kopen == 0 && kclose == 1)\n    \n    /* The objects intersect as open sets.  */\n    \n    *jstat = 1;\n  else if (kopen == 1)\n    \n    /* The objects intersect as closed sets and not as open.  */\n    \n    *jstat = 2;                                            \n  else\n    \n    /* The objects do not intersect.  */\n    \n    *jstat = 0;\n  \n  /* Box-test permformed.  */\n  \n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1834\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Dimension not equal to 2 or 3.  */\n  \n err105: *jstat = -105;\n  s6err(\"s1834\",*jstat,kpos);\n  goto out;\n  \n out:\n  \n  /* Free space occupied by local arrays.  */\n  \n  if (smin1 != SISL_NULL) freearray(smin1);\n  if (smin2 != SISL_NULL) freearray(smin2);\n  if (smax1 != SISL_NULL) freearray(smax1);\n  if (smax2 != SISL_NULL) freearray(smax2);\n  if (smat != SISL_NULL) free0array(smat);\n  \n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1834_s9mat2d(double emat[],double edir[])\n#else\nstatic void s1834_s9mat2d(emat,edir)\n     double emat[];\n     double edir[];\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Set up rotation matrix in two dimensions when the x-axis\n*              is supposed to be rotated to be parallell with edir.\n*\n* INPUT      : edir  - Direction of rotated x-axis.\n*\n* OUTPUT     : emat  - Rotation matrix. emat is supposed to be\n*                      initialized to zero before this routine is entered.\n*\n*********************************************************************\n*/\n{          \n  int kstat = 0;   /* Local status variable.              */\n  double tlength;  /* Length of vector edir.              */\n  double sdir[2];  /* Normalized vertion of vector edir.  */\n  \n  tlength = s6norm(edir,2,sdir,&kstat);\n  if (kstat == 0)\n    \n    /* Length of edir equal to zero. Let the rotation matrix be\n       the identity matrix.                                      */\n    \n    emat[0] = emat[3] = (double)1.0;\n  else\n    {          \n      \n      /* Make rotation matrix.  */\n      \n      emat[0] = sdir[0];\n      emat[1] = -sdir[1];\n      emat[2] = sdir[1];\n      emat[3] = sdir[0];\n    }\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1834_s9mat3d(double emat[],double edir1[],double edir2[])\n#else\nstatic void s1834_s9mat3d(emat,edir1,edir2)\n     double emat[];\n     double edir1[];\n     double edir2[];\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Set up rotation matrix in three dimensions when edir1\n*              is supposed to be rotated to be parallell with the x-axis\n*              and (edir1 x edir2) to be parallell with the z-axis.\n*\n* INPUT      : edir1 - First direction vector.\n*              edir2 - Second direction vector.\n*\n* OUTPUT     : emat  - Rotation matrix. The matrix is supposed to be\n*                      initialized to zero before this routine is enterd.\n*\n*********************************************************************\n*/\n{          \n  int kstat = 0;    /* Local status variable.                         */\n  double snorm[3];  /* Cross-product of edir1 and edir2.              */\n  double sdir[3];   /* Normalized vertion of edir1.                   */\n  double *s1;       /* Pointer into emat array.                       */\n  double tleng1,tleng2; /* Length of snorm and edir1 respectively.    */\n  double ta1,ta2,ta3,tb1,tb2,tb3,td1,td2,tl1,tl2,tl3; /* Help variables. */\n  \n  /* Calculate cross-product of edir1 and edir2.  */\n  \n  s6crss(edir1,edir2,snorm);\n  \n  /* Normalize snorm.  */\n  \n  tleng1 = s6norm(snorm,3,snorm,&kstat);\n  \n  /* Normalize edir1.  */\n  \n  tleng2 = s6norm(edir1,3,sdir,&kstat);\n  \n  /* Initialize help variables.  */\n  \n  ta1 = snorm[0];\n  ta2 = snorm[1];\n  ta3 = snorm[2];\n  tl1 = sqrt(ta2*ta2+ta3*ta3);\n  \n  /* Set up rotation matrix.  */\n  \n  if ((DEQUAL(tleng1,DZERO) || DEQUAL(tl1,DZERO)) && DEQUAL(tleng2,DZERO))\n    \n    /* The rotation matrix is the identity matrix.  */\n    \n    emat[0] = emat[4] = emat[8] = (double)1.0;\n  else if (DEQUAL(tleng1,DZERO) || DEQUAL(tl1,DZERO))\n    {\n      \n      /* The rotation matrix is supposed to rotate edir1 to be parallell\n\t to the x-axis.                                                   */\n      \n      tb1 = sdir[0];\n      tb2 = sdir[1];\n      tb3 = sdir[2];\n      tl3 = sqrt(tb1*tb1+tb2*tb2);\n      \n      if (DEQUAL(tl3,DZERO)) emat[0] = emat[4] = emat[8] = (double)1.0;\n      else\n\t{\n\t  s1      = emat;    \n\t  *(s1++) = tb1;\n\t  *(s1++) = tb2;\n\t  *(s1++) = tb3;\n\t  *(s1++) = -tb2/tl3;\n\t  *(s1++) = tb1/tl3;  \n\t  *(s1++) = DZERO;\n\t  *(s1++) = -tb1*tb3/tl3;\n\t  *(s1++) = -tb2*tb3/tl3;  \n\t  *(s1++) = tl3;\n\t}\n    }\n  else\n    {\n      td1 = edir1[0]/tl1;\n      td2 = (ta3*edir1[1] - ta2*edir1[2])/tl1;\n      tl2 = sqrt(td1*td1+td2*td2);\n      \n      if (DEQUAL(tl2,DZERO))\n\t{\n\t  \n\t  /* The normal snorm is rotated to be parallell to the z-axis. */\n\t  \n\t  s1      = emat;\n\t  *(s1++) = tl1;\n\t  *(s1++) = -ta1*ta2/tl1;\n\t  *(s1++) = -ta1*ta3/tl1;\n\t  *(s1++) = DZERO;\n\t  *(s1++) = ta3/tl1;\n\t  *(s1++) = -ta2/tl1;\n\t  *(s1++) = ta1;\n\t  *(s1++) = ta2;\n\t  *(s1++) = ta3;\n\t}\n      else\n\t{\n\t  \n\t  /* The normal is rotated to be parallell to the z-axis and edir1\n\t     to be parallell to the x-axis.                                 */\n\t  \n\t  s1      = emat;\n\t  *(s1++) = td1*tl1/tl2;\n\t  *(s1++) = (-ta1*ta2*td1 + ta3*td2)/(tl1*tl2);\n\t  *(s1++) = (-ta1*ta3*td1 - ta2*td2)/(tl1*tl2);\n\t  *(s1++) = -td2*tl1/tl2;\n\t  *(s1++) = (ta1*ta2*td2 + ta3*td1)/(tl1*tl2);\n\t  *(s1++) = (ta1*ta3*td2 - ta2*td1)/(tl1*tl2);\n\t  *(s1++) = ta1;\n\t  *(s1++) = ta2;\n\t  *(s1++) = ta3;\n\t}\n    }\n}\n"
  },
  {
    "path": "src/s1839.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1839.c,v 1.2 2001-03-19 15:58:54 afr Exp $\n *\n */\n\n\n#define S1839\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1839(SISLSurf *ps1,double epol[],int in,int idim,int *jstat)\n#else\nvoid s1839(ps1,epol,in,idim,jstat)\n     SISLSurf   *ps1;\n     double epol[];\n     int    in;\n     int    idim;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Perform improved box-test in intersection involving\n*              a surface. Test the surface against a control-polygon.\n*\n*\n*\n* INPUT      : ps1     - Pointer to the surface in the intersection.\n*              epol    - The control-polygon in the test.\n*              in      - Number of vertices in control-polygon.\n*              idim    - The dimension of the space in which the polygon\n*                        lies.\n*\n*\n*\n* OUTPUT     : *jstat  - status messages  \n*                            = 2      : Only edge-intersections possible.\n*                            = 1      : Internal intersections possible.\n*                            = 0      : No intersections possible.\n*                            < 0      : error\n*\n*\n* METHOD     : Pick the diagonal of the surface and the tangents in\n*              the corners of the surface if these might be different \n*              from the diagonals. Rotate coordinate system according\n*              to the vectors picked and perform a box-test.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1834 - Perform rotated box-test.\n*\n* WRITTEN BY : Tor Dokken, SI, OSlo, Norway.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;           /* Local status variable.                        */\n  int kpos = 0;            /* Position of error.                            */\n  int ki;                  /* Counter.                                      */\n  int kn1,kn2;             /* Number of vertices in each parameter\n\t\t\t      direction of surface.                         */\n  int kk1,kk2;             /* Order in each parameter direction of surface. */\n  int kvec;                /* Number of direction vectors to calculate.     */\n  int klap;                /* Indcates whether SISLbox of surface overlap point.*/\n  double *scoef;           /* Vertices of surface.                          */\n  register double *s1,*s2,\n  *s3,*s4;                 /* Pointers used to traverse arrays.             */\n  double *sdir = SISL_NULL;     /* Array containing direction vectors.           */\n  \n  /* Check input.  */\n  \n  if (idim != 2 && idim != 3) goto err105;\n  if (idim != ps1->idim) goto err106;\n  \n  /* Copy surface to local parameters.  */\n  \n  kn1 = ps1 -> in1;\n  kn2 = ps1 -> in2;\n  kk1 = ps1 -> ik1;\n  kk2 = ps1 -> ik2;\n  scoef = ps1 -> ecoef;\n  \n  /* Find number of rotations to make.  */\n  \n  if (kk1 > 2 || kk2 > 2) kvec = 10; else kvec = 2;\n  \n  /* Allocate space for vectors with which the x-axis is to be parallell. */\n  \n  sdir = newarray(kvec*idim,double);\n  if (sdir == SISL_NULL) goto err101;\n  \n  /* Make diagonal from lower left to upper right corner of patch.  \n     s1 points to the array which contains the results, s3 points to the\n     lower left corner and s4 to the upper right corner.                 */\n  \n  for (s1=sdir,s2=s1+idim,s3=scoef,s4=scoef+idim*(kn1*kn2-1); s1<s2;\n       s1++,s3++,s4++)\n    *s1 = *s4 - *s3;\n  \n  /* Make diagonal from upper left to lower right corner of patch. s1\n     points to the array which contains the results, s3 points to the\n     upper left and s4 to the lower right corner.                       */\n  \n  for (s1=sdir+idim,s2=s1+idim,s3=scoef+idim*kn1*(kn2-1),\n       s4=scoef+idim*(kn1-1); s1<s2; s1++,s3++,s4++)\n    *s1 = *s4 - *s3;\n  \n  if (kvec > 2)\n    {\n      \n      /* The surface is not linear in both parameter directions. Make\n\t horizontal and vertical tangent in lower left corner. s1 points\n\t to the array which contain the results and s3 to the corner.    */\n      \n      for (s1=sdir+2*idim,s2=s1+idim,s3=scoef; s1<s2; s1++,s3++)\n\t{       \n\t  *s1 = *(s3+idim) - *s3;\n\t  *(s1+idim) = *(s3+idim*kn1) - *s3;\n\t}\n      \n      /* Make the horizontal and vertical tangent in lower right corner. s1\n\t points to the array which contain the results and s3 to the corner.*/\n      \n      for (s1=sdir+4*idim,s2=s1+idim,s3=scoef+idim*(kn1-1); s1<s2; s1++,s3++)\n\t{\n\t  *s1 = *(s3-idim) - *s3;\n\t  *(s1+idim) = *(s3+idim*kn1) - *s3;\n\t}\n      \n      /* Make the horizontal and vertical tangent in upper left corner. s1\n\t points to the result array and s3 to the corner.                  */\n      \n      for (s1=sdir+6*idim,s2=s1+idim,s3=scoef+idim*kn1*(kn2-1);s1<s2;s1++,s3++)\n\t{\n\t  *s1 = *(s3+idim) - *s3;\n\t  *(s1+idim) = *(s3-idim*kn1) - *s3;\n\t}\n      \n      /* Make the horizontal and vertical tangent in upper right corner. \n\t s1 points to the result array and s3 to the corner.             */\n      \n      for (s1=sdir+8*idim,s2=s1+idim,s3=scoef+idim*(kn1*kn2-1);s1<s2;s1++,s3++)\n\t{\n\t  *s1 = *(s3-idim) - *s3;\n\t  *(s1+idim) = *(s3-kn1*idim) - *s3;\n\t}\n    }\n  \n  /* Rotate coordinate system according to the vectors found and perform\n     box-test. First use the diagonal vectors.                           */\n  \n  klap = 1;\n  s1834(scoef,kn1*kn2,epol,in,idim,sdir,sdir+idim,&kstat);\n  if (kstat < 0) goto error;\n  klap = kstat;\n  \n  if (klap == 1)\n    {\n      s1834(scoef,kn1*kn2,epol,in,idim,sdir+idim,sdir,&kstat);\n      if (kstat < 0) goto error;\n      klap = kstat;\n    }\n  \n  /* If the box-tests performed till now show overlap and the surface\n     is non-linear in at least one direction rotate the geometry according\n     to the tangent information gathered.                                 */\n  \n  ki = 2;\n  while (ki<kvec && klap == 1)\n    {\n      s1834(scoef,kn1*kn2,epol,in,idim,sdir+ki*idim,sdir+(ki+1)*idim,&kstat);\n      if (kstat < 0) goto error;\n      klap = kstat;\n      ki += 2;\n    }\n  \n  /* Improved boxtest performed.  */\n  \n  *jstat = klap;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1839\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Dimension not equal to 2 or 3.  */\n  \n err105: *jstat = -105;\n  s6err(\"s1839\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Dimensions conflicting.  */\n  \n err106: *jstat = -106;\n  s6err(\"s1839\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"s1839\",*jstat,kpos);\n  goto out;\n  \n out: \n  \n  /* Free allocated space.  */\n  \n  if (sdir != SISL_NULL) freearray(sdir);\n  \n  return;\n}\n"
  },
  {
    "path": "src/s1840.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1840.c,v 1.2 2001-03-19 15:58:54 afr Exp $\n *\n */\n\n\n#define S1840\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1840(SISLCurve *pcurve,double *cdist,int *jstat)\n#else\nvoid s1840(pcurve,cdist,jstat)\n     SISLCurve  *pcurve;\n     double *cdist;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate the distance of the control polygon of a\n*              B-spline curve to the control polygon of a straight line\n*              from the first to the last vertex of the curve described\n*              by the same control polygon.\n*\n*\n* INPUT      : pcurve  - Pointer to surface object\n*\n*\n*\n* OUTPUT     : \n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*              *cdist - Deviation of curve polygon fromstraight line\n*\n* METHOD     : The knot vector is normalized to the interval [0,1]\n*              Then Marsdens identity is used for representing the\n*              function f(x)=x by the knot vector.\n*\n* REFERENCES : Theorem 4.21. (Marsdens identity). page 125. in\n*              Larry L. Schumaker: Basic spline theory. \n*              John Wiley & Sons. 1981. ISBN 0-471-76475-2\n*\n*\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. 10. Sept. 1988\n*\n*********************************************************************\n*/\n{\n  int kstop,kj,ki,kp;        /* Loop control variable                     */\n  int kpos = 0;              /* Position of errors                        */\n  int kkm1;                  /* Orders minus 1                            */\n  int kn,kk,kdim;            /* Variables in surface description          */\n  double *st,*scoef;         /* Pointers to arrays describing surface     */\n  double tstart,tlength;     /* Temproary variables                       */\n  double tdiff;              /* Temproary variables                       */\n  double *sm1=SISL_NULL;          /* Arrays for coefficients from Marsdens idnt*/\n  double *start,*send;       /* Pointers to first and last vertex         */\n  double tval0,tval1;        /* s and 1-s used in Marsdens identity       */\n  double tsum;               /* Dummy variables                           */\n  \n  /* Initiate distance */\n  \n  *cdist = (double)0.0;         \n  \n  /* Make local versions of the curve object */\n  \n  st    = pcurve->et;\n  scoef = pcurve->ecoef;\n  kn    = pcurve->in;\n  kk    = pcurve->ik;\n  kdim  = pcurve->idim;\n  \n  /* Allocate space for arrays to be used by coefficients in Marsdens\n   * identity, average of corners, diagonals, normal vector and\n   * projection of corners into the plane defined by average of corners\n   * and normalvector */\n  \n  sm1 = newarray(kn,double);\n  if (sm1 == SISL_NULL) goto err101;\n  \n  /* Make representation of coefficients from Marsdens identity for the\n     function f(t) = t, with the knot vector scaled to [0,1]. */\n  \n  tstart = st[kk-1];\n  tlength = st[kn] - tstart;\n  kkm1 = kk - 1;\n  for (ki=0;ki<kn;ki++)\n    {\n      tsum = 0;\n      kstop = ki+kk;\n      for (kj=ki+1;kj<kstop;kj++)\n        tsum +=st[kj];\n      \n      sm1[ki] = (tsum/kkm1-tstart)/tlength;\n    }\n  \n  /* Calculate distances between the control polygon of the curve\n     and the control polygon of the straight line */\n  \n  start = scoef;\n  send  = scoef + kdim*(kn-1);\n  kp    = 0;\n  \n  for (ki=0;ki<kn;ki++)\n    {\n      tval1 = sm1[ki];\n      tval0 = (double)1.0 - tval1;\n      tsum = (double)0.0; \n      \n      for (kj=0;kj<kdim;kj++)\n        {\n\t  \n\t  /* Accumulate distance between curve vertex and line vertex */\n\t  \n\t  tdiff = scoef[kp] - (tval0*start[kj] + tval1*send[kj]);\n\t  tsum += tdiff*tdiff;\n\t  kp++;\n        }\n      *cdist = MAX(*cdist,tsum);\n    }\n  \n  *cdist = sqrt(*cdist);\n  \n  /* Everything ok */\n\n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n  err101: *jstat = -101;      \n    s6err(\"s1840\",*jstat,kpos);\n    goto out;\n  \n  /* Free allocated space */\n  \n  out:\n    if (sm1 != SISL_NULL) freearray(sm1);\n    return;\n}\n"
  },
  {
    "path": "src/s1850.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1850.c,v 1.2 2001-03-19 15:58:54 afr Exp $\n *\n */\n\n\n#define S1850\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1850(SISLCurve *pc1,double epoint[],double enorm[],int idim,\n\t   double aepsco,double aepsge,int *jpt,double **gpar,\n\t   int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1850(pc1,epoint,enorm,idim,aepsco,aepsge,\n\t   jpt,gpar,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     double   epoint[];\n     double   enorm[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a curve and a plane if\n*              the dimension is equal to three and a line if the \n*              dimension is two.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve.\n*              epoint - SISLPoint in the plane/line.\n*              enorm  - Normal to the plane/line.\n*              idim   - Dimension of the space in which the plane/line\n*                       lies. idim should be equal to two or three.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              jcrv   - Number of intersection curves.\n*              wcurve - Array containing descrjptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See descrjption of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the curve is put into the equation of the\n*              plane/line achieving a curve in the one-dimentional space.\n*              The zeroes of this curve is found.\n*\n*\n*\n* REFERENCES : Main routine written by Vibeke Skytt, SI, 1988.\n*\n* CALLS      : sh1850, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n*\n*********************************************************************\n*/                                                               \n{                                                                     \n  int kstat = 0;           /* Local status variable.                       */\n  int kpos = 0;            /* Position of error.                           */\n  int trackflag = 0;\n  int jtrack;\n  int *pretop=SISL_NULL;\n  SISLTrack **wtrack=SISL_NULL;\n\n  sh1850(pc1,epoint,enorm,idim,aepsco,aepsge,\n\t trackflag,&jtrack,&wtrack,jpt,gpar,&pretop,jcrv,wcurve,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : \n    *jstat = kstat;\n    s6err(\"s1850\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}                                               \n                                           \n                       \n"
  },
  {
    "path": "src/s1851.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1851.c,v 1.3 2001-03-19 15:58:54 afr Exp $\n *\n */\n\n\n#define S1851\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1851(SISLSurf *ps1,double epoint[],double enorm[],int idim,\n\t   double aepsco,double aepsge,int *jpt,double **gpar,\n\t   int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1851(ps1,epoint,enorm,idim,aepsco,aepsge,\n\t   jpt,gpar,jcrv,wcurve,jstat)\n     SISLSurf     *ps1;\n     double   epoint[];\n     double   enorm[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find all intersections between a tensor-product surface\n*              and a plane.\n*\n*\n*\n* INPUT      : ps1    - Pointer to surface.\n*              epoint - SISLPoint in the plane.\n*              enorm  - Normal to the plane.\n*              idim   - Dimension of the space in which the plane lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : *jpt   - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       plane of the surface. The points lie continuous.\n*                       Intersection curves are stored in wcurve.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the surface are put into the equation of the\n*              plane achieving a surface in the one-dimentional space.\n*              Then the zeroes of this surface is found.\n*\n*\n* REFERENCES : Main routine written by Vibeke Skytt, SI, 1988.\n*\n* CALLS      : sh1851, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Oct. 1994.\n*              Initialized 'jsurf'.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;              /* Local status variable.                      */\n  int kpos = 0;               /* Position of error.                          */\n  int i;\n  int trackflag = 0;\n  int jtrack;\n  SISLTrack **wtrack=SISL_NULL;\n  int jsurf = 0;\n  SISLIntsurf **wsurf=SISL_NULL;\n  int *pretop=SISL_NULL;\n\n  sh1851(ps1, epoint, enorm, idim, aepsco, aepsge,trackflag, &jtrack,\n\t &wtrack,jpt, gpar,&pretop,jcrv,wcurve,&jsurf,&wsurf,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  for(i=0; i<jsurf; i++)\n    freeIntsurf(wsurf[i]);\n  if(wsurf != SISL_NULL) freearray(wsurf);\n\n  if(jsurf > 0)\n    *jstat=10;\n  else\n    *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n    s6err(\"s1851\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}\n"
  },
  {
    "path": "src/s1852.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1852.c,v 1.2 2001-03-19 15:58:54 afr Exp $\n *\n */\n\n\n#define S1852\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1852(SISLSurf *ps1,double ecenter[],double aradius,\n\t   int idim,double aepsco,double aepsge,\n\t   int *jpt,double **gpar, int *jcrv,\n\t   SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1852(ps1,ecenter,aradius,idim,aepsco,aepsge,\n\t   jpt,gpar,jcrv,wcurve,jstat)\n     SISLSurf     *ps1;\n     double   ecenter[];\n     double   aradius;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar; \n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a tensor-product surface\n*              and a sphere.\n*\n*\n*\n* INPUT      : ps1      - Pointer to surface.\n*              ecenter  - Center of the sphere.\n*              aradius  - Radius of the sphere.\n*              idim     - Dimension of the space in which the sphere lies.\n*              aepsco   - Computational resolution.\n*              aepsge   - Geometry resolution.\n*\n*\n*\n* OUTPUT     : *jpt   - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       plane of the surface. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the surface are put into the equation of the\n*              sphere achieving a surface in the one-dimentional space.\n*              Then the zeroes of this surface is found.\n*\n*\n* REFERENCES : Main routine written by Vibeke Skytt, SI, 1988.\n*\n* CALLS      : sh1852, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n*\n*********************************************************************\n*/\n{            \n  int kstat = 0;              /* Local status variable.                      */\n  int kpos = 0;               /* Position of error.                          */\n  int i;\n  int trackflag = 0;\n  int jtrack = 0;\n  SISLTrack **wtrack=SISL_NULL;\n  int jsurf = 0;\n  SISLIntsurf **wsurf=SISL_NULL;\n  int *pretop=SISL_NULL;\n\n  sh1852(ps1,ecenter,aradius,idim,aepsco,aepsge,trackflag,&jtrack,\n\t &wtrack,jpt,gpar,&pretop,jcrv,wcurve,&jsurf,&wsurf,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  for(i=0; i<jsurf; i++)\n    freeIntsurf(wsurf[i]);\n  if(wsurf != SISL_NULL) freearray(wsurf);\n\n  if(jsurf > 0) \n    *jstat=10;\n  else \n    *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error: \n    *jstat = kstat;\n    s6err(\"s1852\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}                                               \n"
  },
  {
    "path": "src/s1853.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1853.c,v 1.2 2001-03-19 15:58:54 afr Exp $\n *\n */\n\n\n#define S1853\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1853(SISLSurf *ps1,double epoint[],double edirec[],double aradius,\n\t   int idim,double aepsco,double aepsge,int *jpt,double **gpar,\n\t   int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1853(ps1,epoint,edirec,aradius,idim,aepsco,aepsge,\n\t   jpt,gpar,jcrv,wcurve,jstat)\n     SISLSurf     *ps1;\n     double   epoint[];\n     double   edirec[];\n     double   aradius;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a tensor-product surface\n*              and a cylinder.\n*\n*\n*\n* INPUT      : ps1      - Pointer to surface.\n*              epoint   - SISLPoint on the axis of the cylinder.\n*              edirec   - The direction vector of the axis of the cylinder.\n*              aradius  - Radius of the cylinder.\n*              idim     - Dimension of the space in which the cylinder lies.\n*              aepsco   - Computational resolution.\n*              aepsge   - Geometry resolution.\n*                                                                        \n*\n*\n* OUTPUT     : *jpt   - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       plane of the surface. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the surface are put into the equation of the\n*              cylinder achieving a surface in the one-dimentional space.\n*              Then the zeroes of this surface is found.\n*\n*\n* REFERENCES : Main routine written by Vibeke Skytt, SI, 1988.\n*\n* CALLS      : sh1853, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;              /* Local status variable.                      */\n  int kpos = 0;               /* Position of error.                          */\n  int i;\n  int trackflag = 0;\n  int jtrack = 0;\n  SISLTrack **wtrack=SISL_NULL;\n  int jsurf = 0;\n  SISLIntsurf **wsurf=SISL_NULL;\n  int *pretop=SISL_NULL;\n\n  sh1853(ps1,epoint,edirec,aradius,idim,aepsco,aepsge,trackflag,&jtrack,\n\t &wtrack,jpt,gpar,&pretop,jcrv,wcurve,&jsurf,&wsurf,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  for(i=0; i<jsurf; i++)\n    freeIntsurf(wsurf[i]);\n  if(wsurf != SISL_NULL) freearray(wsurf);\n\n  if(jsurf > 0) \n    *jstat=10;\n  else \n    *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : \n    *jstat = kstat;\n    s6err(\"s1853\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}                                               \n"
  },
  {
    "path": "src/s1854.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1854.c,v 1.2 2001-03-19 15:58:54 afr Exp $\n *\n */\n\n\n#define S1854\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1854(SISLSurf *ps1,double etop[],double eaxis[],double econe[],int idim,\n\t   double aepsco,double aepsge,\n\t   int *jpt,double **gpar,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1854(ps1,etop,eaxis,econe,idim,aepsco,aepsge,\n\t   jpt,gpar,jcrv,wcurve,jstat)\n     SISLSurf     *ps1;\n     double   etop[];\n     double   eaxis[];\n     double   econe[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a tensor-product surface\n*              and a cone.\n*\n*\n*\n* INPUT      : ps1      - Pointer to surface.\n*              etop     - Top point of the cone.\n*              eaxis    - SISLPoint on the axis of the cone. eaxis is not\n*                         equal to etop.\n*              econe    - SISLPoint on the cone surface. econe is not equal\n*                         to etop.\n*              idim     - Dimension of the space in which the cone lies.\n*              aepsco   - Computational resolution.\n*              aepsge   - Geometry resolution.\n*                                                                        \n*                                                                        \n*\n* OUTPUT     : *jpt   - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       plane of the surface. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the surface are put into the equation of \n*              the cone achieving a surface in the one-dimentional space.\n*              Then the zeroes of this surface is found.\n*\n*\n* REFERENCES : Main routine written by Vibeke Skytt, SI, 1988.\n*\n* CALLS      : sh1854, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n*\n*********************************************************************\n*/\n{            \n  int kstat = 0;              /* Local status variable.                      */\n  int kpos = 0;               /* Position of error.                          */\n  int i;\n  int trackflag = 0;\n  int jtrack;\n  SISLTrack **wtrack=SISL_NULL;\n  int jsurf;\n  SISLIntsurf **wsurf=SISL_NULL;\n  int *pretop=SISL_NULL;\n\n  sh1854(ps1,etop,eaxis,econe,idim,aepsco,aepsge,trackflag,&jtrack,\n\t &wtrack,jpt,gpar,&pretop,jcrv,wcurve,&jsurf,&wsurf,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  for(i=0; i<jsurf; i++)\n    freeIntsurf(wsurf[i]);\n  if(wsurf != SISL_NULL) freearray(wsurf);\n\n  if(jsurf > 0) \n    *jstat=10;\n  else \n    *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error:\n    *jstat = kstat;\n    s6err(\"s1854\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}                                               \n"
  },
  {
    "path": "src/s1855.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1855.c,v 1.2 2001-03-19 15:58:54 afr Exp $\n *\n */\n\n\n#define S1855\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1855(SISLSurf *ps1,double ecentr[],double aradius,\n\t   double enorm[],int idim,double aepsco,double aepsge,\n\t   int *jpt,double **gpar,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1855(ps1,ecentr,aradius,enorm,idim,aepsco,aepsge,\n\t   jpt,gpar,jcrv,wcurve,jstat)\n     SISLSurf     *ps1;\n     double   ecentr[];\n     double   aradius;\n     double   enorm[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a tensor-product surface\n*              and a circle.\n*\n*\n*\n* INPUT      : ps1      - Pointer to surface.\n*              ecentr   - Center of the circle.\n*              aradius  - Radius of the circle.\n*              enorm    - Normal vector to the plane in which the circle\n*                         lies.\n*              idim     - Dimension of the space in which the circle lies.\n*              aepsco   - Computational resolution.\n*              aepsge   - Geometry resolution.\n*                                                                        \n*                                                                        \n*\n* OUTPUT     : *jpt   - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       plane of the surface. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the surface are put into the equation of \n*              the circle achieving a surface in the two-dimentional space.\n*              Then the zeroes of this surface is found.\n*\n* REFERENCES : Main routine written by Vibeke Skytt, SI, 1988.\n*\n* CALLS      : sh1855, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n*\n*********************************************************************\n*/\n{   \n  int kstat = 0;           /* Local status variable.                       */\n  int kpos = 0;            /* Position of error.                           */\n  int trackflag = 0;\n  int jtrack;\n  int *pretop=SISL_NULL;\n  SISLTrack **wtrack=SISL_NULL;\n\n  sh1855(ps1,ecentr,aradius,enorm,idim,aepsco,aepsge,trackflag,\n\t &jtrack,&wtrack,jpt,gpar,&pretop,jcrv,wcurve,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : \n    *jstat = kstat;\n    s6err(\"s1855\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}                                               \n"
  },
  {
    "path": "src/s1856.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1856.c,v 1.2 2001-03-19 15:58:54 afr Exp $\n *\n */\n\n\n#define S1856\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1856(SISLSurf *ps1,double epoint[],double edir[],int idim,\n\t   double aepsco,double aepsge,int *jpt,double **gpar,\n\t   int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1856(ps1,epoint,edir,idim,aepsco,aepsge,jpt,gpar,jcrv,wcurve,jstat)\n     SISLSurf     *ps1;\n     double   epoint[];\n     double   edir[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a tensor-product surface\n*              and an infinite straight line.\n*\n*\n*\n* INPUT      : ps1    - Pointer to surface.\n*              epoint - SISLPoint on the line.\n*              edir   - Direction vector of the line.\n*              idim   - Dimension of the space in which the line lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : *jpt   - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       plane of the surface. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The line is described as the intersection between two\n*              planes. The vertices of the surface are put into the equation \n*              of this planes achieving a surface in the two-dimentional \n*              space. Then the zeroes of this surface is found.\n*\n*\n* REFERENCES : Main routine written by Vibeke Skytt, SI, 1988.\n*\n* CALLS      : sh1856, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n*\n*********************************************************************\n*/\n{            \n  int kstat = 0;           /* Local status variable.                       */\n  int kpos = 0;            /* Position of error.                           */\n  int trackflag = 0;\n  int jtrack;\n  int *pretop=SISL_NULL;\n  SISLTrack **wtrack=SISL_NULL;\n\n  sh1856(ps1,epoint,edir,idim,aepsco,aepsge,trackflag,&jtrack,\n\t &wtrack,jpt,gpar,&pretop,jcrv,wcurve,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n   \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : \n    *jstat = kstat;\n    s6err(\"s1856\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}                                               \n"
  },
  {
    "path": "src/s1857.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1857.c,v 1.2 2001-03-19 15:58:54 afr Exp $\n *\n */\n\n\n#define S1857\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1857(SISLCurve *pc1,SISLCurve *pc2,double aepsco,double aepsge,\n\t   int *jpt,double **gpar1,double **gpar2,int *jcrv,\n\t   SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1857(pc1,pc2,aepsco,aepsge,jpt,gpar1,gpar2,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     SISLCurve    *pc2;    \n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar1;\n     double   **gpar2;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between two B-spline curves.\n*\n*\n*\n* INPUT      : pc1    - Pointer to first curve.\n*              pc2    - Pointer to second curve.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : jpt    - Number of single intersection points.\n*              gpar1  - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the first curve. The points lie \n*                       continuous. Intersection curves are stored in wcurve.\n*              gpar2  - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the second curve.\n*              jcrv   - Number of intersection curves.\n*              wcurve - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*                       If the curves given as input are degnenerate an\n*                       intersection point can be returned as an intersection\n*                       curve. Use s1327 to decide if an intersection curve\n*                       is a point on one of the curves.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The curves are subdivided until we have a simple problem\n*              where the intersection can be found by iteration. Then\n*              Newton iteration is used.\n*\n*\n* REFERENCES : Main routine written by Vibeke Skytt, SI, 1988.\n*\n* CALLS      : sh1857, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n*\n*********************************************************************\n*/\n{            \n  int kstat = 0;           /* Local status variable.                       */\n  int kpos = 0;            /* Position of error.                           */\n  int trackflag = 0;\n  int jtrack;\n  int *pretop=SISL_NULL;\n  SISLTrack **wtrack=SISL_NULL;\n\n  sh1857(pc1,pc2,aepsco,aepsge,trackflag,&jtrack,&wtrack,jpt,gpar1,\n\t gpar2,&pretop,jcrv,wcurve,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);   \n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : \n    *jstat = kstat;\n    s6err(\"s1857\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}                                               \n"
  },
  {
    "path": "src/s1858.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1858.c,v 1.2 2001-03-19 15:58:54 afr Exp $\n *\n */\n\n\n#define S1858\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1858(SISLSurf *ps1,SISLCurve *pc1,double aepsco,double aepsge,\n\t   int *jpt,double **gpar1,double **gpar2,int *jcrv,\n\t   SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1858(ps1,pc1,aepsco,aepsge,jpt,gpar1,gpar2,jcrv,wcurve,jstat)\n     SISLSurf     *ps1;\n     SISLCurve    *pc1;    \n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar1;\n     double   **gpar2;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a B-spline surface\n*              and a B-spline curve.\n*\n*\n*\n* INPUT      : ps1    - Pointer to the surface.\n*              pc1    - Pointer to the curve.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : jpt    - Number of single intersection points.\n*              gpar1  - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the first curve. The points lie \n*                       continuous. Intersection curves are stored in wcurve.\n*              gpar2  - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the second curve.\n*              jcrv   - Number of intersection curves.\n*              wcurve - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*                       If the curves given as input are degnenerate an\n*                       intersection point can be returned as an intersection\n*                       curve. Use s1327 to decide if an intersection curve\n*                       is a point on one of the curves.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* REFERENCES : Main routine written by Vibeke Skytt, SI, 1988.\n*\n* CALLS      : sh1858, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n*\n*********************************************************************\n*/\n{  \n  int kstat = 0;           /* Local status variable.                       */\n  int kpos = 0;            /* Position of error.                           */\n  int trackflag = 0;\n  int jtrack;\n  int *pretop=SISL_NULL;\n  SISLTrack **wtrack=SISL_NULL;\n          \n  sh1858(ps1,pc1,aepsco,aepsge,trackflag,&jtrack,&wtrack,jpt,\n\t gpar1,gpar2,&pretop,jcrv,wcurve,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n     \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : \n    *jstat = kstat;\n    s6err(\"s1858\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}                                               \n"
  },
  {
    "path": "src/s1859.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1859.c,v 1.2 2001-03-19 15:58:54 afr Exp $\n *\n */\n\n\n#define S1859\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1859(SISLSurf *ps1,SISLSurf *ps2,double aepsco,double aepsge,\n\t   int *jpt,double **gpar1,double **gpar2,int *jcrv,\n\t   SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1859(ps1,ps2,aepsco,aepsge,jpt,gpar1,gpar2,jcrv,wcurve,jstat)\n     SISLSurf     *ps1;\n     SISLSurf     *ps2;    \n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar1;\n     double   **gpar2;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between two B-spline surfaces.\n*\n*\n*\n* INPUT      : ps1    - Pointer to first surface.\n*              ps2    - Pointer to second surface.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : jpt    - Number of single intersection points.\n*              gpar1  - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the first curve. The points lie \n*                       continuous. Intersection curves are stored in wcurve.\n*              gpar2  - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the second curve.\n*              jcrv   - Number of intersection curves.\n*              wcurve - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*                       If the curves given as input are degnenerate an\n*                       intersection point can be returned as an intersection\n*                       curve. Use s1327 to decide if an intersection curve\n*                       is a point on one of the curves.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The curves are subdivided until we have a simple problem\n*              where the intersection can be found by iteration. Then\n*              Newton iteration is used.\n*\n*\n* REFERENCES : Main routine written by Vibeke Skytt, SI, 1988.\n*\n* CALLS      : sh1859, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n*\n*********************************************************************\n*/\n{            \n  int kstat = 0;               /* Local status variable.                   */\n  int kpos = 0;                /* Position of error.                       */\n  int i;\n\n  int trackflag = 0;\n  int jtrack;\n  SISLTrack **wtrack=SISL_NULL;\n  int *pretop=SISL_NULL;\n  int jsurf;\n  SISLIntsurf **wsurf=SISL_NULL;\n\n  sh1859 (ps1, ps2, aepsco, aepsge, trackflag, &jtrack, &wtrack, jpt, gpar1, \n\t  gpar2, &pretop, jcrv, wcurve,&jsurf,&wsurf,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  for(i=0; i<jsurf; i++)\n    freeIntsurf(wsurf[i]);\n  if(wsurf != SISL_NULL) freearray(wsurf);\n\n  if(jsurf > 0) \n    *jstat=10;\n  else \n    *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : \n    *jstat = kstat;\n    s6err(\"s1859\",*jstat,kpos);\n    goto out;\n\n  out:\n\n  /*\n   * Exit s1859.\n   * -----------\n   */\n\n    return;\n}                                               \n"
  },
  {
    "path": "src/s1860.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1860.c,v 1.4 2001-03-19 15:58:55 afr Exp $\n *\n */\n\n\n#define S1860\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1860(SISLSurf *ps,double eview[],int idim,double aepsco,double aepsge,\n\t   int *jpt,double **gpar,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1860(ps,eview,idim,aepsco,aepsge,jpt,gpar,jcrv,wcurve,jstat)\n     SISLSurf     *ps;\n     double   eview[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find the silhouette curves and points of a surface when\n*              the surface is viewed from a specific direction. In\n*              addition to the points and curves found by this routine,\n*              break curves and edge-curves might be silhouette curves.\n*\n*\n*\n* INPUT      : ps  - Pointer to the surface.\n*              eview  - The direction vector of the viewing.\n*              idim   - Dimension of the space in which eview lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : jpt    - Number of single silhouette points.\n*              gpar   - Array containing the parameter values of the\n*                       single silhouette points in the parameter\n*                       plane of the surface. The points lie continuous.\n*                       Silhouette curves are stored in wcurve.\n*              jcrv   - Number of silhouette curves.\n*              wcurve - Array containing descriptions of the silhouette\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES : Main routine written by Vibeke Skytt, SI, 1988.\n*\n* CALLS      : sh1860, s6err.\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF, 93-06.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Jan. 1995.\n*              Made deallocation of 'wsurf' safer.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;              /* Local status variable.                      */\n  int kpos = 0;               /* Position of error.                          */\n  int i;\n  int trackflag = 0;\n  int jtrack;\n  SISLTrack **wtrack=SISL_NULL;\n  int jsurf;\n  SISLIntsurf **wsurf=SISL_NULL;\n  int *pretop=SISL_NULL;\n\n  sh1860(ps,eview,idim,aepsco,aepsge,trackflag,&jtrack,&wtrack,\n\t jpt,gpar,&pretop,jcrv,wcurve,&jsurf,&wsurf,&kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  if ( wsurf != SISL_NULL )\n  {\n    for( i=0;  i < jsurf;  i++ )\n      if ( wsurf[i] != SISL_NULL )  freeIntsurf(wsurf[i]);\n    freearray(wsurf);\n  }\n\n  if(jsurf > 0)\n    *jstat=10;\n  else\n    *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n    s6err(\"s1860\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}\n"
  },
  {
    "path": "src/s1870.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1870\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1870(SISLSurf *ps1, double *pt1, int idim, double aepsge,\n\t int *jpt,double **gpar1,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1870(ps1,pt1,idim,aepsge,jpt,gpar1,jcrv,wcurve,jstat)\n     SISLSurf     *ps1;\n     double    pt1[];\n     int\tidim;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar1;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find all intersections between a NURBS surface\n*              and a point.\n*\n*\n*\n* INPUT      : ps1    - Pointer to the surface.\n*              pt1    - coordinates of the point.\n*\t       idim   - number of coordinates in pt1.\n*              aepsge - Geometry resolution.\n*              *jstat    - Flag\n*                          = 202 : Complicated point-surface intersection\n*                                  in 3D. Perform extra interception test.\n*\n*\n*\n*\n* OUTPUT     : jpt    - Number of single intersection points.\n*              gpar1  - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the surface. The points lie\n*                       continuous. Intersection curves are stored in wcurve.\n*              jcrv   - Number of intersection curves.\n*              wcurve - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*                       If the curves given as input are degnenerate an\n*                       intersection point can be returned as an intersection\n*                       curve. Use s1327 to decide if an intersection curve\n*                       is a point on one of the curves.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1870      - Perform the actual intersection.\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 9403.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;           /* Local status variable.                       */\n  int kpos = 0;            /* Position of error.                           */\n  int trackflag = 0;\n  int jtrack;\n  int *pretop=SISL_NULL;\n  SISLTrack **wtrack=SISL_NULL;\n  double aepsco = REL_COMP_RES;\n\n  kstat = *jstat;\n  sh1870(ps1, pt1, idim, aepsco, aepsge, trackflag, &jtrack, &wtrack,\n\t jpt, gpar1, &pretop, jcrv, wcurve, &kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  /*\n   * Intersections found.\n   * --------------------\n   */\n\n  *jstat = kstat;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n    s6err(\"s1870\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}\n"
  },
  {
    "path": "src/s1871.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1871\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1871(SISLCurve *pc1, double *pt1, int idim, double aepsge,\n\t int *jpt,double **gpar1,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1871(pc1,pt1,idim,aepsge,jpt,gpar1,jcrv,wcurve,jstat)\n     SISLCurve     *pc1;\n     double    *pt1;\n     int\tidim;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar1;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find all intersections between a B-spline curve\n*              and a point.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve.\n*              pt1    - coordinates of the point.\n*\t       idim   - number of coordinates in pt1.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : jpt    - Number of single intersection points.\n*              gpar1  - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie\n*                       continuous. Intersection curves are stored in wcurve.\n*              jcrv   - Number of intersection curves.\n*              wcurve - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*                       If the curves given as input are degnenerate an\n*                       intersection point can be returned as an intersection\n*                       curve. Use s1327 to decide if an intersection curve\n*                       is a point on one of the curves.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1871      - Perform the actual intersection.\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 9403.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;           /* Local status variable.                       */\n  int kpos = 0;            /* Position of error.                           */\n  int trackflag = 0;\n  int jtrack;\n  int *pretop=SISL_NULL;\n  SISLTrack **wtrack=SISL_NULL;\n  double aepsco = REL_COMP_RES;\n\n  sh1871(pc1, pt1, idim, aepsco, aepsge, trackflag, &jtrack, &wtrack,\n\t jpt, gpar1, &pretop, jcrv, wcurve, &kstat);\n  if(kstat < 0) goto error;\n\n  if(pretop != SISL_NULL) freearray(pretop);\n\n  /*\n   * Intersections found.\n   * --------------------\n   */\n\n  *jstat = kstat;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n    s6err(\"s1871\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}\n"
  },
  {
    "path": "src/s1880.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1880.c,v 1.2 2001-03-19 15:58:55 afr Exp $\n *\n */\n\n\n#define S1880\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1880(int ipar1,int ipar2,int *jpt,SISLIntpt **vpoint,int *jlist,SISLIntlist **vlist,\n\t   int *jpar,double **gpar1,double **gpar2,int *jcrv,SISLIntcurve ***wcrv,int *jstat)\n#else\nvoid s1880(ipar1,ipar2,jpt,vpoint,jlist,vlist,jpar,gpar1,gpar2,jcrv,\n           wcrv,jstat)\n     int      ipar1;\n     int      ipar2;\n     int      *jpt;\n     SISLIntpt    **vpoint;\n     int      *jlist;\n     SISLIntlist  **vlist;\n     int      *jpar;\n     double   **gpar1;\n     double   **gpar2;\n     int      *jcrv;\n     SISLIntcurve ***wcrv;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Transform intersection points and curves from internal\n*              format in the recursive part of intersection routines\n*              to output format.\n*\n*\n*\n* INPUT      : ipar1  - Number of parameter directions of first object.\n*              ipar2  - Number of parameter directions of second object.\n*              vpoint - Array containing intersection points on the\n*                       internal format.\n*              vlist  - Array representing intersection curves on the\n*                       internal format.\n*\n* INPUT/OUTPUT : jpt    - Number of intersection point in the vpoint array.\n*                jlist  - Number of lists representing intersection curves\n*                         in the array vlist.\n*\n*\n*\n*\n* OUTPUT     : jpar   - Number of single intersection points.\n*              gpar1  - Parameter values of the single intersection points\n*                       in the parameter area of the first object.\n*              gpar2  - Parameter values of the single intersection points\n*                       in the parameter area of the second object.\n*              jcrv   - Number of intersection curves.\n*              wcrv   - Array containing description of intersection curves.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : newIntcurve - Create a new instance of Intcurve.\n*              freeIntpt   - Free space occupied by intersection point.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-05.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;         /* Position of error.                          */\n  int ki,kj,kk;         /* Counters.                                   */\n  int kpoint;           /* Number of points in an intersection list.   */\n  int klst;             /* Kind of intersection list. (See SISLIntlist).   */\n  int ktype;            /* Kind of intersection curve. (See SISLIntcurve). */\n  int kpt;              /* Used to find number of single intersection points.*/\n  double *spar1,*spar2; /* Values of points belonging to an intersection\n\t\t\t   curve in the parameter area of the objects\n\t\t\t   involved in the intersection.               */\n  double *stpar1,*stpar2,*stpar3; /* Pointers used to travers arrays \n\t\t\t\t     containing parameter values.      */ \n  SISLIntcurve **ucrv;      /* Pointer used to traverse *wcrv array.    */\n  SISLIntlist **ulst;       /* Pointer used to traverse vlist array.     */\n  SISLIntpt *qpt;           /* Pointer to an intersection point.         */\n  SISLIntpt **upt;          /* Pointer used to travers vpoint array.     */\n  \n  /* Initiate output arrays.  */\n  \n  *gpar1 = *gpar2 = SISL_NULL;  *wcrv = SISL_NULL;\n  \n  /* Allocate space for intersection curve array.  */\n  \n  *jcrv = *jlist;\n  *wcrv = newarray(*jlist,SISLIntcurve*);\n  if ((*jcrv) > 0 && *wcrv == SISL_NULL) goto err101;\n  \n  /* Transfer curve-information from vlist array to wcrv array. */\n  \n  ucrv = *wcrv;\n  ulst = vlist;\n  kpt = 0;\n  for (ki=0; ki<(*jlist); ki++)\n    {\n      qpt = (*ulst) -> pfirst;\n      \n      /* Allocate space for arrays containing parameter vlaues of points \n\t in intersection curves.                                          */\n      \n      kpoint = (*ulst) -> inumb;\n      if (kpoint == 0) goto err137;\n      spar1 = newarray(ipar1*kpoint,double);\n      spar2 = newarray(ipar2*kpoint,double);\n      if ((ipar1 > 0 && spar1 == SISL_NULL) ||\n\t  (ipar2 > 0 && spar2 == SISL_NULL)) goto err101;\n      \n      /* Collect parameter values of the points in this intersection list\n\t and distribute values to the objects in the intersection.         */\n      \n      kj = 0;\n      stpar1 = spar1;   \n      stpar2 = spar2;\n      while (qpt != SISL_NULL && qpt -> ipar != -1)\n\t{\n\t  stpar3 = qpt -> epar;\n\t  for (kk=0; kk<ipar1; kk++) *(stpar1++) = *(stpar3++);\n\t  for (kk=0; kk<ipar2; kk++) *(stpar2++) = *(stpar3++);\n\t  qpt -> ipar = -1;\n\t  qpt = qpt -> pcurve;\n\t  kj++;\n\t}\n      \n      /* Find kind of intersection curve.  */\n      \n      klst = (*ulst) -> itype;\n      if (klst == 0) ktype = 4;\n      else if (klst == 1) ktype = 2;\n      else if (klst == 2) ktype = 5;\n      else if (klst == 3) ktype = 6;\n      else if (klst == 4) ktype = 7;\n      else if (klst == 5) ktype = 8;\n      else goto err146;             \n      \n      /* Create new intersection curve.  */\n      \n      *ucrv = newIntcurve(kj,ipar1,ipar2,spar1,spar2,ktype);\n      if (*ucrv == SISL_NULL) goto err101;\n      \n      kpt += kj;\n      ucrv++;\n      ulst++;\n    }                  \n  \n  /* Find number of single intersection points.  */\n  \n  kpt = *jpt - kpt;\n  \n  /* Create arrays to keep parameter values of intersection points.  */\n  \n  *gpar1 = newarray(ipar1*kpt,double);\n  *gpar2 = newarray(ipar2*kpt,double);\n  if ((ipar1*kpt > 0 && *gpar1 == SISL_NULL) \n      || (ipar2*kpt > 0 && *gpar2 == SISL_NULL)) goto err101;\n  \n  /* Copy parameters of single intersection points into output-arrays. */\n  \n  kj = 0;\n  upt = vpoint; \n  stpar1 = *gpar1;\n  stpar2 = *gpar2;\n  for (ki=0; ki<(*jpt); ki++)\n    {\n      qpt = *upt;     \n      if (qpt != SISL_NULL)\n\t{  \n\t  if (qpt -> ipar != -1)\n\t    {\n\t      kj++;\n\t      stpar3 = qpt -> epar;\n\t      for (kk=0; kk<ipar1; kk++) *(stpar1++) = *(stpar3++);\n\t      for (kk=0; kk<ipar2; kk++) *(stpar2++) = *(stpar3++);\n\t    }     \n\t  \n\t  /* Free space occupied by current intersection point.  */\n\t  \n\t  freeIntpt(qpt);\n\t}\n      \n      upt++;\n    }\n  \n  *jpar = kj;\n  \n  /* Adjust output arrays to correct length.  */\n  \n  if (kj*ipar1 > 0)\n    {\n      if ((*gpar1 = increasearray(*gpar1,kj*ipar1,double)) == SISL_NULL) goto err101;\n    }\n  else \n    {\n      if (*gpar1 != SISL_NULL) freearray(*gpar1);\n      *gpar1 = SISL_NULL;\n    }\n  if (kj*ipar2 > 0)\n    {\n      if ((*gpar2 = increasearray(*gpar2,kj*ipar2,double)) == SISL_NULL) goto err101;\n    }\n  else \n    {\n      if (*gpar2 != SISL_NULL) freearray(*gpar2);\n      *gpar2 = SISL_NULL;\n    }\n  \n  /* Intersections copied to output format.  */\n  \n  *jpt = 0;\n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1880\",*jstat,kpos);\n  goto out;\n  \n  /* Error in data-strucuture. Expected intersection point not found. */\n  \n err137: *jstat = -137;\n  s6err(\"s1880\",*jstat,kpos);\n  goto out;\n  \n  /* Unknown kind of intersection type.  */\n  \n err146: *jstat = -146;\n  s6err(\"s1880\",*jstat,kpos);\n  goto out;\n  \n out: return;\n}                                   \n\n"
  },
  {
    "path": "src/s1890.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1890.c,v 1.3 2005-02-28 09:04:49 afr Exp $\n *\n */\n\n\n#define S1890\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1890 (double oknots[], int oik, int oin, double *par[], int *der[],\n       int *jstat)\n#else\nvoid\ns1890 (oknots, oik, oin, par, der, jstat)\n     double oknots[];\n     int oik;\n     int oin;\n     double *par[];\n     int *der[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    :  To produce a set of parameter values and their corresponding\n*\t\tderivative indicatores.\n*\t\tThe parameters will later be used in an interpolation problem.\n*\n* INPUT      :  oknots\t- The original knot vector.\n*\t\toik\t- The order of the basis.\n*\t\toin\t- The number of degrees of freedom in the basis given\n*\t\t\t  by the knot vector.\n*\n* OUTPUT     :  par\t- The computed parameter values.\n*\t\tder\t- The derivate indicators. (all 0.0)\n*\t\tjstat\t- Status variable:\n*\t\t\t\t\t\t> 0\t: warning\n*\t\t\t\t\t\t= 0\t: ok\n*\t\t\t\t\t\t< 0 \t: error\n*\n* METHOD     :  First one parameter value is inserted at the start parameter\n*\t\tvalue, then ik+1 knots are added successively and divided by\n*\t\tik+1 to produce internal parameter values. Then the end\n*\t\tparameter value is inserted. This procedure can result in\n*\t\tparameter values outside the legal range, these are then\n*\t\tcorrected. All parameter values are assigned derivative\n*\t\tindicator 0.\n*\n* REFERENCES :  Fortran version:\n*\t\tTor Dokken, SI, 1981-10\n*\n* CALLS      :  s6err.\n*\n* WRITTEN BY\t: Christophe R. Birkeland & Trond Vidar Stensby, SI, 1991-06\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\n  int count1, count2;\t\t/* Loop control variables     */\n  int start, stop;\n  int numb;\t\t\t/* Number of wrong parameters */\n\n  double sum;\t\t\t/* Sum of knot values         */\n  double pvl;\t\t\t/* Single parameter value     */\n  double delta;\t\t\t/* Used for correcting wrong\n\t\t\t\t * parameter values           */\n\n  *jstat = 0;\n\n\n  /* Test if legal input. */\n\n  if (oik <= 1 || oin < oik)\n    goto err112;\n\n\n  /* Test if input knot vector degenerate. */\n\n  if (oknots[oik - 1] >= oknots[oin])\n    goto err112;\n\n\n  /* Allocate arrays par and der. */\n\n  *par = newarray (oin, DOUBLE);\n  if (*par == SISL_NULL)\n    goto err101;\n  *der = new0array (oin, INT);\n  if (*der == SISL_NULL)\n    goto err101;\n\n\n  /* P R O D U C E  P A R A M E T E R   V A L U E S.\n   * First we produce parameter values by a simple algorithm.\n   * The parameter values calculated in a wrong way are then corrected. */\n\n  (*par)[0]       = oknots[oik - 1];\n  (*par)[oin - 1] = oknots[oin];\n  \n  for (count1 = 2; count1 < oin; count1++)\n    {\n      stop = count1 + oik;\n      sum = (double) 0.0;\n      for (count2 = count1; count2 <= stop; count2++)\n\tsum += oknots[count2 - 1];\n      (*par)[count1 - 1] = sum / (oik + 1);\n    }\n\n  /* Find second distinct knot value. */\n\n  pvl = oknots[oik - 1];\n  for (count1 = oik; oknots[count1] <= pvl; count1++) ;\n\n\n  /* Find number of parameter values with wrong value at start of curve. */\n\n  pvl = (oknots[oik - 1] + oknots[count1]) / (double)2.0;\n  for (numb = 0, start = 1; (*par)[start] <= pvl; start++, numb++) ;\n\n  if (numb > 0)\n    {\n      delta = (pvl - (*par)[0]) / (numb + 1);\n\n      /* Fill inn missing parameter values. */\n\n      pvl = (*par)[0] + delta;\n\n      for (count1 = 1; count1 <= numb; count1++)\n\t{\n\t  (*par)[count1] = pvl;\n\t  pvl += delta;\n\t}\n    }\n\n  /* Find last but one distinct knot value. */\n\n  pvl = oknots[oin];\n  for (count1 = oin - 1; oknots[count1] >= pvl; count1--) ;\n\n\n  /* Find end parameters in wrong interval. */\n\n  pvl = (oknots[count1] + oknots[oin + 1]) / (double) 2.0;\n  for (numb = 0, stop = oin - 2; (*par)[stop] >= pvl; stop--, numb++) ;\n\n  if (numb > 0)\n    {\n      delta = ((*par)[oin - 1] - pvl) / (numb + 1);\n      pvl = (*par)[oin - 1] - delta;\n      for (count1 = 1; count1 <= numb; count1++)\n\t{\n\t  (*par)[oin - 1 - count1] = pvl;\n\t  pvl -= delta;\n\t}\n    }\n\n  /* Make derivative indicators */\n\n  /* We used new0array which initializes all elements with zeroes \n   * and then this code is redundant.\n   *\n   * for (count1 = 0; count1 < oin; count1++)\n   *  (*der)[count1] = 0;\n   */\n  /* Knots produced */\n\n  goto out;\n\n\n  /* Not enough memory. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1890\", *jstat, kpos);\n  goto out;\n\n  /* Error in description of B-spline. */\n\nerr112:\n  *jstat = -112;\n  s6err (\"s1890\", *jstat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1891.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1891.c,v 1.2 2001-03-19 15:58:55 afr Exp $\n *\n */\n\n\n#define S1891\n\n#include \"sislP.h\"\n#define MAX_SIZE  50\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1891 (double etau[], double epoint[], int idim, int inbpnt, int iright,\n       int eder[], int iopen, double et[], double *ebcoef[], int *in,\n       int ik, int inlr, int inrc, int *jstat)\n\n#else\nvoid\ns1891 (etau, epoint, idim, inbpnt, iright, eder, iopen, et, ebcoef,\n       in, ik, inlr, inrc, jstat)\n     double etau[];\n     double epoint[];\n     int idim;\n     int inbpnt;\n     int iright;\n     int eder[];\n     int iopen;\n     double et[];\n     double *ebcoef[];\n     int *in;\n     int ik;\n     int inlr;\n     int inrc;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : \tTo compute the B-spline coefficients required for\n*\t\tinterpolation of epoint with a B-spline.\n*\n* INPUT      : \tetau\t- Parameter values (i.e. parametrization of\n*\t\t\t  points in epoint) calculated in s1890.\n*\t\tepoint\t- Point array. Contains points/derivatives.\n*\t\tidim\t- Dimension of the space in which the points\n*\t\t\t  lie.\n*\t\tinbpnt\t- Number of points/derivatives\n*\t\tiright\t- Number of right hand sides of dimension\n*\t\t\t  (idim,inbpnt)\n*\t\teder\t- Parametrization of derivatives in epoint\n*\t\t\t  (calculated in s1890)\n*\t\tiopen\t- Open or closed curve.\n*\t\tet\t- Knot vector of length (in+ik)\n*\t\t\t  Open curve:   in = inbpnt\n*\t\t\t  Closed curve: in = inbpnt+ik-1\n*\t\tik\t- Order of B-spline basis to be used\n*\t\tinlr\t- Indicates shape of matrix required for B-spline\n*\t\t\t  interpolation (see subroutines s1925 & s1926).\n*\t\tinrc\t- Indicates shape of matrix required for B-spline\n*\t\t\t  interpolation (see subroutines s1925 & s1926).\n*\n* OUTPUT     : \tebcoef\t- Guiding points for B-spline curve.\n*\t\t\t  Dimension (1:idim*in*iright)\n*\t\tin\t- Number of vertices in the B-spline curve\n*\t\t\t  produced.  Open curve:   in=inbpnt\n*\t\t\t\t     Closed curve: in=inbpnt+ik-1.\n*               jstat\t- Status variable:\n*\t\t\t  \t< 0  \t: error\n*\t\t\t\t> 0\t: warning\n*\t\t\t\t= 0\t: OK.\n*\n* METHOD     : \tSee: \tCarl De Boor: \"A practical guide to splines\"\n*\n* REFERENCES :\tFortran version:\n*\t\tE. Aarn[s, CP, 1979-01\n*\n* CALLS      :  s1925,s6err.\n*\n* WRITTEN BY : \tChristophe R. Birkeland 1991-06\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\n  int kpos = 0;\t\t\t/* Position of error\t\t\t*/\n  int ii;\t\t\t/* Loop control parameter\t\t*/\n  int limit1, limit2;\t\t/* Loop parameters\t\t\t*/\n  int kj, kl;\n  int kdum, stop;\n  int nur;\t\t\t/* Number of upper rows in W\t\t*/\n  int inlx;\t\t\t/* Equal to inlr if inlr>0, else=1 \t*/\n  int inrx;\t\t\t/* Equal to inrc if inrc>0, else=1\t*/\n  int edarray[MAX_SIZE];        /* Array for ed below                   */\n  int alloc_needed=FALSE;\n  int *ed = SISL_NULL;\t\t/* Arrays defining elements of W\t*/\n  double *ewarray=SISL_NULL;         /* Array for ew1, ew2 and ew3           */\n  double *ew1 = SISL_NULL;\t\t/* See subroutine s1926\t\t\t*/\n  double *ew2 = SISL_NULL;\n  double *ew3 = SISL_NULL;\n\n  *jstat = 0;\n\n\n  /* Test if legal input. */\n\n  if (ik < 1 || idim < 1) goto err112;\n\n  /* Indicate dimension of B-spline. */\n\n  *in = inbpnt;\n  if (iopen != SISL_CRV_OPEN)    *in +=ik - 1;\n\n  *ebcoef = new0array (*in *idim * iright, DOUBLE);\n  if (*ebcoef == SISL_NULL) goto err101;\n\n  if ((nur = inbpnt - inlr) > MAX_SIZE)\n    alloc_needed = TRUE;\n\n  /* Allocate arrays ew1, ew2, ew3, ed. */\n\n  inlx = MAX (1, inlr);\n  inrx = MAX (1, inrc);\n  limit1 = (ik * nur) + (inrx * nur) + (inlx * inbpnt);\n  \n  if ((ewarray = new0array(limit1 + 1,DOUBLE)) == SISL_NULL) goto err101;\n  \n  ew1 = ewarray;\n  ew2 = ew1 + (ik * nur);\n  ew3 = ew2 + (inrx * nur);\n\n  if (alloc_needed)\n    {\n       if ((ed = new0array(nur,INT)) == SISL_NULL)\n\t goto err101;\n    }\n  else\n    ed = edarray;\n  \n  s1925 (etau, epoint, inbpnt, eder, et, *ebcoef,*in, ik, iright, \n\t idim, ew1, nur, ed, ew2, inrc, ew3, inlr, &kstat);\n  if (kstat < 0) goto error;\n\n  /* For closed B-spline curves we have:\n   * ebcoef(i) = ebcoef(i+inbpnt) ; i=1,...,ik-1. */\n\n  if (iopen != SISL_CRV_OPEN)\n    {\n      stop = ik - 1;\n      for (kl = 0; kl < iright; kl++)\n\t{\n\t  kdum = *in *kl;\n\t  for (kj = 0; kj < stop; kj++)\n\t    {\n\t      limit2 = (kj + kdum) * idim;\n\t      limit1 = inbpnt * idim + limit2;\n\t      for (ii = 0; ii < idim; ii++)\n\t\t(*ebcoef)[limit1 + ii] = (*ebcoef)[limit2 + ii];\n\t    }\n\t}\n    }\n\n  goto out;\n\n  /* Error in lower level routine */\n\n  error:\n    *jstat = kstat;\n    s6err (\"s1891\", *jstat, kpos);\n    goto out;\n\n  /* Error in array allocations */\n\n  err101:\n    *jstat = -101;\n    s6err (\"s1891\", *jstat, kpos);\n    goto out;\n\n  /* Error in description of B-spline */\n\n  err112:\n    *jstat = -112;\n    s6err (\"s1891\", *jstat, kpos);\n    goto out;\n\n  out:\n    if (alloc_needed)    freearray (ed);\n    if (ewarray)         freearray (ewarray);\n    return;\n}\n#undef MAX_SIZE\n"
  },
  {
    "path": "src/s1893.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1893.c,v 1.3 2001-03-19 15:58:55 afr Exp $\n *\n */\n\n\n#define S1893\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1893 (SISLCurve * orig, double earray[], int dimp1, int narr, int der1,\n       int der2, SISLCurve ** ncurve, int *jstat)\n\n#else\nvoid\ns1893 (orig, earray, dimp1, narr, der1, der2, ncurve, jstat)\n     SISLCurve *orig;\n     double earray[];\n     int dimp1;\n     int narr;\n     int der1;\n     int der2;\n     SISLCurve **ncurve;\n     int *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    :  To make the function\n*\t\tF(t) = (D**der1)P(t) earray (D**der2)P(t),\n*\t\tIf earray is the identity matrix then we make the dot\n*\t\tproduct of ider1-derivate and ider2-derivate of the B-spline\n*\t\tcurve P(t) described by orig.\n*\n* INPUT      :  orig\t- The original B-spline curve, P(t).\n*\t\tearray\t- The array to be used.\n*\t\tdimp1\t- The dimension orig.idim+1. This is due to that the\n*\t\t\t  matrix earray is used for calculation with homogenous\n*\t\t\t  coordinates.\n*\t\tnarr\t- Number of parallel arrays.\n*\t\tder1\t- The order of the first derivate to be used.\n*\t\tder2\t- The order of the second derivate to be used.\n*\n* OUTPUT     :  ncurve\t- The new B-spline curve.\n*\t\tjstat\t- Status variable.\n*                        > 0     : warning\n*                        = 0     : ok\n*                        < 0     : error\n*\n* METHOD     :  The product of the der1 derivate of a B-spline curve a matrix\n*\t\tand the der2 derivate of the same B-spline curve is a B-spline\n*\t\tfunction of order 2*ik-der1-der2, if the order of the B-spline\n*\t\tcurve is ik.\n*\t\tThe subroutine has the following steps.\n*\t\t1. Calculate knot vector of B-spline function.\n*\t\t2. Calculate parameter value to be used for calculation of\n*\t\t   points on the B-spline function.\n*\t\t3. Interpolate the calculated values on the B-spline function.\n*\t\tNote: the parameter values of the B-spline function must be\n*\t\tcalculated to ensure reproduction of the B-spline function.\n*\n* REFERENCES :  Fortran version\n*\t\tTor Dokken, SI, 1982-02\n*\n* CALLS      :  s1894, s1890, s1221, s1891, s6err.\n*\n* WRITTEN BY : Trond Vidar Stensby, SI, 1991-06\n* REVISED BY : Johannes Kaasa, SI, May 1992 (Corrected the sequence of\n*              indexes in the product earray*val1*val2)\n* REVISED BY : Michael Floater, SI, June 92. The rational stuff\n*              was completely messed up. But it works now.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, September 1994.  Size of\n*              'tau' must be according to parameters passed to s1891().\n*********************************************************************\n*/\n{\n  int nik;\t\t\t/* The order of the new basis. */\n  int nin;\t\t\t/* The number of verices in the new basis. */\n  int mder;\t\t\t/* max(der1,der2) */\n  int left;\t\t\t/* Interval indicator. */\n  int pos;\t\t\t/* Used to index earray */\n  int pos1;\t\t\t/* Position of the first derivatives in the\n\t\t\t\t * array deriv. (returned form s1221); */\n  int pos2;\t\t\t/* Position of the second derivatives in the\n\t\t\t\t * array deriv. (returned form s1221); */\n  int count1, count2;\t\t/* Loop control variables. */\n  int count3=0;\n  int kr, kl, kp;\n  int *der = SISL_NULL;\t\t/* The derivative indicators. (0) */\n\n  double *nknots = SISL_NULL;\t/* The new knot vector. */\n  double *coef = SISL_NULL;\t\t/* Coefficients of the new B-spline curve. */\n  double *par = SISL_NULL;\t\t/* Parameter values used for interpolation. */\n  double *deriv = SISL_NULL;\t\t/* The derivates returned by s1221. */\n  double *val1 = SISL_NULL;\t\t/* Extracted values from deriv. */\n  double *val2 = SISL_NULL;\t\t/* Extracted values from deriv. */\n  double *tau = SISL_NULL;\t\t/* Interpolation points. */\n  double sum;\t\t\t/* Used for calculating F(t). */\n  int kpos = 0;\n  int kstat = 0;\n\n  *jstat = 0;\n\n\n  /* Test if legal input. */\n\n  if (orig->ik <= 1 || orig->in <orig->ik)\n    goto err112;\n  if ( dimp1 < orig->idim || dimp1 > orig->idim +1 )\n    goto err151;\n\n\n  /* Produce a knot vector. */\n\n  s1894 (orig->et, orig->ik, orig->in, der1, der2, earray, dimp1, narr,\n\t &nknots, &nik, &nin, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Produce parameter values and derivate indicators. */\n\n  s1890 (nknots, nik, nin, &par, &der, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Allocate arrays. */\n\n  val1 = newarray (orig->idim + 1, DOUBLE);\n  if (val1 == SISL_NULL)\n    goto err101;\n  val2 = newarray (orig->idim + 1, DOUBLE);\n  if (val2 == SISL_NULL)\n    goto err101;\n  tau = new0array (nin * narr * narr, DOUBLE);\n  /*  tau = newarray (nin * narr, DOUBLE);  (PFU 21/09-94) */\n  if (tau == SISL_NULL)\n    goto err101;\n\n  mder = max (der1, der2);\n  deriv = newarray ((mder + 1) * orig->idim, DOUBLE);\n  if (deriv == SISL_NULL)\n    goto err101;\n\n\n  /* Calculate interpolation points. */\n\n  left = 0;\n  for (count1 = 0; count1 < nin; count1++)\n    {\n      s1221 (orig, mder, par[count1], &left, deriv, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n\n      /* Extract the values/derivatives. */\n\n      pos1 = der1 * orig->idim;\n      pos2 = der2 * orig->idim;\n\n      for (count2 = 0; count2 < orig->idim; count2++)\n\t{\n\t  val1[count2] = deriv[pos1++];\n\t  val2[count2] = deriv[pos2++];\n\t}\n\n      if(orig->idim < dimp1)\n      {\n          if (der1 > 0)\n            val1[orig->idim] = (double) 0.0;\n          else\n            val1[orig->idim] = (double) 1.0;\n\n          if (der2 > 0)\n            val2[orig->idim] = (double) 0.0;\n          else\n            val2[orig->idim] = (double) 1.0;\n      }\n\n      /* Calculate the functtion F(t). */\n\n      pos = 0;\n      for (kl = 0; kl < narr; kl++)\n\t{\n\t  sum = (double) 0.0;\n\t  for (kr = 0; kr < dimp1; kr++)\n\t    {\n\t      for (kp = 0; kp < dimp1; kp++)\n\t\tsum += earray[pos++] * val1[kr] * val2[kp];\n\t      /* sum += earray[pos++] * val1[kp] * val2[kr]; */\n\t    }\n\t  tau[count3++] = sum;\n\t}\n    }\n\n  /* Caculate new curve description */\n\n  s1891 (par, tau, narr, nin, narr, der, TRUE, nknots, &coef, &nin,\n\t nik, 0, 0, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  *ncurve = newCurve (nin, nik, nknots, coef, orig->ikind, narr, 2);\n  if (*ncurve == SISL_NULL)\n    goto err171;\n  (*ncurve)->cuopen = orig->cuopen;\n\n  /* OK */\n\n  goto out;\n\n\n  /* Memory error. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1893\", *jstat, kpos);\n  goto out;\n\n  /* Could not create curve. */\n\nerr171:\n  *jstat = -171;\n  s6err (\"s1893\", *jstat, kpos);\n  goto out;\n\n  /* Error in description of B-spline. */\n\nerr112:\n  *jstat = -112;\n  s6err (\"s1893\", *jstat, kpos);\n  goto out;\n\n  /* dimp1 not equal to idim+1. */\n\nerr151:\n  *jstat = -151;\n  s6err (\"s1893\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine. */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1893\", *jstat, kpos);\n  goto out;\n\n  /* Free memory. */\n\nout:\n  if (val1 != SISL_NULL)\n    freearray (val1);\n  if (val2 != SISL_NULL)\n    freearray (val2);\n  if (der != SISL_NULL)\n    freearray (der);\n  if (par != SISL_NULL)\n    freearray (par);\n  if (deriv != SISL_NULL)\n    freearray (deriv);\n  if (tau != SISL_NULL)\n    freearray (tau);\n  return;\n}\n"
  },
  {
    "path": "src/s1894.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1894.c,v 1.3 2005-02-28 09:04:49 afr Exp $\n *\n */\n\n\n#define S1894\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1894 (double oknots[], int oik, int oin, int der1, int der2, double earray[],\n       int dimp1, int narr, double *nknots[], int *nik, int *nin, int *jstat)\n#else\nvoid\ns1894 (oknots, oik, oin, der1, der2, earray, dimp1, narr, nknots,\n       nik, nin, jstat)\n     double oknots[];\n     int oik;\n     int oin;\n     int der1;\n     int der2;\n     double earray[];\n     int dimp1;\n     int narr;\n     double *nknots[];\n     int *nik;\n     int *nin;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    :  To produce a knot vector for the dot product of two derivates\n*\t\tof a B-spline curve having the input knot vector.\n*\n* INPUT      :  oknots\t- The original knot vector.\n*\t\toik\t- The order of the original knot vector.\n*\t\toin\t- The number of degrees of freedom in the original\n*\t\t\t  knot vector.\n*\t\tder1\t- The first of the derivatives.\n*\t\tder2\t- The secondof the derivatives.\n*\t\tearray\t- Description of the array to be used.\n*\t\tdimp1\t- The dimension of the first matrix plane.\n*\t\tnarr\t- Number of parallel matrix planes.\n*\n* OUTPUT     :  nknots\t- The new knot vector.\n*\t\tnik\t- The order of the new knot vector.\n*\t\tnin\t- The number of degrees of freedom in the new\n*\t\t\t  knot vector.\n*\t\tjstat    - Status variable:\n*                                               > 0     : warning\n*                                               = 0     : ok\n*                                               < 0     : error\n*\n* METHOD     :  The order nk of the new new basis is determined.\n*\t\tThe multiplicity of the knots are counted and the right number\n*\t\tof knots inserted according to the order of the original basis\n*\t\tand the derivates involved. At et[ik] and et[in+1] nk knots\n*\t\tare inserted.\n*\n* REFERENCES :  Fortran version:\n*\t\tTor Dokken, SI, 1982-10\n*\n* CALLS      : s6err.\n*\n* WRITTEN BY :  Trond Vidar Stensby, SI, 1991-06\n* REVISED BY :  Johannes Kaasa, SI, May 92. (Taking the number of derivatives\n*               into account when calculating the multiplicity of the interior\n*               knots, to reduce the continuity in accordance with the\n*               derivatives. I also changed minimum allowed order from 1 to 2,\n*               to avoid errors in s1890).\n*\n**************************************************************** */\n{\n  int size;\t\t\t/* The total size of earray. */\n  int mult;\t\t\t/* Multiplicity of knots */\n  int numb;\t\t\t/* Number of new knots. */\n  int kdim;\t\t\t/* dimp1 -1  (sub-matrix dimension) */\n  int empty;\t\t\t/* Used to check if sub-matrix of earray\n\t\t\t\t   is zero. */\n  int kl;\t\t\t/* Loop control varibles. */\n  int count1;\n  int count2;\n  int count3;\n  int start;\n  int stop;\n\n  double eps;\t\t\t/* Resolution. */\n  double maximum;\t\t/* The maximum value in et. */\n  double prev;\t\t\t/* Knot value. (extracted from orig) */\n  double curr;\t\t\t/* Knot value. (extracted from orig) */\n  int kpos = 0;\n  int der = max(der1, der2);\n\n  *jstat = 0;\n  \n\n  /* Test if legal input. */\n\n  if (oik <= 1 || oin < oik)\n    goto err112;\n\n\n  /* Test if knot vector degenerate. */\n\n  if (oknots[oik - 1] >= oknots[oin])\n    goto err112;\n\n\n  /* The maximal number of knots to be produced at a specified knot value\n   * is the order of the B-spline basis produced. */\n\n  /* Allocate space for new knot vector */\n\n  (*nknots) = newarray ((oin + oik) * oik, DOUBLE);\n  if (*nknots == SISL_NULL)\n    goto err101;\n\n\n  /* Check if sub-matrix is zero. */\n\n  kdim = dimp1 - 1;\n  size = dimp1 * dimp1;\n  empty = TRUE;\n\n  for (count1 = 0; count1 < narr && empty; count1++)\n    for (count2 = 0; count2 < kdim && empty; count2++)\n      for (count3 = 0; count3 < kdim && empty; count3++)\n\tif (earray[count1 * size + count2 * dimp1 + count3] != (double)0.)\n\t  empty = FALSE;\n\n\n  /* Assign value to nk. */\n\n  if (empty)\n    (*nik) = oik - min (der1, der2);\n  else\n    (*nik) = 2 * oik - der1 - der2 - 1;\n  if ((*nik) < 2)\n    (*nik) = 2;\n  *nin = 0;\n\n\n  /* Make resolution to be used for testing of knot value equalness. */\n\n  eps = fabs (oknots[oin] - oknots[oik - 1]) * 1.0e-11;\n\n\n  /* Production of knots. Initiate for calculation of knots.\n     Find first knot not equal to start of curve. */\n\n  maximum = oknots[oin];\n  prev = oknots[oik - 1];\n  for (kl = oik; prev >= oknots[kl]; kl++) ;\n\n  curr = oknots[kl];\n  for (mult = oik; curr < maximum; mult++)\n    {\n      if (curr < prev)\n\tgoto err112;\n\n      if (prev > curr || curr > prev + eps)\n\t{\n\n\t  /* New knot value found. Fill in old value. */\n\n\t   /* numb = (*nik) - oik + mult; */\n\t  numb = (*nik) - oik + mult + der;\n\t  if (numb > (*nik))\n\t    numb = (*nik);\n\n\n\t  /* If numb >= nik, test if all the numb knots are equal\n\t     or if they only are equal within the resolution eps.\n\t     If not totally equal knumb=nik-1. */\n\n\t  if (numb == (*nik))\n\t    {\n\t       /* start = max (kl - oik, 1);\n\t      stop = kl - 2;\n\t      for (count1 = start; count1 <= stop; count1++)\n\t\tif (oknots[count1 - 1] != oknots[count1])\n\t\t  numb = (*nik) - 1; */\n\n\t      start = kl - oik + der;\n\t      stop = kl - 2;\n\t      for (count1 = start; count1 <= stop; count1++)\n\t\tif (oknots[count1] != oknots[count1 + 1])\n\t\t  numb = (*nik) - 1;\n\t    }\n\n\t  if (prev == oknots[oik - 1])\n\t    numb = (*nik);\n\t  for (count1 = 1; count1 <= numb; count1++)\n\t    (*nknots)[(*nin)++] = prev;\n\n\n\t  /* Initialize multiplicity. */\n\n\t  mult = 0;\n\t  prev = curr;\n\t}\n      kl++;\n      curr = oknots[kl];\n    }\n\n  /* Knot for the next last knot value not produced. */\n\n  /* numb = min ((*nik) - oik + mult, (*nik)); */\n  numb = min ((*nik) - oik + mult + der, (*nik));\n\n\n  /* If numb >= nik, test if all the numb knots are equal or if they\n   * only are equal within the resolution eps. */\n\n  /* I not totally equal numb=nik-1. */\n\n  if (numb >= (*nik))\n    {\n       /* start = max (kl - oik, 1);\n      stop = kl - 2;\n      for (count1 = start; count1 <= stop; count1++)\n\tif (oknots[count1 - 1] != oknots[count1])\n\t  numb = (*nik) - 1; */\n\n      start = kl - oik + der;\n      stop = kl - 2;\n      for (count1 = start; count1 <= stop; count1++)\n\tif (oknots[count1] != oknots[count1 + 1])\n\t  numb = (*nik) - 1;\n    }\n\n  for (count1 = 1; count1 <= numb; count1++)\n    (*nknots)[(*nin)++] = prev;\n\n\n  /* Knot at et[oin+1] not produced. */\n\n  for (count1 = 1; count1 <= (*nik); count1++)\n    (*nknots)[(*nin)++] = maximum;\n\n\n  /* Knots produced. Correct nin and length of nknots. */\n\n  (*nin) -= (*nik);\n  *nknots = increasearray (*nknots, (*nik) + (*nin), DOUBLE);\n  if (*nknots == SISL_NULL)\n    goto err101;\n\n  goto out;\n\n  /* Not enough memory. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1894\", *jstat, kpos);\n  goto out;\n\n  /* Error in description of B-spline. */\n\nerr112:\n  *jstat = -112;\n  s6err (\"s1894\", *jstat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1896.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1896.c,v 1.3 2001-03-19 15:58:55 afr Exp $\n *\n */\n\n\n#define S1896\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1896 (SISLSurf * osurf, double earray[], int dimp1, int narr, int ders1[],\n       int dert1[], int ders2[], int dert2[], SISLSurf ** nsurf, int *jstat)\n\n#else\nvoid\ns1896 (osurf, earray, dimp1, narr, ders1, dert1, ders2, dert2, nsurf, jstat)\n     SISLSurf *osurf;\n     double earray[];\n     int dimp1;\n     int narr;\n     int ders1[];\n     int dert1[];\n     int ders2[];\n     int dert2[];\n     SISLSurf **nsurf;\n     int *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    :  For each of the planes in the matrix we make the function\n*\n*\t\t     iders1\tidert1\t\t     iders2    idert2\n*\t\t  /D \\       /D \\\t\t  /D \\      /D \\\n*\tF(s,t) =   --    *    --   P(s,t) earray   --   *    --    P(s,t)\n*              \t  \\DS/       \\DT/\t\t  \\DS/      \\DT/\n*\n*\t\tHere:\n*\t\t\tiders1=ders1[i], iders2=ders2[i]\n*\t\t\tidert1=dert1[i], idert2=dert2[i]\n*\n*\t\tIf earray is the identity matrix then we make the dor product\n*\t\tof (iders1,idert1)-derivateive and (iders2,idert2)-derivative\n*\t\tof the B-spline \"surface\" P(s,t) described by osurf.\n*\n* INPUT      :  osurf\t- The original B-pline surface.\n*\t\tearray\t- The array to be used.\n*\t\tdimp1\t- The dimension idim+1. This is due to that the matrix\n*\t\t\t  earray is used for calculation with homogenous\n*\t\t\t  coordinates.\n*\t\tnarr\t- Number of parallel arrays.\n*\t\tders1\t- The derivatives to be applied in the first parameter\n*\t\t\t  direction in the first occurence of the surface.\n*\t\tdert1\t- The derivatives to be applied in the second parameter\n*\t\t\t  direction in the first occurence of the surface.\n*\t\tders2\t- The derivatives to be applied in the first parameter\n*\t\t\t  direction in the second occurence of the surface.\n*\t\tdert2\t- The derivatives to be applied in the second parameter\n*\t\t\t  direction in the second occurence of the surface.\n*\n* OUTPUT     :  nsurf\t- The new B-spline surface.\n*\t\tjstat\t- Status variable\n*                                               > 0     : warning\n*                                               = 0     : ok\n*                                               < 0     : error\n*\n* METHOD     :  The product of the (iders1,idert1)-derivative of a B-spline\n*\t\tcurve, a matrix and the (iders2,idert2)-derivative of the same\n*\t\tB-spline curve is a function of order 2*ik1-ders1-ders2-1 in\n*\t\tthe first parameter direction and 2*ik2-dert1-dert2-1 in the\n*\t\tsecond parameter direction, if the order of the B-spline\n*\t\tsurface is ik1,ik2.\n*\t\tds1 = min( ders1[i] ),\ti=1,...,narr\n*\t\tdt1 = min( dert1[i] ),\ti=1,...,narr\n*\t\tds2 = min( ders2[i] ),\ti=1,...,narr\n*\t\tdt2 = min( dert2[i] ),\ti=1,...,narr\n*\n*\t\tThe subroutine have the following steps.\n*\t\t1. Calculate knot vectors of B-spline functions.\n*\t\t2. Calculate parameter value pairs to be used for calculation\n*\t\t   of points on the B-spline function.\n*\t\t3. Interpolate the calculated values on the B-spline function.\n*\n*\t\tNote: The parameter values of the B-spline function values must\n*\t\tbe calculated to ensure reproduction of the B-spline function.\n*\n* REFERENCES :  Fortran version:\n*\t\tTor Dokken, SI, 1983-05\n*\n* CALLS      :  s1894,s1890,s1421,s1891,s6err.\n*\n* WRITTEN BY :  Trond Vidar Stensby, SI, 1991-06\n* REVISED BY :  Johannes Kaasa, SI, May 92 (Changed the order of the indexes\n*               in the multiplication of earray, val1 and val2. In addition I\n*               changed the sequence in the second assignment of ds2 and dt2.\n*               I also had to put on paranthesises in the expression for pos1\n*               and pos2).\n* REVISED BY : Michael Floater, SI, June 92. The rational stuff\n*              was completely messed up. But it works now.\n*              Dimension of output curve was wrong -- now narr.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, August 94. Fixed over-running\n*              of array indices (found with Purify).\n*\n*********************************************************************\n*/\n{\n  int nik1;\t\t\t/* Order of new surface in\n\t\t\t\t   first parameter direction. */\n  int nin1;\t\t\t/* Order of new surface in\n\t\t\t\t   second parameter direction. */\n  int nik2;\t\t\t/* Number of vertices in first\n\t\t\t\t   parameter direction. */\n  int nin2;\t\t\t/* Number of vertices in second parameter direction. */\n  int lfs;\t\t\t/* Interval indicator. (left side) */\n  int lft;\t\t\t/* Interval indicator. (left side) */\n  int tpos;\t\t\t/* Used to index array tau. */\n  int epos;\t\t\t/* Used to index earray. */\n  int pos1;\t\t\t/* Position of values of first derivatives. */\n  int pos2;\t\t\t/* Position of values of second derivatives. */\n  int ds1;\t\t\t/* Order of derivatives. */\n  int dt1;\n  int ds2;\n  int dt2;\n  int mds1;\t\t\t/* Maximum order of derivatives. */\n  int mdt1;\n  int mds2;\n  int mdt2;\n  int nder1;\t\t\t/* Total order of derivatives.\n\t\t\t\t   (Both directions) */\n  int nder2;\n  int dim;\t\t\t/* Dimension of tau. */\n  int maxder;\t\t\t/* Largest total order of derivatives.\n\t\t\t\t   (Both functions.) */\n  int count1;\t\t\t/* Loop control variables. */\n  int kj, ki;\n  int kl, kr, kp;\n  double parval[2];\n  double sum;\t\t\t/* Used for calculation of P(s,t). */\n  double *nknots1 = SISL_NULL;\t/* New knots in first parameter direction. */\n  double *nknots2 = SISL_NULL;\t/* New knots in second parameter direction. */\n  double *coef1 = SISL_NULL;\t\t/* New coeficients */\n  double *coef2 = SISL_NULL;\t\t/* New coeficients */\n  double *par1 = SISL_NULL;\t\t/* Parameter values in first direction. */\n  double *par2 = SISL_NULL;\t\t/* Parameter values in second direction. */\n  int *der1 = SISL_NULL;\t\t/* Derivative indicators in first direction. */\n  int *der2 = SISL_NULL;\t\t/* Derivative indicators in second direction.*/\n  double *deriv = SISL_NULL;\t\t/* Derivatives returned by s1421. */\n  double *normal = SISL_NULL;\t/* Normal returned by s1421. (not used) */\n  double *val1 = SISL_NULL;\t\t/* Values extracted from deriv. */\n  double *val2 = SISL_NULL;\t\t/* Values extracted from deriv. */\n  double *tau = SISL_NULL;\t\t/* Interpolation points. */\n  int kstat = 0;\n  int kpos = 0;\n\n  *jstat = 0;\n\n  /* Test if legal input. */\n\n  if (osurf->ik1 <= 1 || osurf->in1 < osurf->ik1)\n    goto err112;\n  if (osurf->ik2 <= 1 || osurf->in2 < osurf->ik2)\n    goto err112;\n\n  /* Find minimal and maximal order of derivatives */\n\n  ds1 = mds1 = ders1[0];\n  dt1 = mdt1 = dert1[0];\n  ds2 = mds2 = ders2[0];\n  dt2 = mdt2 = dert2[0];\n\n  for (count1 = 1; count1 < narr; count1++)\n    {\n      if (ds1 > ders1[count1])\tds1 = ders1[count1];\n      if (dt1 > dert1[count1])\tdt1 = dert1[count1];\n      if (ds2 > ders2[count1])\tds2 = ders2[count1];\n      if (dt2 > dert2[count1])\tdt2 = dert2[count1];\n\n      if (mds1 < ders1[count1])\tmds1 = ders1[count1];\n      if (mdt1 < dert1[count1])\tmdt1 = dert1[count1];\n      if (mds2 < ders2[count1])\tmds2 = ders2[count1];\n      if (mdt2 < dert2[count1]) mdt2 = dert2[count1];\n    }\n\n  /* Produce a knot vector in the first parameter direction. */\n\n  s1894 (osurf->et1, osurf->ik1, osurf->in1, ds1, ds2, earray, dimp1, narr,\n\t &nknots1, &nik1, &nin1, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Produce a knot vector in second parameter direction. */\n\n  s1894 (osurf->et2, osurf->ik2, osurf->in2, dt1, dt2, earray, dimp1, narr,\n\t &nknots2, &nik2, &nin2, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Produce parameter values and derivative indicators in first\n   * parameter direction. */\n\n  s1890 (nknots1, nik1, nin1, &par1, &der1, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Produce parameter values and derivative indicators in second\n   * parameter direction. */\n\n  s1890 (nknots2, nik2, nin2, &par2, &der2, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Allocate memory for point calculation. */\n\n  val1 = newarray (dimp1, DOUBLE);\n  if (val1 == SISL_NULL) goto err101;\n  val2 = newarray (dimp1, DOUBLE);\n  if (val2 == SISL_NULL) goto err101;\n  tau = newarray (narr * nin1 * nin2, DOUBLE);\n  if (tau == SISL_NULL) goto err101;\n  maxder = max (max (mds1, mds2), max (mdt1, mdt2));\n  deriv = newarray (osurf->idim * (maxder + 1) * (maxder + 2) / 2, DOUBLE);\n  if (deriv == SISL_NULL) goto err101;\n  normal = newarray (osurf->idim * (maxder + 1) * (maxder + 2) / 2, DOUBLE);\n  if (normal == SISL_NULL) goto err101;\n\n  /* Calculate interpolation points. */\n\n  lfs = 0;\n  lft = 0;\n  tpos = 0;\n  for (kj = 0; kj < nin2; kj++)\n    {\n      parval[1] = par2[kj];\n      for (ki = 0; ki < nin1; ki++)\n\t{\n\t  parval[0] = par1[ki];\n\t  epos = 0;\n\t  for (kl = 0; kl < narr; kl++)\n\t    {\n\t      ds1 = ders1[kl];\n\t      dt1 = dert1[kl];\n\t      ds2 = ders2[kl];\n\t      dt2 = dert2[kl];\n\n\t      /* ds2 = dert2[kl];\n\t      dt2 = ders2[kl]; */\n\n\t      maxder = max (max (ds1, ds2), max (dt1, dt2));\n\n\t      s1421 (osurf, maxder, parval, &lfs, &lft, deriv, normal, &kstat);\n\t      if (kstat < 0) goto error;\n\n\t      nder1 = ds1 + dt1;\n\t      nder2 = ds2 + dt2;\n\t      pos1 = osurf->idim * (nder1 * (nder1 + 1) / 2 + dt1);\n\t      pos2 = osurf->idim * (nder2 * (nder2 + 1) / 2 + dt2);\n\n\t      for (count1 = 0; count1 < osurf->idim; count1++)\n\t\t{\n\t\t  val1[count1] = deriv[pos1++];\n\t\t  val2[count1] = deriv[pos2++];\n\t\t}\n\t      if (osurf->idim < dimp1)\n\t\t{\n\t\t  val1[osurf->idim] = (double) 1.0;\n\t\t  val2[osurf->idim] = (double) 1.0;\n\t\t  if (ds1 > 0 || dt1 > 0)\n\t\t    val1[osurf->idim] = (double) 0.0;\n\t\t  if (ds2 > 0 || dt2 > 0)\n\t\t    val2[osurf->idim] = (double) 0.0;\n\t\t}\n\n\t      /* Can now calculate a interpolation point. */\n\n\t      sum = (double) 0.0;\n\t      for (kr = 0; kr < dimp1; kr++, epos += dimp1)\n\t\t{\n\t\t  for (kp = 0; kp < dimp1; kp++)\n\t\t    sum += earray[epos + kp] * val1[kr] * val2[kp];\n\t\t  /* sum += earray[epos + kp] * val1[kp] * val2[kr]; */\n\t\t}\n\t      tau[tpos++] = sum;\n\t    }\n\t}\n    }\n\n  /* Calculate new surface description. */\n\n  /* Interpolate in second parameter direction. */\n\n  dim = narr * nin1;\n\n  s1891 (par2, tau, dim, nin2, 1, der2, TRUE, nknots2, &coef1, &nin2,\n\t nik2, 0, 0, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Interpolate in first parameter direction. */\n\n  s1891 (par1, coef1, narr, nin1, nin2, der1, TRUE, nknots1, &coef2,\n\t &nin1, nik1, 0, 0, &kstat);\n  if (kstat < 0) goto error;\n\n  /* OK */\n\n  *nsurf = newSurf (nin1, nin2, nik1, nik2, nknots1, nknots2,\n\t\t    coef2, osurf->ikind, narr, 2);\n  if (*nsurf == SISL_NULL) goto err171;\n\n  goto out;\n\n  /* Not enough memory. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1896\", *jstat, kpos);\n  goto out;\n\n  /* Could not create surface, */\n\nerr171:\n  *jstat = -171;\n  s6err (\"s1896\", *jstat, kpos);\n  goto out;\n\n  /* Error in description of B-spline. */\n\nerr112:\n  *jstat = -112;\n  s6err (\"s1896\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine. */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1896\", *jstat, kpos);\n  goto out;\n\n  /* Free pointers. */\n\nout:\n  if (coef1 != SISL_NULL)    freearray (coef1);\n  if (val1 != SISL_NULL)     freearray (val1);\n  if (val2 != SISL_NULL)     freearray (val2);\n  if (par1 != SISL_NULL)     freearray (par1);\n  if (par2 != SISL_NULL)     freearray (par2);\n  if (der1 != SISL_NULL)     freearray (der1);\n  if (der2 != SISL_NULL)     freearray (der2);\n  if (normal != SISL_NULL)   freearray (normal);\n  if (deriv != SISL_NULL)    freearray (deriv);\n  if (tau != SISL_NULL)      freearray (tau);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1897.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1897.c,v 1.3 2005-02-28 09:04:49 afr Exp $\n *\n */\n\n\n#define S1897\n\n#include \"sislP.h\"\n\f\n#define MAX_IK    50\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1897 (double et[], int ik, double ax, int left, int deriv,\n       double ebiatx[], int *jstat)\n#else\nvoid\ns1897 (et, ik, ax, left, deriv, ebiatx, jstat)\n     double et[];\n     int ik;\n     double ax;\n     int left;\n     int deriv;\n     double ebiatx[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    :\tTo calculate the value of all the ideriv-th derivative\n*\t\tthe posible nonzero B-splines at ax of order ik with knot\n*\t\tsequence et.\n*\n* INPUT      :\tet\t- Knot sequence, of length left + ik, assumed to be\n*\t\t\t  non decreasing.\n*\t\t\t  DIVISION BY ZERO will result if et[left]==et[left+1]\n*\t\tik\t- The order of the B-spline.\n*\t\tax\t- The point at wich the B-splines are to be evaluated.\n*\t\tleft\t- An integer chosen so that et[left] <= ax < et[left+1]\n*\t\tderiv\t- Which derivative of the B-spline to evaluate.\n*\n* OUTPUT     :\tebiatx\t- Array of length ik, with ebiatx[i] contining the value\n*\t\t\t  at ax of the B-spline B(left-ik+i,ik,t)\n*\t\tjstat\t- Status variable:\n*                                               > 0     : warning\n*                                               = 0     : ok\n*                                               < 0     : error\n*\n* METHOD     :\n*\n* REFERENCES :\tFortran version by Tor Dokken, SI, 1982-03\n*\n* CALLS      :\n*\n* WRITTEN BY :\tTrond Vidar Stensby, SI, 1991-07\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\n  int local_array_allocated = FALSE;\n  int j;\t\t\t         /* Loop control variables.    */\n  int count;\n  double dummy;\t\t\t         /* Used for temporary calculations.*/\n  double fak;\n  double term;\n  double saved;\n  double stmp[2*MAX_IK + 1];             /* temporary storage              */\n  double *sltmp = SISL_NULL;                  /* temp storage allocated only \n\t\t\t\t\t    if ik > MAX_IK                 */\n  double *edltr = SISL_NULL;                  /* pointer into temporary storage */\n  double *edltl = SISL_NULL;                  /* pointer into temporary storage */\n  \n  /*\n   * Initialize.\n   * -----------\n   */\n\n  *jstat = 0;\n\n  if (ik > MAX_IK)\n    {\n       /*\n        * We need to allocate a larger local tmp array; Do so.\n\t* ----------------------------------------------------\n\t*/\n       \n       if ((sltmp = newarray(2 * ik + 1, DOUBLE)) == SISL_NULL)\n\t goto err101;\n       local_array_allocated = TRUE;\n       \n    }\n  else\n    sltmp = stmp;\n\n  /*\n   * Set pointer into local array.\n   * -----------------------------\n   */\n         \n  edltr = sltmp;\n  edltl = sltmp + ik;\n\n  ebiatx[0] = (double) 1.0;\n\n  for (j = 1; j <= deriv; j++)\n    {\n      edltr[j - 1] = et[left + j] - ax;\n      edltl[j - 1] = ax - et[left + 1 - j];\n      fak = (double) j;\n\n      saved = (double) 0.0;\n      for (count = 1; count <= j; count++)\n\t{\n\t  dummy = edltr[count - 1] + edltl[j - count];\n\t  if (dummy <= (double) 0.0)\n\t    goto err112;\n\n\t  term = fak * ebiatx[count - 1] / dummy;\n\t  ebiatx[count - 1] = saved - term;\n\t  saved = term;\n\t}\n      ebiatx[j] = saved;\n    }\n\n  for (; j < ik; j++)\n    {\n      edltr[j - 1] = et[left + j] - ax;\n      edltl[j - 1] = ax - et[left + 1 - j];\n      fak = ((double) j) / (double) (j - deriv);\n\n      saved = (double) 0.0;\n      for (count = 1; count <= j; count++)\n\t{\n\t  dummy = edltr[count - 1] + edltl[j - count];\n\t  if (dummy <= (double) 0.0)\n\t    goto err112;\n\n\t  term = fak * ebiatx[count - 1] / dummy;\n\t  ebiatx[count - 1] = saved + edltr[count - 1] * term;\n\t  saved = edltl[j - count] * term;\n\t}\n      ebiatx[j] = saved;\n    }\n\n  /* OK */\n\n  goto out;\n\n  /* Error in scratch allocation. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1897\", *jstat, kpos);\n  goto out;\n\n  /* Error in knot vector. */\n\nerr112:\n  *jstat = -112;\n  s6err (\"s1897\", *jstat, kpos);\n  goto out;\n\nout:\n  if (local_array_allocated)\n    freearray (sltmp);\n  return;\n}\n\n#undef MAX_IK\n"
  },
  {
    "path": "src/s1900.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1900.c,v 1.2 2001-03-19 15:58:55 afr Exp $\n *\n */\n\n\n#define S1900\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1900 (double param[], double knots[], double econd[], int ntype[],\n       int inpt, int ik, int idim, int iopen,\n       double *cendpar, SISLCurve ** rcurve,\n       double **gpar, int *jnbpar, int *jstat)\n#else\nvoid\ns1900 (param, knots, econd, ntype, inpt, ik, idim, iopen,\n       cendpar, rcurve, gpar, jnbpar, jstat)\n     double param[];\n     double knots[];\n     double econd[];\n     int ntype[];\n     int inpt;\n     int ik;\n     int idim;\n     int iopen;\n     double *cendpar;\n     SISLCurve **rcurve;\n     double **gpar;\n     int *jnbpar;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Compute a B-spline curve interpolating a set of points.\n*              The points can be assigned derivative conditions. The\n*              curve can be open, closed, or closed and periodic.\n*\n* INPUT      : param - The parametrization of the point set.\n*\t       knots - The knot vector for the point set.\n*              econd  - Array of interpolation conditions. Dimension\n*                       is inpt*idim.\n*              ntype  - Array containing kind of condition. Dimension\n*                       is inpt.\n*                       =  0 : A point is given.\n*                       =  d : The d'th derivatative condition to the\n*                              previous point is given.\n*                       = -d : The d'th derivatative condition to the\n*                              next point is given.\n*              inpt   - Number of interpolation conditions.\n*              ik     - Order of interpolating curve.\n*              idim   - Dimension of geometry space.\n*              iopen - Indicates if the curve is to be open, closed or\n*                       periodic.\n*\n* OUTPUT     : cendpar - End parameter of parametrization.\n*              rcurve  - Interpolating curve.\n*\t       gpar    - The distinct parameter values.\n*\t       jnbpar  - Number of distinct parameter values.\n*              jstat   - status messages\n*                        = 1      : Specified parametrization method\n*                                   replaced by cord length parametrization.\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     :\n*\n* REFERENCES :\n*\n* CALLS      : s1908, s1891, s1713, s1750\n*\n* WRITTEN BY : Vibeke Skytt, SI, 91-04.\n* REVISED BY : Trond Vidar Stensby, SI, 91-07\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                             */\n  int kpos = 0;\n  int ki;\t\t\t/* Counter.                                     */\n  int knpt;\t\t\t/* Number of accepted interpolation conditions. */\n  int kn;\t\t\t/* Number of coefficients of B-spline curve.    */\n  int kordr;\t\t\t/* Local order of curve.                        */\n  int kright = 1;\t\t/* One equation system to solve in interpolation. */\n  int knlr = 0;\t\t\t/* Indicates shape of interpolation matrix.     */\n  int knrc = 0;\t\t\t/* Indicates shape of interpolation matrix.     */\n  double *scoef = SISL_NULL;\t\t/* Coefficients of curve.                          */\n  int *ltype = SISL_NULL;\t\t/* Type of accepted interpolation conditions.   */\n  double *scond = SISL_NULL;\t\t/* Array containing interpolation conditions.   */\n  double *lpar = SISL_NULL;\t\t/* Array containing new parameter valued. */\n  int *sder = SISL_NULL;\t\t/* Vector of derivative indicators.                */\n  SISLCurve *qc = SISL_NULL;\t\t/* Interpolation curve.                */\n  SISLCurve *qc2 = SISL_NULL;\t/* Interpolation curve. */\n\n  *jstat = 0;\n\n  /* Test interpolation conditions */\n\n  s1908 (econd, ntype, param, inpt, ik, idim, iopen,\n\t &scond, &ltype, &lpar, &knpt, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Allocate scratch for derivative indicator. */\n\n  if ((sder = newarray (knpt, INT)) == SISL_NULL)\n    goto err101;\n\n  for (ki = 0; ki < knpt; ki++)\n    sder[ki] = (int) fabs ((double) ltype[ki]);\n\n  /* Set local order.  */\n\n  kordr = MIN (ik, knpt);\n\n  if (iopen != SISL_CRV_OPEN)\n    {\n      knlr = kordr / 2;\n      knrc = kordr - knlr - 1;\n      knpt--;\n    }\n  /* Perform interpolation.  */\n\n  s1891 (lpar, scond, idim, knpt, kright, sder, iopen, knots,\n\t &scoef, &kn, kordr, knlr, knrc, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Express the curve as a curve object.  */\n\n  qc = newCurve (kn, kordr, knots, scoef, 1, idim, 1);\n  if (qc == SISL_NULL) goto err101;\n\n  if (!(iopen == SISL_CRV_OPEN))\n    {\n      /* A closed, non-periodic curve is expected. Pick the part of the\n\t interpolation curve that has got a full basis.  */\n\n      s1713 (qc, knots[kordr - 1], knots[kn], &qc2, &kstat);\n      if (kstat < 0) goto error;\n\n      if (qc != SISL_NULL) freeCurve (qc);\n      qc = qc2;\n    }\n\n  if (kordr < ik)\n    {\n      /* The order of the curve is less than expected. Increase the order. */\n\n      qc2 = SISL_NULL;\n      s1750 (qc, ik, &qc2, &kstat);\n      if (kstat < 0) goto error;\n      if (qc != SISL_NULL) freeCurve (qc);\n      qc = qc2;\n    }\n\n  /* Set open/closed parameter of curve.  */\n\n  qc->cuopen = iopen;\n\n  /* Interpolation performed. */\n\n  /* Find distinct parameter values. */\n\n  *gpar = lpar;\n\n  *jnbpar = 1;\n  for (ki = 1; lpar[ki] < *cendpar; ki++)\n    {\n      if (lpar[ki - 1] < lpar[ki])\n\t(*gpar)[(*jnbpar)++] = lpar[ki];\n    }\n  (*gpar)[(*jnbpar)++] = lpar[ki];\n\n  *gpar = increasearray (*gpar, *jnbpar, DOUBLE);\n\n  *rcurve = qc;\n  goto out;\n\n  /* Error in scratch allocation.  */\n\n  err101:\n    *jstat = -101;\n    s6err (\"s1900\", *jstat, kpos);\n    goto out;\n\n  /* Error in lower level routine. */\n\n  error:\n    *jstat = kstat;\n    s6err (\"s1900\", *jstat, kpos);\n    goto out;\n\nout:\n  /* Free scratch occupied by local arrays. */\n\n  if (scond != SISL_NULL)    freearray (scond);\n  if (scoef != SISL_NULL)    freearray (scoef);\n  if (sder != SISL_NULL)     freearray (sder);\n  if (ltype != SISL_NULL)    freearray (ltype);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1901.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1901.c,v 1.2 2001-03-19 15:58:55 afr Exp $\n *\n */\n\n\n#define S1901\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\ntypedef void (*fparamProc)(double[], int[], int, int, int, double, double *, \n\t\t\t   double *[], double *[], int *);\ntypedef void (*fknotsProc)(double[], int, int, int, double *[], int *);\n#else\ntypedef void (*fparamProc)();\ntypedef void (*fknotsProc)();\n#endif\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1901 (fparamProc fparam, fknotsProc fknots,\n       double econd[], int ntype[], int inpt, double astpar, int ik,\n       int idim, int iopen, double *cendpar, SISLCurve ** rcurve,\n       double **gpar, int *jnbpar, int *jstat)\n#else\nvoid\ns1901 (fparam, fknots, econd, ntype, inpt, astpar, ik, idim, iopen,\n       cendpar, rcurve, gpar, jnbpar, jstat)\n     fparamProc fparam;\n     fknotsProc fknots;\n     double econd[];\n     int ntype[];\n     int inpt;\n     double astpar;\n     int ik;\n     int idim;\n     int iopen;\n     double *cendpar;\n     SISLCurve **rcurve;\n     double **gpar;\n     int *jnbpar;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Compute a B-spline curve interpolating a set of points.\n*              The points can be assigned derivative conditions. The\n*              curve can be open, closed, or closed and periodic.\n*\n* INPUT      : fparam - Routine computing parametrization of point set.\n*\t       fknots - Routine coputing knot vector of point set.\n*              econd  - Array of interpolation conditions. Dimension\n*                       is inpt*idim.\n*              ntype  - Array containing kind of condition. Dimension\n*                       is inpt.\n*                       =  0 : A point is given.\n*                       =  d : The d'th derivatative condition to the\n*                              previous point is given.\n*                       = -d : The d'th derivatative condition to the\n*                              next point is given.\n*              inpt   - Number of interpolation conditions.\n*              astpar - Start parameter of parametrization.\n*              ik     - Order of interpolating curve.\n*              idim   - Dimension of geometry space.\n*              iopen - Indicates if the curve is to be open, closed or\n*                       periodic.\n*\n* OUTPUT     : cendpar - End parameter of parametrization.\n*              rcurve  - Interpolating curve.\n*\t       gpar    - The distinct parameter values.\n*\t       jnbpar  - Number of distinct parameter values.\n*              jstat   - status messages\n*                        = 1      : Specified parametrization method\n*                                   replaced by cord length parametrization.\n*                                         = 0      : ok\n*\n* METHOD     :\n*\n* REFERENCES :\n*\n* CALLS      :\ts1905, s1891, s1713, s1750\n*\n* WRITTEN BY : Vibeke Skytt, SI, 91-04.\n* REVISED BY : Trond Vidar Stensby, SI, 91-07\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                             */\n  int kpos = 0;\n  int ki;\t\t\t/* Counter.                                     */\n  int knpt;\t\t\t/* Number of accepted interpolation conditions. */\n  int kn;\t\t\t/* Number of coefficients of B-spline curve.    */\n  int kordr;\t\t\t/* Local order of curve.                        */\n  int kright = 1;\t\t/* One equation system to solve in interpolation. */\n  int knlr = 0;\t\t\t/* Indicates shape of interpolation matrix.     */\n  int knrc = 0;\t\t\t/* Indicates shape of interpolation matrix.     */\n  int *ltype = SISL_NULL;\t\t/* Type of accepted interpolation conditions.   */\n  double *scond = SISL_NULL;\t\t/* Array containing interpolation conditions.   */\n  double *spar1 = SISL_NULL;\t\t/* Parametrization array of interpolation conditions. */\n  double *spar2 = SISL_NULL;\t\t/* Parametrization array used to make knot vector. */\n  double *sknot = SISL_NULL;\t\t/* Knot vector of curve.                           */\n  double *scoef = SISL_NULL;\t\t/* Coefficients of curve.                          */\n  int *sder = SISL_NULL;\t\t/* Vector of derivative indicators.                */\n  SISLCurve *qc = SISL_NULL;\t\t/* Interpolation curve.                            */\n  SISLCurve *qc2 = SISL_NULL;\t/* Interpolation curve.                            */\n\n  *jstat = 0;\n\n  /* Test interpolation conditions, and adjust the input conditions\n     if necessary.  */\n\n  s1905 (econd, ntype, inpt, ik, idim, iopen, &scond, &ltype, &knpt, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Set local order.  */\n\n  kordr = MIN (ik, knpt);\n\n  /* Allocate scratch for derivative indicator. */\n\n  if ((sder = newarray (knpt, INT)) == SISL_NULL)\n    goto err101;\n\n  for (ki = 0; ki < knpt; ki++)\n    sder[ki] = (int) fabs ((double) ltype[ki]);\n\n  /* Compute parametrization of point set. */\n\n  (* fparam) (scond, ltype, knpt, idim, iopen, astpar, cendpar, \n\t      &spar1, &spar2, &kstat);  \n  if (kstat < 0) goto error;\n\n  /* Make knot vector of curve.  */\n\n  if (!(iopen == SISL_CRV_OPEN))\n    {\n      /* Closed curve. */\n\n      knlr = kordr / 2;\n      knrc = kordr - knlr - 1;\n      knpt--;\n    }\n\n  /* Produce knot vector. */\n\n  (* fknots) (spar1, knpt, kordr, iopen, &sknot, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Perform interpolation.  */\n\n  s1891 (spar1, scond, idim, knpt, kright, sder, iopen, sknot,\n\t &scoef, &kn, kordr, knlr, knrc, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Express the curve as a curve object.  */\n\n  qc = newCurve (kn, kordr, sknot, scoef, 1, idim, 1);\n  if (qc == SISL_NULL) goto err101;\n\n  qc->cuopen = (iopen == SISL_CRV_OPEN) ? iopen : SISL_CRV_PERIODIC;\n\n  if (iopen == SISL_CRV_CLOSED)\n    {\n      /* A closed, non-periodic curve is expected. Pick the part of the\n\t interpolation curve that has got a full basis.  */\n\n      s1713 (qc, sknot[kordr - 1], sknot[kn], &qc2, &kstat);\n      if (kstat < 0) goto error;\n\n      if (qc != SISL_NULL) freeCurve (qc);\n      qc = qc2;\n    }\n\n  if (kordr < ik)\n    {\n      /* The order of the curve is less than expected. Increase the order. */\n\n      qc2 = SISL_NULL;\n      s1750 (qc, ik, &qc2, &kstat);\n      if (kstat < 0) goto error;\n\n      if (qc != SISL_NULL) freeCurve (qc);\n      qc = qc2;\n    }\n\n  /* Interpolation performed. */\n\n  /* Find distinct parameter values. */\n\n  *gpar = spar1;\n\n  *jnbpar = 1;\n  for (ki = 1; spar1[ki] < *cendpar; ki++)\n    {\n      if (spar1[ki - 1] < spar1[ki])\n\t(*gpar)[(*jnbpar)++] = spar1[ki];\n    }\n  (*gpar)[(*jnbpar)++] = spar1[ki];\n\n  *gpar = increasearray (*gpar, *jnbpar, DOUBLE);\n\n  *rcurve = qc;\n  goto out;\n\n\n  /* Error in scratch allocation.  */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1901\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine. */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1901\", *jstat, kpos);\n  goto out;\n\nout:\n  /* Free scratch occupied by local arrays. */\n\n  if (spar2 != SISL_NULL)\n    freearray (spar2);\n  if (scond != SISL_NULL)\n    freearray (scond);\n  if (scoef != SISL_NULL)\n    freearray (scoef);\n  if (sknot != SISL_NULL)\n    freearray (sknot);\n  if (sder != SISL_NULL)\n    freearray (sder);\n  if (ltype != SISL_NULL)\n    freearray (ltype);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1902.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1902.c,v 1.7 2001-03-19 15:58:55 afr Exp $\n *\n */\n\n\n#define S1902\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1902 (double epar[], int in, int ik, int cuopen, double **eknots, int *jstat)\n\n#else\nvoid\ns1902 (epar, in, ik, cuopen, eknots, jstat)\n     double epar[];\n     int in;\n     int ik;\n     int cuopen;\n     double **eknots;\n     int *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    :\tTo produce the knot vector of a B-spline basis satisfying the\n*\t\tinterpolation requirements reflected in the epar array.\n*\n* INPUT      :\tepar\t- Array containing a parametrization of the\n*\t\t\t  interpolation conditions. Each interpolation\n*\t\t\t  condition has got a distinct parameter value\n*\t\t\t  expect form the cases where several conditions\n*\t\t\t  are conflicting. In that case a multiple parameter\n*                         value indicates the need of a multiple knot. The\n*                         parameter values are sorted in increasing order.\n*                         The dimension of the array is 'in' if the curve is\n*\t\t\t  open and 'in+1' if it is closed.\n*               in     \t- Number of interpolation conditions.\n*               ik      - Order of B-spline basis.\n*\t\tcuopen\t- Open/closed curve.\n*\n* OUTPUT     : eknots - The produced knot vector. The dimension of\n*                       the array is in+ik if the curve is open.\n*\t\t\tIf the curve is closed the dimension of the array\n*\t\t\tis in+2*ik-1 if the curve is even and in+2*ik if it is\n*\t\t\todd.\n*              jstat  - status messages\n*\n* METHOD     :\n*\n* REFERENCES :\n*\n* CALLS      :\n*\n* WRITTEN BY :\tVibeke Skytt, SI, 91-03\n* REVISED BY :\tTrond Vidar Stensby, SI, 91-06\n*\n*********************************************************************\n*/\n{\n  int ki;\t\t\t/* Counter used to traverse the knot vector.\t*/\n  int kpar;\t\t\t/* Counter used to traverse the parametrization\n\t                      \t   array.\t\t\t\t\t*/\n  int kn;\t\t\t/* The number of conditions in epar. (closed)   */\n  int kk2;\t\t\t/* Half the order.\t\t\t\t*/\n  int kstop;\t\t\t/* Control variable of loop.            \t*/\n  int smult;\t\t\t/* Multiplisity of start parameter value        */\n  int emult;\t\t\t/* Multiplisity of end parameter value          */\n  int kmult;\n  double tprev;\t\t\t/* Value of previous knot.                     \t*/\n  double th;\t\t\t/* Value of current knot.                      \t*/\n  double tval1;\t\t\t/* Start parameter value.\t\t\t*/\n  double tval2;\t\t\t/* End parameter value.            \t\t*/\n  double tparint;\t\t/* The parameter interval. (closed)\t\t*/\n  double tdum;\t\t\t/* Help parameter used for parameter interval.\t*/\n  double dummy1, dummy2;\n  double delta;\n  int count1;\n\n  /* Check if curve is closed or open. */\n\n  if (cuopen == SISL_CRV_OPEN)\n    {\n      /* O P E N   C U R V E */\n\n      *eknots = newarray (in +ik, DOUBLE);\n      if (*eknots == SISL_NULL)\n\tgoto err101;\n\n      kk2 = ik / 2;\n      tval1 = epar[0];\n      tval2 = epar[in -1];\n\n      /* Store a knot of multiplisity equal to the order at the start of the\n\t curve The value of the knot is equal to the value of the start\n\t parameter value. */\n\n      for (ki = 0; ki < ik; ki++)\n\t(*eknots)[ki] = tval1;\n\n      /* Find the multiplisity of the start parameter value. */\n\n      for (smult = 1; epar[smult - 1] == epar[smult]; smult++) ;\n\n      /* Find the multiplisity of the end parameter value. */\n\n      for (emult = 1, count1 = in -2; epar[count1] == epar[count1 + 1];\n\t   count1--)\n\temult++;\n\n\n      if (ik % 2 == 0)\n\t{\n\t  /* The order is even.\n\t     Place the internal knots at the parameter values.  */\n\n\t  dummy1 = (double)0.5 * (epar[smult] + tval1);\n\t  dummy2 = (double)0.5 * (epar[in -emult - 1] +tval2);\n\t  if (dummy1 == dummy2)\n\t    {\n\t      dummy1 = (epar[smult] + tval1 + tval1)/(double)3;\n\t      dummy2 = (epar[in -emult - 1] + tval2 + tval2)/(double)3;\n\t    }\n\t  for (count1 = 0; count1 < smult - kk2; count1++, ki++)\n\t    (*eknots)[ki] = dummy1;\n\n\t  for (kpar = smult + MAX (0, kk2 - smult), kstop = in -emult -\n\t       MAX (0, kk2 - emult);\n\t       kpar < kstop; kpar++, ki++)\n\t    (*eknots)[ki] = epar[kpar];\n\n\t  for (count1 = 0; count1 < emult - kk2; count1++, ki++)\n\t    (*eknots)[ki] = dummy2;\n\t}\n      else\n\t{\n\t  /* The order is odd.\n\t     Place the internal knots between the parameter values.  */\n\n\t  if (smult - kk2 > 0)\n\t    {\n\t      delta = (epar[smult] - tval1) / (smult - kk2 + 1);\n\t      dummy1 = tval1 + delta;\n\t      for (count1 = 0; count1 < smult - kk2;\n\t\t   count1++, dummy1 += delta, ki++)\n\t\t(*eknots)[ki] = dummy1;\n\t    }\n\n\t  for (kpar = smult + MAX (0, kk2 - smult), kstop = in -emult -\n\t       MAX (0, kk2 - emult);\n\t       kpar < kstop; kpar++, ki++)\n\t    (*eknots)[ki] = (double) 0.5 *(epar[kpar] + epar[kpar + 1]);\n\n\t  if (emult - kk2 > 0)\n\t    {\n\t      delta = (tval2 - epar[in -emult - 1]) / (emult - kk2 + 1);\n\t      dummy2 = epar[in -emult - 1] +delta;\n\t      for (count1 = 0; count1 < emult - kk2; count1++, dummy2 +=\n\t\t   delta, ki++)\n\t\t(*eknots)[ki] = dummy2;\n\t    }\n\t}\n\n      /* Store a knot of multiplisity equal to the order at the end of\n\t the curve. The value of the knot is equal to the value of the */\n\n\n      for (ki = 0; ki < ik; ki++)\n\t(*eknots)[in +ki] = tval2;\n    }\n  else\n    {\n      /* C L O S E D   C U R V E */\n\n      *eknots = newarray (in +2 * ik, DOUBLE);\n      if (*eknots == SISL_NULL)\n\tgoto err101;\n\n      kn = in +1;\n      kk2 = ik / 2;\n      kstop = in +2 * ik - 1;\n      tparint = epar[in] -epar[0];\n\n      if (ik % 2 == 0)\n\t{\n\t  /* The order of the B-spline curve is even.\n\t     Make the ik/2 first knots as a shift of the last knots.  */\n\n\t  for (ki = 0, kpar = in -ik + ik / 2; ki < ik / 2; ki++, kpar++)\n\t    (*eknots)[ki] = epar[kpar] - tparint;\n\t  \n\t  /* Make the knots corresponding to the data points. */\n\n\t  for (kpar = 0; kpar < kn; ki++, kpar++)\n\t    (*eknots)[ki] = epar[kpar];\n\n\n\t  /* Make the ik+ik/2-2 last knots.  */\n\n\t  for (kpar = 1; ki < kstop; ki++, kpar++)\n\t    {\n\t      tdum = tparint;\n\n\t      /* We may risk that a double cyclic use of the parameter\n\t         values may result.          */\n\n\t      if (kpar > in)\n\t\t{\n\t\t  tdum += tparint;\n\t\t  kpar = 1;\n\t\t}\n\t      (*eknots)[ki] = epar[kpar] + tdum;\n\t    }\n\t}\n      else\n\t{\n\t  /* The order of the B-spline curve is odd.\n\t     Make the ik/2+1 first knots.             */\n\n\t  for (ki = 0, kpar = in -ik + ik / 2; ki < ik / 2 + 1; ki++, kpar++)\n\t    (*eknots)[ki] = (double) 0.5 *(epar[kpar] + epar[kpar + 1]) -\n\t     tparint;\n\n\t  /* Make the in next knots.  */\n\n\t  for (kpar = 0; kpar < in; ki++, kpar++)\n\t    (*eknots)[ki] = (double) 0.5 *(epar[kpar] + epar[kpar + 1]);\n\n\t  /* Make the ik remaining knots.  */\n\n\t  for (kpar = 0; ki < kstop; ki++, kpar++)\n\t    {\n\t      tdum = tparint;\n\n\t      /* We may risk that a double cyclic use of the parameter\n\t         values may result.        */\n\n\t      if (kpar >= in)\n\t\t{\n\t\t  tdum += tparint;\n\t\t  kpar = 0;\n\t\t}\n\t      (*eknots)[ki] = (double) 0.5 *(epar[kpar] + epar[kpar + 1]) + tdum;\n\t    }\n\t}\n    }\n\n\n  /* Check that the produced knots are in increasing order and that\n     the multiplicity is not greater than ik.                       */\n\n  if (cuopen == SISL_CRV_OPEN)\n    kstop = in +ik;\n\n  for (ki = 1, tprev = (*eknots)[0], kmult = 0; ki < kstop; ki++, tprev = th)\n    {\n       th = (*eknots)[ki];\n      kmult++;\n      if (tprev > th)\n\tgoto err112;\t\t/* Decreasing parameter value. */\n      if (tprev < th)\n\tkmult = 1;\n      if (kmult > ik)\n\tgoto err112;\t\t/* Knot multiplisity greater than order. */\n    }\n\n  /* The knot vector is produced.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1902\", *jstat, 0);\n  goto out;\n\n  /* Error in the knot vector.  */\n\nerr112:*jstat = -112;\n  s6err (\"s1902\", *jstat, 0);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1903.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1903.c,v 1.2 2001-03-19 15:58:55 afr Exp $\n *\n */\n\n\n#define S1903\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1903 (double epar[], int in, int ik, int cuopen, double *eknots[], int *jstat)\n\n#else\nvoid\ns1903 (epar, in, ik, cuopen, eknots, jstat)\n     double epar[];\n     int in;\n     int ik;\n     int cuopen;\n     double *eknots[];\n     int *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    :\tTo produce the knot vector of a B-spline basis satisfying the\n*\t\tinterpolation requirements reflected in the epar array.\n*\n* INPUT      :\tepar\t- Array containing a parametrization of the\n*\t\t\t  interpolation conditions. Each interpolation\n*\t\t\t  condition has got a distinct parameter value\n*\t\t\t  expect form the cases where several conditions\n*\t\t\t  are conflicting. In that case a multiple parameter\n*                         value indicates the need of a multiple knot. The\n*                         parameter values are sorted in increasing order.\n*                         The dimension of the array is 'in' if the curve is\n*\t\t\t  open and 'in+1' if it is closed.\n*               in     \t- Number of interpolation conditions.\n*               ik      - Order of B-spline basis.\n*\t\tcuopen\t- Open/closed curve.\n*\n* OUTPUT     : eknots - The produced knot vector. The dimension of\n*                       the array is in+ik if the curve is open.\n*\t\t\tIf the curve is closed the dimension of the array\n*\t\t\tis in+2*ik-1 if the curve is even and in+2*ik if it is\n*\t\t\todd.\n*              jstat  - status messages\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* CALLS      :\n*\n*\n* WRITTEN BY :\tVibeke Skytt, SI, 91-03\n* REVISED BY :\tTrond Vidar Stensby, SI, 91-06\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\n  int ki;\t\t\t/* Counter used to traverse the knot vector.\t*/\n  int kpar;\t\t\t/* Counter used to traverse the parametrization\n\t                      \t   array.\t\t\t\t\t*/\n  int kn;\t\t\t/* The number of conditions in epar. (closed)   */\n  int kk2;\t\t\t/* Half the order.\t\t\t\t*/\n  int kstop;\t\t\t/* Control variable of loop.            \t*/\n  int kmult;\t\t\t/* Multiplisity of knot.                       \t*/\n  double tprev;\t\t\t/* Value of previous knot.                     \t*/\n  double curr;\t\t\t/* Value of current knot.                      \t*/\n  double tval1;\t\t\t/* Start parameter value.\t\t\t*/\n  double tval2;\t\t\t/* End parameter value.            \t\t*/\n  double tparint;\t\t/* The parameter interval. (closed)\t\t*/\n  double tdum;\t\t\t/* Help parameter used for parameter interval.\t*/\n\n  *jstat = 0;\n\n\n  /* Check if curve is closed or open. */\n\n  if (cuopen)\n    {\n      /* O P E N   C U R V E */\n\n      *eknots = newarray (in +ik, DOUBLE);\n      if (*eknots == SISL_NULL)\n\tgoto err101;\n\n      kk2 = ik / 2;\n      tval1 = epar[0];\n      tval2 = epar[in -1];\n\n      /* Store a knot of multiplisity equal to the order at the start of the\n\t curve The value of the knot is equal to the value of the start\n\t parameter value. */\n\n      for (ki = 0; ki < ik; ki++)\n\t(*eknots)[ki] = tval1;\n\n      if (ik % 2 == 0)\n\t{\n\t  /* The order is even.\n\t     Place the internal knots at the parameter values.  */\n\n\t  for (kpar = kk2, kstop = in -kk2; kpar < kstop; kpar++, ki++)\n\t    (*eknots)[ki] = epar[kpar];\n\t}\n      else\n\t{\n\t  /* The order is odd.\n\t     Place the internal knots between the parameter values.  */\n\n\t  for (kpar = kk2, kstop = in -kk2 - 1; kpar < kstop; kpar++, ki++)\n\t    (*eknots)[ki] = (double) 0.5 *(epar[kpar] + epar[kpar + 1]);\n\t}\n\n      /* Store a knot of multiplisity equal to the order at the end of\n\t the curve. The value of the knot is equal to the value of the\n\t end parameter value.  */\n\n      for (ki = 0; ki < ik; ki++)\n\t(*eknots)[in +ki] = tval2;\n    }\n  else\n    {\n      /* C L O S E D   C U R V E */\n\n      *eknots = newarray (in +2 * ik, DOUBLE);\n      if (*eknots == SISL_NULL)\n\tgoto err101;\n\n      kn = in +1;\n      kk2 = ik / 2;\n      kstop = in +2 * ik - 1;\n      tparint = epar[in] -epar[0];\n\n      if (ik % 2 == 0)\n\t{\n\t  /* The order of the B-spline curve is even.\n\t     Make the ik-1 first knots as a shift of the last knots.  */\n\n\t  for (ki = 0, kpar = in -ik + 1; ki < ik - 1; ki++, kpar++)\n\t    (*eknots)[ki] = epar[kpar] - tparint;\n\n\t  /* Make the knots corresponding to the data points. */\n\n\t  for (kpar = 0; kpar < kn; ki++, kpar++)\n\t    (*eknots)[ki] = epar[kpar];\n\n\t  /* Make the ik-1 last knots.  */\n\n\t  for (kpar = 1; ki < kstop; ki++, kpar++)\n\t    {\n\t      tdum = tparint;\n\n\t      /* We may risk that a double cyclic use of the parameter\n\t         values may result.          */\n\n\t      if (kpar > kn)\n\t\t{\n\t\t  tdum += tparint;\n\t\t  kpar -= in;\n\t\t}\n\t      (*eknots)[ki] = epar[kpar] + tdum;\n\t    }\n\t}\n      else\n\t{\n\t  /* The order of the B-spline curve is odd.\n\t     Make the ik-1 first knots.             */\n\n\t  for (ki = 0, kpar = in -ik + 1; ki < ik - 1; ki++, kpar++)\n\t    (*eknots)[ki] = (double) 0.5 *(epar[kpar] + epar[kpar + 1]) - tparint;\n\n\t  /* Make the in next knots.  */\n\n\t  for (kpar = 0; kpar < in; ki++, kpar++)\n\t    (*eknots)[ki] = (double) 0.5 *(epar[kpar] + epar[kpar + 1]);\n\n\t  /* Make the ik remaining knots.  */\n\n\t  for (kpar = 0; ki < kstop; ki++, kpar++)\n\t    {\n\t      tdum = tparint;\n\n\t      /* We may risk that a double cyclic use of the parameter\n\t         values may result.        */\n\n\t      if (kpar > kn)\n\t\t{\n\t\t  tdum += tparint;\n\t\t  kpar -= in;\n\t\t}\n\t      (*eknots)[ki] = (double) 0.5 *(epar[kpar] + epar[kpar + 1]) + tdum;\n\t    }\n\t}\n    }\n\n\n  /* Check that the produced knots are in increasing order and that\n     the multiplicity is not greater than ik.                       */\n\n  if (cuopen)\n    kstop = in +ik;\n\n  for (ki = 1, tprev = (*eknots)[0], kmult = 0; ki < kstop; ki++, tprev = curr)\n    {\n       curr = (*eknots)[ki];\n      kmult++;\n      if (tprev > curr)\n\tgoto err112;\t\t/* Decreasing parameter value. */\n      if (tprev < curr)\n\tkmult = 1;\n      if (kmult > ik)\n\tgoto err112;\t\t/* Knot multiplisity greater than order. */\n    }\n\n  /* The knot vector is produced.  */\n\n  goto out;\n\n\n  /* Error in scratch allocation. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1903\", *jstat, kpos);\n  goto out;\n\n  /* Error in the knot vector.  */\n\nerr112:\n  *jstat = -112;\n  s6err (\"s1903\", *jstat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1904.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1904.c,v 1.2 2001-03-19 15:58:55 afr Exp $\n *\n */\n\n\n#define S1904\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1904 (double epar[], int in, int ik, int cuopen, double *eknots[], int *jstat)\n\n#else\nvoid\ns1904 (epar, in, ik, cuopen, eknots, jstat)\n     double epar[];\n     int in;\n     int ik;\n     int cuopen;\n     double *eknots[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To produce the knot vector of a B-spline basis satisfying\n*              the interpolation requirements reflected in the epar\n*              array. The knots is placed in such a way that the\n*              interpolation conditions will lie close to the points\n*              corresponding to the top point of the basis functions,\n*              using the Laksaa method. This knot placement in particularily\n*              suited when the coefficients are given, and a knot vector\n*              is to be found.\n*\n* INPUT      : epar   - Array containing a parametrization of the\n*                       interpolation conditions. Each interpolation\n*                       conditions has got a distinct parameter value\n*                       exept from the cases where several conditions\n*                       are conflicing. In that case a multiple parameter\n*                       value indicates the need of a multiple knot. The\n*                       parameter values are sorted in increasing order.\n*                       The dimension of the array is in.\n*              in     - Number of interpolation conditions.\n*              ik     - Order of B-spline basis.\n*\t       cuopen - Open/closed curve.\n*\n* OUTPUT     : eknots - The produced knot vector. The dimension of\n*                       the array is in+ik.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     :\n*\n* REFERENCES :\n*\n* CALLS      :\n*\n* WRITTEN BY :  Vibeke Skytt, SI, 91-04.\n* REVISED BY :\tTrond Vidar Stensby, SI, 91-07\n*\n*********************************************************************\n*/\n{\n  int ki;\t\t\t/* Counter used to traverse the knot vector.  \t*/\n  int kpar1, kpar2;\t\t/* Counters used to traverse the parametrization\n\t\t\t\t   array \t\t\t\t\t*/\n  int k1, k2;\t\t\t/* Numers with wich to multiply interval size.\t*/\n  int kstop;\t\t\t/* Control variable of loop.                  \t*/\n  int kmult;\t\t\t/* Multiplisity of knot.                      \t*/\n  double tdegree;\t\t/* Degree of wanted basis.  \t\t\t*/\n  double tprev;\t\t\t/* Value of previous knot.           \t        */\n  double curr;\t\t\t/* Value of current knot.           \t        */\n  double tval1;\t\t\t/* Start parameter value.          \t\t*/\n  double tval2;\t\t\t/* End parameter value.            \t\t*/\n  double tparint;\t\t/* The parameter interval.\t\t\t*/\n  int kpos = 0;\n\n  *jstat = 0;\n\n\n  if (cuopen)\n    {\n      /* O P E N   C U R V E */\n\n      *eknots = newarray (in +ik, DOUBLE);\n      if (*eknots == SISL_NULL)\n\tgoto err101;\n\n      tdegree = (double) (ik - 1);\n      tval1 = epar[0];\n      tval2 = epar[in -1];\n\n      /* Store a knot of multiplisity equal to the order in the start\n\t of the curve. The value of the knot is equal to the value\n\t of the start parameter value.  */\n\n      for (ki = 0; ki < ik; ki++)\n\t(*eknots)[ki] = tval1;\n\n      if (in -3 * ik + 4 < 0)\n\t{\n\t  /* All internal knots are affected by both endpoints.\n\t     Place internal knots.  */\n\n\t  for (; ki < in; ki++)\n\t    (*eknots)[ki] = (*eknots)[ki - 1]\n\t      + ((double) (2 * ik - ki - 1) * (epar[ki - ik + 1] - epar[ki - ik])\n\t\t + (double) (ki - in +ik - 1) *(epar[ki - 1] - epar[ki - 2])\n\t\t + epar[ki - 2] - epar[ki - ik + 1]) / tdegree;\n\t}\n      else\n\t{\n\n\t  /* Place the knots close to the startpoint.  */\n\n\t  for (; ki < 2 * ik - 2; ki++)\n\t    (*eknots)[ki] = (*eknots)[ki - 1]\n\t      + ((double) (2 * ik - ki - 1) * (epar[ki - ik + 1] - epar[ki - ik])\n\t\t + epar[ki - 1] - epar[ki - ik + 1]) / tdegree;\n\n\t  /* Place the inner knots.  */\n\n\t  for (; ki < in -ik + 2; ki++)\n\t    (*eknots)[ki] = (*eknots)[ki - 1]\n\t      + (epar[ki - 1] - epar[ki - ik]) / tdegree;\n\n\t  /* Place the knots close to the endpoint. */\n\n\t  for (; ki < in; ki++)\n\t    (*eknots)[ki] = (*eknots)[ki - 1]\n\t      + ((double) (ki - in +ik - 1) *(epar[ki - 1] - epar[ki - 2])\n\t\t + epar[ki - 2] - epar[ki - ik]) / tdegree;\n\t}\n\n      /* Store a knot of multiplisity equal to the order at the end of\n\t the curve. The value of the knot is equal to the value of the\n\t end parameter value.  */\n\n      for (ki = 0; ki < ik; ki++)\n\t(*eknots)[in +ki] = tval2;\n    }\n  else\n    {\n      /* C L O S E D   C U R V E */\n\n      *eknots = newarray (in +2 * ik, DOUBLE);\n      if (*eknots == SISL_NULL)\n\tgoto err101;\n\n      kstop = in +2 * ik - 1;\n      tparint = epar[in] -epar[0];\n      tdegree = (double) (ik - 1);\n\n      /* Set the knot starting the interval of full basis.  */\n\n      (*eknots)[ik - 1] = (ik % 2 == 0) ? epar[0] : (double) 0.5 *(epar[0] + epar[1]);\n\n      /* Compute the following knots. */\n\n      for (ki = ik, kpar1 = ki - 1, kpar2 = ki - ik, k1 = k2 = 0;\n\t   ki < kstop; ki++, kpar1++, kpar2++)\n\t{\n\t  /* Check that the indexes into the parameter array is legal. */\n\n\t  while (kpar1 < 0)\n\t    kpar1 += in, k1--;\n\t  while (kpar1 > in)\n\t    kpar1 -= in, k1++;\n\t  while (kpar2 < 0)\n\t    kpar2 += in, k2++;\n\t  while (kpar2 > in)\n\t    kpar2 -= in, k2--;\n\n\t  /* Compute knot.  */\n\n\t  (*eknots)[ki] = (*eknots)[ki - 1]\n\t    + (epar[kpar1] - epar[kpar2] + (double) (k1 + k2) * tparint) / tdegree;\n\t}\n\n      /* Compute the first ik-1 knots. */\n\n      for (ki = ik - 1, kpar1 = ki - 1, kpar2 = ki - ik, k1 = k2 = 0;\n\t   ki > 0; ki--, kpar1--, kpar2--)\n\t{\n\t  /* Check that the indexes into the parameter array is legal. */\n\n\t  while (kpar1 < 0)\n\t    kpar1 += in, k1--;\n\t  while (kpar1 > in)\n\t    kpar1 -= in, k1++;\n\t  while (kpar2 < 0)\n\t    kpar2 += in, k2++;\n\t  while (kpar2 > in)\n\t    kpar2 -= in, k2--;\n\n\t  /* Compute knot.  */\n\n\t  (*eknots)[ki - 1] = (*eknots)[ki]\n\t    - (epar[kpar1] - epar[kpar2] + (double) (k1 + k2) * tparint) / tdegree;\n\t}\n    }\n\n\n  /* Check that the produced knots are in increasing order and that\n     the multiplicity is not greater than ik.                       */\n\n  if (cuopen)\n    kstop = in +ik;\n\n  for (ki = 1, tprev = (*eknots)[0], kmult = 0; ki < kstop; ki++, tprev = curr)\n    {\n       curr = (*eknots)[ki];\n      kmult++;\n      if (tprev > curr)\n\tgoto err112;\t\t/* Decreasing parameter value. */\n      if (tprev < curr)\n\tkmult = 1;\n      if (kmult > ik)\n\tgoto err112;\t\t/* Knot multiplisity greater than order. */\n    }\n\n  /* The knot vector is produced.  */\n\n  goto out;\n\n\n  /* Error in scratch allocation. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1904\", *jstat, kpos);\n  goto out;\n\n  /* Error in the knot vector.  */\n\nerr112:\n  *jstat = -112;\n  s6err (\"s1904\", *jstat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1905.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1905.c,v 1.3 2001-03-19 15:58:55 afr Exp $\n *\n */\n\n\n#define S1905\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1905 (double econd1[], int ntype1[], int inpt1, int ik, int idim,\n       int iopen, double **gcond2, int **mtype2, int *jnpt2, int *jstat)\n#else\nvoid\ns1905 (econd1, ntype1, inpt1, ik, idim, iopen, gcond2, mtype2, jnpt2, jstat)\n     double econd1[];\n     int ntype1[];\n     int inpt1;\n     int ik;\n     int idim;\n     int iopen;\n     double **gcond2;\n     int **mtype2;\n     int *jnpt2;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Check legality of interpolation conditions, and adjust\n*              to legal conditions if possible.\n*\n* INPUT      : econd1 - Array of interpolation conditions. Dimension\n*                       is inpt1*idim.\n*              ntype1 - Array containing kind of condition. Dimension\n*                       is inpt1.\n*                       =  0 : A point is given.\n*                       =  d : The d'th derivatative condition to the\n*                              previous point is given.\n*                       = -d : The d'th derivatative condition to the\n*                              next point is given.\n*              inpt1  - Number of original interpolation conditions.\n*              ik     - Order of interpolating curve.\n*              idim   - Dimension of geometry space.\n*              iopen - Indicates if the curve is to be open, closed or\n*                       periodic.\n*\n* OUTPUT     : gcond2 - Adjusted interpolation conditions.\n*              mtype2 - Type of adusted conditions. See description of\n*                       ntype1.\n*              jnpt2  - Number of adusted interpolation conditions.\n*                       The dimension is inpt1*idim.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     :\n*\n* REFERENCES :\n*\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 91-04.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;\n  int kpos = 0;\n  int kmaxpt = inpt1 + ik*(iopen != SISL_CRV_OPEN); /* Maximum number of \n\t\t\t\t\t\t    adjusted conditions.  */\n  int knpt = 0;\t\t\t/* Current number of adjusted conditions. */\n  int ki, kj, kl;\t\t/* Counters.                              */\n  int ktype;\t\t\t/* Kind of interpolation condition.       */\n  int kneg;\t\t\t/* Indicates negative type indicator.     */\n  int kder;\t\t\t/* Order of differentiation.              */\n  int *lder = SISL_NULL;\t\t/* Kind of derivative.                    */\n  double *sdum = SISL_NULL;\t\t/* Help array.                            */\n  double tdist;                 /* Distance between first and last point. */\n  double tref;                  /* Referance value.                       */\n\n  *jstat = 0;\n\n\n  /* Allocate scratch for output arrays. Make sure that the arrays\n     are large enough.  */\n\n  if ((*gcond2 = newarray (kmaxpt * idim, DOUBLE)) == SISL_NULL)\n    goto err101;\n  if ((*mtype2 = newarray (kmaxpt, INT)) == SISL_NULL)\n    goto err101;\n\n  /* Allocate scratch for local arrays.  */\n\n  if ((lder = new0array (ik, INT)) == SISL_NULL)\n    goto err101;\n  if ((sdum = newarray (idim, DOUBLE)) == SISL_NULL)\n    goto err101;\n\n\n  /* Find first positional condition.  */\n\n  for (ki = 0; ki < inpt1; ki++)\n    if (ntype1[ki] == 0)\n      break;\n\n  lder[0] = 1;\n  (*mtype2)[0] = 0;\n  memcopy (*gcond2, econd1 + ki * idim, idim, DOUBLE);\n  knpt++;\n  ki++;\n\n  /* Move any derivative conditions to the first point after the position. */\n\n  for (kj = ki - 2; kj >= 0 && ntype1[kj] < 0; kj--)\n    {\n      ktype = abs (ntype1[kj]);\n      if (ktype >= ik)\n\tcontinue;\t\t/* Not a legal derivative condition. */\n      if (lder[ktype])\n\tcontinue;\t\t/* Derivative condition already given. */\n      lder[ktype] = 1;\n      (*mtype2)[knpt] = ktype;\n      memcopy ((*gcond2) + knpt * idim, econd1 + kj * idim, idim, DOUBLE);\n      knpt++;\n    }\n\n  /* Copy the remaining derivative conditions of the first point. */\n\n  for (; ki < inpt1 && ntype1[ki] > 0; ki++)\n    {\n      ktype = ntype1[ki];\n      if (ktype >= ik)\n\tcontinue;\t\t/* Not a legal derivative condition. */\n      if (lder[ktype])\n\tcontinue;\t\t/* Derivative condition already given. */\n      lder[ktype] = 1;\n      (*mtype2)[knpt] = ktype;\n      memcopy ((*gcond2) + knpt * idim, econd1 + ki * idim, idim, DOUBLE);\n      knpt++;\n    }\n\n  /* Traverse the remaining interpolation conditions and copy legal\n     conditions. */\n\n  for (; ki < inpt1; ki = kj)\n    {\n      /* Initiate array indicating occupied derivatives to zero. */\n\n      for (kj = 0; kj < ik; kj++)\n\tlder[kj] = 0;\n\n      /* Copy all conditions corresponding to current position. */\n\n      kneg = 1;\n      for (kj = ki; kj < inpt1 && (kneg || ntype1[kj] > 0); kj++)\n\t{\n\t  ktype = abs (ntype1[kj]);\n\t  if (ktype == 0)\n\t    kneg = 0;\t\t/* Position condition reached. */\n\t  if (ktype >= ik)\n\t    continue;\t\t/* Not a legal derivative condition. */\n\t  if (lder[ktype])\n\t    continue;\t\t/* Derivative condition already given. */\n\t  lder[ktype] = 1;\n\t  (*mtype2)[knpt] = ntype1[kj];\n\t  memcopy ((*gcond2) + knpt * idim, econd1 + kj * idim, idim, DOUBLE);\n\t  knpt++;\n\t}\n    }\n\n  if (iopen != SISL_CRV_OPEN)\n  {\n     /* Closed curve requested. Let the first positional interpolation\n\tcondition also be the last condition. First fetch derivative\n\tconditions.     */\n     \n     /* Test first if the first and last interpolation points is equal\n\talready.   */\n     \n     for (kj=ki-1; kj<=0; kj--)\n        if (ntype1[kj] == 0) break;\n     for (kl=0;  kl<inpt1; kl++)\n        if (ntype1[kl] == 0) break;\n     tdist = s6dist(econd1+kl*idim,econd1+kj*idim,idim);\n     tref = MAX(s6length(econd1+kl*idim,idim,&kstat),\n\t\ts6length(econd1+kj*idim,idim,&kstat));\n     \n     if (DNEQUAL(tdist+tref,tref))\n     {\n\t/* Initiate array indicating occupied derivatives to zero. */\n\t\n\tfor (kj = 0; kj < ik; kj++)\n\t   lder[kj] = 0;\n\t\n\t/* Fetch derivative conditions to next point. */\n\t\n\tfor (kj = ki; kj < inpt1 && ntype1[kj] < 0; kj++)\n\t{\n\t   ktype = abs (ntype1[kj]);\n\t   if (ktype >= ik)\n\t      continue;\t\t/* Not a legal derivative condition. */\n\t   if (lder[ktype])\n\t      continue;\t\t/* Derivative condition already given. */\n\t   lder[ktype] = 1;\n\t   (*mtype2)[knpt] = ntype1[kj];\n\t   memcopy ((*gcond2) + knpt * idim, econd1 + kj * idim, idim, DOUBLE);\n\t   knpt++;\n\t}\n\t\n\t/* Fetch derivative conditions prior to first point. */\n\t\n\tfor (kj = 0; kj < inpt1 && ntype1[kj] > 0; kj++)\n\t{\n\t   ktype = ntype1[kj];\n\t   if (ktype >= ik)\n\t      continue;\t\t/* Not a legal derivative condition. */\n\t   if (lder[ktype])\n\t      continue;\t\t/* Derivative condition already given. */\n\t   lder[ktype] = 1;\n\t   (*mtype2)[knpt] = -ktype;\n\t   memcopy ((*gcond2) + knpt * idim, econd1 + kj * idim, idim, DOUBLE);\n\t   knpt++;\n\t}\n\t\n\t/* Find first interpolation point and copy it. */\n\t\n\tfor (; ntype1[kj] != 0; kj++) ;\n\t\n\t(*mtype2)[knpt] = 0;\n\tmemcopy ((*gcond2) + knpt * idim, econd1 + kj * idim, idim, DOUBLE);\n\tknpt++;\n     }\n  }\n\n  /* Make sure that the last interpolation conditions are\n     of decreasing order of interpolation. */\n\n  kneg = 1;\n  for (kder = 0, ki = knpt - 1; ki >= 0 && (kneg || (*mtype2)[ki] < 0); ki--, kder--)\n    {\n      if ((*mtype2)[ki] != kder)\n\t{\n\t  for (kj = ki - 1; kj >= 0 && (kneg || (*mtype2)[kj] < 0) &&\n\t       (*mtype2)[kj] != kder; kj--) ;\n\t  if ((*mtype2)[kj] == kder)\n\t    {\n\t      /* Interchange interpolation conditions. */\n\n\t      memcopy (sdum, (*gcond2) + kj * idim, idim, DOUBLE);\n\t      memcopy ((*gcond2) + kj * idim, (*gcond2) + ki * idim, idim, DOUBLE);\n\t      memcopy ((*gcond2) + ki * idim, sdum, idim, DOUBLE);\n\t      (*mtype2)[kj] = (kder == 0) ? -(*mtype2)[ki] : (*mtype2)[ki];\n\t      (*mtype2)[ki] = kder;\n\t      if (kder == 0)\n\t\t{\n\t\t  for (kj++; kj<ki; kj++)\n\t\t    (*mtype2)[kj] *= -1;\n\t\t}\n\t    }\n\t}\n      kneg = 0;\n    }\n\n  /* Adjust size of output arrays.  */\n\n  *gcond2 = increasearray (*gcond2, knpt * idim, DOUBLE);\n  if (*gcond2 == SISL_NULL)\n    goto err101;\n  *mtype2 = increasearray (*mtype2, knpt, INT);\n  if (*mtype2 == SISL_NULL)\n    goto err101;\n\n  /* Conditions adjusted.  */\n\n  *jnpt2 = knpt;\n  goto out;\n\n\n  /* Error in scratch allocation.  */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1905\", *jstat, kpos);\n  goto out;\n\nout:\n  /* Free scratch occupied by local array. */\n\n  if (lder != SISL_NULL)\n    freearray (lder);\n  if (sdum != SISL_NULL)\n    freearray (sdum);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1906.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1906.c,v 1.2 2001-03-19 15:58:55 afr Exp $\n *\n */\n\n\n#define S1906\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1906 (double *epoint, int *etype, int icnsta, int icnend, int inbpnt,\n       int idim, double **opoint, int **otype, int *knbpnt, int *jstat)\n#else\nvoid\ns1906 (epoint, etype, icnsta, icnend, inbpnt, idim, opoint,\n       otype, knbpnt, jstat)\n     double *epoint;\n     int    *etype;\n     int    icnsta;\n     int    icnend;\n     int    inbpnt;\n     int    idim;\n     double **opoint;\n     int    **otype;\n     int    *knbpnt;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE: To transform from one type of interpolation conditions to another.\n*\n* INPUT: epoint - Array (length idim*inbpnt) containing the 'old'\n*                 interpolation conditions.\n*        etype  - Array (length inbpnt) containing type indicator for\n*                 points/derivatives/second-derivatives:\n*                  1 - Ordinary point.\n*                  2 - Knuckle point. (Is treated as an ordinary point.)\n*                  3 - Derivative to next point.\n*                  4 - Derivative to prior point.\n*                  5 - Second derivative to next point.\n*                  6 - Second derivative to prior point.\n*                 13 - Start-point of tangent to next point.\n*                 14 - End-point of tangent to prior  point.\n*        icnsta - Additional condition at the start of the curve:\n*                  0 : No additional condition.\n*                  1 : Zero curvature at start.\n*        icnend - Additional condition at the end of the curve:\n*                  0 : No additional condition.\n*                  1 : Zero curvature at end.\n*        inbpnt - No. of points/derivatives in the epoint array.\n*        idim   - The dimension of the space in which the points lie.\n*\n* OUTPUT:\n*\t opoint - The new interpolation conditions. (length idim*inbpnt)\n*        otype  - Array containing kind of condition. Dimension\n*                 is inbpnt.\n*                 =  0 : A point is given.\n*                 =  d : The d'th derivatative condition to the\n*                        previous point is given.\n*                 = -d : The d'th derivatative condition to the\n*                        next point is given.\n*        knbpnt - no. of points.\n*\t jstat\t- Status variable.\n*                  > 0     : warning\n*                  = 0     : ok\n*                  < 0     : error\n*\n* METHOD     :\n*\n* REFERENCES :\n*\n* CALLS      : s6err.\n*\n* WRITTEN BY :  Trond Vidar Stensby, SI, 1991-07\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\n  int count, count2;\t\t/* Loop control variables. */\n  int dummy;\t\t\t/* Dummy variables used when adressing arrays. */\n  int start, start2;\n\n  *jstat = 0;\n\n\n  /* Allocate output arrays. */\n\n  if (icnsta && icnend)\n    *knbpnt = inbpnt + 2;\n  else if (icnsta || icnend)\n    *knbpnt = inbpnt + 1;\n  else\n    *knbpnt = inbpnt;\n\n  *opoint = newarray ((*knbpnt) * idim, DOUBLE);\n  if (*opoint == SISL_NULL)\n    goto err101;\n  *otype = newarray (*knbpnt, INT);\n  if (*otype == SISL_NULL)\n    goto err101;\n\n\n  /* Insert additional interpolation conditions. */\n\n  if (icnsta != 0)\n    {\n      for (count = 0; count < idim; count++)\n\t(*opoint)[count] = (double) 0.0;\n\n      (*otype)[0] = -2;\n    }\n\n  if (icnend != 0)\n    {\n      dummy = (*knbpnt) * idim;\n      for (count = ((*knbpnt) - 1) * idim; count < dummy; count++)\n\t(*opoint)[count] = (double) 0.0;\n\n      (*otype)[(*knbpnt) - 1] = 2;\n    }\n\n  /* Copy the rest of the points. */\n\n  if (icnsta != 0)\n    start = 1;\n  else\n    start = 0;\n\n  for (count = 0; count < inbpnt; count++)\n    {\n      /* Transfor interpolation conditions. */\n\n      if (etype[count] == 13)\n\t{\n\t  start2 = (count + start) * idim;\n\t  for (count2 = 0; count2 < idim; count2++)\n\t    {\n\t      (*opoint)[start2 + count2] = epoint[(count + 1) * idim + count2] -\n\t\tepoint[count * idim + count2];\n\t    }\n\t}\n      else if (etype[count] == 14)\n\t{\n\t  start2 = (count + start) * idim;\n\t  for (count2 = 0; count2 < idim; count2++)\n\t    {\n\t      (*opoint)[start2 + count2] = epoint[count * idim + count2] -\n\t\tepoint[(count - 1) * idim + count2];\n\t    }\n\t}\n      else\n\t{\n\t  start2 = (count + start) * idim;\n\t  for (count2 = 0; count2 < idim; count2++)\n\t    {\n\t      (*opoint)[start2 + count2] = epoint[count * idim + count2];\n\t    }\n\t}\n\n      /* Transform derivative indicators. */\n\n      if (etype[count] == 1 || etype[count] == 2)\n\t(*otype)[count + start] = 0;\n      else if (etype[count] == 3)\n\t(*otype)[count + start] = -1;\n      else if (etype[count] == 4)\n\t(*otype)[count + start] = 1;\n      else if (etype[count] == 5)\n\t(*otype)[count + start] = -2;\n      else if (etype[count] == 6)\n\t(*otype)[count + start] = 2;\n      else if (etype[count] == 13)\n\t(*otype)[count + start] = -1;\n      else if (etype[count] == 14)\n\t(*otype)[count + start] = 1;\n    }\n\n  /* Ok. */\n\n  goto out;\n\n\n  /* Error in scratch allocation. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1906\", *jstat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1907.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1907.c,v 1.3 2005-02-28 09:04:49 afr Exp $\n *\n */\n\n\n#define S1907\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1907(double *epoint, int *ntype, double *epar, int iopen, int icnsta,\n\t   int icnend, int inbpnt, int idim, double *opoint[], int *otype[],\n\t   double *opar[], int *knbpnt, int *jstat)\n#else\nvoid s1907(epoint, ntype, epar, iopen, icnsta, icnend, inbpnt, idim,\n\t   opoint, otype, opar, knbpnt, jstat)\n     double *epoint;\n     int *ntype;\n     double *epar;\n     int iopen;\n     int icnsta;\n     int icnend;\n     int inbpnt;\n     int idim;\n     double *opoint[];\n     int *otype[];\n     double *opar[];\n     int *knbpnt;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE: To transform from one type of interpolation conditions to\n*\t   another. Parameter values are also transformed.\n*\n* INPUT: epoint - Array (length idim*inbpnt) containing the 'old'\n*                 interpolation conditions.\n*        ntype  - Array (length inbpnt) containing type indicator for\n*                 points/derivatives/second-derivatives:\n*                  1 - Ordinary point.\n*                  2 - Knuckle point. (Is treated as an ordinary point.)\n*                  3 - Derivative to next point.\n*                  4 - Derivative to prior point.\n*                  5 - Second derivative to next point.\n*                  6 - Second derivative to prior point.\n*                 13 - Start-point of tangent to next point.\n*                 14 - End-point of tangent to prior  point.\n*\t epar   - Array containing wanted paramerization for the\n*\t\t  interpolation points.\n*        iopen  - Open / closed flag.\n*        icnsta - Additional condition at the start of the curve:\n*                  0 : No additional condition.\n*                  1 : Zero curvature at start.\n*        icnend - Additional condition at the end of the curve:\n*                  0 : No additional condition.\n*                  1 : Zero curvature at end.\n*        inbpnt - No. of points/derivatives in the epoint array.\n*        idim   - The dimension of the space in which the points lie.\n*\n* OUTPUT:\n*\t opoint - The new interpolation conditions. (length idim*inbpnt)\n*        otype  - Array containing kind of condition. Dimension\n*                 is inbpnt.\n*                 =  0 : A point is given.\n*                 =  d : The d'th derivatative condition to the\n*                        previous point is given.\n*                 = -d : The d'th derivatative condition to the\n*                        next point is given.\n*\t opar   - The new parametrization. The derivative conditions are\n*\t\t  given the same parameter value as the point they belong to.\n*        knbpar - no. of points.\n*\t stat   - Status variable.\n*                                     > 0     : warning\n*                                     = 0     : ok\n*                                     < 0     : error\n:\n*\n* METHOD     :\n*\n* REFERENCES :\n*\n* CALLS      : s6dist,s6err.\n*\n* WRITTEN BY :  Trond Vidar Stensby, SI, 1991-07\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\n  int count1, count2;\t\t/* Loop control variables. */\n  int dummy;\n  int start, start2;\n  int cpv;\t\t\t/* Current parameter value. */\n\n  *jstat = 0;\n\n\n  /* Allocate output arrays. */\n\n  if (icnsta && icnend)\n    *knbpnt = inbpnt + 2;\n  else if (icnsta || icnend)\n    *knbpnt = inbpnt + 1;\n  else\n    *knbpnt = inbpnt;\n\n  *opoint = newarray ((*knbpnt) * idim, DOUBLE);\n  if (*opoint == SISL_NULL)\n    goto err101;\n  *otype = newarray (*knbpnt, INT);\n  if (*otype == SISL_NULL)\n    goto err101;\n\n  if (iopen == SISL_CRV_OPEN)\n    *opar = newarray (*knbpnt, DOUBLE);\n  else\n    *opar = newarray (*knbpnt + 1, DOUBLE);\n  if (*opar == SISL_NULL)\n    goto err101;\n\n\n  /* Insert additional interpolation conditions. */\n\n  if (icnsta != 0)\n    {\n      for (count1 = 0; count1 < idim; count1++)\n\t(*opoint)[count1] = (double) 0.0;\n\n      (*otype)[0] = -2;\n      (*opar)[0] = epar[0];\n    }\n\n  if (icnend != 0)\n    {\n      dummy = (*knbpnt) * idim;\n      for (count1 = ((*knbpnt) - 1) * idim; count1 < dummy; count1++)\n\t(*opoint)[count1] = (double) 0.0;\n\n      (*otype)[(*knbpnt) - 1] = 2;\n    }\n\n  /* Copy the rest of the points. */\n\n  if (icnsta != 0)\n    start = 1;\n  else\n    start = 0;\n\n  cpv = -1;\n\n  for (count1 = 0; count1 < inbpnt; count1++)\n    {\n      /* Transfor interpolation conditions. */\n\n      if (ntype[count1] == 13)\n\t{\n\t  start2 = (count1 + start) * idim;\n\t  for (count2 = 0; count2 < idim; count2++)\n\t    {\n\t      (*opoint)[start2 + count2] = epoint[(count1 + 1) * idim + count2] -\n\t\tepoint[count1 * idim + count2];\n\t    }\n\t}\n      else if (ntype[count1] == 14)\n\t{\n\t  start2 = (count1 + start) * idim;\n\t  for (count2 = 0; count2 < idim; count2++)\n\t    {\n\t      (*opoint)[start2 + count2] = epoint[count1 * idim + count2] -\n\t\tepoint[(count1 - 1) * idim + count2];\n\t    }\n\t}\n      else\n\t{\n\t  start2 = (count1 + start) * idim;\n\t  for (count2 = 0; count2 < idim; count2++)\n\t    {\n\t      (*opoint)[start2 + count2] = epoint[count1 * idim + count2];\n\t    }\n\t}\n\n      /* Transform derivative indicators. */\n\n      if (ntype[count1] == 1 || ntype[count1] == 2)\n\t{\n\t  (*otype)[count1 + start] = 0;\n\t  cpv++;\n\t  (*opar)[count1 + start] = epar[cpv];\n\t}\n      else if (ntype[count1] == 3)\n\t{\n\t  (*otype)[count1 + start] = -1;\n\t  (*opar)[count1 + start] = epar[cpv + 1];\n\t}\n      else if (ntype[count1] == 4)\n\t{\n\t  (*otype)[count1 + start] = 1;\n\t  (*opar)[count1 + start] = epar[cpv];\n\t}\n      else if (ntype[count1] == 5)\n\t{\n\t  (*otype)[count1 + start] = -2;\n\t  (*opar)[count1 + start] = epar[cpv + 1];\n\t}\n      else if (ntype[count1] == 6)\n\t{\n\t  (*otype)[count1 + start] = 2;\n\t  (*opar)[count1 + start] = epar[cpv];\n\t}\n      else if (ntype[count1] == 13)\n\t{\n\t  (*otype)[count1 + start] = -1;\n\t  (*opar)[count1 + start] = epar[cpv + 1];\n\t}\n      else if (ntype[count1] == 14)\n\t{\n\t  (*otype)[count1 + start] = 1;\n\t  (*opar)[count1 + start] = epar[cpv];\n\t}\n    }\n\n  if (icnend != 0)\n    (*opar)[(*knbpnt) - 1] = epar[cpv];\n\n  if (!(iopen == SISL_CRV_OPEN))\n    {\n     /* UJK, Following calculations not necessary, \n      * Parameter value given as input.\n        \n        Calculate distance between first and last point.\n        \n        for (count1 = 0; count1 < (*knbpnt) && (*otype)[count1] != 0; \n\t     count1++);\n        for (count2 = (*knbpnt) - 1; count2 >= 0 && (*otype)[count2] != 0; \n\t     count2--);\n        if (count1 > (*knbpnt) || count2 < 0) goto err164;\n        \n        (*opar)[*knbpnt] = (*opar)[(*knbpnt) - 1] +\n        s6dist (&(*opoint)[count1 * idim], &(*opoint)[count2 * idim], idim); \n\n      */\n\n     cpv++;\n     (*opar)[*knbpnt] = epar[cpv];     \n   }\n\n  /* OK */\n\n  goto out;\n\n/*  UJK + CBI, not used:  \n    No point conditions specified.\n\n    err164:\n      *jstat = -164;\n      s6err (\"s1907\", *jstat, kpos);\n      goto out;\n*/\n\n  /* Allocation error. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1907\", *jstat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1908.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1908.c,v 1.2 2001-03-19 15:58:55 afr Exp $\n *\n */\n\n\n#define S1908\n\n#include \"sislP.h\"\n#define MAX_SIZE  30\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1908 (double econd1[], int ntype1[], double epar[], int inpt1, int ik, int idim,\n       int iopen, double **gcond2, int **mtype2, double *mpar[],\n       int *jnpt2, int *jstat)\n#else\nvoid\ns1908 (econd1, ntype1, epar, inpt1, ik, idim, iopen,\n       gcond2, mtype2, mpar, jnpt2, jstat)\n     double econd1[];\n     int ntype1[];\n     double epar[];\n     int inpt1;\n     int ik;\n     int idim;\n     int iopen;\n     double *gcond2[];\n     int *mtype2[];\n     double *mpar[];\n     int *jnpt2;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Check legality of interpolation conditions, and adjust\n*              to legal conditions if possible. The legal parameter values\n*\t       are also sent back.\n*\n* INPUT      : econd1 - Array of interpolation conditions. Dimension\n*                       is inpt1*idim.\n*              ntype1 - Array containing kind of condition. Dimension\n*                       is inpt1.\n*                       =  0 : A point is given.\n*                       =  d : The d'th derivatative condition to the\n*                              previous point is given.\n*                       = -d : The d'th derivatative condition to the\n*                              next point is given.\n*\t       epar   - The parameter values. In the open case the lenght\n*                       of this array is inpt1. In the closed or periodic\n*                       case the length is inpt1+1. The last entry contains\n*                       the parametrization of the repeted start point.\n*                       (if the endpoint is equal to the startpoint of\n*                        the interpolation the lenght of the array should\n*                        be equal to inpt1 also in the closed case).\n*              inpt1  - Number of original interpolation conditions.\n*              ik     - Order of interpolating curve.\n*              idim   - Dimension of geometry space.\n*              iopen - Indicates if the curve is to be open, closed or\n*                       periodic.\n*\n*\n* OUTPUT     : gcond2 - Adjusted interpolation conditions.\n*              mtype2 - Type of adusted conditions. See description of\n*                       ntype1.\n*\t       mpar   - The adjusted parameter values.\n*              jnpt2  - Number of adusted interpolation conditions.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*\n* METHOD     :\n*\n* REFERENCES :\n*\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 91-04.\n* REVISED BY : Trond Vidar Stensby, SI, 91-07\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;\n  int kmaxpt = inpt1+ik*(iopen!=SISL_CRV_OPEN);  /* Maximum number of \n\t\t\t\t\t\t adjusted conditions. */\n  int knpt = 0;\t\t\t/* Current number of adjusted conditions. */\n  int ki, kj, kl;\t\t/* Counters.                              */\n  int ktype;\t\t\t/* Kind of interpolation condition.       */\n  int kneg;\t\t\t/* Indicates negative type indicator.     */\n  int kder;\t\t\t/* Order of differentiation.              */\n  int lderarray[MAX_SIZE];\n  int alloc_needed=FALSE;\n  int *lder = SISL_NULL;\t\t/* Kind of derivative.                    */\n  double *sdum = SISL_NULL;\t        /* Help array.                            */\n  double tdist;                 /* Distance between first and last point. */\n  double tref;                  /* Referance value.                       */\n\n  if ((sdum = newarray (idim, DOUBLE)) == SISL_NULL)\n     goto err101;\n\n  /* Allocate scratch for output arrays. Make sure that the arrays\n     are large enough.  */\n\n  *gcond2 = SISL_NULL;\n  if ((*gcond2 = newarray (kmaxpt * idim, DOUBLE)) == SISL_NULL)\n    goto err101;\n  *mtype2 = SISL_NULL;\n  if ((*mtype2 = newarray (kmaxpt, INT)) == SISL_NULL)\n    goto err101;\n  *mpar = SISL_NULL;\n  if ((*mpar = newarray (kmaxpt, DOUBLE)) == SISL_NULL)\n    goto err101;\n\n  /* Allocate scratch for local arrays.  */\n\n  if (ik > MAX_SIZE)\n    {\n       if ((lder = new0array (ik, INT)) == SISL_NULL)\n         goto err101;\n       alloc_needed = TRUE;\n    }\n  else\n    {\n       lder = lderarray;\n       memzero(lder,MAX_SIZE,INT);\n    }\n\n  \n  /* Find first positional condition.  */\n\n  for (ki = 0; ki < inpt1; ki++)\n    if (ntype1[ki] == 0)\n      break;\n\n  lder[0] = 1;\n  (*mtype2)[0] = 0;\n  (*mpar)[0] = epar[ki];\n  memcopy (*gcond2, econd1 + ki * idim, idim, DOUBLE);\n  knpt++;\n  ki++;\n\n  /* Move any derivative conditions to the first point after the position. */\n\n  for (kj = ki - 2; kj >= 0 && ntype1[kj] < 0; kj--)\n    {\n      ktype = abs (ntype1[kj]);\n      if (ktype >= ik)\n\tcontinue;\t\t/* Not a legal derivative condition. */\n      if (lder[ktype])\n\tcontinue;\t\t/* Derivative condition already given. */\n      lder[ktype] = 1;\n      (*mtype2)[knpt] = ktype;\n      (*mpar)[knpt] = epar[kj];\n      memcopy ((*gcond2) + knpt * idim, econd1 + kj * idim, idim, DOUBLE);\n      knpt++;\n    }\n\n  /* Copy the remaining derivative conditions of the first point. */\n\n  for (; ki < inpt1 && ntype1[ki] > 0; ki++)\n    {\n      ktype = ntype1[ki];\n      if (ktype >= ik)\n\tcontinue;\t\t/* Not a legal derivative condition. */\n      if (lder[ktype])\n\tcontinue;\t\t/* Derivative condition already given. */\n      lder[ktype] = 1;\n      (*mtype2)[knpt] = ktype;\n      (*mpar)[knpt] = epar[ki];\n      memcopy ((*gcond2) + knpt * idim, econd1 + ki * idim, idim, DOUBLE);\n      knpt++;\n    }\n\n  /* Traverse the remaining interpolation conditions and copy legal\n     conditions. */\n\n  for (; ki < inpt1; ki = kj)\n    {\n      /* Initiate array indicating occupied derivatives to zero. */\n\n      for (kj = 0; kj < ik; kj++)\n\tlder[kj] = 0;\n\n      /* Copy all conditions corresponding to current position. */\n\n      kneg = 1;\n      for (kj = ki; kj < inpt1 && (kneg || ntype1[kj] > 0); kj++)\n\t{\n\t  ktype = abs (ntype1[kj]);\n\t  if (ktype == 0)\n\t    kneg = 0;\t\t/* Position condition reached. */\n\t  if (ktype >= ik)\n\t    continue;\t\t/* Not a legal derivative condition. */\n\t  if (lder[ktype])\n\t    continue;\t\t/* Derivative condition already given. */\n\t  lder[ktype] = 1;\n\t  (*mtype2)[knpt] = ntype1[kj];\n\t  (*mpar)[knpt] = epar[kj];\n\t  memcopy ((*gcond2) + knpt * idim, econd1 + kj * idim, idim, DOUBLE);\n\t  knpt++;\n\t}\n    }\n\n  if (iopen != SISL_CRV_OPEN)\n  {\n     /* Closed curve requested. Let the first positional interpolation\n\tcondition also be the last condition. First fetch derivative\n\tconditions.     */\n     \n     /* Test first if the first and last interpolation points is equal\n\talready.   */\n     \n     for (kj=ki-1; kj<=0; kj--)\n        if (ntype1[kj] == 0) break;\n     for (kl=0;  kl<inpt1; kl++)\n        if (ntype1[kl] == 0) break;\n     tdist = s6dist(econd1+kl*idim,econd1+kj*idim,idim);\n     tref = MAX(s6length(econd1+kl*idim,idim,&kstat),\n\t\ts6length(econd1+kj*idim,idim,&kstat));\n     \n     if (DNEQUAL(tdist+tref,tref))\n     {\n\t/* Initiate array indicating occupied derivatives to zero. */\n\t\n\tfor (kj = 0; kj < ik; kj++)\n\t   lder[kj] = 0;\n\t\n\t/* Fetch derivative conditions to next point. */\n\t\n\tfor (kj = ki; kj < inpt1 && ntype1[kj] < 0; kj++)\n\t{\n\t   ktype = abs (ntype1[kj]);\n\t   if (ktype >= ik)\n\t      continue;\t\t/* Not a legal derivative condition. */\n\t   if (lder[ktype])\n\t      continue;\t\t/* Derivative condition already given. */\n\t   lder[ktype] = 1;\n\t   (*mtype2)[knpt] = ntype1[kj];\n\t   (*mpar)[knpt] = epar[kj];\n\t   memcopy ((*gcond2) + knpt * idim, econd1 + kj * idim, idim, DOUBLE);\n\t   knpt++;\n\t}\n\t\n\t/* Fetch derivative conditions prior to first point. */\n\t\n\tfor (kj = 0; kj < inpt1 && ntype1[kj] > 0; kj++)\n\t{\n\t   ktype = ntype1[kj];\n\t   if (ktype >= ik)\n\t      continue;\t\t/* Not a legal derivative condition. */\n\t   if (lder[ktype])\n\t      continue;\t\t/* Derivative condition already given. */\n\t   lder[ktype] = 1;\n\t   (*mtype2)[knpt] = -ktype;\n\t   (*mpar)[knpt] = epar[inpt1];\n\t   memcopy ((*gcond2) + knpt * idim, econd1 + kj * idim, idim, DOUBLE);\n\t   knpt++;\n\t}\n\t\n\t/* Find first interpolation point and copy it. */\n\t\n\tfor (kj = 0; ntype1[kj] != 0; kj++) ;\n\tfor (ki = inpt1 - 1; ntype1[ki] != 0; ki--) ;\n\t\n\t(*mtype2)[knpt] = 0;\n\t\n\t/* UJK & CBI      \n\t   Replacing     (*mpar)[knpt] = epar[ki] + epar[inpt1]; \n\t   with                                                   */\n\t\n\t(*mpar)[knpt] = epar[inpt1]; \n\t\n\tmemcopy ((*gcond2) + knpt * idim, econd1 + kj * idim, idim, DOUBLE);\n\tknpt++;\n     }\n  }\n\n  /* Make sure that the last interpolation conditions are\n     of decreasing order of interpolation. */\n\n  kneg = 1;\n  for (kder = 0, ki = knpt - 1; ki >= 0 && (kneg ||\n\t\t\t\t\t    (*mtype2)[ki] < 0); ki--, kder--)\n    {\n      if ((*mtype2)[ki] != kder)\n\t{\n\t  for (kj = ki - 1; kj >= 0 && (kneg || (*mtype2)[kj] < 0) &&\n\t       (*mtype2)[kj] != kder; kj--) ;\n\t  if ((*mtype2)[kj] == kder)\n\t    {\n\t      /* Interchange interpolation conditions. */\n\n\t      memcopy (sdum, (*gcond2) + kj * idim, idim, DOUBLE);\n\t      memcopy ((*gcond2) + kj * idim, (*gcond2) + ki * idim,\n\t\t       idim, DOUBLE);\n\t      memcopy ((*gcond2) + ki * idim, sdum, idim, DOUBLE);\n\t      (*mtype2)[kj] = (kder == 0) ? -(*mtype2)[ki] : (*mtype2)[ki];\n\t      (*mtype2)[ki] = kder;\n\t    }\n\t}\n      kneg = 0;\n    }\n\n/* UJK & CBI: The following additional parameter value is not used\n\n  if (iopen != SISL_CRV_OPEN)\n    {\n      (*mpar)[knpt] = (*mpar)[knpt - 1];\n      kpar = knpt + 1;\n    }\n  else\n    kpar = knpt;\n\n*/\n\n  /* Conditions adjusted.  */\n\n  *jnpt2 = knpt;\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation.  */\n\n  err101:\n    *jstat = -101;\n    s6err (\"s1908\", *jstat, 0);\n    goto out;\n\n  out:\n    /* Free scratch occupied by local array. */\n\n    if (alloc_needed) freearray (lder);\n    if(sdum != SISL_NULL)  freearray(sdum);\n    return;\n}\n"
  },
  {
    "path": "src/s1909.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1909.c,v 1.2 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1909\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1909 (double econd[], int ntype[], int inpt, int idim, int iopen,\n       double astpar, double *cendpar, double *epar1[],\n       double *epar2[], int *jstat)\n#else\nvoid\ns1909 (econd, ntype, inpt, idim, iopen, astpar, cendpar, epar1, epar2, jstat)\n     double econd[];\n     int ntype[];\n     int inpt;\n     int idim;\n     int iopen;\n     double astpar;\n     double *cendpar;\n     double *epar1[];\n     double *epar2[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Make cord length parametrization of interpolation\n*              conditions. Derivative conditions are given the same value\n*\t       as the corresponding point condition.\n*\n* INPUT      : econd  - Array of interpolation conditions. The last\n*                       condition must be a point. Dimension is inpt*idim.\n*              ntype  - Array containing kind of condition. Dimension\n*                       is inpt.\n*                       =  0 : A point is given.\n*                       =  d : The d'th derivatative condition to the\n*                              previous point is given.\n*                       = -d : The d'th derivatative condition to the\n*                              next point is given.\n*              inpt   - Number of interpolation conditions.\n*              idim   - Dimension of geometry space.\n*\t       iopen  - Open/closed curve.\n*              astpar - Start parameter of parametrization.\n*\n* OUTPUT     : cendpar - End parameter of parametrization.\n*              epar1   - Parametrization array. Derivative conditions has\n*                        got the same parameter value as the corresponding\n*                        positional condition.\n*              epar2   - Parametrization array to use when making a knot\n*                        vector. All entries are different.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     :\n*\n* REFERENCES :\n*\n* CALLS      : s6dist,s6err.\n*\n* WRITTEN BY : Trond Vidar Stensby, SI, 1991-07\n*\n*********************************************************************\n*/\n{\n  int count1, count2, count3;\t/* Loop control variables. */\n  int knpt;\t\t\t/* Number of parameter values to\n\t\t\t\t   be produced. */\n\n  double kpar, npar;\t\t/* Used when calculating\n\t\t\t\t   the parameter values. */\n  int kpos = 0;\n\n  *jstat = 0;\n\n\n  if (iopen != SISL_CRV_OPEN)\n    knpt = inpt + 1;\n  else\n    knpt = inpt;\n\n\n  /* Allocate arrays. */\n\n  *epar1 = newarray (knpt, DOUBLE);\n  if (*epar1 == SISL_NULL)\n    goto err101;\n\n  *epar2 = newarray (knpt, DOUBLE);\n  if (*epar2 == SISL_NULL)\n    goto err101;\n\n  (*epar1)[0] = astpar;\n  kpar = astpar;\n\n  for (count1 = 1, kpar = astpar; count1 < inpt; count1++)\n    {\n      if (ntype[count1] == 0)\n\t{\n\t  kpar += s6dist (&econd[(count1 - 1) * idim], &econd[count1 * idim], idim);\n\t  (*epar1)[count1] = kpar;\n\t}\n      else\n\t{\n\t  /* Find next value. */\n\n\t  for (count2 = count1 + 1; ntype[count2] != 0 && count2 < inpt; count2++) ;\n\n\t  if (count2 < inpt)\n\t    {\n\t      npar = kpar + s6dist (&econd[(count1 - 1) * idim],\n\t\t\t\t    &econd[count2 * idim], idim);\n\t      (*epar1)[count2] = npar;\n\t    }\n\n\t  for (count3 = count1; count3 < count2; count3++)\n\t    {\n\t      if (ntype[count3] > 0)\n\t\t(*epar1)[count3] = kpar;\n\t      else\n\t\t(*epar1)[count3] = npar;\n\t    }\n\t  count1 = count2;\n\t  kpar = npar;\n\t}\n    }\n\n  if (iopen != SISL_CRV_OPEN)\n    {\n      /* Calculate distance between first and last point. */\n\n      for (count1 = 0; count1 < inpt && ntype[count1] != 0; count1++) ;\n\n      for (count2 = inpt - 1; count2 >= 0 && ntype[count2] != 0; count2--) ;\n\n      if (count1 >= inpt || count2 < 0)\n\tgoto err164;\n\n      (*epar1)[inpt] = kpar + s6dist (&econd[count1 * idim],\n\t\t\t\t      &econd[count2 * idim], idim);\n    }\n\n  *cendpar = (*epar1)[knpt - 1];\n\n  count2 = 1;\n  (*epar2)[0] = (*epar1)[0];\n\n  for (count1 = 1; count1 < knpt; count1++)\n    {\n      if ((*epar1)[count1 - 1] < (*epar1)[count1])\n\t{\n\t  (*epar2)[count2] = (*epar1)[count1];\n\t  count2++;\n\t}\n    }\n\n  *epar2 = increasearray (*epar2, count2, DOUBLE);\n  if (*epar2 == SISL_NULL)\n    goto err101;\n\n\n  /* Parametrization computed.  */\n\n  goto out;\n\n\n  /* No point conditions given. */\n\nerr164:\n  *jstat = -164;\n  s6err (\"s1909\", *jstat, kpos);\n  goto out;\n\n  /* Error in scratch allocation. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1909\", *jstat, kpos);\n  goto out;\n\nout:\n\n  return;\n}\n"
  },
  {
    "path": "src/s1910.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1910.c,v 1.2 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1910\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1910 (double econd[], int ntype[], int inpt, int idim, int iopen,\n       double astpar, double *cendpar, double *epar1[],\n       double *epar2[], int *jstat)\n#else\nvoid\ns1910 (econd, ntype, inpt, idim, iopen, astpar, cendpar, epar1, epar2, jstat)\n     double econd[];\n     int ntype[];\n     int inpt;\n     int idim;\n     int iopen;\n     double astpar;\n     double *cendpar;\n     double *epar1[];\n     double *epar2[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Make uniform parametrization of interpolation conditions.\n*\t       Derivative conditions are given the same value\n*\t       as the corresponding point condition.\n*\n* INPUT      : econd  - Array of interpolation conditions. The last\n*                       condition must be a point. Dimension is inpt*idim.\n*              ntype  - Array containing kind of condition. Dimension\n*                       is inpt.\n*                       =  0 : A point is given.\n*                       =  d : The d'th derivatative condition to the\n*                              previous point is given.\n*                       = -d : The d'th derivatative condition to the\n*                              next point is given.\n*              inpt   - Number of interpolation conditions.\n*              idim   - Dimension of geometry space.\n*\t       iopen  - Open/closed curve.\n*              astpar - Start parameter of parametrization.\n*\n* OUTPUT     : cendpar - End parameter of parametrization.\n*              epar1   - Parametrization array. Derivative conditions has\n*                        got the same parameter value as the corresponding\n*                        positional condition.\n*              epar2   - Parametrization array to use when making a knot\n*                        vector. All entries are different.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     :\n*\n* REFERENCES :\n*\n* CALLS      : s6dist,s6err.\n*\n* WRITTEN BY : Trond Vidar Stensby, SI, 1991-07\n*\n*********************************************************************\n*/\n{\n  int count1, count2;\t/* Loop control variables. */\n  int prev;\n  int knpt;\t\t\t/* Number of parameter values to\n\t\t\t\t   be produced. */\n  double sum, cord;\n  int kpos = 0;\n\n  *jstat = 0;\n\n  if (iopen != SISL_CRV_OPEN)\n    knpt = inpt + 1;\n  else\n    knpt = inpt;\n\n\n  /* Allocate arrays. */\n\n  *epar1 = newarray (knpt, DOUBLE);\n  if (*epar1 == SISL_NULL)\n    goto err101;\n\n  *epar2 = newarray (knpt, DOUBLE);\n  if (*epar2 == SISL_NULL)\n    goto err101;\n\n\n  /* Find average cord_length. */\n\n  sum = (double) 0.0;\n  prev = -1;\n  for (count1 = 0, count2 = 0; count1 < inpt; count1++)\n    {\n      if (ntype[count1] == 0)\n\t{\n\t  if (prev >= 0)\n\t    sum += s6dist (&econd[count1 * idim], &econd[prev * idim],\n\t\t\t   idim);\n\t  prev = count1;\n\t  count2++;\n\t}\n    }\n  cord = sum / (double) (count2 -  1.0);\n\n\n  for (count1 = 0; count1 < inpt; count1++)\n    {\n      if (ntype[count1] > 0)\n\t(*epar1)[count1] = astpar - cord;\n      else if (ntype[count1] < 0)\n\t(*epar1)[count1] = astpar;\n      else\n\t{\n\t  (*epar1)[count1] = astpar;\n\t  astpar += cord;\n\t}\n    }\n\n  if (iopen != SISL_CRV_OPEN)\n    (*epar1)[inpt] = astpar;\n\n  *cendpar = (*epar1)[knpt - 1];\n\n\n  /* Find distinct values. */\n\n  count2 = 1;\n  (*epar2)[0] = (*epar1)[0];\n\n  for (count1 = 1; count1 < knpt; count1++)\n    {\n      if ((*epar1)[count1 - 1] < (*epar1)[count1])\n\t{\n\t  (*epar2)[count2] = (*epar1)[count1];\n\t  count2++;\n\t}\n    }\n\n  *epar2 = increasearray (*epar2, count2, DOUBLE);\n  if (*epar2 == SISL_NULL)\n    goto err101;\n\n\n  /* Parametrization computed.  */\n\n  goto out;\n\n\n  /* Error in scratch allocation. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1910\", *jstat, kpos);\n  goto out;\n\nout:\n\n  return;\n}\n"
  },
  {
    "path": "src/s1911.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1911.c,v 1.2 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1911\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1911 (double econd[], int ntype[], int inpt, int idim, int iopen,\n       double astpar, double *cendpar, double *epar1[],\n       double *epar2[], int *jstat)\n#else\nvoid\ns1911 (econd, ntype, inpt, idim, iopen, astpar, cendpar, epar1, epar2, jstat)\n     double econd[];\n     int ntype[];\n     int inpt;\n     int idim;\n     int iopen;\n     double astpar;\n     double *cendpar;\n     double *epar1[];\n     double *epar2[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Make centripital cord length parametrization of interpolation\n*              conditions. Derivative conditions are given the same value\n*\t       as the corresponding point condition.\n*\n* INPUT      : econd  - Array of interpolation conditions. The last\n*                       condition must be a point. Dimension is inpt*idim.\n*              ntype  - Array containing kind of condition. Dimension\n*                       is inpt.\n*                       =  0 : A point is given.\n*                       =  d : The d'th derivatative condition to the\n*                              previous point is given.\n*                       = -d : The d'th derivatative condition to the\n*                              next point is given.\n*              inpt   - Number of interpolation conditions.\n*              idim   - Dimension of geometry space.\n*\t       iopen  - Open/closed curve\n*              astpar - Start parameter of parametrization.\n*\n* OUTPUT     : cendpar - End parameter of parametrization.\n*              epar1   - Parametrization array. Derivative conditions has\n*                        got the same parameter value as the corresponding\n*                        positional condition.\n*              epar2   - Parametrization array to use when making a knot\n*                        vector. All entries are different.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* METHOD     :\n*\n* REFERENCES :\n*\n* CALLS      : s6dist,s6err.\n*\n* WRITTEN BY : Trond Vidar Stensby, SI, 1991-07\n*********************************************************************\n*/\n{\n  int count1, count2, count3;\t/* Loop control variables. */\n  int knpt;\t\t\t/* Number of parameter values to\n\t\t\t\t   be produced. */\n\n  double kpar, npar;\t\t/* Used when calculating\n\t\t\t\t   the parameter values. */\n  int kpos = 0;\n\n  *jstat = 0;\n\n\n  if (iopen != SISL_CRV_OPEN)\n    knpt = inpt + 1;\n  else\n    knpt = inpt;\n\n\n  /* Allocate arrays. */\n\n  *epar1 = newarray (knpt, DOUBLE);\n  if (*epar1 == SISL_NULL)\n    goto err101;\n\n  *epar2 = newarray (knpt, DOUBLE);\n  if (*epar2 == SISL_NULL)\n    goto err101;\n\n  (*epar1)[0] = astpar;\n  kpar = astpar;\n\n  for (count1 = 1, kpar = astpar; count1 < inpt; count1++)\n    {\n      if (ntype[count1] == 0)\n\t{\n\t  kpar += sqrt (s6dist (&econd[(count1 - 1) * idim],\n\t\t\t\t&econd[count1 * idim], idim));\n\t  (*epar1)[count1] = kpar;\n\t}\n      else\n\t{\n\t  /* Find next value. */\n\n\t  for (count2 = count1 + 1; ntype[count2] != 0 && count2 < inpt; count2++) ;\n\n\t  if (count2 < inpt)\n\t    {\n\t      npar = kpar + sqrt (s6dist (&econd[(count1 - 1) * idim],\n\t\t\t\t\t  &econd[count2 * idim], idim));\n\t      (*epar1)[count2] = npar;\n\t    }\n\n\t  for (count3 = count1; count3 < count2; count3++)\n\t    {\n\t      if (ntype[count3] > 0)\n\t\t(*epar1)[count3] = kpar;\n\t      else\n\t\t(*epar1)[count3] = npar;\n\t    }\n\t  count1 = count2;\n\t  kpar = npar;\n\t}\n    }\n\n  if (iopen != SISL_CRV_OPEN)\n    {\n      /* Calculate distance between first and last point. */\n\n      for (count1 = 0; count1 < inpt && ntype[count1] != 0; count1++) ;\n\n      for (count2 = inpt - 1; count2 >= 0 && ntype[count2] != 0; count2--) ;\n\n      if (count1 >= inpt || count2 < 0)\n\tgoto err101;\t\t/* NB NB NB */\n\n      (*epar1)[inpt] = kpar + sqrt (s6dist (&econd[count1 * idim],\n\t\t\t\t\t    &econd[count2 * idim], idim));\n    }\n\n  *cendpar = (*epar1)[knpt - 1];\n\n  count2 = 1;\n  (*epar2)[0] = (*epar1)[0];\n\n  for (count1 = 1; count1 < knpt; count1++)\n    {\n      if ((*epar1)[count1 - 1] < (*epar1)[count1])\n\t{\n\t  (*epar2)[count2] = (*epar1)[count1];\n\t  count2++;\n\t}\n    }\n\n  *epar2 = increasearray (*epar2, count2, DOUBLE);\n  if (*epar2 == SISL_NULL)\n    goto err101;\n\n\n  /* Parametrization computed.  */\n\n  goto out;\n\n\n  /* Error in scratch allocation. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1911\", *jstat, kpos);\n  goto out;\n\nout:\n\n  return;\n}\n"
  },
  {
    "path": "src/s1912.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1912\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\ntypedef void (*fparamProc)(double[], int[], int, int, int, double, double *, \n\t\t\t   double *[], double *[], int *);\ntypedef void (*fknotsProc)(double[], int, int, int, double *[], int *);\n#else\ntypedef void (*fparamProc)();\ntypedef void (*fknotsProc)();\n#endif\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1912 (fparamProc fparam, fknotsProc fknots,\n       double econd[], int ntype[], int inpt, double astpar, int ik,\n       int idim, int iopen, double *cendpar, SISLCurve ** rcurve,\n       double **gpar, int *jnbpar, int *jstat)\n#else\nvoid\n   s1912 (fparam, fknots, econd, ntype, inpt, astpar, ik, idim, iopen,\n       cendpar, rcurve, gpar, jnbpar, jstat)\n     fparamProc fparam;\n     fknotsProc fknots;\n     double econd[];\n     int ntype[];\n     int inpt;\n     double astpar;\n     int ik;\n     int idim;\n     int iopen;\n     double *cendpar;\n     SISLCurve **rcurve;\n     double **gpar;\n     int *jnbpar;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Compute a B-spline curve interpolating a set of points.\n*              The points can be assigned derivative conditions. The\n*              curve can be open, closed, or closed and periodic.\n*\n* INPUT      : fparam - Routine computing parametrization of point set.\n*\t       fknots - Routine coputing knot vector of point set.\n*              econd  - Array of interpolation conditions. Dimension\n*                       is inpt*idim.\n*              ntype  - Array containing kind of condition. Dimension\n*                       is inpt.\n*                       =  0 : A point is given.\n*                       =  d : The d'th derivatative condition to the\n*                              previous point is given.\n*                       = -d : The d'th derivatative condition to the\n*                              next point is given.\n*              inpt   - Number of interpolation conditions.\n*              astpar - Start parameter of parametrization.\n*              ik     - Order of interpolating curve.\n*              idim   - Dimension of geometry space.\n*              iopen - Indicates if the curve is to be open, closed or\n*                       periodic.\n*\n* OUTPUT     : cendpar - End parameter of parametrization.\n*              rcurve  - Interpolating curve.\n*\t       gpar    - The distinct parameter values.\n*\t       jnbpar  - Number of distinct parameter values.\n*              jstat   - status messages\n*                        = 1      : Specified parametrization method\n*                                   replaced by cord length parametrization.\n*                                         = 0      : ok\n*\n* METHOD     :\n*\n* REFERENCES :\n*\n* CALLS      :\ts1905, s1891, s1713, s1750\n*\n* WRITTEN BY : Vibeke Skytt, SI, 91-04.\n* REVISED BY : Trond Vidar Stensby, SI, 91-07\n* REWISED BY : Vibeke Skytt, 94-03. Changed the concept of closed, \n*                                   non-periodic.\n* REWISED BY : Johannes Kaasa, 95-11. Fixed error in output of the parameter\n*              values (included the last parameter value).\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                             */\n  int kpos = 0;\n  int ki;\t\t\t/* Counter.                                     */\n  int knpt;\t\t\t/* Number of accepted interpolation conditions. */\n  int kn;\t\t\t/* Number of coefficients of B-spline curve.    */\n  int kordr;\t\t\t/* Local order of curve.                        */\n  int kright = 1;\t\t/* One equation system to solve in interpolation. */\n  int knlr = 0;\t\t\t/* Indicates shape of interpolation matrix.     */\n  int knrc = 0;\t\t\t/* Indicates shape of interpolation matrix.     */\n  int kopen;                    /* Local open/closed parameter. Closed,\n\t\t\t\t   non-periodic is treated as an open curve.*/\n  int *ltype = SISL_NULL;\t\t/* Type of accepted interpolation conditions.   */\n  double *scond = SISL_NULL;\t\t/* Array containing interpolation conditions.   */\n  double *spar1 = SISL_NULL;\t\t/* Parametrization array of interpolation conditions. */\n  double *spar2 = SISL_NULL;\t\t/* Parametrization array used to make knot vector. */\n  double *sknot = SISL_NULL;\t\t/* Knot vector of curve.                           */\n  double *scoef = SISL_NULL;\t\t/* Coefficients of curve.                          */\n  int *sder = SISL_NULL;\t\t/* Vector of derivative indicators.                */\n  SISLCurve *qc = SISL_NULL;\t\t/* Interpolation curve.                            */\n  SISLCurve *qc2 = SISL_NULL;\t/* Interpolation curve.                            */\n\n  *jstat = 0;\n\n  /* Set local open/closed parameter. */\n  \n  kopen = (iopen == SISL_CRV_PERIODIC) ? 0 : 1;\n  \n  /* Test interpolation conditions, and adjust the input conditions\n     if necessary.  */\n\n  s1905 (econd, ntype, inpt, ik, idim, iopen, &scond, &ltype, &knpt, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Set local order.  */\n\n  kordr = MIN (ik, knpt);\n\n  /* Allocate scratch for derivative indicator. */\n\n  if ((sder = newarray (knpt, INT)) == SISL_NULL)\n    goto err101;\n\n  for (ki = 0; ki < knpt; ki++)\n    sder[ki] = (int) fabs ((double) ltype[ki]);\n\n  /* Compute parametrization of point set. */\n\n  (* fparam) (scond, ltype, knpt, idim, kopen, astpar, cendpar, \n\t      &spar1, &spar2, &kstat);  \n  if (kstat < 0) goto error;\n\n  /* Make knot vector of curve.  */\n\n  if (iopen == SISL_CRV_PERIODIC)\n    {\n      /* Closed, periodic curve. */\n\n      knlr = kordr / 2;\n      knrc = kordr - knlr - 1;\n      knpt--;\n    }\n\n  /* Produce knot vector. */\n\n  (* fknots) (spar1, knpt, kordr, kopen, &sknot, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Perform interpolation.  */\n\n  s1891 (spar1, scond, idim, knpt, kright, sder, kopen, sknot,\n\t &scoef, &kn, kordr, knlr, knrc, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Express the curve as a curve object.  */\n\n  qc = newCurve (kn, kordr, sknot, scoef, 1, idim, 1);\n  if (qc == SISL_NULL) goto err101;\n\n  qc->cuopen = iopen;\n\n  if (kordr < ik)\n    {\n      /* The order of the curve is less than expected. Increase the order. */\n\n      qc2 = SISL_NULL;\n      s1750 (qc, ik, &qc2, &kstat);\n      if (kstat < 0) goto error;\n\n      if (qc != SISL_NULL) freeCurve (qc);\n      qc = qc2;\n    }\n\n  /* Interpolation performed. */\n\n  /* Find distinct parameter values. */\n\n  *gpar = spar1;\n  *jnbpar = 0;\n\n  for (ki = 1; spar1[ki] < *cendpar; ki++)\n    {\n      if (spar1[ki - 1] < spar1[ki])\n\t(*gpar)[(*jnbpar)++] = spar1[ki-1];\n    }\n  (*gpar)[(*jnbpar)++] = spar1[ki-1];\n  (*gpar)[(*jnbpar)++] = spar1[ki];\n\n  *gpar = increasearray (*gpar, *jnbpar, DOUBLE);\n\n  *rcurve = qc;\n  goto out;\n\n\n  /* Error in scratch allocation.  */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1912\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine. */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1912\", *jstat, kpos);\n  goto out;\n\nout:\n  /* Free scratch occupied by local arrays. */\n\n  if (spar2 != SISL_NULL)\n    freearray (spar2);\n  if (scond != SISL_NULL)\n    freearray (scond);\n  if (scoef != SISL_NULL)\n    freearray (scoef);\n  if (sknot != SISL_NULL)\n    freearray (sknot);\n  if (sder != SISL_NULL)\n    freearray (sder);\n  if (ltype != SISL_NULL)\n    freearray (ltype);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1916.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1916.c,v 1.2 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1916\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1916 (int inbcrv, double et2[], double ecoef[], int in2, int iord, int idim,\n       int iopen, double par[], int der[], int *jstat)\n#else\nvoid\ns1916 (inbcrv, et2, ecoef, in2, iord, idim, iopen, par, der, jstat)\n     int inbcrv;\n     double et2[];\n     double ecoef[];\n     int in2;\n     int iord;\n     int idim;\n     int iopen;\n     double par[];\n     int der[];\n     int *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    :\tTo adjust the length of the derivative curves such that the\n*\t\tresulting product of the derivative of the lofting surface\n*\t\tcorresponds better to the curve length.\n*\n* INPUT      :\tinbcrv\t- The number of input curves given to the interpolation\n*\t\t\t  problem.\n*\t\tet2\t- The knot vector of the B-spline curves.\n*\t\tecoef\t- Array containing the B-spline vertices of the input\n*\t\t\t  curves.\n*\t\tin2\t- Number of vertices in the B-spline curves.\n*\t\tiord1\t- The order of the B-spline lofting.\n*\t\tidim\t- The dimension of the space in which the curves lie.\n*\t\teptyp\t- The description of each curve.\n*\t\t\t  1 - Ordinary curve.\n*\t\t\t  2 - Knuckle curve, is treated as ordinary curve.\n*\t\t\t  3 - Tangent to next curve.\n*\t\t\t  4 - Tangent to prior curve.\n*\t\t\t  5 - Double derivative to prior curve.\n*\t\t\t  6 - Double derivative to next curve.\n*\t\tiopen\t- Open/closed surface in lofting direction\n*\t\tastpar\t- Start parameter value.\n*\n* OUTPUT     :\tecoef\t- The adjusted B-spline vertices.\n*\t\tetyp\t- The type indicators.\n*\t\tpar\t- The parametrization.\n*\t\tder\t- The derivative indicators.\n*\t\tjstat    - Status variable:\n*                                               > 0     : warning\n*                                               = 0     : ok\n*                                               < 0     : error\n*\n* METHOD     :\n*\n* REFERENCES :\tFortran version by Tor Dokken, SI, 1984-10\n*\n* CALLS      :\ts1919,s6err.\n*\n* WRITTEN BY :\tTrond Vidar Stensby, SI, 1991-07\n*\n*********************************************************************\n*/\n{\n  int kpekc;\t\t\t/* Pointer to current curve. */\n  int kpekp;\t\t\t/* Pointer to previous curve. */\n  int kpekf;\t\t\t/* Pointer to following curve. */\n  int kstart;\t\t\t/* Used for controllong loops. */\n  int kstop;\n  int kip;\t\t\t/* Indicates if previous curve exists. */\n  int kif;\t\t\t/* Indicates if following curve exists. */\n  int ki, kj;\t\t\t/* Loop control variable. */\n\n  double tc;\t\t\t/* Parameter value for current curve. */\n  double tp;\t\t\t/* Parameter value for previous curve. */\n  double tf;\t\t\t/* Parameter value for following curve. */\n  double *prev = SISL_NULL;\t\t/* Vertices of previous curve. */\n  double *curr = SISL_NULL;\t\t/* Vertices of current curve. */\n  double *deriv = SISL_NULL;\t\t/* Vertices of derivative curve. */\n  double *follow = SISL_NULL;\t/* Vertices of following curve. */\n  int kstat = 0;\n  int kpos = 0;\n\n  *jstat = 0;\n\n\n  /* Test if legal input. */\n\n  if (in2 < iord || iord < 1)\n    goto err112;\n\n  /* Allocate space for the curves. */\n\n  prev = newarray (in2 * idim, DOUBLE);\n  if (prev == SISL_NULL)\n    goto err101;\n  curr = newarray (in2 * idim, DOUBLE);\n  if (curr == SISL_NULL)\n    goto err101;\n  deriv = newarray (in2 * idim, DOUBLE);\n  if (deriv == SISL_NULL)\n    goto err101;\n  follow = newarray (in2 * idim, DOUBLE);\n  if (follow == SISL_NULL)\n    goto err101;\n\n  for (ki = 0; ki < inbcrv; ki++)\n    {\n      if (der[ki] == 1)\n\t{\n\t  /* Derivative curve found.\n\t     kpekp is to be the pointer to the previous curve.\n\t     kpekc is to be the pointer to the current curve.\n\t     kpekf is to be the pointer to the following curve. */\n\n\t  kpekc = ki;\n\t  tc = par[ki];\n\n\t  /* Find previous curve if any. */\n\n\t  kstop = ki;\n\t  kip = 0;\n\t  for (kj = 1; kj <= kstop && kip == 0; kj++)\n\t    {\n\t      kpekp = ki - kj;\n\t      tp = par[kpekp];\n\t      if (der[kpekp] == 0 && tp == tc)\n\t\tkpekc = kpekp;\n\t      if (der[kpekp] == 0 && tp < tc)\n\t\tkip = 1;\n\t    }\n\n\t  /* Find following curve if any. */\n\n\t  kstart = ki + 1;\n\t  kif = 0;\n\t  for (kj = kstart; kj < inbcrv && kif == 0; kj++)\n\t    {\n\t      kpekf = kj;\n\t      tf = par[kpekf];\n\t      if (der[kpekf] == 0 && tf == tc)\n\t\tkpekc = kpekf;\n\t      if (der[kpekf] == 0 && tf > tc)\n\t\tkif = 1;\n\t    }\n\n\t  /* Previous, current and next position curve found if any.\n\t     Check that at least current and one of previous or next is found. */\n\n\t  if (kpekc == ki || (kip == 0 && kif == 0))\n\t    goto err186;\n\n\n\t  /* Copy the current curves into temporary arrays. */\n\n\t  if (kip == 1)\n\t    memcopy (prev, &ecoef[kpekp * in2 * idim], in2 * idim, DOUBLE);\n\n\t  memcopy (curr, &ecoef[kpekc * in2 * idim], in2 * idim, DOUBLE);\n\t  memcopy (deriv, &ecoef[ki * in2 * idim], in2 * idim, DOUBLE);\n\n\t  if (kif == 1)\n\t    memcopy (follow, &ecoef[kpekf * in2 * idim],\n\t\t     in2 * idim, DOUBLE);\n\n\t  s1919 (et2, prev, curr, deriv, follow, in2, iord, idim, kip,\n\t\t kif, tp, tc, tf, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\n\t  /* Copy the adjusted derivative curve back. */\n\n\t  memcopy (&ecoef[ki * in2 * idim], deriv, in2 * idim, DOUBLE);\n\t}\n    }\n\n  /* OK */\n\n  goto out;\n\n  /* Error in allocation. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1916\", *jstat, kpos);\n  goto out;\n\n  /* Error in description of B-spline. */\n\nerr112:\n  *jstat = -112;\n  s6err (\"s1916\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine. */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1916\", *jstat, kpos);\n  goto out;\n\n  /* Special error. */\n\nerr186:\n  *jstat = -186;\n  s6err (\"s1916\", *jstat, kpos);\n  goto out;\n\nout:\n  if (prev != SISL_NULL)\n    freearray (prev);\n  if (curr != SISL_NULL)\n    freearray (curr);\n  if (deriv != SISL_NULL)\n    freearray (deriv);\n  if (follow != SISL_NULL)\n    freearray (follow);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1917.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1917.c,v 1.3 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1917\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1917 (int inbcrv, double ecoef[], int in2,\n       int idim, int eptyp[], double astpar, int iopen,\n       double *par[], int *der[], int *inumb, int *jstat)\n#else\nvoid\ns1917 (inbcrv, ecoef, in2, idim, eptyp, astpar, iopen,\n       par, der, inumb, jstat)\n     int inbcrv;\n     double ecoef[];\n     int in2;\n     int idim;\n     int eptyp[];\n     double astpar;\n     int iopen;\n     double *par[];\n     int *der[];\n     int *inumb;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    :\tTo calculate the parametrization for a spline lofted curve\n*\t\tinterpolation. At the same time the illegal interpolation\n*\t\tconditions are discarded and the legal ones along with the end\n*\t\tconditions are returned in the input coefficient array.\n*\n* INPUT      :\tinbcrv\t- The number of input curves given to the interpolation\n*\t\t\t  problem.\n*\t\tecoef\t- Array containing the B-spline verices of the input\n*\t\t\t  curves.\n*\t\tin2\t- Number of vertices in the B-spline curves.\n*\t\tidim\t- The dimension of the space in which the curve lie.\n*\t\teptyp\t- The decription of each curve.\n*\t\t\t  1 - Ordinary curve.\n*\t\t\t  2 - Knuckle curve.\n*\t\t\t  3 - Tangent to next curve.\n*\t\t\t  4 - Tangent to prior curve.\n*\t\t\t  5 - Double derivative to prior curve.\n*\t\t\t  6 - Double derivative to next curve.\n*\t\tastpar\t- Start value of parametrization.\n*\t\tiopen\t- Open/closed surface in lofting direction.\n*\n* OUTPUT     :\tecoef\t- The checked B-spline vertices.\n*\t\teptyp\t- The checked type indicators.\n*\t\tpar\t- The parametrization array.\n*\t\tder\t- The derivative indicarors.\n*\t\tinumb\t- Number of updated interpolation conditions.\n*               jstat    - Status variable:\n*                                               > 0     : warning\n*                                               = 0     : ok\n*                                               < 0     : error\n* METHOD     :\tThe start end-condition, the interpolation conditions and\n*\t\tthe end end-condition are checked and the legal interpolation\n*\t\tconditions produced. If the curve is closed an extra parameter\n*\t\tvalue is produced. At last the sequence of the end\n*\t\tend-condition is checked to ensure that the equation system can\n*\t\tbe solved without pivotation.\n*\n* REFERENCES :\tFortran version by Tor Dokken, SI, 81-12\n*\t\tLine correction by Steinar Meen, KV\n*\n* CALLS      : s6err.\n*\n* WRITTEN BY :  Trond Vidar Stensby, SI, 1991-07\n* Revised by : Paal Fugelli, SINTEF, Oslo 02/08-1994.  Changed order of\n*              occurence of test conditions to avoid overrunning array bounds.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\n  int knext;\t\t\t/* True if next point is being processed. */\n  int ktang;\t\t\t/* True if tangent has been given. */\n  int kcurv;\t\t\t/* True if double derivative has been given. */\n  int kerr;\t\t\t/* True if an error has been found.\n\t\t\t\t   The error does not cause a program stop, but a\n\t\t\t\t   default action is taken. */\n  int kprev;\t\t\t/* True if working with previus point. */\n  int knumb;\t\t\t/* Number of exepted interpolation conditions. */\n  int kpopar;\n  int kkkksm;\n  int kant;\t\t\t/* Number of sucessfully processed interpolation\n\t\t\t\t   conditions. */\n  int ktyp = 0;\n  int ki, kj, kl, kr;\t\t/* Loop control variables. */\n  int legal;\t\t\t/* Dummy variables. */\n  int dummy1;\n  int dummy2;\n\n  double tsum;\t\t\t/* Variables used when calculating the */\n  double tdum;\t\t\t/* parametrization. */\n  int    kdum;\n  double tdiff;\n\n  *jstat = 0;\n\n\n  /* Test if legal input. */\n\n  if (idim < 1)\n    goto err102;\n  if (inbcrv < 2)\n    goto err179;\n\n\n  /* Allocate space for output parameters. */\n\n  *par = newarray (inbcrv + 1, DOUBLE);\n  if (*par == SISL_NULL)\n    goto err101;\n\n  *der = newarray (inbcrv, INT);\n  if (*der == SISL_NULL)\n    goto err101;\n\n\n  /* Calculate parametrization. */\n\n  kerr = 0;\n  knumb = 0;\n  kpopar = 0;\n  kkkksm = 0;\n\n\n  /* Initate logical variables taking care of the state of the\n     curves, tangents and double derivatives. */\n\n  knext = TRUE;\n  ktang = FALSE;\n  kcurv = FALSE;\n\n\n  /* Test curve type for input curves. If internal curves are\n     knuckle curves or curves are assigned two derivatives the\n     illegal information is discarded. */\n\n  kant = inbcrv;\n  ki = 1;\n\n  while (ki <= kant)\n    {\n      legal = TRUE;\n\n      ktyp = eptyp[ki - 1];\n\n      if (ktyp == 1 || ktyp == 2)\n\t{\n\t  if (ktyp == 2 && ki != 1 && ki != inbcrv)\n\t    kerr = 1;\n\n\t  if (knext == FALSE)\n\t    {\n\t      ktang = FALSE;\n\t      kcurv = FALSE;\n\t    }\n\t  knext = FALSE;\n\n\n\t  /* Calculate paramerization. The first curve shall\n\t     have parameter value astpar. */\n\n\t  if (kkkksm != 0)\n\t    {\n\t      tsum = (double) 0.0;\n\t      for (kl = 0; kl < in2; kl++)\n\t\t{\n\t\t  tdum = (double) 0.0;\n\t\t  dummy1 = (ki - 1) * in2 * idim + kl * idim;\n\t\t  dummy2 = (kkkksm - 1) * in2 * idim + kl * idim;\n\t\t  for (kj = 0; kj < idim; kj++)\n\t\t    {\n\t\t      tdiff = ecoef[dummy1 + kj] - ecoef[dummy2 + kj];\n\t\t      tdum += tdiff * tdiff;\n\t\t    }\n\t\t  tsum += sqrt (tdum);\n\t\t}\n\t      if (tsum == (double) 0.0)\n\t\tlegal = FALSE;\n\t      else\n\t\tastpar += tsum / (double)in2;\n\t    }\n\n\t  if (legal)\n\t    {\n\t      (*der)[knumb] = 0;\n\t      for (kj = kpopar; kj <= knumb; kj++)\n\t\t(*par)[kj] = astpar;\n\n\t      kprev = ki;\n\t      kkkksm = ki;\n\t      kpopar = knumb + 1;\n\t    }\n\t}\n      else if (ktyp == 3 || ktyp == 13)\n\t{\n\t  /* TANGENT TO NEXT CURVE. */\n\n\t  /* Test that tangent not already given. */\n\n\t  if (knext && ktang)\n\t    legal = FALSE;\n\t  else\n\t    {\n\t      if (knext == FALSE)\n\t\tkcurv = FALSE;\n\t      ktang = TRUE;\n\t      knext = TRUE;\n\n\t      /* Legal tanent. */\n\n\t      (*der)[knumb] = 1;\n\t    }\n\t}\n      else if (ktyp == 4 || ktyp == 14)\n\t{\n\t  /* TANGENT TO PRIOR CURVE */\n\n\t  /* Test that tangent not already given or that we are\n\t     already working with the next curve. */\n\n\t  if (knext || (ktang && !knext))\n\t    legal = FALSE;\n\t  else\n\t    {\n\t      ktang = TRUE;\n\n\t      /* Legal tangent. */\n\n\t      (*der)[knumb] = 1;\n\t      (*par)[knumb] = astpar;\n\t      kpopar = knumb + 1;\n\t    }\n\t}\n      else if (ktyp == 5)\n\t{\n\t  /* SECOND DERIVATIVE TO NEXT CURVE. */\n\n\t  /* Test that double derivative not already given. */\n\n\t  if (knext && kcurv)\n\t    legal = FALSE;\n\t  else\n\t    {\n\t      if (knext == FALSE)\n\t\tktang = FALSE;\n\t      kcurv = TRUE;\n\t      knext = TRUE;\n\n\t      /* Legal double derivative. */\n\n\t      (*der)[knumb] = 2;\n\t    }\n\t}\n      else if (ktyp == 6)\n\t{\n\t  /* SECOND DERIVATIVE TO PRIOR CURVE. */\n\n\t  /* Test that double derivative not already given or that we are\n\t     already working with the next curve. */\n\n\t  if (knext || (kcurv && !knext))\n\t    kcurv = TRUE;\n\n\t  /* Legal double derivative. */\n\n\t  (*der)[knumb] = 2;\n\t  (*par)[knumb] = astpar;\n\t  kpopar = knumb + 1;\n\t}\n      else\n\tlegal = FALSE;\n\n\n      if (legal)\n\t{\n\t  /* Legal curve or derivative. */\n\n\t  /* Since curve is legal, the curve is already in the right position. */\n\n\t  ki++;\n\t  knumb++;\n\t}\n      else\n\t{\n\t  kerr = 1;\n\n\t  /* Decrease the number of conditions by one and copy remaining\n\t     pointers. */\n\n\t  kant--;\n\n\t  if (ki <= kant)\n\t    {\n\t      memcopy (&eptyp[ki - 1], &eptyp[ki], kant - ki, INT);\n\t      memcopy (&ecoef[(ki - 1) * in2 * idim], &ecoef[ki * in2 * idim],\n\t\t       (kant - ki) * in2 * idim, DOUBLE);\n\t    }\n\t}\n    }\n\n  /* If tangent or curvature to next specified after end curve, remove this. */\n\n  if (knext)\n    {\n      /* Remove tangent and/or curvature. */\n\n      if (ktang)\n\tknumb--;\n      if (kcurv)\n\tknumb--;\n\n      ktang = FALSE;\n      kcurv = FALSE;\n      kerr = 1;\n    }\n\n  if (kpopar > knumb)\n    {\n      /* Error at end of curve. */\n\n      kerr = 1;\n      knumb = kpopar;\n    }\n\n  /* If closed surface in lofting direction, find parametrization from\n     last to first curve. */\n\n  if (iopen != SISL_CRV_OPEN)\n    {\n      for (ki = 1; eptyp[ki] != 1 && eptyp[ki] != 2; ki++)\n\tif (ki > inbcrv)\n\t  goto err179;\n\n\n      /* Calculate distance */\n\n      tsum = (double) 0.0;\n\n      for (kl = 0; kl < in2; kl++)\n\t{\n\t  tdum = (double) 0.0;\n\t  dummy1 = (ki - 1) * idim * in2 + kl * idim;\n\t  dummy2 = (kprev - 1) * idim * in2 + kl * idim;\n\t  for (kj = 0; kj < idim; kj++)\n\t    {\n\t      tdiff = ecoef[dummy1 + kj] - ecoef[dummy2 + kj];\n\t      tdum += tdiff * tdiff;\n\t    }\n\t  tsum += sqrt (tdum);\n\t}\n\n      /* If tsum is zero the curve must be discarded. */\n\n      if (tsum == (double) 0.0)\n\t{\n\t  knumb--;\n\t  kerr = 1;\n\t}\n      else\n\t{\n\t  astpar += tsum / (double)in2;\n\t  (*par)[knumb] = astpar;\n\t}\n    }\n\n  /* Parametrization completed. */\n\n  /* To get an interpolation problem solvable without pivotation,\n     last interpolation condition must be interpolation of position. */\n\n  for (kl = knumb - 2; kl >= 1 && (*par)[kl] >= (*par)[knumb - 1] &&\n       (*der)[kl] != 0; kl--) ;\n\n  if (kl >= 1 && (*par)[kl] >= (*par)[knumb - 1])\n    {\n      /* Interpolation of position at end not last condition.\n\t Interchange conditions. */\n\n      (*der)[kl] = (*der)[knumb - 1];\n      (*der)[knumb - 1] = 0;\n      kdum = eptyp[knumb - 1];\n      eptyp[knumb - 1] = eptyp[kl];\n      eptyp[kl] = kdum - 1;\n\n\n      for (kr = kl + 1; kr < knumb - 1; kr++)\n\t{\n\t  ktyp = eptyp[kr];\n\t  if (ktyp == 4 || ktyp == 6)\n\t    (eptyp[kr])--;\n\t}\n\n      for (kr = 0; kr < in2; kr++)\n\t{\n\t  dummy1 = (knumb - 1) * in2 * idim + kr * idim;\n\t  dummy2 = kl * in2 * idim + kr * idim;\n\t  for (kj = 0; kj < idim; kj++)\n\t    {\n\t      tdum = ecoef[dummy1 + kj];\n\t      ecoef[dummy1 + kj] = ecoef[dummy2 + kj];\n\t      ecoef[dummy2 + kj] = tdum;\n\n\t      ktyp = eptyp[kl];\n\t      if (ktyp >= 10)\n\t\tecoef[dummy2 + kj] = (double) 2.0 *ecoef[dummy1 + kj]\n\t\t- ecoef[dummy2 + kj];\n\t    }\n\t}\n    }\n\n  /* To get an interpolation problem solvable without pivotation, the\n     next last interpolation condition should be interpolation of\n     tangent if such interpolation is specified. */\n\n  for (kl = knumb - 3; kl >= 1 && (*par)[kl] >= (*par)[knumb - 2] &&\n       (*der)[kl] != 1; kl--) ;\n\n  if (kl >= 1 && (*par)[kl] >= (*par)[knumb - 2])\n    {\n      /* More than one interpolation condition at the end, and interpolation\n\t of tangent at end not last but one condition. */\n\n      (*der)[kl] = (*der)[knumb - 2];\n      (*der)[knumb - 2] = 1;\n      kdum = eptyp[knumb - 2];\n      eptyp[knumb - 2] = eptyp[kl];\n      eptyp[kl] = kdum;\n\n      for (kr = 0; kr < in2; kr++)\n\t{\n\t  dummy1 = (knumb - 2) * in2 * idim + kr * idim;\n\t  dummy2 = kl * in2 * idim + kr * idim;\n\t  for (kj = 0; kj < idim; kj++)\n\t    {\n\t      tdum = ecoef[dummy1 + kj];\n\t      ecoef[dummy1 + kj] = ecoef[dummy2 + kj];\n\t      ecoef[dummy2 + kj] = tdum;\n\t    }\n\t}\n    }\n\n  if (knumb < 2)\n    goto err187;\n\n  /* OK */\n\n  *inumb = knumb;\n\n  if (kerr == 1)\n    *jstat = 102;\n  else\n    goto out;\n\n\n  /*  Not able to allocate memory. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1917\", *jstat, kpos);\n  goto out;\n\n  /* Error in description of spline. */\n\nerr102:\n  *jstat = -102;\n  s6err (\"s1917\", *jstat, kpos);\n  goto out;\n\n  /* Error in description if interpolation problem. */\n\nerr179:\n  *jstat = -179;\n  s6err (\"s1917\", *jstat, kpos);\n  goto out;\n\n  /* Error in description of input curves. */\n\nerr187:\n  *jstat = -187;\n  s6err (\"s1917\", *jstat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1918.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1918.c,v 1.2 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1918\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1918 (int inbcrv, double et2[], double ecoef[], int in2, int iord, int idim,\n       double par[], int der[], int *jstat)\n#else\nvoid\ns1918 (inbcrv, et2, ecoef, in2, iord, idim, par, der, jstat)\n     int inbcrv;\n     double et2[];\n     double ecoef[];\n     int in2;\n     int iord;\n     int idim;\n     double par[];\n     int der[];\n     int *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    :\tTo adjust the length of the derivative curves such that the\n*\t\tresulting product of the derivative of the lofting surface\n*\t\tcorresponds better to the curve length.\n*\n* INPUT      :\tinbcrv\t- The number of input curves given to the interpolation\n*\t\t\t  problem.\n*\t\tet2\t- The knot vector of the B-spline curves.\n*\t\tecoef\t- Array containing the B-spline vertices of the input\n*\t\t\t  curves.\n*\t\tin2\t- Number of vertices in the B-spline curves.\n*\t\tiord\t- The order of the B-spline lofting.\n*\t\tidim\t- The dimension of the space in which the curves lie.\n*\n* OUTPUT     :\tecoef\t- The adjusted B-spline vertices.\n*\t\tpar\t- The parametrization.\n*\t\tder\t- The derivative indicators.\n*\t\tjstat    - Status variable:\n*                                               > 0     : warning\n*                                               = 0     : ok\n*                                               < 0     : error\n*\n* METHOD     :\n*\n* REFERENCES :\tFortran version by Tor Dokken, SI, 1984-10\n*\n* CALLS      :\ts1919, s6err.\n*\n* WRITTEN BY :\tTrond Vidar Stensby, SI, 1991-07\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\n  int kstat = 0;\n  int kpekc;\t\t\t/* Pointer to current curve. */\n  int kpekp;\t\t\t/* Pointer to previous curve. */\n  int kpekf;\t\t\t/* Pointer to following curve. */\n  int kstart;\t\t\t/* Used for controllong loops. */\n  int kstop;\n  int kip;\t\t\t/* Indicates if previous curve exists. */\n  int kif;\t\t\t/* Indicates if following curve exists. */\n  int ki, kj;\t\t\t/* Loop control variable. */\n  double tc;\t\t\t/* Parameter value for current curve. */\n  double tp;\t\t\t/* Parameter value for previous curve. */\n  double tf;\t\t\t/* Parameter value for following curve. */\n  double *prev = SISL_NULL;\t\t/* Vertices of previous curve. */\n  double *curr = SISL_NULL;\t\t/* Vertices of current curve. */\n  double *deriv = SISL_NULL;\t\t/* Vertices of derivative curve. */\n  double *follow = SISL_NULL;\t/* Vertices of following curve. */\n\n  *jstat = 0;\n\n\n  /* Test if legal input. */\n\n  if (in2 < iord || iord < 1)\n    goto err112;\n\n\n  /* Allocate space for the curves. */\n\n  prev = newarray (in2 * idim, DOUBLE);\n  if (prev == SISL_NULL)\n    goto err101;\n  curr = newarray (in2 * idim, DOUBLE);\n  if (curr == SISL_NULL)\n    goto err101;\n  deriv = newarray (in2 * idim, DOUBLE);\n  if (deriv == SISL_NULL)\n    goto err101;\n  follow = newarray (in2 * idim, DOUBLE);\n  if (follow == SISL_NULL)\n    goto err101;\n\n  for (ki = 0; ki < inbcrv; ki++)\n    {\n      if (der[ki] == 1)\n\t{\n\t  /* Derivative curve found.\n\t     kpekp is to be the pointer to the previous curve.\n\t     kpekc is to be the pointer to the current curve.\n\t     kpekf is to be the pointer to the following curve. */\n\n\t  kpekc = ki;\n\t  tc = par[ki];\n\n\n\t  /* Find previous curve if any. */\n\n\t  kstop = ki;\n\t  kip = 0;\n\t  for (kj = 1; kj <= kstop && kip == 0; kj++)\n\t    {\n\t      kpekp = ki - kj;\n\t      tp = par[kpekp];\n\t      if (der[kpekp] == 0 && tp == tc)\n\t\tkpekc = kpekp;\n\t      if (der[kpekp] == 0 && tp < tc)\n\t\tkip = 1;\n\t    }\n\n\t  /* Find following curve if any. */\n\n\t  kstart = ki + 1;\n\t  kif = 0;\n\t  for (kj = kstart; kj < inbcrv && kif == 0; kj++)\n\t    {\n\t      kpekf = kj;\n\t      tf = par[kpekf];\n\t      if (der[kpekf] == 0 && tf == tc)\n\t\tkpekc = kpekf;\n\t      if (der[kpekf] == 0 && tf > tc)\n\t\tkif = 1;\n\t    }\n\n\t  /* Previous, current and next position curve found if any.\n\t     Check that at least current and one of previous or next is found. */\n\n\t  if (kpekc == ki || (kip == 0 && kif == 0))\n\t    goto err186;\n\n\n\t  /* Copy the current curves into temporary arrays. */\n\n\t  if (kip == 1)\n\t    memcopy (prev, &ecoef[kpekp * in2 * idim], in2 * idim, DOUBLE);\n\n\t  memcopy (curr, &ecoef[kpekc * in2 * idim], in2 * idim, DOUBLE);\n\t  memcopy (deriv, &ecoef[ki * in2 * idim], in2 * idim, DOUBLE);\n\n\t  if (kif == 1)\n\t    memcopy (follow, &ecoef[kpekf * in2 * idim],\n\t\t     in2 * idim, DOUBLE);\n\n\t  s1919 (et2, prev, curr, deriv, follow, in2, iord, idim,\n\t\t kip, kif, tp, tc, tf, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\n\t  /* Copy the adjusted derivative curve back. */\n\n\t  memcopy (&ecoef[ki * in2 * idim], deriv, in2 * idim, DOUBLE);\n\t}\n    }\n\n  /* OK */\n\n  goto out;\n\n\n  /* Error in allocation. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1918\", *jstat, kpos);\n  goto out;\n\n  /* Error in description of B-spline. */\n\nerr112:\n  *jstat = -112;\n  s6err (\"s1918\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine. */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1918\", *jstat, kpos);\n  goto out;\n\n  /* Special error. */\n\nerr186:\n  *jstat = -186;\n  s6err (\"s1918\", *jstat, kpos);\n  goto out;\n\nout:\n  if (prev != SISL_NULL)\n    freearray (prev);\n  if (curr != SISL_NULL)\n    freearray (curr);\n  if (deriv != SISL_NULL)\n    freearray (deriv);\n  if (follow != SISL_NULL)\n    freearray (follow);\n  return;\n}\n"
  },
  {
    "path": "src/s1919.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1919.c,v 1.2 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1919\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1919 (double et[], double prev[], double curr[], double deriv[],\n       double follow[], int in, int ik, int idim, int iip, int iif,\n       double ap, double ac, double af, int *jstat)\n#else\nvoid\ns1919 (et, prev, curr, deriv, follow, in, ik, idim, iip, iif, ap, ac, af, jstat)\n     double et[];\n     double prev[];\n     double curr[];\n     double deriv[];\n     double follow[];\n     int in;\n     int ik;\n     int idim;\n     int iip;\n     int iif;\n     double ap;\n     double ac;\n     double af;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    :\tTo make the product of the tangent legth and the parametrization\n*\t\tof the curve epd as close as possible to the curve length.\n*\n* INPUT      :\tet\t- The original knot vector.\n*\n* OUTPUT     :jstat    - Status variable:\n*                                               > 0     : warning\n*                                               = 0     : ok\n*                                               < 0     : error\n*\n* METHOD     :\n*\n* REFERENCES :\tFortran version by Tor Dokken, SI, 1991-07\n*\n* CALLS      : s1890, s1221, s1891, s6err.\n*\n* WRITTEN BY :\tTrond Vidar Stensby, SI, 1991-07\n*\n*********************************************************************\n*/\n{\n  SISLCurve *tcurve = SISL_NULL;\t/* Temporary curve. */\n  int knh;\t\t\t/* Local number of verticews. */\n  int left;\t\t\t/* Used when calling s1221 */\n  int pos, pos2;\t\t/* Used for efficent adressing of arrays. */\n  int ki, kj;\t\t\t/* Loop control variables. */\n  double tdist1;\t\t/* Distance between previous and current. */\n  double tdist2;\t\t/* Distance between current and following. */\n  double tlength;\t\t/* Length of tangemt. */\n  double tdiff;\t\t\t/* Dummy. */\n  double tfak;\n  double tval1;\t\t\t/* Adjusted parameter values. */\n  double tval2;\n  double *kpar = SISL_NULL;\t\t/* Used when calculating parametrization. */\n  int *kder = SISL_NULL;\n  double *kpc = SISL_NULL;\t\t/* Points on previous curve. */\n  double *kdc = SISL_NULL;\t\t/* Points on derivative curve. */\n  double *kcc = SISL_NULL;\t\t/* Points on current curve. */\n  double *kfc = SISL_NULL;\t\t/* Points on following curve. */\n  double *epd = SISL_NULL;\t\t/* Vertices of the derivative curve. */\n  int kstat = 0;\n  int kpos = 0;\n\n  *jstat = 0;\n\n\n  /* Test if legal input. */\n\n  if (ik <= 1 || in <ik)\n    goto err112;\n\n\n  /* Produce parameter values. */\n\n  s1890 (et, ik, in, &kpar, &kder, &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  /* Allocate temporary arrays. */\n\n  kpc = newarray (idim * in, DOUBLE);\n  if (kpc == SISL_NULL)\n    goto err101;\n  kcc = newarray (idim * in, DOUBLE);\n  if (kcc == SISL_NULL)\n    goto err101;\n  kdc = newarray (idim * in, DOUBLE);\n  if (kdc == SISL_NULL)\n    goto err101;\n  kfc = newarray (idim * in, DOUBLE);\n  if (kfc == SISL_NULL)\n    goto err101;\n\n\n  if (iip == 1)\n    {\n      /* Caculate interpolation points on previous curve. */\n\n      tcurve = newCurve (in, ik, et, prev, 1, idim, 1);\n      if (tcurve == SISL_NULL)\n\tgoto err101;\n\n      left = 0;\n      for (ki = 0; ki < in; ki++)\n\t{\n\t  s1221 (tcurve, 0, kpar[ki], &left, &kpc[ki * idim], &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n      if (tcurve != SISL_NULL)\n\tfreeCurve (tcurve);\n    }\n\n  /* Caculate interpolation points on current curve. */\n\n  tcurve = newCurve (in, ik, et, curr, 1, idim, 1);\n  if (tcurve == SISL_NULL)\n    goto err101;\n\n  left = 0;\n  for (ki = 0; ki < in; ki++)\n    {\n      s1221 (tcurve, 0, kpar[ki], &left, &kcc[ki * idim], &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n  if (tcurve != SISL_NULL)\n    freeCurve (tcurve);\n\n\n  /* Caculate interpolation points on derivative curve. */\n\n  tcurve = newCurve (in, ik, et, deriv, 1, idim, 1);\n  if (tcurve == SISL_NULL)\n    goto err101;\n\n  left = 0;\n  for (ki = 0; ki < in; ki++)\n    {\n      s1221 (tcurve, 0, kpar[ki], &left, &kdc[ki * idim], &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n  if (tcurve != SISL_NULL)\n    freeCurve (tcurve);\n\n\n  if (iif == 1)\n    {\n      /* Caculate interpolation points on following curve. */\n\n      tcurve = newCurve (in, ik, et, follow, 1, idim, 1);\n      if (tcurve == SISL_NULL)\n\tgoto err101;\n\n      left = 0;\n      for (ki = 0; ki < in; ki++)\n\t{\n\t  s1221 (tcurve, 0, kpar[ki], &left, &kfc[ki * idim], &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n      if (tcurve != SISL_NULL)\n\tfreeCurve (tcurve);\n    }\n\n  /* Adjust the points calculated on the derivative curve according to the\n     distances between previous, current and following curve. */\n\n  if (iip == 1)\n    tval1 = fabs (ac - ap);\n  if (iif == 1)\n    tval2 = fabs (af - ac);\n\n  pos = 0;\n  for (ki = 0; ki < in; ki++)\n    {\n      tdist1 = (double) 0.0;\n      tdist2 = (double) 0.0;\n      tlength = (double) 0.0;\n\n      for (kj = 0; kj < idim; kj++)\n\t{\n\t  if (iip == 1)\n\t    {\n\t      tdiff = kcc[pos] - kpc[pos];\n\t      tdist1 += tdiff * tdiff;\n\t    }\n\t  if (iif == 1)\n\t    {\n\t      tdiff = kfc[pos] - kcc[pos];\n\t      tdist2 += tdiff * tdiff;\n\t    }\n\t  tlength += kdc[pos] * kdc[pos];\n\t  pos++;\n\t}\n\n      tdist1 = sqrt (tdist1);\n      tdist2 = sqrt (tdist2);\n      tlength = sqrt (tlength);\n      if (tlength == (double) 0.0)\n\ttlength = (double) 1.0;\n\n\n      /* Make scaling factor of tangent/derivative. */\n\n      tfak = (double) 1.0;\n      if (iip == 1 && iif != 1)\n\ttfak = tdist1 / (tval1 * tlength);\n      else if (iip != 1 && iif == 1)\n\ttfak = tdist2 / (tval2 * tlength);\n      else if (iip == 1 && iif == 1)\n\ttfak = min (tdist1 / (tval1 * tlength),\n\t\t    tdist2 / (tval2 * tlength));\n\n\n      /* Find actual length of derivative curve at the parameter value.\n\t Make new derivative length. */\n\n      pos2 = pos - idim;\n      for (kj = 0; kj < idim; kj++)\n\t{\n\t  kdc[pos2 + kj] *= tfak;\n\t}\n    }\n\n  /* Calculate new curve description. */\n\n  s1891 (kpar, kdc, idim, in, 1, kder, 1, et, &epd, &knh, ik, 0, 0, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  memcopy (deriv, epd, idim * in, DOUBLE);\n\n\n  /* OK */\n\n  goto out;\n\n\n  /* Allocation error. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1919\", *jstat, kpos);\n  goto out;\n\n  /* Error in description of B-spline. */\n\nerr112:\n  *jstat = -112;\n  s6err (\"s1919\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine. */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1919\", *jstat, kpos);\n  goto out;\n\nout:\n  if (epd != SISL_NULL)\n    freearray (epd);\n  if (kpc != SISL_NULL)\n    freearray (kpc);\n  if (kcc != SISL_NULL)\n    freearray (kcc);\n  if (kdc != SISL_NULL)\n    freearray (kdc);\n  if (kfc != SISL_NULL)\n    freearray (kfc);\n  if (kpar != SISL_NULL)\n    freearray (kpar);\n  if (kder != SISL_NULL)\n    freearray (kder);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1920.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1920.c,v 1.3 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1920\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1920(SISLCurve *pc1,double edir[],int idim,double aepsco,double aepsge,\n\t   int *jpt,double **gpar,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1920(pc1,edir,idim,aepsco,aepsge,jpt,gpar,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     double   edir[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find the extremal points/intervals of the curve pc1 in\n*              the direction edir.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve.\n*              edir   - The direction in which the extremal point(s)\n*                       and/or interval(s) are to be calculated. If\n*                       idim=1 a positive value indicates the maximum\n*                       of the B-spline function and a negative value\n*                       the minimum. If the dimension is greater that\n*                       1 the array contains the coordinates of the\n*                       direction vector.\n*              idim   - Dimension of the space in which the vector edir\n*                       lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : jpt    - Number of single extremal points.\n*              gpar   - Array containing the parameter values of the\n*                       single extremal points in the parameter\n*                       interval of the curve. The points lie continuous.\n*                       Extremal curves are stored in wcurve.\n*              jcrv   - Number of extremal curves.\n*              wcurve - Array containing descriptions of the extremal\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See descrjption of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The scalar-product of the coefficients of the curve with\n*              the vector edir is calculated giving a curve with dimension\n*              1. Then the maxima of this curve is calculated.\n*\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1880 - Put extremal points/intervals into output format.\n*              s1161 - Find maxima of one-dimensional curve.\n*              s6scpr - Scalar-product between two vectors.\n*              newCurve   - Create new curve.\n*              newObject  - Create new object.\n*              newIntpt   - Create new extremal point.\n*              freeObject - Free the space occupied by a given object.\n*              freeIntdat - Free space occupied by an extremal list.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-10.\n* REVISED BY : Mike Floater, SI, 1991-04 for a rational curve.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, 1994-08.  Updated to handle\n*              input curve with periodic basis correctly.\n*********************************************************************\n*/\n{\n  int ikind;               /* Type of curve pc1 is                     */\n  int kstat = 0;           /* Local status variable.                     */\n  int kpos = 0;            /* Position of error.                         */\n  int ki;                  /* Counter.                                   */\n  int kn;                  /* Number of vertices of curve.               */\n  int kk;                  /* Order of curve.                            */\n  double tmax;             /* Estimate of maximal value of 1-dim. curve. */\n  double *st;              /* Pointer to knotvector of curve.            */\n  double *scoef;           /* Pointer to vertices of curve.              */\n  double *sc = SISL_NULL;       /* Pointer to vertices of curve in maxima\n\t\t\t      calculation.                               */\n  double *spar = SISL_NULL;     /* Values of extremal points in the parameter\n\t\t\t      area of the second object. Empty in this case.*/\n  double *s1,*s2,*sstop;   /* Pointers used to traverse double-arrays.   */\n  SISLIntdat *qintdat = SISL_NULL;  /* Maximum results.                     */\n  SISLCurve *qc = SISL_NULL;        /* Pointer to curve in maxima calculation.    */\n  SISLObject *qo1 = SISL_NULL;      /* Pointer to object in maxima calculation. */\n  SISLCurve *qkreg = SISL_NULL;     /* Input curve with k-regularity ensured. */\n\n\n  *jpt = 0;\n  *jcrv = 0;\n\n\n  /* Ensure k-regular basis. */\n\n  if ( pc1 -> cuopen == SISL_CRV_PERIODIC )\n  {\n    /* Cyclic (periodic) basis. */\n\n    make_cv_kreg(pc1, &qkreg, &kstat);\n    if ( kstat < 0 )  goto error;\n  }\n  else\n    qkreg = pc1;\n\n\n  /* Check dimension.  */\n\n  if ( qkreg -> idim != idim )  goto err106;\n\n  /* Describe curve with local variables.  */\n\n  kn = qkreg -> in;\n  kk = qkreg -> ik;\n  st = qkreg -> et;\n  ikind = qkreg -> ikind;\n\n  if ( ikind == 2 || ikind == 4 )\n  {\n      scoef = qkreg -> rcoef;\n      /* Allocate space for coeffecients of new curve.  */\n\n      if ( (sc = newarray(2*kn, DOUBLE)) == SISL_NULL )  goto err101;\n\n      /* Compute scalar-product of curve-vertices and direction vector. */\n      /* Copy over weights. */\n\n      for ( s1=scoef, s2=sc, sstop=s2+2*kn;  s2<sstop;  s1+=idim+1, s2+=2 )\n      {\n          *s2 = s6scpr(s1, edir, idim);\n          *(s2+1) = *(s1+idim);\n      }\n  }\n  else\n  {\n      scoef = qkreg -> ecoef;\n      /* Allocate space for coeffecients of new curve.  */\n\n      if ( (sc = newarray(kn, DOUBLE)) == SISL_NULL )  goto err101;\n\n      /* Compute scalar-product of curve-vertices and direction vector. */\n\n      for ( s1=scoef, s2=sc, sstop=s2+kn;  s2<sstop;  s1+=idim, s2++ )\n      {\n          *s2 = s6scpr(s1, edir, idim);\n      }\n  }\n\n\n  /* Create new curve.  */\n\n  qc = newCurve(kn, kk, st, sc, qkreg->ikind, 1, 1);\n  if ( qc == SISL_NULL )  goto err101;\n\n  /* Create new object and connect curve to object.  */\n\n  qo1 = newObject(SISLCURVE);\n  if ( qo1 == SISL_NULL )  goto err101;\n  qo1 -> c1 = qc;\n\n  tmax = -(double)HUGE;\n\n  /* Find maxima. */\n  s1161(qo1, &tmax, aepsge, &qintdat, &kstat);\n  if ( kstat < 0 )  goto error;\n\n  if (qintdat)\n  {\n\n    /* Express maximal points/intervals on output format.  */\n    s1880(1, 0, &qintdat->ipoint, qintdat->vpoint,\n\t  &qintdat->ilist, qintdat->vlist,\n\t  jpt, gpar, &spar, jcrv, wcurve, &kstat);\n    if ( kstat < 0 )  goto error;\n\n    /* Handle periodicity (remove points at periodic curve ends). */\n    if ( *jpt > 1 && idim > 1 && pc1->cuopen == SISL_CRV_PERIODIC )\n    {\n      for ( ki=0; ki < (*jpt); ki++ )\n      {\n\tif ( (*gpar)[ki] == pc1->et[pc1->in] )\n\t{\n\t  (*jpt)--;\n\t  (*gpar)[ki] = (*gpar)[*jpt];\n\t  ki--;\n\t}\n      }\n    }\n  }\n\n  /* Extremal points/intervals found.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101:\n  *jstat = -101;\n  s6err(\"s1920\", *jstat, kpos);\n  goto out;\n\n  /* Dimensions conflicting.  */\n\n err106:\n  *jstat = -106;\n  s6err(\"s1920\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n error:\n  *jstat = kstat;\n  s6err(\"s1920\", *jstat, kpos);\n  goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if ( qkreg && qkreg != pc1 ) freeCurve(qkreg);\n  if (sc) freearray(sc);\n  if (spar) freearray(spar);\n  if (qintdat) freeIntdat(qintdat);\n  if (qo1) freeObject(qo1);\n\n\n  return;\n}\n"
  },
  {
    "path": "src/s1921.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1921.c,v 1.3 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1921\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1921(SISLSurf *ps1,double edir[],int idim,double aepsco,double aepsge,\n\t   int *jpt,double **gpar,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1921(ps1,edir,idim,aepsco,aepsge,jpt,gpar,jcrv,wcurve,jstat)\n     SISLSurf     *ps1;\n     double   edir[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find the extremal points/curves of the surface ps1 in\n*              the direction edir.\n*\n*\n* INPUT      : ps1    - Pointer to the surface.\n*              edir   - The direction in which the extremal point(s)\n*                       and/or interval(s) are to be calculated. If\n*                       idim=1 a positive value indicates the maximum\n*                       of the B-spline function and a negative value\n*                       the minimum. If the dimension is greater that\n*                       1 the array contains the coordinates of the\n*                       direction vector.\n*              idim   - Dimension of the space in which the vector edir\n*                       lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : jpt    - Number of single extremal points.\n*              gpar   - Array containing the parameter values of the\n*                       single extremal points in the parameter\n*                       area of the surface. The points lie continuous.\n*                       Extremal curves are stored in wcurve.\n*              jcrv   - Number of extremal curves.\n*              wcurve - Array containing descriptions of the extremal\n*                       curves. The curves are only described by points\n*                       in the parameter area. The curve-pointers points\n*                       to nothing. (See descrjption of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The scalar-product of the coefficients of the surface with\n*              the vector edir is calculated giving a surface with dimension\n*              1. Then the maxima of this surface is calculated.\n*\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1880 - Put extremal points/intervals into output format.\n*              s1161 - Find maxima of one-dimensional object.\n*              s6scpr - Scalar-product between two vectors.\n*              newSurf    - Create new surface\n*              newObject  - Create new object.\n*              newIntdat  - Create new max point .\n*              freeObject - Free the space occupied by a given object.\n*              freeIntdat  - Free space occupied by an extremal data.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-10.\n* REVISED BY : Mike Floater, SI, 91-09.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, 1994-08.  Updated to handle\n*              input surface with periodic basis correctly.\n*\n*********************************************************************\n*/\n{\n  int ikind;               /* Type of surface ps1 is.                     */\n  int kstat = 0;           /* Local status variable.                      */\n  int kpos = 0;            /* Position of error.                          */\n  int ki;                  /* Counter.                                    */\n  int kn1,kn2;             /* Number of vertices of surface.              */\n  int kk1,kk2;             /* Order of surface.                           */\n  double tmax;             /* Estimate of maximal value of 1-dim. surface.*/\n  double *st1,*st2;        /* Pointer to knotvectors of surface.          */\n  double *scoef;           /* Pointer to vertices of surface.             */\n  double *sc = SISL_NULL;       /* Pointer to vertices of surface in maxima\n\t\t\t      calculation.                                */\n  double *spar = SISL_NULL;     /* Values of maxima in the parameter area of\n\t\t\t      the second object. Empty in this case.      */\n  double *s1,*s2,*sstop;   /* Pointers used to traverse double-arrays.    */\n  SISLIntdat *qintdat = SISL_NULL;  /* Pointer to max data structure.*/\n  SISLSurf *qs = SISL_NULL;         /* Pointer to 1-dim. surface in maxima-calculation.*/\n  SISLObject *qo1 = SISL_NULL;      /* Pointer to object in maxima-calculation.  */\n  SISLSurf *qkreg = SISL_NULL;      /* Input surface with k-regularity ensured.  */\n\n\n  /* Ensure k-regular input surface. */\n\n  if ( ps1 -> cuopen_1 == SISL_SURF_PERIODIC ||\n       ps1 -> cuopen_2 == SISL_SURF_PERIODIC )\n  {\n    /* Cyclic (periodic) surface */\n\n    make_sf_kreg(ps1, &qkreg, &kstat);\n    if ( kstat < 0 )  goto error;\n  }\n  else\n    qkreg = ps1;\n\n\n  /* Check dimension.  */\n\n  if ( qkreg -> idim != idim )  goto err106;\n\n  /* Describe surface with local variables.  */\n\n  kn1 = qkreg -> in1;\n  kn2 = qkreg -> in2;\n  kk1 = qkreg -> ik1;\n  kk2 = qkreg -> ik2;\n  st1 = qkreg -> et1;\n  st2 = qkreg -> et2;\n  ikind = qkreg -> ikind;\n\n  if ( ikind == 2 || ikind == 4 )\n  {\n    scoef = qkreg -> rcoef;\n    /* Allocate space for coeffecients of new surface.  */\n\n    if ( (sc = newarray(2*kn1*kn2, DOUBLE)) == SISL_NULL )  goto err101;\n\n    /* Compute scalar-product of surface-vertices and direction vector. */\n    /* Copy over weights. */\n\n    for ( s1=scoef, s2=sc, sstop=s2+2*kn1*kn2;  s2 < sstop;  s1+=idim+1, s2+=2 )\n    {\n      *s2 = s6scpr(s1, edir, idim);\n      *(s2+1) = *(s1+idim);\n    }\n  }\n  else\n  {\n    scoef = qkreg -> ecoef;\n    /* Allocate space for coeffecients of new surface.  */\n\n    if ( (sc = newarray(kn1*kn2, DOUBLE)) == SISL_NULL )  goto err101;\n\n    /* Compute scalar-product of surface-vertices and direction vector. */\n\n    for ( s1=scoef, s2=sc, sstop=s2+kn1*kn2;  s2 < sstop;  s1+=idim, s2++ )\n      *s2 = s6scpr(s1, edir, idim);\n  }\n\n\n  /* Create new surface.  */\n\n  qs = newSurf(kn1, kn2, kk1, kk2, st1, st2, sc, qkreg->ikind, 1, 1);\n  if ( qs == SISL_NULL )  goto err101;\n\n  /* Create new object and connect surface to object.  */\n\n  qo1 = newObject(SISLSURFACE);\n  if ( qo1 == SISL_NULL )  goto err101;\n  qo1 -> s1 = qs;\n\n  /* Find maxima.  */\n\n  /* Find maxima. */\n  tmax = -(double)HUGE;\n\n  s1161(qo1, &tmax, aepsge, &qintdat, &kstat);\n  if ( kstat < 0 )  goto error;\n\n  if (qintdat)\n  {\n\n    /* Express maximal points/intervals on output format.  */\n    s1880(2, 0, &qintdat->ipoint, qintdat->vpoint,\n\t  &qintdat->ilist, qintdat->vlist,\n\t  jpt, gpar, &spar, jcrv, wcurve, &kstat);\n    if ( kstat < 0 )  goto error;\n\n    /* Handle periodicity (remove extraneous points) */\n\n    if ( *jpt > 1  &&  idim > 1 && (ps1 -> cuopen_1 == SISL_SURF_PERIODIC ||\n\t\t\t\t    ps1 -> cuopen_2 == SISL_SURF_PERIODIC ) )\n    {\n      for ( ki=0; ki < (*jpt); ki++ )\n      {\n\tif ( (ps1 -> cuopen_1 == SISL_SURF_PERIODIC &&\n\t      (*gpar)[2*ki]   == ps1 -> et1[ps1->in1]) ||\n\t     (ps1 -> cuopen_2 == SISL_SURF_PERIODIC &&\n\t      (*gpar)[2*ki+1] == ps1 -> et2[ps1->in2]) )\n\t{\n\t  (*jpt)--;\n\t  (*gpar)[2*ki]   = (*gpar)[2*(*jpt)];\n\t  (*gpar)[2*ki+1] = (*gpar)[2*(*jpt)+1];\n\t  ki--;\n\t}\n      }\n    }\n  }\n\n  /* Extremal points/intervals found.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101:\n  *jstat = -101;\n  s6err(\"s1921\",*jstat,kpos);\n  goto out;\n\n  /* Dimensions conflicting.  */\n\n err106:\n  *jstat = -106;\n  s6err(\"s1921\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n error:\n  *jstat = kstat;\n  s6err(\"s1921\",*jstat,kpos);\n  goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if ( qkreg && qkreg != ps1 )  freeSurf(qkreg);\n  if (sc) freearray(sc);\n  if (spar) freearray(spar);\n  if (qo1) freeObject(qo1);\n  if (qintdat) freeIntdat(qintdat);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1924.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1924.c,v 1.2 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1924\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1924 (int id1, int id2, int id3, int id4, int in1, int in2,\n       double **ew, int *jstat)\n#else\nvoid\ns1924 (id1, id2, id3, id4, in1, in2, ew, jstat)\n     int id1;\n     int id2;\n     int id3;\n     int id4;\n     int in1;\n     int in2;\n     double **ew;\n     int *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    :\tTo compute the weight matrix to blend together two\n*\t\tsurfaces.\n*\n*\n* INPUT      :\tid1\t- Derivative on edge one up to (id1-1).\n*\t\tid2\t- Derivative on edge two up to (id2-1).\n*\t\tid3\t- Derivative on edge three up to (id3-1).\n*\t\tid4\t- Derivative on edge four up to (id4-1).\n*\t\tin1\t- Size of matrix in first direction\n*\t\tin2\t- Size of matrix in second direction\n*\n*\n* OUTPUT     :  ew\t- Matrix containing the weights.\n*            :  jstat   - output status:\n*                         < 0: error.\n*                         = 0: ok.\n*                         > 0: warning.\n*\n*\n* REFERENCES :  Fortran version:\n*\t\tMorten Daehlen, SI, 1987-01\n*\n* CALLS: s6err.\n*\n*\n* WRITTEN BY :  Christophe R. Birkeland, SI, 1991-08\n*\n*********************************************************************\n*/\n{\n  int ki, kj;\t\t\t/* Loop control parameters \t\t*/\n  int in1m1, in2m1;\t\t/* Equals in1-1 and in2-1\t\t*/\n  int kpos = 0;\n\n  *jstat = 0;\n\n\n  /* Initialization */\n\n  *ew = new0array (in1 * in2, double);\n  if (*ew == SISL_NULL)\n    goto err101;\n\n  in1m1 = in1 - 1;\n  in2m1 = in2 - 1;\n  (*ew)[0] = (double) 0.5;\n  (*ew)[in1m1] = (double) 0.5;\n  (*ew)[in2m1 * in1] = (double) 0.5;\n  (*ew)[in2m1 * in1 + in1m1] = (double) 0.5;\n\n  for (ki = 1; ki < in1m1; ki++)\n    {\n      (*ew)[ki] = (double) 1.0;\n      for (kj = 1; kj < id1; kj++)\n\tif (ki < id4 || ki >= in1 - id2)\n\t  (*ew)[kj * in1 + ki] = (double) 0.5;\n\telse\n\t  (*ew)[kj * in1 + ki] = (double) 1.0;\n\n      (*ew)[in2m1 * in1 + ki] = (double) 1.0;\n      for (kj = in2 - id3; kj < in2m1; kj++)\n\tif (ki < id4 || ki >= in1 - id2)\n\t  (*ew)[kj * in1 + ki] = (double) 0.5;\n\telse\n\t  (*ew)[kj * in1 + ki] = (double) 1.0;\n    }\n\n  for (kj = id1; kj < in2 - id3; kj++)\n    for (ki = id4; ki < in1 - id2; ki++)\n      {\n\tif ((double) (kj + 1) <= (double) (in2 + 1) / (double) 2.0)\n\t  {\n\t    if ((double) (ki + 1) <= (double) (in1 + 1) / (double) 2.0)\n\t      (*ew)[kj * in1 + ki] = (double) (ki + 1) / (ki + kj + 2);\n\t    else\n\t      (*ew)[kj * in1 + ki] = (double) (in1 - ki) / (in1 - ki + kj + 1);\n\t  }\n\telse\n\t  {\n\t    if ((double) (ki + 1) <= (double) (in1 + 1) / (double) 2.0)\n\t      (*ew)[kj * in1 + ki] = (double) (ki + 1) / (ki + 1 + in2 - kj);\n\t    else\n\t      (*ew)[kj * in1 + ki] = (double) (in1 - ki) / (in1 + in2 - ki - kj);\n\t  }\n      }\n\n  /* Ok. */\n\n  goto out;\n\n\n  /* Memory error. */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1924\", *jstat, kpos);\n  goto out;\n\nout:\n\n  return;\n}\n"
  },
  {
    "path": "src/s1925.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1925.c,v 1.3 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1925\n\n#include \"sislP.h\"\n#define s1925_MAX_ARRAY_SIZE 50\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1925 (double etau[], double epoint[], int inbpnt, int eder[],\n       double et[], double ebcoef[], int in, int ik, int iright, int dim,\n       double ew1[], int nur, int ed[], double ew2[], int inrc, double ew3[],\n       int inlr, int *jstat)\n#else\nvoid\ns1925 (etau, epoint, inbpnt, eder, et, ebcoef, in, ik, iright, dim, ew1, nur,\n       ed, ew2, inrc, ew3, inlr, jstat)\n     double etau[];\n     double epoint[];\n     int inbpnt;\n     int eder[];\n     double et[];\n     double ebcoef[];\n     int in;\n     int ik;\n     int iright;\n     int dim;\n     double ew1[];\n     int nur;\n     int ed[];\n     double ew2[];\n     int inrc;\n     double ew3[];\n     int inlr;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : \tTo calculate B-spline coefficients ebcoef required for\n*\t\tinterpolation of epoint(i) at etau(i); i=0,1,...,inbpnt-1\n*\n* INPUT      :\tetau\t- Vector containing the parametrization of the data\n*\t\t\t  points/derivatives/second-derivatives.\n*\t\tepoint\t- Points/derivatives/second-derivatives to be inter-\n*\t\t\t  polated. Only entries from epoint are used.\n*\t\tinbpnt\t- Number of points/derivatives/second-derivatives\n*\t\t\t  to be interpolated.\n*\t\teder\t- Indicator for the order of derivative of the data\n*\t\t\t  to be interpolated.\n*\t\tet\t- Knot vector of B-spline. Length: in+ik\n*\t\tin\t- Number of vertices in B-spline to be produced.\n*\t\tik\t- Order of B-spline to be produced\n*\t\tiright\t- Number of right hand sides of dimension (dim*in)\n*\t\tdim\t- The dimension of space in which the points lie\n*\t\tew1,    - Arrays defining elements of W.\n*\t\tnur\t- Number of upper rows of W.\n*\t\ted      -\n*\t\tew2     - Detailed description: see subroutine s1898.\n*\t\tinrc\t- Number of right columns of W.\n*\t\tew3     -\n*\t\tinlr\t- Number of lower rows of W\n*\n* OUTPUT     :\tebcoef\t- Coefficients of interpolating B-spline.\n*\t\t\t  Stored in array of dimension (1:dim*inbpnt).\n*               ew1     - Arrays defining elements of LU-factorization of W.\n*\t\ted      -\n*               ew2     -\n*\t\tew3 \t- Detailed description: see subroutine s1898\n*               jstat   - Output status:\n*                         < 0: Error.\n*                         = 0: Ok.\n*                         > 0: Warning.\n*\n* METHOD     : \tThe i-th equation of the set  W*ebcoef = B  enforces\n*\t\tinterpolation of B(i) at etau(i). Thus B(i)=epoint(i).\n*\t\tW is generated row by row and stored in ew1,ew2 and ew3\n*\t\tas described in subroutine s1898. The system is solved by\n*\t\tone call to s1898 and then by 'dim' calls to s1899.\n*\n* REFERENCES : \tFortran version:\n*\t\tE.Aarn[s, CP, 1979-01\n*\n* CALLS      : \ts1897,s1926,s1927,s6err.\n*\n* WRITTEN BY : \tChristophe R. Birkeland\n* REVISED BY :  Johannes Kaasa, SI, June 1992 (Introduced iadd_save)\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\n  int kpos = 0;\t\t\t/* Position of error\t\t\t*/\n  int open;\t\t\t/* Used as a boolean parameter to\n\t\t\t\t * indicate open or closed curve:\n\t\t\t\t * open=TRUE   ; Open curve\n\t\t\t  \t * open=FALSE  ; Closed curve  \t\t*/\n  int left;\t\t\t/* An integer chosen (usually) so that\n\t\t\t\t * et(left-1)<=point<et(left)\t\t*/\n  int leftmax;\n  int leftmin;\n  int leftdel;\n  int kmod;\t\t\t/* Used in calculation of ew3 index  \t*/\n  int isum;\n  int ii, jj, kl, stop;\t\t/* Loop control parameters\t\t*/\n  int dim1;\t\t\t/* Loop control parameter,\n\t\t\t\t * values: 0..dim-1 \t\t\t*/\n  int imnur;\t\t\t/* Equals ii-nur\t\t\t*/\n  int nn;\t\t\t/* Equals nur+inlr\n\t\t\t\t * i.e. Number of rows/columns in W\t*/\n  int nlc;\t\t\t/* Number of lower columns\n\t\t\t\t * Equals inbpnt-inrc\t\t\t*/\n  int kk;\t\t\t/* Minimum: ik or nlc\t\t\t*/\n  double tk;\t\t\t/* ik-th element of knot vector \t*/\n  double taudel;\t\t/* to left and taui\t\t\t*/\n  int lfmkm;\t\t\t/* Equals left-ik\t\t\t*/\n  int iadd;\n  int iadd_save;\n  int kmiadd;\n  int isub;\n  int kmisub;\t\t\t/* Equals ik-isub\t\t\t*/\n  int ish;\n  int ideri;\t\t\t/* Derivative order indicator \t\t*/\n  int store;\n\n  double taui;\t\t\t/* Parametrization value = etau[ii] \t*/\n  double *mcoef = SISL_NULL;\t\t/* Arrays for internal use in \t\t*/\n  double *ebder = SISL_NULL;\t\t/* this subroutine\t\t\t*/\n  double sarray[s1925_MAX_ARRAY_SIZE];\n  int alloc_needed=FALSE;\n  \n  *jstat = 0;\n\n  nn = nur + inlr;\n\n  /* Test if legal input */\n\n  if (ik < 1)\n    goto err109;\n\n  if ((nur < 0) || ((nur + inlr) != inbpnt) || (inrc < 0) || (inlr < 0))\n    goto err160;\n\n  nlc = inbpnt - inrc;\n  kk = MIN (ik, nlc);\n  tk = et[ik - 1];\n\n\n  /* Test if open or closed curve */\n\n  if (inbpnt == in)\n    open = TRUE;\n  else\n    open = FALSE;\n\n  if (open == TRUE)\n    {\n      /* Open curve */\n\n      taudel = (double) 0.0;\n      leftdel = 0;\n      leftmin = ik - 1;\n      leftmax = in -1;\n      if ((inrc != 0) || (inlr != 0))\n\tgoto err160;\n    }\n  else\n    {\n      /* Closed curve, note: we assume that et(in) < etau(inbpnt) */\n\n      if ((inbpnt + ik - 1) != in)\n\tgoto err160;\n      leftdel = in +1 - ik;\n      iadd = (ik - 1) / 2;\n      leftmax = leftdel + iadd - 1;\n      leftmin = ik - iadd - 1;\n      taudel = et[in] -tk;\n\n      if ((iadd != inrc) || ((inrc + inlr) != (ik - 1)))\n\tgoto err160;\n\n      if (inrc > 0)\n\t{\n\t  stop = nur * inrc;\n\t  for (ii = 0; ii < stop; ii++)\n\t    ew2[ii] = (double) 0.0;\n\t}\n    }\n\n  /* Band part of W */\n\n  /* Allocate array ebder */\n\n  left = leftmin;\n  if (ik > s1925_MAX_ARRAY_SIZE)\n    {\n       if ((ebder = newarray (ik, DOUBLE)) == SISL_NULL)\n\t goto err101;\n\talloc_needed = TRUE;\n    }\n  else\n    ebder = sarray;\n  \n  for (ii = 0; ii < nur; ii++)\n    {\n      taui = etau[ii];\n      ideri = eder[ii];\n\n\n      /* Locate left so that  et[left] <= taui < et[left+1] */\n\n      while (left < leftmax && et[left + 1] <= taui)\n\tleft++;\n\n\n      /* et(left-1) <= taui < et(left)  */\n\n      ed[ii] = ii - (left - ik);\n\n\n      /* Test if error in interpolation problem */\n\n      if ((ed[ii] < 1) || (ed[ii] > ik))\n\tgoto err165;\n\n\n      iadd = MAX (0, ik - left - 1);\n      iadd_save = iadd;\n      kmiadd = ik - iadd;\n\n\n      /* Compute the value and ideri first derivative of the\n      ik (possibly) nonzero B-spline associated with the knot\n      vector et at a point \t\t\t\t    */\n\n      if (iadd > 0)\n\t{\n\t  s1897 (et, ik, taui + taudel, left + leftdel, ideri, ebder, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  ed[ii] -= iadd;\n\t  ish = inrc - iadd;\n\t  if ((ish < 0) || (kmiadd < 0))\n\t    goto err160;\n\n\t  for (jj = 0; jj < iadd; jj++)\n\t    {\n\t      ew1[(jj + kmiadd) * nur + ii] = (double) 0.0;\n\t      ew2[(jj + ish) * nur + ii] = ebder[jj];\n\t    }\n\t}\n      else\n\t{\n\t  s1897 (et, ik, taui, left, ideri, ebder, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n\n      isub = MAX (0, ii - ed[ii] + kmiadd - nlc + 1);\n      kmisub = ik - isub;\n      if (isub > 0)\n\t{\n\t  ish = isub - (kmiadd - kk);\n\t  ed[ii] += ish;\n\t  iadd -= ish;\n\t  if (kmisub < 0)\n\t    goto err160;\n\t  stop = MIN (ik, kmisub + inrc);\n\n\t  for (jj = kmisub; jj < stop; jj++)\n\t    {\n\t      ew1[(jj - kmisub) * nur + ii] = (double) 0.0;\n\t      ew2[(jj - kmisub) * nur + ii] = ebder[jj];\n\t    }\n\t}\n      for (jj = iadd_save; jj < kmisub; jj++)\n\tew1[(jj - iadd) * nur + ii] = ebder[jj];\n\n\n      /* Test if error in dimension of interpolation problem */\n\n      if ((ideri < 0) || (ik <= ideri))\n\tgoto err160;\n    }\n\n  /* Band part of W is now completed */\n\n  if (ii < inbpnt)\n    {\n      /* Will compute lower, filled part of W for closed\n\t curve interpolation */\n\n      if ((inbpnt + ik - 1) != in)\n\tgoto err160;\n      store = inlr * inbpnt;\n      for (jj = 0; jj < store; jj++)\n\tew3[jj] = (double) 0.0;\n\n\n      /* Repeat until filled part of W is completed */\n\n      for (; ii < inbpnt; ii++)\n\t{\n\t  taui = etau[ii];\n\n\n\t  /* Locate left so that  et[left] <= taui < et[left+1] */\n\n\t  while (left < in -1 && et[left + 1] <= taui)\n\t    left++;\n\n\n\t  /* et(left-1) <= taui < et(left)  */\n\n\t  ideri = eder[ii];\n\n\n\t  /* Compute the value and the ideri first derivatives of the\n\t     ik (possibly) nonzero B-spline associated with the knot\n\t     vector et at the point (taui) */\n\n\t  s1897 (et, ik, taui, left, ideri, ebder, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  imnur = ii - nur;\n\t  lfmkm = left - ik;\n\t  for (jj = 0; jj < ik; jj++)\n\t    {\n\t      isum = jj + lfmkm + 1;\n\t      if (isum >= 0)\n\t\tkmod = isum % inbpnt;\n\t      if (isum < 0)\n\t\tkmod = (isum + 1) % inbpnt + in -1;\n\t      ew3[kmod * inlr + imnur] = ebder[jj];\n\t    }\n\t  if ((ideri < 0) || (ik <= ideri))\n\t    goto err160;\n\t}\n    }\n  if (inlr != (inbpnt - nur))\n    goto err160;\n\n\n  /* W is now contained in ew1, ew2 and ew3 as required\n     by the subroutine s1898  */\n\n  s1926 (ew1, nur, kk, ed, ew2, inrc, ew3, inlr, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  store = iright * dim * inbpnt;\n  for (jj = 0; jj < store; jj++)\n    ebcoef[jj] = epoint[jj];\n\n\n  /* epoint is now properly contained in ebcoef.\n   * Solve interpolation equations \t\t */\n\n  if (nn > s1925_MAX_ARRAY_SIZE)\n    {\n       if (alloc_needed)\n\t {\n\t    if ((ebder = increasearray(ebder,nn,DOUBLE)) == SISL_NULL)\n\t      goto err101;\n\t }\n       else\n\t {\n\t    if ((ebder = newarray(nn,DOUBLE)) == SISL_NULL)\n\t      goto err101;\n\t    alloc_needed = TRUE;\n\t }\n    }\n\n  for (kl = 0; kl < iright; kl++)\n    for (dim1 = 0; dim1 < dim; dim1++)\n      {\n\tstore = inbpnt * dim * kl + dim1;\n\tfor (jj = 0; jj < nn; jj++, store += dim)\n\t  ebder[jj] = ebcoef[store];\n\n\ts1927 (ew1, nur, kk, ed, ew2, inrc, ew3, inlr, &mcoef, ebder, &kstat);\n\tif (kstat < 0)\n\t  goto error;\n\n\tstore = inbpnt * dim * kl + dim1;\n\tfor (jj = 0; jj < nn; jj++, store += dim)\n\t  ebcoef[store] = mcoef[jj];\n\n        if(mcoef != SISL_NULL)       /* KYS 200594: healed memory leak */\n        {\n          freearray(mcoef);\n          mcoef = SISL_NULL;\n        }\n      }\n\n  goto out;\n\n\n  /* Error in array allocations */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1925\", *jstat, kpos);\n  goto out;\n\n  /* Order of B-spline zero or negative */\n\nerr109:\n  *jstat = -109;\n  s6err (\"s1925\", *jstat, kpos);\n  goto out;\n\n  /* Error in dimension of interpolation problem */\n\nerr160:\n  *jstat = -160;\n  s6err (\"s1925\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1925\", *jstat, kpos);\n  goto out;\n\n  /* Error in interpolation problem */\n\nerr165:\n  *jstat = -165;\n  s6err (\"s1925\", *jstat, kpos);\n  goto out;\n\nout:\n  if (alloc_needed)\n    freearray (ebder);\n  if (mcoef != SISL_NULL)\n    freearray (mcoef);\n  return;\n}\n#undef s1925_MAX_ARRAY_SIZE\n"
  },
  {
    "path": "src/s1926.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1926.c,v 1.2 2005-02-28 09:04:49 afr Exp $\n *\n */\n\n\n#define S1926\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1926 (double *w1, int nur, int ik, int *ed, double *w2, int nrc,\n       double *w3, int nlr, int *jstat)\n#else\nvoid\ns1926 (w1, nur, ik, ed, w2, nrc, w3, nlr, jstat)\n     double *w1;\n     int nur;\n     int ik;\n     int *ed;\n     double *w2;\n     int nrc;\n     double *w3;\n     int nlr;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    :  To calculate the LU-factorization of an almost banded matrix W.\n*\n*\n* INPUT      :  w1  \t- Upper part of W. Dimension (1:nur*ik).\n*\t\tnur\t- Number of rows of upper part.\n*\t\tik\t- Number of non-zero entries of each upper row.\n*\t\ted\t- Pointers do diagonal elements of W.\n*\t\tw2\t- Right part of W. Dimension (1:nur*nrc).\n*\t\tnrc\t- Number of right columns of W.\n*\t\tw3\t- Lower part of W. Dimension (1:nlr*(nur+nlr)).\n*\t\tnlr\t- Number of lower rows.\n*\n* OUTPUT     :  w1      -\n*               w2      -\n*               w3      - Contain the LU-factorization on return. L is lower\n*\t\t\t  triangular, and U is upper triangular with ones on\n*\t\t \t  the diagonal.\n*               jstat   - Output status:\n*                          < 0: Error.\n*                          = 0: Ok.\n*                          > 0: Warning.\n*\n* METHOD     : The matrix W is of the following form:\n*\n*                 1 2 3 4 5 6 7 8 9   ED(.)\n*              1  D X X X         Y     1\n*              2  X D X X         Y     2\n*              3    X D X X       Y     2\n*              4        D X X X   Y     1\n* \t       5          D X X X Y     1\n*\t       6          X D X X Y     2\n*   \t       7          X X D X Y     3\n*\t       8  Z Z Z Z Z Z Z D Z     -\n*\t       9  Z Z Z Z Z Z Z Z D     -\n*\n*\n*               w1[1:nur*ik] is used to store the upper nur rows of W,\n*\t\teach row containing ik non-zero entries. The positions of\n*\t\tW[i,i] ; i=1,2,...,[nur+nlr]  are indicated in ed[1:nur]. In\n*               the above example: nur=7, ik=4 and ed[1:7] is indicated to the\n*\t\tright. The diagonal elements of W are indicated with D's,\n*\t\tand the elements of w1 are indicated with X's.\n*\n*\t\tw2[1:nur*nrc] is used to store the right nrc columns of W,\n* \t\teach column containing nur entries. In the above example,\n*\t\tnrc=1, w2 is indicated with Y's.\n*\n*\t\tw3[1:nlr*(nur+nlr)] is used to store the lower nlr rows of W.\n*\t\tIn the above example, nlr=2 and nur+nlr=9 (total number of\n*\t\trows/columns). w3 is indicated with Z's in the above example.\n*\n* REFERENCES :  Fortran version:\n*               E.Aarn[s, CP, 1979-01\n*\n* CALLS      : s6err.\n*\n*\n* WRITTEN BY :  Christophe R. Birkeland\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\n  int ii, jj;\t\t\t/* Loop control parameters \t\t*/\n  int ll;\n  int nn;\t\t\t/* Number of rows/columns in W \t\t*/\n  int nlc;\t\t\t/* Number of left columns in W \t\t*/\n  int di;\t\t\t/* Pointer to diagonal element of W   \t*/\n  int midi;\t\t\t/* Parameters used in elimination alg.  */\n  int midl;\n  int korr;\t\t\t/* midl - midi \t\t\t\t*/\n  int mur;\t\t\t/* Used in calculation of index for w3  */\n  double wii;\t\t\t/* Used to store values from matrix W   */\n  double wli;\n\n  *jstat = 0;\n\n\n  /* Test if legal dimension of interpolation problem */\n\n  if (nur < 1 || (nur >= 1 && ik < 1) || nrc < 0 || nlr < 0)\n    goto err160;\n\n  nn = nur + nlr;\n  nlc = nn - nrc;\n  if (ik > nlc)\n    goto err160;\n\n\n  /* Elimination scheme, jump if band part of W is completed */\n\n  for (ii = 0; ii < nur; ii++)\n    {\n      di = ed[ii];\n      wii = w1[(di - 1) * nur + ii];\n\n\n      /* Test for errors */\n\n      if (ii >= nlc)\n\tgoto err163;\n      if ((di < 1) || (ik < di) || (wii == 0.0))\n\tgoto err162;\n\n\n      /* Jump if W(ii,jj) is trivially zero, jj = ii+1,ii+2,...,nlr */\n\n      if (di < ik)\n\t{\n\t  for (jj = di; jj < ik; jj++)\n\t    w1[jj * nur + ii] /= wii;\n\n\n\t  /* Perform elimination row by row */\n\n\t  midi = ii - di;\n\t  for (ll = ii + 1;; ll++)\n\t    {\n\t      /* Jump if ii-th element of rows of band-part has been\n               * eliminated */\n\n\t      if (ll >= nur)\n\t\tbreak;\n\t      midl = ll - ed[ll];\n\n\n\t      /* Jump if W(ii,jj) is trivially zero, jj = ll,ll+1,...,nur */\n\n\t      if (midl >= ii)\n\t\tbreak;\n\t      korr = midl - midi;\n\t      wli = w1[(di - korr - 1) * nur + ll];\n\t      for (jj = di; jj < ik; jj++)\n\t\tw1[(jj - korr) * nur + ll] += -w1[jj * nur + ii] * wli;\n\t    }\n\n\t  /*  Eliminate ii-th column of w3 using ii-th row from w1 */\n\n\t  if (nlr > 0)\n\t    for (ll = 0; ll < nlr; ll++)\n\t      {\n\t\twli = w3[ii * nlr + ll];\n\t\tfor (jj = di; jj < ik; jj++)\n\t\t  w3[(jj + midi + 1) * nlr + ll] -= w1[jj * nur + ii] * wli;\n\t      }\n\t}\n    }\n\n  /* Apply the above elimination scheme on w2 */\n\n  if (nrc > 0)\n    {\n      /* Jump if band part of W is completed or if system error\n       * occures, i.e. if w2 contains some diagonal elements of W) */\n\n      for (ii = 0; ii < nur; ii++)\n\t{\n\t  /* Test for error */\n\n\t  if (ii > nlc)\n\t    goto err163;\n\n\t  di = ed[ii];\n\t  wii = w1[(di - 1) * nur + ii];\n\t  for (jj = 0; jj < nrc; jj++)\n\t    w2[jj * nur + ii] /= wii;\n\n\n\t  /* Perform elimination row by row */\n\n\t  midi = ii - di;\n\t  for (ll = ii + 1;; ll++)\n\t    {\n\n\t      /*  Jump if ii-th element of rows of band-part has been\n\t          eliminated                                          */\n\n\t      if (ll >= nur)\n\t\tbreak;\n\t      midl = ll - ed[ll];\n\n\n\t      /* Jump if W(ii,jj) is trivially zero, jj = ll,ll+1,...,nur */\n\n\t      if (midl >= ii)\n\t\tbreak;\n\t      korr = midl - midi;\n\t      wli = w1[(di - korr - 1) * nur + ll];\n\t      for (jj = 0; jj < nrc; jj++)\n\t\tw2[jj * nur + ll] -= w2[jj * nur + ii] * wli;\n\t    }\n\n\t  /*  Eliminate ii-th column of w3 using ii-th row from w2 */\n\n\t  for (ll = 0; ll < nlr; ll++)\n\t    {\n\t      wli = w3[ii * nlr + ll];\n\t      for (jj = nlc; jj < nn; jj++)\n\t\tw3[jj * nlr + ll] -= w2[(jj - nlc) * nur + ii] * wli;\n\t    }\n\t}\n    }\n\n  /* Eliminate w3-part of W */\n\n  if (ii >= nn)\n    goto out;\n  for (; ii < nn; ii++)\n    {\n\n      /* 1 <= ii <= nn */\n\n      mur = ii - nur;\n      wii = w3[ii * nlr + mur];\n      if (wii == (double) 0.0)\n\tgoto err162;\n\n\n      /*  1 <= ii < nn */\n\n      for (jj = ii + 1; jj < nn; jj++)\n\tw3[jj * nlr + mur] /= wii;\n      for (ll = mur + 1; ll < nlr; ll++)\n\t{\n\t  wli = w3[ii * nlr + ll];\n\t  for (jj = ii + 1; jj < nn; jj++)\n\t    w3[jj * nlr + ll] -= w3[jj * nlr + mur] * wli;\n\t}\n    }\n\n  goto out;\n\n\n  /* W may be non-invertible */\n\nerr162:\n  *jstat = -162;\n  s6err (\"s1926\", *jstat, kpos);\n  goto out;\n\n  /* Error in dimension in interpolation problem */\n\nerr160:\n  *jstat = -160;\n  s6err (\"s1926\", *jstat, kpos);\n  goto out;\n\n  /* w2 contains diagonal elements */\n\nerr163:\n  *jstat = -163;\n  s6err (\"s1926\", *jstat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1927.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1927.c,v 1.3 2005-02-28 09:04:49 afr Exp $\n *\n */\n\n\n#define S1927\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1927 (double *w1, int nur, int ik, int *ed, double *w2, int nrc,\n       double *w3, int nlr, double *ex[], double *ey, int *jstat)\n#else\nvoid\ns1927 (w1, nur, ik, ed, w2, nrc, w3, nlr, ex, ey, jstat)\n     double *w1;\n     int nur;\n     int ik;\n     int *ed;\n     double *w2;\n     int nrc;\n     double *w3;\n     int nlr;\n     double *ex[];\n     double *ey;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : \tTo solve the equation  W*ex = ey  where W is an almost\n*\t\tbanded matrix whose LU-factorization is contained in\n*\t\tw1, w2, w3.\n*\n*\n* INPUT      : \tw1\t\t- Upper part of LU-factorization of W.\n*\t\t\t\t  Dimension (1:nur*ik-1).\n*\t\tnur\t\t- Number of upper rows of W.\n*\t\tik\t\t- Number of non-zero entries in each upper\n*\t\t\t\t  row of W.\n*\t\ted\t\t- Pointers to the diagonal elements in w1.\n*\t\tw2\t\t- Right part of LU-factorization of W.\n*\t\t\t\t  Dimension (1:nur*nrc-1).\n*\t\tnrc\t\t- Number of right columns of W.\n*\t\tw3\t\t- Lower part of LU-factorization of W.\n*\t\t\t\t  Dimension (1:nlr*(nur+nlr)-1).\n*\t\tnlr\t\t- Number of lower rows.\n*\t\tey\t\t- Right side of equation.\n*\t\t\t\t  Dimension (1:nur+nlr-1).\n*\t\tdim\t\t- Number of rows of the arrays ey and ex.\n*\n* OUTPUT     :\tex\t\t- Solution to W*ex=ey. Dimension (1:nur+nlr-1).\n*               jstat           - Output status:\n*                                 < 0: Error.\n*                                 = 0: Ok.\n*                                 > 0: Warning.\n*\n* METHOD     :\tA description of the form of the matrix W may be found in the\n*\t\tsubroutine s1898.\n*\t\tSince the LU-factorization of W is contained in w1 and w3, the\n*\t\tsolution of W*ex=ey proceeds as follows:\n*\t\tFirst solve L*z=ey, then solve U*ex=z.\n*\n* REFERENCES :\tFortran version:\n*\t\tE.Aarn[s, CP, 79-01\n*\n* CALLS      :\n*\n* WRITTEN BY : \tChristophe R. Birkeland, SI, 1991-06\n* REWRITTEN BY :\n* REVISED BY :\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\n  int ii, jj;\t\t\t/* Loop control parameters \t\t*/\n  int di;\t\t\t/* Pointer to diagonal element of W \t*/\n  int midi;\t\t\t/* Parameter always equal: ii-di\t*/\n  int dim;\t\t\t/* di minus 2:  di-2\t\t\t*/\n  int mur;\t\t\t/* Used in calculation of index for w3  */\n  int nn;\t\t\t/* Number of rows/columns in w3\t\t*/\n  int nlc;\t\t\t/* Number of left columns in W\t\t*/\n  double wii;\t\t\t/* Used to store values from matrix W\t*/\n  double sum;\t\t\t/* Stores values for calculation of ex \t*/\n\n  *jstat = 0;\n\n\n  /* Test if legal dimension of interpolatoin problem */\n\n  if (nur < 1 || ik < 1 || nrc < 0 || nlr < 0)\n    goto err160;\n  nn = nur + nlr;\n  nlc = nn - nrc;\n  if (ik > nlc)\n    goto err160;\n\n\n  /* Allocate output array ex */\n\n  *ex = new0array (nn, DOUBLE);\n  if (*ex == SISL_NULL)\n    goto err101;\n\n\n  /* Solve L*z = ey */\n\n  for (ii = 0; ii < nur; ii++)\n    {\n      di = ed[ii];\n      wii = w1[(di - 1) * nur + ii];\n\n\n      /* Test for errors */\n\n      if (ii >= nlc)\n\tgoto err163;\n      if (di < 1 || ik < di || wii == (double) 0.0)\n\tgoto err162;\n      sum = ey[ii];\n      if (di > 1)\n\t{\n\t  dim = di - 1;\n\t  midi = ii - di + 1;\n\t  for (jj = 0; jj < dim; jj++)\n\t    sum -= w1[jj * nur + ii] * ((*ex)[jj + midi]);\n\t}\n      (*ex)[ii] = sum / wii;\n    }\n\n  /* Solve filled part of L*z = ey */\n\n  for (; ii < nn; ii++)\n    {\n      mur = ii - nur;\n      wii = w3[ii * nlr + mur];\n      if (wii == (double) 0.0)\n\tgoto err162;\n      sum = ey[ii];\n      if (ii >= 1)\n\t{\n\t  for (jj = 0; jj < ii; jj++)\n\t    sum -= w3[jj * nlr + mur] * ((*ex)[jj]);\n\t}\n      (*ex)[ii] = sum / wii;\n    }\n\n  /* Solve U*ex = z   ; Jump if filled part of U is exhausted */\n\n  for (ii = nn - 2; ii >= nur; ii--)\n    {\n      sum = (*ex)[ii];\n      mur = ii - nur;\n      for (jj = ii + 1; jj < nn; jj++)\n\tsum -= w3[jj * nlr + mur] * ((*ex)[jj]);\n      (*ex)[ii] = sum;\n    }\n\n  /* Test if w2 contains diagonal elements */\n\n  if (ii >= nlc)\n    goto err163;\n  if (nlc < nn)\n    {\n      for (; ii >= 0; ii--)\n\t{\n\t  sum = (*ex)[ii];\n\t  for (jj = nlc; jj < nn; jj++)\n\t    sum -= w2[(jj - nlc) * nur + ii] * ((*ex)[jj]);\n\t  (*ex)[ii] = sum;\n\t}\n    }\n  for (ii = nur - 1; ii >= 0; ii--)\n    {\n      di = ed[ii];\n      if (di < ik)\n\t{\n\t  sum = (*ex)[ii];\n\t  midi = ii - di + 1;\n\t  for (jj = di; jj < ik; jj++)\n\t    sum -= w1[jj * nur + ii] * ((*ex)[jj + midi]);\n\t  (*ex)[ii] = sum;\n\t}\n    }\n\n  goto out;\n\n\n  /* Memory error, array ex not allocated */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1927\", *jstat, kpos);\n  goto out;\n\n  /* error in dimension of interpolation problem */\n\nerr160:\n  *jstat = -160;\n  s6err (\"s1927\", *jstat, kpos);\n  goto out;\n\n  /* W is non-invertible */\n\nerr162:\n  *jstat = -162;\n  s6err (\"s1927\", *jstat, kpos);\n  goto out;\n\n  /* w2 contains diagonal element */\n\nerr163:\n  *jstat = -163;\n  s6err (\"s1927\", *jstat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1930.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * \n *\n */\n\n\n#define S1930\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1930 (int inbcrv, SISLCurve ** vpcrv, double **gknot2,\n       double **gcoef2, int *jn2, int *jord2, int *jstat)\n#else\nvoid\ns1930 (inbcrv, vpcrv, gknot2, gcoef2, jn2, jord2, jstat)\n     int inbcrv;\n     SISLCurve **vpcrv;\n     double **gknot2;\n     double **gcoef2;\n     int *jn2;\n     int *jord2;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Given a set of curves where some may be rational, \n*              put these on a common basis.\n*              (Common knot-vector of length (jn2+jord2).\n*              The vertices are recomputed according to this new basis.\n*\n* INPUT      : inbcrv - Number of curves in the curve-set.\n*              vpcrv  - Array (length inbcrv) of pointers to the\n*                       curves in the curve-set.\n*\n* OUTPUT     : gknot2 - Common knot-vector (new basis) for the curves.\n*                       (jn2+jord2).\n*              gcoef2 - The vertices of the inbcrv curves\n*                       expressed in the new basis. Stored in sequence\n*                       first curve, second curve,...\n*                       Also the weight is stored. For non-rational curves\n*                       the weight is one\n*              jn2    - The no. of vertices in each of the inbcrv curves.\n*              jord2  - The order of the new representation of the curves.\n*              jstat  - Output status:\n*                        < 0: Error.\n*                        = 0: Ok.\n*                        > 0: Warning.\n*\n* NOTE\t     : This routine is an interface to s1931 using a rational format\n*\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 2009-08\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\n  int kpos = 0;\n  SISLCurve **ratcurves=SISL_NULL;\n  int ki, kj;\n  int kdim = vpcrv[0]->idim;\n  int rat;\n  int kn;\n\n  ratcurves = newarray(inbcrv,SISLCurve*);\n  for(ki=0; ki<inbcrv; ki++)\n  {\n    /* Set pointers to the homogeneous coordinates or create array. */\n    double *sc = SISL_NULL;\n    rat = (vpcrv[ki]->ikind == 2 || vpcrv[ki]->ikind == 4);\n    if (!rat)\n      {\n\tkn = vpcrv[ki]->in;\n\tsc = newarray((kdim+1)*kn, double);\n\tif (!sc)\n\t  goto err101;\n\n\tfor (kj=0; kj<kn; kj++)\n\t  {\n\t    memcopy(sc+ki*(kdim+1), vpcrv[ki]->ecoef+ki*kdim, kdim, double);\n\t    sc[ki*(kdim+1)+kdim] = 1.0;\n\t  }\n\n      }\n    ratcurves[ki] = newCurve(vpcrv[ki]->in,vpcrv[ki]->ik,vpcrv[ki]->et,\n\t\t\t     (rat) ? vpcrv[ki]->rcoef : sc, 1, kdim+1, 1);\n    if (sc) freearray(sc);\n\n    if (!ratcurves[ki])\n      goto err101;\n  }\n\n  /* Put the curves into common basis. */\n\n  s1931 (inbcrv, ratcurves, gknot2, gcoef2, jn2, jord2, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  *jstat = 0;\n  goto out;\n\n  err101:\n    *jstat = -101;\n    s6err(\"s1930\",*jstat,kpos); \n    goto out;\n  \n  /* Error in lower level routine.  */\n\n  error:\n    *jstat = kstat;\n    s6err (\"s1930\", *jstat, kpos);\n    goto out;\n\n  out:\n    /* Release allocated curve pointer array and curves */\n    for (ki=0; ki<inbcrv; ki++)\n      freeCurve(ratcurves[ki]);\n    freearray(ratcurves);\n    return;\n  }\n"
  },
  {
    "path": "src/s1931.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1931.c,v 1.2 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1931\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1931 (int inbcrv, SISLCurve ** vpcrv, double **gknot2,\n       double **gcoef2, int *jn2, int *jord2, int *jstat)\n#else\nvoid\ns1931 (inbcrv, vpcrv, gknot2, gcoef2, jn2, jord2, jstat)\n     int inbcrv;\n     SISLCurve **vpcrv;\n     double **gknot2;\n     double **gcoef2;\n     int *jn2;\n     int *jord2;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Given a set of curve, put these on a common basis.\n*              (Common knot-vector of length (jn2+jord2).\n*              The vertices are recomputed according to this new basis.\n*\n* INPUT      : inbcrv - Number of curves in the curve-set.\n*              vpcrv  - Array (length inbcrv) of pointers to the\n*                       curves in the curve-set.\n*\n* OUTPUT     : gknot2 - Common knot-vector (new basis) for the curves.\n*                       (jn2+jord2).\n*              gcoef2 - The vertices of the inbcrv curves\n*                       expressed in the new basis. Stored in sequence\n*                       first curve, second curve,...\n*              jn2    - The no. of vertices in each of the inbcrv curves.\n*              jord2  - The order of the new representation of the curves.\n*              jstat  - Output status:\n*                        < 0: Error.\n*                        = 0: Ok.\n*                        > 0: Warning.\n*\n* NOTE\t     : The maximal order of the B-spline basis in the lofting\n*\t       direction is no longer used. In earlier version (s1337)\n*\t       the maximal order iord1 was not found, nor calculated.\n*\n* CALLS      : s1349,s1933,s1932,s6err.\n*\n* WRITTEN BY : Christophe R. Birkeland, SI, 1991-07\n* Revised by : Christophe Rene Birkeland, SINTEF Oslo, May 1993.\n*              Error message corrected\n*\n*********************************************************************\n*/\n{\n  int ki;                       /* Counter.                               */\n  double tstart;            \t/* Start parameter-value of B-spline basis\n\t\t\t         * to be made \t\t\t \t  */\n  double tstop;          \t/* Stop parameter-value of B-spline basis\n\t\t\t         * to be made\t\t\t  \t  */\n  int kstat = 0;\t\t/* Status variable.                         */\n  int kpos = 0;\t\t\t/* Position of error.                       */\n  SISLCurve **tmp_vpcrv = SISL_NULL;  /* Temporary array for curve pointers   */\n  SISLCurve *pcrv=SISL_NULL;\n\n  *jstat = 0;\n\n  /* VSK, 10.92. Set parameter interval in the curve direction as\n     the medium of the parameter interval of the input curves. */\n  \n  for (tstart=DZERO, tstop=DZERO, ki=0; ki<inbcrv; ki++)\n  {\n     tstart += *(vpcrv[ki]->et + vpcrv[ki]->ik - 1);\n     tstop += *(vpcrv[ki]->et + vpcrv[ki]->in);\n  }\n  tstart /= (double)inbcrv;\n  tstop /= (double)inbcrv;\n  \n  /* s1349 make all the curves k-regular, copy curves not to destroy cyclic bases */\n  \n  tmp_vpcrv = new0array(inbcrv, SISLCurve*);\n  if (tmp_vpcrv == SISL_NULL) goto err101;\n  \n  /* Copy all curves */\n  for (ki=0 ; ki<inbcrv ; ki++)\n    { \n       pcrv = SISL_NULL;\n       pcrv = newCurve(vpcrv[ki]->in,vpcrv[ki]->ik,vpcrv[ki]->et,vpcrv[ki]->ecoef,\n\t\t       vpcrv[ki]->ikind,vpcrv[ki]->idim,1);\n       if (pcrv==SISL_NULL) goto err101;\n       tmp_vpcrv[ki] = pcrv;\t       \n    }  \n\n  /* Be sure that all curves have got an open description. */\n\n  s1349 (inbcrv, tmp_vpcrv, &kstat);\n  if (kstat < 0)  goto error;\n\n  /* Find common basis for all B-spline curves. */\n\n  s1933 (inbcrv, tmp_vpcrv, tstart, tstop, gknot2, jn2, jord2, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Express the curves in the already found basis. */\n\n  s1932 (inbcrv, tmp_vpcrv, tstart, tstop, *gknot2, *jn2, *jord2, gcoef2, &kstat);\n  if (kstat < 0) goto error;\n\n  goto out;\n\n  err101:\n    *jstat = -101;\n    s6err(\"s1931\",*jstat,kpos); \n    goto out;\n  \n  /* Error in lower level routine.  */\n\n  error:\n    *jstat = kstat;\n    s6err (\"s1931\", *jstat, kpos);\n    goto out;\n\n  out:\n    /* Release allocated curve pointer array and curves */\n\n    if (tmp_vpcrv != SISL_NULL)\n    {      \n      for (ki=0 ; ki<inbcrv ; ki++)\n\t{\n\t  if (tmp_vpcrv[ki] != SISL_NULL) freeCurve(tmp_vpcrv[ki]); \n\t}\n      if (tmp_vpcrv != SISL_NULL) freearray(tmp_vpcrv); \n    }  \n  return;\n}\n"
  },
  {
    "path": "src/s1931unit.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1931unit.c,v 1.2 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1931UNIT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1931unit (int inbcrv, SISLCurve ** vpcrv, double **gknot2,\n       double **gcoef2, int *jn2, int *jord2, int *jstat)\n#else\nvoid\n   s1931unit (inbcrv, vpcrv, gknot2, gcoef2, jn2, jord2, jstat)\n     int inbcrv;\n     SISLCurve **vpcrv;\n     double **gknot2;\n     double **gcoef2;\n     int *jn2;\n     int *jord2;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Given a set of curve, put these on a common basis\n*              using a unit knot vector.\n*              (Common knot-vector of length (jn2+jord2).\n*              The vertices are recomputed according to this new basis.\n*\n* INPUT      : inbcrv - Number of curves in the curve-set.\n*              vpcrv  - Array (length inbcrv) of pointers to the\n*                       curves in the curve-set.\n*\n* OUTPUT     : gknot2 - Common knot-vector (new basis) for the curves.\n*                       (jn2+jord2).\n*              gcoef2 - The vertices of the inbcrv curves\n*                       expressed in the new basis. Stored in sequence\n*                       first curve, second curve,...\n*              jn2    - The no. of vertices in each of the inbcrv curves.\n*              jord2  - The order of the new representation of the curves.\n*              jstat  - Output status:\n*                        < 0: Error.\n*                        = 0: Ok.\n*                        > 0: Warning.\n*\n* NOTE\t     : The maximal order of the B-spline basis in the lofting\n*\t       direction is no longer used. In earlier version (s1337)\n*\t       the maximal order iord1 was not found, nor calculated.\n*\n* CALLS      : s1349,s1933,s1932,s6err.\n*\n* WRITTEN BY : Christophe R. Birkeland, SI, 1991-07\n*\n*********************************************************************\n*/\n{\n   int ki;                      /* Counter.                               */\n  double tstart = 0;           \t/* Start parameter-value of B-spline basis\n\t\t\t         * to be made \t\t\t \t  */\n  double tstop = 1;          \t/* Stop parameter-value of B-spline basis\n\t\t\t         * to be made\t\t\t  \t  */\n  int kstat = 0;\t\t/* Status variable.                         */\n  int kpos = 0;\t\t\t/* Position of error.                       */\n  \n  SISLCurve **tmp_vpcrv = SISL_NULL;  /* Temporary array for curve pointers   */\n  SISLCurve *pcrv=SISL_NULL;\n\n  *jstat = 0;\n\n  /* s1349 make all the curves k-regular, copy curves not to destroy cyclic bases */\n  \n  tmp_vpcrv = new0array(inbcrv, SISLCurve*);\n  if (tmp_vpcrv == SISL_NULL) goto err101;\n    \n  /* Copy all curves */\n  for (ki=0 ; ki<inbcrv ; ki++)\n    { \n       pcrv = SISL_NULL;\n       pcrv = newCurve(vpcrv[ki]->in,vpcrv[ki]->ik,vpcrv[ki]->et,vpcrv[ki]->ecoef,\n\t\t       vpcrv[ki]->ikind,vpcrv[ki]->idim,1);\n       if (pcrv==SISL_NULL) goto err101;\n       tmp_vpcrv[ki] = pcrv;\t       \n    }  \n\n  /* Be sure that all curves have got an open description. */\n\n  s1349 (inbcrv, tmp_vpcrv, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Find common basis for all B-spline curves. */\n\n  s1933 (inbcrv, tmp_vpcrv, tstart, tstop, gknot2, jn2, jord2, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Express the curves in the already found basis. */\n\n  s1932 (inbcrv, tmp_vpcrv, tstart, tstop, *gknot2, *jn2, *jord2, gcoef2, &kstat);\n  if (kstat < 0) goto error;\n\n  goto out;\n\n  err101:\n    *jstat = -101;\n    s6err(\"s1931unit\",*jstat,kpos);\n    goto out;\n\n  /* Error in lower level routine.  */\n\n  error:\n    *jstat = kstat;\n    s6err (\"s1931unit\", *jstat, kpos);\n    goto out;\n\n  out:\n    /* Release allocated curve pointer array and curves */\n\n    if (tmp_vpcrv != SISL_NULL)\n    {\n      \n      for (ki=0 ; ki<inbcrv ; ki++)\n\t{\n\t  if (tmp_vpcrv[ki] != SISL_NULL) freeCurve(tmp_vpcrv[ki]); \n\t}\n      if (tmp_vpcrv != SISL_NULL) freearray(tmp_vpcrv);      \n    }\n \n    return;\n}\n"
  },
  {
    "path": "src/s1932.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1932.c,v 1.2 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1932\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1932 (int inbcrv, SISLCurve ** crvarr, double start, double stop, double *et,\n       int in, int iordr, double **iright, int *jstat)\n#else\nvoid\ns1932 (inbcrv, crvarr, start, stop, et, in, iordr, iright, jstat)\n     int inbcrv;\n     SISLCurve **crvarr;\n     double start;\n     double stop;\n     double *et;\n     int in;\n     int iordr;\n     double **iright;\n     int *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    :\tTo express a set of B-spline curves described in different\n*\t\tB-spline bases using a basis reflecting the continuity in\n*\t\tall the B-spline bases used in the description of the\n*\t\tdifferent curves.\n*\n*\n* INPUT      :\tinbcrv\t- Number of curves in the curve-set.\n*\t\tcrvarr\t- Array (length inbcrv) of pointers to the\n*\t\t\t  curves in the curve-set.\n*\t\tstart\t- Start parameter-value of B-spline basis to be made.\n*\t\tstop\t- Stop parameter-value of B-spline basis to be made.\n*\t\tet\t- The knot vector of the basis in which the curves\n*\t\t\t  are to be expressed.\n*\t\tin\t- The number of B-spline bases in which the curves\n*\t\t\t  are to be expressed.\n*\t\tiordr\t- The order of the basis in which the curves are to\n*\t\t\t  be expressed.\n*\n* OUTPUT     :  iright\t- Array containing the right hand side of the equation\n*\t\t\t  system. Sequence first curve, second curve etc...\n*               jstat   - Output status:\n*                          < 0: Error.\n*                          = 0: Ok.\n*                          > 0: Warning.\n*\n* METHOD     : \tThe description of the curves are lifted to the order given\n*\t\tas input. The lifted knot vectors are then mapped into the\n*\t\tparameter range given by astart and astop. Then the curves\n*\t\tare expressed in the refined basis given et. This basis must\n*\t\tbe calculated to be refinement of the lifted and mapped knot\n*\t\tvectors of the input curves.\n*\n* REFERENCES :  Fortran revised version:\n*               T.Dokken, SI, 1989-02\n*\n* CALLS      :  s1750,s1934,s1936,s6err.\n*\n*\n* WRITTEN BY :  Christophe R. Birkeland, SI, 1991-07\n*\n*********************************************************************\n*/\n{\n  int ki, kj, kp;\t\t/* Loop control parameters \t\t*/\n  int kpos = 0;\t\t\t/* Error position indicator\t\t*/\n  int kordr;\t\t\t/* Highest curve-order used in\n\t\t\t\t * description\t\t\t\t*/\n  int idim;\t\t\t/* Dimension of the space where the\n\t\t\t\t * curves lie\t\t\t\t*/\n  int kstat;\t\t\t/* Status variable from lower level\n\t\t\t\t * routines\t\t\t\t*/\n  SISLCurve *crv = SISL_NULL;\t/* SISLCurve, sent to s1936\t\t*/\n  double *kdumcf = SISL_NULL;\t/* Contains curve-coefficients sent over\n\t\t\t\t * from s1936\t\t\t\t*/\n\n\n  *jstat = 0;\n\n  /* Initailzation of variables */\n\n  idim = crvarr[0]->idim;\n  kordr = 0;\n\n  for (ki = 0; ki < inbcrv; ki++)\n    if ((crvarr[ki]->in <crvarr[ki]->ik) ||(crvarr[ki]->ik < 1))\n      goto err112;\n\n\n  /* Find highest order used in description */\n\n  for (ki = 0; ki < inbcrv; ki++)\n    kordr = MAX (kordr, crvarr[ki]->ik);\n\n  if (kordr > iordr)\n    goto err151;\n\n\n  /* Lift the order of the description of the curve, then refine the\n     description of the curve, and copy the result into the right hand\n     side of the equation ssystem. */\n\n  /* Allocate array kdumcf and output array iright */\n\n  kdumcf = newarray (idim * in, DOUBLE);\n  if (kdumcf == SISL_NULL)\n    goto err101;\n  *iright = newarray (in *idim * inbcrv, DOUBLE);\n  if (*iright == SISL_NULL)\n    goto err101;\n\n  kp = 0;\n\n  for (ki = 0; ki < inbcrv; ki++)\n    {\n      /* Increase the order of the basis */\n\n      s1750 (crvarr[ki], iordr, &crv, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n\n      /* Normalize the lifted basis */\n\n      s1934 (crv->et, crv->in, crv->ik, start, stop, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n\n      /* Express the curve using the refined basis */\n\n      s1936 (crv, et, in, kdumcf, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      if (crv != SISL_NULL)\n\tfreeCurve (crv);\n      crv = SISL_NULL;\t\n\n\n      /* Copy coefficients into right hand side of equation system */\n\n      for (kj = 0; kj < (in *idim); kj++)\n\t(*iright)[kj + kp] = kdumcf[kj];\n      kp += in *idim;\n    }\n  goto out;\n\n  /* Memory error */\n\n  err101:\n    *jstat = -101;\n    s6err (\"s1932\", *jstat, kpos);\n    goto out;\n\n  /* Error in curve description */ \n  \n  err112:\n     *jstat = -112;\n     s6err(\"s1932\",*jstat,kpos);\n     goto out;\n \n  /* Error in input */\n\n  err151:  \n    *jstat = -151;\n    s6err (\"s1932\", *jstat, kpos);\n    goto out;\n\n  /* Error in lower level routines */\n\n  error:\n    *jstat = kstat;\n    s6err (\"s1932\", *jstat, kpos);\n    goto out;\n\n  out:\n   /* Free scratch occupied by local array.  */\n   \n   if (kdumcf != SISL_NULL) freearray(kdumcf);\n\n   return;\n}\n"
  },
  {
    "path": "src/s1933.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1933.c,v 1.4 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1933\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1933 (int inbcrv, SISLCurve * crvarr[], double start, double stop,\n       double **it, int *in, int *iordr, int *jstat)\n#else\nvoid\ns1933 (inbcrv, crvarr, start, stop, it, in, iordr, jstat)\n     int inbcrv;\n     SISLCurve *crvarr[];\n     double start;\n     double stop;\n     double **it;\n     int *in;\n     int *iordr;\n     int *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    :\tTo map a number of knot vectors of different lengths\n*\t\tinto the same interval, and to produce a union of the\n*\t\tknot vectors taking care to use the greatest of the\n*\t\torders of the input knot vectors and to reflect the\n*\t\tcontinuity requirements reflected in all input knot\n*\t\tvectors. To avoid too many new knots, knots lying\n*\t\tcloser than 0.0001 times the parameter interval\n*               (relative distance), might be moved.\n*\n*\n* INPUT      :\tinbcrv\t- Number of curves to be interpolated by a\n*\t\t\t  spline lofted surface.\n*\t\tcrvarr\t- Array (length inbcrv) of pointers to the curves\n*\t\t\t  in the curve-set.\n*\t\tstart\t- Start parameter value of B-spline basis to\n*\t\t\t  be made.\n*\t\tstop\t- End parameter value of B-spline basis to\n*\t\t\t  be made.\n*\n*\n* OUTPUT     :  it\t- The new knot vector (union of the old ones).\n*\t\tin\t- The number of B-spline basis functions in basis\n*\t\t\t  produced.\n*\t\tiordr\t- The order of the B-spline basis produced.\n*               jstat   - Output status:\n*                          < 0: Error.\n*                          = 0: Ok.\n*                          > 0: Warning.\n*\n* METHOD     : \tPhase 1:\n*                   Find highest order of all curves.\n*                   Map all knot-vectors into [astart,astop].\n*                   Lift all knot-vectors to the highest order and make union.\n*           \tPhase 2:\n*                   Run through the union vector and detect knots lying\n*                   closer to each other than 10E-4 times the parameter\n*                   interval.\n*                   Find values to be used for the close knot-values.\n*                   Move knots in original knot-vectors to match these values.\n*           \tPhase 3:\n*                   Lift all knot-vectors (now adjusted) to the highest\n*                   order and make union.\n*\n* REFERENCES :  Fortran version:\n*               T.Dokken, SI, 1981-12\n*\n* CALLS      :  s1934,s1754,s1935,s6err.\n*\n*\n* WRITTEN BY :  Christophe R. Birkeland, SI, 1991-07\n* REVISED BY :  Paal Fugelli, SINTEF, Oslo 18/07-1994.  Removed memory\n*               leaks.\n*\n*********************************************************************\n*/\n{\n  int ki, kj, kl, kr, kp;\t/* Loop control variables\t\t*/\n  int ktell;\n  int kfirst;\t\t\t/* Pointer to first knot value in\n\t\t\t\t * interval [tinmin,tinmax]\t\t*/\n  int klast;\t\t\t/* Pointer to last knot value in\n\t\t\t\t * interval [tinmin,tinmax]\t\t*/\n  int kn;\t\t\t/* Number of vertices in curve\t\t*/\n  int kbgn;\t\t\t/* Pointer to first knot value\n\t\t\t\t * satisfying kt[kbgn] > kt[*iordr-1]\t*/\n  int kend;\t\t\t/* Pointer to last knot value\n\t\t\t\t * satisfying kt[kend] < kt[kn]\t\t*/\n  int kmax;\t\t\t/* Number of distinct knot values to be\n\t\t\t\t * kept in the interval [tinmin,tinmax]\t*/\n  int kdum1;\t\t\t/* Dummy variables for use in algorithm */\n  int kdum2;\n  int kdiff;\n  int kdf;\t\t\t/* Equals (kdiff div 2)\t\t\t*/\n  int knumb;\t\t\t/* Number of vertices in a curve\t*/\n  int kpos = 0;\t\t\t/* Error position indicator \t\t*/\n  int kstat;\n  double tepsco;\t\t/* Greatest distance for two knots to be\n\t\t\t\t * regarded as the same knot\t\t*/\n  double dum;\n  double tlast;\t\t\t/* Value of knot vector\t\t\t*/\n  double tval;\n  double tincre;\n  double tincr2;\t\t/* Equals   tincre / 2.0\t\t*/\n  double tmin, tmax;\n  double tinmin, tinmax;\n  double tbgn, tend;\t\t/* tbgn=kt[*iordr-1] & tend = kt[kn]\n\t\t\t\t * Used to find kbgn and kend\t\t*/\n  double *kt = SISL_NULL;\t\t/* New knot vector\t\t\t*/\n  double *knot = SISL_NULL;\t\t/* Knot vector\t\t\t\t*/\n  double *incknt = SISL_NULL;\t/* Used to store the union of two\n\t\t\t\t * knot vectors\t\t\t\t*/\n  SISLCurve *curve = SISL_NULL;\n\n  *jstat = 0;\n\n\n  /* Initailzation of variables */\n\n  *in = 0;\n  *iordr = 0;\n\n\n  /* Test if legal input */\n\n  if (inbcrv < 2)\n    goto err179;\n  for (ki = 0; ki < inbcrv; ki++)\n    if (crvarr[ki]->in <crvarr[ki]->ik || crvarr[ki]->ik < 1)\n      goto err112;\n\n\n  /* Find highest order used in description */\n\n  for (ki = 0; ki < inbcrv; ki++)\n    *iordr = MAX (*iordr, crvarr[ki]->ik);\n\n  kn = *iordr;\n\n\n  /* Normalize the knot vectors */\n\n  for (ki = 0; ki < inbcrv; ki++)\n    {\n      curve = crvarr[ki];\n      s1934 (curve->et, curve->in, curve->ik, start, stop, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* Make start knot vector */\n\n  kt = newarray (*iordr * 2, double);\n  if (kt == SISL_NULL)\n    goto err101;\n  for (ki = 0; ki < *iordr; ki++)\n    {\n      kt[ki] = start;\n      kt[*iordr + ki] = stop;\n    }\n\n  /* Run through all knot vectors, lift the order, map into right\n   * interval and make the union with the candidates already existing */\n\n  for (ki = 0; ki < inbcrv; ki++)\n    {\n      /* Increase order of basis */\n\n      curve = crvarr[ki];\n      s1754 (curve->et, curve->in, curve->ik, *iordr,\n\t     &incknt, &knumb, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n\n      /* Make union of old union and new knot vector */\n\n      s1935 (kt, kn, incknt, knumb, &knot, &kn, *iordr, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      if (incknt != SISL_NULL)  freearray(incknt);  /* PFU 18/07-94. */\n\n      if (kt != SISL_NULL)\n\tfreearray (kt);\n      kt = knot;\n      knot = SISL_NULL;  /* PFU 18/07-94 */\n    }\n\n  /* The knot vector produced might contain knots originating\n   * from different curves that are located very close to each\n   * other. We will move internal knots when they are closer\n   * to each other than tepsco.\n   *\n   * Find first knot bigger than kt[*iordr-1] and last\n   * knot less than kt[kn].\t\t\t\t\t*/\n\n  kend = kn - 1;\n  tbgn = kt[*iordr - 1];\n  tend = kt[kn];\n\n  /* Find first knot kt[kbgn] > tbgn\t*/\n\n  for (kbgn = *iordr; (tbgn >= kt[kbgn]) && (kbgn < kend); kbgn++) ;\n\n  /* Find last knot kt[kend] < tend\t*/\n\n  for (; (tend <= kt[kend]) && (kbgn < kend); kend--) ;\n\n  /* Set greatest distance for two knots to be regarded\n   * as the same knot\t\t\t\t\t*/\n\n  tepsco = (double) 0.00000000000001 * (stop - start);\n\n  /* Loop runing through all the knots of the union knot\n   * vector and moving knots when possible\t\t*/\n\n  for (ki = kbgn; ki < kend; ki = kl + 1)\n    {\n      /* Find knots closer to knot ki than tepsco in\n       * positive direction\t\t\t\t*/\n\n      kl = ki - 1;\n      do\n\t{\n\t  kl++;\n\t  dum = MAX (fabs(kt[kl + 1]), fabs(kt[ki]))/stop;\n\t  if (dum == (double) 0.0)\n\t    dum = (double) 1.0;\n\t}\n      while ((kl < kend) && ((fabs (kt[kl + 1] - kt[ki]) / dum) <= tepsco));\n\n\n      /* If only one value found, then shifting is not necessary */\n\n      if (ki == kl)\n\tcontinue;\n\n\n      /* The knots close to kt[ki-1] are kt[ki]...kt[kl-1]\t*/\n\n      tmin = kt[ki];\n      tmax = MIN (kt[kl] + tepsco*dum, kt[kend]);\n\n\n      /* If interval is degenerate we have finished the moving\t*/\n\n      if (tmin >= tmax)\n\tbreak;\n\n\n      /* For each curve, count the number of distinct knot\n         values in the interval [tmin,tmax].\n         Accumulate max and min knot values in the interval\n         where we know that tmin is a knot.\t\t\t*/\n\n      tinmin = tmin;\n      tinmax = tmax;\n      kmax = 0;\n      for (kj = 0; kj < inbcrv; kj++)\n\t{\n\t  curve = crvarr[kj];\n\t  ktell = 0;\n\t  tlast = (double) 0.0;\n\n\t  for (kr = *iordr - 1; kr <= curve->in; kr++)\n\t    if ((tmin <= curve->et[kr]) && (curve->et[kr] <= tmax))\n\t      {\n\t\tif (ktell == 0)\n\t\t  ktell = 1;\n\t\telse if (curve->et[kr] > tlast)\n\t\t  ktell++;\n\t\ttlast = curve->et[kr];\n\t\ttinmin = MIN (tinmin, tlast);\n\t\ttinmax = MAX (tinmax, tlast);\n\t      }\n\t  kmax = MAX (kmax, ktell);\n\t}\n\n      /* kmax now contains the number of distinct knot values\n       * to be kept in the interval [tinmin,tinmax]. */\n\n      if (kmax > 1)\n\ttincre = (tinmax - tinmin) / (double) (kmax - 1);\n      else\n\ttincre = (double) 0.0;\n      tincr2 = tincre / (double) 2.0;\n\n      /* The values used will be\n         tinmin,tinmin+tincre,...,tinmin+(kmax-1)*tincre.\n         We want to use the values closest to the actual\n         knot values when possible.\n         Run through each curve and move knots if tinmin<tinmax.\n         If they are equal, knots should not be moved. */\n\n      if (tinmin >= tinmax)\n\tcontinue;\n\n      for (kj = 0; kj < inbcrv; kj++)\n\t{\n\t  curve = crvarr[kj];\n\t  ktell = 0;\n\t  for (kr = *iordr - 1; kr <= curve->in; kr++)\n\t    if ((tinmin <= curve->et[kr]) && (curve->et[kr] <= tinmax))\n\t      {\n\t\tif (ktell == 0)\n\t\t  {\n\t\t    ktell = 1;\n\t\t    kfirst = kr;\n\t\t  }\n\t\telse if (curve->et[kr] >= tlast)\n\t\t  {\n\t\t    ktell++;\n\t\t    klast = kr;\n\t\t  }\n\t\ttlast = curve->et[kr];\n\t      }\n\n\t  /* ktell contains the number of knots in [tinmin,tinmax]\n\t     on curve kj. kfirst is a pointer to first knot value,\n\t     klast is the pointer to last knot value\t\t*/\n\n\t  if (ktell == 1)\n\t    {\n\n\t      /* Only one knot value in interval, move to closest\n\t       * legal value\t\t\t\t\t*/\n\n\t      if ((kmax == 1) || (tincre == (double) 0.0))\n\t\ttval = tinmin;\n\t      else\n\t\t{\n\t\t  kdum1 = (int)((curve->et[kfirst] - tinmin + tincr2) / tincre);\n\t\t  tval = tinmin + (double)kdum1 * tincre;\n\t\t}\n\t      tlast = curve->et[kfirst];\n\t      do\n\t\t{\n\t\t  curve->et[kfirst] = tval;\n\t\t  kfirst++;\n\t      } while (curve->et[kfirst] == tlast);\n\t      continue;\n\t    }\n\n\t  if ((ktell <= 1) || (tincre <= (double) 0.0))\n\t    continue;\n\n\n\t  /* More than one point found. */\n\n\t  kdum1 = (int)((curve->et[kfirst] - tinmin + tincr2) / tincre);\n\t  kdum2 = (int)((curve->et[klast] - tinmin + tincr2) / tincre);\n\t  kdiff = ktell - kdum2 + kdum1 - 1;\n\t  if (kdiff > 0)\n\t    {\n\t      /* Change kdum1 and kdum2 to allow for ktell\n\t         different values. */\n\n\t      kdf = kdiff / 2;\n\t      kdum1 = MAX (0, kdum1 - kdf);\n\t      kdum2 = MIN (kmax - 1, kdum2 + kdiff - kdf);\n\t      kdiff = ktell - kdum2 + kdum1 - 1;\n\n\t      if (kdiff > 0)\n\t\t{\n\t\t  if (kdum1 == 0)\n\t\t    kdum2 += kdiff;\n\t\t  else\n\t\t    {\n\t\t      if (kdum2 != ktell)\n\t\t\tgoto err170;\n\t\t      kdum1 -= kdiff;\n\t\t    }\n\t\t}\n\t    }\n\n\t  if ((kdum1 < 0) || (kdum2 > ktell))\n\t    goto err170;\n\n\n\t  /* Use kdum1 as start value, move knots. */\n\n\t  tval = tinmin + kdum1 * tincre;\n\t  kr = kfirst;\n\t  tlast = curve->et[kr];\n\t  for (kp = 0; kp < ktell; kp++, kr++)\n\t    if (curve->et[kr] == tlast)\n\t      curve->et[kr] = tval;\n\t    else\n\t      {\n\t\tif (curve->et[kr] <= tlast)\n\t\t  goto err170;\n\t\ttval += tincre;\n\t\ttlast = curve->et[kr];\n\t\tcurve->et[kr] = tval;\n\t      }\n\t}\n    }\n\n  /* Make start knot vector\t\t\t\t\t*/\n\n  if (kt != SISL_NULL)  freearray(kt);  /* PFU 18/07-94 */\n\n  kt = newarray (*iordr * 2, double);\n  if (kt == SISL_NULL)\n    goto err101;\n\n  for (ki = 0; ki < *iordr; ki++)\n    {\n      kt[ki] = start;\n      kt[*iordr + ki] = stop;\n    }\n\n  kn = *iordr;\n\n  /* Run through all knot vectors, lift the order, map into right\n     interval and make the union with the candidates already existing. */\n\n  for (ki = 0; ki < inbcrv; ki++)\n    {\n      /* Increase order of basis. */\n\n      curve = crvarr[ki];\n      s1754 (curve->et, curve->in, curve->ik, *iordr, &incknt, &knumb, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n\n      /* Make union of old union and new knot vector */\n\n      s1935 (kt, kn, incknt, knumb, &knot, &kn, *iordr, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      if (incknt != SISL_NULL)  freearray(incknt);  /* PFU 18/07-94 */\n\n      if (kt != SISL_NULL)\n\tfreearray (kt);\n      kt = knot;\n      knot = SISL_NULL;  /* PFU 18/07-94 */\n    }\n\n  /* No errors */\n\n  *in = kn;\n  *it = kt;\n  kt = SISL_NULL;  /* PFU 18/07-94 */\n  goto out;\n\n\n  /* Memory error */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1933\", *jstat, kpos);\n  goto out;\n\n  /* Error in input */\n\nerr112:\n  *jstat = -112;\n  s6err (\"s1933\", *jstat, kpos);\n  goto out;\n\n  /* Too few curves for spline lofted surface */\n\nerr179:\n  *jstat = -179;\n  s6err (\"s1933\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routines */\n\nerror:\n  *jstat = kstat;\n  s6err (\"s1933\", *jstat, kpos);\n  goto out;\n\n  /* Special error in moving of knot values */\n\nerr170:\n  *jstat = -170;\n  s6err (\"s1933\", *jstat, kpos);\n  goto out;\n\nout:\n  if (kt != SISL_NULL)  freearray(kt);  /* PFU 18/07-94 */\n  if (knot != SISL_NULL)  freearray(knot);  /* PFU 18/07-94 */\n  if (incknt != SISL_NULL)  freearray(incknt);  /* PFU 18/07-94 */\n  return;\n}\n"
  },
  {
    "path": "src/s1934.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1934.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1934\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1934 (double *et, int in, int ik, double start, double end, int *jstat)\n#else\nvoid\ns1934 (et, in, ik, start, end, jstat)\n     double *et;\n     int in;\n     int ik;\n     double start;\n     double end;\n     int *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    :\tTo map the support of a knot vector into a specified\n*\t\tinterval.\n*\n*\n* INPUT      :\tet\t- The original knot vector\n*\t\tin\t- The number of degrees of freedom in the\n*\t\t\t  B-basis given by the knot vector.\n*\t\tik\t- The order of the basis.\n*\t\tstart\t- Start of the interval into which the knot\n*\t\t\t  vector is to be mapped.\n*\t\tend\t- End of the interval into which the knot\n*\t\t\t  vector is to be mapped.\n*\n*\n* OUTPUT     :\tet\t- The changed knot vector.\n*               jstat   - Output status:\n*                          < 0: Error.\n*                          = 0: Ok.\n*                          > 0: Warning.\n*\n* METHOD     :\n*\n* REFERENCES :  Fortran version:\n*               T.Dokken, SI, 1981-10\n*\n* CALLS      : s6err.\n*\n*\n* WRITTEN BY :  Christophe R. Birkeland\n* REWISED BY :  Vibeke Skytt, SI, 92-10. The output knot vector will\n*                                        have k-tupple knots in the ends.\n*\n*********************************************************************\n*/\n{\n  int ii, stop;\t\t\t/* Loop control parameters \t\t*/\n  int kpos = 0;\t\t\t/* Error position indicator\t\t*/\n  double store1;\t\t/* Parameters used to decrease execution\n\t\t\t\t * time\t\t\t\t\t*/\n  double fac;\t\t\t/* Factor used in computation of new\n\t\t\t\t * knot vector\t\t\t\t*/\n\n  *jstat = 0;\n\n\n  /* Test if legal input */\n\n  if ((ik < 1) || (in <ik))\n    goto err112;\n\n  if (start == end)\n    goto err124;\n\n\n  /* Perform normalization */\n\n  store1 = et[ik - 1];\n  fac = (end - start) / (et[in] -store1);\n  stop = in +ik;\n\n  for (ii=0; ii<ik; ii++) et[ii] = start;\n  \n  for (ii = ik; ii < in; ii++)\n    et[ii] = fac * (et[ii] - store1) + start;\n\n  for (ii = in; ii < stop; ii++) et[ii] = end;\n\n\n  /* Normalization performed */\n\n  goto out;\n\n\n  /* Error in description of B-spline */\n\nerr112:\n  *jstat = -112;\n  s6err (\"s1934\", *jstat, kpos);\n  goto out;\n\n  /* The parameter interval is of zero length */\n\nerr124:\n  *jstat = -124;\n  s6err (\"s1934\", *jstat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s1935.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1935.c,v 1.4 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1935\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1935 (double et1[], int in1, double et2[], int in2,\n\t    double *knt[], int *in, int ik, int *jstat)\n#else\nvoid\ns1935 (et1, in1, et2, in2, knt, in, ik, jstat)\n     double *et1;\n     int in1;\n     double *et2;\n     int in2;\n     double *knt[];\n     int *in;\n     int ik;\n     int *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE: To produce a knot vector that is the union of two knot\n*\t   vectors. The original knot vectors and the produced knot\n*\t   vector are of the same order.\n*\n*\n* INPUT:   et1\t- The first knot vector.\n*\t   in1\t- The number of degrees of freedom in the\n*\t          B-basis given by the first knot vector.\n*\t   et2\t- The second knot vector.\n*\t   in2\t- The number of degrees of freedom in the\n*\t\t  B-basis given by the second knot vector.\n*\t   ik\t- The order of the knot vector to be produced.\n*\n* OUTPUT:  jstat - Output status:\n*                   < 0: Error.\n*\t\t    = 0: Ok.\n*                   > 0: Warning.\n*\n* METHOD:\n*\n* REFERENCES:  Fortran version:\n*              T.Dokken, SI, 1981-11\n*\n* CALLS: s6err.\n*\n* WRITTEN BY:  Christophe R. Birkeland, SI, 1991-07\n* CORRECTED BY: Vibeke Skytt, SI, 92-10. Removed exact test on equality\n*                                        of knots.\n* CORRECTED BY: Christophe R. Birkeland, SI, 93-05.\n*         Reinstalled exact test on equality of knots. Necessary\n*         for correct working of routine s1931-s1937.\n* CORRECTED BY: Paal Fugelli, SINTEF, 1994-07.\n*         Changed the setting of 'curr', for the while loop, to avoid\n*         over running array bounds (address error) and added DEQUAL in\n*         tests for knot equality.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\t\t\t/* Error position indicator.\t\t*/\n  int pek1, pek2;\t\t/* Index for array et1 and et2. \t*/\n  int stop1;\t\t\t/* Length of et1, equals in1+ik.\t*/\n  int stop2;\t\t\t/* Length of et2, equals in2+ik.\t*/\n  double curr;\t\t\t/* Parameter used in calculation of\n\t\t\t\t   new knots.\t\t\t\t*/\n\n  *jstat = 0;\n\n  /* Test if legal input */\n\n  if (ik < 1) goto err110;\n  if ((in1 < ik) || (in2 < ik)) goto err111;\n\n\n  /* Allocate array for new knot vector */\n\n  if((*knt = newarray (2 * ik + in1 + in2, DOUBLE))==SISL_NULL) goto err101;\n\n  /* Test if input knot vectors degenerate */\n\n  if (et1[ik - 1] >= et1[in1]) goto err112;\n\n  if (et2[ik - 1] >= et2[in2]) goto err112;\n\n  /* PRODUCTION OF KNOTS */\n\n  *in = 0;\n  /* PFU 05/07-94  curr = MIN (et1[0], et2[0]); */\n  pek1 = 0;\n  pek2 = 0;\n  stop1 = in1 + ik;\n  stop2 = in2 + ik;\n\n  while ((pek1 < stop1) && (pek2 < stop2))\n    {\n      /* Test if error in knot vector */\n\n      curr = MIN (et1[pek1], et2[pek2]);\n\n      if ((et1[pek1] < curr) || (et2[pek2] < curr)) goto err112;\n\n      if ( DEQUAL(et1[pek1],curr) ) pek1++;\n      if ( DEQUAL(et2[pek2],curr) ) pek2++;\n      (*knt)[*in] = curr;\n      (*in) ++;\n    }\n\n  /* Some knots may remain in one of the arrays */\n\n  if ((pek1 < stop1) || (pek2 < stop2))\n    {\n      if (pek1 >= stop1)\n\t{\n\t  for (; pek2 < stop2; pek2++, (*in) ++)\n\t    (*knt)[*in] = et2[pek2];\n\t}\n      else\n\tfor (; pek1 < stop1; pek1++, (*in) ++)\n\t  (*knt)[*in] = et1[pek1];\n    }\n\n  /* Knots produced */\n\n  *in -=ik;\n  *knt = increasearray (*knt, *in +ik, DOUBLE);\n  if (*knt == SISL_NULL) goto err101;\n  goto out;\n\n\n  /* Memory error */\n\n  err101:\n    *jstat = -101;\n    s6err (\"s1935\", *jstat, kpos);\n    goto out;\n\n  /* Error in description of B-spline curve: Order less than 1.*/\n\n  err110:\n    *jstat = -110;\n    s6err (\"s1935\", *jstat, kpos);\n    goto out;\n\n  /* No. of vertices less than order. */\n\n  err111:\n    *jstat = -111;\n    s6err (\"s1935\", *jstat, kpos);\n    goto out;\n\n  /* Error in knot vector */\n\n  err112:\n    *jstat = -112;\n    s6err (\"s1935\", *jstat, kpos);\n    goto out;\n\n  out:\n    return;\n}\n"
  },
  {
    "path": "src/s1936.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1936.c,v 1.4 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1936\n\n#include \"sislP.h\"\n#define MAX_SIZE  50\n\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1936 (SISLCurve * crv, double etd[], int ind, double *curvd, int *jstat)\n#else\nvoid\ns1936 (crv, etd, ind, curvd, jstat)\n     SISLCurve *crv;\n     double etd[];\n     int ind;\n     double *curvd;\n     int *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE: To express a B-spline curve using a refined basis.\n*\t   of the refinement etref of the array et.\n*\n*\n* INPUT:   crv\t- The original curve.\n*\t   etd\t- The knots of the subdivided curve.\n*\t   ind\t- The number of vertices of the subdivided curve.\n*\n*\n* OUTPUT:  curvd - Array containing the vertices of the refined curve.\n*          jstat - Output status:\n*                   < 0: Error.\n*                   = 0: Ok.\n*                   > o: Warning.\n*\n* METHOD:  The vertices are calculated using the \"Oslo\"-algorithm\n*\t   developped by Cohen, Lyche and Riesenfeld.\n*\n*\n* REFERENCES: Cohen, Lyche, Riesenfeld: Discrete B-splines and subdivision\n*\t      techniques in computer aided geometric design, computer\n*             graphics and image processing, vol 14, no.2 (1980)\n*\n* CALLS: s1937, s6err.\n*\n* WRITTEN BY :  Christophe R. Birkeland, SI, 1991-07.\n* CORRECTED BY : Paal Fugelli, SINTEF, Oslo 1994-07. Added test for\n*                equality using DEQUAL in knot verification loop.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\t\t\t/* Error position indicator\t*/\n  int ki, kj, kr, low;\t\t/* Loop control parameters \t*/\n  int nu;\t\t\t/* Pointer into knot vector:\n\t\t\t\t * knt[nu-1]<=etd[kj]<knt[nu]\t*/\n  int ins;\t\t\t/* Number of vertices of curve\t*/\n  int iordr;\t\t\t/* Order of curve\t\t*/\n  int idim;\t\t\t/* Dimension of space where the\n\t\t\t\t * curve lies\t\t\t*/\n  double *knt = SISL_NULL;\t\t/* Original knot-vector. */\n  double *coef = SISL_NULL;\t\t/* Original coefficient arrays.\t*/\n  double sum;\t\t\t/* Used to compute vertices of\n\t\t\t\t * new curve\t\t\t*/\n  double sarray[MAX_SIZE];\n  int alloc_needed=FALSE;\n  double *alfa = SISL_NULL;\t\t/* Array needed in subroutine\n\t\t\t\t * s1937 (Oslo-algorithm)\t*/\n\n  *jstat = 0;\n\n\n  /* Initialization. */\n\n  knt = crv->et;\n  ins = crv->in;\n  iordr = crv->ik;\n  idim = crv->idim;\n  coef = crv->ecoef;\n\n\n  /* Test if legal input. */\n\n  if (iordr < 1)\n    goto err110;\n  if (ins < iordr || ind < iordr)\n    goto err111;\n  if (idim < 1)\n    goto err102;\n\n\n  /* Allocate array for internal use only. */\n\n  if (iordr > MAX_SIZE)\n    {\n       if ((alfa = newarray (iordr, DOUBLE)) == SISL_NULL)\n\t goto err101;\n       alloc_needed = TRUE;\n    }\n  else\n    alfa = sarray;\n\n  /* Find if etd is a refinement of the original knot vector knt. */\n\n  kj = 0;\n\n  for (ki = 0; kj < ins; ki++)\n    {\n      if (ki >= ind)\n\tgoto err111;\n      if ( DEQUAL(knt[kj], etd[ki]) )  /* PFU 25/07-1994 */\n      {\n\tkj++;\n\tcontinue;\n      }\n      if (knt[kj] > etd[ki])\n\tcontinue;\n      if (knt[kj] < etd[ki])\n\tgoto err112;\n    }\n\n  /* etd is a refinement of original knot vector knt\n   * Produce refined curve. */\n\n  nu = 1;\n  for (kj = 0; kj < ind; kj++)\n    {\n\n      /* We want to find  knt[nu-1] <= etd[kj] < knt[nu]\n         The copying of knots guarantees the nu-value to be found.\n         Since kj is increasing, the nu-values will be increasing\n         due to copying of knots. */\n\n       /* for (; (((knt[nu - 1] > etd[kj]) || (etd[kj] >= knt[nu])) && (nu != ins));\n\t   nu++) ; */\n       for (; (((knt[nu - 1] > (double)0.5*(etd[kj]+etd[kj+1])) \n\t\t || ((double)0.5*(etd[kj]+etd[kj+1]) >= knt[nu])) && (nu != ins)); nu++) ; \n\n      /* Now we have  knt[nu-1] <= etd[kj] < knt[nu],\n         so the discrete B-splines can be calculated. */\n\n      s1937 (knt, iordr, kj + 1, nu, alfa, etd);\n\n\n      /* Compute the coefficients of etd. */\n\n      low = nu - iordr;\n      for (ki = 0; ki < idim; ki++)\n\t{\n\t  sum = (double) 0.0;\n\t  for (kr = MAX (0, low); kr < nu; kr++)\n\t    sum += alfa[kr - low] * coef[kr * idim + ki];\n\t  curvd[kj * idim + ki] = sum;\n\t}\n    }\n\n  /* OK. */\n\n  goto out;\n\n\n  /* Memory error */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1936\", *jstat, kpos);\n  goto out;\n\n  /* Error in B-spline curve description:\n     Dimension less than 1. */\n\nerr102:\n  *jstat = -102;\n  s6err (\"s1936\", *jstat, kpos);\n  goto out;\n\n  /* Order less than 1. */\n\nerr110:\n  *jstat = -110;\n  s6err (\"s1936\", *jstat, kpos);\n  goto out;\n\n  /* No. of vertices less than order. */\n\nerr111:\n  *jstat = -111;\n  s6err (\"s1936\", *jstat, kpos);\n  goto out;\n\n  /* Error in knot-vector. */\n\nerr112:\n  *jstat = -112;\n  s6err (\"s1936\", *jstat, kpos);\n\nout:\n  if (alloc_needed)\n    freearray (alfa);\n\n  return;\n}\n#undef MAX_SIZE\n"
  },
  {
    "path": "src/s1937.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1937.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S1937\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1937 (double et[], int iordr, int ref, int left, double alfa[], double etref[])\n#else\nvoid\ns1937 (et, iordr, ref, left, alfa, etref)\n     double et[];\n     int iordr;\n     int ref;\n     int left;\n     double alfa[];\n     double etref[];\n\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE: To calculate the discrete B-spline values number iref\n*\t   of the refinement etref of the array et.\n*\n*\n* INPUT:   et\t - The original knot vector.\n*\t   iordr - The order of the discrete B-spline to be\n*\t\t   calculated.\n*\t   ref\t - The index of the discrete B-spline to be\n*\t\t   calculated.\n*\t   left\t - Arrayindex, satisfying:\n*\t\t   et[left-1] <= etref[ref-1] < et[left]\n*\t   etref - Refined knot vector.\n*\n*\n* OUTPUT:  alfa\t - The values of the calculated discrete B-splines.\n*\t\t   alfa[0]    - Corresponds to number left-iordr+1.\n*\t\t   alfa[1]    - Corresponds to number left-iordr+2.\n*\t\t   alfa[left] - Corresponds to number left.\n*\n* METHOD: We use the Oslo-algorithm developped by Cohen, Lyche and\n*         Riesenfeld.\n*\n* REFERENCES: Cohen, Lyche, Riesenfeld: Discrete B-splines and subdivision\n*\t      techniques in computer aided geometric design, computer\n*\t      graphics and image processing, vol 14, no.2 (1980)\n*\n* CALLS: No.\n*\n* WRITTEN BY :  Christophe R. Birkeland, SI, 1991-07\n*\n*********************************************************************\n*/\n{\n  int ki, kl, kr, low;\t\t/* Loop control parameters. \t*/\n  int stop, start;\t\t/* and array indicators.\t*/\n  double tj, td1, td2;\t\t/* Parameters used to improve.\t*/\n  double beta1, beta;\t\t/* algorithm.\t\t\t*/\n\n\n  /* We have et[left-1] <= etref[ref-1] < et[left]\n     So the discrete B-splines can be calculated. */\n\n  low = left - iordr;\n  start = left - 1;\n  stop = iordr - 1;\n  alfa[stop] = 1;\n\n  for (kr = 0; kr < stop; kr++)\n    {\n      beta1 = (double) 0.0;\n      tj = etref[ref + kr];\n      if (start < 0)\n\tstart = 0;\n\n      for (ki = start; ki < left; ki++)\n\t{\n\t  kl = ki - low;\n\t  td1 = tj - et[ki];\n\t  td2 = et[ki + kr + 1] - tj;\n\t  beta = alfa[kl] / (td1 + td2);\n\t  alfa[kl - 1] = td2 * beta + beta1;\n\t  beta1 = td1 * beta;\n\t}\n      alfa[iordr - 1] = beta1;\n      start--;\n    }\n  return;\n}\n"
  },
  {
    "path": "src/s1938.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1938.c,v 1.2 2001-03-19 15:58:56 afr Exp $\n *\n */\n\n\n#define S1938\n\n#include \"sislP.h\"\n#define MAX_SIZE 50\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1938 (SISLSurf * srf, double etr1[], int inr1, double etr2[], int inr2,\n       double **surfr, int *jstat)\n#else\nvoid\ns1938 (srf, etr1, inr1, etr2, inr2, surfr, jstat)\n     SISLSurf *srf;\n     double etr1[];\n     int inr1;\n     double etr2[];\n     int inr2;\n     double **surfr;\n     int *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE: To express a B-spline surface curve using a refined basis.\n*\n*\n* INPUT:   srf\t- The original surface.\n*\t   etr1\t- The refined knot vector in the first parameter\n*\t\t  direction.\n*\t   inr1\t- The number of vertices of the subdivided surface\n*\t\t  in first parameter direction.\n*\t   etr2\t- The refined knot vector in the second parameter\n*\t\t  direction.\n*\t   inr2\t- The number of vertices of the subdivided surface\n*\t\t  in the second parameter direction.\n*\n* OUTPUT:  surfr - Array containing the vertices of the refined\n*\t\t   surface.\n*          jstat - Status variable.\n*                   < 0: Error.\n*\t            = 0: Ok.\n*                   > 0: Warning.\n*\n* METHOD:  The vertices are calculated using the \"Oslo\"-algorithm\n*\t   developped by Cohen, Lyche and Riesenfeld.\n*\n*\n* REFERENCES: Cohen, Lyche, Riesenfeld: Discrete B-splines and subdivision\n*\t      techniques in computer aided geometric design, computer\n*\t      graphics and image processing, vol 14, no.2 (1980)\n*\n* CALLS: s1937, s6err.\n*\n*\n* WRITTEN BY:  Christophe R. Birkeland, SI, 1991-08\n* REVISED BY:  Johannes Kaasa, SI, May 1992 (Introduced NURBS)\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\n  int ki, kj, kl, kr, low;\t/* Loop control parameters \t\t*/\n  int start;\n  int rem;\t\t\t/* Used to store array index\t\t*/\n  int nu;\t\t\t/* Pointer into knot vector:\n\t\t\t\t   knt[nu-1]<=etd[kj]<knt[nu]\t\t*/\n  int ins1;\t\t\t/* Number of vertices of curve in first\n\t\t\t\t   parameter direction\t\t\t*/\n  int iordr1;\t\t\t/* Order of curve in first\n\t\t\t\t   parameter direction\t\t\t*/\n  int ins2;\t\t\t/* Number of vertices of curve in second\n\t\t\t\t   parameter direction\t\t\t*/\n  int iordr2;\t\t\t/* Order of curve in second\n\t\t\t\t   parameter direction\t\t\t*/\n  double *knt1 = SISL_NULL;\t\t/* Original knot-vector of surface.     */\n  double *knt2 = SISL_NULL;\t\t/* Original knot vector of surface.\t*/\n  double *coef = SISL_NULL;\t\t/* Pointer to array of coefficients of\n\t\t\t\t   the surface\t\t\t\t*/\n  int idim;\t\t\t/* Dimension of space where the\n\t\t\t\t   curve lies\t\t\t\t*/\n  double sum;\t\t\t/* Used to store vertices of\n\t\t\t\t   new curve\t\t\t\t*/\n  double sarray[MAX_SIZE];\n  int alloc_needed=FALSE;\n  double *alfa = SISL_NULL;\t\t/* Array needed in subroutine\n\t\t\t\t   s1937 (Oslo-algorithm)\t\t*/\n  double *ktsurf = SISL_NULL;\t/* Array for internal use only\t\t*/\n\n  *jstat = 0;\n\n\n  /* Initialization. */\n\n  knt1 = srf->et1;\n  knt2 = srf->et2;\n  ins1 = srf->in1;\n  ins2 = srf->in2;\n  iordr1 = srf->ik1;\n  iordr2 = srf->ik2;\n  if (srf->ikind == 2 || srf->ikind == 4)\n    {\n      idim = srf->idim + 1;\n      coef = srf->rcoef;\n    }\n  else\n    {\n      idim = srf->idim;\n      coef = srf->ecoef;\n    }\n     \n  /* Test if legal input. */\n\n  if (iordr1 < 1 || iordr2 < 1)\n    goto err115;\n  if (ins1 < iordr1 || ins2 < iordr2)\n    goto err116;\n  if (idim < 1)\n    goto err102;\n\n\n  /* Allocate array for internal use only. */\n\n  if (MAX(iordr1,iordr2) > MAX_SIZE)\n    {\n      if ((alfa = newarray(MAX(iordr1,iordr2),DOUBLE)) == SISL_NULL)\n\tgoto err101;\n      alloc_needed = TRUE;\n    }\n  else\n    alfa = sarray;\n  \n  ktsurf = newarray (inr1 * inr2 * idim, DOUBLE);\n  if (ktsurf == SISL_NULL)\n    goto err101;\n\n\n  /* Allocate array surfr for output. */\n\n  *surfr = newarray (inr1 * inr2 * idim, DOUBLE);\n  if (*surfr == SISL_NULL)\n    goto err101;\n\n\n  /* Find if etr1 is a refinement of the original\n     knot vector knt1 (srf->et1). */\n\n  kj = iordr1 - 1;\n\n  for (ki = 0; kj < ins1; ki++)\n    {\n      if (ki >= inr1)\n\tgoto err116;\n      if (knt1[kj] > etr1[ki])\n\tcontinue;\n      if (knt1[kj] < etr1[ki])\n\tgoto err117;\n      kj++;\n    }\n\n  /* etr1 is a refinement of original knot vector knt1\n   * Produce surface refined in one direction. */\n\n  nu = 1;\n  for (kj = 0; kj < inr1; kj++)\n    {\n      /* We want to find  knt1[nu-1] <= etr1[kj] < knt1[nu]\n\t The copying of knots guarantees the nu-value to be found.\n\t Since kj is increasing, the nu-values will be increasing\n\t due to copying of knots. */\n\n      for (; (((knt1[nu - 1] > etr1[kj]) || (etr1[kj] >= knt1[nu]))\n\t      && (nu != ins1)); nu++) ;\n\n\n      /* Now we have  knt1[nu-1] <= etr1[kj] < knt1[nu],\n\t so the discrete B-splines can be calculated. */\n\n      s1937 (knt1, iordr1, kj + 1, nu, alfa, etr1);\n\n\n      /* Compute the temporary surface. */\n\n      low = nu - iordr1 + 1;\n      for (ki = 0; ki < ins2; ki++)\n\t{\n\t  rem = idim * kj + idim * inr1 * ki;\n\n\t  for (kl = 0; kl < idim; kl++)\n\t    {\n\t      sum = (double) 0.0;\n\t      start = nu - iordr1 + 1;\n\t      if (start < 1)\n\t\tstart = 1;\n\n\t      for (kr = start; kr <= nu; kr++)\n\t\tsum += alfa[kr - low] * coef[ki * ins1 * idim + (kr - 1) * idim + kl];\n\t      ktsurf[rem + kl] = sum;\n\t    }\n\t}\n    }\n\n  /* Find if etr2 is a refinement of the original\n   * knot vector knt2 (srf->et2). */\n\n  kj = iordr2 - 1;\n\n  for (ki = 0; kj < ins2; ki++)\n    {\n      if (ki >= inr2)\n\tgoto err116;\n      if (knt2[kj] > etr2[ki])\n\tcontinue;\n      if (knt2[kj] < etr2[ki])\n\tgoto err117;\n      kj++;\n    }\n\n  /* etr2 is a refinement of original knot vector knt2\n   * Produce surface refined in one direction. */\n\n  nu = 1;\n  for (ki = 0; ki < inr2; ki++)\n    {\n      /* We want to find  knt2[nu-1] <= etr2[ki] < knt2[nu]\n\t The copying of knots guarantees the nu-value to be found.\n\t Since kj is increasing, the nu-values will be increasing\n\t due to copying of knots. */\n\n      for (; (((knt2[nu - 1] > etr2[ki]) || (etr2[ki] >= knt2[nu]))\n\t      && (nu != ins2)); nu++) ;\n\n\n      /* Now we have  knt2[nu-1] <= etr2[kj] < knt2[nu],\n\t so the discrete B-splines can be calculated */\n\n      s1937 (knt2, iordr2, ki + 1, nu, alfa, etr2);\n\n\n      /* Compute the temporary surface. */\n\n      low = nu - iordr2 + 1;\n      for (kj = 0; kj < inr1; kj++)\n\tfor (kl = 0; kl < idim; kl++)\n\t  {\n\t    sum = (double) 0.0;\n\t    start = nu - iordr2 + 1;\n\t    if (start < 1)\n\t      start = 1;\n\t    for (kr = start; kr <= nu; kr++)\n\t      sum += alfa[kr - low] * ktsurf[kj * idim + (kr - 1) * idim * inr1 + kl];\n\t    (*surfr)[ki * idim * inr1 + kj * idim + kl] = sum;\n\t  }\n    }\n\n\n  /* OK. */\n\n  goto out;\n\n\n  /* Memory error */\n\nerr101:\n  *jstat = -101;\n  s6err (\"s1938\", *jstat, kpos);\n  goto out;\n\n  /* Error in B-spline surface description:\n\n     Dimension less than 1. */\n\n\nerr102:\n  *jstat = -102;\n  s6err (\"s1938\", *jstat, kpos);\n  goto out;\n\n  /* Order less than 1. */\n\nerr115:\n  *jstat = -115;\n  s6err (\"s1938\", *jstat, kpos);\n  goto out;\n\n  /* No. of vertices less than order. */\n\nerr116:\n  *jstat = -116;\n  s6err (\"s1938\", *jstat, kpos);\n  goto out;\n\n  /* Error in knot vector */\n\nerr117:\n  *jstat = -117;\n  s6err (\"s1938\", *jstat, kpos);\n  goto out;\n\nout:\n  if (alloc_needed)\n    freearray (alfa);\n  if (ktsurf != SISL_NULL)\n    freearray (ktsurf);\n\n  return;\n}\n#undef MAX_SIZE\n"
  },
  {
    "path": "src/s1940.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1940\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1940(SISLCurve *oldcurve, double eps[], int startfix, int endfix, int iopen,\n      int itmax, SISLCurve **newcurve, double maxerr[],\n      int *stat)\n#else\nvoid\ns1940(oldcurve, eps, startfix, endfix, iopen, itmax, newcurve,\n      maxerr, stat)\n    SISLCurve \t*oldcurve;\n    double\teps[];\n    int\t\tstartfix;\n    int\t\tendfix;\n    int         iopen;\n    int\t\titmax;\n    SISLCurve\t**newcurve;\n    double\tmaxerr[];\n    int\t\t*stat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* Purpose: To remove as many knots as possible from the spline curve\n*\t   \"oldcurve\" without perturbing the curve more than a given\n*\t   tolerance. The tolerance is given by \"eps\" and the\n* \t   approximation by \"newcurve\".\n*\n*\n* Input:\n*          oldcurve    - pointer to the original spline curve. \n*\n*\t   eps\t       - double array giving the desired absolute accuracy\n*                        of the final approximation as compared to oldcurve.\n*                        If oldcurve is a spline curve in a space of\n*\t\t\t dimension dim, then eps must have length dim.\n*                        Note that it is not relative, but absolute accuracy\n*                        that is being used. This means that the difference\n*                        in component i at any parameter value, between\n*                        the given curve and the approximation, is to be\n*                        less than eps[i]. Note that in such comparisons\n*                        the same parametrization is used for both curves.\n*\n*\t   startfix    - the number of derivatives to be kept fixed at\n*\t\t\t the beginning of the knot interval.\n*                        The (0 - (startfix-1)) derivatives will be kept fixed.\n*                        If startfix <0, this routine will set it to 0.\n*                        If startfix< the order of the curve, this routine\n*                        will set it to the order.\n*\n*\t   endfix      - the number of derivatives to be kept fixed at\n*\t\t         the end of the knot interval.\n*                        The (0 - (endfix-1)) derivatives will be kept fixed.\n*                        If endfix <0, this routine will set it to 0.\n*                        If endfix< the order of the curve, this routine\n*                        will set it to the order.\n*\n*          iopen       - Open/closed parameter.\n*                        =  1 : Produce open curve.\n*                        =  0 : Produce closed, non-periodic curve if possible.\n*                        = -1 : Produce closed, periodic curve if possible.\n*\n*\t   itmax       - maximum number of iterations. The routine will\n*                        follow an iterative procedure trying to remove\n*                        more and more knots. The process will almost always\n*                        stop after less than 10 iterations and it will often\n*                        stop after less than 5 iterations. A suitable\n*                        value for itmax is therefore usually in the region\n*                        3-10.\n*\n*\n*\n*\n* Output:\n*          newcurve    - the spline approximation on the reduced\n*                        knot vector.\n*\t   maxerr      - double array containing an upper bound for the\n*\t\t\t pointwise error in each of the components of the\n*\t\t         spline approximation. The two curves oldcurve and\n*\t\t\t newcurve are compared at the same parameter value,\n*                        i.e., if oldcurve is f and newcurve is g, then\n*\t\t\t               |f(t)-g(t)| <= eps\n*\t\t\t in each of the components.\n*\n*           stat       - status message\n*                           > 0      : warning\n*                           = 0      : ok\n*                           < 0      : error\n*\n*\n*\n*\n* Method:\n*     The method is described in two papers listed as references below.\n*     First, the knots of the input spline, s, are ranked according to their\n*     relative importance in the representation of s (s1353). Using this\n*     information, knots are removed from s and an approximation g is computed\n*     on the reduced knot vector (s1950) with the error guaranteed to be\n*     less than the tolerance in all components. In order to remove more knots,\n*     the knots of g are ranked, and then knots are removed from g, resulting\n*     in a spline h with even fewer knots. The knot vector of h is then\n*     clearly a subsequence of the knot vector of s and s is approximated\n*     on this knot vector (s1943). If the error is less than the tolerance\n*     then h is accepted as the new best approximation and stored in g.\n*     If the error is greater than the tolerance, knots are removed directly\n*     from s based on the ranking of g resulting in a new g. In either case a\n*     new best approximation g is obtained, and we can continue the iteration.\n*     The iterations stop when no more knots can be removed or all the interior\n*     knots have been removed. (The names s, g, and h are not used in the\n*     code.)\n*\n* NB! The iopen parameter will be satisfyed only if the original curve\n*     provides the possibility for it. For instance if the original curve\n*     is open, and a closed curve is expected, this will in general not be\n*     possible.\n*\n*\n* References:\n*     1. A Data-Reduction Strategy for Splines with Applications to the\n*        Approximation of Functions and data, IMA J. of Num. Anal. 8 (1988),\n*        pp. 185-208.\n*\n*     2. Knot Removal for Parametric B-spline Curves and Surfaces,\n*        CAGD 4 (1987), pp. 217-230.\n*\n*\n* Calls: s1353, s1712, s1950, s1943, s6err\n*\n* Written by: Knut Moerken, University of Oslo, November 1992, based\n*             on an earlier Fortran version by the same author.\n* CHANGED BY: Paal Fugelli, SINTEF, 1994-07.  Initialized pointers (to SISL_NULL)\n*      in 'ranking' to avoid potential memory leak when exiting through 'out'.\n*      Removed several other memory leaks.\n* CHANGED BY: Per OEyvind Hvidsten, SINTEF, 1994-11. Added a freeCurve\n*      call before overwriting the *newarray pointer (thus removing a\n*      memory leak.\n* Changed by : Vibeke Skytt, SINTEF Oslo, 94-12. Introduced periodicity.\n*\n*********************************************************************\n*/\n{\n  char ready, big;              /* Boolean variables used for computing\n                                   the stopping criteria.                */\n  int k = oldcurve->ik;         /* Unwrapped version of the given curve. */\n  int dim = oldcurve->idim;\n  double *d = oldcurve->ecoef;\n  int itcount=0;                /* Iteration counter.                    */\n  int n1 = oldcurve->in;        /* n1 and n2 are used for storing the number\n                                   coefficients in consecutive spline\n                                   approximations. The situation n1=n2\n\t\t\t\t   signifies that no more knots can be\n\t\t\t\t   removed.                              */\n  int n2;\n  int i, mini, maxi, indx;      /* Various auxiliary integer variables.  */\n  int kncont = 0;               /* Number of continuity requirements over\n\t\t\t\t   the seem of a closed curve.           */\n  double *local_err = SISL_NULL;     /* Variables used for storing local error\n                                   estimates.                            */\n  double *l2err = SISL_NULL;\n  double *lepsco = SISL_NULL;\n  double *temp_err = SISL_NULL;\n  SISLCurve *tempcurve = SISL_NULL;  /* Variables that are used for storing\n                                   temporary curves.                     */\n  SISLCurve  *helpcurve = SISL_NULL;\n  rank_info ranking;            /* Variable used for holding ranking\n                                   information (from s1353).             */\n  int lstat=0;                  /* Local status variable.                */\n  int pos=0;\t\t\t/* Parameter to s6err.                  */\n  SISLCurve *qc_kreg = SISL_NULL;    /* Non-periodic version of the input curve. */\n  SISLCurve *qcpart = SISL_NULL;     /* Curve representing a Bezier segment. */\n\n\n  /* Initialize ranking ptrs in case of early exit through 'out' (PFU 05/07-94) */\n  ranking.prio = SISL_NULL;\n  ranking.groups = SISL_NULL;\n\n  /* Initialize maxerr to zero. */\n\n  for (i=0; i<dim; i++) maxerr[i] = DZERO;\n\n  /* Only interior knots may be removed so if n1==k we can stop\n     straight away.                                             */\n\n  if (n1 == k)\n  {\n    *newcurve = newCurve(n1, k, oldcurve->et, oldcurve->ecoef,\n\t\t\t oldcurve->ikind, oldcurve->idim, 1);\n    if (*newcurve == SISL_NULL)  goto err101;\n\n    *stat = 0;\n    goto out;\n  }\n\n  /* Make sure that the input curve is non-periodic.  */\n\n  if (oldcurve->cuopen == SISL_CRV_PERIODIC)\n  {\n     /* First count continuity at the seem. */\n      \n     for (i=oldcurve->ik-1; i>0; i--)\n\tif (DNEQUAL(oldcurve->et[i-1], oldcurve->et[i])) break;\n     kncont = i;\n     \n    make_cv_kreg(oldcurve, &qc_kreg, &lstat);\n    if (lstat < 0) goto error;\n  }\n  else\n  {\n    qc_kreg = newCurve(oldcurve->in, oldcurve->ik, oldcurve->et, \n\t\t       oldcurve->ecoef, oldcurve->ikind, oldcurve->idim, 1);\n    if (qc_kreg == SISL_NULL) goto err101;\n  }\n  \n  /* Ensure closed output curve if the input curve is closed. */\n  \n  if (oldcurve->cuopen == SISL_CRV_CLOSED)\n     kncont = 1;\n \n  /* Allocate space for some local arrays. */\n\n  temp_err = newarray(dim, double);\n  if (temp_err == SISL_NULL) goto err101;\n\n  lepsco = newarray(dim, double);\n  if (lepsco == SISL_NULL) goto err101;\n  \n  local_err = newarray(dim, double);\n  if (local_err == SISL_NULL) goto err101;\n\n  l2err = newarray(dim, double);\n  if (l2err == SISL_NULL) goto err101;\n  \n  /* ranking is of type rank_info which is a struct described in s1353. */\n\n  ranking.prio = newarray(n1, int);\n  if (ranking.prio == SISL_NULL) goto err101;\n\n  ranking.groups = newarray(n1, int);\n  if (ranking.groups == SISL_NULL) goto err101;\n\n  /* lespco is needed in s1950. In component i we first store the l1-norm\n     of the component i of the B-spline coefficients of oldcurve. */\n\n  for (i=0; i<dim; i++) lepsco[i] = fabs(d[i]);\n\n  indx = 0;\n  for (i=1; i<n1*dim; i++)\n  {\n    lepsco[indx++] += fabs(d[i]);\n    if (indx == dim) indx = 0;\n  }\n\n  /* We can now compute the final value of lepsco which will be used for\n     checking if two numbers are almost equal. */\n\n  for (i=0; i<dim; i++)\n    lepsco[i] = MIN(lepsco[i]*REL_COMP_RES/n1, eps[i]);\n\n  /* This is where the knot removal process starts. */\n\n  /* mini and maxi are lower and upper bounds on how many knots that can\n     be removed. */\n\n  mini = 0;\n  maxi = n1 - k + 1;\n\n  /* Start by ranking the knots of oldcurve. First make a help curve where\n     the first Bezier segment of the original curve is repeated at the\n     end of the curve. */\n  \n  /* Pick first segment of original curve. */\n  \n  s1712(qc_kreg, qc_kreg->et[k-1], qc_kreg->et[k], &qcpart, &lstat);\n  if (lstat < 0) goto error;\n  \n  /* Adjust qc_kreg in order to store the extra Bezier segment. */\n  \n  if ((qc_kreg->ecoef = increasearray(qc_kreg->ecoef, (n1+k)*dim, DOUBLE))\n      == SISL_NULL) goto err101;\n  if ((qc_kreg->et = increasearray(qc_kreg->et, n1+k+k, DOUBLE)) == SISL_NULL)\n     goto err101;\n  memcopy(qc_kreg->ecoef+n1*dim, qcpart->ecoef, k*dim, DOUBLE);\n  for (i=0; i<k; i++) \n     qc_kreg->et[n1+k+i] = qc_kreg->et[n1+i] + qcpart->et[k+i] - qcpart->et[i];\n  qc_kreg->in += k;\n\n  /* Remove memory occupied by the curve describing the Bezier segment. */\n  \n  if (qcpart != SISL_NULL) freeCurve(qcpart);\n  qcpart = SISL_NULL;\n  \n  /* Perform ranking. */\n  \n  s1353(qc_kreg, eps, &ranking, &lstat);\n  if (lstat < 0) goto error;\n\n  /* Based on the computed ranking, we remove as close to maxi knots\n     from oldcurve as possible, but such that we can always compute an\n     approximation to oldcurve on the reduced knot vector, with error less\n     than eps.  newcurve will be created with icopy==1.  */\n\n  /* First reset the size of qc_kreg. This routine operates on the\n     original (non-periodic) input curve. */\n  \n  qc_kreg ->in -= k;\n  \n  s1950(qc_kreg, qc_kreg, &ranking, eps, lepsco, startfix, endfix, &kncont,\n\tmini, maxi, newcurve, maxerr, &lstat);\n  if (lstat < 0) goto error;\n\n  /* The spline stored in newcurve is now an approximation to oldcurve\n     with error less than eps. We will now iterate and try to remove knots\n     from newcurve. The integers n1 and n2 will be the number of knots in\n     the two most recent approximations. */\n\n  n2 = (*newcurve)->in;\n\n  /* Start the iterations. We have already done one iteration and we have\n     not had any problems with the error getting too big. */\n\n  itcount = 1;\n  big = 0;\n\n  /* If n1=n2 we are unable to remove any knots, and if n2=k there are\n     no interior knots left so we can stop. Likewise if itmax was 1. */\n\n  ready = (n1 == n2) || (n2 == k) || (itcount == itmax);\n  while (!ready)\n  {\n\n    /* We start by ranking the knots of newcurve which is the approximation\n       with the fewest knots that we have found so far. */\n\n     /* Pick first segment of newcurve curve. */\n     \n     s1712(*newcurve, (*newcurve)->et[k-1], (*newcurve)->et[k],\n\t   &qcpart, &lstat);\n     if (lstat < 0) goto error;\n     \n     /* Adjust *newcurve in order to store the extra Bezier segment. */\n     \n     if (((*newcurve)->ecoef = increasearray((*newcurve)->ecoef, (n2+k)*dim, DOUBLE))\n\t == SISL_NULL) goto err101;\n     if (((*newcurve)->et = increasearray((*newcurve)->et, n2+k+k, DOUBLE)) == SISL_NULL)\n\tgoto err101;\n     memcopy((*newcurve)->ecoef+n2*dim, qcpart->ecoef, k*dim, DOUBLE);\n     for (i=0; i<k; i++) \n\t(*newcurve)->et[n2+k+i] = (*newcurve)->et[n2+i] + qcpart->et[k+i] - qcpart->et[i];\n     (*newcurve)->in += k;\n     \n     /* Remove memory occupied by the curve describing the Bezier segment. */\n     \n     if (qcpart != SISL_NULL) freeCurve(qcpart);\n     qcpart = SISL_NULL;\n  \n     /* Ranking. */\n     \n    s1353(*newcurve, eps, &ranking, &lstat);\n    if (lstat < 0) goto error;\n\n    /* Reset size of *newcurve. */\n    \n    (*newcurve)->in -= k;\n    \n    if (!big)\n    {\n\n      /* If we have not had any problems with the error in approximation\n         becoming too big we take the risk of removing as many knots as\n         we can from newcurve and in this way determining an even shorter\n\t knot vector.\n\t First we iterate in s1950 to see how many knots we can remove\n\t and store the approximation to newcurve in helpcurve (will be\n\t created with icopy==1). */\n\n      mini = 0; maxi = (*newcurve)->in - k + 1;\n      s1950(*newcurve, *newcurve, &ranking, eps, lepsco, startfix, \n\t    endfix, &kncont, mini, maxi, &helpcurve, temp_err, &lstat);\n      if (lstat < 0) goto error;\n\n      /* Now, we have no guarantee that helpcurve is closer to oldcurve\n         than the tolerance so we compute a new approximation to oldcurve\n         on the knot vector of helpcurve and store this in tempcurve (with\n\t icopy==1).\n\t Must make sure that local_err is free'ed if allocated from last\n\t iteration. */\n\n      s1943(qc_kreg, helpcurve->et, k, helpcurve->in,\n\t     startfix, endfix, kncont, &tempcurve,\n\t     local_err, l2err, &lstat);\n      if (lstat < 0) goto error;\n\n      /* Don't need  helpcurve anymore. */\n\n      freeCurve(helpcurve);\n      helpcurve = SISL_NULL;\n\n      /* We must now check if the new tempcurve is within the tolerance. */\n      i = 0;\n      while (!big && i<dim)\n      {\n\tbig = local_err[i] > eps[i];\n\ti++;\n      }\n    }\n    else\n\n      /* If we have had problems with the error becoming greater than the\n\t tolerance, we simply store newcurve in tempcurve and proceed. */\n\n      tempcurve = *newcurve;\n\n    if (big)\n    {\n\n      /* If at some stage we have had problems with the error becoming\n\t larger than the tolerance, we do not get involved in the risky\n\t approach of removing knots from newcurve. Instead we throw away\n         tempcurve and remove knots directly from oldcurve, but remember\n\t that the only knots left to remove are the knots of newcurve for\n\t which we use the ranking computed above. The result is stored\n\t in helpcurve and later transferred to newcurve. */\n\n      mini= 0; maxi = tempcurve->in - k + 1;\n      s1950(qc_kreg, *newcurve, &ranking, eps, lepsco, startfix, \n\t    endfix, &kncont, mini, maxi, &helpcurve, maxerr, &lstat);\n      if (lstat < 0) goto error;\n\n      if (*newcurve != SISL_NULL && *newcurve != tempcurve)\n      {\n\tfreeCurve(*newcurve);\n\t*newcurve = SISL_NULL;\n      }\n\n      if (tempcurve != SISL_NULL)\n      {\n\tfreeCurve(tempcurve);\n\ttempcurve = SISL_NULL;\n      }\n      *newcurve = helpcurve;\n      helpcurve = SISL_NULL;\n    }\n    else\n    {\n\n      /* Since we now know that the difference between oldcurve and tempcurve\n\t is within the tolerance, we just have to store the error in maxerr,\n\t throw away the old newcurve, and store tempcurve in newcurve. */\n\n      for (i=0; i<dim; i++) maxerr[i] = local_err[i];\n\n      if (*newcurve != SISL_NULL) freeCurve(*newcurve);\n      *newcurve = tempcurve;\n      tempcurve = SISL_NULL;\n    }\n\n    /* Now we must check if it is time to stop. */\n\n    n1 = n2;\n    n2 = (*newcurve)->in;\n    ++itcount;\n    ready = (n1 == n2) || (n2 == k) || (itcount == itmax);\n  }\n\n  /* Set periodicity flag.  */\n\n  if (iopen == SISL_CRV_PERIODIC && kncont > 0)\n  {\n     /* Make the curve periodic. */\n     \n     s1941(*newcurve, MIN(k-2,kncont-1), &lstat);\n     if (lstat < 0) goto error;\n  }\n  else if (kncont > 0)\n    (*newcurve)->cuopen = SISL_CRV_CLOSED;\n\n  /* Success */\n\n  *stat = 0;\n  goto out;\n\n  /* Error in allocation of memory. */\n\nerr101:\n  *stat = -101;\n  s6err(\"s1940\", *stat, pos);\n  goto out;\n\n  /* Error in lower level routine. */\n\nerror:\n  *stat = lstat;\n  s6err(\"s1940\", *stat, pos);\n  goto out;\n\n  /* Clear up and free memory before exit. */\n\nout:\n  if (temp_err != SISL_NULL) freearray(temp_err);\n  if (local_err != SISL_NULL) freearray(local_err);\n  if (l2err != SISL_NULL) freearray(l2err);\n  if (lepsco != SISL_NULL) freearray(lepsco);\n  if (ranking.prio != SISL_NULL) freearray(ranking.prio);\n  if (ranking.groups != SISL_NULL) freearray(ranking.groups);\n  if (qc_kreg != SISL_NULL) freeCurve(qc_kreg);\n  if (qcpart != SISL_NULL) freeCurve(qcpart);\n  if (helpcurve != SISL_NULL && helpcurve != (*newcurve)) freeCurve(helpcurve);\n  if (tempcurve != SISL_NULL && tempcurve != (*newcurve)) freeCurve(tempcurve);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1941.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n\n#define S1941\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1941(SISLCurve *pcurve,int icont,int *jstat)\n#else\nvoid s1941(pcurve,icont,jstat)\n     SISLCurve  *pcurve;\n     int        icont;\n     int    \t*jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To describe the B-spline curve (i.e. not NURBS) pcurve with a\n*              cyclic basis of continuity icont.\n*\n* INPUT      : pcurve - Pointer to the curve\n*              icont  - The required continuity\n*\n* OUTPUT     : jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*              pcurve - The curve with modified description\n*\n* METHOD     : 1. The cyclic knot vector with the right continuity is made\n*              2. The transformation matrix for the ik2 first vertices between\n*                 the cyclic and the old knot vector is made.\n*              3. The transformation matrix is inverted and used to update the\n*                 ik2 first vertices.\n*              4. The transformation matrix for the ik2 last vertices between\n*                 the cyclic and the old knot vector is made.\n*              5. The transformation matrix is inverted and used to update the\n*                 ik2 last vertices.\n*              6. The knot vector is updated.\n*-\n* CALLS      : s1701,s6err.\n*\n* Written  by : Tor Dokken, SI, Oslo, Norway,feb-1992\n* Renamed and adapted for curves by : Vibeke Skytt, SINTEF Oslo, 01.95.\n*\n*********************************************************************\n*/\n{\n  double *scycl=SISL_NULL;                    /* Cyclic version of knot vector */\n  double *smatrix=SISL_NULL;                   /* Matrix converting between baes */\n  double *salloc=SISL_NULL;                    /* Matrix for memory allocation */\n  double *salfa=SISL_NULL;                     /* The values of a discrete B-spline\n                                             calculation */\n  double *spek=SISL_NULL;                      /* Pointer used in traversing arrays */\n  double *scoef=SISL_NULL;                     /* Copy of the vertices of the surface */\n  double *sb=SISL_NULL;                        /* Right hand side of equation */\n  double *sfrom,*sto;\n  double *sp;                             /* Hlep array for s1701 */\n  double *st1=SISL_NULL;                       /* Internal version of et */\n  double *stx=SISL_NULL;                       /* Knot vector after insertion of knots\n                                             at start */\n\n  int    kdim = pcurve->idim;\n  int    kk = pcurve->ik;\n  int    kn = pcurve->in;\n\n  int    kcont;                           /* Checked continuity */\n  int    kmult;                           /* Multiplicity of knot kk-1 and kn*/\n  int    ki,kj,kl;\n  int    kperlength;\n  int    kant;\n  int    kleft=0;                         /* Pointer into knot vector */\n  int    kpl,kfi,kla;                     /* Pointers into conversion matrix */\n  int    kstat;\n  int    *mpiv=SISL_NULL;                      /* Pointer to pivotation array */\n  int    kpos = 0;\n  int    knst1;                           /* NUmber of basis functions in st1 */\n  int    knstx;                           /* Number of basis functions in stx */\n\n\n\n\n  /* Test continuity */\n\n  if (icont < 0) goto finished;\n  kcont = icont;\n  if (icont >= kk-2) icont = kk-2;\n\n  /* Make multiplicty to be used at value et[ik-1] and et[in] */\n  kmult = kk - kcont - 1;\n\n  /* Make the number of knots to be changed at the start and the end, this\n     is also equal to extra knot to be inserted in internal version of array et */\n\n  kant = kk-kmult;\n\n\n  /* Alloocate array for pivotation vector */\n\n  mpiv = new0array(2*kk,INT);\n  if (mpiv == SISL_NULL) goto err101;\n\n  salloc = new0array(3*kn+9*kk+4*kk*kk+kdim*kn,DOUBLE);\n  if (salloc == SISL_NULL) goto err101;\n  scycl = salloc;                  /* Size kn+kk */\n  smatrix = scycl + kn + kk;  /* Max size 4*kk*kk */\n  salfa = smatrix + 4*kk*kk;     /* Size kk */\n  scoef = salfa + kk;           /* Size kdim*kn */\n  sb    = scoef + kdim*kn;    /* Size 2*kk */\n  sp    = sb + 2*kk;              /* Size kk */\n  st1   = sp + kk;                /* Size kn + 2*kk */\n  stx   = st1 + kn + 2*kk;       /* Size kn + 2*kk */\n\n\n\n  /* Copy vertices, to avoid destruction of the curve */\n\n  memcopy(scoef,pcurve->ecoef,kdim*kn,DOUBLE);\n\n\n\n  /* Make cyclic knot vector */\n\n\n  /* First copy all knots */\n\n  memcopy(scycl,pcurve->et,kn+kk,DOUBLE);\n\n  /* The change the ik first and the ik last knots to make a cyclic basis */\n\n  kperlength = kn - kk + kmult;\n\n  /* Make knots 0 to ik - kmult - 1 */\n\n  for (ki=kk-kmult-1 ; 0<=ki ; ki--)\n    {\n      scycl[ki] = scycl[kk-1] - (scycl[kn] - scycl[ki+kperlength]);\n    }\n\n\n  /* Make knots kn1 + kmult to kn1 + kk1 -1 */\n\n  for (ki=kmult ; ki < kk ; ki++)\n    {\n      scycl[kn+ki] = scycl[kn] + (scycl[kk+ki-kmult] - scycl[kk-1]);\n\n    }\n      /* s1701 expects et1 to be a refinement of scyclic, thus we have to make a new\n\t version of et1 with the extra kk1-kmult new knots before the start and\n\t after the end and one intermediate version with only kk1-kmult at the start */\n\n  memcopy(st1,scycl,kant,DOUBLE);\n  memcopy(st1+kant,pcurve->et,kn+kk,DOUBLE);\n  memcopy(st1+kant+kk+kn,scycl+kn+kk-kant,kant,DOUBLE);\n  knst1 = kn + 2*kant;\n\n  memcopy(stx,scycl,kn,DOUBLE);\n  memcopy(stx+kn,st1+kant+kn,kk+kant,DOUBLE);\n  knstx = kn + kant;\n\n  /* STEP 2 Make matrix going between bases, only the kk2-kmult first and last knots\n     are to be changed.  */\n\n\n  /* Now we have two cases. We know that only the kk1-kmult first and kk1-kmult\n     last vertices are to be changed. However 2*(kk1-kmult) might be a bigger\n     number than kn1. Thus we have to change all vertices if kn1<=2(kk1-kmult) */\n\n\n  /* Make two steps one for the start and one for the end of the surface */\n\n\n  /* Make matrix for the kk1 first vertices */\n\n  for (ki=kant,spek=smatrix ; ki <kk+kant ; ki++, spek+=kk)\n    {\n      /* we use kn instead of knstx since s1219 expects et[in-1] != et[in], we only\n         address vertices at the start so this does not matter*/\n\n      s1219(stx,kk,kn,&kleft,st1[ki],&kstat);\n      if (kstat<0) goto error;\n\n      s1701(ki,kleft,kk,knstx,&kpl,&kfi,&kla,st1,stx,sp,salfa,&kstat);\n      if(kstat<0) goto error;\n\n      /* Copy the discrete B-splines into the right position */\n\n      memcopy(spek+kfi,salfa+kpl+kfi,kla-kfi+1,DOUBLE);\n    }\n\n\n\n  /* Do the factorisation of the matrix */\n\n  s6lufacp(smatrix,mpiv,kk,&kstat);\n  if (kstat<0) goto error;\n\n  /* The vertices in the curve are ordered in the sequence\n     (x1,y1,z1),..,(xi,yi,zi), i=1,..,in. The only vertices\n     affected by this backsubstitution is the kant first ones.\n     We want to treat the back substitution\n     as idim(=3) backsubstitutions. Thus we have to copy the proper\n     parts of the vertices into a temporary array. Do backsubstitution and\n     copy back into the curve object */\n\n\n  for (kl=0 ; kl<kdim ; kl++)\n  {\n     for (kj=0, sfrom=(pcurve->ecoef)+kl,sto=sb ;\n      kj<kk ; kj++,sfrom+=kdim,sto++)\n\t*sto = *sfrom;\n     \n     /* sb now contains the vertices to be backsubsituted */\n     \n     s6lusolp(smatrix,sb,mpiv,kk,&kstat);\n     if (kstat<0) goto error;\n     \n     /* Copy the backsubsituted vertices back into scoef */\n     \n     for (kj=0, sto=scoef+kl,sfrom=sb ;\n      kj<kk ; kj++,sfrom++,sto+=kdim)\n\t*sto = *sfrom;\n  }\n\n\n  /* Make matrix for the kk last vertices */\n\n\n  for (ki=0,spek=smatrix ; ki<kk*kk ; ki++,spek++) *spek = DZERO;\n\n\n  for (ki=kn-kk ,spek=smatrix ; ki <kn ; ki++, spek+=kk)\n    {\n      s1219(scycl,kk,kn,&kleft,stx[ki],&kstat);\n      if (kstat<0) goto error;\n\n      s1701(ki,kleft,kk,kn,&kpl,&kfi,&kla,stx,scycl,sp,salfa,&kstat);\n      if(kstat<0) goto error;\n\n      /* Copy the discrete B-splines into the right position */\n\n      memcopy(spek+kfi-(kn-kk),salfa+kpl+kfi,kla-kfi+1,DOUBLE);\n    }\n\n\n\n  /* Do the factorisation of the matrix */\n\n  s6lufacp(smatrix,mpiv,kk,&kstat);\n  if (kstat<0) goto error;\n\n  /* The vertices in the curve are ordered in the sequence\n     (x1,y1,z1),..,(xi,yi,zi), i=1,..,in. The only vertices\n     affected by this backsubstitution is the kant last ones.\n     We want to treat the back substitution\n     as idim(=3) backsubstitutions. Thus we have to copy the proper\n     parts of the vertices into a temporary array. Do backsubstitution and\n     copy back into the curve object */\n\n  for (kl=0 ; kl<kdim ; kl++)\n  {\n     for (kj=0, sfrom=scoef+kdim*(kn-kk)+kl,sto=sb ;\n      kj<kk ; kj++,sfrom+=kdim,sto++)\n\t*sto = *sfrom;\n     \n     /* sb now contains the vertices to be backsubsituted */\n     \n     s6lusolp(smatrix,sb,mpiv,kk,&kstat);\n     if (kstat<0) goto error;\n     \n     /* Copy the backsubsituted vertices back into scoef */\n     \n     for (kj=0, sto=scoef+kdim*(kn-kk)+kl,sfrom=sb ;\n      kj<kk ; kj++,sto+=kdim,sfrom++)\n\t*sto = *sfrom;\n  }\n\n\n  /* Copy knots and vertices into the curve object */\n\n  memcopy(pcurve->ecoef,scoef,kdim*kn,DOUBLE);\n  memcopy(pcurve->et,scycl,kn+kk,DOUBLE);\n\n  /* Set periodicity flag */\n  pcurve->cuopen = SISL_CRV_PERIODIC;\n\n\n  /* Task done */\n\n finished:\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in allocation. */\n\n err101:\n  *jstat = -101;\n  s6err(\"s1941\",*jstat,kpos);\n  goto out;\n\n\n\n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n  s6err(\"s1941\",*jstat,kpos);\n  goto out;\n out:\n\n  /* Free allocated scratch  */\n  if (salloc != SISL_NULL) freearray(salloc);\n  if (mpiv != SISL_NULL) freearray(mpiv);\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s1942.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1942\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1942(SISLCurve *pc1,SISLCurve *pc2,int idim,double ea[],int nstart[],\n\t     int nstop[],double emxerr[],double el2err[],int *jstat)\n#else\nvoid s1942(pc1,pc2,idim,ea,nstart,nstop,emxerr,el2err,jstat)\n   SISLCurve *pc1;\n   SISLCurve *pc2;\n   int idim;\n   double ea[];\n   int nstart[];\n   int nstop[];\n   double emxerr[];\n   double el2err[];\n   int *jstat;\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : To calculate the discrete max-error\n*              and L2-error of the approximation.\n* \n* \n* INPUT      : pc1    - The spline curve to be approximated.\n*              pc2    - The curve approximating pc1 on a subset of the\n*                       knotvector.\n*              idim   - The dimension of the geometry space.\n*              ea     - Real array of dimension (pc1->in*pc1->ik) containing \n*                       the B-spline refinement matrix from the knot vector\n*                       pc2->et to the knot vector pc1->et. This matrix has\n*                       dimension pc1->in*pc2->in but since at most\n*                       pc1->ik entries are nonzero in each row, it can\n*                       be stored in a pc1->in*pc1->ik array together\n*                       with two integer arrays indicating the position\n*                       of the first and last nonzero elements in each\n*                       row.\n*              nstart - Integer array of dimension (pc1->in) containing \n*                       pointers to the first nonzero element of each row \n*                       of the B-spline refinement matrix from pc2->et to\n*                       pc1->et.\n*              nstop  - Integer array of dimension (pc1->in) containing \n*                       pointers to the last nonzero element of each row \n*                       of the B-spline refinement matrix from pc2->et to\n*                       pc1->et.\n*\n* \n* OUTPUT     : emxerr - Real array of dimension (idim) containing the \n*                       absolute value of the largest B-spline coefficient\n*                       of f-g in each component when\n*                       f-g is expressed as a spline on the pc1->et knot\n*                       vector.\n*              el2err - Real array of dimension (idim) containing a\n*                       weighted L2-norm of the B-spline coefficients of\n*                       f-g in each component when f-g is expressed as a\n*                       spline on the knot vector pc1->et.\n*              jstat     - status messages \n*                          > 0 : warning \n*                          = 0 : ok \n*                          < 0 : error \n*             \n* \n* METHOD     : \n*\n*\n* REFERENCES : Any book on general numerical analysis or numerical\n*              linear algebra.\n*              \n*\n* USE        :\n*\n*-\n* CALLS      :   \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.92, on the basis of a routine\n*              written by Tom Lyche and Knut Moerken, 12.85.\n* CHANGED AND RENAMED BY : Vibeke Skytt, SINTEF Oslo, 12.94. Introduced\n*                                        periodicity.\n*\n*********************************************************************\n*/\n{\n   int ki,kj,kr;\n   int kjh;\n   int kk = pc1->ik;\n   int km = pc1->in;\n   int kj1,kj2;\n   double tkindv = (double)1.0/(double)kk;\n   double thelp;\n   double *st = pc1->et;\n   double *sd = pc1->ecoef;\n   double *sc = pc2->ecoef;\n   double *stemp = SISL_NULL;\n   \n   /* Allocate scratch for local array.  */\n   \n   if ((stemp = newarray(idim,DOUBLE)) == SISL_NULL) goto err101;\n  \n   /* Initiate arrays to zero.  */\n   \n   memzero(stemp,idim,DOUBLE);\n   memzero(emxerr,idim,DOUBLE);\n   memzero(el2err,idim,DOUBLE);\n\t\t  \n   /* Express the approximating spline as a spline on et by multiplying\n      ec by ea and then calculate the error in the spline approximation. */\n   \n   for (ki=0; ki<km; ki++)\n     {\n\tmemzero(stemp,idim,DOUBLE);\n\t\n\t/* Express the approximation as a spline on et.  */\n\t\n\tkj1 = nstart[ki];\n\tkj2 = nstop[ki];\n\tfor (kjh=kk+kj1-kj2-1, kj=kj1; kj<=kj2; kjh++, kj++)\n\t  {\n\t     thelp = ea[ki*kk+kjh];\n\t     for (kr=0; kr<idim; kr++)\n\t       stemp[kr] += thelp*sc[kj*idim+kr];\n\t  }\n\t\n\t/* Calculate the maxerror and the weighted L2-error of the\n\t   approximation. */\n\t\n\tthelp = (st[ki+kk] - st[ki])*tkindv;  \n\tfor (kr=0; kr<idim; kr++)\n\t  {\n\t     stemp[kr] = fabs(stemp[kr] - sd[ki*idim+kr]);\n\t     el2err[kr] += thelp*stemp[kr]*stemp[kr];\n\t     if (stemp[kr] > emxerr[kr]) emxerr[kr] = stemp[kr];\n\t  }\n     }\n   for (kr=0; kr<idim; kr++)\n     el2err[kr] = sqrt(el2err[kr]);\n\t\n   \n   *jstat = 0;\n   goto out;\n   \n   /* Error in space allocation.  */\n   \n   err101: *jstat = -101;\n   goto out;\n   \n   out:\n      /* Free scratch used for local array.  */\n      \n      if (stemp != SISL_NULL) freearray(stemp);\n\t  \n      return;\n}\n   \n"
  },
  {
    "path": "src/s1943.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S1943\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1943(SISLCurve *pcurve,double etau[],int ik,int in,int ileftfix,\n\t     int irightfix,int incont,SISLCurve **rnewcurve,\n\t     double gmaxerr[],double gl2err[],int *jstat)\n#else\nvoid s1943(pcurve,etau,ik,in,ileftfix,\n\t    irightfix,incont,rnewcurve,gmaxerr,gl2err,jstat)\n     SISLCurve *pcurve;\n     double etau[];\n     int ik;\n     int in;\n     int ileftfix;\n     int irightfix;\n     int incont;\n     SISLCurve **rnewcurve;\n     double gmaxerr[];\n     double gl2err[];\n     int *jstat;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate an approximation to a given spline pcurve, f,\n*              in a spline space S0 (given by the knot vector and number\n*              of coefficients of the spline pcurve), from a subspace \n*              S1 (given by the knot vector etau which is a subseqence\n*              of the knotvector of pcurve) of dimension in. Both the \n*              input and the output spline is of order ik. The approximation\n*              rnewcurve, g, is to be a least squares approximation to pcurve\n*              in the sense that a weighted sum of the squares of the \n*              B-spline coefficients of f-g (expressed as a spline on the\n*              knotvector of pcurve, i.e. f) is minimized. In addition, the\n*              0 - ileftfix-1 derivatives at the left end of the curve pcurve\n*              and the 0 - irightfix-1 derivatives at the right end of the \n*              curve are to be kept fixed, i.e. there are ileftfix+irightfix\n*              side conditions, and there are incont continuity conditions\n*              at the seam of the spline curve.\n*\n*\n*\n* INPUT      : pcurve    - Curve to be approximated on a subspace of the spline\n*                          space in which the curve lies.\n*              etau      - Knot vector corresponding to the subspace in which\n*                          the approximating curve will lie.\n*              ik        - Order of approximating curve. Should be the same as \n*                          the order of the input curve.\n*              in        - Number of coefficients of the approximating spline.\n*                          The dimension of the subspace.\n*              ileftfix  - The number of derivatives that are to be kept fixed\n*                          at the left end of the spline.\n*              irightfix - The number of derivatives that are to be kept fixed\n*                          at the right end of the spline.\n*              incont    - Number of continuity conditions over the seam.\n*                          incont < ik.\n*              \n*                       \n*\n* OUTPUT     : rnewcurve  - Curve in the given subspace approximating the\n*                           input spline curve.\n*              gmaxerr    - Array of dimension equal to the dimension of the \n*                           geometry space, containing the absolute value of \n*                           the largest B-spline coefficient of the error f-g\n*                           (see purpose above) in each component when f-g is\n*                           expressed as a spline on the knot vector of f, \n*                           i.e. pcurve.\n*              gl2err     - Array of dimension equal to the dimension of the\n*                           geometry space, containing a weighted L2-norm of\n*                           the B-spline coefficients of the error curve f-g.\n*              jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES : T. Lyche and K. Moerken. A Data Reduction Strategy for\n*              Splines. February 1987.\n*              \n*\n* USE        : \n*\n*-\n* CALLS      : \n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 07.90.\n* REWRITTEN BY: Vibeke Skytt, SI, 05.92 on a basis of a routine by\n*               Tom Lyche and Knut Moerken, 08.86 and 12.85.\n* REWISED AND RENAMED BY : Vibeke Skytt, SINTEF Oslo, 12/94. Introduced\n*                          continuity conditions originating from periodicity.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;            /* Status variable. */\n  int kdim = pcurve->idim;  /* Dimension of geometry space.          */\n  int kj;                   /* Counter.                              */\n  int kkind = 1;            /* Indicates polynomial B-spline curve.  */\n  int kcopy = 1;            /* Copy input arrays when creating a\n\t\t\t       B-spline curve.      */\n  int kn = pcurve->in;      /* Number of vertices of input curve.    */\n  int knlr;                 /* Number of rows in corner element.     */\n  int knred = 0;            /* Number of equations removed because of \n\t\t\t       periodicity. */\n  int knormr;               /* Number of rows of corner element of normal\n\t\t\t       equations.                                */\n  double *scoef = SISL_NULL;     /* Coefficient array of approximating curve. */\n  double *sa = SISL_NULL;        /* Transformation matrix.  */\n  double *sa2 = SISL_NULL;       /* Transformation matrix. Copy of last part of sa.*/\n  double *sw1 = SISL_NULL;       /* Corner element due to continuity requirements. */\n  double *sb = SISL_NULL;        /* Coefficient matrix of the normal equations. */\n  double *sw2 = SISL_NULL;       /* Corner elements of normal equations.        */\n  double *sfac = SISL_NULL;      /* Factors used to implement continuity \n\t\t\t       requirements.                               */\n  int *lfirst = SISL_NULL;       /* Integer array of dimension kn containing\n\t\t\t       pointers to the first nonzero element of each\n\t\t\t       row of the B-spline refinement matrix, sa. from\n\t\t\t       etau to pcurve->et.  */\n  int *lfirst2 = SISL_NULL;      /* Copy of last part of lfirst.               */\n  int *llast = SISL_NULL;        /* Pointer to the last nonzero element of sa. */\n  int *llast2 = SISL_NULL;       /* Copy of last part of llast to avoid destroing \n\t\t\t       the original information of llast.         */\n  int *l2sta = SISL_NULL;        /* Pointer to the first non-zero element of the\n\t\t\t       coefficient matrix of the normal equations. */\n  double *sc = SISL_NULL;        /* Copy of coefficients of the input curve.    */\n  int kk = pcurve->ik;      /* Order of curves.                            */\n  int knh;                  /* Size of coefficient matrix in matrix solver. */\n\n  /* Test order of input curve. */\n\n  if (kk != ik) goto err109;\n\n  /* Make sure that the conditions on continuity and side constraints\n     are consistent. */\n  \n  if (incont < 0) incont = 0;\n  if (incont >= ik) incont = ik-1;\n  \n  if (ileftfix >= incont && irightfix >= incont) incont = 0;\n  else if (irightfix >= ileftfix && irightfix >= incont)\n  {\n     ileftfix = incont;\n     irightfix -= incont;\n  }\n  else if (irightfix > ileftfix)\n  {\n     ileftfix = irightfix;\n     irightfix = 0;\n  }\n  else if (incont >= irightfix) irightfix = 0;\n  knh = in - ileftfix - irightfix - incont;\n  \n  /* Allocate scratch for coefficients of approximating spline.  */\n\n  if ((scoef = newarray(in*kdim,DOUBLE)) == SISL_NULL) goto err101;\n  \n  /* If kn = in then pcurve->et = etau and if no continuity \n     requirements are given, the problem is trivial. \n     The solution is the input spline itself resulting in\n     a zero error. If any continuity requirements are given,\n     we run the approximation in order to get an exact fit\n     at the seem.  */\n  \n  if (kn == in && incont == 0)\n  {\n     memcopy(scoef,pcurve->ecoef,in*kdim,DOUBLE);\n     \n     /* Express the approximating curve as a curve.  */\n     \n     if ((*rnewcurve = newCurve(in,ik,etau,scoef,kkind,kdim,kcopy)) == SISL_NULL)\n\tgoto err101;\n     (*rnewcurve)->cuopen = pcurve->cuopen;\n     \n     memzero(gmaxerr,kdim,DOUBLE);\n     memzero(gl2err,kdim,DOUBLE);\n  }     \n  else\n  {\n     /* Allocate scratch for local arrays. \n\tAllocate scratch for a transformation matrix. This is a\n\tkn*in matrix, but since at most ik elements\n\tare nonzero in each row, it can be stored as a kn*ik\n\tmatrix together with two integer arrays of length kn\n\tindicating the position of the first and last nonzero elements\n\tof each row of the matrix.   \n\tAlso allocate scratch for the coefficient matrix sb of the\n\tnormal equations. This is a in*in symmetric positive definite\n\tmatrix, but since at most ik elemnts are nonzero in each row, it\n\tcan be stored as a in*ik matrix together with an integer array\n\tof length kn indicating the position of the first nonzero element\n\tof each row of sb.  \n\tIn the periodic case (continuity requirements are given) it is\n\tnecessary to allocate scratch for storing corner elements. */\n     \n     if ((sa = newarray((kn+in)*ik+incont*incont,DOUBLE)) == SISL_NULL) goto err101;\n     sb = sa + kn*ik;\n     if ((lfirst = newarray(3*kn,INT)) == SISL_NULL) goto err101;\n     llast = lfirst + kn;\n     l2sta = llast + kn;\n     \n     if (incont > 0)\n     {\n\tsfac = sb + in*ik;\n\tmemzero(sfac, incont*incont, DOUBLE);\n     }\n     \n     /* Compute the refinement matrix sa from etau to pcurve->et.  */\n     \n     sh1922(pcurve->et,kn,ik,etau,in,sa,lfirst,llast,&kstat);\n     if (kstat < 0) goto error;\n\t\t\n     /* Compute size of matrix storing corner element. */\n     \n     for (knormr=in, kj=kn-1; kj>=0; kj--)\n     {\n\tif (llast[kj] < in-incont) break;\n\tknormr = MIN(knormr, lfirst[kj]);\n     }\n     knlr = kn - kj - 1;\n     knormr = MIN(knh, in - knormr);\n     \n     \n     if (knlr > 0)\n     {\n\t\n\t/* Allocate scratch for corner element matrix. */\n\tif ((sa2 = new0array(knlr*(ik+incont)+knormr*in,DOUBLE)) == SISL_NULL) \n\t   goto err101;\n\tsw1 = sa2 + knlr*ik;\n\tsw2 = sw1 + knlr*incont;\n\tif ((lfirst2 = newarray(2*knlr,INT)) == SISL_NULL) goto err101;\n\tllast2 = lfirst2 + knlr;\n     \n     /* Save the content of sa to be used for estimating the error.  */\n     \n\tmemcopy(sa2, sa+(kn-knlr)*ik, knlr*ik, DOUBLE);\n\t\n\t/* Make copy of lfirst and llast. */\n\t\n\tmemcopy(lfirst2, lfirst+kn-knlr, knlr, INT);\n\tmemcopy(llast2, llast+kn-knlr, knlr, INT);\n     }\n     \n     if (incont > 0)\n     {\n\t\n\t/* Set up as constraints expressing that incont derivatives of\n\t   the curve is to be equal across the seam. */\n\t\n\ts1947(sa, lfirst, llast, ik, kn, etau, in, incont, sw1, \n\t      knlr, &knred, sfac, &kstat);\n\tif (kstat < 0) goto error;\n     }\n     \n     /* Set up the normal equations.  */\n\t\t    \n     if (ileftfix == 0 && irightfix == 0)\n     {\n\t/* If there is no side constraints, the number of unknowns is\n\t   in and the first unknown is no. 1. */\n\t\n\ts1944(etau,ik,in-incont,kdim,pcurve->et,pcurve->ecoef,kn,incont,\n\t      knlr,knormr,sa,sw1,lfirst,llast,sb,sw2,l2sta,scoef,&kstat);\n\tif (kstat < 0) goto error;\n      }\n     else\n     {\n\t/* Make a local copy of the coefficients of the input spline.\n\t   This is necessary since the right-hand-side of the problem\n\t   will be adjusted and the original data should not be altered. */\n\t\n\tif ((sc = newarray(kn*kdim,DOUBLE)) == SISL_NULL) goto err101;\n\tmemcopy(sc,pcurve->ecoef,kn*kdim,DOUBLE);\n     \n\t/* Enforce the side conditions.  */\n\t\n\tsh1927(etau,ik,in,kdim,pcurve,ileftfix,irightfix,scoef,&kstat);\n\tif (kstat < 0) goto error;\n\t\t       \n        /* There are now in-ileftfix-irightfix unknowns left, and the first\n            of them is no. ileftfix+1.  */\n\t\t       \n        if (knh > 0)\n\t{\n\t   /* Adjust the left squares problem.  */\n\t   \n\t   s1946(sa,sw1,lfirst,llast,sc,scoef,ik,in,kn,kdim,ileftfix,\n\t\t  irightfix,knlr,incont,&kstat);\n\t   if (kstat < 0) goto error;\n\t\t\t  \n           /* Set up the normal equations for the modified least\n\t      squares problem.   */\n\t\t\t  \n\t   s1945(etau,ik,in,kdim,pcurve->et,sc,kn,ileftfix,irightfix,\n\t\t incont,knlr,knormr,sa,sw1,knh,lfirst,llast,sb,sw2,scoef,\n\t\t l2sta,&kstat);\n\t   if (kstat < 0) goto error;\n        }\n     }\n     \n     if (knh > 0)\n     {\n\t/* Calculate the Cholesky factorization of the coefficient\n\t   matrix of the normal equations.  */\n\t\n\ts1948(sb,sw2,knh,ik,(knlr==knred)?0:knormr,l2sta,&kstat);\n\tif (kstat < 0) goto error;\n\t\t       \n        /* Solve the normal equations.  */\n\t\t       \n        s1949(sb,sw2,scoef+ileftfix*kdim,knh,ik,(knlr==knred)?0:knormr,\n\t      kdim,l2sta,&kstat);\n\tif (kstat < 0) goto error;\n      }\n     \n     /* Multiply the coefficients by dtau(-1/2) and express the incont \n\tlast coefficients as a weighted sum of the incont first. */\n     \n     s1951(etau, scoef, in, ik, kdim, ileftfix, irightfix, incont, sfac);\n\n     /* Express the approximating curve as a curve.  */\n     \n     if ((*rnewcurve = newCurve(in,ik,etau,scoef,kkind,kdim,kcopy)) == SISL_NULL)\n\tgoto err101;\n     (*rnewcurve)->cuopen = pcurve->cuopen;\n     \n     /* Restore information of sa, lfirst and llast. */\n     \n     if (knlr > 0)\n     {\n\tmemcopy(sa+(kn-knlr)*ik, sa2, knlr*ik, DOUBLE);\n\tmemcopy(lfirst+kn-knlr, lfirst2, knlr, INT);\n\tmemcopy(llast+kn-knlr, llast2, knlr, INT);\n     }\n     \n     /* Estimate error.  */\n     \n     s1942(pcurve,*rnewcurve,kdim,sa,lfirst,llast,gmaxerr,gl2err,&kstat);\n     if (kstat < 0) goto error;\n  }\n  \n  /* Approximation performed.  */\n\n  *jstat = 0;\n  goto out;\n  \n  /* Error in scratch allocation.  */\n\n  err101 :\n    *jstat = -101;\n  goto out;\n  \n  /* Error in input. Order of input and output curve in conflict.  */\n\n  err109 :\n    *jstat = -109;\n  goto out;\n  \n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n  goto out;\n  \n  out :\n\n    /* Free scratch occupied by local arrays.  */\n\n    if (scoef != SISL_NULL) freearray(scoef);\n    if (sc != SISL_NULL) freearray(sc);\n    if (sa != SISL_NULL) freearray(sa);\n    if (sa2 != SISL_NULL) freearray(sa2);\n    if (lfirst != SISL_NULL) freearray(lfirst);\n    if (lfirst2 != SISL_NULL) freearray(lfirst2);\n  \n    return;\n}\n"
  },
  {
    "path": "src/s1944.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S1944\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1944(double etau[],int ik,int in,int idim,double et[],double ed[],\n\t     int im,int inlc,int inlr,int inorm,double ea[],double ew1[],\n\t     int nfirst[],int nlast[],double eb[],double ew2[],\n\t     int n2sta[],double ec[],int *jstat)\n#else\nvoid s1944(etau,ik,in,idim,et,ed,im,inlc,inlr,inorm,ea,ew1,nfirst,nlast,eb,ew2,\n\t   n2sta,ec,jstat)\n   double etau[];\n   int ik;\n   int in;\n   int idim;\n   double et[];\n   double ed[];\n   int im;\n   int inlc;\n   int inlr;\n   int inorm;\n   double ea[];\n   double ew1[];\n   int nfirst[];\n   int nlast[];\n   double eb[];\n   double ew2[];\n   int n2sta[];\n   double ec[];\n   int *jstat;\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : To set up the normal equations for solving the linear\n*              system ea*x=ed in a weighted least squares sense. The\n*              least squares problem stems from the problem of approximating\n*              the spline with knot vector et and B-spline coefficients \n*              ed from the subspace generated by the knot vector etau\n*              which is a subsequence of et. The aim is to minimize a\n*              weighted 2-norm of the coefficients of the difference between\n*              a spline from the spline space generated by etau and the\n*              given spline in the spline space gernerated by et expressed\n*              in the latter space.\n* \n* INPUT      : etau   - Real array of length (in+ik) containing the  \n*                       knot vector of the approximating space.\n*\t       ik     - The order of the spline space.\n*              in     - The dimension of the spline space corresponding\n*                       to etau.\n*              idim   - The dimension of the geometry space.\n*              et     - Real array of length (im+ik) containing the refined\n*                       knot vector.\n*              ed     - Real array of length (im*idim) containing the B-spline\n*                       coefficients of the spline to be approximated.\n*              im     - The dimension of the spline space corresponding to et.\n*              inlc   - Number of columns of corner element.\n*              inlr   - Number of rows of corner element.\n*              inorm  - Number of rows of corner element of normal equations.\n*              ea     - Real array of dimension (im*ik) containing \n*                       the B-spline refinement matrix from the knot vector\n*                       etau to the knot vector et. This matrix has\n*                       dimension im*in but since at most\n*                       ik entries are nonzero in each row, it can\n*                       be stored in a im*ik array together\n*                       with two integer arrays indicating the position\n*                       of the first and last nonzero elements in each\n*                       row, and a matrix representing corner elements if\n*                       the spline is periodic.\n*              ew1    - Corner element originating from periodicity.\n*                       Size inlr*inlc.\n*              nfirst - Integer array of dimension (im) containing \n*                       pointers to the first nonzero element of each row \n*                       of the B-spline refinement matrix from etau to et.\n*              nlast  - Integer array of dimension (im) containing \n*                       pointers to the last nonzero element of each row \n*                       of the B-spline refinement matrix from etau to et.\n*\n* \n* OUTPUT     : eb     - Real array of dimension (in*ik) containing the \n*                       band part of the coefficient matrix of the normal \n*                       equations. This is really a \n*                       in*in matrix but since each row of ea\n*                       only has at most ik nonzero elements and eb\n*                       essentially is of the form eb = ea(tr)*ea, it is\n*                       easy to see that eb is a band matrix of band with\n*                       at most ik. Since eb also is symmetric it is enough\n*                       to store the elements below and on the diagonal.\n*                       This is done by storing the diagonal element of row\n*                       i in eb(i*ik+ik-1), and then letting d2sta[i] indicat\n*                       the position of the first nonzero element in row i of eb.\n*              ew2    - Corner element of the coefficient matrix of the normal\n*                       equations. Size inlc*in.\n*              n2sta  - Integer array of length (in*idim) containing pointers to\n*                       the first nonzero elements of the in rows of eb.\n*              ec     - Real array of lengh (in*idim) containing the right\n*                       hand side of the normal equations (or really the\n*                       idim right hand sides).\n*              jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*             \n* \n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        :\n*\n*-\n* CALLS      :   \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.92, on the basis of a routine\n*              written by Tom Lyche and Knut Moerken, 12.85.\n* REWRITTEN AND RENAMED BY : Vibeke Skytt, SINTEF Oslo, 01.95. \n*                            Introduced periodicity.\n*\n*********************************************************************\n*/\n{ \n  int ki,kj,kr;\n  int kj2;\n  int ki1,ki2,kr1,kj1;\n  int kik,kih,krh;\n  double tw;\n  double thelp;\n  double *swa = SISL_NULL;\n  \n  /* Allocate space for a local array of length in to be used during\n     multiplication with dtau(-1/2).  */\n  \n  if ((swa = newarray(in,DOUBLE)) == SISL_NULL)goto err101;\n  \n  /* Initiate output arrays to zero.  */\n  \n  for (kj=0; kj<in; kj++) n2sta[kj] = -1;\n  memzero(ec,in*idim,DOUBLE);\n  memzero(eb,in*ik,DOUBLE);\n  if (inorm > 0)\n     memzero(ew2,in*inorm,DOUBLE);\n  \n  /* Determine the normal equations.\n     Compute ea(tr)*dt*ea and ea(tr)*dt*ed and store in eb and ec\n     respectively. First perform multipliciation involving only the\n     band part of the coefficient matrix. */\n  \n  for (kj=0; kj<im; kj++)\n  {\n     ki1 = nfirst[kj];\n     ki2 = nlast[kj];\n     kr1 = ik - ki2 + ki1 - 1;\n     tw = (et[kj+ik] - et[kj])/(double)ik;\n     kik = ik - 1;\n     for (kr = kr1; kr<ik; ki1++, kik--, kr++)\n     {\n\tif (n2sta[ki1] == -1) n2sta[ki1] = kik;\n\tkih = ik - ki2 + ki1 - 1;\n\tkrh = ik - 1;\n\tthelp = tw*ea[kj*ik+kr];\n\tfor (ki=ki1; ki<=ki2; kih++, krh--, ki++)\n\t   eb[ki*ik+krh] += ea[kj*ik+kih]*thelp;\n\tkih = kr - ik + ki2 + 1;\n\tfor (ki=0; ki<idim; ki++)\n\t   ec[kih*idim+ki] += ed[kj*idim+ki]*thelp;\n     }\n  }\n  \n  /* Permform multipliciations involving the corner elements. */\n  \n  for (kj=im-inlr, kj2=0; kj<im; kj++, kj2++)\n  {\n     ki1 = nfirst[kj];\n     ki2 = nlast[kj];\n     tw = (et[kj+ik] - et[kj])/(double)ik; \n     for (kr=0; kr<inlc; kr++)\n     {\n\tkih = ik - ki2 + ki1 - 1;\n\tkrh = ik-1;\n\tthelp = tw*ew1[kj2*inlc+kr];\n\tfor (ki=kr; ki<inlc; ki++, krh--)\n\t{\n\t   eb[ki*ik+krh] += ew1[kj2*inlc+ki]*thelp;\n\t   if (krh < n2sta[ki]) n2sta[ki] = krh;\n\t}\n\tfor (ki=0; ki<idim; ki++)\n\t   ec[kr*idim+ki] += ed[kj*idim+ki]*thelp;\n\tfor (ki=ki1; ki<=ki2; kih++, krh--, ki++)\n\t   ew2[(ki-in+inorm)*in+kr] += ea[kj*ik+kih]*thelp;\n     }\n  }\n  \n  /* Multiply eb, ew2 and ec by dtau(-1/2).  */\n  \n  for (ki=0; ki<in; ki++)\n    swa[ki] = sqrt((double)ik/(etau[ki+ik]-etau[ki]));\n  for (ki=0; ki<in; ki++)\n    {\n       thelp = swa[ki];\n       for (kj=0; kj<idim; kj++)\n\t ec[ki*idim+kj] *= thelp;\n       for (kj1=n2sta[ki], kih=kj1-ik+ki+1, kj=kj1;\n\tkj<ik; kih++, kj++)\n\t eb[ki*ik+kj] *= swa[kih]*thelp;\n    }\n  for (ki=0; ki<inorm; ki++)\n     for (kj=0; kj<inlc; kj++)\n\tew2[ki*in+kj] *= swa[in-inorm+ki]*swa[kj]; \n  \n  /* Copy the last inlc rows of the band part of the matrix into ew2. */\n  \n  for (ki2=0, ki=in-inorm; ki<in; ki2++, ki++)\n  {\n     for (kj=n2sta[ki]; kj<ik; kj++)\n\tew2[ki2*in+ki-ik+kj+1] += eb[ki*ik+kj];\n  }\n\n  /* Normal equations set.  */\n  \n   *jstat = 0;\n   goto out;\n   \n   /* Error in space allocation.  */\n   \n   err101: *jstat = -101;\n   goto out;\n   \n   out:\n      /* Free scratch used for local array.  */\n      \n      if (swa != SISL_NULL) freearray(swa);\n\t  \n      return;\n}\n   \n"
  },
  {
    "path": "src/s1945.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1945\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1945(double etau[],int ik,int in,int idim,double et[],\n\t     double ed[],int im,int ilend,int irend, int inlc,\n\t     int inlr, int inorm, double ea[], double ew1[], int inh,\n\t     int nfirst[],int nlast[],double eb[], \n\t     double ew2[], double ec[],int n2sta[],int *jstat)\n#else\nvoid s1945(etau,ik,in,idim,et,ed,im,ilend,irend,inlc,inlr,inorm,ea,ew1,inh,\n\t   nfirst,nlast,eb,ew2,ec,n2sta,jstat)\n   double etau[];\n   int ik;\n   int in;\n   int idim;\n   double et[];\n   double ed[];\n   int im;\n   int ilend;\n   int irend;\n   int inlc;\n   int inlr;\n   int inorm;\n   double ea[];\n   double ew1[];\n   int inh;\n   int nfirst[];\n   int nlast[];\n   double eb[];\n   double ew2[];\n   double ec[];\n   int n2sta[];\n   int *jstat;\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : To set up the normal equations for solving the linear\n*              system ea*x=ed in a weighted least squares sense. The\n*              least squares problem stems from the problem of approximating\n*              the spline with knot vector et and B-spline coefficients \n*              ed from the subspace generated by the knot vector etau\n*              which is a subsequence of et. The aim is to minimize a\n*              weighted 2-norm of the coefficients of the difference between\n*              a spline from the spline space generated by etau and the\n*              given spline in the spline space gernerated by et expressed\n*              in the latter space.\n*              However, there are side constraints which means that the first\n*              ilend and the last irend unknowns have already been computed\n*              and the right-hand-side adjusted correspondingly so columns\n*              0,...,ilend-1 and in-irend,...,in-1 of ea are to be ignored.\n* \n* INPUT      : etau   - Real array of length (in+ik) containing the  \n*                       knot vector of the approximating space.\n*\t       ik     - The order of the spline space.\n*              in     - The dimension of the spline space corresponding\n*                       to etau.\n*              idim   - The dimension of the geometry space.\n*              et     - Real array of length (im+ik) containing the refined\n*                       knot vector.\n*              ed     - Real array of length (im*idim) containing the B-spline\n*                       coefficients of the spline to be approximated.\n*              im     - The dimension of the spline space corresponding to et.\n*              ilend  - The number of derivatives that are to be kept fixed\n*                       at the left end of the spline.\n*              irend  - The number of derivatives that are to be kept fixed\n*                       at the right end of the spline.\n*              inlc   - Number of columns in corner element.\n*              inlr   - Number of rows in corner element.\n*              inorm  - Number of rows in corner element of normal equations.\n*              ea     - Real array of dimension (im*ik) containing \n*                       the B-spline refinement matrix from the knot vector\n*                       etau to the knot vector et. This matrix has\n*                       dimension im*in but since at most\n*                       ik entries are nonzero in each row, it can\n*                       be stored in a im*ik array together\n*                       with two integer arrays indicating the position\n*                       of the first and last nonzero elements in each\n*                       row, and a corner matrix.\n*              ew1    - Array storing corner elements originating from\n*                       periodicity. Length (inlr*inlc).\n*              inh    - The dimension of the system of normal equations\n*                       (inh=in-ilend-irend+1).\n*              nfirst - Integer array of dimension (im) containing \n*                       pointers to the first nonzero element of each row \n*                       of the B-spline refinement matrix from etau to et.\n*              nlast  - Integer array of dimension (im) containing \n*                       pointers to the last nonzero element of each row \n*                       of the B-spline refinement matrix from etau to et.\n*\n* \n* OUTPUT     : eb     - Real array of dimension (inh*ik) containing the \n*                       coefficient matrix of the normal equations. This\n*                       is really a in*in matrix but since each row of ea\n*                       only has at most ik nonzero elements and eb\n*                       essentially is of the form eb = ea(tr)*ea, it is\n*                       easy to see that eb is a band matrix of band with\n*                       at most ik. Since eb also is symmetric it is enough\n*                       to store the elements below and on the diagonal.\n*                       This is done by storing the diagonal element of row\n*                       i in eb(i*ik+ik-1), and then letting d2sta[i] indicate\n*                       the position of the first nonzero element in row i \n*                       of eb.\n*              ew2    - Corner element after computing the normal equations.\n*                       Length inlc*inh.\n*              ec     - Real array of lengh (in*idim) containing the right\n*                       hand side of the normal equations (or really the\n*                       idim right hand sides).\n*              n2sta  - Integer array of length (in*idim) containing pointers\n*                       to the first nonzero elements of the in rows of eb.\n*              jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*             \n* \n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        :\n*\n*-\n* CALLS      :   \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.92, on the basis of a routine\n*              written by Tom Lyche and Knut Moerken, 12.85.\n*\n*********************************************************************\n*/\n{ \n  int ki,kj,kr;\n  int ki1,ki2,kr1,kj1,kj2;\n  int kik,kih,krh,kihh,krhh;\n  double tw;\n  double thelp;\n  double *swa = SISL_NULL;\n  \n  /* Allocate space for a local array of length in to be used during\n     multiplication with dtau(-1/2).  */\n  \n  if ((swa = newarray(in,DOUBLE)) == SISL_NULL)goto err101;\n  \n  /* Initiate output arrays to zero.  */\n  \n  for (kj=0; kj<inh; kj++) n2sta[kj] = -1;\n  memzero(ec+ilend*idim,inh*idim,DOUBLE);\n  memzero(eb,inh*ik,DOUBLE);\n  if (inorm > 0)\n     memzero(ew2,inh*inorm,DOUBLE);\n  \n  /* Determine the normal equations.\n     Compute ea(tr)*dt*ea and ea(tr)*dt*ed and store in eb and ec\n     respectively. First perform multiplications involving only the\n     band part of the matrix. */\n  \n  for (kj=0; kj<im; kj++)\n    {\n       ki1 = MAX(nfirst[kj],ilend);\n       ki2 = MIN(nlast[kj],in-irend-1);\n       kr1 = ik - ki2 + ki1 - 1;\n       tw = (et[kj+ik] - et[kj])/(double)ik;\n       kik = ik - 1;\n       krhh = ik - nlast[kj] + ki1 - 1;\n       for (kr = kr1; kr<ik; ki1++, kik--, krhh++, kr++)\n\t {\n\t    kihh = ki1 - ilend;\n\t    if (n2sta[kihh] == -1) n2sta[kihh] = kik;\n\t    kih = ik - nlast[kj] + ki1 - 1;\n\t    krh = ik - 1;\n\t    thelp = tw*ea[kj*ik+krhh];\n\t    for (ki=ki1; ki<=ki2; kih++, kihh++, krh--, ki++)\n\t      eb[kihh*ik+krh] += ea[kj*ik+kih]*thelp;\n\t    kih = kr - ik + ki2 + 1;\n\t    for (ki=0; ki<idim; ki++)\n\t      ec[kih*idim+ki] += ed[kj*idim+ki]*thelp;\n\t }\n    }\n  \n  /* Perform multiplications involving the corner element. */\n  \n  for (kj=im-inlr, kj2=0; kj<im; kj++, kj2++)\n  {\n     ki1 = MAX(nfirst[kj],ilend);\n     ki2 = MIN(nlast[kj],in-irend-1);\n     tw = (et[kj+ik] - et[kj])/(double)ik; \n     for (kr=ilend; kr<inlc; kr++)\n     {\n\tkih = ik - ki2 + ki1 - 1;\n\tkrh = ik-1;\n\tthelp = tw*ew1[kj2*inlc+kr];\n\tfor (ki=kr; ki<inlc; ki++, krh--)\n\t{\n\t   eb[(ki-ilend)*ik+krh] += ew1[kj2*inlc+ki]*thelp;\n\t   if (krh < n2sta[ki-ilend]) n2sta[ki-ilend] = krh;\n\t}\n\tfor (ki=0; ki<idim; ki++)\n\t   ec[kr*idim+ki] += ed[kj*idim+ki]*thelp;\n\tfor (ki=ki1; ki<=ki2; kih++, krh--, ki++)\n\t   ew2[(ki-ilend-inh+inorm)*inh+kr-ilend] += ea[kj*ik+kih]*thelp;\n     }\n  }\n  \n  /* Multiply eb, ew2 and ec by dtau(-1/2), but remember to skip the first \n     ilen and last irend elements of ec and dtau. */\n  \n  for (kihh=ilend, ki=0; ki<inh; kihh++, ki++)\n       swa[ki] = sqrt((double)ik/(etau[kihh+ik]-etau[kihh]));\n\n  for (kihh=ilend, ki=0; ki<inh; kihh++, kih++, ki++)\n    {\n       thelp = swa[ki];\n       for (kj=0; kj<idim; kj++)\n\t ec[kihh*idim+kj] *= thelp;\n       for (kj1=n2sta[ki], kih=kj1-ik+ki+1, kj=kj1;\n\tkj<ik; kih++, kj++)\n\t eb[ki*ik+kj] *= swa[kih]*thelp;\n    }\n  for (ki=0; ki<inorm; ki++)\n     for (kj=ilend; kj<inlc; kj++)\n\tew2[ki*inh+kj-ilend] *= \n\t   swa[inh-inorm+ki]*swa[kj-ilend]; \n   \n\n  /* Copy the last inlc rows of the band part of the matrix into ew2. */\n  \n  for (ki2=0, ki=inh-inorm; ki<inh; ki2++, ki++)\n  {\n     for (kj=n2sta[ki]; kj<ik; kj++)\n\tew2[ki2*inh+ki-ik+kj+1] += eb[ki*ik+kj];\n  }\n  \n  /* Normal equations set.  */\n  \n   *jstat = 0;\n   goto out;\n   \n   /* Error in space allocation.  */\n   \n   err101: *jstat = -101;\n   goto out;\n   \n   out:\n      /* Free scratch used for local array.  */\n      \n      if (swa != SISL_NULL) freearray(swa);\n\t  \n      return;\n}\n   \n"
  },
  {
    "path": "src/s1946.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S1946\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1946(double ea[],double ew1[],int nfirst[],int nlast[],double ed[],\n\t double ec[],int ik,int in,int im,int idim,int ilend,int irend,\n\t int inlr, int inlc,int *jstat)\n#else\nvoid s1946(ea,ew1,nfirst,nlast,ed,ec,ik,in,im,idim,ilend,irend,inlr,inlc,jstat)\n   double ea[];\n   double ew1[];\n   int nfirst[];\n   int nlast[];\n   double ed[];\n   double ec[];\n   int ik;\n   int in;\n   int im;\n   int idim;\n   int ilend;\n   int irend;\n   int inlr;\n   int inlc;\n   int *jstat;\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : To modify a least squares problem to take into account \n*              equality constraints at the beginning and end of the vector\n*              of unknowns.\n* \n* INPUT      : ea     - Real array of dimension (im*ik) containing \n*                       the band part of the coefficient matrix of the \n*                       problem. This matrix has\n*                       dimension im*in but since at most\n*                       ik entries are nonzero in each row, it can\n*                       be stored in a im*ik array together\n*                       with two integer arrays indicating the position\n*                       of the first and last nonzero elements in each\n*                       row. In addition it is known that the last nonzero\n*                       element of row ki is stored in ea[ki*ik+ik-1].\n*              ew1    - Corner element of the coefficient matrix originating\n*                       from periodicity. The size of ew1 is inlc*inlr.\n*              nfirst - Integer array of dimension (im) containing \n*                       pointers to the first nonzero element of each row \n*                       of the original matrix.\n*              nlast  - Integer array of dimension (im) containing \n*                       pointers to the last nonzero element of each row \n*                       of the original matrix.\n*              ed     - Real array of dimension (in*idim) containing the \n*                       'right hand side' of the least squares problem.\n*              ec     - Real array of dimension (in*idim) which is to contain\n*                       the solution of the least squares problem. Upon entry\n*                       of this routine ec[0],...ec[ilend] and \n*                       ec[in-irend],...,ec[in-1] (assuming idim=1) contain\n*                       the values wich are forced by the constraints\n*                       (the first ilend derivatives are to be kept fixed\n*                       at the beginning of the curve, and the last irend at\n*                       the end of the curve).\n*\t       ik     - The order of the spline space in the underlying least\n*                       squares problem.\n*              in     - The number of unknowns in the original least squares\n*                       problem. This is reduced by (ilend+irend) due to the\n*                       constraints.\n*              im     - The number of constraints in the least squares problem\n*                       excluding the (ilend+irend) side constraints.\n*              idim   - The dimension of the geometry space.\n*              ilend  - The number of coefficients at the beginning of ec\n*                       which have a value.\n*              irend  - The number of coefficients at the end of ec\n*                       which have a value.\n*              inlr   - Number of rows of ew1.\n*              inlc   - Number of columns of ew1.\n*              \n*\n* \n* OUTPUT     : ed     - Real array of dimension (im*idim) containing the new\n*                       'right hand side' of the problem, which takes into\n*                       consideration the side constraints.\n*              jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*             \n* \n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        :\n*\n*-\n* CALLS      :   \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.92, on the basis of a routine\n*              written by Tom Lyche and Knut Moerken, 12.85.\n* CHANGED AND RENAMED BY : Vibeke Skytt, SINTEF Oslo, 12.94.\n*\n*********************************************************************\n*/\n{ \n   int ki,kj,kr;\n   int kjst;\n   int knk1;\n   double th;\n   double *shelp = SISL_NULL;\n\n   /* Check input.  */\n   \n   if (ilend + irend >= in) goto err203;\n\n   /* Allocate scratch for help array and set to zero. */\n\t\t\t    \n   if ((shelp = new0array(idim,DOUBLE)) == SISL_NULL) goto err101;\n   \n   /* Make adjustments for the fact that ec[0],...,ec[ilend-1] are known\n      This is done by going through the rows of the coefficient matrix until\n      the first nonzero element is in column ilend or further to the right.\n      Make sure also to make adjustments of an evantual corner element. */\n   \n   for (ki=0; ; ki++)\n     {\n\t/* The maximum column is im-1.  */\n\t\n\tif (ki >= im) break;\n\t\n\t/* Check if the first nonzero element is far to the right. */\n\t\n\tif (nfirst[ki] >= ilend && inlc == 0) break;\n\tif (nfirst[ki] >= ilend && ki < im - inlr) continue;\n\t\n\t/* kjst points to the last column among the first ilend that has \n\t   a nonzero element in row ki.     */\n\t\n\tkjst = MIN(ilend-1,nlast[ki]);\n\t\n\t/* Compute the necessary adjustment for row no. ki by multiplying\n\t   together the appropriate elements for ec and ea and\n\t   accumulate.  */\n\t\n\tfor (kj=nfirst[ki]; kj<=kjst; kj++)\n\t  {\n\t     th = ea[ki*ik+ik-nlast[ki]+kj-1];\n\t     for (kr=0; kr<idim; kr++)\n\t       shelp[kr] += th*ec[kj*idim+kr];\n\t  }\n\t\n\t/* Make necessary adjustment from corner element. */\n\t\n\tif (inlc > 0 && ki >= im-inlr)\n\t{\n\t   for (kj=0; kj<MIN(ilend,inlc); kj++)\n\t   {\n\t      th = ew1[(ki-im+inlr)*inlc+kj];\n\t      for (kr=0; kr<idim; kr++)\n\t\t shelp[kr] += th*ec[kj*idim+kr];\n\t   }\n\t}\n\t\n\t/* Adjust ed[ki].  */\n\t\n\tfor (kr=0; kr<idim; kr++)\n\t  {\n\t     ed[ki*idim+kr] -= shelp[kr];\n\t     shelp[kr] = (double)0.0;\n\t  }\n     }\n   \n   /* Make adjustments for the fact that ec[in-irend],...,ec[in-1] are known.\n      This is done by going through the rows of the coefficient matrix from\n      the right until the last nonzero element is in column in-irend-1 or\n      further to the left.  */\n   \n   for (knk1=in-irend, ki=im-1; ; ki--)\n     {\n\t/* In any case we can stop when we get passed column 0.  */\n\t\n\tif (ki < 0) break;\n\t\n\t/* Check if the last nonzero element is sufficiently far to the\n\t   right. */\n\t\n\tif (nlast[ki] < knk1) break;\n\t\n\t/* kjst points to the first element in this row that is of\n\t   interest. */\n\t\n\tkjst = MAX(knk1,nfirst[ki]);\n\t\n\t/* Multiply together the appropriate elements for ea and ec and\n\t   accumulate.  */\n\t\n\tfor (kj=kjst; kj<=nlast[ki]; kj++)\n\t  {\n\t     th = ea[ki*ik+ik-nlast[ki]+kj-1];\n\t     for (kr=0; kr<idim; kr++)\n\t       shelp[kr] += th*ec[kj*idim+kr];\n\t  }\n\t\n\t/* Adjust ed[ki].  */\n\t\n\tfor (kr=0; kr<idim; kr++)\n\t  {\n\t     ed[ki*idim+kr] -= shelp[kr];\n\t     shelp[kr] = (double)0.0;\n\t  }\n     }\n   \n   /* Modification performed.  */\n\t      \n   *jstat = 0;\n   goto out;\n   \n   /* Error in space allocation.  */\n   \n   err101: *jstat = -101;\n   goto out;\n   \n   /* Error in input.  */\n   \n   err203: *jstat = -203;\n   goto out;\n   \n   out:\n      /* Free scratch used for local array.  */\n      \n      if (shelp != SISL_NULL) freearray(shelp);\n\t  \n      return;\n}\n   \n"
  },
  {
    "path": "src/s1947.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S1947\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1947(double ea[], int nfirst[], int nlast[], int ik, int im, \n\t double etau[], int in, int incont, double ew[], int inlr, \n\t int *jnred, double efac[], int *jstat)\n#else\n   void s1947(ea, nfirst, nlast, ik, im, etau, in, incont, ew, inlr, \n\t      jnred, efac, jstat)\n      double ea[];\n      int    nfirst[];\n      int    nlast[];\n      int    ik;\n      int    im;\n      double etau[];\n      int    in;\n      int    incont;\n      double ew[];\n      int    inlr;\n      int    *jnred;\n      double efac[];\n      int    *jstat;\n#endif\n/*\n*********************************************************************\n* \n* PURPOSE    : To adjust a least squares problem originating from \n*              approximating a spline curve from a subspace of the\n*              original spline space, in order to satisfy given\n*              continuity constraints at the start- and endpoint of\n*              the spline. \n* \n* INPUT      : ea     - Real array of dimension (im*ik) containing \n*                       the band part of the coefficient matrix of the \n*                       problem. This matrix has\n*                       dimension im*in but since at most\n*                       ik entries are nonzero in each row, it can\n*                       be stored in a im*ik array together\n*                       with two integer arrays indicating the position\n*                       of the first and last nonzero elements in each\n*                       row. In addition it is known that the last nonzero\n*                       element of row ki is stored in ea[ki*ik+ik-1].\n*              nfirst - Integer array of dimension (im) containing \n*                       pointers to the first nonzero element of each row \n*                       of the original matrix.\n*              nlast  - Integer array of dimension (im) containing \n*                       pointers to the last nonzero element of each row \n*                       of the original matrix.\n*\t       ik     - The order of the spline space in the underlying least\n*                       squares problem.\n*              im     - The dimension of the original spline space.\n*              etau   - The knot vector of the reduced spline space..\n*              in     - The number of unknowns in the original least squares\n*                       problem, i.e. the dimension of the reduced spline space.\n*              incont - Number of continuity constraints. Number of columns\n*                       of ew.\n*              inlr   - Number of rows of ew.\n*              \n*\n* \n* OUTPUT     : ew     - Corner element of the coefficient matrix originating\n*                       from periodicity. The size of ew1 is incont*inlr.\n*              jnred  - Number of lines removed from the band part of the \n*                       equation system due to removal of the latest \n*                       coefficients because of continuity across the seem.\n*              efac   - Factors used to express the incont last coefficients\n*                       by the incont first.\n*              jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*             \n* \n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        : The knot vectors of the current spline space has to have\n*              ik-multiple knots at the start- and endpoint.\n*\n*-\n* CALLS      :   \n*\n* WRITTEN BY : Vibeke Skytt, SINTEF Oslo, 01.95.\n*\n*********************************************************************\n*/\n{\n   int ki, kj, kr, kih;       /* Counters.       */\n   int khindx;                /* Help in index computing. */\n   double tdiv, th;           /* Help variables. */\n   double *sr1 = SISL_NULL;   /* Help array used to store factors in equality\n\t\t\t        constraints at the start of the spline curve.  */\n   double *sr2 = SISL_NULL;   /* To store factors at the end of the curve.     */\n   double *stw1 = SISL_NULL;  /* Knot intervals at the start of the curve.     */\n   double *stw2 = SISL_NULL;  /* Knot intervals at the end of the curve.       */\n   double *shelp = SISL_NULL; /* Help array to avoid overwriting.              */\n      \n   /* Test input. */\n   \n   if (DEQUAL(etau[ik-1], etau[ik]) || DEQUAL(etau[in-1], etau[in])) \n      goto err112;\n   \n   /* Allocate scratch for local arrays. */\n   \n   if ((sr1 = new0array(2*incont*incont+3*incont, DOUBLE)) == SISL_NULL) \n      goto err101;\n   sr2 = sr1 + incont*incont;\n   stw1 = sr2 + incont*incont;\n   stw2 = stw1 + incont;\n   shelp = stw2 + incont;\n   \n   /* Set up equality constraints for coefficients at the ends of the curve. */\n     \n   /* Store first and last knot interval. */\n   \n   stw1[0] = etau[ik] - etau[ik-1];\n   stw2[0] = etau[in] - etau[in-1];\n      \n   /* Compute factors in the constraint equations. */\n   \n   sr1[0] = sr2[0] = (double)1;\n   for (ki=1; ki<incont; ki++)\n   {\n      stw1[ki] = etau[ik+ki] - etau[ik-1];\n      stw2[ki] = etau[in] - etau[in-ki-1];\n      \n      sr1[ki*incont] = -sr1[(ki-1)*incont]/stw1[0];\n      sr2[ki*incont] = sr2[(ki-1)*incont]/stw2[0];\n      for (kj=1; kj<=ki; kj++)\n      {\n\t sr1[ki*incont+kj] = sr1[(ki-1)*incont+kj-1]/stw1[kj-1] -\n\t    sr1[(ki-1)*incont+kj]/stw1[kj];\n\t sr2[ki*incont+kj] = -sr2[(ki-1)*incont+kj-1]/stw2[kj-1] +\n\t    sr2[(ki-1)*incont+kj]/stw2[kj];\n      }\n   }\n\n   /* Express the incont coefficients at the end of the spline by a combination\n      of the coefficients at the start, starting with the last coefficient. \n      The result is stored in sr2. */\n   \n   for (ki=1; ki<incont; ki++)\n   {\n      tdiv = sr2[ki*incont+ki];\n      for (kj=ki; kj>=0; kj--)\n      {\n\t th = sr1[ki*incont+kj];\n\t for (kr = ki-1; kr>= kj; kr--)\n\t    th -= sr2[ki*incont+kr]*sr2[kr*incont+kj];\n\t shelp[kj] = th/tdiv;\n      }\n      memcopy(sr2+ki*incont, shelp, ki+1, DOUBLE);\n   }\n   \n   /* Use the fact that the incont last coefficients may be expressed as\n      a known combination of the first incont coefficients to reduce the\n      number of unknown in the equation system. */\n   \n   for (kj=im-1; kj>=0; kj--)\n   {\n      if (nlast[kj] < in-incont) break;  /* All continuity requirement treated. */\n      \n      for (kih=0, ki=0; ki<incont; ki++)\n      {\n\t if (nlast[kj] < in-ki-1) continue;  /* No contribution. */\n\t \n\t for (kr=0; kr<=ki; kr++)\n\t    ew[(kj-im+inlr)*incont+kr] += sr2[ki*incont+kr]*\n\t       ea[(kj+1)*ik-kih-1];\n\t    \n\t kih++;\n      }\n\t \n      \n      /* Justify size of equation system. */\n      \n      if (nlast[kj] >= in-incont) \n      {\n\t khindx = nlast[kj] - in + incont + 1;\n\t \n\t /* Move line of equation system to the left in order to have \n\t    the last non-zero element at position kj*ik+ik-1 in ea. */\n\t \n\t for (ki=ik-1; ki>=ik-in+incont+nfirst[kj]; ki--)\n\t    ea[kj*ik+ki] = ea[kj*ik+ki-khindx];\n\t for (; ki>=0; ki--)\n\t    ea[kj*ik+ki] = DZERO;\n      }\n      nlast[kj] = in-incont-1;\n      if (nlast[kj] < nfirst[kj]) (*jnred)++;\n      \n      /* Test if the band part of the matrix and the corner element \n\t interfere, and in that case move elements from the band part\n\t of the matrix to the corner element.                         */\n      \n      if (nfirst[kj] < incont)\n      {\n\t for (ki=nfirst[kj]; ki<incont; ki++)\n\t    ew[(kj-im+inlr)*incont+ki] += ea[kj*ik+ik-1-nlast[ki]+nfirst[ki]];\n\t nfirst[kj] = incont;\n      }\n   }\n   \n   /* Equation system adusted. Copy factors to output array. */\n   \n   memcopy(efac, sr2, incont*incont, DOUBLE);\n   *jstat = 0;\n   goto out;\n   \n   /* Error in scratch allocation. */\n   \n   err101 : *jstat = -101;\n   s6err(\"s1947\", *jstat, 0);\n   goto out;\n\n   /* Error in knot vector. */\n   \n   err112 : *jstat = -112;\n   s6err(\"s1947\", *jstat, 0);\n   goto out;\n   \n   out:\n      /* Free scratch occupied by local arrays. */\n      \n      if (sr1 != SISL_NULL) freearray(sr1);\n      \n      return;\n}\n"
  },
  {
    "path": "src/s1948.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S1948\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1948(double *ea,double *ew,int in,int ik,int inlr, \n\t int *nstart,int *jstat)\n#else\nvoid s1948(ea,ew,in,ik,inlr,nstart,jstat)\n   double *ea;\n   double *ew;\n   int in;\n   int ik;\n   int inlr;\n   int *nstart;\n   int *jstat;\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : To calculate the Cholesky factorization (A=L*L(tr)) of\n*              a (symmetric positive definite) in*in matrix with a band of\n*              maximum of 2*ik-1 nonzero elements in each row. In addition\n*              it might be a corner element of size inlr*inlr. Because \n*              of the  symmetry it is sufficient to store the nonzero\n*              elements to the left of and including the diagonal, i.e.\n*              at most ik nonzero elements, and the lower inlr rows. \n*              Hence, the input matrix is given by the three arrays\n*              ea, ew and nstart of dimension (in*ik), (inlr*in)\n*              and in, respectively, with nstart indicating the position\n*              of the first nonzero elements of each row of ea. If the\n*              factorization is successfull, it is given as output in ea\n*              ew, and nstart using the same representation as the input.\n* \n* \n* INPUT      : ea     - Real array of dimension (in*ik) containing the \n*                       nonzero band elements of the matrix factorized. This\n*                       is possible since it is assumed that the input \n*                       matrix is symmetric with at most 2*ik nonzero\n*                       elements in each row.\n*              ew     - Corner element originating from periodic geometry.\n*                       The size of ew is inlr*in. It is expected \n*                       that the last inlr rows of ea is copied into ew.\n*              in     - The dimension of the input matrix, i.e. the number\n*                       of rows in ea.\n*              ik     - The maximum number of different nonzero elements\n*                       in each row of the input matrix and therefore the\n*                       number of columns of ea.\n*              inlr   - The number of rows of the corner element\n*              nstart - Integer array of dimension (in) containing pointers\n*                       to the first nonzero element of each row of ea.\n*              \n*\n* \n* OUTPUT     : ea     - Real array of dimension (in*ik) containing the\n*                       nonzero elements of the Cholesky factorization.\n*                       This is possible because of the special structure \n*                       of the input matrix and the fact that Cholesky\n*                       factorization preserves this structure.\n*              ew    -  The corner element and the last inlr rows of ea\n*                       after the factorization. Due to fill in all inlr*in\n*                       elements are expected to be non-zero.\n*              jstat  - status messages \n*                          > 0 : warning \n*                          = 0 : ok \n*                          < 0 : error \n*             \n* \n* METHOD     : The Cholesky factorization is computed in the form\n*              A = L*L(tr). (L(tr) denotes the transpose of L) one\n*              row at a time.\n*\n*\n* REFERENCES : Any book on general numerical analysis or numerical\n*              linear algebra.\n*              \n*\n* USE        :\n*\n*-\n* CALLS      :   \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.92, on the basis of a routine\n*              written by Tom Lyche and Knut Moerken, 12.85.\n* REWRITTEN AND RENAMED BY : Vibeke Skytt, SINTEF Oslo, 12.94. Introduced\n*                            a corner element originating from periodicity.\n*\n*********************************************************************\n*/\n{\n   int ki,kj,kr;           /* Counters.              */\n   int kjs,kjh,krhs,krh;   /* Pointers into ea matrix.  */\n   int ki2, ki3;           /* Pointers into ew.      */\n   int kik1 = ik-1;        /* Order minus one.       */\n   double tsum;            /* Help variable.         */\n   double thelp;           /* Help variable.         */\n\n   \n   /* Go through the rows of the matrix one by one excluding the rows\n      storing the corner element.  */\n   \n   for (ki=0; ki<in-inlr; ki++)\n     {\n\t/* Calculate the off diagonal elemnts of row no ki of the\n\t   Cholesky factorization. The first nonzero element of this\n\t   row is given by nstart[ki]. The integer kjh gives the\n\t   position of this element in the underlying in*in matrix.  */\n\t\n\tfor (kjs=nstart[ki], kjh=ki+kjs-ik+1, krhs=kik1, kj=kjs;\n\t kj<kik1; kjh++, krhs--, kj++)\n\t  {\n\t     tsum = (double)0.0;\n\t     krh = krhs;\n\t     for (kr=kjs; kr<kj; krh++,kr++)\n\t       tsum += ea[ki*ik+kr]*ea[kjh*ik+krh];\n\t     ea[ki*ik+kj] -= tsum;\n\t     ea[ki*ik+kj] /= ea[kjh*ik+kik1];\n\t  }\n\t\n\t/* Finish off row ki by calculating the diagonal element of the\n\t   Cholesky factorization.   */\n\t\n\ttsum = (double)0.0;\n\tfor (kr=kjs; kr<kik1; kr++)\n\t  {\n\t     thelp = ea[ki*ik+kr];\n\t     tsum += thelp*thelp;\n\t  }\n\t\n\t/* Check if nonpositive ea[ki*ik+ik-1], i.e. singular non positive\n\t   definite matrix.  */\n\t\n\ttsum = ea[ki*ik+kik1] - tsum;\n\tif (tsum <= DZERO) goto err106;\n        ea[ki*ik+kik1] = sqrt(tsum);\n     }\n   \n   for (ki2=0; ki<in; ki++, ki2++)\n     {\n\t/* Calculate the off diagonal elemnts of row no ki of the\n\t   Cholesky factorization. The current rows are stored in ew.\n\t   The first nonzero element of the band part of this\n\t   row (stored in ea) is given by nstart[ki]. The integer kjh gives \n\t   the position of this element in the underlying in*in matrix. \n\t   This loop is entered only if continuity requirements are\n\t   given across the seem.  */\n\t\n\tfor (kjs=nstart[ki], kjh=ki+kjs-ik+1, krhs=kik1, kj=0;\n\t kj<MIN(ki,in-inlr); kjh++, krhs--, kj++)\n\t  {\n\t     tsum = (double)0.0;\n\t     krh = nstart[kj];\n\t     for (kr=kj-kik1+nstart[kj]; kr<kj; krh++,kr++)\n\t       tsum += ew[ki2*in+kr]*ea[kj*ik+krh];\n\t     ew[ki2*in+kj] -= tsum;\n\t     ew[ki2*in+kj] /= ea[kj*ik+kik1];\n\t  }\n\t\n\t/* Compute the factorization of the last inlr elements. */\n\t\n\tfor (ki3=0; kj<ki; kj++, ki3++)\n\t{\n\t     tsum = (double)0.0;\n\t     for (kr=0; kr<kj; kr++)\n\t\ttsum += ew[ki2*in+kr]*ew[ki3*in+kr];\n\t     ew[ki2*in+kj] -= tsum;\n\t     ew[ki2*in+kj] /= ew[ki3*in+kj];\n\t}\n\t\n\t/* Finish off row ki by calculating the diagonal element of the\n\t   Cholesky factorization.   */\n\t\n\ttsum = (double)0.0;\n\tfor (kr=0; kr<ki; kr++)\n\t  {\n\t     thelp = ew[ki2*in+kr];\n\t     tsum += thelp*thelp;\n\t  }\n\t\n\t/* Check if nonpositive ea[ki*ik+ik-1], i.e. singular non positive\n\t   definite matrix.  */\n\t\n\ttsum = ew[ki2*in+ki] - tsum;\n\tif (tsum <= DZERO) goto err106;\n        ew[ki2*in+ki] = sqrt(tsum);\n     }\n   \n   /* Cholesky factorization computed.  */\n   \n   *jstat = 0;\n   goto out;\n   \n   /* Singular matrix.  */\n   \n   err106: *jstat = -106;\n   goto out;\n   \n   out:\n      return;\n}\n   \n"
  },
  {
    "path": "src/s1949.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1949.c,v 1.2 2001-03-19 15:58:57 afr Exp $\n *\n */\n\n#define S1949\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1949(double *ea,double *ew,double *eb,int in,int ik,int inlr,\n\t int idim,int *nstart,int *jstat)\n#else\nvoid s1949(ea,ew,eb,in,ik,inlr,idim,nstart,jstat)\n   double *ea;\n   double *ew;\n   double *eb;\n   int in;\n   int ik;\n   int inlr;\n   int idim;\n   int *nstart;\n   int *jstat;\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : To solve idim linear systems of equations A*X=eb, given\n*              the right-hand-side eb and the Cholesky factorization of\n*              the matrix A (i.e. A is assumed to be symmetric and\n*              positive definite). It is also assumed that A has a band \n*              part of at most 2*ik-1 nonzero elements in each row and a\n*              corner element stored in the inlr*in array ew.\n*              Since the structure is not destroyed by the Cholesky\n*              factorization and the corner element creates a fill in only\n*              in the last inlr rows, it is sufficient to store a maximum \n*              of ik elements for the in-inlr first rows and the full size\n*              of the last inlr rows. See s1948. The right-hand-side eb has\n*              idim components each of length in. The output of the \n*              routine is the solution of the linear system which \n*              overwrites eb.\n* \n* \n* INPUT      : ea     - Real array of dimension (in*ik) containing the \n*                       nonzero elements of the band part of the Cholesky \n*                       factorization.\n*              ew     - The last inlr rows of the Cholesky factorization.\n*              eb     - Real array of dimension (in*idim) containing\n*                       the right-hand-side(s) of the linear systems.\n*              in     - The dimension of the linear systems, i.e. the number\n*                       of rows in ea.\n*              ik     - The maximum number of different nonzero elements\n*                       in each row of the Cholesky factorization and \n*                       therefore the number of columns of ea.\n*              inlr   - The number of rows contained in ew. 0 <= inlr <= ik.\n*              idim   - The number of different right-hand-sides.\n*              nstart - Integer array of dimension (in) containing pointers\n*                       to the first nonzero element of each row of ea.\n*\n* \n* OUTPUT     : eb     - The solution of the idim linear systems.\n*              jstat  - status messages \n*                          > 0 : warning \n*                          = 0 : ok \n*                          < 0 : error \n*             \n* \n* METHOD     : The linear system is solved in the usual way, first a \n*              forward substition and the a back substitution.\n*\n*\n* REFERENCES : Any book on general numerical analysis or numerical\n*              linear algebra.\n*              \n*\n* USE        :\n*\n*-\n* CALLS      :   \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.92, on the basis of a routine\n*              written by Tom Lyche and Knut Moerken, 12.85.\n* REWRITTEN AND RENAMED BY : Vibeke Skytt, SINTEF Oslo, 12.94. Introduced\n*                            an element ew originating from periodicity.\n*\n*********************************************************************\n*/\n{\n   int ki,kj,kr;         /* Counters.    */\n   int ki1,ki2,ki3,kih,kim;  /* Counters.    */\n   int kjs,kjh; /* Pointers into matrix.  */\n   int kik1 = ik-1;      /* Order minus one.       */\n   double thelp;         /* Help variable.         */\n   double *ssum=SISL_NULL;    /* Help array.            */\n\n   /* Allocate scratch for help array.  */\n   \n   if ((ssum = new0array(idim,DOUBLE)) == SISL_NULL) goto err101;\n   \n   /* Forward substitution excluding the lines representning\n      the corner element.  */\n   \n   for (ki=0; ki<in-inlr; ki++)\n     {\n\tki1 = ki - 1;\n\tmemzero(ssum, idim, DOUBLE);\n\t\n\t/* kjs points to the firs nonzero element of row ki of ea, and\n\t   kjh points to the corresponding element in the underlying\n\t   matrix.       */\n\t\n\tfor (kjs=nstart[ki], kjh=ki+kjs-ik+1, kj=kjs;\n\t kj<kik1; kjh++, kj++)\n\t  {\n\t     thelp = ea[ki*ik+kj];\n\t     for (kr=0; kr<idim; kr++)\n\t       ssum[kr] += thelp*eb[kjh*idim+kr];\n\t  }\n\t\n\t/* Check if the linear system is singular.  */\n\t\n\tif (DEQUAL(ea[ki*ik+kik1],DZERO)) goto err106;\n\t\n\tthelp = (double)1.0/ea[ki*ik+kik1];\n\tfor (kr=0; kr<idim; kr++)\n\t  eb[ki*idim+kr] = (eb[ki*idim+kr] - ssum[kr])*thelp;\n     }\n\n   /* Forward substitution of the lines where the corner element is stored.\n      If no continuity requirements are given across the seem, this loop\n      is not entered. */\n   \n   for (ki2=0; ki<in; ki++,ki2++)\n     {\n\tmemzero(ssum, idim, DOUBLE);\n\t\n\t/* kjs points to the firs nonzero element of row ki of ea, and\n\t   kjh points to the corresponding element in the underlying\n\t   matrix.       */\n\t\n\tfor (kj=0; kj<ki; kj++)\n\t  {\n\t     thelp = ew[ki2*in+kj];\n\t     for (kr=0; kr<idim; kr++)\n\t       ssum[kr] += thelp*eb[kj*idim+kr];\n\t  }\n\t\n\t/* Check if the linear system is singular.  */\n\t\n\tif (DEQUAL(ew[ki2*in+ki],DZERO)) goto err106;\n\t\n\tthelp = (double)1.0/ew[ki2*in+ki];\n\tfor (kr=0; kr<idim; kr++)\n\t  eb[ki*idim+kr] = (eb[ki*idim+kr] - ssum[kr])*thelp;\n     }\n   \n   /* Back substitution.  */\n   \n   for (ki=in-1, ki1=in-1, kih=0;\n    kih<in; ki--, kih++)\n     {\n\t/* Compute the index of the last nonzero element in row ki of the\n\t   transpose of the Cholesky factorization. The integer ik-ki1+ki\n\t   gives the position of element no (ki1*ik+ki) in row ki1 of ea.\n\t   ki1 is reduced until the first nonzero element or row ki1 is\n\t   ik-ki1+ki.   */\n\t\n\tfor (;;ki1--)\n\t  if (nstart[ki1] < ik-ki1+ki) break;\n\t\n\tmemzero(ssum, idim, DOUBLE);\n\t\n\t/* Calculate eb[.*ik+kik1].  First treat the last inlr columns. */\n\t\n\tfor (kj=in-1, ki3=inlr-1; kj>MAX(ki, in-inlr-1); kj--, ki3--)\n\t{\n\t  thelp = ew[ki3*in+ki];\n\t  for (kr=0; kr<idim; kr++)\n\t     ssum[kr] += thelp*eb[kj*idim+kr];\n\t}\n\t\n\t/* Treat the band part of the system. */\n\t\n\tfor (kjs=ki+1, kim=ik-kjs+ki-1, kj=kjs;\n\t kj<=MIN(ki1,in-inlr-1); kim--, kj++)\n\t  {\n\t     thelp = ea[kj*ik+kim];\n\t     for (kr=0; kr<idim; kr++)\n\t       ssum[kr] += thelp*eb[kj*idim+kr];\n\t  }\n\t\n\tif (ki >= in-inlr)\n\t   thelp = (double)1/ew[(ki-in+inlr)*in+ki];\n\telse\n\t   thelp = (double)1.0/ea[ki*ik+ik-1];\n\tfor (kr=0; kr<idim; kr++)\n\t  eb[ki*idim+kr] = (eb[ki*idim+kr] - ssum[kr])*thelp;\n     }\n   \n   \n   /* The linear system is solved.  */\n   \n   *jstat = 0;\n   goto out;\n   \n   /* Error in space allocation.  */\n   \n   err101: *jstat = -101;\n   goto out;\n   \n   /* Singular matrix.  */\n   \n   err106: *jstat = -106;\n   goto out;\n   \n   out:\n      /* Free scratch used for local array.  */\n      \n      if (ssum != SISL_NULL) freearray(ssum);\n\t  \n      return;\n}\n   \n"
  },
  {
    "path": "src/s1950.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S1950\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1950(SISLCurve *oldcurve,SISLCurve *rankcurve,rank_info *ranking,\n\t   double eps[],double epsco[],int startfix,int endfix,int *jncont,\n\t   int mini,int maxi,SISLCurve **newcurve,double maxerr[],int *stat)\n#else\nvoid s1950(oldcurve, rankcurve, ranking, eps, epsco,\n\t   startfix, endfix, jncont, mini, maxi, newcurve, maxerr, stat)\n     SISLCurve\t*oldcurve;\n     SISLCurve\t*rankcurve;\n     rank_info\t*ranking;\n     double\teps[];\n     double\tepsco[];\n     int\tstartfix;\n     int\tendfix;\n     int        *jncont;\n     int\tmini;\n     int\tmaxi;\n     SISLCurve\t**newcurve;\n     double\tmaxerr[];\n     int\t*stat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* Purpose: To remove as many knots as possible from oldcurve\n*          without perturbing this spline more than eps, using the ranking\n*          information in rank_info which was obtained from the spline\n*          rankcurve; and compute an approximation to oldcurve on the\n*          knot vector of rankcurve. The knot vector of rankcurve must be\n*          a subsequence of the knot vector of oldcurve and the knots are\n*          always removed from rankcurve so that the final reduced knot\n*          vector will always be a subsequence of both the knot vectors of\n*          oldcurve and rankcurve. The final approximation is given in\n*\t   newcurve.\n*\n*\n*\n*\n* Input:\n*          oldcurve    - pointer to the original spline from which the knots\n*\t\t\t are to be removed.\n*\n*          rankcurve   - pointer to the curve that the ranking information\n*                        is based on. It is assumed the knot vector of\n*                        rankcurve is a subsequence of the knot vector of\n*\t\t\t oldcurve.\n*\n*\t   ranking     - a pointer to a rank_info object containing the\n*                        result of the ranking computations. The struct\n*                        rank_info contains four variables listed below\n*                        (t, k, and n refer to the knot vector of rankcurve,\n*                        its polynomial order and the number of B-spline\n*                        coefficients):\n*        ranking->prio - integer array of dimension (n-k) containing the\n*                        ranking of the interior knots. The knots are listed\n*                        in order of increasing ranking number, cf. the\n*                        second reference, with knots with the same ranking\n*                        number listed in the order in which they occur\n*                        in t. To differentiate between the different\n*                        ranking numbers the array ranking->groups is used.\n*      ranking->groups - integer array of dimension (n-k) used to partition\n*                        ranking->prio into blocks of knots with the same\n*                        ranking number. ranking->groups[0] contains the\n*                        number of knots with the smallest ranking number,\n*                        ranking->groups[1] contains the number of knots with\n*                        the two smallest ranking numbers etc.. Only the first\n*                        ranking->antgr elements of ranking->groups are used.\n*       ranking->antgr - the number of distinct ranking numbers among the\n*                        interior knots of t.\n*      ranking->antrem - an estimate of the number of knots that can be\n*                        removed from curve.\n*\n*          eps         - double array containing the tolerance. The\n*\t\t\t approximation must at each parameter value deviate\n*\t\t\t less than eps from oldcurve (in each component).\n*\n*\t   epsco       - double array of containing a tolerance which\n*                        is used when the number of coefficients in the\n*                        approximating spline becomes very small. More\n*                        specifically, if so many knots are removed that\n*                        the corresponding spline approximation has fewer\n*                        knots than startfix+endfix (the total number of\n*                        constraints), then it is required that the error\n*                        is less than epsco in each component.\n*\n*          startfix    - the number of derivatives to be kept fixed at the\n*\t\t\t left end of the parameter interval.\n*\n*          endfix      - the number of derivatives to be kept fixed at the\n*\t\t\t right end of the parameter interval.\n*\n*          jncont      - Number of continuity requirements across the seem.\n*\n*          mini        - a lower bound on how many knots that can be removed.\n*\n*          maxi        - an upper bound on how many knots that can be removed.\n*\n*\n* Output:\n*          jncont      - Number of continuity requirements across the seem.\n*\n*          newcurve    - pointer to the spline approximation on the reduced\n*\t\t\t knot vector.\n*          maxerr      - double array containing an upper bound for the\n*                        pointwise error in each of the components of the\n*                        spline approximation. The two curves oldcurve and\n*\t\t\t newcurve are compared at the same parameter value,\n*                        i.e., if oldcurve is f and newcurve is g, then\n*\t\t\t               |f(t)-g(t)| <= eps\n*\t\t\t in each of the components.\n*\n*           stat       - status message\n*                           > 0      : warning\n*                           = 0      : ok\n*                           < 0      : error\n*\n*\n* Method:\n*     The routine determines the maximum number of knots that can be removed\n*     by binary search starting by removing ranking->antrem (antrem below)\n*     knots. In other words, it first tries to remove antrem knots from\n*     oldcurve. If this gives an error less than the tolerance, it tries\n*     to remove (antrem+maxi)/2 knots, while if the error is greater than\n*     the tolerance, the routine will try to remove (mini+antrem)/2 of the\n*     knots. This is continued until the number of knots that can be removed\n*     has been determined exactly, together with the corresponding\n*     approximation. The acceptable approximation with the fewest knots is\n*     kept in the variables igtau,igc,ign, and this is\n*     initialized to the spline given by etprio,edprio,imprio.\n*\n*     During each iteration it must be determined which knots to remove,\n*     given the number of knots to remove. The basis for this choice is\n*     the ranking information (below groups and prio denote the arrays\n*     ranking->groups and ranking->prio and t and k denote the knot vector\n*     and order of rankcurve). Suppose we are to remove r knots.\n*     First the smallest integer i satisying groups(i) >= r is determined.\n*     In prio all the interior knots of t are listed (or rather their\n*     index in t, t[k-1+5] has index 5), and since we are to remove\n*     all knots in the first ranking groups, we remove the first groups[i-1]\n*     knots of prio (assuming for simplicity that groups[-1]=0).\n*     In the last group we reach into (which consists of knots no.\n*     prio[groups[i-1]+1], prio[groups[i-1]+2],...,prio[groups[i]])\n*     knots are removed uniformly on index, meaning that if we are to remove\n*     half the knots in this group, we pick every other knot as they are\n*     listed in prio, if we are to remove 1/3 of the knots, we remove every\n*     three knots and so on. In general, it is difficult to say what\n*     uniformly on subscripts should mean (how do you choose one knot from\n*     six in a symmetric way) but the approach used here seems to work\n*     reasonably well (see the program text below).\n*     When it is known which knots to remove, the corresponding knot vector\n*     can be constructed and an approximation computed.\n*     the error is then checked as indicated above, and the iterations proceed.\n*\n*     For more information cf. the references:\n*\n*\n* References:\n*      1. A Data-Reduction Strategy for Splines with Applications to the\n*         Approximation of Functions and data, IMA J. of Num. Anal. 8 (1988),\n*         pp. 185-208.\n*\n*      2. Knot Removal for Parametric B-spline Curves and Surfaces,\n*         CAGD 4 (1987), pp. 217-230.\n*\n*\n* Calls: s1943, s6err\n*\n* Written by : Knut Moerken, University of Oslo, July 1992, based on an\n*              earlier Fortran version.\n* Changed by: Paal Fugelli, SINTEF, 1994-07.\n*             Changed to fix several major memory leakage problems.\n* Renamed and changed by: Vibeke Skytt, SINTEF Oslo, 01.95. Introduced\n*                                                treatment of periodicity.\n*\n*********************************************************************\n*/\n{\n  int k = oldcurve->ik;           /* Make some parameters more easily */\n  int dim = oldcurve->idim;       /* accessible. */\n  int mprio = rankcurve->in;\n  int *prio = ranking->prio;\n  int *group = ranking->groups;\n  int antrem = ranking->antrem;\n  int antgr = ranking->antgr;\n  char *del_array;                /* Boolean array that is used for\n                                     marking what knots to include.   */\n  char big, bigco;                /* Boolean variables that are used\n                                     for checking whether the error\n\t\t\t\t     is small enough.                 */\n  int lstat=0;\t\t\t  /* Local status variable.           */\n  int pos=0;\t\t\t  /* Parameter to s6err.              */\n  int nlim = MAX(k, startfix+endfix); /* The minimum number of B-spline\n\t\t\t\t\t coefficients that should be\n\t\t\t\t\t left in newcurve.            */\n\n\t\t\t\t/* For the use of the other variables,\n\t\t\t\t   see the code below.              */\n  int i, start, stop, indx, count, r, p, hn;\n  int kncont = 0;\n  SISLCurve *hcurve = SISL_NULL;\n  double h;\n  double *local_err = SISL_NULL, *l2_err = SISL_NULL, *ltau = SISL_NULL;\n  double tend_domain = oldcurve->et[oldcurve->in];\n\n  /* Allocate memory for the local arrays. */\n\n  del_array = newarray(mprio, char);\n  if (del_array == SISL_NULL) goto err101;\n  if ((local_err = newarray(dim, DOUBLE)) == SISL_NULL) goto err101;\n  if ((l2_err = newarray(dim, DOUBLE)) == SISL_NULL) goto err101;\n\n  /* In case we do not enter the while loop at all we must give newcurve\n     a value. */\n\n  *newcurve = newCurve(mprio, k, rankcurve->et, rankcurve->ecoef, 1, dim, 1);\n  if (newcurve == SISL_NULL) goto err101;\n\n  /* Iterate by binary search until the lower and upper bound on how many\n     knots to include are essentially equal. */\n\n  while (mini+1 < maxi)\n  {\n\n    /* To start with none of the knots of rankspline are marked\n       for removal. */\n\n    for (i=0; i<mprio; i++) del_array[i] = 0;\n    \n    /* Initialize number of knots to remove at the seem. */\n    \n    kncont = 0;\n\n    /* We then have to find out which knots to remove. We remove knots\n       group by group, with start pointing (into prio) to the first knot\n       of the current group and stop to the one following the last of this\n       group. */\n\n    start = 0;\n    stop = group[0];\n    count = 0;\n\n    /* We remove all knots of each group and mark them in del_array\n       until this would mean that we have removed too many. */\n\n    while (stop <= antrem)\n    {\n      for (i=start; i<stop; i++) del_array[prio[i]] = 1;\n\n      count++;\n\n      if (count < antgr)\n      {\n\tstart = stop;\n\tstop = group[count];\n      }\n      else\n      {\n\n\t/* start=stop signifies that we have reached the end. */\n\n\tstop = stop + 1;\n\tstart = stop + 1;\n      }\n    }\n\n    /* Now there are p more knots to remove from a group containing\n       p knots. These p knots are removed \"uniformly on index\". */\n\n    r = stop - start;\n    p = antrem - start;\n\n    if (p > 0)\n    {\n      h = (double) (r+1) / (double) p;\n      for (i=0; i<p; i++)\n      {\n\tindx = start - 1 + (int) floor( h*(i+0.5)+0.5 );\n\tdel_array[prio[indx]] = 1;\n      }\n    }\n\n    /* Gives the number of coefficients in the new spline to be computed. */\n\n    hn = mprio - antrem ;\n\n    /* The new knot vector is stored in ltau.  It might already be allocated\n       from the last iteration, so free it first if required. */\n\n    if (ltau != SISL_NULL) freearray(ltau);\n    ltau = newarray(hn+2*k, double);\n    if (ltau == SISL_NULL) goto err101;\n\n    /* Set the first and last k knots. */\n\n    for (i=0; i<k; i++)\n    {\n      ltau[i] = rankcurve->et[i];\n    }\n\n    /* Set the remaining knots as indicated by del_array. */\n\n    for (indx=k, i=0; i<mprio; i++)\n    {\n       if (!del_array[i]) ltau[indx++] = rankcurve->et[i+k];\n       else if (rankcurve->et[i+k] == tend_domain)\n       {\n\t  /* Set knot at the seem that leads to a continutiy requirement\n\t     on the final spline.  */\n\t  \n\t  ltau[indx++] = tend_domain;\n\t  hn++;\n\t  kncont++;\n       }\n    }\n    \n    /* Compute an approximation on the new knot vector and store it\n       in hcurve.\n       s1943() will allocate space for hcurve (with icopy==1).\n       Need local_err to store the error of the approximation until we know\n       that we have an approximation with error smaller than the tolerance,\n       then we can transfer the error to maxerr. */\n\n    /* *jncont = MAX(kncont, *jncont); */\n    *jncont = MIN(kncont, k-1);\n    s1943(oldcurve, ltau, k, hn, startfix, endfix, *jncont,\n\t   &hcurve, local_err, l2_err, &lstat);\n    if (lstat < 0) goto err;\n\n    /* Check the error. big signifies that the error in one of the\n       components is larger than the tolerance. bigco signifies that\n       the error in one of the components is larger than the (usually\n       much smaller) tolerance epsco. */\n    big = 0;\n    bigco = 0;\n\n    for (i=0; i<dim; i++)\n    {\n      big = big || (local_err[i] > eps[i]);\n      bigco = bigco || (local_err[i] > epsco[i]);\n    }\n\n    /* The error is too large if it is big or if it is bigco and the\n       number of coefficients is smaller than nlim. The latter test is\n       important when the sum of the number of derivatives to be kept\n       fixed at the two ends is larger than k. */\n\n    big = big || (bigco && hn < nlim);\n\n    if (big)\n    {\n\n      /* If the error was too big, we just throw away hcurve and\n\t indicate that an upper bound for the number of knots to\n\t remove is antrem. */\n\n      if (hcurve != SISL_NULL) freeCurve(hcurve);\n      hcurve = SISL_NULL;\n      maxi = antrem;\n    }\n    else\n    {\n\n      /* If the error is acceptable we know that we can remove at least\n\t antrem knots and store hcurve in newcurve. We also save the\n\t error in maxerr. */\n\n      mini = antrem;\n      if (*newcurve != SISL_NULL) freeCurve(*newcurve);\n      *newcurve = hcurve;\n      hcurve = SISL_NULL;\n      memcopy(maxerr, local_err, dim, DOUBLE);\n    }\n\n    /* The number of knots to be removed next time is half way between\n       mini and maxi. */\n\n    antrem = mini + (maxi-mini)/2;\n  }\n\n  *stat = 0;\n\n  goto out;\n\n\n\n  /* Error in memory allocation. */\n\nerr101:\n  *stat = -101;\n  goto out;\n\n  /* Error in lower level routine. */\n\nerr:\n  *stat = lstat;\n  s6err(\"s1950\", *stat, pos);\n\n  /* Clean up before exit. */\n\nout:\n  if (hcurve != SISL_NULL) freeCurve(hcurve);\n  if (del_array != SISL_NULL) freearray(del_array);\n  if (local_err != SISL_NULL) freearray(local_err);\n  if (l2_err != SISL_NULL) freearray(l2_err);\n  if (ltau != SISL_NULL) freearray(ltau);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1951.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S1951\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s1951(double etau[], double ecoef[], int in, int ik, int idim, \n\t int ilend, int irend, int incont, double efac[])\n#else\nvoid s1951(etau, ecoef, in, ik, idim, ilend, irend, incont, efac)\n   double etau[];\n   double ecoef[];\n   int    in;\n   int    ik;\n   int    idim;\n   int    ilend;\n   int    irend;\n   int    incont;\n   double efac[];\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : Multiply the coefficients by dtau(-1/2) and express \n*              the incont last coefficients as a weighted sum\n*              of the incont first coeffecients. The weights are given\n*              in efac.\n* \n* \n* INPUT      : ecoef  - Coefficients of spline curve.\n*              in     - Number of coefficients.p in\n*              idim   - Dimension of geometry space.\n*              incont - Number of continuity conditions, i.e. number of\n*                       coefficients at the end to be expressed by\n*                       coefficients at the start.\n*              efac   - Factors.\n*              \n*\n* \n* OUTPUT     : ecoef  - Coefficients of spline curve.\n*             \n* \n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        :\n*\n*-\n* CALLS      :   \n*\n* WRITTEN BY : Vibeke Skytt,  SINTEF Oslo, 01.95.\n*\n*********************************************************************\n*/\n{\n   int ki, kj, kr;   /* Counters.  */\n   int kstop;\n   double tw;\n\n   /* Multiply the part of ec pointed to by kstart and kstop by the\n      corresponding parts of the square matrix dtau(-1/2).   */\n   \n   for (kstop=in-MAX(incont,irend), ki=ilend; ki<kstop; ki++)\n     {\n\ttw = sqrt((double)ik/(etau[ki+ik] - etau[ki]));\n\tfor (kj=0; kj<idim; kj++)\n\t  ecoef[ki*idim+kj] *= tw;\n     }  \n   \n   /* Express the incont last coefficients by the incont first ones given\n      the factors stored in efac. See s1947. */\n   \n   for (ki=0; ki<incont; ki++)\n   {\n      for (kr=0; kr<idim; kr++)\n      {\n\t ecoef[(in-ki-1)*idim+kr] = DZERO;\n\t for (kj=0; kj<=ki; kj++)\n\t    ecoef[(in-ki-1)*idim+kr] += ecoef[kj*idim+kr]*efac[ki*incont+kj];\n      }\n   }\n   \n}\n   \n"
  },
  {
    "path": "src/s1953.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1953.c,v 1.3 2001-03-19 15:58:57 afr Exp $\n *\n */\n\n\n#define S1953\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1953(SISLCurve *pcurve,double epoint[],int idim,double aepsco,double aepsge,\n\t   int *jpt,double **gpar,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1953(pcurve,epoint,idim,aepsco,aepsge,jpt,gpar,jcrv,wcurve,jstat)\n     SISLCurve    *pcurve;\n     double   epoint[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find the closest point between the curve pcurve and the\n*              point epoint.\n*\n*\n*\n* INPUT      : pcurve - Pointer to the curve in the closest point problem.\n*              epoint - The point in the closest point problem.\n*              idim   - Dimension of the space in which epoint lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : jpt    - Number of single closest points.\n*              gpar   - Array containing the parameter values of the\n*                       single closest points in the parameter interval\n*                       of the curve. The points lie continuous.\n*                       Closest curves are stored in wcurve.\n*              jcrv   - Number of closest curves.\n*              wcurve - Array containing descriptions of the closest\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See descrjption of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Put the equation of the curve into the equation of a\n*              circel/sphere with center epoint and radius zero. The\n*              result is a curve of dimension one. Find the minimum\n*              points of this curve.\n*\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1321,s1370,s1920,freeCurve.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, 1994-08.  Updated to handle\n*              input curve with periodic basis correctly.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;            /* Local status variable.                    */\n  int kpos = 0;             /* Position of error.                        */\n  int kdim = 1;             /* Dimension of curve in extremal problem.   */\n  double tradius = 0;       /* Radius of circel/sphere describing point. */\n  double tdir = -1;         /* Direction of extremal value.              */\n  double sarray[16];        /* Matrix describing circel/sphere.          */\n  SISLCurve *qc = SISL_NULL;     /* Curve of which to find extremal points.   */\n  SISLCurve *qkreg = SISL_NULL;  /* Input curve with ensured k-regular basis. */\n  int ratflag = 0;          /* Flag to indicate if curve is rational.    */\n  int ki;                   /* Counter.                                  */\n\n\n  /* Ensure input has k-regular knot basis. */\n\n  if ( pcurve -> cuopen == SISL_CRV_PERIODIC )\n  {\n    /* Cyclic (periodic) curve */\n\n    make_cv_kreg(pcurve, &qkreg, &kstat);\n    if ( kstat < 0 )  goto error;\n  }\n  else\n    qkreg = pcurve;\n\n\n  /* Test input.  */\n\n  if ( idim != 2 && idim != 3 )  goto err105;\n  if ( qkreg -> idim != idim )  goto err106;\n\n  if ( qkreg -> ikind == 2 || qkreg -> ikind == 4 )  ratflag = 1;\n\n  /* Make a matrix of dimension (idim+1)*(idim+1) to describe\n     the circel/shpere.                                        */\n\n  s1321(epoint, tradius, idim, kdim, sarray, &kstat);\n  if ( kstat < 0 )  goto error;\n\n  /* Put curve into circel/sphere equation.  */\n\n  s1370(qkreg, sarray, idim, kdim, ratflag, &qc, &kstat);\n  if ( kstat < 0 )  goto error;\n\n  /* Find minimum points of the new curve.  */\n\n  s1920(qc, &tdir, kdim, aepsco, aepsge, jpt, gpar, jcrv, wcurve, &kstat);\n  if ( kstat < 0 )  goto error;\n\n  /* Handle periodicity (remove extraneous points) */\n  if ( *jpt > 1  &&  idim > 1  &&  pcurve -> cuopen == SISL_CRV_PERIODIC )\n  {\n    for ( ki=0;  ki < (*jpt);  ki++ )\n    {\n      if ( (*gpar)[ki] == pcurve -> et[pcurve->in] )\n      {\n\t(*jpt)--;\n\t(*gpar)[ki] = (*gpar)[*jpt];\n\tki--;\n      }\n    }\n  }\n\n  /* Closest points/intervals found.  */\n\n  *jstat = 0;\n  goto out;\n\n\n  /* Error in input. Dimension not equal to 2 or 3.  */\n\n err105:\n  *jstat = -105;\n  s6err(\"s1953\",*jstat,kpos);\n  goto out;\n\n  /* Dimensions conflicting.  */\n\n err106:\n  *jstat = -106;\n  s6err(\"s1953\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n error:\n  *jstat = kstat;\n  s6err(\"s1953\",*jstat,kpos);\n  goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if ( qkreg  &&  qkreg != pcurve )  freeCurve(qkreg);\n  if (qc)  freeCurve(qc);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1954.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1954.c,v 1.3 2001-03-19 15:58:57 afr Exp $\n *\n */\n\n\n#define S1954\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1954(SISLSurf *psurf,double epoint[],int idim,double aepsco,double aepsge,\n\t   int *jpt,double **gpar,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1954(psurf,epoint,idim,aepsco,aepsge,jpt,gpar,jcrv,wcurve,jstat)\n\t   SISLSurf     *psurf;\n\t   double   epoint[];\n\t   int      idim;\n\t   double   aepsco;\n\t   double   aepsge;\n\t   int      *jpt;\n\t   double   **gpar;\n\t   int      *jcrv;\n\t   SISLIntcurve ***wcurve;\n\t   int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find the closest point between the surface psurf and the\n*              point epoint.\n*\n*\n*\n* INPUT      : psurf  - Pointer to the surface in the closest point problem.\n*              epoint - The point in the closest point problem.\n*              idim   - Dimension of the space in which epoint lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : jpt    - Number of single closest points.\n*              gpar   - Array containing the parameter values of the\n*                       single closest points in the parameter area\n*                       of the surface. The points lie continuous.\n*                       Closest curves are stored in wcurve.\n*              jcrv   - Number of closest curves.\n*              wcurve - Array containing descriptions of the closest\n*                       curves. The curves are only described by points\n*                       in the parameter area. The curve-pointers points\n*                       to nothing. (See descrjption of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Put the equation of the surface into the equation of a\n*              sphere with center in the point epoint and radius zero,\n*              achieving a one-dimensional surface. Find the minima of\n*              this surface.\n*\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1321 - Create matrix describing the sphere as an\n*                      implicit function.\n*              s1320 - Put the description of the surface into the\n*                      equation of the sphere.\n*              s1921 - Find minimum of surface.\n*              freeSurf - Free space occupied by a surface.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, 1994-08.  Updated to handle\n*              input surface with periodic basis correctly.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;            /* Local status variable.                    */\n  int kpos = 0;             /* Position of error.                        */\n  int kdim = 1;             /* Dimension of curve in extremal problem.   */\n  double tradius = 0;       /* Radius of hyper-sphere describing point.  */\n  double tdir = -1;         /* Direction of extremal value.              */\n  double *sarray = SISL_NULL;    /* Matrix describing hyper-sphere.           */\n  SISLSurf *qs = SISL_NULL;      /* Surface of which to find extremal points. */\n  SISLSurf *qkreg = SISL_NULL;   /* Input surface with k-regularity ensured.  */\n  int ratflag = 0;          /* Flag to indicate if surface is rational.  */\n  int ki;                   /* Counter.                                  */\n\n\n  *jstat = 0;\n\n  /* Ensure k-regular basis */\n\n  if ( psurf -> cuopen_1 == SISL_SURF_PERIODIC ||\n       psurf -> cuopen_2 == SISL_SURF_PERIODIC )\n  {\n    /* Cyclic (i.e. periodic) surface */\n\n    make_sf_kreg(psurf, &qkreg, &kstat);\n    if ( kstat < 0 )  goto error;\n  }\n  else\n    qkreg = psurf;\n\n\n  /* Test input.  */\n\n  if ( qkreg -> idim != idim )  goto err106;\n\n  if ( qkreg -> ikind == 2  ||  qkreg -> ikind == 4)  ratflag = 1;\n\n  /* Allocate space for array describing a hyper-sphere.  */\n\n  if ( (sarray = newarray((idim+1)*(idim+1), DOUBLE)) == SISL_NULL )  goto err101;\n\n  /* Make a matrix of dimension (idim+1)*(idim+1) to describe\n     the hyper-shpere.                                        */\n\n  s1321(epoint, tradius, idim, kdim, sarray, &kstat);\n  if ( kstat < 0 )  goto error;\n\n  /* Put surface into equation of hyper-sphere.  */\n\n  s1320(qkreg, sarray, kdim, ratflag, &qs, &kstat);\n  if ( kstat < 0 )  goto error;\n\n  /* Find minimum points of the new surface.  */\n\n  s1921(qs, &tdir, kdim, aepsco, aepsge, jpt, gpar, jcrv, wcurve, &kstat);\n  if ( kstat < 0 )  goto error;\n\n  /* Handle periodicity (remove extraneous points) */\n  if ( (*jpt) > 1  &&  idim > 1  && (psurf -> cuopen_1 == SISL_SURF_PERIODIC ||\n\t\t\t\t     psurf -> cuopen_2 == SISL_SURF_PERIODIC) )\n  {\n    for ( ki=0;  ki < (*jpt);  ki++ )\n    {\n      if ( (psurf -> cuopen_1 == SISL_SURF_PERIODIC &&\n\t    (*gpar)[2*ki]     == psurf -> et1[psurf->in1]) ||\n\t   (psurf -> cuopen_2 == SISL_SURF_PERIODIC &&\n\t    (*gpar)[2*ki+1]     == psurf -> et2[psurf->in2]) )\n      {\n\t(*jpt)--;\n\t(*gpar)[2*ki]   = (*gpar)[2*(*jpt)];\n\t(*gpar)[2*ki+1] = (*gpar)[2*(*jpt)+1];\n\tki--;\n      }\n    }\n  }\n\n  /* Closest points/intervals found.  */\n\n  *jstat = 0;\n  goto out;\n\n\n  /* Error in space allocation.  */\n\n err101:\n  *jstat = -101;\n  s6err(\"s1954\",*jstat,kpos);\n  goto out;\n\n  /* Dimensions conflicting.  */\n\n err106:\n  *jstat = -106;\n  s6err(\"s1954\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n error:\n  *jstat = kstat;\n  s6err(\"s1954\",*jstat,kpos);\n  goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if ( qkreg  &&  qkreg != psurf )  freeSurf(qkreg);\n  if (sarray)  freearray(sarray);\n  if (qs)  freeSurf(qs);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1955.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1955.c,v 1.3 2001-03-19 15:58:57 afr Exp $\n *\n */\n\n\n#define S1955\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1955(SISLCurve *pc1,SISLCurve *pc2,double aepsco,double aepsge,\n\t   int *jpt,double **gpar1,double **gpar2,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid s1955(pc1,pc2,aepsco,aepsge,jpt,gpar1,gpar2,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     SISLCurve    *pc2;\n     double   aepsco;\n     double   aepsge;\n     int      *jpt;\n     double   **gpar1;\n     double   **gpar2;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find the closest point between the two curve pc1 and pc2.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the first curve in the closest point\n*                       problem.\n*              pc2    - Pointer to the second curve in the closest point\n*                       problem.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : jpt    - Number of single closest points.\n*              gpar1  - Array containing the parameter values of the\n*                       single closest points in the parameter intervals\n*                       of the first curve. The points lie continuous.\n*                       Closest curves are stored in wcurve.\n*              gpar2  - Array containing the parameter values of the\n*                       single closest points in the parameter intervals\n*                       of the second curve. The points lie continuous.\n*              jcrv   - Number of closest curves.\n*              wcurve - Array containing descriptions of the closest\n*                       curves. The curves are only described by points\n*                       in the parameter area. The curve-pointers points\n*                       to nothing. (See descrjption of Intcurve\n*                       in intcurve.dcl).\n*                       If the curves given as input are degnenerate an\n*                       intersection point can be returned as an intersection\n*                       curve. Use s1327 to decide if an intersection curve\n*                       is a point on one of the curves.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Generate the difference surface between the two curves,\n*              and find those points of this surface closest to origo.\n*\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1954    - Find closest points between a surface and a point.\n*              s1956    - Create difference surface between two curves.\n*              freeSurf - Free space occupied by a surface.\n*              newIntcurve - Create new closest curve.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, 1994-08.  Updated to handle\n*              input curves with periodic basis correctly.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;               /* Local status variable.                 */\n  int kpos = 0;                /* Position of error.                     */\n  int ki,kj;                   /* Counters.                              */\n  int kdim;                    /* Dimension of the space in which the\n\t\t\t\t  curves lie.                            */\n  double *sorigo = SISL_NULL;       /* Array representing origo.              */\n  double *spar1 = SISL_NULL;        /* Parameter-values in the parameter\n\t\t\t\t  interval of the first curve of the\n\t\t\t\t  closest curve.                         */\n  double *spar2 = SISL_NULL;        /* Parameter-values in the parameter\n\t\t\t\t  interval of the second curve of the\n\t\t\t\t  closest curve.                         */\n  double *ssing = SISL_NULL;        /* Single closest points between\n\t\t\t\t  difference surface and origo.          */\n  SISLSurf *qsdiff = SISL_NULL;         /* Difference surface.                    */\n  SISLIntcurve *qcurve;            /* Pointer to closest curve.              */\n  SISLCurve *qkreg1 = SISL_NULL;    /* First incrv with ensured k-regular basis. */\n  SISLCurve *qkreg2 = SISL_NULL;    /* Second incrv with ensured k-regular basis. */\n  int k1=1,k2=2,k4=4;          /* Constants                              */\n\n\n  /* Ensure k-regular basis for input curves. */\n\n  if ( pc1 -> cuopen == SISL_CRV_PERIODIC )\n  {\n    /* Cyclic (i.e. periodic) basis. */\n\n    make_cv_kreg(pc1, &qkreg1, &kstat);\n    if ( kstat < 0 )  goto error;\n  }\n  else\n    qkreg1 = pc1;\n\n  if ( pc2 -> cuopen == SISL_CRV_PERIODIC )\n  {\n    /* Cyclic (i.e. periodic) basis. */\n\n    make_cv_kreg(pc2, &qkreg2, &kstat);\n    if ( kstat < 0 )  goto error;\n  }\n  else\n    qkreg2 = pc2;\n\n\n  /* Test input.  */\n\n  kdim = qkreg1 -> idim;\n  if ( kdim != qkreg2 -> idim )  goto err106;\n\n  /* Allocate space for the point origo.  */\n\n  if ( (sorigo = new0array(kdim, DOUBLE)) == SISL_NULL )  goto err101;\n\n  /* Generate the difference surface between the curves.  */\n\n  s1956(qkreg1, qkreg2, &qsdiff, &kstat);\n  if ( kstat < 0 )  goto error;\n\n  if ( kstat > 0 )\n  {\n\n    /* The curves define a closest interval. Allocate space\n       for points defining the interval.                      */\n\n    if ( (spar1 = newarray(k2, DOUBLE)) == SISL_NULL )  goto err101;\n    if ( (spar2 = newarray(k2, DOUBLE)) == SISL_NULL )  goto err101;\n\n    if ( kstat == 1 )\n    {\n\n      /* The curves are equal.  */\n\n      spar1[0] = *(qkreg1->et + qkreg1->ik - 1);\n      spar1[1] = *(qkreg1->et + qkreg1->in);\n      spar2[0] = *(qkreg2->et + qkreg2->ik - 1);\n      spar2[1] = *(qkreg2->et + qkreg2->in);\n\n    }\n    else if ( kstat == 2 )\n    {\n\n      /* The curves are equal, but oppositely directed.  */\n\n      spar1[0] = *(qkreg1->et + qkreg1->ik - 1);\n      spar1[1] = *(qkreg1->et + qkreg1->in);\n      spar2[0] = *(qkreg2->et + qkreg2->in);\n      spar2[1] = *(qkreg2->et + qkreg2->ik - 1);\n    }\n\n    *wcurve = SISL_NULL;\n    if ( (*wcurve = newarray(k1, SISLIntcurve*)) == SISL_NULL )  goto err101;\n    *jcrv = 1;\n\n    **wcurve = SISL_NULL;\n    if ( (**wcurve = newIntcurve(k2,k1,k1,spar1,spar2,k4)) == SISL_NULL )  goto err101;\n\n  }\n  else\n  {\n\n    /* Find the closest points between the difference function and origo.*/\n\n    s1954(qsdiff, sorigo, kdim, aepsco, aepsge, jpt, &ssing, jcrv, wcurve, &kstat);\n    if ( kstat < 0 )  goto error;\n\n    /* Handle periodicity (remove extraneous points) */\n\n    if ( (*jpt) > 1  &&  kdim > 1  && (pc1 -> cuopen == SISL_CRV_PERIODIC ||\n\t\t\t\t       pc2 -> cuopen == SISL_CRV_PERIODIC) )\n    {\n      for ( ki=0;  ki < (*jpt);  ki++ )\n      {\n\tif ( (pc1 -> cuopen == SISL_CRV_PERIODIC &&\n\t      ssing[2*ki]   == pc1 -> et[pc1->in]) ||\n\t     (pc2 -> cuopen == SISL_CRV_PERIODIC &&\n\t      ssing[2*ki+1] == pc2 -> et[pc2->in]) )\n\t{\n\t  (*jpt)--;\n\t  ssing[2*ki]   = ssing[2*(*jpt)];\n\t  ssing[2*ki+1] = ssing[2*(*jpt)+1];\n\t  ki--;\n\t}\n      }\n    }\n\n    if ( (*jpt) > 0 )\n    {\n\n      /* Allocate space for output of single closest points.  */\n\n      *gpar1 = *gpar2 = SISL_NULL;\n      if ( (*gpar1 = newarray(*jpt, DOUBLE)) == SISL_NULL )  goto err101;\n      if ( (*gpar2 = newarray(*jpt, DOUBLE)) == SISL_NULL )  goto err101;\n\n      /* Copy single closest points to output arrays.  */\n\n      for ( ki=0;  ki < (*jpt);  ki++ )\n      {\n\t*(*gpar1 + ki) = ssing[2*ki];\n\t*(*gpar2 + ki) = ssing[2*ki+1];\n      }\n    }\n\n    for ( kj=0;  kj < (*jcrv);  kj++ )\n    {\n\n      /* Correct parameter-arrays of closest curve.  */\n\n      qcurve = *(*wcurve + kj);\n      qcurve -> ipar1 = qcurve -> ipar2 = 1;\n\n      /* Allocate space for new parameter arrays.  */\n\n      spar1 = spar2 = SISL_NULL;\n      if ( (spar1 = newarray(qcurve->ipoint, DOUBLE)) == SISL_NULL )  goto err101;\n      if ( (spar2 = newarray(qcurve->ipoint, DOUBLE)) == SISL_NULL )  goto err101;\n\n      /* Copy parameter-values to new arrays.  */\n\n      for ( ki=0;  ki < qcurve->ipoint;  ki++ )\n      {\n\tspar1[ki] = *(qcurve->epar1+2*ki);\n\tspar2[ki] = *(qcurve->epar1+2*ki+1);\n      }\n\n      freearray(qcurve->epar1);\n      qcurve -> epar1 = spar1;\n      qcurve -> epar2 = spar2;\n    }\n  }\n\n  /* Closest points found.  */\n\n  *jstat = 0;\n  goto out;\n\n\n  /* Error in space allocation.  */\n\n err101:\n  *jstat = -101;\n  s6err(\"s1955\",*jstat,kpos);\n  goto out;\n\n  /* Error in input. Dimensions conflicing.  */\n\n err106:\n  *jstat = -106;\n  s6err(\"s1955\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n error:\n  *jstat = kstat;\n  s6err(\"s1955\",*jstat,kpos);\n  goto out;\n\n out:\n\n  /* Free space occupied local variables.  */\n\n  if ( qkreg1  &&  qkreg1 != pc1 )  freeCurve(qkreg1);\n  if ( qkreg2  &&  qkreg2 != pc2 )  freeCurve(qkreg2);\n  if (ssing)  freearray(ssing);\n  if (sorigo) freearray(sorigo);\n  if (qsdiff) freeSurf(qsdiff);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1956.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1956.c,v 1.3 2001-03-19 15:58:57 afr Exp $\n *\n */\n\n\n#define S1956\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1956(SISLCurve *pc1,SISLCurve *pc2,SISLSurf **rsurf,int *jstat)\n#else\nvoid s1956(pc1,pc2,rsurf,jstat)\n     SISLCurve *pc1;\n     SISLCurve *pc2;\n     SISLSurf  **rsurf;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find the surface describing the difference function\n*              between two B-spline curves.\n*\n*\n* INPUT      : pc1    - Pointer to first curve in difference function.\n*              pc2    - Pointer to second curve in difference function.\n*\n*\n*\n* OUTPUT     : rsurf  - Pointer to difference surface.\n*              jstat  - status messages\n*                     = 2      : The curves have the same representation\n*                                and opposite direction.\n*                     = 1      : The curves have the same representation\n*                                and the same direction.\n*                     = 0      : ok\n*                     < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6dist - Distance between two points.\n*              s6diff - Difference vector between two vectors.\n*              newSurf - Create new surface.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n* REVISED BY : Michael Floater, SI, 91-09 for possible rational curves.\n*          Also fixed a bug in the \"check same representation\" part.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Sept. 1994. Fixed memory\n*          leak from 'ratpc'.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;        /* Local status variable.                        */\n  int kpos = 0;         /* Position of error.                            */\n  int i,ki,kj;          /* Counters.                                     */\n  int kind1,kind2;      /* Kinds of the two curves.                       */\n  int kdim;             /* Dimension of the space in which the curves lie.*/\n  int kn1;              /* Number of vertices of first curve.            */\n  int kk1;              /* Order of first curve.                         */\n  int kn2;              /* Number of vertices of second curve.           */\n  int kk2;              /* Order of second curve.                        */\n  double tdist;         /* Distance between vertices.                    */\n  double *scoef1;       /* Pointer to vertices of first curve.           */\n  double *scoef2;       /* Pointer to vertices of second curve.          */\n  double *ssurf = SISL_NULL; /* Pointer to the vertices of the difference\n\t\t\t   surface.                                      */\n  double *s0;           /* Pointer used to traverse ssurf.               */\n  double *s1;           /* Pointer used to traverse scoef1.              */\n  double *s2;           /* Pointer used to traverse scoef2.              */\n  SISLCurve *ratpc=SISL_NULL; /* Temporary SISLCurve for rational cases.      */\n  int newdim;          /* = kdim+1 if pc1 or pc2 rational, else = kdim.  */\n  double *s1weight;    /* Pointer to weights in pc1 if rational.         */\n  double *s2weight;    /* Pointer to weights in pc2 if rational.         */\n  double *s3;          /* Pointer to traverse scoef2 if rational.        */\n\n  /* Test input. */\n\n  if (pc1->idim != pc2->idim) goto err106;\n\n  /* Describe curves in local parameters.  */\n\n  kdim = pc1 -> idim;\n  kn1 = pc1 -> in;\n  kk1 = pc1 -> ik;\n  kind1 = pc1 -> ikind;\n\n  kn2 = pc2 -> in;\n  kk2 = pc2 -> ik;\n  kind2 = pc2 -> ikind;\n\n  if((kind1 == 2 || kind1 == 4) || (kind2 == 2 || kind2 == 4))\n  {\n    /* At least one of the curves is rational. Convert the\n       other curve to rational if necessary. */\n\n    newdim=kdim+1;\n\n    if(kind1 != 2 && kind1 != 4)\n    {\n\tratpc=s1521(pc1,&kstat);\n\tif(kstat < 0) goto err102;\n\n\tscoef1 = ratpc -> rcoef;\n\tscoef2 = pc2 -> rcoef;\n    }\n    else if(kind2 != 2 && kind2 != 4)\n    {\n\tratpc=s1521(pc2,&kstat);\n\tif(kstat < 0) goto err102;\n\n\tscoef1 = pc1 -> rcoef;\n\tscoef2 = ratpc -> rcoef;\n    }\n    else\n    {\n\tscoef1 = pc1 -> rcoef;\n\tscoef2 = pc2 -> rcoef;\n    }\n\n\n    /* Allocate space for homogeneous coefficients of rational\n       difference surface.  */\n\n    if ((ssurf = newarray(kn1*kn2*newdim,double)) == SISL_NULL) goto err101;\n\n    /* Make coefficients of difference function.  */\n\n    for (s0=ssurf,s2=scoef2,kj=0; kj<kn2; s2+=(kdim+1),kj++)\n    {\n      for (s1=scoef1,ki=0; ki<kn1; s0++,s1++,ki++)\n      {\n\t  s1weight=s1+kdim;\n\t  s2weight=s2+kdim;\n\n\t  for(i=0,s3=s2; i<kdim; i++,s0++,s1++,s3++)\n\t  {\n\t      (*s0) = (*s2weight) * (*s1) - (*s1weight) * (*s3);\n\t  }\n\n\t  (*s0) = (*s1weight) * (*s2weight);\n      }\n    }\n\n    /* Create difference function.  */\n\n    *rsurf = SISL_NULL;\n    if ((*rsurf = newSurf(kn1,kn2,kk1,kk2,pc1->et,pc2->et,\n\t\t\t  ssurf,2,kdim,1)) == SISL_NULL) goto err101;\n  }\n  else\n  {\n      /* Both curves are non-rational. */\n\n    newdim=kdim;\n\n    scoef1 = pc1 -> ecoef;\n    scoef2 = pc2 -> ecoef;\n\n    /* Allocate space for coefficients of difference surface.  */\n\n    if ((ssurf = newarray(kn1*kn2*kdim,double)) == SISL_NULL) goto err101;\n\n    /* Make coefficients of difference function.  */\n\n    for (s0=ssurf,s2=scoef2,kj=0; kj<kn2; s2+=kdim,kj++)\n      for (s1=scoef1,ki=0; ki<kn1; s0+=kdim,s1+=kdim,ki++)\n        s6diff(s1,s2,kdim,s0);\n\n    /* Create difference function.  */\n\n    *rsurf = SISL_NULL;\n    if ((*rsurf = newSurf(kn1,kn2,kk1,kk2,pc1->et,pc2->et,\n\t\t\t  ssurf,1,kdim,1)) == SISL_NULL) goto err101;\n  }\n\n\n\n  /* Test if the curves have the same representation and same direction. */\n\n  kstat = 1;\n  if (kn1 != kn2 || kk1 != kk2) kstat = 0;\n  tdist = s6dist(scoef1,scoef2,newdim);\n  if(DNEQUAL(tdist,(double)0.0))\n  {\n      kstat = 0;\n  }\n  else\n  {\n      for (s1=scoef1+newdim,s2=scoef2+newdim,ki=1; ki<kn1 && kstat>0;\n           s1+=newdim,s2+=newdim,ki++)\n      {\n        if (DNEQUAL(s6dist(s1,s2,newdim),tdist))\n\t{\n\t    kstat = 0;\n\t    break;\n\t}\n      }\n  }\n\n  if (kstat == 0)\n  {\n\n      /* Test if the curves have the same representation and opposite direction.*/\n\n      kstat = 2;\n      if (kn1 != kn2 || kk1 != kk2) kstat = 0;\n      tdist = s6dist(scoef1,scoef2+(kn2-1)*newdim,newdim);\n      if(DNEQUAL(tdist,(double)0.0))\n      {\n          kstat = 0;\n      }\n      else\n      {\n          for (s1=scoef1+newdim,s2=scoef2+(kn2-2)*newdim,ki=1;\n\t\t ki<kn1 && kstat>0; s1+=newdim,s2-=newdim,ki++)\n          {\n            if (DNEQUAL(s6dist(s1,s2,newdim),tdist))\n\t    {\n\t        kstat = 0;\n\t        break;\n\t    }\n\t  }\n      }\n  }\n\n\n  /* Difference function made.  */\n\n  *jstat = kstat;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;\n  s6err(\"s1956\",*jstat,kpos);\n  goto out;\n\n  /* Error in in lower level routine. */\n\n err102: *jstat = kstat;\n  s6err(\"s1956\",*jstat,kpos);\n  goto out;\n\n  /* Error in input. Conflicting dimensions.  */\n\n  err106 : *jstat = -106;\n  s6err(\"s1956\",*jstat,kpos);\n  goto out;\n\n out:\n\n  /* Free space occupied by local array.  */\n\n  if (ssurf != SISL_NULL) freearray(ssurf);\n  if (ratpc) freeCurve(ratpc);\n\n  return;\n}\n"
  },
  {
    "path": "src/s1957.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1957.c,v 1.2 2001-03-19 15:58:57 afr Exp $\n *\n */\n\n\n#define S1957\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1957(SISLCurve *pcurve,double epoint[],int idim,double aepsco,double aepsge,\n           double *gpar,double *dist,int *jstat)\n#else\nvoid s1957(pcurve,epoint,idim,aepsco,aepsge,gpar,dist,jstat)\n     SISLCurve    *pcurve;\n     double   epoint[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     double   *gpar;\n     double   *dist;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find the closest point between the curve pcurve and the\n*              point epoint. The method is fast and should work well\n*              in clear cut cases but does not guarantee finding\n*              the right solution. As long as it doesn't fail,\n*              it will find exactly one point.\n*\n*\n*\n* INPUT      : pcurve - Pointer to the curve in the closest point problem.\n*              epoint - The point in the closest point problem.\n*              idim   - Dimension of the space in which epoint lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : gpar   - The parameter value of the closest point\n*                       in the parameter interval \n*                       of the curve.\n*              dist   - The closest distance between curve and point.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : Point found by iteration\n*                                         = 1      : Point lies at an end\n*                                         < 0      : error\n*\n*\n* METHOD     : Find an initial guess solution by finding, essentially,\n*              the closest control point to the given point\n*              and estimating the corresponding parameter value, s1959.\n*              This value is then the starting point for a Newton\n*              iteration in s1771. The distance of this solution\n*              is then compared with the distance of the end points\n*              (from the given point) and the minimum is returned.\n*              \n*              \n*\n*\n* REFERENCES :\n*\n*- \n* CALLS      : s1959,s1771,newPoint,freePoint.\n*\n* WRITTEN BY : Michael Floater, SI, 91-10.\n*\n*********************************************************************\n*/                                                               \n{                                                                     \n  double dist1,dist2;       /* Distances of endpoints from epoint.       */\n  double cldist;            /* Current minimum distance.                 */\n  double endpt[3];          /* Coeffs of an end point of the curve.      */\n  double clspt[3];          /* Coeffs of closest point of the curve.     */\n  double enext;             /* Initial guess for iteration               */\n  double estart,eend;       /* Parameter area for Newton iteration.      */\n  double *et=SISL_NULL;          /* Knot vector.                              */\n  int ik;                   /* Order of curve.                           */\n  int in;                   /* Number of control points of curve.        */\n  int kleft=0;              /* Dummy used in evualation.                 */\n  int kstat = 0;            /* Local status variable.                    */\n  int kpos = 0;             /* Error position.                           */\n  double gpos;              /* Parameter of closest point on curve.      */\n  double clgpar;            /* Parameter of current closest point.       */\n  SISLPoint *ppoint = SISL_NULL; /* epoint in SISLPoint form.                 */\n  \n  /* Test input.  */\n  \n  if (idim != 2 && idim != 3) goto err105;\n  if (pcurve->idim != idim) goto err106;\n\n  /* Set up local variables. */\n\n  et = pcurve->et;\n  ik = pcurve->ik;\n  in = pcurve->in;\n\n\n  /* Evaluate the curve at its end points. */\n  \n  s1221(pcurve,0,et[ik-1],&kleft,endpt,&kstat);\n  if (kstat < 0) goto error;\n  \n  dist1 = s6dist(epoint,endpt,idim);\n  \n  s1221(pcurve,0,et[in],&kleft,endpt,&kstat);\n  if (kstat < 0) goto error;\n  \n  dist2 = s6dist(epoint,endpt,idim);\n  \n  /* Find the closest end point and store the result. */\n\n  *jstat = 1;\n\n  if(dist1 < dist2)\n  {\n      cldist = dist1;\n      clgpar = et[ik-1];\n  }\n  else\n  {\n      cldist = dist2;\n      clgpar = et[in];\n  }\n\n  \n  /* Now try the interior of the curve. */\n\n  ppoint = newPoint(epoint,idim,1);\n  if(ppoint == SISL_NULL) goto err101;\n\n  /* Find a good guess point based on finding the closest control\n     point and its corresponding parameter values. */\n\n  s1959(ppoint,pcurve,&enext,&kstat);\n  if(kstat < 0) goto error;\n\n\n  /* Do the Newton iteration. */\n    \n  estart=et[ik-1];\n  eend=et[in];\n\n  s1771(ppoint,pcurve,aepsge,estart,eend,enext,&gpos,&kstat);\n  if(kstat >= 0)\n  {\n      /* Closest point found. */\n      /* Find distance to compare with end points. */\n    \n      s1221(pcurve,0,gpos,&kleft,clspt,&kstat);\n      if (kstat < 0) goto error;\n      \n      dist1 = s6dist(epoint,clspt,idim);\n\n      if(dist1 < cldist)\n      {\n          cldist = dist1;\n          clgpar = gpos;\n          *jstat = 0;\n      }\n  }\n\n  /* Return the result. */\n\n  *gpar = clgpar;\n  *dist = cldist;\n\n\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1957\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Dimension not equal to 2 or 3.  */\n  \n err105: *jstat = -105;\n  s6err(\"s1957\",*jstat,kpos);\n  goto out;\n  \n  /* Dimensions conflicting.  */\n  \n err106: *jstat = -106;\n  s6err(\"s1957\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"s1957\",*jstat,kpos);\n  goto out;\n  \n out:\n  \n  /* Free allocated space.  */\n  \n  if (ppoint != SISL_NULL) freePoint(ppoint);\n  \n  return;\n}                                               \n                                           \n                       \n\n"
  },
  {
    "path": "src/s1958.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1958.c,v 1.2 2001-03-19 15:58:58 afr Exp $\n *\n */\n\n\n#define S1958\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1958(SISLSurf *psurf,double epoint[],int idim,double aepsco,double aepsge,\n           double gpar[],double *dist,int *jstat)\n#else\nvoid s1958(psurf,epoint,idim,aepsco,aepsge,gpar,dist,jstat)\n     SISLSurf    *psurf;\n     double   epoint[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     double   gpar[];\n     double   *dist;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find the closest point between the surface psurf\n*              and the point epoint.\n*              The method is fast and should work well\n*              in clear cut cases but does not guarantee finding\n*              the right solution. As long as it doesn't fail,\n*              it will find exactly one point.\n*\n*\n*\n* INPUT      : psurf  - Pointer to the surface in the closest point problem.\n*              epoint - The point in the closest point problem.\n*              idim   - Dimension of the space in which epoint lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : gpar   - Array(2) containing the parameter values of the\n*                       closest point in the parameter space\n*                       of the surface.\n*              dist   - The closest distance between point and the surface.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : Solution in interior \n*                                         = 1      : Solution at an edge \n*                                         = 2      : Solution at a corner \n*                                         < 0      : error\n*\n*\n* METHOD     : Find an initial guess solution by finding, essentially,\n*              the closest control point to the given point\n*              and estimating the corresponding parameter pair, s1959.\n*              This pair is then the starting point for a Newton\n*              iteration in s1773. The distance of this solution\n*              is then compared with the distance of the edge curves\n*              (from the given point) found by s1957\n*              and the minimum is returned.\n*\n*\n* REFERENCES :\n*\n*- \n* CALLS      : s1960,s1773,newPoint,freePoint,\n*              s1957,freeCurve,s1436,s1437.\n*\n* WRITTEN BY : Michael Floater, SI, 91-10.\n*\n*********************************************************************\n*/                                                               \n{                                                                     \n  double clspt[3];          /* Coeffs. of potential closest point.       */\n  double newdist,cldist;    /* Distances of edges from epoint.           */\n  double enext[2];          /* Initial guess for iteration               */\n  double estart[2],eend[2]; /* Parameter area for Newton iteration.      */\n  double *et1=SISL_NULL;         /* Knot vector in u direc.                   */\n  double *et2=SISL_NULL;         /* Knot vector in v direc.                   */\n  int ik1;                  /* Order of curve in u direction.            */\n  int ik2;                  /* Order of curve in v direction.            */\n  int in1;                  /* No. control points of curve in u direec.  */\n  int in2;                  /* No. control points of curve in v direec.  */\n  int kleft1=0,kleft2=0;    /* Dummies used in evualation.               */\n  int kstat = 0;            /* Local status variable.                    */\n  int clkstat = 0;          /* Local status variable.                    */\n  int kpos = 0;             /* Error position.                           */\n  double gpos[2];           /* Parameters of closest point on surface.   */\n  double clgpos[2];         /* Current parameters of cl. pt. on surface. */\n  double crvpar;            /* Parameter of closest point on an edge.    */\n  SISLPoint *ppoint=SISL_NULL;   /* epoint in SISLPoint form.                 */\n  SISLCurve *pcurve=SISL_NULL;   /* An edge of the surface.                   */\n  \n  /* Test input.  */\n  \n  if (idim != 3) goto err105;\n  if (psurf->idim != idim) goto err106;\n\n\n  /* Set up local variables. */\n\n  ik1 = psurf->ik1;\n  ik2 = psurf->ik2;\n  in1 = psurf->in1;\n  in2 = psurf->in2;\n  et1 = psurf->et1;\n  et2 = psurf->et2;\n\n  /* First of all, find the closest point on the boundary.\n     This is done by calling s1957 on each of the four edges. */\n\n  /* Find closest point of edge 0. */\n  \n  s1437(psurf,et1[ik1-1],&pcurve,&kstat);\n  if (kstat < 0) goto error;\n\n  s1957(pcurve,epoint,idim,aepsco,aepsge,&crvpar,&cldist,&clkstat);\n  if (kstat < 0) goto error;\n  if(pcurve != SISL_NULL)\n  {\n    freeCurve(pcurve);\n    pcurve = SISL_NULL;  \n  }\n  clgpos[0] = et1[ik1-1];\n  clgpos[1] = crvpar;\n  clkstat++;\n\n  /* Find closest point of edge 1. */\n  \n  s1437(psurf,et1[in1],&pcurve,&kstat);\n  if (kstat < 0) goto error;\n\n  s1957(pcurve,epoint,idim,aepsco,aepsge,&crvpar,&newdist,&kstat);\n  if (kstat < 0) goto error;\n  if(pcurve != SISL_NULL)\n  {\n    freeCurve(pcurve);\n    pcurve = SISL_NULL;\n  }\n  if(newdist < cldist)\n  {\n      cldist = newdist;\n      clgpos[0] = et1[in1];\n      clgpos[1] = crvpar;\n      clkstat = kstat+1;\n  }\n\n  /* Find closest point of edge 2. */\n  \n  s1436(psurf,et2[ik2-1],&pcurve,&kstat);\n  if (kstat < 0) goto error;\n\n  s1957(pcurve,epoint,idim,aepsco,aepsge,&crvpar,&newdist,&kstat);\n  if (kstat < 0) goto error;\n  if(pcurve != SISL_NULL)\n  {\n    freeCurve(pcurve);\n    pcurve = SISL_NULL;\n  }\n\n  if(newdist < cldist)\n  {\n      cldist = newdist;\n      clgpos[0] = crvpar;\n      clgpos[1] = et2[ik2-1];\n      clkstat = kstat+1;\n  }\n\n  /* Find closest point of edge 3. */\n  \n  s1436(psurf,et2[in2],&pcurve,&kstat);\n  if (kstat < 0) goto error;\n\n  s1957(pcurve,epoint,idim,aepsco,aepsge,&crvpar,&newdist,&kstat);\n  if (kstat < 0) goto error;\n  if(pcurve != SISL_NULL) freeCurve(pcurve);\n\n  if(newdist < cldist)\n  {\n      cldist = newdist;\n      clgpos[0] = crvpar;\n      clgpos[1] = et2[in2];\n      clkstat = kstat+1;\n  }\n\n\n\n  /* Next, try the interior of the surface by Newton iteration. */\n\n  ppoint = newPoint(epoint,idim,1);\n  if(ppoint == SISL_NULL) goto err101;\n\n  /* Find a good guess point based on finding the closest control\n     point and its corresponding parameter values. */\n\n  s1960(ppoint,psurf,enext,&kstat);\n  if(kstat < 0) goto error;\n\n  /* Do the Newton iteration. */\n    \n  estart[0] = et1[ik1-1];\n  estart[1] = et2[ik2-1];\n  eend[0] = et1[in1];\n  eend[1] = et2[in2];\n\n  s1773(ppoint,psurf,aepsge,estart,eend,enext,gpos,&kstat);\n  if(kstat >= 0)\n  {\n    \n      /* Closest point found. */\n      /* Find distance and compare with edges. */\n    \n      s1424(psurf,0,0,gpos,&kleft1,&kleft2,clspt,&kstat);\n      if (kstat < 0) goto error;\n      \n      newdist = s6dist(epoint,clspt,idim);\n\n      if(newdist < cldist)\n      {\n          cldist = newdist;\n          clgpos[0] = gpos[0];\n          clgpos[1] = gpos[1];\n          clkstat = 0;\n      }\n\n    \n  }\n\n  \n  /* Closest point found. Return point is in interior, on an edge,\n     or at a corner. */\n\n  *dist = cldist;\n  gpar[0] = clgpos[0];\n  gpar[1] = clgpos[1];\n\n  *jstat = clkstat;\n\n  goto out;\n \n\n\n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1958\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Dimension not equal to 3.  */\n  \n err105: *jstat = -105;\n  s6err(\"s1958\",*jstat,kpos);\n  goto out;\n  \n  /* Dimensions conflicting.  */\n  \n err106: *jstat = -106;\n  s6err(\"s1958\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"s1958\",*jstat,kpos);\n  goto out;\n  \n out:\n  \n  /* Free allocated space.  */\n  \n  if (ppoint != SISL_NULL) freePoint(ppoint);\n  \n  return;\n}                                               \n                                           \n                       \n\n"
  },
  {
    "path": "src/s1959.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1959.c,v 1.3 2001-03-19 15:58:58 afr Exp $\n *\n */\n#define S1959\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1959(SISLPoint *ppoint, SISLCurve *pcurve, double *gpos, int *jstat)\n#else\nvoid s1959(ppoint,pcurve,gpos,jstat)\n     SISLPoint        *ppoint;\n     SISLCurve         *pcurve;\n     double       *gpos;\n     int          *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Estimate parameter of guess-point (used by closest point\n*              calculation).\n*\n*\n* INPUT      : ppoint   - Pointer to the point.\n*              pcurve    - Pointer to the curve.\n*\n* OUTPUT     : gpos    - Parameter of the found guess-point.\n*              jstat   - status messages\n*                                = 0   : Guess-point found.\n*                                = 1   : Closest point as guess-point.\n*                                < 0   : error.\n*\n*\n* METHOD     : Quadrant analysis and Schoenberger equation.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Michael Floater, SI, October 1991\n*                Based on Per Evensen's surface version s1960.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Dec. 1994. Fixed memory\n*              problem for 2D curves.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;            /* Local status variable.                     */\n  int kpos = 0;             /* Position of error.                         */\n  int i;                    /* Running indexes                            */\n  int iind;                 /* Index variable                             */\n  int kk;                /* The polynomial order of the curve (pcurve) */\n  int nk;                /* The number of vertices of the curve (pcurve)  */\n  int dim;                  /* Dimension of space the curve lies in      */\n  double *et;              /* Knots for the curve (pcurve)               */\n  double *lpoint;           /* Coefficients of the point (ppoint)         */\n  double *scoef;            /* Coefficients of the curve (pcurve)         */\n  double tdist;             /* Distance variable                          */\n  double tmin;              /* Minimum distance variable                  */\n  double vec1[3],vec2[3];   /* Vectors defining the quadrants surrounding\n                               a vertex                                  */\n  double vecp[3];           /* Relative point vector                      */\n  double lqua1=DZERO;\n  double lqua2=DZERO;\n                            /* Length of vec1 and vec2                   */\n  double lprj1=DZERO;\n  double lprj2=DZERO;\n                            /* Length of projection of vecp on\n                               vec1 and vec2                             */\n  double svals,svale;       /* Local start and end parameter values      */\n /* --------------------------------------------------------------------- */\n\n  /* Test input.  */\n  if (ppoint->idim != pcurve->idim || pcurve->idim <= 1) goto err106;\n\n  /* Initialize local variables.  */\n  kk  = pcurve->ik;\n  nk  = pcurve->in;\n  et = pcurve->et;\n  scoef = pcurve->ecoef;\n  dim = pcurve->idim;\n  lpoint = ppoint->ecoef;\n\n  /* Find vertex closest to point.  */\n  tdist=s6dist(scoef,lpoint,dim);\n  tmin=tdist;\n  iind = 0;\n  for (i=0; i<nk; i++)\n  {\n        tdist=s6dist(scoef,lpoint,dim);\n        if (tdist<tmin)\n        {\n           tmin=tdist;\n           iind = i;\n        }\n        scoef+=dim;  /* PFU 02/12-94 Changed from 'scoef+=3' */\n  }\n\n  /*\n  * Generate the \"vectors of the quadrant\".\n\n\n\n           vec2              vec 1\n             <-------X------->\nclosest            /     x\n     vertex (iind)        \\ point\n\n  */\n  scoef = pcurve->ecoef;\n\n  if (iind < (nk-1))\n     s6diff(&(scoef[(iind+1)*dim]),\n            &(scoef[iind*dim]),dim,vec1);\n  if (iind > 0)\n     s6diff(&(scoef[(iind-1)*dim]),\n            &(scoef[iind*dim]),dim,vec2);\n\n  /* Generate the point - closest vertex vector. */\n  s6diff(lpoint,&(scoef[iind*dim]),dim,vecp);\n\n  /* Calculate the length of the quadrant vectors. */\n  if (iind < (nk-1)) lqua1 = s6length(vec1,dim,&kstat);\n  if (iind > 0) lqua2 = s6length(vec2,dim,&kstat);\n\n  /* Calculate the length of the projection of 'vecp' on the quadrant\n     vectors. */\n  if (iind < (nk-1)) lprj1 = s6lprj(vecp,vec1,dim);\n  if (iind > 0) lprj2 = s6lprj(vecp,vec2,dim);\n\n  /* Decide in which quadrant the point lies. */\n  if (iind == 0)\n  {\n     /* Point lies in 1. quadrant */\n\n     /* Calculate knot values of vertex */\n     svals = s6schoen(et,kk,iind);\n     svale = s6schoen(et,kk,iind+1);\n\n     /* Calculate estimated parameter values of point */\n     if (lqua1 != DZERO) (*gpos) = svals + (lprj1/lqua1)*(svale-svals);\n     else (*gpos) = svals;\n  }\n  else if (iind == (nk-1))\n  {\n     /* Point lies in 2. quadrant */\n\n     /* Calculate knot values of vertices */\n     svals = s6schoen(et,kk,iind-1);\n     svale = s6schoen(et,kk,iind);\n\n     /* Calculate estimated parameter values of point */\n     if (lqua2 != DZERO) (*gpos) = svals + ((lqua2-lprj2)/lqua2)*(svale-svals);\n     else (*gpos) = svals;\n  }\n  else if (iind > 0 && iind < (nk-1))\n  {\n     /* Evaluate 1. and 2. quadrant */\n\n      if (lprj1 > lprj2)\n      {\n           /* Point lies in 1. quadrant */\n\n           /* Calculate knot values of vertices */\n           svals = s6schoen(et,kk,iind);\n           svale = s6schoen(et,kk,iind+1);\n\n           /* Calculate estimated parameter values of point */\n           if (lqua1 != DZERO) (*gpos) = svals + (lprj1/lqua1)*(svale-svals);\n           else (*gpos) = svals;\n      }\n      else if (lprj2 > lprj1)\n      {\n           /* Point lies in 2. quadrant */\n\n           /* Calculate knot values of vertices */\n           svals = s6schoen(et,kk,iind-1);\n           svale = s6schoen(et,kk,iind);\n\n           /* Calculate estimated parameter values of point */\n           if (lqua2 != DZERO) (*gpos) = svals + ((lqua2-lprj2)/lqua2)*(svale-svals);\n           else (*gpos) = svals;\n      }\n      else\n      {\n           /* lprj1 and lprj2 are both zero or equal. */\n           /* Choose the control point itself. */\n\n           goto usvert;\n      }\n  }\n  else\n  {\n     /* Error */\n     goto usvert;\n  }\n\n  /* Check that values are within parameter plane of curve. */\n  if ((*gpos)<et[kk-1]) (*gpos)=et[kk-1];\n  else if ((*gpos)>et[nk]) (*gpos)=et[nk];\n  *jstat = 0;\n\n  /* Calculation completed.  */\n  goto out;\n\n  /* No intermediate parameter value found,\n     use parameter value of closest vertex. */\n  usvert: *jstat = 1;\n\n  /* Calculate knot value of closest vertex */\n  (*gpos) = s6schoen(et,kk,iind);\n\n  /* Check that values are within parameter plane of curve. */\n  if ((*gpos)<et[kk-1]) (*gpos)=et[kk-1];\n  else if ((*gpos)>et[nk]) (*gpos)=et[nk];\n\n  goto out;\n\n /* --------------------------------------------------------------------- */\n  /* Error in input. Dimension not equal to 1 */\n err106: *jstat = -106;\n  s6err(\"s1959\",*jstat,kpos);\n  goto out;\n\n out:\n    return;\n}\n"
  },
  {
    "path": "src/s1960.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1960.c,v 1.2 2001-03-19 15:58:58 afr Exp $\n *\n */\n#define S1960\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns1960(SISLPoint *ppoint, SISLSurf *psurf, double gpos[], int *jstat)\n#else\nvoid s1960(ppoint,psurf,gpos,jstat)\n     SISLPoint        *ppoint;\n     SISLSurf         *psurf;\n     double       gpos[];\n     int          *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Estimate parameter-pair of guess-point (used by closest point\n*              calculation).\n*\n*\n* INPUT      : ppoint   - Pointer to the point.\n*              psurf    - Pointer to the surface.\n*\n* OUTPUT     : gpos    - Parameter values of the found guess-point.\n*              jstat   - status messages  \n*                                = 0   : Guess-point found.\n*                                = 1   : Closest point as guess-point.\n*                                < 0   : error.\n*\n*\n* METHOD     : Quadrant analysis and Schoenberger equation.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Per Evensen, SI, August 1991\n* REVISED BY : Michael Floater, SI, December 1991\n*\n*********************************************************************\n*/                       \n{  \n  int kstat = 0;            /* Local status variable.                      */\n  int kpos = 0;             /* Position of error.                          */\n  int i,j;                  /* Running indexes                             */\n  int iind,jind;            /* Index variables                             */\n  int k1;                   /* The polynomial order in 1. parameter \n                               direction of the surface (psurf)            */\n  int k2;                   /* The polynomial order in 2. parameter \n                               direction of the surface (psurf)            */\n  int n1;                   /* The number of vertices in 1. parameter \n                               direction of the surface (psurf)            */\n  int n2;                   /* The number of vertices in 2. parameter \n                               direction of the surface (psurf)            */\n  int dim;                  /* Dimension of space the surface lies in      */\n  double *et1;              /* Knots in 1. parameter direction of the \n                               surface (psurf)                             */\n  double *et2;              /* Knots in 2. parameter direction of the \n                               surface (psurf)                             */\n  double *lpoint;           /* Coefficients of the point (ppoint)          */\n  double *scoef;            /* Coefficients of the surface (psurf)         */\n  double tdist;             /* Distance variable                           */\n  double tmin;              /* Minimum distance variable                   */\n  double vec1[3],vec2[3],vec3[3],vec4[3];\n                            /* Vectors defining the quadrants surrounding \n                               a vertice                                   */\n  double vecp[3];           /* Relative point vector                       */\n  double lqua1=DZERO;\n  double lqua2=DZERO;\n  double lqua3=DZERO;\n  double lqua4=DZERO;\n                            /* Length of vec1,....,vec4                    */\n  double lprj1=DZERO;\n  double lprj2=DZERO;\n  double lprj3=DZERO;\n  double lprj4=DZERO;\n                            /* Length of projection of vecp on \n                               vec1,....,vec4                              */\n  double svals,svale,tvals,tvale;\n                            /* Local start and end parameter values in s \n                               and t direction                             */\n  /* --------------------------------------------------------------------- */\n  \n  /* Test input.  */\n  if (ppoint->idim != psurf->idim || psurf->idim <= 1) goto err106;\n\n  /* Initiate local variables.  */\n  k1  = psurf->ik1;\n  k2  = psurf->ik2;\n  n1  = psurf->in1;\n  n2  = psurf->in2;\n  et1 = psurf->et1;\n  et2 = psurf->et2;\n  scoef = psurf->ecoef;\n  dim = psurf->idim;\n  lpoint = ppoint->ecoef;\n   \n  /* Find vertice closest to point.  */\n  tdist=s6dist(scoef,lpoint,dim);\n  tmin=tdist;\n  iind = 0;\n  jind = 0;\n  for (i=0; i<n1; i++)\n  {\n     for (j=0; j<n2; j++)\n     {\n        tdist=s6dist(scoef,lpoint,dim);\n        if (tdist<tmin)\n        {\n           tmin=tdist;\n           iind = i;\n           jind = j;\n        }\n        scoef+=3;\n     }\n  }\n  \n  /* \n  * Generate the \"vectors of the quadrant\".\n  \n                     I vec2\n                     l\n           vec3      l       vec 1\n             <-------X------->\nclosest            / l   x\nvertice (iind,jind)  l    \\ point\n                     I vec4\n  */\n  scoef = psurf->ecoef;\n  \n  if (iind < (n1-1))\n     s6diff(&(scoef[(iind+1)*dim+jind*dim*n1]),\n            &(scoef[iind*dim+jind*dim*n1]),dim,vec1);\n  if (jind < (n2-1))\n     s6diff(&(scoef[iind*dim+(jind+1)*dim*n1]),\n            &(scoef[iind*dim+jind*dim*n1]),dim,vec2);\n  if (iind > 0)\n     s6diff(&(scoef[(iind-1)*dim+jind*dim*n1]),\n            &(scoef[iind*dim+jind*dim*n1]),dim,vec3);\n  if (jind > 0)\n     s6diff(&(scoef[iind*dim+(jind-1)*dim*n1]),\n            &(scoef[iind*dim+jind*dim*n1]),dim,vec4);\n  \n  /* Generate the point - closest vertice vector. */\n  s6diff(lpoint,&(scoef[iind*dim+jind*dim*n1]),dim,vecp);\n     \n  /* Calculate the length of the quadrant vectors. */\n  if (iind < (n1-1)) lqua1 = s6length(vec1,dim,&kstat);\n  if (jind < (n2-1)) lqua2 = s6length(vec2,dim,&kstat);\n  if (iind > 0) lqua3 = s6length(vec3,dim,&kstat);\n  if (jind > 0) lqua4 = s6length(vec4,dim,&kstat);\n\n  /* Calculate the length of the projection of 'vecp' on the quadrant \n     vectors. */\n  if (iind < (n1-1)) lprj1 = s6lprj(vecp,vec1,dim);\n  if (jind < (n2-1)) lprj2 = s6lprj(vecp,vec2,dim);\n  if (iind > 0) lprj3 = s6lprj(vecp,vec3,dim);\n  if (jind > 0) lprj4 = s6lprj(vecp,vec4,dim);\n\n  /* Decide in which quadrant the point lies. */\n  if (iind == 0 && jind == 0)\n  {\n     /* Point lies in 1. quadrant */\n     \n     /* Calculate knot values of vertices */\n     svals = s6schoen(et1,k1,iind);\n     svale = s6schoen(et1,k1,iind+1);\n     tvals = s6schoen(et2,k2,jind);\n     tvale = s6schoen(et2,k2,jind+1);\n     \n     /* Calculate estimated parameter values of point */\n     if (lqua1 != DZERO) gpos[0] = svals + (lprj1/lqua1)*(svale-svals);\n     else gpos[0] = svals;\n     if (lqua2 != DZERO) gpos[1] = tvals + (lprj2/lqua2)*(tvale-tvals);\n     else gpos[1] = tvals;\n  }\n  else if (iind == (n1-1) && jind == 0)\n  {\n     /* Point lies in 2. quadrant */\n     \n     /* Calculate knot values of vertices */\n     svals = s6schoen(et1,k1,iind-1);\n     svale = s6schoen(et1,k1,iind);\n     tvals = s6schoen(et2,k2,jind);\n     tvale = s6schoen(et2,k2,jind+1);\n     \n     /* Calculate estimated parameter values of point */\n     if (lqua3 != DZERO) gpos[0] = svals + ((lqua3-lprj3)/lqua3)*(svale-svals);\n     else gpos[0] = svals;\n     if (lqua2 != DZERO) gpos[1] = tvals + (lprj2/lqua2)*(tvale-tvals);\n     else gpos[1] = tvals;\n  }\n  else if (iind == (n1-1) && jind == (n2-1))\n  {\n     /* Point lies in 3. quadrant */\n     \n     /* Calculate knot values of vertices */\n     svals = s6schoen(et1,k1,iind-1);\n     svale = s6schoen(et1,k1,iind);\n     tvals = s6schoen(et2,k2,jind-1);\n     tvale = s6schoen(et2,k2,jind);\n     \n     /* Calculate estimated parameter values of point */\n     if (lqua3 != DZERO) gpos[0] = svals + ((lqua3-lprj3)/lqua3)*(svale-svals);\n     else gpos[0] = svals;\n     if (lqua4 != DZERO) gpos[1] = tvals + ((lqua4-lprj4)/lqua4)*(tvale-tvals);\n     else gpos[1] = tvals;\n  }\n  else if (iind == 0 && jind == (n2-1))\n  {\n     /* Point lies in 4. quadrant */\n     \n     /* Calculate knot values of vertices */\n     svals = s6schoen(et1,k1,iind);\n     svale = s6schoen(et1,k1,iind+1);\n     tvals = s6schoen(et2,k2,jind-1);\n     tvale = s6schoen(et2,k2,jind);\n     \n     /* Calculate estimated parameter values of point */\n     if (lqua1 != DZERO) gpos[0] = svals + (lprj1/lqua1)*(svale-svals);\n     else gpos[0] = svals;\n     if (lqua4 != DZERO) gpos[1] = tvals + ((lqua4-lprj4)/lqua4)*(tvale-tvals);\n     else gpos[1] = tvals;\n  }\n  else if (iind > 0 && iind < (n1-1) && jind == 0)\n  {\n     /* Evaluate 1. and 2. quadrant */\n     \n     if (lprj1 > lprj3)\n        {\n           /* Point lies in 1. quadrant */\n           \n           /* Calculate knot values of vertices */\n           svals = s6schoen(et1,k1,iind);\n           svale = s6schoen(et1,k1,iind+1);\n           tvals = s6schoen(et2,k2,jind);\n           tvale = s6schoen(et2,k2,jind+1);\n           \n           /* Calculate estimated parameter values of point */\n           if (lqua1 != DZERO) gpos[0] = svals + (lprj1/lqua1)*(svale-svals);\n           else gpos[0] = svals;\n           if (lqua2 != DZERO) gpos[1] = tvals + (lprj2/lqua2)*(tvale-tvals);\n           else gpos[1] = tvals;\n        }\n        else if (lprj3 > lprj1)\n        {\n           /* Point lies in 2. quadrant */\n           \n           /* Calculate knot values of vertices */\n           svals = s6schoen(et1,k1,iind-1);\n           svale = s6schoen(et1,k1,iind);\n           tvals = s6schoen(et2,k2,jind);\n           tvale = s6schoen(et2,k2,jind+1);\n           \n           /* Calculate estimated parameter values of point */\n           if (lqua3 != DZERO) gpos[0] = svals + ((lqua3-lprj3)/lqua3)*(svale-svals);\n           else gpos[0] = svals;\n           if (lqua2 != DZERO) gpos[1] = tvals + (lprj2/lqua2)*(tvale-tvals);\n           else gpos[1] = tvals;\n        }\n        else\n        {\n           /* lprj1 and lprj3 are equal. */\n           /* Choose original control point. */\n           goto usvert;\n        }\n  }\n  else if (iind == (n1-1) && jind > 0 && jind < (n2-1))\n  {\n     /*  Evaluate 2. and 3. quadrant */\n     \n     if (lprj2 > lprj4)\n        {\n           /* Point lies in 2. quadrant */\n           \n           /* Calculate knot values of vertices */\n           svals = s6schoen(et1,k1,iind-1);\n           svale = s6schoen(et1,k1,iind);\n           tvals = s6schoen(et2,k2,jind);\n           tvale = s6schoen(et2,k2,jind+1);\n           \n           /* Calculate estimated parameter values of point */\n           if (lqua3 != DZERO) gpos[0] = svals + ((lqua3-lprj3)/lqua3)*(svale-svals);\n           else gpos[0] = svals;\n           if (lqua2 != DZERO) gpos[1] = tvals + (lprj2/lqua2)*(tvale-tvals);\n           else gpos[1] = tvals;\n        }\n        else if (lprj4 > lprj2)\n        {\n           /* Point lies in 3. quadrant */\n           \n           /* Calculate knot values of vertices */\n           svals = s6schoen(et1,k1,iind-1);\n           svale = s6schoen(et1,k1,iind);\n           tvals = s6schoen(et2,k2,jind-1);\n           tvale = s6schoen(et2,k2,jind);\n           \n           /* Calculate estimated parameter values of point */\n           if (lqua3 != DZERO) gpos[0] = svals + ((lqua3-lprj3)/lqua3)*(svale-svals);\n           else gpos[0] = svals;\n           if (lqua4 != DZERO) gpos[1] = tvals + ((lqua4-lprj4)/lqua4)*(tvale-tvals);\n           else gpos[1] = tvals;\n        }\n        else\n        {\n           /* lprj2 and lprj4 are equal. */\n           /* Choose original control point. */\n           goto usvert;\n        }\n  }\n  else if (iind > 0 && iind < (n1-1) && jind == (n2-1))\n  {\n     /*  Evaluate 3. and 4. quadrant */\n     \n     if (lprj3 > lprj1)\n        {\n           /* Point lies in 3. quadrant */\n           \n           /* Calculate knot values of vertices */\n           svals = s6schoen(et1,k1,iind-1);\n           svale = s6schoen(et1,k1,iind);\n           tvals = s6schoen(et2,k2,jind-1);\n           tvale = s6schoen(et2,k2,jind);\n           \n           /* Calculate estimated parameter values of point */\n           if (lqua3 != DZERO) gpos[0] = svals + ((lqua3-lprj3)/lqua3)*(svale-svals);\n           else gpos[0] = svals;\n           if (lqua4 != DZERO) gpos[1] = tvals + ((lqua4-lprj4)/lqua4)*(tvale-tvals);\n           else gpos[1] = tvals;\n        }\n        else if (lprj1 > lprj3)\n        {\n           /* Point lies in 4. quadrant */\n           \n           /* Calculate knot values of vertices */\n           svals = s6schoen(et1,k1,iind);\n           svale = s6schoen(et1,k1,iind+1);\n           tvals = s6schoen(et2,k2,jind-1);\n           tvale = s6schoen(et2,k2,jind);\n           \n           /* Calculate estimated parameter values of point */\n           if (lqua1 != DZERO) gpos[0] = svals + (lprj1/lqua1)*(svale-svals);\n           else gpos[0] = svals;\n           if (lqua4 != DZERO) gpos[1] = tvals + ((lqua4-lprj4)/lqua4)*(tvale-tvals);\n           else gpos[1] = tvals;\n        }\n        else\n        {\n           /* lprj1 and lprj3 are equal. */\n           /* Choose original control point. */\n           goto usvert;\n        }\n  }\n  else if (iind == 0 && jind > 0 && jind < (n2-1))\n  {\n     /*  Evaluate 4. and 1. quadrant */\n     \n     if (lprj2 > lprj4)\n        {\n           /* Point lies in 1. quadrant */\n           \n           /* Calculate knot values of vertices */\n           svals = s6schoen(et1,k1,iind);\n           svale = s6schoen(et1,k1,iind+1);\n           tvals = s6schoen(et2,k2,jind);\n           tvale = s6schoen(et2,k2,jind+1);\n           \n           /* Calculate estimated parameter values of point */\n           if (lqua1 != DZERO) gpos[0] = svals + (lprj1/lqua1)*(svale-svals);\n           else gpos[0] = svals;\n           if (lqua2 != DZERO) gpos[1] = tvals + (lprj2/lqua2)*(tvale-tvals);\n           else gpos[1] = tvals;\n        }\n        else if (lprj4 > lprj2)\n        {\n           /* Point lies in 4. quadrant */\n           \n           /* Calculate knot values of vertices */\n           svals = s6schoen(et1,k1,iind);\n           svale = s6schoen(et1,k1,iind+1);\n           tvals = s6schoen(et2,k2,jind-1);\n           tvale = s6schoen(et2,k2,jind);\n           \n           /* Calculate estimated parameter values of point */\n           if (lqua1 != DZERO) gpos[0] = svals + (lprj1/lqua1)*(svale-svals);\n           else gpos[0] = svals;\n           if (lqua4 != DZERO) gpos[1] = tvals + ((lqua4-lprj4)/lqua4)*(tvale-tvals);\n           else gpos[1] = tvals;\n        }\n        else\n        {\n           /* lprj2 and lprj4 are equal. */\n           /* Choose original control point. */\n           goto usvert;\n        }\n  }\n  else if (iind > 0 && iind < (n1-1) && jind > 0 && jind < (n2-1))\n  {\n     /* Evaluate all four quadrants */\n     \n     if (lprj1 > lprj3)\n        {\n           /* Point lies in 1. or 4. quadrant */\n           \n           /* Calculate knot values of vertices */\n           svals = s6schoen(et1,k1,iind);\n           svale = s6schoen(et1,k1,iind+1);\n           \n           /* Calculate estimated parameter values of point */\n           if (lqua1 != DZERO) gpos[0] = svals + (lprj1/lqua1)*(svale-svals);\n           else gpos[0] = svals;\n        }\n        else if (lprj3 > lprj1)\n        {\n           /* Point lies in 2. or 3. quadrant */\n           \n           /* Calculate knot values of vertices */\n           svals = s6schoen(et1,k1,iind-1);\n           svale = s6schoen(et1,k1,iind);\n           \n           /* Calculate estimated parameter values of point */\n           if (lqua3 != DZERO) gpos[0] = svals + ((lqua3-lprj3)/lqua3)*(svale-svals);\n           else gpos[0] = svals;\n        }\n        else\n        {\n           /* lprj1 and lprj3 are equal. */\n           /* Choose original control point. */\n           gpos[0] = s6schoen(et1,k1,iind);\n        }\n\n\n        if (lprj2 > lprj4)\n        {\n           /* Point lies in 1. or 2. quadrant */\n           \n           /* Calculate knot values of vertices */\n           tvals = s6schoen(et2,k2,jind);\n           tvale = s6schoen(et2,k2,jind+1);\n           \n           if (lqua2 != DZERO) gpos[1] = tvals + (lprj2/lqua2)*(tvale-tvals);\n           else gpos[1] = tvals;\n        }\n\n\n        else if (lprj4 > lprj2)\n        {\n           /* Point lies in 3. or 4. quadrant */\n           \n           /* Calculate knot values of vertices */\n           tvals = s6schoen(et2,k2,jind-1);\n           tvale = s6schoen(et2,k2,jind);\n           \n           if (lqua4 != DZERO) gpos[1] = tvals + ((lqua4-lprj4)/lqua4)*(tvale-tvals);\n           else gpos[1] = tvals;\n        }\n        else\n        {\n           /* lprj2 and lprj4 are equal. */\n           /* Choose original control point. */\n           gpos[1] = s6schoen(et2,k2,jind);\n        }\n  }\n  else\n  {\n     /* Error */\n     goto usvert;\n  }\n  \n  /* Check that values are within parameter plane of surface. */\n  if (gpos[0]<et1[k1-1]) gpos[0]=et1[k1-1];\n  else if (gpos[0]>et1[n1]) gpos[0]=et1[n1];\n  if (gpos[1]<et2[k2-1]) gpos[1]=et2[k2-1];\n  else if (gpos[1]>et2[n2]) gpos[1]=et2[n2];\n  *jstat = 0;\n  \n  /* Calculation completed.  */\n  goto out;\n  \n  /* No intermediate parameter values found,\n     use parameter values of closest vertice */\n  usvert: *jstat = 1;\n           \n  /* Calculate knot values of closest vertice */\n  gpos[0] = s6schoen(et1,k1,iind);\n  gpos[1] = s6schoen(et2,k2,jind);\n\n  /* Check that values are within parameter plane of surface. */\n  if (gpos[0]<et1[k1-1]) gpos[0]=et1[k1-1];\n  else if (gpos[0]>et1[n1]) gpos[0]=et1[n1];\n  if (gpos[1]<et2[k2-1]) gpos[1]=et2[k2-1];\n  else if (gpos[1]>et2[n2]) gpos[1]=et2[n2];\n  goto out;                  \n  \n /* --------------------------------------------------------------------- */ \n  /* Error in input. Dimension not equal to 1 */\n err106: *jstat = -106;\n  s6err(\"s1960\",*jstat,kpos);\n  goto out;   \n  \n out:\n    return;\n}\n\n"
  },
  {
    "path": "src/s1961.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1961\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1961(double ep[],int im,int idim,int ipar,double epar[],\n\t   double eeps[],int ilend,int irend,int iopen,double afctol,\n\t   int itmax,int ik,SISLCurve **rc,double emxerr[],\n\t   int *jstat)\n#else\nvoid s1961(ep,im,idim,ipar,epar,eeps,ilend,irend,iopen,afctol,\n           itmax,ik,rc,emxerr,jstat)\n     double ep[];\n     int    im;\n     int    idim;\n     int    ipar;\n     double epar[];\n     double eeps[];\n     int    ilend;\n     int    irend;\n     int    iopen;\n     double afctol;\n     int    itmax;\n     int    ik;\n     SISLCurve  **rc;\n     double emxerr[];\n     int    *jstat;\n#endif\n/*\n************************************************************\n*\n* Purpose: To compute a spline-approximation to the data given by the\n*          points ep, and represent it as a B-spline curve with\n*          parameterization determined by the parameter ipar.\n*          The approximation is determined by first forming the piecewise\n*          linear interpolant to the data, and then performing knot\n*          removal on this initial approximation.\n*\n* Input :\n*        Ep     - Array (length idim*im) containing the points to\n*                 be approximated.\n*        Im     - The no. of data points.\n*        Idim   - The dimension of the euclidean space in which the data\n*                 points lie, i.e. the number of components of each data point.\n*        Ipar   - Flag indicating the type of parameterization to be used:\n*                  = 1 : Paramterize by accumulated cord length.\n*                        (Arc length parametrization for the piecewise\n*                        linear interpolant.)\n*                  = 2 : Uniform parameterization.\n*                  = 3 : Parametrization given by epar.\n*                 If ipar<1 or ipar>3, it will be set to 1.\n*        Epar   - Array (length im) containing a parametrization\n*                 of the given data.\n*        Eeps   - Array (length idim) containing the tolerance to be\n*                 used during the data reduction stage. The final\n*                 approximation to the data will deviate less than eeps\n*                 from the piecewise linear interpolant in each of the\n*                 idim components.\n*        Ilend  - The no. of derivatives that are not allowed to change\n*                 at the left end of the curve.\n*                 The (0 - (ilend-1)) derivatives will be kept fixed.\n*                 If ilend <0, this routine will set it to 0.\n*                 If ilend<ik, this routine will set it to ik.\n*        Irend  - The no. of derivatives that are not allowed to change\n*                 at the right end of the curve.\n*                 The (0 - (irend-1)) derivatives will be kept fixed.\n*                 If irend <0, this routine will set it to 0.\n*                 If irend<ik, this routine will set it to ik.\n*        iopen  - Open/closed parameter.\n*                        =  1 : Produce open curve.\n*                        =  0 : Produce closed, non-periodic curve.\n*                        = -1 : Produce closed, periodic curve.\n*                 If a closed or periodic curve is to be produced and the\n*                 start- and endpoint is more distant than the length of\n*                 the tolerance, a new point is added. Note that if the\n*                 parametrization is given as input, the parametrization\n*                 if the last point will be arbitrary.\n*        Afctol = Number indicating how the tolerance is to be shared\n*                 between the two data reduction stages. For the linear\n*                 reduction, a tolerance of afctol*eeps will be used,\n*                 while a tolerance of (1-afctol)*eeps will be used\n*                 during the final data reduction. (Similarly for edgeps.)\n*        Itmax  - Max. no. of iterations in the data-reduction routine.\n*        Ik     - The polynomial order of the approximation.\n*\n* Output:\n*        Jstat  - Output staus:\n*                  < 0 : Error.\n*                  = 0 : Ok.\n*                  > o : Warning.\n*        Rc     - Pointer to curve.\n*        Emxerr - Array (length idim) (allocated outside this routine.)\n*                 containing for each component an upper bound on the\n*                 max. deviation of the final approximation from the\n*                 initial piecewise linear interpolant.\n*\n* Method: First the piecewise linear interpoolant is computed by a call\n*         to s1350 or s1351, and then knots are removed from this\n*         interpolant. The degree of the resulting linear spline is then\n*         raised to ik, and a second data-reduction is performed.\n*\n* Written by: C.R.Birkeland  Si  Oslo,Norway April 1993.\n* Changed and renamed by : Vibeke Skytt, SINTEF Oslo, 02.95. Introduced\n*                                                            periodicity.\n********************************************************************\n*/\n{\n  double *maxerr = SISL_NULL;    /* Arrays used to store error estimates */\n  double *error1 = SISL_NULL;\n  int i;\n  int stat = 0;             /* Loop control variables               */\n  int kpos = 0;\n  SISLCurve *ocurve = SISL_NULL; /* Local spline curve                   */\n  double *sp = SISL_NULL;        /* Extended data points in closed/periodic case. */\n  double *spar = SISL_NULL;      /* Extended par. values.                */\n  \n  /* Check Input */\n  \n  if (im < 2 || idim < 1) goto err103;\n  if (ipar < 1 || ipar > 3) ipar = 1;\n\n  if ((iopen == 0 || iopen == -1) &&\n      s6dist(ep, ep+(im-1)*idim, idim) > s6length(eeps, idim, &stat))\n  {\n     /* Add an extra point to the input points. First allocated scratch\n\tfor extended arrays. */\n     \n     if ((sp = newarray((im+1)*idim, DOUBLE)) == SISL_NULL) goto err101;\n     memcopy(sp, ep, im*idim, DOUBLE);\n     memcopy(sp+im*idim, ep, idim, DOUBLE);\n     if (ipar == 3)\n     {\n\tif ((spar = newarray(im+1, DOUBLE)) == SISL_NULL) goto err101;\n\tmemcopy(spar, epar, im, DOUBLE);\n\tspar[im] = spar[im-1] + s6dist(sp+(im-1)*idim, sp+im*idim, idim);\n     }\n  }\n  else \n  {\n     sp = ep;\n     spar = epar;\n  }\n  \n  /* Set default value for afctol */\n\n  if(afctol < 0 || afctol > 1) afctol =0;\n\n  /* Piecewise linear interpolant to the data */\n\n  if (ipar == 3)\n    s1350(sp, spar, im, idim, 2, &ocurve, &stat);\n  else\n    s1351(sp, ipar, im, idim, 2, &ocurve, &stat);\n  if (stat<0) goto error;\n\n  /* Compute tolerance for linear reduction */\n\n  error1 = newarray(idim, DOUBLE);\n  maxerr = newarray(idim, DOUBLE);\n  if (error1 == SISL_NULL || maxerr == SISL_NULL) goto err101;\n  for (i=0; i<idim; i++)\n    maxerr[i] = eeps[i]*afctol;\n\n  /* Data reduction on piecewise linear interpolant */\n\n  s1940(ocurve, maxerr, ilend, irend, iopen, itmax, rc,\n\terror1, &stat);\n  if (stat<0) goto error;\n  freeCurve(ocurve);\n\n  /* Piecewise linear interpolant to the reduced data \n     (coefficients of linear spline curve rc)\n     expressed as B-spline of order ik */\n\n  s1350((*rc)->ecoef, &((*rc)->et)[1], (*rc)->in, \n\tidim, ik, &ocurve, &stat);\n  if (stat<0) goto error;\n  freeCurve(*rc);\n  \n  /* Compute tolerance for last reduction */\n\n  for (i=0; i<idim; i++)\n    maxerr[i] = eeps[i] - error1[i];\n\n  /* Perform data reduction on the hermite interpolant */\n\n  s1940(ocurve, maxerr, ilend, irend, iopen, itmax, rc,\n\temxerr, &stat);\n  if (stat<0) goto error;\n\n  /* Compute total error after reduction */\n\n  for (i=0; i<idim; i++)\n    emxerr[i] += error1[i];\n  \n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation.  */\n\n  err101 :\n     *jstat = -101;\n  s6err(\"s1961\",*jstat,kpos);\n  goto out;\n\n  /* Error in input */\n\n err103: \n  *jstat = -103;\n  s6err(\"s1961\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine. */\n\n error:\n  *jstat = stat;\n  s6err(\"s1961\",*jstat,kpos);\n  goto out;\n\n  /* Exit */\n\n out:\n  if (maxerr != SISL_NULL) freearray(maxerr);\n  if (error1 != SISL_NULL) freearray(error1);\n  if (ocurve != SISL_NULL) freeCurve(ocurve);\n  if (spar != SISL_NULL && spar != epar) freearray(spar);\n  if (sp != SISL_NULL && sp != ep) freearray(sp);\n  return;\n}\n"
  },
  {
    "path": "src/s1962.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S1962\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1962(double ep[],double ev[],int im,int idim,int ipar,double epar[],\n\t   double eeps[],int ilend,int irend,int iopen,int itmax,\n\t   SISLCurve **rc,double emxerr[],int *jstat)\n#else\nvoid s1962(ep,ev,im,idim,ipar,epar,eeps,ilend,irend,iopen,itmax,\n           rc,emxerr,jstat)\n     double ep[];\n     double ev[];\n     int    im;\n     int    idim;\n     int    ipar;\n     double epar[];\n     double eeps[];\n     int    ilend;\n     int    irend;\n     int    iopen;\n     int    itmax;\n     SISLCurve  **rc;\n     double emxerr[];\n     int    *jstat;\n#endif\n/*\n***********************************************************\n*\n* Purpose: To compute the approximation to the data given by the points\n*          ep and the derivatives (tangents) ev, and represent it as a\n*          B-spline curve with parametrization determined by the parameter\n*          ipar. The approximation is determined by first forming the cubic\n*          hermite interpolant to the data, and then performing knot\n*          removal on this initial approximation.\n*\n* Input :\n*         Ep     - Array (length idim*im) comtaining the points\n*                  to be approximated.\n*         Ev     - Array (length idim*im) containing the derivatives\n*                  of the points to be approximated.\n*         Im     - The no. of data points.\n*         Idim   - The dimension of the euclidean space in which the\n*                  curve lies.\n*         Ipar   - Flag indicating the type of paramterization to be used.\n*                   = 1 : Parametrize by accumulated cord length (arc\n*                         length parameterization for the piecewise\n*                         linear interpolant.)\n*                   = 2 : Uniform parametrization.\n*                   = 3 : parameterization given by epar.\n*                  If ipar<1 or ipar>3, it will be set to 1.\n*         Epar   - Array (length im) containing a parameterization\n*                  of the given data.\n*         Eeps   - Array (length idim) giving the desired accuracy of\n*                  the spline-approximation in each component.\n*         Ilend  - The no. of derivatives that are not allowed to change\n*                  at the left end of the curve.\n*                  The (0 - (ilend-1)) derivatives will be kept fixed.\n*                  If ilend <0, this routine will set it to 0.\n*                  If ilend<ik, this routine will set it to ik.\n*         Irend  - The no. of derivatives that are not allowed to change\n*                  at the right end of the curve.\n*                  The (0 - (irend-1)) derivatives will be kept fixed.\n*                  If irend <0, this routine will set it to 0.\n*                  If irend<ik, this routine will set it to ik.\n*        iopen   - Open/closed parameter.\n*                        =  1 : Produce open curve.\n*                        =  0 : Produce closed, non-periodic curve.\n*                        = -1 : Produce closed, periodic curve.\n*                  If a closed or periodic curve is to be produced and the\n*                  start- and endpoint is more distant than the length of\n*                  the tolerance, a new point is added. Note that if the\n*                  parametrization is given as input, the parametrization\n*                  if the last point will be arbitrary.\n*         Itmax  - Max. no. of iteration.\n* Output:\n*         Jstat  - Output status:\n*                   < 0 : Error.\n*                   = 0 : Ok.\n*                   > 0 : Warning:\n*         Rc     - Pointer to curve.\n*         Emxerr - Array (length idim) (allocated outside this routine.)\n*                  containing an upper bound for the pointwise error\n*                  in each of the components of the spline-approximation.\n*-\n* Method: First the cubic hermite interpolant is computed by a call\n*         to s1379 or s1380, and then knots are removed from this\n*         interpolant.\n*\n* Calls: s1379, s1380, s1940, s6err.\n*\n* Written by: C.R. Birkeland, Si, April 1993.\n* Changed and renamed by : Vibeke Skytt, SINTEF Oslo, 02.95. \n*                          Introduced periodicity.\n**********************************************************\n*/\n{\n  int stat = 0;                /* Error control parameters         */\n  int kpos = 0;\n  SISLCurve *ocurve = SISL_NULL;    /* Local spline curve               */\n  double *sp = SISL_NULL;        /* Extended data points in closed/periodic case. */\n  double *sv = SISL_NULL;        /* Extended tangents in closed/periodic case. */\n  double *spar = SISL_NULL;      /* Extended par. values.                */\n\n  /* Check Input */\n\n  if (im < 2 || idim < 1) goto err103;\n  if (ipar < 1 || ipar > 3) ipar = 1;\n\n  if ((iopen == 0 || iopen == -1) &&\n      s6dist(ep, ep+(im-1)*idim, idim) > s6length(eeps, idim, &stat))\n  {\n     /* Add an extra point to the input points. First allocated scratch\n\tfor extended arrays. */\n     \n     if ((sp = newarray((im+1)*idim, DOUBLE)) == SISL_NULL) goto err101;\n     memcopy(sp, ep, im*idim, DOUBLE);\n     memcopy(sp+im*idim, ep, idim, DOUBLE);\n     \n     if ((sv = newarray((im+1)*idim, DOUBLE)) == SISL_NULL) goto err101;\n     memcopy(sv, ev, im*idim, DOUBLE);\n     memcopy( sv+im*idim, ev, idim, DOUBLE);\n     \n     if (ipar == 3)\n     {\n\tif ((spar = newarray(im+1, DOUBLE)) == SISL_NULL) goto err101;\n\tmemcopy(spar, epar, im, DOUBLE);\n\tspar[im] = spar[im-1] + s6dist(sp+(im-1)*idim, sp+im*idim, idim);\n     }\n  }\n  else \n  {\n     sp = ep;\n     sv = ev;\n     spar = epar;\n  }\n  \n  /* Compute hermite interpolant */\n\n  if (ipar == 3)\n    s1379(sp, sv, spar, im, idim, &ocurve, &stat);\n  else\n    s1380(sp, sv, im, idim, ipar, &ocurve, &stat);\n  if (stat < 0) goto error;\n\n  /* Perform data reduction on the cubic hermite interpolant */\n\n  s1940(ocurve, eeps, ilend, irend, iopen, itmax, rc,\n\temxerr, &stat);\n  if (stat < 0) goto error;\n\n  /* Success */\n\n  *jstat = 0;\n  goto out;\n  \n  /* Error in scratch allocation. */\n  \n  err101:\n     *jstat = -101;\n  s6err(\"s1962\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input */\n\n err103: \n  *jstat = -103;\n  s6err(\"s1962\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine. */\n\n error: \n  *jstat = stat;\n  s6err(\"s1962\",*jstat,kpos);\n  goto out;\n\n  /* Exit */\n\n out:\n  if (ocurve != SISL_NULL) freeCurve(ocurve);\n  if (spar != SISL_NULL && spar != epar) freearray(spar);\n  if (sp != SISL_NULL && sp != ep) freearray(sp);\n  if (sv != SISL_NULL && sv != ev) freearray(sv);\n  return;\n}\n"
  },
  {
    "path": "src/s1963.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1963\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1963(SISLCurve *pc,double eeps[],int ilend,int irend,int iopen, \n\t   int itmax, SISLCurve **rc,int *jstat)\n#else\nvoid s1963(pc,eeps,ilend,irend,iopen,itmax,rc,jstat)\n     SISLCurve  *pc;\n     double eeps[];\n     int    ilend;\n     int    irend;\n     int    iopen;\n     int    itmax;\n     SISLCurve  **rc;\n     int    *jstat;\n#endif\n/*\n***********************************************************\n*\n* Purpose: To approximate the input spline-curve by a cubic spline-\n*          curve with error less than eeps in each of the kdim components.\n*\n* Input :\n*         Pc     - Pointer to curve.\n*         Eeps   - Array (length kdim) giving the desired accuracy of\n*                  the spline-approximation in each component.\n*         Ilend  - The no. of derivatives that are not allowed to change\n*                  at the left end of the curve.\n*                  The (0 - (ilend-1)) derivatives will be kept fixed.\n*                  If ilend <0, this routine will set it to 0.\n*                  If ilend<kord, this routine will set it to kord.\n*         Irend  - The no. of derivatives that are not allowed to change\n*                  at the right end of the curve.\n*                  The (0 - (irend-1)) derivatives will be kept fixed.\n*                  If irend <0, this routine will set it to 0.\n*                  If irend<kord, this routine will set it to kord.\n*         iopen  - Open/closed parameter.\n*                        =  1 : Produce open curve.\n*                        =  0 : Produce closed, non-periodic curve if possible.\n*                        = -1 : Produce closed, periodic curve if possible.\n*         Itmax  - Max. no. of iterations.\n*\n* Output:\n*         Jstat  - Output status:\n*                   < 0 : Error.\n*                   = 0 : Ok.\n*                   > 0 : Warning:\n*         Rc     - Pointer to curve.\n*-\n* Method: First sampling points on the input-curve are determined such\n*         that the cubic hermite spline interpolant to these points will\n*         deviate with less than half the tolerance from the input-spline,\n*         and this hermite spline interpolant is run through data\n*         reduction to reduce the no. of knots.\n*\n* Calls: s1379, s1940, s1355, s6err\n*\n* Written by: C.R. Birkeland, Si, April 1993.\n* Changed and renamed by : Vibeke Skytt, SINTEF Oslo, 02.95. \n*                          Introduced periodicity.\n**********************************************************\n*/\n{\n  int i,j;                   /* Loop control variables           */\n  int index = 0;\n  int idim = pc->idim;       /* Space dimension                  */\n  int stat = 0;              /* Error control parameters         */\n  int kpos = 0;\n  int km;\n  int leftknot = 0;\n  double *error1 = SISL_NULL;\n  double *error2 = SISL_NULL;\n  double *epar = SISL_NULL;\n  double *derive = SISL_NULL;\n  double *kp = SISL_NULL;\n  double *kder = SISL_NULL;\n  SISLCurve *ocurve = SISL_NULL;\n  \n  \n  /* Check input-curve. */\n\n  if (!pc) goto err150;\n  s1707(pc, &stat);\n  if (stat<0) goto error;\n  \n  /* Check input */\n\n  if (pc->in < pc->ik || pc->ik < 1 || idim < 1) goto err103;\n  if (pc->ik < 5)\n    { \n      /* Increase order of curve to 4 (cubic) */\n\n      s1750(pc, 4, &ocurve, &stat);\n      if (stat < 0) goto error;\n\n      /* Curve is now a cubic spline \n       * Call reduction routine      */\n\n      if( (error2 = newarray( idim, DOUBLE )) == SISL_NULL) goto err101;\n      s1940( ocurve, eeps, ilend, irend, iopen, itmax, rc, \n\t    error2, &stat);\n      if (stat < 0) goto error;\n\n      /* Success !  Go out ! */\n\n      goto out;\n    }\n\n  /* Set local tolerance */\n\n  if( (error1 = newarray(idim, DOUBLE)) == SISL_NULL) goto err101;\n\n  for (i=0; i<idim; i++)\n    error1[i] = 0.5*eeps[i];\n\n  /* Determine the sample points */\n\n  s1355( pc, error1, &epar, &km, &stat );\n  if (stat < 0) goto error;\n\n  /* Compute positions and derivatives of input spline\n   * at the given sampling points                      */\n\n  derive = newarray( idim * 2, DOUBLE );\n  kp     = newarray( idim * km, DOUBLE );\n  kder   = newarray( idim * km, DOUBLE );\n  if (derive == SISL_NULL || kp == SISL_NULL || kder == SISL_NULL) goto err101;\n\n  for(i=0; i<km; i++)\n    {\n      if(i<km-1 && epar[i] == epar[i+1])\n\ts1227( pc, 1, epar[i], &leftknot, derive, &stat );\n      else\n\ts1221( pc, 1, epar[i], &leftknot, derive, &stat );\n\n      for(j=0; j<idim; j++, index++)\n\t{\n\t  kp[index] = derive[j];\n\t  kder[index] = derive[j+idim];\n\t}\n    }\n  if (stat < 0) goto error;\n\n  /* Compute Hermite interpolant */\n\n  s1379( kp, kder, epar, km, idim, &ocurve, &stat );\n  if (stat < 0) goto error;\n\n  /* Compute datareduction on the cubic hermite interpolant */\n\n  if( (error2 = newarray( idim, DOUBLE )) == SISL_NULL) goto err101;\n  s1940( ocurve, error1, ilend, irend, iopen, itmax, rc, \n\terror2, &stat);\n  if (stat < 0) goto error;\n\n  /* Success ! */\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Allocation error. */\n\n err101: \n   *jstat = -101;\n   s6err(\"s1963\",*jstat,kpos);\n   goto out;\n  \n  /* Error in input */\n\n  err103: \n    *jstat = -103; \n    s6err(\"s1963\",*jstat,kpos);\n    goto out;\n  \n  /* Empty curve. */\n\n  err150: \n    *jstat = -150;\n    s6err(\"s1963\",*jstat,kpos);\n    goto out;\n  \n  /* Error in lower level routine. */\n\n  error: \n    *jstat = stat;\n    s6err(\"s1963\",*jstat,kpos);\n    goto out;\n\n  /* Exit */\n\n  out:\n    /* Free allocated arrays */\n\n    if( error1 != SISL_NULL) freearray(error1);\n    if( error2 != SISL_NULL) freearray(error2);\n    if( epar   != SISL_NULL) freearray(epar);\n    if( derive != SISL_NULL) freearray(derive);\n    if( kp     != SISL_NULL) freearray(kp);\n    if( kder   != SISL_NULL) freearray(kder);\n\n    /* Free local SISL-curves */\n\n    if( ocurve != SISL_NULL) freeCurve(ocurve);\n\n    return;\n}\n"
  },
  {
    "path": "src/s1965.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S1965\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1965(SISLSurf *oldsurf,double eps[],int edgefix[4],int iopen1, \n\t   int iopen2,double edgeps[],int opt,int itmax,\n\t   SISLSurf **newsurf,double maxerr[],int *stat)\n#else\nvoid s1965(oldsurf, eps, edgefix, iopen1, iopen2, edgeps, opt, \n\t    itmax, newsurf,maxerr, stat)\n     SISLSurf \t*oldsurf;\n     double\teps[];\n     int\tedgefix[4];\n     int        iopen1;\n     int        iopen2;\n     double\tedgeps[];\n     int \topt;\n     int\titmax;\n     SISLSurf\t**newsurf;\n     double\tmaxerr[];\n     int\t*stat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* Purpose: To remove as many knots as possible from the surface oldsurf\n*          without perturbing the surface more than the given tolerance.\n*          The tolerances are given by eps and epsfix, while the\n*\t   approximation is given by newsurf.\n*          Mark that the error in continuity over the start and end of\n*          a closed or periodic surface is only guaranteed to be within\n*          edgeps.\n*\n*\n*\n* Input:       oldsurf - pointer to the original spline surface. Note\n*\t\t\t if the polynomial orders of the surface are\n*\t\t\t k1 and k2, then the two knot vectors are\n*\t\t\t assumed to have knots of multiplicity k1 and\n*\t\t\t k2 at the ends.\n*\n*\t       eps     - double array of length dim (the number of\n*\t\t\t components of the surface, typically three)\n*\t\t\t giving the desired accuracy of the\n*\t\t\t final approximation compared to oldcurve.\n*                        Note that in such comparisons the two\n*\t\t\t surfaces are not reparametrized in any way.\n*\n*\t       edgefix - integer array of dimension (4) giving the number\n*\t\t\t of derivatives to be kept fixed along each edge\n*\t\t\t of the surface. The numbering of the edges is the\n*\t\t\t same as for edgeps below. All the derivatives of\n*\t\t\t order < nend(i)-1 will be kept fixed along\n*\t\t\t edge i. Hence nend(i)=0 indicates that nothing is\n*\t\t\t to be kept fixed along edge i.\n*\n*                NB! TO BE KEPT FIXED HERE MEANS TO HAVE ERROR LESS THAN\n*\t\t     EDGEPS. IN GENERAL, IT IS IMPOSSIBLE TO REMOVE KNOTS\n*                    AND KEEP AN EDGE COMPLETELY FIXED.\n*\n*              iopen1  - Open/closed parameter in first parameter direction.\n*                        =  1 : Produce open surface.\n*                        =  0 : Produce closed, non-periodic surface if possible.\n*                        = -1 : Produce closed, periodic surface\n*\n*              iopen2  - Open/closed parameter in second parameter direction.\n*                        =  1 : Produce open surface.\n*                        =  0 : Produce closed, non-periodic surface if possible.\n*                        = -1 : Produce closed, periodic surface\n*\n*              edgeps  - double array of length 4*dim ([4,dim]) (dim is\n*                        the number of components of each coefficient)\n*\t\t\t containing the maximum deviation which is\n*\t\t\t acceptable along the edges of the surface.\n*                        edgeps[0]-edgeps[dim-1] gives the tolerance along\n*\t\t\t the edge corresponding to x1 (the first parameter)\n* \t\t\t having it's minimum value.\n*\t\t\t edgeps[dim]-edgeps[2*dim-1] gives the tolerance\n*\t\t\t along the edge corresponding to x1 (the first\n*\t\t\t parameter) having it's maximum value.\n*              \t\t edgeps[2*dim]-edgeps[3*dim-1] gives the tolerance\n*\t\t\t along the edge corresponding to x2 (the second\n*\t\t\t parameter) having it's minimum value.\n*              \t\t edgeps[3*dim]-edgeps[4*dim-1] gives the tolerance\n*\t\t\t along the edge corresponding to x2 (the second\n*\t\t\t parameter) having it's maximum value.\n*           \t NB! EDGEPS WILL ONLY HAVE ANY SIGNIFICANCE IF THE\n*\t\t     CORRESPONDING ELEMENT OF EDGEFIX IS POSITIVE.\n*\n*\n*\t       itmax   - maximum number of iterations. The routine will\n*                        follow an iterative procedure trying to remove\n*                        more and more knots, one direction at a time.\n*                        The process will almost always stop after less\n*                        than 10 iterations and it will often stop after\n*                        less than 5 iterations. A suitable value for itmax\n*                        is therefore usually in the region 3-10.\n*\n*\n*\t       opt     - integer indicating the order in which the\n*\t       \t         knot removal is to be performed.\n*                            = 1 - remove knots in parameter direction 1 only.\n*                            = 2 - remove knots in parameter direction 2 only.\n*                            = 3 - remove knots first in parameter direction\n*\t\t\t       1 and then 2.\n*                            = 4 - remove knots first in parameter direction\n*\t\t\t       2 and then 1.\n*\n*\n*\n*\n*\n* Output:\n*         newsurf      - the approximating surface on the reduced knot vectors.\n*\n*\t  maxerr       - double array of length dim containing an upper\n*\t\t         bound for the pointwise error in each of the\n*\t\t         components of the spline approximation. The two\n*                        surfaces oldsurf and newsurf are compared at the\n*                        same parameter vaues, i.e., if oldsurf is f and\n*                        newsurf is g then\n*                              |f(u,v)-g(u,v)| <= eps\n*                        in each of the components.\n*\n*         stat         - status message\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n*\n*\n* Method:\n*     The data reduction is performed in one parameter direction at a time,\n*     using a subroutine for data reduction for spline curves (s1940).\n*     Consider for example knot removal in the second parameter direction\n*     (suppose oldcurve has m1xm2 coefficients, each with dim components\n*     and suppose also that the knot vectors are t1 and t2).\n*     This amounts to removing knots from each of the m1*dim curves, each\n*     of length m2 and with knot vector t2, obtained by considering the\n*     coefficients d as an array of dimension [m2][dim*m1] instead\n*     of [m2][m1][dim] (note that in the code the arrays are always\n*     treated as one dimensional).\n*     A similar approach is possible when removing knots in the first parameter\n*     direction except that then d has to be transposed in the first two\n*     dimensions first.\n*     The remaining part of the subroutine is more or less obvious except\n*     perhaps the fact that if knots are to be removed in both directions,\n*     the permissible error must be halved so that the total error committed\n*     is kept within the original tolerance.\n*\n*\n* References:\n*     1. A Data-Reduction Strategy for Splines with Applications to the\n*        Approximation of Functions and data, IMA J. of Num. Anal. 8 (1988),\n*        pp. 185-208.\n*\n*     2. Knot Removal for Parametric B-spline Curves and Surfaces,\n*        CAGD 4 (1987), pp. 217-230.\n*\n*-\n* Calls: s1940, s1352, s6chpar, s6err\n*\n* Written by: Knut Moerken, University of Oslo, December 1992, based\n*             on an earlier Fortran version by the same author.\n* Changed by: Paal Fugelli, SINTEF, 1994-07.\n*             Rewritten to fix several major memory leakage problems.\n* Changed and renamed by : Vibeke Skytt, SINTEF Oslo, 02.95. Introduced\n*                                                            periodicity.\n*\n*********************************************************************\n*/\n\n{\n  int k1 = oldsurf->ik1;          /* Unwrap some of the most commonly */\n  int k2 = oldsurf->ik2;          /* used parameters.                 */\n  int m1 = oldsurf->in1;\n  int m2 = oldsurf->in2;\n  int dim = oldsurf->idim;\n  int kopen1, kopen2;\n  double *et1 = SISL_NULL;\n  double *et2 = SISL_NULL;\n\n  double *local_eps = SISL_NULL;       /* Declaration of local variables, */\n  double *local_edge_eps = SISL_NULL;  /* for usage, see the code.        */\n  double *clocal_eps = SISL_NULL;\n  double *clocal_err = SISL_NULL;\n  double *harray = SISL_NULL;\n  double *tempcoef = SISL_NULL;\n\n  double *loct1 = SISL_NULL;\n  double *loct2 = SISL_NULL;\n  SISLCurve *local_curve = SISL_NULL;\n  SISLCurve *newlcurve = SISL_NULL;\n\n  int lopt, i, it, n1, n2, antit, j, jh, lstat;\n  double factor;\n  int pos = 0;                    /* Parameter in s6err.             */\n\n\n  /* Initialize kopen1 and kopen2 to make sure that the returned\n     surface has legal open/closed parametere also if datareduction\n     only is performed in one direction. */\n  \n  kopen1 = oldsurf->cuopen_1;\n  kopen2 = oldsurf->cuopen_2;\n  \n  /* Make sure the returned surface has a valid value. */\n  (*newsurf) = SISL_NULL;\n\n  /* Unwrap the two (possibly changed) input knot vectors */\n\n  et1 = oldsurf->et1;\n  et2 = oldsurf->et2;\n\n\n  /* We start by allocating space for local arrays (any error exit must\n     now handle free'ing of allocated space). */\n\n  local_eps = newarray(dim, DOUBLE);\n  if (local_eps == SISL_NULL) goto err101;\n\n  local_edge_eps = newarray(4*dim, DOUBLE);\n  if (local_edge_eps == SISL_NULL) goto err101;\n\n  /* If we are going to remove knots in both directions, we use half the\n     tolerance each time, otherwise the whole tolerance once. This is\n     signified by factor. */\n\n  factor = (opt < 3) ? 1.0 : 0.5;\n\n  /* Store a local version of the tolerance and initialize the error\n     to zero. */\n\n  for (i=0; i<dim; i++)\n  {\n    local_eps[i] = factor*eps[i];\n    maxerr[i] = 0.0;\n  }\n\n  /* We also need a local version of the edge tolerance. */\n\n  /* Originally the edgetolerance was also multiplied by fac. It turns\n     out that this is unnecessary: Each edge is completely fixed in one\n     of the calls to s1940. */\n\n  for (i=0; i<4*dim; i++) local_edge_eps[i] = edgeps[i];\n\n  /* Now we are ready to prepare for the iterations. it counts the iterations\n     while lopt says which direction to start with and antit tells us how\n     many iterations there should be (one or two). n1 and n2 are used for\n     keeping track of the number of coefficients. */\n\n  it = 0; lopt = (opt-1) % 2 + 1;\n  n1 = m1; n2 = m2;\n\n  antit = (opt < 3) ? 1 : 2;\n  while (it < antit)\n  {\n    if (lopt == 1)\n    {\n\n      /* Here we remove knots along the first parameter direction. */\n\n      /* Since we are going to treat the surface as a collection of\n\t n2 curves in the first direction each with dim components,\n\t we need a tolerance array of length dim*n2 and a similar\n\t array for storing the error. */\n\n      clocal_eps = newarray(dim*n2, DOUBLE);\n      if (clocal_eps == SISL_NULL) goto err101;\n\n      clocal_err = newarray(dim*n2, DOUBLE);\n      if (clocal_err == SISL_NULL) goto err101;\n\n      /* The tolerance will in general not be the same for all the\n\t n2*dim curves. If edges 1 and/or 3 are to be kept fixed then\n\t first and/or last tolerance must be smaller than the tolerance\n\t for middle curves. This is accomplished by a call to s1352. */\n\n      s1352(et2, n2, k2, local_eps, (local_edge_eps+2*dim),\n\t    (local_edge_eps+3*dim), dim, edgefix[2], edgefix[3],\n\t    clocal_eps, &lstat);\n      if (lstat < 0) goto error;\n\n      /* First we have to pick out the correct coefficients.\n\t Then we must transpose the coefficient with respect to\n\t n1 and n2 due to the way we store the coefficients of\n\t surfaces. */\n\n      harray = newarray(n1*n2*dim, DOUBLE);\n      if (harray == SISL_NULL) goto err101;\n\n      if (opt == 4)\n      {\n\t/* Here tempcoef points to the coefs of the first direction. */\n\n\ts6chpar(tempcoef, n1, n2, dim, harray);\n\tfreearray(tempcoef);\n\ttempcoef = harray;\n      }\n      else\n      {\n\ts6chpar(oldsurf->ecoef, n1, n2, dim, harray);\n\ttempcoef = harray;\n      }\n      harray = SISL_NULL;\n\n      /* We then create a curve in which to store the high dimensional\n\t curve. */\n\n      local_curve = newCurve(n1, k1, oldsurf->et1, tempcoef,\n\t\t\t     1, dim*n2, 0);\n      if (local_curve == SISL_NULL) goto err101;\n      local_curve -> cuopen = oldsurf->cuopen_1;\n\n      /* We can now perform knot removal on this curve. The result\n\t is stored in newlcurve (will always have icopy==1, i.e. a\n\t proper copy). */\n\n      s1940(local_curve, clocal_eps, edgefix[0], edgefix[1], iopen1,\n\t    itmax, &newlcurve, clocal_err, &lstat);\n      if(lstat<0) goto error;\n      \n      kopen1 = newlcurve->cuopen;\n      \n      /* Remember to update n1 and throw away local_curve (has icopy==0). */\n\n      n1 = newlcurve->in;\n      freeCurve(local_curve);\n      local_curve = SISL_NULL;\n\n      /* Now we must transpose back to return to surface coeffiecients. */\n\n      tempcoef = increasearray(tempcoef,n1*n2*dim, DOUBLE);\n      if (tempcoef == SISL_NULL) goto err101;\n\n      harray = newlcurve->ecoef;\n      s6chpar(harray, n2, n1, dim, tempcoef);\n      harray = SISL_NULL;\n\n      /* We save the surface as a curve and create the final surface\n\t later. */\n\n      local_curve = newlcurve;\n      freearray(newlcurve->ecoef);\n      local_curve->ecoef = tempcoef;\n      newlcurve = SISL_NULL;\n\n      /* Now local_curve has icopy==1, so the knots and coefs are proper\n\t copies.  Must make it safe to free local_curve. */\n\n      local_curve->icopy = 0;\n\n      /* Now we can just save the new knot vector in loct1 and update the\n\t pointer to the \"input\" knot vector et1. */\n\n      loct1 = local_curve->et;\n      et1 = loct1;\n\n      /* tempcoef and loct1 are now safe from free'ing of local_curve, so\n\t throw it away. */\n\n      freeCurve(local_curve);\n      local_curve = SISL_NULL;\n\n      /* Calculate the error in the approximation. */\n\n      /* The error in component i in the approximation is simply\n\t the largest error in component i in any of the curves. */\n\n      for (i=0; i<dim; i++) clocal_eps[i] = 0.0;\n      for (jh=0, i=0; i<n2; i++)\n\tfor (j=0; j<dim; j++, jh++)\n\t  clocal_eps[j] = MAX(clocal_eps[j], clocal_err[jh]);\n\n      /* Accumulate the error in maxerr and use the remaining tolerance\n\t in the next direction. */\n\n      for (i=0; i<dim; i++)\n      {\n\tmaxerr[i] += clocal_eps[i];\n\tlocal_eps[i] = eps[i] - maxerr[i];\n      }\n      freearray(clocal_eps);\n      freearray(clocal_err);\n    }\n    else\n    {\n\n\n      /* Now we are to remove knots in the second direction. This is\n\t very similar to removing knots in the first direction but\n\t we do not need to transpose. */\n\n      /* First some local arrays. */\n\n      clocal_eps = newarray(dim*n1, DOUBLE);\n      if (clocal_eps == SISL_NULL) goto err101;\n\n      clocal_err = newarray(dim*n1, DOUBLE);\n      if (clocal_err == SISL_NULL) goto err101;\n\n      /* Compute a tolerance along the second direction. */\n\n      s1352(et1, n1, k1, local_eps, local_edge_eps,\n\t    local_edge_eps+dim, dim, edgefix[0], edgefix[1],\n\t    clocal_eps, &lstat);\n      if (lstat < 0) goto error;\n\n      /* Generate a high dimensional curve along the second direction\n\t with the right coefficients. */\n\n      if (opt == 3)\n      {\n\t/* Here tempcoef points to the coefs of the first direction. */\n\tlocal_curve = newCurve(n2, k2, oldsurf->et2, tempcoef,\n\t\t\t       1, dim*n1, 0);\n      }\n      else\n\tlocal_curve = newCurve(n2, k2, oldsurf->et2, oldsurf->ecoef, 1,\n\t\t\t       dim*n1, 0);\n      if (local_curve == SISL_NULL) goto err101;\n      local_curve->cuopen = oldsurf->cuopen_2;\n\n      /* Remove knots and store in newlcurve (will always get icopy==1, i.e.\n\t proper copy. */\n\n      s1940(local_curve, clocal_eps, edgefix[2], edgefix[3], iopen2,\n\t    itmax, &newlcurve, clocal_err, &lstat);\n      if(lstat<0) goto error;\n      \n      kopen2 = newlcurve->cuopen;\n\n      /* Remember to update n2. */\n\n      n2 = newlcurve->in;\n\n      /* Throw away the old local_curve which has icopy==0 (must throw away\n\t tempcoef too -- non-null if opt==3), but keep newlcurve. */\n\n      freeCurve(local_curve);\n      if (tempcoef != SISL_NULL) freearray(tempcoef);\n      local_curve = newlcurve;\n      newlcurve = SISL_NULL;\n\n      /* Now local_curve has icopy==1, so the knots and coefs are proper\n\t copies.  Must make it safe to free local_curve. */\n\n      local_curve->icopy = 0;\n      tempcoef = local_curve->ecoef;\n\n      /* The new knot vector in the second direction will be stored in\n\t loct2 so we must update the pointer to the \"input\" knot vector et2. */\n\n      loct2 = local_curve->et;\n      et2 = loct2;\n\n      /* tempcoef and loct2 are now safe from free'ing of local_curve, so\n\t throw it away. */\n\n      freeCurve(local_curve);\n      local_curve = SISL_NULL;\n\n      /* Calculate the error in the approximation as above. */\n\n      for (i=0; i<dim; i++) clocal_eps[i] = 0.0;\n      for (jh=0, i=0; i<n1; i++)\n\tfor (j=0; j<dim; j++, jh++)\n\t  clocal_eps[j] = MAX(clocal_eps[j], clocal_err[jh]);\n\n      for (i=0; i<dim; i++)\n      {\n\tmaxerr[i] += clocal_eps[i];\n\tlocal_eps[i] = eps[i] - maxerr[i];\n      }\n      freearray(clocal_eps);\n      freearray(clocal_err);\n    }\n\n    /* Prepare for the next iteration. */\n\n    ++it;\n    lopt = 3 - lopt;\n\n  }\n\n  /* It remains to create a new surface object. If we only removed knots\n     in one direction, one of loct1 and loct2 will be SISL_NULL. */\n\n  if (loct1 == SISL_NULL)\n  {\n    loct1 = newarray(n1+k1, DOUBLE);\n    if (loct1 == SISL_NULL)  goto err101;\n\n    harray = et1;\n    for (i=0; i<n1+k1; i++) loct1[i] = harray[i];\n  }\n\n  if (loct2 ==SISL_NULL)\n  {\n    loct2 = newarray(n2+k2, DOUBLE);\n    if (loct2 == SISL_NULL)  goto err101;\n\n    harray = et2;\n    for (i=0; i<n2+k2; i++) loct2[i] = harray[i];\n  }\n\n  /* Generate the new surface object. */\n\n  *newsurf = newSurf(n1, n2, k1, k2, loct1, loct2, tempcoef,\n\t\t     1, dim, 2);\n  if (*newsurf == SISL_NULL) goto err101;\n\n  /* Avoid free'ing the referenced knots and coefs on exit. */\n\n  loct1 = SISL_NULL;\n  loct2 = SISL_NULL;\n  tempcoef = SISL_NULL;\n\n  /* Set periodicity flag. */\n\n  (*newsurf)->cuopen_1 = kopen1;\n  (*newsurf)->cuopen_2 = kopen2;\n  \n  *stat = 0;\n  goto out;\n\n  /* Error in memory allocation. */\n\nerr101:\n  *stat = -101;\n  s6err(\"s1965\", *stat, pos);\n  goto out;\n\n  /* Error in lower level routine. */\n\nerror:\n  *stat = lstat;\n  s6err(\"s1965\", *stat, pos);\n\n  /* Clean up. */\n\nout:\n  if (local_eps != SISL_NULL) freearray(local_eps);\n  if (local_edge_eps != SISL_NULL) freearray(local_edge_eps);\n  if (clocal_eps != SISL_NULL) freearray(clocal_eps);\n\n  /* Must remember to free everything to avoid memory leak. */\n\n  if (clocal_eps != SISL_NULL) freearray(clocal_eps);\n  if (clocal_err != SISL_NULL) freearray(clocal_err);\n  if (tempcoef != SISL_NULL) freearray(tempcoef);\n  if (loct1 != SISL_NULL) freearray(loct1);\n  if (loct2 != SISL_NULL) freearray(loct2);\n  if (local_curve != SISL_NULL) freeCurve(local_curve);  /* icopy==0 */\n  if (newlcurve != SISL_NULL) freeCurve(newlcurve);  /* icopy ==1 */\n\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s1966.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S1966\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1966(double ep[],int im1,int im2,int idim,int ipar,double epar1[],\n\t   double epar2[],double eeps[],int nend[],int iopen1,int iopen2,\n\t   double edgeps[],double afctol,int iopt,int itmax,\n\t   int ik1,int ik2,SISLSurf **rs,double emxerr[],int *jstat)\n#else\nvoid s1966(ep,im1,im2,idim,ipar,epar1,epar2,eeps,nend,iopen1,iopen2,\n           edgeps,afctol,iopt,itmax,ik1,ik2,\n           rs,emxerr,jstat)\n     double ep[];\n     int    im1;\n     int    im2;\n     int    idim;\n     int    ipar;\n     double epar1[];\n     double epar2[];\n     double eeps[];\n     int    nend[];\n     int    iopen1;\n     int    iopen2;\n     double edgeps[];\n     double afctol;\n     int    iopt;\n     int    itmax;\n     int    ik1;\n     int    ik2;\n     SISLSurf   **rs;\n     double emxerr[];\n     int    *jstat;\n#endif\n/*\n********************************************************************\n*\n* Purpose: To compute a tensor-product spline-approximation of order\n*          (ik1,ik2) to the rectangular array of idim-dimensional\n*          points given by ep.\n*\n* Input : Ep     - Array (length idim*im1*im2) containing the points\n*                  to be approximated.\n*         Im1    - The no. of points in first parameter-direction.\n*         Im2    - The no. of points in second parameter-direction.\n*         Idim   - The no. of components of each input-point.\n*                  The approximation will be a parametric surface\n*                  situated in the idim-dimensional euclidean space\n*                  (usually 3).\n*         Ipar   - Flag determining the parametrization of the data points:\n*                   = 1: Mean accumulated cord-length parameterization.\n*                   = 2: Uniform parametrization.\n*                   = 3: Parametrization given by epar1 and epar2.\n*         Epar1  - Array (length im1) containing a parametrization\n*                  in the first parameter-direction. (Will only\n*                  be used if ipar=3).\n*         Epar2  - Array (length im2) containing a parametrization\n*                  in the second parameter-direction. (Will only\n*                  be used if ipar=3).\n*         Eeps   - Array (length idim) containing the max. permissible\n*                  deviation of the approximation from the given data\n*                  points, in each of the components. More specifically,\n*                  the approximation will not deviate more than eeps(kdim)\n*                  in component no. kdim, from the bilinear approximation\n*                  to the data.\n*         Nend   - Array (length 4) giving the no. of derivatives to be\n*                  kept fixed along each edge of the bilinear interpolant.\n*                  The numbering of the edges is the same as for edgeps below.\n*                  All the derivatives of order < (nend(i)-1) will be kept\n*                  fixed along the edge i. Hence nend(i)=0 indicates that\n*                  nothing is to be kpet fixed along edge i. (Used by the\n*                  data reduction routine.)\n*                  To be kept fixed here means to have error less than edgeps.\n*                  In general, it is impossible to remove any knots and keep\n*                  an edge completely fixed.\n*         iopen1 - Open/closed parameter in first parameter direction.\n*                      =  1 : Produce open surface.\n*                      =  0 : Produce closed, non-periodic surface if possible.\n*                      = -1 : Produce closed, periodic surface if possible.\n*                  NB! The surface will be closed/periodic only if the first \n*                      and last column of data points are (approximately) equal.\n*         iopen2 - Open/closed parameter in second parameter direction.\n*                      =  1 : Produce open surface.\n*                      =  0 : Produce closed, non-periodic surface if possible.\n*                      = -1 : Produce closed, periodic surface if possible.\n*                  NB! The surface will be closed/periodic only if the first \n*                      and last row of data points are (approximately) equal.\n*         Edgeps - Array (length idim*4) containing the max. deviation from\n*                  the bilinear interpolant which is acceptable along the\n*                  edges of the surface.\n*                  Edgeps(1,i):edgeps(idim,i) gives the tolerance along\n*                  the edge corresponding to the i-th parameter having\n*                  one of it`s extremal-values.\n*                   i=1: min value of first parameter.\n*                   i=2: max value of first parameter.\n*                   i=3: min value of second parameter.\n*                   i=4: max value of second parameter.\n*                  (Used by the data-reduction routine.)\n*                  Edgeps(kp,i) will only have significance if nend(i)>0.\n*         Afctol - 0.0 >= afctol <= 1.0.\n*                  Afctol indicates how the tolerance is to be shared\n*                  between the two data-reduction stages. For the linear\n*                  reduction, a tolerance of afctol*eeps will be used,\n*                  while a tolerance of (1.0-afctol)*eeps will be used\n*                  during the final data reduction (similarly for edgeps.)\n*                  Default is 0.\n*          Iopt  - Flag indicating the order in which the data-reduction\n*                  is to be performed:\n*                   = 1: Remove knots inparameter-direction 1 only.\n*                   = 2: Remove knots inparameter-direction 2 only.\n*                   = 3: Remove knots first in parameter-direction 1 and\n*                        then in parameter-direction 2.\n*                   = 4: Remove knots first in parameter-direction 2 and\n*                        then in parameter-direction 1.\n*         Itmax  - Max. no. of iterations in the data-reduction.\n*         Ik1    - The order of the approximation in first\n*                  parameter-directon.\n*         Ik2    - The order of the approximation in second\n*                  parameter-directon.\n*\n* Output:\n*         Jstat  - Output status:\n*                   < 0 : Error.\n*                   = 0 : Ok.\n*                   > 0 : Warning:\n*         Rs     - Pointer to surface.\n*         Emxerr - Array (length idim) (allocated outside this routine.)\n*                  containing the error in the approximation to the data.\n*                  This is guaranteed upper bound on the max. deviation\n*                  in each component, between the final approximation\n*                  and the bilinear spline-approximation to the original data.\n*\n* Method:\n*        First the bilinear interpolant to the data is computed, using the\n*        parameterization given by ipar, and knots are removed from this\n*        initial approximation by a call to the data-reduction routine for\n*        surfaces. Then the order is raised to (ik1,ik2) and the final data\n*        reduction is performed.\n*-\n* Calls: s1965, s1350, s6chpar, s6err.\n*\n* Written by: C.R.Birkeland, Si, April 1993.\n* Changed by: Per OEyvind, SINTEF, 1994-11.\n*             Removed following memory leaks:\n*              1) Improper use of copy flag to newSurf()\n*              2) Forgetting to free temp array after using icopy == 1\n* Changed and renamed by : Vibeke Skytt, SINTEF Oslo, 02.95. Introduced\n*                                                            periodicity.\n**********************************************************************\n*/\n{\n  int in1,in2;                /* Number of vertices                   */\n  int newin1, newin2;\n  int fouridim=4*idim;\n  int i;                      /* Loop control parameters              */\n  int stat=0, kpos=0;         /* Error message parameters             */\n  double *par1 = SISL_NULL;\n  double *par2 = SISL_NULL;\n  double *knot1 = SISL_NULL;       /* Knot vectors in 1 and 2. par.dir.    */\n  double *knot2 = SISL_NULL;\n  double *error1 = SISL_NULL;      /* Arrays for error storage             */\n  double *error2 = SISL_NULL;\n  double *maxerr = SISL_NULL;\n  double *newcoeff = SISL_NULL;    /* Coefficients array                   */\n  SISLCurve *ocurve1 = SISL_NULL;  /* Used to store local curves           */\n  SISLCurve *ocurve2 = SISL_NULL;\n  SISLSurf *osurf1 = SISL_NULL;    /* Used to store local surfaces         */\n  SISLSurf *osurf2 = SISL_NULL;\n\n  /* Check Input */\n\n  if (im1 < 2 || im2 < 2 || ik1 < 1 || ik2 < 1 || idim < 1)\n    goto err103;\n  if (ipar < 1 || ipar > 3) ipar = 1;\n\n  if (ipar != 3)\n    {\n      /* Generate parametrization */\n\n      s1528(idim, im1, im2, ep, ipar, SISL_CRV_OPEN, SISL_CRV_OPEN,\n\t    &par1, &par2, &stat);\n      if (stat<0) goto error;\n    }\n  else\n    {\n      /* Parametrization is passed as parameter */\n\n      par1 = epar1;\n      par2 = epar2;\n    }\n\n  /* Represent input (points) as a surface of\n   * order 2 (linear) in both directions.\n   * First, generate knot vectors */\n\n  knot1 = newarray(im1+2, DOUBLE);\n  knot2 = newarray(im2+2, DOUBLE);\n  if(knot1 == SISL_NULL || knot2 == SISL_NULL) goto err101;\n  memcopy(&knot1[1],par1,im1,DOUBLE);\n  memcopy(&knot2[1],par2,im2,DOUBLE);\n  knot1[0] = knot1[1];\n  knot2[0] = knot2[1];\n  knot1[im1+1] = knot1[im1];\n  knot2[im2+1] = knot2[im2];\n  osurf1 = newSurf(im1, im2, 2, 2, knot1, knot2, ep,\n\t\t   1,idim, 1);\n  if (osurf1 == SISL_NULL) goto err101;\n  if (knot1 != SISL_NULL) freearray(knot1); knot1 = SISL_NULL;\n  if (knot2 != SISL_NULL) freearray(knot2); knot2 = SISL_NULL;\n\n  /* Compute tolerance vectors for linear reduction\n   * Both max deviation of surface and max dev. of edges */\n\n  maxerr = newarray(idim, DOUBLE);\n  error1 = newarray(idim, DOUBLE);\n  error2 = newarray(fouridim, DOUBLE);\n  if (error1 == SISL_NULL || error2 == SISL_NULL || maxerr == SISL_NULL)\n    goto err101;\n  for (i=0; i<fouridim; i++)\n    {\n      edgeps[i] = MIN(edgeps[i], eeps[(i+idim)%idim]);\n      error2[i] = afctol * edgeps[i];\n    }\n  for (i=0; i<idim; i++)\n    error1[i] = afctol*eeps[i];\n\n  /* Perform datareduction on the bilinear interpolant */\n\n  s1965(osurf1, error1, nend, SISL_CRV_OPEN, SISL_CRV_OPEN, error2,\n\tiopt, itmax, &osurf2, maxerr, &stat);\n  if (stat<0) goto error;\n\n  in1 = osurf2->in1;\n  in2 = osurf2->in2;\n\n  /* Free surface osurf1 */\n\n  if(osurf1 != SISL_NULL)\n    {\n      freeSurf(osurf1);\n      osurf1 = SISL_NULL;\n    }\n\n  /* Piecewise linear interpolant to the reduced\n   * bilinear interpolant expressed as a surface\n   * of orders ik1 and ik2 */\n\n  /* Second parameter direction */\n\n  s1350(osurf2->ecoef,&(osurf2->et2)[1], in2,\n\tin1 * idim, ik2, &ocurve1, &stat);\n  if (stat<0) goto error;\n\n  newin2 = ocurve1->in;\n\n  /* Transpose result, store new coefficients in\n   * array newcoeff */\n\n  if( (newcoeff = newarray(idim * in1 * newin2, DOUBLE)) == SISL_NULL )\n    goto err101;\n  s6chpar(ocurve1->ecoef, in1, newin2, idim, newcoeff);\n\n  /* First parameter direction */\n\n  s1350(newcoeff, &(osurf2->et1)[1], in1,\n\tidim*newin2, ik1, &ocurve2, &stat);\n  if (stat<0) goto error;\n  newin1 = ocurve2->in;\n\n  /* Free surface osurf2 */\n\n  if(osurf2 != SISL_NULL)\n    {\n      freeSurf(osurf2);\n      osurf2 = SISL_NULL;\n    }\n\n  /* Transpose back and get coefficients of bilinear\n   * approximatoin surface of orders ik1 and ik2     */\n\n  newcoeff = increasearray(newcoeff,\n\t\t\t   idim * newin1 * newin2, DOUBLE);\n  if (newcoeff == SISL_NULL) goto err101;\n  s6chpar(ocurve2->ecoef, newin2, newin1, idim, newcoeff);\n\n  /* Store results as a surface */\n\n  osurf1 = newSurf(newin1, newin2, ik1, ik2, ocurve2->et,\n\t\t   ocurve1->et, newcoeff, 1, idim, 1);\n\n  if (newcoeff != SISL_NULL) freearray(newcoeff); newcoeff = SISL_NULL;\n\n  if (osurf1 == SISL_NULL) goto err101;\n\n  /* Set periodicity flag. */\n\n  osurf1->cuopen_1 = ocurve2->cuopen;\n  osurf1->cuopen_2 = ocurve1->cuopen;\n\n  /* Compute tolerance for final datareduction */\n\n  for (i=0; i<fouridim; i++)\n    error2[i] = edgeps[i]-error2[i];\n  for (i=0; i<idim; i++)\n    error1[i] = eeps[i]-maxerr[i];\n\n  /* Perform final datareduction step */\n\n  s1965(osurf1, error1, nend, iopen1, iopen2, error2, iopt, itmax,\n\trs, emxerr, &stat);\n  if (stat<0) goto error;\n\n  /* Compute total (and final) error */\n\n  for(i=0; i<idim; i++)\n    emxerr[i] += maxerr[i];\n\n  /* Success */\n\n  *jstat = 0;\n  goto out;\n\n  /* Empty array. */\n\n err101:\n  *jstat = -101;\n  s6err(\"s1966\",*jstat,kpos);\n  goto out;\n\n  /* Error in input */\n\n err103:\n  *jstat = -103;\n  s6err(\"s1966\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine. */\n\n error:\n  *jstat = stat;\n  s6err(\"s1966\",*jstat,kpos);\n  goto out;\n\n  /* Exit */\n\n out:\n  /* Free SISL-curves allocated in this routine */\n\n  if(ocurve1 != SISL_NULL) freeCurve(ocurve1);\n  if(ocurve2 != SISL_NULL) freeCurve(ocurve2);\n\n  /* Free SISL-surfaces allocated in this routine */\n\n  if(osurf1 != SISL_NULL) freeSurf(osurf1);\n\n  /* Free arrays */\n\n  if(error1 != SISL_NULL) freearray(error1);\n  if(error2 != SISL_NULL) freearray(error2);\n  if(maxerr != SISL_NULL) freearray(maxerr);\n\n  if (ipar != 3)\n    {\n      freearray(par1);\n      freearray(par2);\n    }\n\n  return;\n}\n"
  },
  {
    "path": "src/s1967.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1967\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1967(double ep[],double etang1[],double etang2[],double eder11[],\n\t   int im1,int im2,int idim,int ipar,double epar1[],double epar2[],\n\t   double eeps[],int nend[],int iopen1,int iopen2,double edgeps[],\n\t   int iopt,int itmax,SISLSurf **rs,double emxerr[],\n\t   int *jstat)\n#else\nvoid s1967(ep,etang1,etang2,eder11,im1,im2,idim,ipar,epar1,epar2,\n\t   eeps,nend,iopen1,iopen2,edgeps,iopt,itmax,rs,emxerr,jstat)\n     double ep[];\n     double etang1[];\n     double etang2[];\n     double eder11[];\n     int    im1;\n     int    im2;\n     int    idim;\n     int    ipar;\n     double epar1[];\n     double epar2[];\n     double eeps[];\n     int    nend[];\n     int    iopen1;\n     int    iopen2;\n     double edgeps[];\n     int    iopt;\n     int    itmax;\n     SISLSurf   **rs;\n     double emxerr[];\n     int    *jstat;\n#endif\n/*\n********************************************************************\n*\n* Purpose: To compute a bicubic hermite spline-approximation to the\n*          position and derivative data given by ep,etang1,etang2\n*          and eder11.\n*\n* Input : Ep     - Array (length idim*im1*im2) containing the points\n*                  to be approximated.\n*         Etang1 - Array (length idim*im1*im2) containing the derivatives\n*                  (tangents) in the first parameter-direction at the\n*                  data-points.\n*         Etang2 - Array (length idim*im1*im2) containing the derivatives\n*                  (tangents) in the second parameter-direction at the\n*                  data-points.\n*         Eder11 - Array (length idim*im1*im2) containing the cross (twist)\n*                  derivatives at the data-points.\n*         Im1    - The no. of points in the first parameter-direction.\n*         Im2    - The no. of points in the second parameter-direction.\n*         Ipar   - Flag determining the parametrization of the data-points.\n*                   = 1: Mean accumulated cord length parametrization.\n*                   = 2: Uniform parametrization.\n*                   = 3: Parametrization given by epar1 and epar2.\n*         Epar1  - Array (length im1) containing a parametrization in the\n*                  first parameter-direction. (Will only be used if ipar=3.)\n*         Epar2  - Array (length im2) containing a parametrization in the\n*                  surface lies.)\n*         Eeps   - Array (length idim) containing the maximum deviation\n*                  which is acceptable in each of the idim components of\n*                  the surface (except possibly along the edges).\n*         Nend   - Array (length 4) containing the no. of derivatives \n*                  to be kept fixed along each edge of the surface.\n*                  The numbering of the edges is the same as for edeps below.\n*                  All the derivatives of order < nend(i)-1 will be kept fixed\n*                  along edge no. i. Hence nend(i)=0 indicates that nothing\n*                  is to be kpet fixed along edge no. i.\n*                  To be kept fixed here means to have error less than edgeps.\n*                  In general, it is impossible to remove any knots and\n*                  keep an edge completely fixed.\n*         iopen1 - Open/closed parameter in first parameter direction.\n*                      =  1 : Produce open surface.\n*                      =  0 : Produce closed, non-periodic surface if possible.\n*                      = -1 : Produce closed, periodic surface if possible.\n*                  NB! The surface will be closed/periodic only if the first \n*                      and last column of data are (approximately) equal.\n*         iopen2 - Open/closed parameter in second parameter direction.\n*                      =  1 : Produce open surface.\n*                      =  0 : Produce closed, non-periodic surface if possible.\n*                      = -1 : Produce closed, periodic surface if possible.\n*                  NB! The surface will be closed/periodic only if the first \n*                      and last row of data are (approximately) equal.\n*         Edgeps - Array (length idim*4) containing the max. deviation\n*                  which is acceptable along the edges of the surfaces.\n*                  Edgeps(1,i):edgeps(idim,i) gives the tolerance along\n*                  the edge corresponding to the i-th parameter having\n*                  its min. or max value.\n*                  i=1 : min value of first parameter.\n*                  i=2 : max value of first parameter.\n*                  i=3 : min value of second parameter.\n*                  i=4 : max value of second parameter.\n*                  Edgeps(kp,i) will only have any significance if nend(i)>0.\n*         Iopt   - Flag indicationg the order in which tha data-reduction\n*                  is to be performed.\n*                   = 1 : Remove knots in parameter-direction 1 only.\n*                   = 2 : Remove knots in parameter-direction 2 only.\n*                   = 3 : Remove knots in parameter-direction 1 and\n*                         and then in parameter-direction 2.\n*                   = 4 : Remove knots in parameter-direction 2 and\n*                         and then in parameter-direction 1.\n*         Itmax  - Max. no. of iteration.\n*\n* Ouput:  Jstat  - Output status:\n*                   < 0 : Error.\n*                   = 0 : Ok.\n*                   > 0 : Warning.\n*         Rs     - Pointer to surface.\n*         Emxerr - Array (length idim) (allocated outside this routine.)\n*                  containing an upper bound for the error comitted in\n*                  each component during the data reduction.\n*\n* Method: First the bicubic hermite spline-interpolant is computed\n*         using the appropriate parametrization, and then knots\n*         are removed from this approximation by a call to the\n*         data-reduction routine for surfaces.\n*\n* Calls: s1530, s1965, s6err.\n*\n* Written by: C.R.Birkeland, Si, Oslo, Norway, May 1993.\n* Changed and renamed by : Vibeke Skytt, SINTEF Oslo, 02.95. Introduced\n*                                                            periodicity.\n**********************************************************************\n*/\n{\n  int stat=0, kpos=0;         /* Error message parameters        */\n  double *par1 = SISL_NULL;        /* Used to store parametrizations  */\n  double *par2 = SISL_NULL;\n  SISLSurf *osurf = SISL_NULL;     /* Hermite interp. surface         */ \n\n  /* Check Input */\n\n  if (im1 < 2 || im2 < 2 || idim < 1) \n    goto err103; \n  if (ipar < 1 || ipar > 3) ipar = 1;\n\n  /* Generate parametrization */\n\n  if (ipar != 3) \n    { \n      /* Generate parametrization */\n      \n      s1528(idim, im1, im2, ep, ipar, SISL_CRV_OPEN, SISL_CRV_OPEN,\n\t    &par1, &par2, &stat);\n      if (stat<0) goto error;\n    }\n  else \n    {\n      /* Parametrization is passed as parameter */\n\n      par1 = epar1;\n      par2 = epar2;\n    } \n\n  /* Perform bicubic hermite spline interpolation */\n\n  s1530(ep, etang1, etang2, eder11, par1, par2,\n\tim1, im2, idim, &osurf, &stat);\n  if (stat<0) goto error;\n\n  /* Perform final datareduction step */\n\n  s1965(osurf, eeps, nend, iopen1, iopen2, edgeps, iopt, itmax,  \n        rs, emxerr, &stat);\n  if (stat<0) goto error;\n  \n  /* Success */\n\n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error in input */\n\n  err103: \n    *jstat = -103;\n    s6err(\"s1967\",*jstat,kpos);\n    goto out;\n  \n  /* Error in lower level routine. */\n\n  error: \n    *jstat = stat;\n    s6err(\"s1967\",*jstat,kpos);\n    goto out;\n  \n  /* Exit. */\n\n  out:\n    /* Free SISL-surface allocated in this routine */\n\n    if(osurf != SISL_NULL) freeSurf(osurf);\n\n    if (ipar != 3)\n      {\n\tif(par1 != SISL_NULL) freearray(par1);\n\tif(par2 != SISL_NULL) freearray(par2);\n      }\n    return;\n}\n"
  },
  {
    "path": "src/s1968.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S1968\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1968(SISLSurf *ps,double eeps[],int nend[],int iopen1,int iopen2,\n\t   double edgeps[],int iopt,int itmax,SISLSurf **rs,\n\t   int *jstat)\n#else\nvoid s1968(ps,eeps,nend,iopen1,iopen2,edgeps,iopt,itmax,rs,jstat)\n     SISLSurf   *ps;\n     double eeps[];\n     int    nend[];\n     int    iopen1;\n     int    iopen2;\n     double edgeps[];\n     int    iopt;\n     int    itmax;\n     SISLSurf   **rs;\n     int    *jstat;\n#endif\n/*\n********************************************************************\n*\n* Purpose: To compute a cubic tensor-product spline approximation\n*          to a given tensor product spline surface of arbitrary order,\n*          with error less than eeps in each of the idim components.\n*          Mark that the error in continuity over the start and end of\n*          a closed or periodic surface is only guaranteed to be within\n*          edgeps.\n*\n* Input : Ps     - Pointer to surface.\n*         Eeps   - Array (length kdim) containing the maximum deviation\n*                  which is acceptable in each of the kdim components of\n*                  of the surface (except possibly along the edges).\n*         Nend   - Array (length 4) containing the no. of derivatives\n*                  to be kept fixed along each edge of the surface.\n*                  The numbering of the edges is the same as for edeps below.\n*                  All the derivatives of order < nend(i)-1 will be kept fixed\n*                  along edge no. i. Hence nend(i)=0 indicates that nothing\n*                  is to be kpet fixed along edge no. i.\n*                  To be kept fixed here means to have error less than edgeps.\n*                  In general, it is impossible to remove any knots and\n*                  keep an edge completely fixed.\n*         iopen1 - Open/closed parameter in first parameter direction.\n*                      =  1 : Produce open surface.\n*                      =  0 : Produce closed, non-periodic surface if possible.\n*                      = -1 : Produce closed, periodic surface if possible.\n*         iopen2 - Open/closed parameter in second parameter direction.\n*                      =  1 : Produce open surface.\n*                      =  0 : Produce closed, non-periodic surface if possible.\n*                      = -1 : Produce closed, periodic surface if possible.\n*         Edgeps - Array (length kdim*4) containing the max. deviation\n*                  which is acceptable along the edges of the surfaces.\n*                  Edgeps(1,i):edgeps(kdim,i) gives the tolerance along\n*                  the edge corresponding to the i-th parameter having\n*                  its min. or max value.\n*                  i=1 : min value of first parameter.\n*                  i=2 : max value of first parameter.\n*                  i=3 : min value of second parameter.\n*                  i=4 : max value of second parameter.\n*                  Edgeps(kp,i) will only have any significance if nend(i)>0.\n*         Iopt   - Flag indicationg the order in which tha data-reduction\n*                  is to be performed.\n*                   = 1 : Remove knots in parameter-direction 1 only.\n*                   = 2 : Remove knots in parameter-direction 2 only.\n*                   = 3 : Remove knots in parameter-direction 1 and\n*                         and then in parameter-direction 2.\n*                   = 4 : Remove knots in parameter-direction 2 and\n*                         and then in parameter-direction 1.\n*         Itmax  - Max. no. of iterations.\n*\n* Output:\n*         Jstat  - Output status:\n*                   < 0 : Error.\n*                   = 0 : Ok.\n*                   > 0 : Warning:\n*         Rs     - Pointer to surface.\n*\n* Method:\n*        First a tensor-product bicubic spline-approximation with error\n*        less than half the tolerance is computed. Then the no. of\n*        parameters is reduced by the use of data-reduction, also with\n*        a tolerance of half the input-tolerance.\n*        The initial approximation is deteremined by first sampling the\n*        surface and its 10, 01 and 11 derivatives sufficiently often to\n*        ensure that a piecewise bicubic hermite interpolation will give\n*        an error less than half the tolerance, and then computing this\n*        approximation.\n*\n* Calls: s1387, s1530, s1965, s6err.\n*\n* Written by: C.R.Birkeland, Si, Oslo, Norway, April 1993.\n* The datareduction routine, s1345, is written by: Knut M|rken,  SI.\n* Changed by: Per OEyvind, SINTEF, 1994-11.\n*             Added input check for invalid Eeps values.\n*             Removed 2 array \"overlooks\", when setting side1 and side2.\n**********************************************************************\n*/\n{\n  int i,j,k;                    /* Loop control                        */\n  int index = 0;\n  int idim=ps->idim;\n  int stat = 0;                 /* Error message parameters            */\n  int kpos = 0;\n  int im1, im2;                 /* Number of vertices                  */\n  int leftknot1 = 0;            /* Used in call to s1424: evaluator    */\n  int leftknot2 = 0;\n  int side1 = 0;                /* Evaluation from what side           */\n  int side2 = 0;\n  double *error1 = SISL_NULL;        /* For error bounds                    */\n  double *error2 = SISL_NULL;\n  double *error1472 = SISL_NULL;\n  double *newcoeff = SISL_NULL;\n  double *ep = SISL_NULL;            /* Used to store points                */\n  double *eder10 = SISL_NULL;        /* Used to store corresponding derivatives */\n  double *eder01 = SISL_NULL;\n  double *eder11 = SISL_NULL;\n  double *derive = SISL_NULL;\n  double *par1 = SISL_NULL;          /*  Used to store parametrizations      */\n  double *par2 = SISL_NULL;\n  SISLCurve *ocurve = SISL_NULL;\n  SISLSurf *osurf1 = SISL_NULL;\n  SISLSurf *osurf2 = SISL_NULL;\n  double parvalue[2];\n\n\n  /* Check input and description of surface.\n   * ---------------------------------------\n   */\n\n  if (!ps) goto err150;\n  if (ps->ik1 < 1 || ps->ik2 < 1 || idim < 1) goto err103;\n\n  /* Get the eeps value with largest absolute value */\n  parvalue[0] = fabs(eeps[0]);\n  for (i = 1; i < 4; i++)\n  {\n    parvalue[1] = fabs(eeps[i]);\n    if (parvalue[1] > parvalue[0])\n      parvalue[0] = parvalue[1];\n  }\n\n  /* If no max deviation are large than zero ... */\n  if (DEQUAL(parvalue[0], 0.0))\n    goto err103;\n\n  /* Allocate error matrices */\n\n  error1 = newarray( idim, DOUBLE);\n  error2 = newarray( idim, DOUBLE);\n  error1472 = newarray( idim, DOUBLE);\n  if( error1 == SISL_NULL || error2 == SISL_NULL || error1472 == SISL_NULL )\n    goto err101;\n\n  /* First,  make sure both orders are higher or equal to 4 */\n\n  if (ps->ik1 < 4 || ps->ik2 < 4)\n    {\n      /* Increase order in at least one direction */\n\n      s1387(ps, MAX( 4, ps->ik1), MAX( 4, ps->ik2),\n\t    &osurf1, &stat);\n      if (stat<0) goto error;\n    }\n  else\n    osurf1 = newSurf(ps->in1, ps->in2, ps->ik1, ps->ik2,\n\t\t     ps->et1, ps->et2, ps->ecoef, 1, idim, 1);\n\n  /* Make sure orders in both directions are 4. */\n\n  if (osurf1->ik1 == 4 && osurf1->ik2 == 4)\n    {\n      /* Orders in both parameterdirections are now 4.\n       * No degree reduction necessary.\n       * Specify directly error bounds for use\n       * in the datareduction routine. */\n\n      for(i=0; i<idim; i++)\n\terror2[i] = eeps[i];\n      osurf2 = newSurf(osurf1->in1, osurf1->in2, 4, 4, osurf1->et1,\n\t\t       osurf1->et2, osurf1->ecoef, 1, idim, 1);\n    }\n  else\n    {\n      /* The order must be decreased for at least one direction.\n       * Create error bounds. */\n\n      for(i=0; i<idim; i++)\n\t{\n\t  error1[i] = 0.25 * eeps[i];\n\t  error2[i] = eeps[i]-error1[i];\n\t}\n\n      /* Check second direction */\n\n      /* Create curve equivalent and determine sampling points\n       * for 2. direction */\n\n      ocurve = newCurve(osurf1->in2, osurf1->ik2, osurf1->et2,\n\t\t\tosurf1->ecoef, 1, idim*osurf1->in1, 1);\n      if(ocurve == SISL_NULL) goto err101;\n\n      error1472 = increasearray(error1472, idim*osurf1->in1, DOUBLE);\n      if(error1472 == SISL_NULL) goto err101;\n      for(i=0; i<idim*osurf1->in1; i++)\n\terror1472[i] = error1[i % idim];\n      s1355(ocurve, error1472, &par2, &im2, &stat);\n      if (stat<0) goto error;\n      freeCurve(ocurve);\n      ocurve = SISL_NULL;\n\n      /* Create curve equivalent and determine sample points\n       * for 1. direction after transposing surface coefficients */\n\n      newcoeff = newarray(idim * osurf1->in1 * osurf1->in2, DOUBLE);\n      if (newcoeff == SISL_NULL) goto err101;\n      s6chpar(osurf1->ecoef, osurf1->in1, osurf1->in2, idim, newcoeff);\n\n      ocurve = newCurve(osurf1->in1, osurf1->ik1, osurf1->et1,\n\t\t\tnewcoeff, 1, idim*osurf1->in2, 1);\n      if(ocurve == SISL_NULL) goto err101;\n\n      error1472 = increasearray(error1472, idim*osurf1->in2, DOUBLE);\n      if(error1472 == SISL_NULL) goto err101;\n      for(i=0; i<idim*osurf1->in2; i++)\n\terror1472[i] = error1[i % idim];\n      s1355(ocurve, error1472, &par1, &im1, &stat);\n      if (stat<0) goto error;\n      freeCurve(ocurve);\n      ocurve = SISL_NULL;\n\n      /* Compute points and derivatives on the surface\n       * at the points given by calculated par.values */\n\n      derive = newarray( idim * 4, DOUBLE );\n      ep     = newarray( idim * im1 * im2, DOUBLE );\n      eder10 = newarray( idim * im1 * im2, DOUBLE );\n      eder01 = newarray( idim * im1 * im2, DOUBLE );\n      eder11 = newarray( idim * im1 * im2, DOUBLE );\n      if (ep == SISL_NULL || eder10 == SISL_NULL || eder01 == SISL_NULL ||\n\t  eder11 == SISL_NULL || derive == SISL_NULL) goto err101;\n      index = 0;\n      for(j=0; j<im2; j++)\n\t{\n\t  parvalue[1] = par2[j];\n\t  if(j+1 < im2 && par2[j] != par2[j+1])\n\t    side2 = 1;\n\t  else\n\t    side2 = -1;\n\n\t  for(i=0; i<im1; i++)\n\t    {\n\t      parvalue[0] = par1[i];\n\t      if(i+1 < im1 && par1[i] != par1[i+1])\n\t\tside1 = 1;\n\t      else\n\t\tside1 = -1;\n\n\t      s1425( ps, 1, 1, side1, side2, parvalue, &leftknot1,\n\t\t\t  &leftknot2, derive, &stat );\n\t      if(stat < 0) goto error;\n\t      for(k=0; k<idim; k++, index++)\n\t\t{\n\t\t  ep[index] = derive[k];\n\t\t  eder10[index] = derive[k+idim];\n\t\t  eder01[index] = derive[k+2*idim];\n\t\t  eder11[index] = derive[k+3*idim];\n\t\t}\n\t    }\n\t}\n      if (stat < 0) goto error;\n\n      /* Compute Hermite interpolant */\n\n      s1530(ep, eder10, eder01, eder11, par1, par2, im1, im2,\n\t    idim, &osurf2, &stat);\n      if(stat < 0) goto error;\n    }\n\n  /* Perform datareduction on the bicubic surface.\n   * Use tolerance error2                         */\n\n  s1965(osurf2, error2, nend, iopen1, iopen2, edgeps, iopt, itmax,\n\trs, error1, &stat);\n  if(stat < 0) goto error;\n\n  /*\n   * Success.\n   * --------\n   */\n\n  *jstat = 0;\n  goto out;\n\n\n  /*\n   * Error in allocation.\n   * --------------------\n   */\n\n  err101:\n    *jstat = -101;\n    s6err(\"s1968\",*jstat,kpos);\n    goto out;\n\n  /* Error in input */\n\n  err103:\n    *jstat = -103;\n    s6err(\"s1968\",*jstat,kpos);\n    goto out;\n\n  /*\n   * Error in input, pointer to SISLSurf was SISL_NULL pointer.\n   * -----------------------------------------------------\n   */\n\n  err150:\n    *jstat = -150;\n    s6err(\"s1968\",*jstat,kpos);\n    goto out;\n\n  /*\n   * Error in lower level routine.\n   * -----------------------------\n   */\n\n   error:\n    *jstat = stat;\n    s6err(\"s1968\",*jstat,kpos);\n    goto out;\n\n  /*\n   * Exit s1968.\n   * -----------\n   */\n\n  out:\n    if(error1 != SISL_NULL)    freearray(error1);\n    if(error2 != SISL_NULL)    freearray(error2);\n    if(error1472 != SISL_NULL) freearray(error1472);\n    if(newcoeff != SISL_NULL)  freearray(newcoeff);\n    if(ep != SISL_NULL)        freearray(ep);\n    if(eder10 != SISL_NULL)    freearray(eder10);\n    if(eder01 != SISL_NULL)    freearray(eder01);\n    if(eder11 != SISL_NULL)    freearray(eder11);\n    if(derive != SISL_NULL)    freearray(derive);\n    if(par1 != SISL_NULL)      freearray(par1);\n    if(par2 != SISL_NULL)      freearray(par2);\n    if(osurf1 != SISL_NULL)    freeSurf(osurf1);\n    if(osurf2 != SISL_NULL)    freeSurf(osurf2);\n\n    return;\n}\n"
  },
  {
    "path": "src/s1986.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1986\n\n#include \"sislP.h\"                                                 \n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1986(SISLCurve *pc, double aepsge, int *jgtpi, double **gaxis,\n\t   double *cang,int *jstat)\n#else\nvoid s1986(pc,aepsge,jgtpi,gaxis,cang,jstat)\n     SISLCurve *pc;\n     double aepsge;\n     int   *jgtpi;\n     double **gaxis;\n     double *cang;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find the direction cone of a curve.\n*\n*\n* INPUT      : pc        - Curve to treat.\n*              aepsge    - Geometry tolerance.\n*\n* OUTPUT     : jgtpi     - To mark if the angle of the direction cone is\n*                          greater than pi.\n*                           0 - The direction cone of the curve\n*                               is not greater than pi. \n*                           1 - The direction cone of the curve\n*                               is greater than pi.\n*              gaxis     - Allocated array containing the coordinates of the\n*                          center of the cone. It is only computed if\n*                          *jgtpi = 0.\n*              cang      - The angle from the center to the boundary of the\n*                          cone. It is only computed if *jgtpi = 0.\n*              jstat     - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                                                                     \n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 9403.\n*\n*********************************************************************\n*/                                     \n{\n   int kstat = 0;        /* Local status variable.  */\n   int kpos = 0;\n   int kdim = pc->idim;\n   \n   /* Allocate scratch for the output array. */\n   \n   if ((*gaxis = newarray(kdim, DOUBLE)) == SISL_NULL) goto err101;\n   \n   /* Let s1991 compute the cone. */\n   \n   s1991(pc, aepsge, &kstat);\n   if (kstat < 0) goto error;\n   \n   /* Copy the resulting cone to output parameters. */\n   \n   *jgtpi = (pc->pdir->igtpi > 0) ? 1 : 0;\n   *cang = pc->pdir->aang;\n   memcopy(*gaxis, pc->pdir->ecoef, kdim, DOUBLE);\n   \n  /* Success ! */\n  \n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error in space allocation.  */\n  \n  err101: \n     *jstat = -101;\n  s6err(\"s1986\",*jstat,kpos);\n  goto out;\n    \n  /* Error in lower level routine. */\n  \n  error:\n     *jstat = kstat;\n  s6err(\"s1986\",*jstat,kpos);\n  goto out;\n     \n  \n  out: \n    return;\n}\n"
  },
  {
    "path": "src/s1987.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define S1987\n\n#include \"sislP.h\"                                                 \n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1987(SISLSurf *ps, double aepsge, int *jgtpi, double **gaxis,\n\t   double *cang,int *jstat)\n#else\nvoid s1987(ps,aepsge,jgtpi,gaxis,cang,jstat)\n     SISLSurf *ps;\n     double aepsge;\n     int   *jgtpi;\n     double **gaxis;\n     double *cang;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find the direction cone of a surface.\n*\n*\n* INPUT      : ps        - Surface to treat.\n*              aepsge    - Geometry tolerance.\n*\n* OUTPUT     : jgtpi     - To mark if the angle of the direction cone is\n*                          greater than pi.\n*                           0 - The direction cone of the surface\n*                               is not greater than pi in any\n*                               parameter direction.\n*                           1 - The direction cone of the surface\n*                               is greater than pi in the first\n*                               parameter direction.\n*                           2 - The direction cone of the surface is greater\n*                               than pi in the second parameter direction.                          \n*                          10 - The direction cone of a boundary curve of\n*                               the surface is greater than pi in the first\n*                               parameter direction.\n*                          20 - The direction cone of a boundary curve of\n*                               the surface is greater than pi in the second\n*                               parameter direction.                      \n*              gaxis     - Allocated array containing the coordinates of the\n*                          center of the cone. It is only computed if\n*                          *jgtpi = 0.\n*              cang      - The angle from the center to the boundary of the\n*                          cone. It is only computed if *jgtpi = 0.\n*              jstat     - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                                                                     \n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 9403.\n*\n*********************************************************************\n*/                                     \n{\n   int kstat = 0;        /* Local status variable.  */\n   int kpos = 0;\n   int kdim = ps->idim;\n   \n   /* Allocate scratch for the output array. */\n   \n   if ((*gaxis = newarray(kdim, DOUBLE)) == SISL_NULL) goto err101;\n   \n   /* Let s1990 compute the cone. */\n   \n   s1990(ps, aepsge, &kstat);\n   if (kstat < 0) goto error;\n   \n   /* Copy the resulting cone to output parameters. */\n   \n   *jgtpi = ps->pdir->igtpi;\n   *cang = ps->pdir->aang;\n   memcopy(*gaxis, ps->pdir->ecoef, kdim, DOUBLE);\n   \n  /* Success ! */\n  \n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error in space allocation.  */\n  \n  err101: \n     *jstat = -101;\n  s6err(\"s1987\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine. */\n  \n  error:\n     *jstat = kstat;\n  s6err(\"s1987\",*jstat,kpos);\n  goto out;\n     \n  out: \n    return;\n}\n"
  },
  {
    "path": "src/s1988.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1988.c,v 1.2 2001-03-19 15:58:58 afr Exp $\n *\n */\n\n\n#define S1988\n\n#include \"sislP.h\"                                                 \n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1988(SISLCurve *pc,double **emax,double **emin,int *jstat)\n#else\nvoid s1988(pc,emax,emin,jstat)\n     SISLCurve *pc;\n     double **emax;\n     double **emin;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find the bounding box of the SISLCurve. NB. The geometric\n*              bounding box is returned also in the rational case, that\n*              is the box in homogenous coordinates is NOT computed.\n*\n*\n* INPUT      : pc        - SISLCurve to treat.\n*\n* OUTPUT     : emin      - Array of dimension idim containing\n*                          the minimum values of the bounding box,\n*                          i.e. down-left corner of the box.\n*              emax      - Array of dimension idim containing\n*                          the maximum values of the bounding box,\n*                          i.e. top-right corner of the box.\n*              jstat     - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                                                                     \n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* CALLS      :\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF Oslo, July 1993.\n*\n*********************************************************************\n*/                                     \n{\n  int i,j;                          /* Loop control variables    */\n  int kpos = 0;                     /* Position of error.        */\n  int bsdim;\n  int len;\n  int in = pc->in;\n  double *coeff;\n  double *minim=SISL_NULL;\n  double *maxim=SISL_NULL;\n\n  /* initialize variables */\n\n  bsdim = pc->idim;\n  coeff = pc->ecoef;\n  len = bsdim;\n\n  minim = newarray(bsdim, DOUBLE);\n  maxim = newarray(bsdim, DOUBLE);\n  if(minim == SISL_NULL || maxim == SISL_NULL) goto err101;\n\n  for(j=0; j<bsdim; j++)\n    {\n      minim[j] = coeff[j];\n      maxim[j] = coeff[j];\n    }\n  for(i=1, len=bsdim; i<in; i++, len+=bsdim)\n    for(j=0; j<bsdim; j++)\n      {\n\tminim[j] = MIN(minim[j], coeff[len+j]);\n\tmaxim[j] = MAX(maxim[j], coeff[len+j]);\n      }\n  *emin = minim;\n  *emax = maxim;      \n\n  /* Success ! */\n  \n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error in space allocation.  */\n  \n  err101: \n    *jstat = -101;\n    s6err(\"s1988\",*jstat,kpos);\n    goto out;\n  \n  out: \n    return;\n}\n"
  },
  {
    "path": "src/s1989.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1989.c,v 1.2 2001-03-19 15:58:58 afr Exp $\n *\n */\n\n\n#define S1989\n\n#include \"sislP.h\"                                                 \n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s1989(SISLSurf *ps,double **emax,double **emin,int *jstat)\n#else\nvoid s1989(ps,emax,emin,jstat)\n     SISLSurf *ps;\n     double **emax;\n     double **emin;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find the bounding box of the SISLSurf. NB. The geometric\n*              bounding box is returned also in the rational case, that\n*              is the box in homogenous coordinates is NOT computed.\n*\n*\n* INPUT      : ps        - SISLSurface to treat.\n*\n* OUTPUT     : emin      - Array of dimension idim containing\n*                          the minimum values of the bounding box,\n*                          i.e. down-left corner of the box.\n*              emax      - Array of dimension idim containing\n*                          the maximum values of the bounding box,\n*                          i.e. top-right corner of the box.\n*              jstat     - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                                                                     \n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* CALLS      :\n*\n* WRITTEN BY : Christophe Rene Birkeland, SINTEF Oslo, July 1993.\n*\n*********************************************************************\n*/                                     \n{\n  int i,j;                          /* Loop control variables    */\n  int kpos = 0;                     /* Position of error.        */\n  int bsdim;\n  int len;\n  int in = ps->in1 * ps->in2;\n  double *coeff;\n  double *minim=SISL_NULL;\n  double *maxim=SISL_NULL;\n\n  /* initialize variables */\n\n  bsdim = ps->idim;\n  coeff = ps->ecoef;\n  len = bsdim;\n\n  minim = newarray(bsdim, DOUBLE);\n  maxim = newarray(bsdim, DOUBLE);\n  if(minim == SISL_NULL || maxim == SISL_NULL) goto err101;\n\n  for(j=0; j<bsdim; j++)\n    {\n      minim[j] = coeff[j];\n      maxim[j] = coeff[j];\n    }\n  for(i=1, len=bsdim; i<in; i++, len+=bsdim)\n    for(j=0; j<bsdim; j++)\n      {\n\tminim[j] = MIN(minim[j], coeff[len+j]);\n\tmaxim[j] = MAX(maxim[j], coeff[len+j]);\n      }\n  *emin = minim;\n  *emax = maxim;      \n\n  /* Success ! */\n  \n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error in space allocation.  */\n  \n  err101: \n    *jstat = -101;\n    s6err(\"s1989\",*jstat,kpos);\n    goto out;\n  \n  out: \n    return;\n}\n"
  },
  {
    "path": "src/s1990.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1990.c,v 1.5 2005-02-28 09:04:49 afr Exp $\n *\n */\n\n\n#define S1990\n\n#include \"sislP.h\"\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void s1990_s9edg(double [],double [],double [],double,double *,\n\t\t\tint,int *);\n/*\nstatic void s1990_s9smooth(double [],int,int,int,double,double [],int *);\n*/\n#else\nstatic void s1990_s9edg();\n/* static void s1990_s9smooth(); */\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1990(SISLSurf *ps,double aepsge,int *jstat)\n#else\nvoid s1990(ps,aepsge,jstat)\n     SISLSurf   *ps;\n     double aepsge;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To make the orientation surface on the unit sphere to\n*\t       a b-spline surface, the surface is representated with\n*\t       a surrounding cone piced from the unit sphere.\n*\n*\n*\n* INPUT      : ps     - The original B-spline surface.\n*              aepsge - Geometry resolution.\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : We are making a cone surrounding the orientating surface\n*\t       on the unit sphere. The cone is representated with senter\n*\t       coordinates and an angle. The orientation is computed\n*\t       from aproximation of the normal to the surface.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-01.\n*              UJK, Changed to accept equality between vertices.\n* REWISED BY : Vibeke Skytt, SI, 91-02.\n*              UJK, SI, 91-10.Accepting surf's degenarated to a curve lying in\n*                   a plane. Necessary for 2D !\n* Revised by : Christophe Rene Birkeland, SINTEF OSLO, June 1993.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;     /* Position of the error.                             */\n  int kstat = 0;    /* Local status variable.                             */\n  int kfirst = 1;   /* Flag to mark if the first patch is treating.       */\n  int kcount;       /* Counts number of vanishing normals.                */\n  int kn1;          /* Number of vertices of surface in 1. par. direction.*/\n  int kn2;          /* Number of vertices of surface in 2. par. direction.*/\n  int kdim;\t   /* Dimension of the space in which the objects lie.   */\n  int kdim4;\t   /* Help variable to contain  4*kdim.\t\t\t */\n  int kver,khor;    /* The index to the vertice in the upper left corner \n\t\t       to the patch to treat.\t\t\t\t */\n  int k1,k2,k3,k4;  /* Control variables in loop. \t\t\t */\n  int ki;           /* Control variable in loop.  \t\t\t */\n  int lcone[4];     /* Flag telling if the cone has been generated.       */\n  double *t=SISL_NULL;   /* Allocating t[5][kdim]. Five tangents around the\n\t\t       patch, the first and the last is the same.         */\n  double *tn;       /* Allocating tn[4][kdim]. Four normals in the corner\n\t\t       of the patch.\t\t\t\t\t */\n  double *tsen;     /* Allocating tsen[4][kdim] for senter in edge cones. */\n  double *ttan;     /* Allocating ttan[kdim] for tangent on edges.        */\n  double tmax,tmin; /* Maximum and minimum coordinates to the narmals in\n\t\t       the first patch.\t\t\t\t\t */\n  double tlen;      /* The length of a vector.\t\t\t\t */\n  double tnlen;     /* The length of a normal vector.\t   \t         */\n  double tang;\t   /* An angle between two vectors.\t\t\t */\n  double t1,t2;     /* Help variables.\t\t\t\t\t */\n  double sang[4];   /* Angel to the cones to edges.                       */\n  double svec1[3];  /* Vectors used to determin degeneration.             */\n  double svec2[3];  /* Vectors used to determin degeneration.             */\n  double *scoef;    /* Pointer to smoothed coefficient vector.            */\n  double slen[5];   /* Distances between coefficients.                    */\n  double scorn[4];  /* Angle between derivatives in corner of patch.      */\n  double aepsge2 = min(aepsge, 1.0e-6);\n  \n  /* Initiate output status */\n\n  *jstat = 0;\n  \n  /* Test if the surfaces already have been treated.  */\n  \n  if (ps->pdir != SISL_NULL) goto out;\n  \n  /* Initialate dimentions. */\n  \n  kdim = ps -> idim;\n  kn1  = ps -> in1;\n  kn2  = ps -> in2;\n  kdim4 = 4*kdim;\n  \n  lcone[0] = 1;\n  lcone[1] = 1;\n  lcone[2] = 1;\n  lcone[3] = 1;\n    \n  /*Make a new direction cone. */\n  \n  if ((ps->pdir = newdir(kdim)) == SISL_NULL) goto err101;\n  \n  ps->pdir->aang = DZERO;\n  for (k1=0;k1<kdim;k1++) ps->pdir->ecoef[k1] = DZERO;\n  \n  /* Allocate scratch for smoothed coefficients.  */\n  \n  if ((ps->pdir->esmooth = newarray(kn1*kn2*kdim,DOUBLE)) == SISL_NULL) goto err101;\n  scoef = ps->pdir->esmooth;\n  \n  /* Compute coefficients of smoothed curve.  */\n  \n  /* s1990_s9smooth(ps->ecoef,kn1,kn2,kdim,aepsge,scoef,&kstat);\n  if (kstat < 0) goto error; */\n  \n  memcopy(scoef,ps->ecoef,kn1*kn2*kdim,DOUBLE); \n  \n  /* Allocate local used matrices, t[5][kdim] and tn[4][kdim]. */\n  \n  if ((t = newarray(14*kdim,double)) == SISL_NULL) goto err101;\n  tn   = t + 5*kdim;\n  tsen = tn + 4*kdim;\n  ttan = tsen + 4*kdim;\n  \n  /* Here we are treating each patch in the control polygon separately.*/\n  \n  for (kver=0; kver < (kn2-1); kver++)\n    for (khor=0; khor < (kn1-1); khor++)\n      {\n\tslen[0] = slen[1] = slen[2] = slen[3] = DZERO;\n\tscorn[0] = scorn[1] = scorn[2] = scorn[3] = DZERO;\n\t\n\t/* Here we make the tangents in each corner of the patch,\n           and in direction with the clock. The first and the last\n\t   vector contains both the first tangent. */\n\t\n\tk2 = (kver*kn1+khor)*kdim;\n\t\n\tfor (k1=0; k1 < kdim; k1++,k2++)\n\t  {\n\t    t[kdim+k1]   = scoef[k2+kdim] - scoef[k2];\n\t    t[2*kdim+k1] = scoef[k2+(kn1+1)*kdim]-scoef[k2+kdim];\n\t    t[3*kdim+k1] = scoef[k2+kn1*kdim]-scoef[k2+(kn1+1)*kdim];\n\t    t[kdim4+k1] = t[k1] = scoef[k2]-scoef[k2+kn1*kdim];\n\t    \n\t    slen[0] += t[k1]*t[k1];\n\t    slen[1] += t[k1+kdim]*t[k1+kdim];\n\t    slen[2] += t[k1+2*kdim]*t[k1+2*kdim];\n\t    slen[3] += t[k1+3*kdim]*t[k1+3*kdim];\n\t  }\n\tslen[4] = slen[0] = sqrt(slen[0]);\n\tslen[1] = sqrt(slen[1]);\n\tslen[2] = sqrt(slen[2]);\n\tslen[3] = sqrt(slen[3]);\n\t\n\tscorn[0] = s6ang(t,t+kdim,kdim);\n\tscorn[1] = s6ang(t+kdim,t+2*kdim,kdim);\n\tscorn[2] = s6ang(t+2*kdim,t+3*kdim,kdim);\n\tscorn[3] = s6ang(t+3*kdim,t,kdim);\n\t\n\t/* If problems on edges is found we jump to the surface. */\n\t\n\tif (ps->pdir->igtpi > 0) goto next;\n\t\n\t/* Computing cones of edges in ends of parameter two. */\n\t\n\tif (kver == 0)\n\t  {\n\t    if (lcone[0])\n\t      {\n\t\t/* First time to generate cone. */\n\t\t \n\t\t memcopy(tsen,t+kdim,kdim,DOUBLE);\n\t\t tlen = slen[1];\n\t\t\n\t\tif (tlen > aepsge2)\n\t\t  {\n\t\t    for (k1=0; k1 < kdim; k1++) tsen[k1] /= tlen;\n\t\t    lcone[0] = 0;\n\t\t    sang[0] = (double)0;\n\t\t  }\n\t      }\n\t    else\n\t      {\n\t\t/* Modify existing cone. */\n\t\t s1990_s9edg(t+(kdim),ttan,tsen,aepsge2,sang,kdim,&kstat);\n\t\t\n\t\tif (kstat)   ps->pdir->igtpi = 10;\n\t      }\n\t  } \n\tif (kver == kn2-2)\n\t  {\n\t    if (lcone[1])\n\t      {\n\t\t/* First time to generate cone. */\n\t\t \n\t\t memcopy(tsen+kdim,t+3*kdim,kdim,DOUBLE);\n\t\t tlen = slen[3];\n\t\t\n\t\tif (tlen > aepsge2)\n\t\t  {\n\t\t    for (k1=0; k1 < kdim; k1++) tsen[kdim+k1] /= tlen;\n\t\t    lcone[1] = 0;\n\t\t    sang[1] = (double)0;\n\t\t  }\n\t      }\n\t    else\n\t      {\n\t\t s1990_s9edg(t+(3*kdim),ttan,tsen+kdim,aepsge2,sang+1,kdim,&kstat);\n\t\tif (kstat) ps->pdir->igtpi = 10;\n\t      }\n\t  }\n\t\n\t/* Computing cones of edges in ends of parameter one. */\n\t\n\tif (khor == 0)\n\t  {\n\t    if (lcone[2])\n\t      /* First time to generate cone. */\n\t      {\n\t\t memcopy(tsen+2*kdim,t,kdim,DOUBLE);\n\t\t tlen = slen[0];\n\t\t\n\t\tif (tlen > aepsge2)\n\t\t  {\n\t\t    for (k1=0; k1 < kdim; k1++) tsen[2*kdim+k1] /= tlen;\n\t\t    lcone[2] = 0;\n\t\t    sang[2] = (double)0;\n\t\t  }\n\t      }\n\t    else\n\t      {\n\t\t s1990_s9edg(t,ttan,tsen+(2*kdim),aepsge2,sang+2,kdim,&kstat);\n\t\tif (kstat) ps->pdir->igtpi = 10;\n\t      }\n\t  } \n\tif (khor == kn1-2)\n\t  {\n\t    if (lcone[3])\n\t      {\n\t\t memcopy(tsen+3*kdim,t+2*kdim,kdim,DOUBLE);\n\t\t tlen = slen[2];\n\t\t\n\t\tif (tlen > aepsge2)\n\t\t  {\n\t\t    for (k1=0; k1 < kdim; k1++) tsen[3*kdim+k1] /= tlen;\n\t\t    lcone[3] = 0;\n\t\t    sang[3] = (double)0;\n\t\t  }\n\t      }\n\t    else\n\t      {\n\t\t s1990_s9edg(t+(2*kdim),ttan,tsen+(3*kdim),aepsge2,sang+3,kdim,&kstat);\n\t\tif (kstat)  ps->pdir->igtpi = 10;\n\t      }\n\t  }\n\t\n      next:\n\t\n\t/* Here we makes the normales in each corner of the patch.\n\t   We are using a cross product between two tangents.\n\t   The normals is also normalized by deviding with its\n\t   own length. */\n\t\n\tfor (kcount=0, ki=0, k1=0; k1 < kdim4; k1+=kdim, ki++)\n\t  {\n\t    for (tlen=DZERO,k2=0,k3=1,k4=2; k2 < kdim; k2++,k3++,k4++)\n\t      {\n\t\tif(k3 == kdim) k3 = 0;\n\t\tif(k4 == kdim) k4 = 0;\n\t\ttn[k1+k2] = t[k1+k3]*t[k1+kdim+k4]-t[k1+k4]*t[k1+kdim+k3];\n\t\t\n\t\ttlen += tn[k1+k2]*tn[k1+k2];\n\t      }\n\t    tlen = sqrt(tlen);\n\t    /* KYS 070494 : multiplied ANGULAR_TOLERANCE by 1.0e-2 */\n\t    if (slen[ki]>aepsge2 && slen[ki+1]>aepsge2 &&\n\t\tscorn[ki] > 1.0e-2*ANGULAR_TOLERANCE)\n\t      for (k2=0; k2 < kdim; k2++) tn[k1+k2] /= tlen;\n\t    else \n\t      {\n\t      for (k2=0; k2 < kdim; k2++) tn[k1+k2] = ps->pdir->ecoef[k2];\n\t      kcount++;\n\t      }\n\t  }\n\t\n\tif (kcount == 4) continue;   /* Degenerate control polygon patch */\n\t\n\t/* We are treating the first patch. */\n\t\n\tif (kfirst)\n\t  {\n\t    /* Computing the center coordinates of the cone.*/\n\t    \n\t    for (tlen=DZERO,k1=0; k1 < kdim; k1++)\n\t      {\n\t\ttmin = (double)1.0;\n\t\ttmax = - tmin;\n\t\tfor (k2=0; k2 < kdim4; k2+=kdim)\n\t\t  {\n\t\t    tmax = max(tn[k2+k1],tmax);\n\t\t    tmin = min(tn[k2+k1],tmin);\n\t\t  }\n\t\tps->pdir->ecoef[k1]=(tmax+tmin)/(double)2;\n\t\t\n\t\ttlen += ps->pdir->ecoef[k1]*ps->pdir->ecoef[k1];\n\t      }\n\t    tlen = sqrt(tlen);\n\t    if (tlen > DZERO)\n\t      for (k1=0; k1 < kdim; k1++) ps->pdir->ecoef[k1] /= tlen;\n\t    else\n\t      /* KYS 070494 : 'continue' replaced by the following block {} */\n\t      /* There are nonzero normals pointing in\n\t\t opposite directions, i.e. not simple case */\n\t      {\n\t\tif (khor <= kver)\n\t\t  ps->pdir->igtpi = 2;\n\t\telse\n\t\t  ps->pdir->igtpi = 1;\n\t\tps->pdir->aang = PI;\n\t\tgoto out;\n\t      }\n\t    \n\t    /* Computing the angle of the cone. */\n\t    \n\t    for (ps->pdir->aang=DZERO,k1=0; k1<kdim4; k1+=kdim)\n\t      {\n\t\t for (tnlen=DZERO,tlen=DZERO,k2=0;k2<kdim;k2++)\n\t\t   {\n\t\t      tlen += ps->pdir->ecoef[k2]*tn[k1+k2];\n\t\t      tnlen += tn[k1+k2]*tn[k1+k2];\n\t\t   }\n\t\t\n\t\tif (tlen >= DZERO) tlen = min((double)1.0,tlen);\n\t\telse               tlen = max((double)-1.0,tlen);\n\t\t\n\t\ttlen = acos(tlen);\n\t\tif (sqrt(tnlen) < aepsge2) tlen = DZERO;\n\t\t\n\t\tps->pdir->aang = max(ps->pdir->aang,tlen);\n\t      }\n\t    \n\t    kfirst = 0;   /* The first patch have been treated.*/\n\t  } \n\telse\n\t  for (k1=0; k1<kdim4; k1+=kdim)\n\t    {\n\t      /* Computing the angle beetween the senter of the cone\n\t\t and the normal. */\n\t      \n\t      for (tnlen=DZERO,tang=DZERO,k2=0;k2<kdim;k2++)\n\t\t{\n\t\t   tang += ps->pdir->ecoef[k2]*tn[k1+k2];\n\t\t   tnlen += tn[k1+k2]*tn[k1+k2];\n\t\t}\n\t      \n\t      if (tang >= DZERO) tang = MIN((double)1.0,tang);\n\t      else               tang = MAX((double)-1.0,tang);\n\t      \n\t      tang = acos(tang);\n\t      if (sqrt(tnlen) < aepsge2) tang = DZERO;\n\t      \n\t      if (tang + ps->pdir->aang >= PI)\n\t\t{\n\t\t  /* The angle is to great, give a meesage\n\t\t     how to subdivied and exit this function. */\n\t\t  \n\t\t  if (khor <= kver)\n\t\t    ps->pdir->igtpi = 2;\n\t\t  else\t\n\t\t    ps->pdir->igtpi = 1;\n\t\t  goto out;\n\t\t}\n\t      else if (tang > ps->pdir->aang)\n\t\t{\n\t\t  /* The normal is not inside the cone, than we\n\t\t     have to compute a new cone. */\n\t\t  \n\t\t  /* Computing the center coordinates.*/\n\t\t  \n\t          double sin_tang = sin(tang);                     /*@  hke  */\n\t          double delta    = (tang - ps->pdir->aang)/2.0;   /*@  hke  */\n\n\t          t1 = sin(delta)/sin_tang;                        /*@  hke  */\n\t          t2 = sin(tang - delta)/sin_tang;                 /*@  hke  */\n\n\t\t  /*\n\t\t  t1 = (tang - ps->pdir->aang)/((double)2*tang);\n\t\t  t2 = (double)1 - t1;\n\t\t  */\n\t\t  \n\t\t  for (tlen=DZERO,k2=0; k2<kdim; k2++)\n\t\t    {\n\t\t      ps->pdir->ecoef[k2] = \n\t\t\tps->pdir->ecoef[k2]*t2 + tn[k1+k2]*t1;\n\t\t      tlen += ps->pdir->ecoef[k2]*ps->pdir->ecoef[k2];\n\t\t    }\n\t\t  tlen = sqrt(tlen);\n\t\t  \n\t\t  for (k2=0; k2 < kdim; k2++)  ps->pdir->ecoef[k2] /= tlen;\n\t\t  \n\t\t  /* Computing the angle of the cone. */\n\t\t  \n\t\t  ps->pdir->aang = (tang + ps->pdir->aang)/(double)2;\n\t\t}\n\t    }\n\t\n\tif (ps->pdir->aang >= SIMPLECASE)\n\t  {\n\t    /* The angle is to great, give a meesage\n\t       how to subdivied and exit this function. */\n\t    \n\t    if (khor <= kver)\n\t      ps->pdir->igtpi = 20;\n\t    else\t\n\t      ps->pdir->igtpi = 10;\n\t  }\n      }\t\t\t\n  \n  /* A final check if we have made a cone. */\n  /* UJK, SI, 91-10, when 2D, return values from edge case */\n  if (kfirst && kdim != 2)\n    {\n      /* No cone has been generated. We must examin if the surface is \n\t degenerated to a point or line. */\n      for (k1 = 1; k1 < kn1*kn2; k1++)\n\tif (s6dist(scoef,scoef + (k1*kdim),kdim) >aepsge2) break;\n      \n      if (k1 == kn1*kn2)\n\t{\n\t  /* Degenerated to a point. */\n\t  ps->pdir->igtpi = 0;\n\t  ps->pdir->aang  = DZERO;\n\t  ps->pdir->ecoef[0] = (double) 1.0;\n\t  for (k1 = 1; k1 < kdim; k1++) ps->pdir->ecoef[k1] = DZERO;\n\t}\n      else\n\t{\n\t  s6diff(scoef,scoef + (k1*kdim),kdim,svec1);\n\t  \n\t  for (k2 = k1 + 1; k2 < kn1*kn2; k2++)\n\t    if (s6dist(scoef,scoef + (k2*kdim),kdim) >aepsge2)\n\t      {\n\t\ts6diff(scoef,scoef + (k2*kdim),kdim,svec2);\n\t\tif (s6ang(svec1,svec2,kdim) > 1.0e-2*ANGULAR_TOLERANCE) break;\n\t      }\n\t  \n\t  if (k2 == kn1*kn2)\n\t    {\n\t      /* Degenerated to a line. */\n\t      ps->pdir->igtpi = 0;\n\t      ps->pdir->aang  = DZERO;\n\t      ps->pdir->ecoef[0] = (double) 1.0;\n\t      for (k1 = 1; k1 < kdim; k1++) ps->pdir->ecoef[k1] = DZERO;\n\t    }\n\t  else\n\t    {\n\t      /* TEST */\n\t      if (kdim == 3)\n\t\t{\n\t\t  s6crss(svec1, svec2, ps->pdir->ecoef);\n\t\t  s6norm(ps->pdir->ecoef, kdim, ps->pdir->ecoef, &kstat);\n\t\t}\n\t      else\n\t\t{\n\t\t  /*  Three points describing a plane found, continue subdividing.*/ \n\t       if (ps->et1[kn1] - ps->et1[ps->ik1-1] >=\n\t\t   ps->et2[kn2] - ps->et2[ps->ik2-1])\n\t\t  ps->pdir->igtpi = 1;\n\t       else\n\t       ps->pdir->igtpi = 2;\n\t\t}\n\t    }\n\t}\n    }\n  \n  /* success */\n  \n  goto out;\n  \n  /* Error in space allacation.  */\n  \n  err101: \n    *jstat = -101;\n    s6err(\"s1990\",*jstat,kpos);\n    goto out;\n  \n  /* Error in lower level routine.  */\n  \n  /* error : \n    *jstat = kstat;\n    goto out; \n  */\n  \n  /* Free local used memory. */\n  \n  out:    \n    if (t != SISL_NULL) freearray(t);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic  void\n  s1990_s9edg(double et[],double etan[],double esen[],double aepsge,\n\t      double *cang,int idim,int *jstat)\n#else\nstatic void s1990_s9edg(et,etan,esen,aepsge,cang,idim,jstat)\n     double et[];\n     double etan[];\n     double esen[];\n     double aepsge;\n     double *cang;\n     int    idim;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To make the orientation surface on the unit sphere to\n*\t       the edges of a b-spline surface, the surface is\n*\t       representated with a surrounding cone piced from\n*              the unit sphere.\n*\n*\n*\n* INPUT      : et[]    - The tangent vector to the edge.\n*              etan[]  - The normalized tangent vector to the edge.\n*              idim    - The dimention of the surface.\n*\n*\n* INPUT/OUTPUT:esen[]  - The senter vector of the cone.\n*              cang    - The angel of the cone..\n*\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-05.\n*\n*********************************************************************\n*/\n{\n  int ki;\n  double tlen;\n  double tang;\n  double t1,t2;\n  \n  \n  /* Normalizing the tangent. */\n  \n  for (tlen = DZERO,ki=0; ki < idim; ki++)\n    {\n      etan[ki] = et[ki];\n      tlen += etan[ki]*etan[ki];\n    }\n  tlen = sqrt(tlen);\n  \n  if (tlen > aepsge)\n    for (ki=0; ki < idim; ki++) etan[ki] /= tlen;\n  else\n    {\n      *jstat = 0;\n      goto out;\n    }\n  \n  \n  /* Computing the angle beetween the senter of the cone\n     and the tangent. */\n  \n  for (tang=DZERO,ki=0;ki<idim;ki++)\n    tang += esen[ki]*etan[ki];\n  \n  if (tang >= DZERO) tang = min((double)1.0,tang);\n  else               tang = max((double)-1.0,tang);\n  \n  tang = acos(tang);\n  \n  \n  if (tang + *cang >= PI)\n    {\n      /* The angle is to great, give a meesage\n\t to subdivied and exit this function. */\n      \n      *jstat = 1;\n      goto out;\n    }\n  else if (tang > *cang)\n    {\n      /* The tangent is not inside the cone, and we\n\t have to compute a new cone. */\n      \n      /* Computing the center coordinates.*/\n      \n      t1 = (tang - *cang)/((double)2*tang);\n      t2 = (double)1 - t1;\n      \n      for (tlen=DZERO,ki=0; ki<idim; ki++)\n        {\n\t  esen[ki] = esen[ki]*t2 + etan[ki]*t1;\n\t  tlen += esen[ki]*esen[ki];\n        }\n      tlen = sqrt(tlen);\n      \n      if (tlen > DZERO)\n\tfor (ki=0; ki < idim; ki++) esen[ki] /= tlen;\n      else\n\t{\n\t  /* Vi have to be aware of colapsed polygon. */\n\t  \n\t  *jstat = 1;\n\t  goto out;\n\t}\n      \n      /* Computing the angle of the cone. */\n      \n      *cang = (tang + *cang)/(double)2;\n    }\n  \n  \n  if (*cang >= SIMPLECASE)\n    {\n      /* The angle is to large, give a meesage\n\t to subdivied and exit this function. */\n      \n      *jstat = 1;\n      goto out;\n    }\n  \n  \n  *jstat = 0;\n  \n out: ;\n}\n\n#if 0   \n#if defined(SISLNEEDPROTOTYPES)\nstatic  void\n  s1990_s9smooth(double ecoef1[],int in1,int in2,int idim,\n\t\t double aepsge,double ecoef2[],int *jstat)\n#else\nstatic void s1990_s9smooth(ecoef1,in1,in2,idim,aepsge,ecoef2,jstat)\n   double ecoef1[];\n   int    in1;\n   int    in2;\n   int    idim;\n   double aepsge;\n   double ecoef2[];\n   int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Perform noise filthering at the corners of the control\n*              polygon of a B-spline surface.\n*\n*\n*\n* INPUT      : ecoef1 - Original coefficients of surface\n*              in1    - Number of coefficients in 1. par dir.\n*              in2    - Number of coefficients in 2. par dir.\n*              idim   - Dimension of geometry space.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : ecoef2 - New coefficients after smoothing.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*              \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6dplane  -  Distance to given plane.\n*              s6dline   -  Distance to given line.\n*              s6dist    -  Distance between two points.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 91-02.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;     /* Local status variable.        */\n   int kn = MIN(in1/2,in2/2)+1;  /* Maximum numbers of \n\t\t\t\t  coefficients to smooth. */\n   int ki,kj,kh,kl;   /* Counters.                     */\n   int kc;            /* Index of current corner.      */\n   int k1;            /* Sign of change in 1. par dir  */\n   int k2;            /* Sign of change in 2. par dir  */\n   int lcorn[4];      /* Indexes of corners.           */\n   int lsgn1[4];      /* Sign of changes in 1. par dir */\n   int lsgn2[4];      /* Sign of changes in 2. par dir */\n   double tdist;      /* Distance to closest point in plane. */\n   \n   /* Set contents of arrays.  */\n   \n   lcorn[0] = 0;\n   lcorn[1] = (in1-1)*idim;\n   lcorn[2] = (in1*in2-1)*idim;\n   lcorn[3] = in1*(in2-1)*idim;\n   \n   lsgn1[0] = 1;\n   lsgn1[1] = -1;\n   lsgn1[2] = -1;\n   lsgn1[3] = 1;\n   \n   lsgn2[0] = 1;\n   lsgn2[1] = 1;\n   lsgn2[2] = -1;\n   lsgn2[3] = -1;\n   \n   /* Copy coefficients to output array.  */\n   \n   memcopy(ecoef2,ecoef1,in1*in2*idim,DOUBLE);\n\n   /* For each corner, try to smooth the coefficients in the\n      neighbourhood of the corner.  */\n   \n   for (ki=0; ki<4; ki++)\n   {\n      kc = lcorn[ki];   /* Index of current corner.   */\n      k1 = lsgn1[ki];   /* Sign change in 1. par dir. */\n      k2 = lsgn2[ki];   /* Sign change in 2. par dir. */\n      \n      /* Try to smooth coefficients on center line.  */\n\t \n      for (kj=2; kj<kn; kj++)\n      {\n\t if (s6dist(ecoef2+kc,ecoef2+kc+(k2*kj*in1+k1*kj)*idim,\n\t\t    idim) < aepsge) continue;\n\t \n\t for (kh=1; kh<kj; kh++)\n\t {\n\t    tdist = s6dline(ecoef2+kc,ecoef2+kc+(k2*kj*in1+k1*kj)*idim,\n\t\t\t    ecoef2+kc+(k2*kh*in1+k1*kh)*idim,idim,&kstat);\n\t    if (kstat < 0) goto error;\n\t    if (kstat || tdist >= aepsge) break;\n\t }\n\t if (kh < kj) break;\n      }\n      \n      /* Perform smoothing.  */\n      \n      kj--;\n      for (kh=1; kh<kj; kh++)\n\t memcopy(ecoef2+kc+(k2*kh*in1+k1*kh)*idim,ecoef2+kc,\n\t\t idim,DOUBLE);\n      \n      /* Try to smooth coefficients on lower triangle.  */\n      \n      for (kj=2; kj<kn; kj++)\n      {\n\t for (kh=1; kh<kj; kh++)\n\t {\n\t    for (kl=0; kl<kh; kl++)\n\t    {\n\t       tdist = s6dplane(ecoef2+kc,ecoef2+kc+k1*kj*idim,\n\t\t\t\tecoef2+kc+(k2*kj*in1+k1*kj)*idim,\n\t\t\t        ecoef2+kc+(k2*kl*in1+k1*kh)*idim,\n\t\t\t\tidim,&kstat);\n\t       if (tdist >= aepsge) break;\n\t    }\n\t    if (tdist >= aepsge) break;\n\t }\n\t if (kh < kj) break;\n      }\n      \n      /* Perform smoothing.  */\n      \n      kj--;\n      for (kh=1; kh<kj; kh++)\n\t for (kl=0; kl<kh; kl++)\n\t    memcopy(ecoef2+kc+(k2*kl*in1+k1*kh)*idim,ecoef2+kc,\n\t\t    idim,DOUBLE);\n      \n      /* Try to smooth coefficients on upper triangle.  */\n      \n      for (kj=2; kj<kn; kj++)\n      {\n\t for (kh=0; kh<kj; kh++)\n\t {\n\t    for (kl=kh+1; kl<kj; kl++)\n\t    {\n\t       tdist = s6dplane(ecoef2+kc,ecoef2+kc+k2*kj*in1*idim,\n\t\t\t\tecoef2+kc+(k2*kj*in1+k1*kj)*idim,\n\t\t\t        ecoef2+kc+(k2*kl*in1+k1*kh)*idim,\n\t\t\t\tidim,&kstat);\n\t       if (tdist >= aepsge) break;\n\t    }\n\t    if (tdist >= aepsge) break;\n\t }\n\t if (kh < kj) break;\n      }\n      \n      /* Perform smoothing.  */\n      \n      kj--;\n      for (kh=0; kh<kj; kh++)\n\t for (kl=kh+1; kl<kj; kl++)\n\t    memcopy(ecoef2+kc+(k2*kl*in1+k1*kh)*idim,ecoef2+kc,\n\t\t    idim,DOUBLE);\n   }\n   \n   /* Smoothing performed. */\n   *jstat = 0;\n   goto out;\n   \n   /* Error in lower level routine.  */\n   \n   error : *jstat = kstat;\n   goto out;\n   \n   out :\n      \n   return;\n}\n \n#endif /* if 0 */\n"
  },
  {
    "path": "src/s1991.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1991.c,v 1.4 2005-02-28 09:04:49 afr Exp $\n *\n */\n\n\n#define S1991\n\n#include \"sislP.h\"\n/*\n#if defined(SISLNEEDPROTOTYPES)\nstatic void s1991_s9smooth(double [],int,int,double,double [],int *);\n#else\nstatic void s1991_s9smooth();\n#endif\n*/\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s1991(SISLCurve *pc,double aepsge,int *jstat)\n#else\nvoid s1991(pc,aepsge,jstat)\n     SISLCurve  *pc;\n     double aepsge;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To make the orientation surface on the unit sphere to\n*\t       a b-spline curve, the surface is representated with\n*\t       a surrounding cone piced from the unit sphere.\n*\n*\n*\n* INPUT      : pc     - The orginal B-spline curve.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : We are making a cone surrounding the orientating surface\n*\t       on the unit sphere. The cone is representated with senter\n*\t       coordinates and an angle. The orientation is computed\n*\t       from aproximation of the tangent to the curve.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-02.\n* CORRECTED BY: Ulf J. Krystad, SI, 91-07\n*               Problems in shevalc when clustering ceoeff's in s9smooth\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, 09/09-1994. Commented out\n*              call to s1991_s9smooth() and added call to memcopy() instead,\n*              according to advice from Vibeke Skytt.\n*********************************************************************\n*/\n{\n  int kpos = 0;     /* Position of the error.                          */\n  int kfirst = 1;   /* Flag to mark if the first tangent is treating.  */\n  int kn;           /* Number of vertices of curve.                    */\n  int kdim;\t    /* Dimension of the space in which the objects lie.*/\n  int kin;          /* The index to the vertice to treat.              */\n  int k1,k2;        /* Control variables in loop.                      */\n  double *t=SISL_NULL;   /* Tangent at each coeficient.                     */\n  double tlen;      /* The length of a vector.                         */\n  double tang;\t    /* An angle between two vectors.\t\t       */\n  double t1,t2;     /* Help variables.\t\t\t\t       */\n  double *scoef;    /* Pointer to coefficients.                        */\n\n\n\n  /* Test if the surfaces already have been treated.  */\n\n  if (pc->pdir != SISL_NULL) goto out;\n\n\n  /* Initialate dimentions. */\n\n  kdim = pc -> idim;\n  kn = pc -> in;\n\n\n  /* Make a new direction cone. */\n\n  if ((pc->pdir = newdir(kdim))==SISL_NULL) goto err101;\n\n  /* UJK, Set default values in pdir. */\n  pc->pdir->aang = DZERO;\n  pc->pdir->igtpi = 0;\n  pc->pdir->ecoef[0] = (double) 1.0;\n\n  for (k2 = 1;k2<kdim;k2++)\n    pc->pdir->ecoef[k2] = DZERO;\n\n\n  /* Allocate local used array. */\n\n  if ((t = newarray(kdim,double)) == SISL_NULL) goto err101;\n\n  /* Allocate scratch for smoothed coefficients.  */\n\n  if ((pc->pdir->esmooth = newarray(kn*kdim,DOUBLE)) == SISL_NULL) goto err101;\n  scoef = pc->pdir->esmooth;\n\n  /* Compute coefficients of smoothed curve.  */\n\n   /* s1991_s9smooth(pc->ecoef,kn,kdim,aepsge,scoef,&kstat);\n      if (kstat < 0) goto error; */\n   /* (VSK 02-1994: no point in smoothing) */\n   memcopy(scoef, pc->ecoef, kn*kdim, DOUBLE);\n\n  /* Here we are treating each patch in the control polygon separately.*/\n\n  for (k2=0,kin=0; kin < kn-1; kin++)\n    {\n\n      /* Here we make an aproximative tangents to the curve\n\t using the control polygon. The tangents is also normalized\n\t by deviding with its own length. */\n\n      for (tlen=DZERO,k1=0; k1 < kdim; k1++,k2++)\n\t{\n\t  t[k1] = scoef[k2+kdim] - scoef[k2];\n\t  tlen += t[k1]*t[k1];\n\t}\n\n      tlen = sqrt(tlen);\n\n      if (tlen > aepsge)\n\tfor (k1=0; k1 < kdim; k1++) t[k1] /= tlen;\n      else\n\t{\n\t  /* UJK, whats wrong with colapsed polygons when computing directions? */\n\t  continue;\n\n\t  /* Vi have to be aware of colapsed polygon. */\n\t  /* pc->pdir->igtpi = 1;\n\t     goto out;             */\n\n\t}\n\n\n      /* We are treating the first tangent. */\n\n      if (kfirst)\n\t{\n\n\t  /* Computing the center coordinates of the cone.*/\n\n\t  for (k1=0; k1 < kdim; k1++)\n\t    pc->pdir->ecoef[k1]= t[k1];\n\n\t  /* Computing the angle of the cone. */\n\n\t  pc->pdir->aang = DZERO;\n\n\t  kfirst = 0;   /* The first tangent have been treated.*/\n\t}\n      else\n\t{\n\n\t  /* Computing the angle beetween the senter of the cone\n\t     and the tangent. */\n\n\t  for (tang=DZERO,k1=0;k1<kdim;k1++)\n\t    tang += pc->pdir->ecoef[k1]*t[k1];\n\n\t  if (tang >= DZERO) tang = min((double)1.0,tang);\n\t  else               tang = max((double)-1.0,tang);\n\n\t  tang = acos(tang);\n\n\t  if (tang + pc->pdir->aang >= PI)\n\t    {\n\t      /* The angle is to great, give a meesage\n\t\t to subdivied and exit this function. */\n\n\t      pc->pdir->igtpi = 1;\n\t      goto out;\n\t    }\n\t  else if (tang > pc->pdir->aang)\n\t    {\n\t      /* The tangent is not inside the cone, and we\n\t\t have to compute a new cone. */\n\n\t      /* Computing the center coordinates.*/\n\n\t      t1 = (tang - pc->pdir->aang)/((double)2*tang);\n\t      t2 = (double)1 - t1;\n\n\t      for (tlen=DZERO,k1=0; k1<kdim; k1++)\n\t\t{\n\t\t  pc->pdir->ecoef[k1] =\n\t\t    pc->pdir->ecoef[k1]*t2 + t[k1]*t1;\n\t\t  tlen += pc->pdir->ecoef[k1]*\n\t\t    pc->pdir->ecoef[k1];\n\t\t}\n\t      tlen = sqrt(tlen);\n\n\t      if (tlen > DZERO)\n\t\tfor (k1=0; k1 < kdim; k1++)\n\t\t  pc->pdir->ecoef[k1] /= tlen;\n\t      else\n\t\t{\n\t\t  /* Vi have to be aware of colapsed polyg.*/\n\n\t\t  pc->pdir->igtpi = 1;\n\t\t  goto out;\n\t\t}\n\n\n\t      /* Computing the angle of the cone. */\n\n\t      pc->pdir->aang = (tang + pc->pdir->aang)/\n\t\t(double)2;\n\t    }\n\t}\n    }\n\n\n\n  if (pc->pdir->aang >= SIMPLECASE)\n    {\n      /* The angle is to great, give a message\n\t to subdivied and exit this function. */\n\n      pc->pdir->igtpi = 3;\n      goto out;\n    }\n\n\n  *jstat = 0;\n  goto out;\n\n\n  /* Error in space allacation.  */\n\n err101: *jstat = -101;\n  s6err(\"s1991\",*jstat,kpos);\n  goto out;\n\n out:    if (t != SISL_NULL) freearray(t);\n\n}\n\n#if 0\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  s1991_s9smooth(double ecoef1[],int in,int idim,double aepsge,\n\t\t double ecoef2[],int *jstat)\n#else\nstatic void s1991_s9smooth(ecoef1,in,idim,aepsge,ecoef2,jstat)\n   double ecoef1[];\n   int    in;\n   int    idim;\n   double aepsge;\n   double ecoef2[];\n   int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Perform noise filthering on the control polygon on a\n*              B-spline curve with special emphasis to the ends of\n*              the curve.\n*\n*\n*\n* INPUT      : ecoef1 - Original coefficients of curve.\n*              in     - Number of coefficients.\n*              idim   - Dimension of geometry space.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : ecoef2 - New coefficients after smoothing.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Start from both ends of the curve and traverse towards\n*              the middle. Coefficients with distance less than the\n*              tolerance from a line between nearby coefficients, are\n*              projected down to this line.\n*\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6dline  -  Distance between point and line.\n*              s6dist   -  Distance between points.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 91-02.\n* CORRECTED BY: Ulf J. Krystad, SI, 91-07\n*               Problems in shevalc when clustering ceoeff's\n*********************************************************************\n*/\n{\n   int kstat = 0;      /* Local status variable.            */\n   int kn2 = in/2;     /* Half the number of coefficients.  */\n   int ki;             /* Loop control.                     */\n   double *sdiff1=SISL_NULL;/* Diff vector                       */\n   double *sdiff2=SISL_NULL;/* Diff vector                       */\n   double alfa,dnum;   /* Factor and denominator in expr.   */\n   double tdist;       /* Distance between point and line.  */\n   double *s1,*s2,*s3; /* Pointers into coefficient array.  */\n   double *st1,*st2;   /* Stop pointers in loop.            */\n\n   /* Alloc scratch for locals */\n   if ((sdiff1 = newarray(idim,DOUBLE)) == SISL_NULL) goto err101;\n   if ((sdiff2 = newarray(idim,DOUBLE)) == SISL_NULL) goto err101;\n\n\n   /* Copy coefficient array to output array.  */\n   memcopy(ecoef2,ecoef1,in*idim,DOUBLE);\n\n   /* Traverse and smooth first half of the coefficient array.  */\n\n   for (s1=ecoef2, st1=s1+(kn2-1)*idim; s1<st1; s1=s2)\n   {\n      for (s2=s1+2*idim, st2=st1+idim; s2<=st2; s2+=idim)\n      {\n\t if (s6dist(s1,s2,idim) < aepsge) continue;\n\n\t for (s3=s1+idim; s3<s2; s3+=idim)\n\t {\n\t    /* Find distance between the point s3 and the line\n\t       segment between s1 and s2.   */\n\n\t    tdist = s6dline(s1,s2,s3,idim,&kstat);\n\t    if (kstat < 0) goto error;\n\n\t    /* Test if the point is close to a point within the\n\t       line segment, and the distance is less than\n\t       the tolerance.        */\n\n\t    if (kstat || tdist >= aepsge) break;  /* No smoothing\n\t\t\t\t\t\t     possible.  */\n\t }\n\t if (s3 < s2) break; /* No smoothing between s1 and s2. */\n      }\n\n      /* Project all coefficients between s1 and s2 down to the\n\t line segment between s1 and s2.  */\n\n      s2 -= idim;\n      /*UJK Problems in shevalc when clustering ceoeff's,\n\t let's really project! */\n      /*for (s3=s1+idim; s3<s2; s3+=idim)\n\t memcopy(s3,s1,idim,DOUBLE); */\n\n      s6diff(s2,s1,idim,sdiff1);\n      dnum = s6scpr(sdiff1,sdiff1,idim);\n\n\n      for (s3=s1+idim; s3<s2; s3+=idim)\n      {\n\t  if (dnum > DZERO)\n\t     {\n\t\ts6diff(s2,s3,idim,sdiff2);\n\t\talfa = s6scpr(sdiff2,sdiff1,idim)/dnum;\n\t\tfor (ki=0;ki<idim;ki++) s3[ki]=\n\t\t   alfa*s1[ki] + ((double)1.0 - alfa)*s2[ki];\n\t     }\n      }\n\n   }\n\n   /* Traverse and smooth second half of the coefficient array.  */\n\n   for (s1=ecoef2+(in-1)*idim, st1=s1-(kn2-1)*idim; s1>st1; s1=s2)\n   {\n      for (s2=s1-2*idim, st2=st1-idim; s2>=st2; s2-=idim)\n      {\n\t if (s6dist(s1,s2,idim) < aepsge) continue;\n\n\t for (s3=s1-idim; s3>s2; s3-=idim)\n\t {\n\t    /* Find distance between the point s3 and the line\n\t       segment between s1 and s2.   */\n\n\t    tdist = s6dline(s1,s2,s3,idim,&kstat);\n\t    if (kstat < 0) goto error;\n\n\t    /* Test if the point is close to a point within the\n\t       line segment, and the distance is less than\n\t       the tolerance.        */\n\n\t    if (kstat || tdist >= aepsge) break;  /* No smoothing\n\t\t\t\t\t\t     possible.  */\n\t }\n\t if (s3 > s2) break; /* No smoothing between s1 and s2. */\n      }\n\n      /* Project all coefficients between s1 and s2 down to the\n\t line segment between s1 and s2.  */\n\n      s2 += idim;\n      /*UJK Problems in shevalc when clustering ceoeff's,\n\t let's really project! */\n      /*for (s3=s1-idim; s3>s2; s3-=idim)\n\t memcopy(s3,s1,idim,DOUBLE); */\n\n      s6diff(s2,s1,idim,sdiff1);\n      dnum = s6scpr(sdiff1,sdiff1,idim);\n\n      for (s3=s1-idim; s3>s2; s3-=idim)\n      {\n\t  if (dnum > DZERO)\n\t     {\n\t\ts6diff(s2,s3,idim,sdiff2);\n\t\talfa = s6scpr(sdiff2,sdiff1,idim)/dnum;\n\t\tfor (ki=0;ki<idim;ki++) s3[ki]=\n\t\t   alfa*s1[ki] + ((double)1.0 - alfa)*s2[ki];\n\t     }\n      }\n   }\n\n   /* Smoothing performed.  */\n\n   *jstat = 0;\n   goto out;\n\n  /* Error in space allacation.  */\n\n   err101: *jstat = -101;\n   goto out;\n\n   /* Error in lower level routine.  */\n\n   error : *jstat = kstat;\n   goto out;\n\n   out :\n      if (sdiff1) freearray(sdiff1);\n      if (sdiff2) freearray(sdiff2);\n      return;\n}\n#endif /* if 0 */\n"
  },
  {
    "path": "src/s1992.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1992.c,v 1.2 2001-03-19 15:58:59 afr Exp $\n *\n */\n\n\n#define S1992\n\n#include \"sislP.h\"                                                 \n\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns1992_s9mbox3(double [],int,double [],double []);\nstatic void\ns1992_s9mbox2(double [],int,double [],double []);\nstatic void\ns1992_s9mbox(double [],int,int idim,double[],double []);\n#else\nstatic void s1992_s9mbox3();\nstatic void s1992_s9mbox2();\nstatic void s1992_s9mbox();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1992(SISLObject *po,int *jstat)\n#else\nvoid s1992(po,jstat)\n     SISLObject *po;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make a SISLbox on the control-polygons given by\n*              ecoef to the object. If dimension is 2 then one\n*\t       SISLbox rotated 45 degree is also made. If dimension\n*\t       is 3 then one SISLbox roteted 45 degree around each\n*\t       main axes, in all 4 boxes is made.\n*\n*\n*\n* INPUT      : po     - SISLObject to treat.\n*\n* OUTPUT     : jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                                                                     \n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-02.\n*\n*********************************************************************\n*/                                     \n{\n  int kpos = 0;                        /* Position of error.   */\n\n  if (po -> iobj == SISLPOINT)\n    {\n      if (po->p1->pbox == SISL_NULL)\n\t{\n\t  if ((po->p1->pbox = newbox(po->p1->idim))==SISL_NULL)\n\t    goto err101;\n\t  \n\t  if (po->p1->idim == 3) \n\t    s1992_s9mbox3(po->p1->ecoef,1,po->p1->pbox->emax,\n\t\t    po->p1->pbox->emin);\n\t  else \n\t    if (po->p1->idim == 2)\n\t      s1992_s9mbox2(po->p1->ecoef,1,po->p1->pbox->emax,\n\t\t      po->p1->pbox->emin);\n\t    else\n\t      s1992_s9mbox(po->p1->ecoef,1,po->p1->idim,\n\t\t     po->p1->pbox->emax,po->p1->pbox->emin);\n\t}\n    }\n  else\n    if (po -> iobj == SISLCURVE)\n      {\n\tif (po->c1->pbox == SISL_NULL)\n\t  {\n\t    if ((po->c1->pbox = newbox(po->c1->idim))==SISL_NULL)\n\t      goto err101;\n\t    \n\t    if (po->c1->idim == 3) \n\t      s1992_s9mbox3(po->c1->ecoef,po->c1->in,po->c1->pbox->emax,\n\t\t      po->c1->pbox->emin);\n\t    else \n\t      if (po->c1->idim == 2)\n\t\ts1992_s9mbox2(po->c1->ecoef,po->c1->in,po->c1->pbox->emax,\n\t\t\tpo->c1->pbox->emin);\n\t      else\n\t\ts1992_s9mbox(po->c1->ecoef,po->c1->in,po->c1->idim,\n\t\t       po->c1->pbox->emax,po->c1->pbox->emin);\n\t  }\n      }\n    else\n      if (po -> iobj == SISLSURFACE)\n\t{\n\t  if (po->s1->pbox == SISL_NULL)\n\t    {\n\t      if ((po->s1->pbox = newbox(po->s1->idim))==SISL_NULL)\n\t\tgoto err101;\n\t      \n\t      if (po->s1->idim == 3) \n\t\ts1992_s9mbox3(po->s1->ecoef,po->s1->in1 * po->s1->in2,\n\t\t\tpo->s1->pbox->emax,po->s1->pbox->emin);\n\t      else \n\t\tif (po->s1->idim == 2)\n\t\t  s1992_s9mbox2(po->s1->ecoef,po->s1->in1 * po->s1->in2,\n\t\t\t  po->s1->pbox->emax,po->s1->pbox->emin);\n\t\telse\n\t\t  s1992_s9mbox(po->s1->ecoef,po->s1->in1 * po->s1->in2,\n\t\t\t po->s1->idim,po->s1->pbox->emax,po->s1->pbox->emin);\n\t    }\n\t}\n  \n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1992\",*jstat,kpos);\n  goto out;\n  \n out: ;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1992cu(SISLCurve *pc,int *jstat)\n#else\nvoid s1992cu(pc,jstat)\n     SISLCurve *pc;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make a SISLbox on the control-polygons given by\n*              ecoef to the object. If dimension is 2 then one\n*\t       SISLbox rotated 45 degree is also made. If dimension\n*\t       is 3 then one SISLbox roteted 45 degree around each\n*\t       main axes, in all 4 boxes is made.\n*\n*\n*\n* INPUT      : pc     - SISLObject to treat.\n*\n* OUTPUT     : jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                                                                     \n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-02.\n*\n*********************************************************************\n*/                                     \n{\n  int kpos = 0;                        /* Position of error.   */\n  \n  if (pc->pbox == SISL_NULL)\n    {\n      if ((pc->pbox = newbox(pc->idim))==SISL_NULL)\n\tgoto err101;\n      \n      if (pc->idim == 3) \n\ts1992_s9mbox3(pc->ecoef,pc->in,pc->pbox->emax,pc->pbox->emin);\n      else if (pc->idim == 2)\n\ts1992_s9mbox2(pc->ecoef,pc->in,pc->pbox->emax,pc->pbox->emin);\n      else\n\ts1992_s9mbox(pc->ecoef,pc->in,pc->idim,\n\t       pc->pbox->emax,pc->pbox->emin);\n    }\n  \n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1992cu\",*jstat,kpos);\n  goto out;\n  \n out: ;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1992su(SISLSurf *ps,int *jstat)\n#else\nvoid s1992su(ps,jstat)\n     SISLSurf *ps;\n     int  *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make a SISLbox on the control-polygons given by\n*              ecoef to the object. If dimension is 2 then one\n*\t       SISLbox rotated 45 degree is also made. If dimension\n*\t       is 3 then one SISLbox roteted 45 degree around each\n*\t       main axes, in all 4 boxes is made.\n*\n*\n*\n* INPUT      : ps     - SISLObject to treat.\n*\n* OUTPUT     : jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                                                                     \n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-02.\n*\n*********************************************************************\n*/                                     \n{\n  int kpos = 0;                        /* Position of error.   */\n  \n  if (ps->pbox == SISL_NULL)\n    {\n      if ((ps->pbox = newbox(ps->idim))==SISL_NULL) goto err101;\n      \n      if (ps->idim == 3) s1992_s9mbox3(ps->ecoef,ps->in1 * ps->in2,\n\t\t\t\t ps->pbox->emax,ps->pbox->emin);\n      \n      else if (ps->idim == 2) s1992_s9mbox2(ps->ecoef,ps->in1 * ps->in2,\n\t\t\t\t      ps->pbox->emax,ps->pbox->emin);\n      else\n\ts1992_s9mbox(ps->ecoef,ps->in1 * ps->in2,\n\t       ps->idim,ps->pbox->emax,ps->pbox->emin);\n    }\n  \n  *jstat = 0;\n  goto out;\n  \n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"s1992su\",*jstat,kpos);\n  goto out;\n  \n out: ;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  s1992_s9mbox3(double ecoef[],int icoef,double gmax[],double gmin[])\n#else\nstatic void s1992_s9mbox3(ecoef,icoef,gmax,gmin)\n     double ecoef[];\n     int    icoef;\n     double gmax[];\n     double gmin[];\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make 4 boxes on the control-polygons given by\n*              ecoef to the object.\n*\n*\n* INPUT      : ecoef  - Control-polygon.\n*              icoef - Number of vertices in control-polygon.\n*\n*                                                                     \n*\n* OUTPUT     : gmax   - Array to contain maximum values of the box.\n*\t       gmin   - Array to contain minimum values of the box.\n*\n*\n* METHOD     : Make 4 boxes. One ordinary and tree boxes rotated\n*\t       45 degree around the main axes.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-02.\n*\n*********************************************************************\n*/                                     \n{\n  int ki,ki1,ki2,ki3;    /* Counters.                                 */\n  double t1,t2,t3,t4;    /* To store elements of the rotation matrix. */\n  double *tmin,*tmax;    /* Pointers used to traverse gmin and gmax.  */\n  \n  /* Fetch value of first vertex.  */\n  \n  t1= ROTM * ecoef[0];\n  t2= ROTM * ecoef[1];\n  t3= ROTM * ecoef[2];\n  \n  tmin = gmin;\n  tmax = gmax;\n  *tmin = *tmax = ecoef[0];\n  tmin++; tmax++;\n  *tmin = *tmax = ecoef[1];\n  tmin++; tmax++;\n  *tmin = *tmax = ecoef[2];\n  tmin++; tmax++;\n  *tmin = *tmax = ecoef[0];\n  tmin++; tmax++;\n  *tmin = *tmax = t2-t3;\n  tmin++; tmax++;\n  *tmin = *tmax = t2+t3;\n  tmin++; tmax++;\n  *tmin = *tmax = t1-t3;\n  tmin++; tmax++;\n  *tmin = *tmax = ecoef[1];\n  tmin++; tmax++;\n  *tmin = *tmax = t1+t3;\n  tmin++; tmax++;\n  *tmin = *tmax = t1-t2;\n  tmin++; tmax++;\n  *tmin = *tmax = t1+t2;\n  tmin++; tmax++;\n  *tmin = *tmax = ecoef[2];\n  \n  /* For each vertice check and corrigate the box.  */\n  \n  for (ki=1,ki1=3,ki2=4,ki3=5; ki<icoef; ki++,ki1+=3,ki2+=3,ki3+=3)\n    {\n      \n      \n      t1= ROTM * ecoef[ki1];\n      t2= ROTM * ecoef[ki2];\n      t3= ROTM * ecoef[ki3];\n      tmin = gmin;\n      tmax = gmax;\n      if(ecoef[ki1] < *tmin) *tmin = ecoef[ki1];\n      if(ecoef[ki1] > *tmax) *tmax = ecoef[ki1];\n      tmin++; tmax++;\n      if(ecoef[ki2] < *tmin) *tmin = ecoef[ki2];\n      if(ecoef[ki2] > *tmax) *tmax = ecoef[ki2];\n      tmin++; tmax++;\n      if(ecoef[ki3] < *tmin) *tmin = ecoef[ki3];\n      if(ecoef[ki3] > *tmax) *tmax = ecoef[ki3];\n      tmin++; tmax++;\n      if(ecoef[ki1] < *tmin) *tmin = ecoef[ki1];\n      if(ecoef[ki1] > *tmax) *tmax = ecoef[ki1];\n      tmin++; tmax++;\n      t4= t2 - t3;\n      if(t4 < *tmin) *tmin = t4;\n      if(t4 > *tmax) *tmax = t4;\n      tmin++; tmax++;\n      t4= t2 + t3;\n      if(t4 < *tmin) *tmin = t4;\n      if(t4 > *tmax) *tmax = t4;\n      tmin++; tmax++;\n      t4= t1 - t3;\n      if(t4 < *tmin) *tmin = t4;\n      if(t4 > *tmax) *tmax = t4;\n      tmin++; tmax++;\n      if(ecoef[ki2] < *tmin) *tmin = ecoef[ki2];\n      if(ecoef[ki2] > *tmax) *tmax = ecoef[ki2];\n      tmin++; tmax++;\n      t4= t1 + t3;\n      if(t4 < *tmin) *tmin = t4;\n      if(t4 > *tmax) *tmax = t4;\n      tmin++; tmax++;\n      t4= t1 - t2;\n      if(t4 < *tmin) *tmin = t4;\n      if(t4 > *tmax) *tmax = t4;\n      tmin++; tmax++;\n      t4= t1 + t2;\n      if(t4 < *tmin) *tmin = t4;\n      if(t4 > *tmax) *tmax = t4;\n      tmin++; tmax++;\n      if(ecoef[ki3] < *tmin) *tmin = ecoef[ki3];\n      if(ecoef[ki3] > *tmax) *tmax = ecoef[ki3];\n    }\n}\n\f \n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  s1992_s9mbox2(double ecoef[],int icoef,double gmax[],double gmin[])\n#else\nstatic void s1992_s9mbox2(ecoef,icoef,gmax,gmin)\n     double ecoef[];\n     int    icoef;\n     double gmax[];\n     double gmin[];\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make 2 boxes on the control-polygons given by\n*              ecoef to the object.\n*\n*\n* INPUT      : ecoef  - Control-polygon.\n*              icoef - Number of vertices in control-polygon.\n*\n*                                                                     \n*\n* OUTPUT     : gmax   - Array to contain maximum values of the box.\n*\t       gmin   - Array to contain minimum values of the box.\n*\n*\n* METHOD     : Make two boxes. One ordinary and one rotated 45 degree.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-02.\n*\n*********************************************************************\n*/                                     \n{\n  int ki,ki1,ki2;        /* Counters.                                 */\n  double t1,t2,t3;       /* To store elements of the rotation matrix. */\n  double *tmin,*tmax;    /* Pointers used to traverse gmin and gmax.  */\n  \n  \n  \n  /* Fetch value of first vertex.  */\n  \n  t1= ROTM * ecoef[0];\n  t2= ROTM * ecoef[1];\n  \n  tmin = gmin;\n  tmax = gmax;\n  *tmin = *tmax = ecoef[0];\n  tmin++; tmax++;\n  *tmin = *tmax = ecoef[1];\n  tmin++; tmax++;\n  *tmin = *tmax = t1-t2;\n  tmin++; tmax++;\n  *tmin = *tmax = t1+t2;\n  \n  /* For each vertice check and corrigate the box.  */\n  \n  for (ki=1,ki1=2,ki2=3; ki<icoef; ki++,ki1+=2,ki2+=2)\n    {\n      \n      \n      t1= ROTM * ecoef[ki1];\n      t2= ROTM * ecoef[ki2];\n      tmin = gmin;\n      tmax = gmax;\n      if(ecoef[ki1] < *tmin) *tmin = ecoef[ki1];\n      if(ecoef[ki1] > *tmax) *tmax = ecoef[ki1];\n      tmin++; tmax++;\n      if(ecoef[ki2] < *tmin) *tmin = ecoef[ki2];\n      if(ecoef[ki2] > *tmax) *tmax = ecoef[ki2];\n      tmin++; tmax++;\n      t3= t1 - t2;\n      if(t3 < *tmin) *tmin = t3;\n      if(t3 > *tmax) *tmax = t3;\n      tmin++; tmax++;\n      t3= t1 + t2;\n      if(t3 < *tmin) *tmin = t3;\n      if(t3 > *tmax) *tmax = t3;\n    }\n}\n\f\n#if defined(SISLNEEDPROTOTYPES) \nstatic void\n  s1992_s9mbox(double ecoef[],int icoef,int idim,double gmax[],double gmin[])\n#else\nstatic void s1992_s9mbox(ecoef,icoef,idim,gmax,gmin)\n     double ecoef[];\n     int    icoef;\n     int    idim;\n     double gmax[];\n     double gmin[];\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make a SISLbox on the control-polygons given by\n*              ecoef to the object.\n*\n*\n* INPUT      : ecoef  - Control-polygon.\n*              icoef - Number of vertices in control-polygon.\n*\n*                                                                     \n*\n* OUTPUT     : gmax   - Array to contain maximum values of the box.\n*\t       gmin   - Array to contain minimum values of the box.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-02.\n*\n*********************************************************************\n*/                                     \n{\n  int ki,ki1,kj;         /* Counters.  */\n  double noice = (double)100.0 * REL_COMP_RES;   /* Noice killer */ \n  \n  \n  \n  /* Fetch value of first vertex.  */\n  \n  for (ki = 0; ki < idim; ki++) gmin[ki] = gmax[ki] = ecoef[ki];\n  \n  /* For each vertice check and corrigate the box.  */\n  \n  for (kj=1; kj<icoef; kj++)\n    for (ki1 = 0; ki1 < idim; ki1++,ki++) \n      {\n\tif(ecoef[ki] < gmin[ki1]) gmin[ki1] = ecoef[ki];\n\tif(ecoef[ki] > gmax[ki1]) gmax[ki1] = ecoef[ki];\n      }\n\n  /* ALA and UJK 30.10.90, remove noice near by zero */\n  if (idim == 1)\n    {\n      if (fabs(gmax[0]) < noice) gmax[0] = DZERO; \n      if (fabs(gmin[0]) < noice) gmin[0] = DZERO; \n    }\n  \n}\n \n\n\n\n"
  },
  {
    "path": "src/s1993.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1993.c,v 1.2 2001-03-19 15:58:59 afr Exp $\n *\n */\n\n\n#define S1993\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1993(SISLCurve *c1,int *jstat)\n#else\nvoid s1993(c1,jstat)\n     SISLCurve *c1;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Check if a point-curve intersection in one dimention\n*              is a simple case,\n*              i.e. the intersection will result in one single point.\n*\n*\n*\n* INPUT      : c1    - SISLCurve in the intersection problem.\n*\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                                         = 1      : simpel case.\n*                                         = 0      : not simpel case.\n*                                         < 0      : error.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-06.\n* Revised by : ALA and UJK 01.11.90, totale rewritten, same strategy\n*              as in s1994 (surface case).\n*********************************************************************\n*/\n{\n  register int ki;\n\n  int kk,kn;\n  int kbez;\n  double tmax;\n  double tmin;\n  double tdiff;\n  double *scoef=SISL_NULL;\n  double noice = (double)100.0 * REL_COMP_RES;   /* Noice killer */ \n  /* ----------------------------------------------------------- */\n  \n  /* Init to  simple case. */\n  *jstat = 1;\n  \n  tmax = - HUGE;\n  tmin =   HUGE;\n  \n  /* Get curve attributes. */\n  kk  = c1->ik;\n  kn  = c1->in;\n  kbez = (kk == kn);\n  \n  /* Run through vertices to find\n     intervall of first derivative. */\n  \n  for (ki = 1,scoef= c1->ecoef;ki < kn; ki++,scoef++ )\n      {\n\ttdiff = *(scoef + 1) - *scoef;\n\ttmin = min(tmin,tdiff);\n\ttmax = max(tmax,tdiff);\n      }\n  \n  if (fabs(tmin) < noice) tmin = DZERO; \n  if (fabs(tmax) < noice) tmax = DZERO; \n  \n  \n  /* Simple case when no genuin zero's of first derivative. */\n  if (kbez && (tmin*tmax >=DZERO)) \n    *jstat = 1;\n  else if (tmin*tmax > DZERO) \n    *jstat = 1;\n  else if (tmin == tmax)\n    *jstat = 1;\n  else\n    /* Not a simple case. */\n    *jstat = 0;\n\n}\n\n\n\n"
  },
  {
    "path": "src/s1994.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s1994.c,v 1.2 2001-03-19 15:58:59 afr Exp $\n *\n */\n\n\n#define S1994\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns1994(SISLSurf *s1,int *jstat)\n#else\nvoid s1994(s1,jstat)\n     SISLSurf *s1;\n     int  *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Check if a point-surface intersection in one dimention\n*              is a simple case,\n*              i.e. the intersection will result in one single point.\n*\n*\n*\n* INPUT      : s1    - Surface in the intersection problem.\n*\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                                         = 1      : simpel case.\n*                                         = 0      : not simpel case.\n*                                         < 0      : error.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* CALLS      : \n*\n* WRITTEN BY : TDO SI, 89-08.\n*\n*********************************************************************\n*/\n{\n  register int ki,kj;\n  int kk1, kk2, kn1, kn2;\n  int kbez;\n  \n  double tmaxt, tmaxs;\n  double tmint, tmins;\n  double tdiff;\n  double *scoef=SISL_NULL;\n  double noice = (double)100.0 * REL_COMP_RES;   /* Noice killer */ \n  \n  /* Init to  simple case. */\n  *jstat = 1;\n  \n  tmaxt = tmaxs = - HUGE;\n  tmint = tmins =   HUGE;\n  \n  /* Get surface attributes. */\n  kk1  = s1->ik1;\n  kk2  = s1->ik2;\n  kn1  = s1->in1;\n  kn2  = s1->in2;\n  kbez = (kk1 == kn1) && (kk2 == kn2); \n  \n  \n  /* If the surface is linear in some direction it is simpel case. */\n  if ((kk1 == 2 && kn1 == 2) || (kk2 == 2 && kn2 == 2)) goto out;\n  \n  \n  /* Run through vertices in first parameter direction to find\n     intervall of first derivative. */\n  \n  for (kj = 0, scoef = s1->ecoef;kj < kn2; kj++,scoef++)\n    for (ki = 1; ki < kn1; ki++,scoef++ )\n      {\n\ttdiff = *(scoef + 1) - *scoef;\n\ttmint = min(tmint,tdiff);\n\ttmaxt = max(tmaxt,tdiff);\n      }\n  \n  /* Run through vertices in second parameter direction to find\n     intervall of first derivative. */\n  for (ki = 0 ;ki < kn1; ki++)\n    for (kj = 1 , scoef = s1->ecoef + ki; kj < kn2; kj++, scoef +=kn1 )\n      {\n\ttdiff = *(scoef + kn1) - *scoef;\n\ttmins = min(tmins,tdiff);\n\ttmaxs = max(tmaxs,tdiff);\n      }\n\n  /* ALA and UJK 30.10.90, remove noice near by zero */\n  \n  if (fabs(tmint) < noice) tmint = DZERO; \n  if (fabs(tmaxt) < noice) tmaxt = DZERO; \n  if (fabs(tmins) < noice) tmins = DZERO; \n  if (fabs(tmaxs) < noice) tmaxs = DZERO; \n\n\n  \n  \n  /* The first derivatives decide directions of possible intersection curves. */\n  if (kbez && (tmint*tmaxt >=DZERO || tmins*tmaxs >=DZERO)) \n    *jstat = 1;\n  else if (tmint*tmaxt > DZERO || tmins*tmaxs > DZERO) \n    *jstat = 1;\n  else if (tmint == tmaxt  || tmins == tmaxs) \n    *jstat = 1;\n  else\n    /* Not a simple case. */\n    *jstat = 0;\n  \n  goto out;\n out: ;\n}\n\n"
  },
  {
    "path": "src/s2500.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2500.c,v 1.8 2001-03-19 15:58:59 afr Exp $\n *\n */\n\n\n#define S2500\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2500(SISLSurf *surf, int ider, int iside1, int iside2, double parvalue[],\n      int *leftknot1,int *leftknot2, double *gaussian, int *jstat)\n#else\n void s2500(surf, ider, iside1, iside2, parvalue, leftknot1, leftknot2, gaussian, jstat)\n      SISLSurf *surf;\n      int    ider;\n      int    iside1;\n      int    iside2;\n      double parvalue[];\n      int *leftknot1;\n      int *leftknot2;\n      double *gaussian;\n      int *jstat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the Gaussian K(u,v) of a Surface for given\n*                  values (u,v) = (parvalue[0],parvalue[1]), where:\n*\n*                          et1[leftknot1] <= parvalue[0] < et1[leftknot1+1],\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*                  See also s2501().\n*\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Number of derivatives to calculate.\n*                     Only implemented for ider=0.\n*                       < 0 : No derivative calculated.\n*                       = 0 : Position calculated.\n*                       = 1 : Position and first derivative calculated.\n*                       etc.\n*          iside1   - Indicator telling if the derivatives in the first\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*          iside2   - Indicator telling if the derivatives in the second\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*      parvalue     - Parameter-value at which to evaluate. Dimension of\n*                     parvalue is 2.\n*\n*  INPUT/OUTPUT :\n*     leftknot1     - Pointer to the interval in the knot vector in the\n*                     first parameter direction where parvalue[0] is found,\n*                     that is:\n*                          et1[leftknot1] <= parvalue[0] < et1[leftknot1+1].\n*                     leftknot1 should be set equal to zero at the first call\n*                     to the routine.\n*\n*     leftknot2     - Pointer to the interval in the knot vector in the\n*                     second parameter direction where parvalue[1] is found,\n*                     that is:\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*                     leftknot2 should be set equal to zero at the first call\n*                     to the routine.\n*\n*  OUTPUT       :\n*     gaussian      - Gaussian of the surface in (u,v) =\n*                     (parvalue[0],parvalue[1]).\n*        jstat      - Status messages\n*                         = 2 : Surface is degenerate at the point, that is,\n*                               the surface is not regular at this point.\n*                         = 1 : Surface is close to degenerate at the point.\n*                               Angle between tangents is less than the angular\n*                               tolerance.\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*  METHOD       :  The Gaussian is given by\n*\n*                      K(x,y) = (hxx*hyy-hxy^2)/((1+hx^2+hy^2)^2),\n*\n*                  if the surface (h(x,y)) is 1D, and\n*\n*                      K(u,v) = (eg-f*f)/(EG-F*F),\n*\n*                  if the surface (X(u,v)) is 3D. The variables E,F,G,e,f and g\n*                  are the coefficients of the first and second fundamental form.\n*                  They are given by: e = <N,Xuu>, f = <N,Xuv>, g = <N,Xvv>,\n*                  E = <Xu,Xu>, F = <Xu,Xv> and G = <Xv,Xv>. The routine will\n*                  test if the surface is degenerate (not regular) or close to\n*                  degenerate. Call s2501().\n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*-\n*  CALLS        :  s1422() and s2501().\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenerated (not regular) at the point\n*                    (u,v), it makes no sense to speak about the Gaussian\n*                    K(u,v). The routine returns jstat = 2.\n*               (ii) If the surface is closed to degenerate, the Gaussian\n*                    K(u,v) can be numerical instable. The routine returns\n*                    jstat = 1.\n*              (iii) If the surface is Cr the curvature calculated is C(r-2).\n*               (iv) The dimension of the space in which the surface lies must\n*                    be 1,2 or 3.\n*\n*\n* WRITTEN BY :    Geir Westgaard, SINTEF, Oslo, Norway.            Date: 1995-1\n* CORRECTED BY :  Ulf J Krystad, SINTEF, Oslo, Norway.             Date: 1995-1\n*                 Added ider, iside1 and iside2 parameters.\n******************************************************************************\n*/\n{\n  int kwarn = 0;      /* Local staus variable(warning).                  */\n  int kistat = 0;        /* Local staus variable.                           */\n  double derive[18];     /* Array containing the computed derivatives.      */\n  double normal[3];      /* Array containing the computed normalvektor.     */\n\n\n  if (ider != 0) goto err178;\n\n\n  if (surf == SISL_NULL)  goto err150;\n  else\n  {\n    /* Compute derivates and normal. */\n\n    s1422(surf,2,iside1,iside2,parvalue,leftknot1,leftknot2,derive,normal,&kistat);\n    if (kistat > 0) kwarn=kistat;\n\n    if (kistat < 0) /* Error in lower level routine. */\n    {\n      goto error;\n    }\n    else if (kistat != 2) /* The surface is not degenerate */\n    {\n      s2501(surf, ider, derive, normal, gaussian, &kistat);\n\n      if (kistat < 0)\n\tgoto error;\n    }\n    else if (kistat == 2) /* The surface is degenerated. */\n    {\n      *gaussian = 0.0;\n      goto war002;\n    }\n\n  }\n\n\n  /* Successful computations  */\n\n  *jstat = kwarn;\n  goto out;\n\n\n   /* The surface is degenerated at (u,v) */\nwar002:\n  *jstat = 2;\n  goto out;\n\n  /* Error. Input (surface) pointer is SISL_NULL. */\nerr150:\n  *jstat = -150;\n  s6err(\"s2500\", *jstat, 0);\n  goto out;\n\n  /* Illegal derivative requested. */\nerr178:\n  *jstat = -178;\n  s6err(\"s2500\",*jstat,0);\n  goto out;\n  /* Error in lower level routine.  */\n\nerror:\n  *jstat = kistat;\n  s6err(\"s2500\",*jstat,0);\n  goto out;\n\n\nout:\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s2501.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2501.c,v 1.11 2001-06-12 11:07:33 jbt Exp $\n *\n */\n\n\n#define S2501\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2501(SISLSurf *surf, int ider, double derive[], double normal[],\n      double *gaussian, int *jstat)\n#else\n void s2501(surf, ider, derive, normal, gaussian, jstat)\n      SISLSurf *surf;\n      int ider;\n      double derive[];\n      double normal[];\n      double *gaussian;\n      int *jstat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the Gaussian K(u,v) of a Surface for given\n*                  values (u,v). This is a lower level routine, used\n*                  for evaluation of many K(u,v)'s.\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Only implemented for ider=0 (derivative order).\n*       derive      - Array containing derivatives from routine s1421().\n*                     Size = idim*6.\n*       normal      - Array containing the normal from routine s1421().\n*                     Size = 3.\n*\n*  OUTPUT       :\n*     gaussian      - Gaussian of the surface in (u,v) =\n*        jstat      - Status messages\n*\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*  METHOD       :  The Gaussian is given by\n*\n*                      K(x,y) = (hxx*hyy-hxy^2)/((1+hx^2+hy^2)^2),\n*\n*                  if the surface (h(x,y)) is 1D, and\n*\n*                      K(u,v) = (eg-f*f)/(EG-F*F),\n*\n*                  if the surface (X(u,v)) is 3D. The variables E,F,G,e,f and g\n*                  are the coefficients of the first and second fundamental form.\n*                  They are given by: e = <N,Xuu>, f = <N,Xuv>, g = <N,Xvv>,\n*                  E = <Xu,Xu>, F = <Xu,Xv> and G = <Xv,Xv>.\n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*-\n*  CALLS        :\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenerated (not regular) at the point\n*                    (u,v), it makes no sense to speak about the Gaussian\n*                    K(u,v).\n*               (ii) If the surface is closed to degenerate, the Gaussian\n*                    K(u,v) can be numerical unstable.\n*              (iii) The surface is Cr the Gaussian calculated is C(r-2).\n*                    To get the correct behavior use the sided evaluator s1422\n*\t\t     instead of s1421.\n*               (iv) The dimension of the space in which the surface lies must\n*                    be 1,2 or 3, if not, jstat = -105 is returned.\n*\n*\n* WRITTEN BY   :  Geir Westgaard, SINTEF, Oslo, Norway.            Date: 1995-1\n* CORRECTED BY :  Ulf J Krystad, SINTEF, Oslo, Norway.             Date: 1995-1\n*                 Removed knot navigators + some clean up.\n* CORRECTED BY :  Johannes Kaasa, SINTEF, Oslo, Norway.            Date: 1995-8\n*                 Calculated the fundamental form coefficients by\n*                 calls to s2513.\n*****************************************************************************\n*/\n{\n   double fundform[6]; /* The coefficients of the fundamental forms.\n\t\t\t  The sequence is: E, F, G, e, f, g.         */\n\n   if (ider != 0) goto err178;\n\n   if (surf->idim == 1 || surf->idim == 3) /* 1D and 3D surface */\n   {\n      s2513(surf, ider, 2, 0, derive, normal, fundform, jstat);\n      if (*jstat < 0) goto error;\n      \n      *gaussian = (fundform[3]*fundform[5]-fundform[4]*fundform[4])\n\t /((fundform[0]*fundform[2] - fundform[1]*fundform[1])*\n\t   (fundform[0]*fundform[2] - fundform[1]*fundform[1]));\n  }\n\n  else if (surf->idim == 2) /* 2D surface */\n  {\n    /* The surface lies in a plane => K(u,v) = 0 */\n\n    *gaussian = 0.0;\n  }\n  else /* When surf->idim != 1,2 or 3 */\n  {\n    goto err105;\n  }\n\n  /* Successful computations  */\n\n  *jstat = 0;\n  goto out;\n\n\n   /* Error in input, surf->idim != 1,2 or 3 */\nerr105:\n  *jstat = -105;\n  s6err(\"s2501\",*jstat,0);\n  goto out;\n\n  /* Illegal derivative requested. */\nerr178:\n  *jstat = -178;\n  s6err(\"s2501\",*jstat,0);\n  goto out;\n  \nerror:\n  s6err(\"s2501\",*jstat,0);\n  goto out;\n\nout:\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s2502.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2502.c,v 1.7 2001-03-19 15:58:59 afr Exp $\n *\n */\n\n\n#define S2502\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s2502(SISLSurf *surf, int ider, int iside1, int iside2, double parvalue[],\n\t int *leftknot1, int *leftknot2, double *meancurvature, int *jstat)\n#else\n void s2502(surf, ider, iside1, iside2, parvalue, leftknot1, leftknot2,\n\t    meancurvature, jstat)\n      SISLSurf *surf;\n      int    ider;\n      int    iside1;\n      int    iside2;\n      double parvalue[];\n      int *leftknot1;\n      int *leftknot2;\n      double *meancurvature;\n      int *jstat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the mean curvature H(u,v) of a surface for given\n*                  values (u,v) = (parvalue[0],parvalue[1]), where:\n*\n*                          etl[leftknot1] <= parvalue[0] < etl[leftknot1+1],\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Number of derivatives to calculate. Only implemented for ider=0\n*                       < 0 : No derivative calculated.\n*                       = 0 : Position calculated.\n*                       = 1 : Position and first derivative calculated.\n*                       etc.\n*          iside1   - Indicator telling if the derivatives in the first\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*          iside2   - Indicator telling if the derivatives in the second\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*      parvalue     - Parameter-value at which to evaluate. Dimension of\n*                     parvalue is 2.\n*\n*  INPUT/OUTPUT :\n*     leftknot1     - Pointer to the interval in the knot vector in the\n*                     first parameter direction where parvalue[0] is found,\n*                     that is:\n*                          et1[leftknot1] <= parvalue[0] < et1[leftknot1+1].\n*                     leftknot1 should be set equal to zero at the first call\n*                     to the routine.\n*\n*     leftknot2     - Pointer to the interval in the knot vector in the\n*                     second parameter direction where parvalue[1] is found,\n*                     that is:\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*                     leftknot2 should be set equal to zero at the first call\n*                     to the routine.\n*\n*  OUTPUT       :\n*    meancurvature  - Mean curvature of the surface in (u,v) =\n*                     (parvalue[0],parvalue[1]).\n*        jstat      - Status messages\n*                         = 2 : Surface is degenerate at the point, that is,\n*                               the surface is not regular at this point.\n*                         = 1 : Surface is close to degenerate at the point.\n*                               Angle between tangents is less than the angular\n*                               tolerance.\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*  METHOD        :  The mean curvature is given by\n*\n*                      H(x,y) = 0.5((1+hx^2)hyy-2hxhyhxy+(1+hy^2)hxx)/\n*                                      ((1+hx^2+hy^2)^3/2),\n*\n*                  if the surface (h(x,y)) is 1D, and\n*\n*                      H(u,v) = 0.5(eG-2fF+gE)/(EG-F*F),\n*\n*                  if the surface (X(u,v)) is 3D. The variables E,F,G,e,f and g\n*                  are the coefficients of the first and second fundamental form.\n*                  They are given by: e = <N,Xuu>, f = <N,Xuv>, g = <N,Xvv>,\n*                  E = <Xu,Xu>, F = <Xu,Xv> and G = <Xv,Xv>. The routine will\n*                  test if the surface is degenerate (not regular) or close to\n*                  degenerate.\n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*-\n*  CALLS        :  s1422() and s2503().\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenerated (not regular) at the point\n*                    (u,v), it makes no sense to speak about the mean curvature\n*                    H(u,v). The routine returns jstat = 2.\n*               (ii) If the surface is closed to degenerate, the mean curvature\n*                    H(u,v) can be numerical unstable. The routine returns\n*                    jstat = 1.\n*              (iii) If the surface is Cr the curvature calculated is C(r-2).\n*               (iv) The dimension of the space in which the surface lies must\n*                    be 1,2 or 3.\n*\n*\n* WRITTEN BY :    Geir Westgaard, SINTEF, Oslo, Norway.            Date: 1995-1\n* CORRECTED BY :  Ulf J Krystad, SINTEF, Oslo, Norway.             Date: 1995-1\n*                 Added ider, iside1 and iside2 parameters.\n******************************************************************************\n*/\n{\n  int kwarn = 0;      /* Local staus variable(warning).                  */\n  int kistat = 0;     /* Local staus variable.                           */\n  double derive[18];  /* Array containing the computed derivatives.      */\n  double normal[3];   /* Array containing the computed normalvektor.     */\n\n\n  if (ider != 0) goto err178;\n\n  if (surf == SISL_NULL)  goto err150;\n  else\n  {\n    /* Compute derivates and normal. */\n\n    s1422(surf,2,iside1,iside2,parvalue,leftknot1,leftknot2,\n\t  derive,normal,&kistat);\n    if (kistat > 0) kwarn=kistat;\n\n    if (kistat < 0) /* Error in lower level routine. */\n    {\n      goto error;\n    }\n    else if (kistat != 2) /* The surface is not degenerate */\n    {\n      s2503(surf, ider, derive, normal, meancurvature, &kistat);\n\n      if (kistat < 0)\n\tgoto error;\n    }\n    else if (kistat == 2) /* The surface is degenerated. */\n    {\n      *meancurvature = 0.0;\n      goto war002;\n    }\n\n  }\n\n\n  /* Successful computations  */\n\n  *jstat = kwarn;\n  goto out;\n\n\n\n   /* The surface is degenerated at (u,v) */\nwar002:\n  *jstat = 2;\n  goto out;\n\n  /* Error. Input (surface) pointer is SISL_NULL. */\nerr150:\n  *jstat = -150;\n  s6err(\"s2502\", *jstat, 0);\n  goto out;\n\n  /* Illegal derivative requested. */\nerr178:\n  *jstat = -178;\n  s6err(\"s2502\",*jstat,0);\n  goto out;\n\n   /* Error in lower level routine.  */\nerror:\n  *jstat = kistat;\n  s6err(\"s2502\",*jstat,0);\n  goto out;\n\nout:\n\n  return;\n}\n"
  },
  {
    "path": "src/s2503.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2503.c,v 1.10 2001-06-12 11:07:33 jbt Exp $\n *\n */\n\n\n#define S2503\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s2503(SISLSurf *surf, int ider, double derive[], double normal[],\n\t   double *meancurvature, int *jstat)\n#else\n void s2503(surf, ider, derive, normal, meancurvature, jstat)\n      SISLSurf *surf;\n      int ider;\n      double derive[];\n      double normal[];\n      double *meancurvature;\n      int *jstat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the mean curvature H(u,v) of a surface for given\n*                  values (u,v). This is a lower level routine, used\n*                  for evaluation of many H(u,v)'s.\n*\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Only implemented for ider=0 (derivative order).\n*       derive      - Array containing derivatives from routine s1421().\n*                     Size = idim*6.\n*       normal      - Array containing the normal from routine s1421().\n*                     Size = 3.\n*  OUTPUT       :\n*    meancurvature  - Mean curvature of the surface in (u,v) =\n*        jstat      - Status messages\n*\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*  METHOD       :  The mean curvature is given by\n*\n*                      H(x,y) = 0.5((1+hx^2)hyy-2hxhyhxy+(1+hy^2)hxx)/\n*                                      ((1+hx^2+hy^2)^3/2),\n*\n*                  if the surface (h(x,y)) is 1D, and\n*\n*                      H(u,v) = 0.5(eG-2fF+gE)/(EG-F*F),\n*\n*                  if the surface (X(u,v)) is 3D. The variables E,F,G,e,f and g\n*                  are the coefficients of the first and second fundamental form.\n*                  They are given by: e = <N,Xuu>, f = <N,Xuv>, g = <N,Xvv>,\n*                  E = <Xu,Xu>, F = <Xu,Xv> and G = <Xv,Xv>. The routine will\n*                  test if the surface is degenerate (not regular) or close to\n*                  degenerate.\n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*\n*  CALLS        :\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenerated (not regular) at the point\n*                    (u,v), it makes no sense to speak about the mean curvature\n*                    H(u,v).\n*               (ii) If the surface is closed to degenerate, the mean curvature\n*                    H(u,v) can be numerical unstable.\n*              (iii) If the surface is Cr the curvature calculated is C(r-2).\n*                    To get the correct behavior use the sided evaluator s1422\n*\t\t     instead of s1421.\n*               (iv) The dimension of the space in which the surface lies must\n*                    be 1,2 or 3, if not, jstat = -105 is returned.\n*\n*\n* WRITTEN BY :  Geir Westgaard, SINTEF, Oslo, Norway.             Date: 1995-1\n* CORRECTED BY :  Ulf J Krystad, SINTEF, Oslo, Norway.            Date: 1995-1\n*                 Removed knot navigators + some clean up.\n* CORRECTED BY :  Johannes Kaasa, SINTEF, Oslo, Norway.           Date: 1995-8\n*                 Calculated the fundamental form coefficients by\n*                 calls to s2513.\n******************************************************************************\n*/\n{\n   double fundform[6]; /* The coefficients of the fundamental forms.\n\t\t\t  The sequence is: E, F, G, e, f, g.         */\n\n   if (ider != 0) goto err178;\n\n   if (surf->idim == 1 || surf->idim == 3) /* 1D and 3D surface */\n   {\n      s2513(surf, ider, 2, 0, derive, normal, fundform, jstat);\n      if (*jstat < 0) goto error;\n      \n      *meancurvature = 0.5*(fundform[3]*fundform[2] - 2*fundform[4]*fundform[1] \n\t\t\t    + fundform[5]*fundform[0])\n\t /((fundform[0]*fundform[2] - fundform[1]*fundform[1])\n\t   *sqrt(fundform[0]*fundform[2] - fundform[1]*fundform[1]));\n   }\n\n  else if (surf->idim == 2) /* 2D surface */\n  {\n    /* The surface lies in a plane => H(u,v) = 0 */\n\n    *meancurvature = 0.0;\n  }\n  else /* When surf->idim != 1,2 or 3 */\n  {\n    goto err105;\n  }\n\n   \n  /* Successful computations  */\n\n  *jstat = 0;\n  goto out;\n\n\n   /* Error in input, surf->idim != 1,2 or 3 */\nerr105:\n  *jstat = -105;\n  s6err(\"s2503\", *jstat, 0);\n  goto out;\n\n  /* Illegal derivative requested. */\nerr178:\n  *jstat = -178;\n  s6err(\"s2503\",*jstat,0);\n  goto out;\n  \nerror:\n  s6err(\"s2503\",*jstat,0);\n  goto out;\n\nout:\n\n  return;\n}\n"
  },
  {
    "path": "src/s2504.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2504.c,v 1.3 2001-03-19 15:58:59 afr Exp $\n *\n */\n\n\n#define S2504\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s2504(SISLSurf *surf, int ider, int iside1, int iside2, double parvalue[],\n      int *leftknot1,int *leftknot2, double *absCurvature, int *jstat)\n#else\n void s2504(surf, ider, iside1, iside2, parvalue, leftknot1, leftknot2,\n\t    absCurvature, jstat)\n      SISLSurf *surf;\n      int    ider;\n      int    iside1;\n      int    iside2;\n      double parvalue[];\n      int *leftknot1;\n      int *leftknot2;\n      double *absCurvature;\n      int *jstat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the absolute curvature A(u,v) of a Surface for\n*                  given values (u,v) = (parvalue[0],parvalue[1]), where:\n*\n*                          et1[leftknot1] <= parvalue[0] < et1[leftknot1+1],\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Number of derivatives to calculate.\n*                     Only implemented for ider=0.\n*                       < 0 : No derivative calculated.\n*                       = 0 : Position calculated.\n*                       = 1 : Position and first derivative calculated.\n*                       etc.\n*          iside1   - Indicator telling if the derivatives in the first\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*          iside2   - Indicator telling if the derivatives in the second\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*      parvalue     - Parameter-value at which to evaluate. Dimension of\n*                     parvalue is 2.\n*\n*  INPUT/OUTPUT :\n*     leftknot1     - Pointer to the interval in the knot vektor in the\n*                     first parameter direction where parvalue[0] is found,\n*                     that is:\n*                          et1[leftknot1] <= parvalue[0] < et1[leftknot1+1].\n*                     leftknot1 should be set equal to zero at the first call\n*                     to the rutine.\n*\n*     leftknot1     - Pointer to the interval in the knot vektor in the\n*                     second parameter direction where parvalue[1] is found,\n*                     that is:\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*                     leftknot2 should be set equal to zero at the first call\n*                     to the rutine.\n*\n*  OUTPUT       :\n*    absCurvature   - Absolute curvature of the surface in (u,v) =\n*                     (parvalue[0],parvalue[1]).\n*        jstat      - Status messages\n*                         = 2 : Surface is degenerate at the point, that is,\n*                               the surface is not regular at this point.\n*                         = 1 : Surface is close to degenerate at the point.\n*                               Angle between tangents is less than the angular\n*                               tolerance.\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*\n*  METHOD        :  The absolute curvature is given by\n*\n*                      A(x,y) = |k1| + |k2|,\n*\n*                  if the surface (h(x,y)) is 1D, and\n*\n*                      A(u,v) = |k1| + |k2|,\n*\n*                  if the surface (X(u,v)) is 3D. The variables E,F,G,e,f and g\n*                  are the coefficents of the first and second fundamental form.\n*                  They are given by: e = <N,Xuu>, f = <N,Xuv>, g = <N,Xvv>,\n*                  E = <Xu,Xu>, F = <Xu,Xv> and G = <Xv,Xv>. The rutine will\n*                  test if the surface is degenerate (not regular) or close to\n*                  degenerate.\n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*-\n*  CALLS        :  s1422() and s2505().\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenrated (not regular) at the point\n*                    (u,v), it makes now sence to speak about the absolute c.\n*                    A(u,v). The routine return jstat == 2.\n*               (ii) If the surface is closed to degenrate, the absolute c.\n*                    A(u,v) can be numerical unstable. The routine return\n*                    jstat == 1.\n*              (iii) The surface should be C2, since the absolute c. is calculated\n*                    from the second derivativs. But since the rutine is using\n*                    right derivatives, the absolute c. will be correct (provided\n*                    that the surface is not degenerate).\n*               (iv) The dimension of the space in which the surface lies must\n*                    be 1,2 or 3.  The routine return jstat < 0.\n*\n*\n* WRITTEN BY    :  Geir Westgaard,  SINTEF, Oslo, Norway.         Date: 1995-1\n******************************************************************************\n*/\n{\n  int kwarn = 0;         /* Local staus variable(warning).                  */\n  int kistat = 0;        /* Local staus variable.                           */\n  double derive[18];     /* Array containing the computed derivatives.      */\n  double normal[3];      /* Array containing the computed normalvektor.     */\n\n\n  if (ider != 0) goto err178;\n\n\n  if (surf == SISL_NULL)  goto err150;\n  else\n  {\n    /* Compute derivates and normal. */\n\n    s1422(surf,2,iside1,iside2,parvalue,leftknot1,leftknot2,derive,normal,&kistat);\n    if (kistat > 0) kwarn=kistat;\n\n    if (kistat < 0) /* Error in lower level routine. */\n    {\n      goto error;\n    }\n    else if (kistat != 2) /* The surface is not degenerate */\n    {\n      s2505(surf, ider, derive, normal, absCurvature, &kistat);\n\n      if (kistat < 0)\n\tgoto error;\n    }\n    else if (kistat == 2) /* The surface is degenerated. */\n    {\n      *absCurvature = 0.0;\n      goto war002;\n    }\n\n  }\n\n\n\n  /* Successful computations  */\n\n  *jstat = kwarn;\n  goto out;\n\n\n   /* The surface is degenerated at (u,v) */\nwar002:\n  *jstat = 2;\n  goto out;\n\n  /* Error. Input (surface) pointer is SISL_NULL. */\nerr150:\n  *jstat = -150;\n  s6err(\"s2504\", *jstat, 0);\n  goto out;\n\n  /* Illegal derivative requested. */\nerr178:\n  *jstat = -178;\n  s6err(\"s2504\",*jstat,0);\n  goto out;\n\n  /* Error in lower level routine.  */\nerror:\n  *jstat = kistat;\n  s6err(\"s2504\",*jstat,0);\n  goto out;\n\n\nout:\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s2505.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2505.c,v 1.10 2001-06-12 11:07:34 jbt Exp $\n *\n */\n\n\n#define S2505\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2505(SISLSurf *surf, int der, double derive[], double normal[],\n      double *absCurvature, int *jstat)\n#else\n void s2505(surf, der, derive, normal, absCurvature, jstat)\n      SISLSurf *surf;\n      int der;\n      double derive[];\n      double normal[];\n      double *absCurvature;\n      int *jstat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the absolute curvature K(u,v) of a Surface\n*                  for given values (u,v). This is a lower level routine,\n*                  used for evaluation of many K(u,v)'s.\n*\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          der      - Not used.\n*       derive      - Array containing derivatives from routine s1421().\n*                     Size = idim*6.\n*       normal      - Array containing the normal from routine s1421().\n*                     Size = 3.\n*\n*  INPUT/OUTPUT :\n*\n*  OUTPUT       :\n*    absCurvature   - Absolute curvature of the surface in (u,v) =\n*        jstat      - Staus messages\n*                         = 2 : Surface is degenrate at the point, that is,\n*                               the surface is not regular at this point.\n*                         = 1 : Surface is closed to degenrate at the point.\n*                               Angle between tangents is less than the angular\n*                               tolerance.\n*                         = 0 : Ok.\n*                         < 0 : error.\n*\n*  METHOD        :  The absolute curvature is given by\n*\n*                      A(x,y) = |k1| + |k2|,\n*\n*                  if the surface (h(x,y)) is 1D, and\n*\n*                      A(u,v) = |k1| + |k2|,\n*\n*                  if the surface (X(u,v)) is 3D. The variables E,F,G,e,f and g\n*                  are the coefficents of the first and second fundamental form.\n*                  They are given by: e = <N,Xuu>, f = <N,Xuv>, g = <N,Xvv>,\n*                  E = <Xu,Xu>, F = <Xu,Xv> and G = <Xv,Xv>. The rutine will\n*                  test if the surface is degenerate (not regular) or close to\n*                  degenerate.\n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*-\n*  CALLS        :  s1421() and s1424().\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenrated (not regular) at the point\n*                    (u,v), it makes now sence to speak about the absolute c.\n*                    A(u,v). The routine return jstat == 2.\n*               (ii) If the surface is closed to degenrate, the absolute c.\n*                    A(u,v) can be numerical unstable. The routine return\n*                    jstat == 1.\n*              (iii) The surface should be C2, since the absolute c. is calculated\n*                    from the second derivativs. But since the rutine is using\n*                    right derivatives, the absolute c. will be correct (provided\n*                    that the surface is not degenerate).\n*               (iv) The dimension of the space in which the surface lies must\n*                    be 1,2 or 3.  The routine return jstat < 0.\n*\n*\n* WRITTEN BY :  Geir Westgaard, SINTEF, Oslo, Norway.            Date: 1995-1\n* CORRECTED BY :  Johannes Kaasa, SINTEF, Oslo, Norway.          Date: 1995-06\n*                 Used absolute valute in square for principal curvature.\n* CORRECTED BY :  Johannes Kaasa, SINTEF, Oslo, Norway.            Date: 1995-8\n*                 Calculated the fundamental form coefficients by\n*                 calls to s2513.\n*****************************************************************************\n*/\n{\n   double fundform[6]; /* The coefficients of the fundamental forms.\n\t\t\t  The sequence is: E, F, G, e, f, g.         */\n   double gc;          /* Gaussian curvature.                        */\n   double mc;          /* Mean curvature.                            */\n\n\n\n   if (surf->idim == 1 || surf->idim == 3) /* 1D and 3D surface */\n   {   \n      s2513(surf, der, 2, 0, derive, normal, fundform, jstat);\n      if (*jstat < 0) goto error;\n      \n      gc = (fundform[3]*fundform[5]-fundform[4]*fundform[4])\n\t /((fundform[0]*fundform[2] - fundform[1]*fundform[1])*\n\t   (fundform[0]*fundform[2] - fundform[1]*fundform[1]));\n      mc = 0.5*(fundform[3]*fundform[2] - 2*fundform[4]*fundform[1] \n\t\t\t    + fundform[5]*fundform[0])\n\t /((fundform[0]*fundform[2] - fundform[1]*fundform[1])\n\t   *sqrt(fundform[0]*fundform[2] - fundform[1]*fundform[1]));\n\n      *absCurvature = fabs(mc + sqrt(fabs(mc*mc - gc))) +\n       fabs(mc - sqrt(fabs(mc*mc - gc)));\n   }\n\n  else if (surf->idim == 2) /* 2D surface */\n  {\n    /* The surface lies in a plane => A(u,v) = 0 */\n\n    *absCurvature = 0.0;\n  }\n  else /* When surf->idim != 1,2 or 3 */\n  {\n    goto err105;\n  }\n\n\n  /* Successful computations  */\n\n  *jstat = 0;\n  goto out;\n\n\n  /* Error in input, surf->idim != 1,2 or 3 */\nerr105:\n  *jstat = -105;\n  s6err(\"s2505\",*jstat,0);\n  goto out;\n  \nerror:\n  s6err(\"s2505\",*jstat,0);\n  goto out;\n\nout:\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s2506.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2506.c,v 1.2 2001-03-19 15:58:59 afr Exp $\n *\n */\n\n\n#define S2506\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s2506(SISLSurf *surf, int ider, int iside1, int iside2, double parvalue[],\n      int *leftknot1,int *leftknot2, double *totalCurvature, int *jstat)\n#else\n void s2506(surf, ider, iside1, iside2, parvalue, leftknot1, leftknot2,\n\t    totalCurvature, jstat)\n      SISLSurf *surf;\n      int    ider;\n      int    iside1;\n      int    iside2;\n      double parvalue[];\n      int *leftknot1;\n      int *leftknot2;\n      double *totalCurvature;\n      int *jstat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the total curvature T(u,v) of a surface for\n*                  given values (u,v) = (parvalue[0],parvalue[1]), where:\n*\n*                          et1[leftknot1] <= parvalue[0] < et1[leftknot1+1],\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Number of derivatives to calculate.\n*                     Only implemented for ider=0.\n*                       < 0 : No derivative calculated.\n*                       = 0 : Position calculated.\n*                       = 1 : Position and first derivative calculated.\n*                       etc.\n*          iside1   - Indicator telling if the derivatives in the first\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*          iside2   - Indicator telling if the derivatives in the second\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*      parvalue     - Parameter-value at which to evaluate. Dimension of\n*                     parvalue is 2.\n*\n*  INPUT/OUTPUT :\n*     leftknot1     - Pointer to the interval in the knot vector in the\n*                     first parameter direction where parvalue[0] is found,\n*                     that is:\n*                          et1[leftknot1] <= parvalue[0] < et1[leftknot1+1].\n*                     leftknot1 should be set equal to zero at the first call\n*                     to the routine.\n*\n*     leftknot1     - Pointer to the interval in the knot vector in the\n*                     second parameter direction where parvalue[1] is found,\n*                     that is:\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*                     leftknot2 should be set equal to zero at the first call\n*                     to the routine.\n*\n*  OUTPUT       :\n*    totalCurvature - Total curvature of the surface in (u,v) =\n*                     (parvalue[0],parvalue[1]).\n*        jstat      - Status messages\n*                         = 2 : Surface is degenerate at the point, that is,\n*                               the surface is not regular at this point.\n*                         = 1 : Surface is close to degenerate at the point.\n*                               Angle between tangents is less than the angular\n*                               tolerance.\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*\n*  METHOD        :  The total curvature is given by\n*\n*                      T(x,y) = k1^2 + k2^2,\n*\n*                  if the surface (h(x,y)) is 1D, and\n*\n*                      T(u,v) = k1^2 + k2^2,\n*\n*                  if the surface (X(u,v)) is 3D. The variables E,F,G,e,f and g\n*                  are the coefficients of the first and second fundamental form.\n*                  They are given by: e = <N,Xuu>, f = <N,Xuv>, g = <N,Xvv>,\n*                  E = <Xu,Xu>, F = <Xu,Xv> and G = <Xv,Xv>. The rutine will\n*                  test if the surface is degenerate (not regular) or close to\n*                  degenerate.\n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*-\n*  CALLS        :  s1422() and s2507().\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenerated (not regular) at the point\n*                    (u,v), it makes now sense to speak about the absolute c.\n*                    T(u,v). The routine return jstat == 2.\n*               (ii) If the surface is closed to degenerate, the absolute c.\n*                    T(u,v) can be numerical unstable. The routine return\n*                    jstat == 1.\n*              (iii) The surface should be C2, since the absolute c. is calculated\n*                    from the second derivatives. But since the routine is using\n*                    right derivatives, the absolute c. will be correct (provided\n*                    that the surface is not degenerate).\n*               (iv) The dimension of the space in which the surface lies must\n*                    be 1,2 or 3.  The routine return jstat < 0.\n*\n*\n* WRITTEN BY    :  Geir Westgaard,  SINTEF, Oslo, Norway.         Date: 1995-1\n******************************************************************************\n*/\n{\n  int kwarn = 0;         /* Local staus variable(warning).                  */\n  int kistat = 0;        /* Local staus variable.                           */\n  int der = 0;           /*  (dummy) */\n  double derive[18];     /* Array containing the computed derivatives.      */\n  double normal[3];      /* Array containing the computed normalvektor.     */\n\n\n  if (ider != 0) goto err178;\n\n\n  if (surf == SISL_NULL)  goto err150;\n  else\n  {\n    /* Compute derivates and normal. */\n\n    s1422(surf,2,iside1,iside2,parvalue,leftknot1,leftknot2,derive,normal,&kistat);\n    if (kistat > 0) kwarn=kistat;\n\n    if (kistat < 0) /* Error in lower level routine. */\n    {\n      goto error;\n    }\n    else if (kistat != 2) /* The surface is not degenerate */\n    {\n      s2507(surf, der, derive, normal, totalCurvature, &kistat);\n\n      if (kistat < 0)\n\tgoto error;\n    }\n    else if (kistat == 2) /* The surface is degenerated. */\n    {\n      *totalCurvature = 0.0;\n      goto war002;\n    }\n\n  }\n\n\n\n  /* Successful computations  */\n\n  *jstat = kwarn;\n  goto out;\n\n\n   /* The surface is degenerated at (u,v) */\nwar002:\n  *jstat = 2;\n  goto out;\n\n  /* Error. Input (surface) pointer is SISL_NULL. */\nerr150:\n  *jstat = -150;\n  s6err(\"s2506\", *jstat, 0);\n  goto out;\n\n  /* Illegal derivative requested. */\nerr178:\n  *jstat = -178;\n  s6err(\"s2506\",*jstat,0);\n  goto out;\n  /* Error in lower level routine.  */\n\nerror:\n  *jstat = kistat;\n  s6err(\"s2506\",*jstat,0);\n  goto out;\n\n\nout:\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s2507.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2507.c,v 1.10 2001-06-12 11:07:34 jbt Exp $\n *\n */\n\n\n#define S2507\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2507(SISLSurf *surf, int ider, double derive[], double normal[],\n      double *totalCurvature, int *jstat)\n#else\n void s2507(surf, ider, derive, normal, totalCurvature, jstat)\n      SISLSurf *surf;\n      int ider;\n      double derive[];\n      double normal[];\n      double *totalCurvature;\n      int *jstat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the total curvature T(u,v) of a Surface\n*                  for given values (u,v). This is a lower level routine,\n*                  used for evaluation of many T(u,v)'s.\n*\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Not used.\n*       derive      - Array containing derivatives from routine s1421().\n*                     Size = idim*6.\n*       normal      - Array containing the normal from routine s1421().\n*                     Size = 3.\n*\n*  INPUT/OUTPUT :\n*\n*  OUTPUT       :\n*    totalCurvature - Total curvature of the surface in (u,v).\n*        jstat      - Staus messages\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*  METHOD        :  The total curvature is given by\n*\n*                      T(x,y) = k1^2 + k2^2,\n*\n*                  if the surface (h(x,y)) is 1D, and\n*\n*                      T(u,v) = = k1^2 + k2^2,\n*\n*                  if the surface (X(u,v)) is 3D. The variables E,F,G,e,f and g\n*                  are the coefficients of the first and second fundamental form.\n*                  They are given by: e = <N,Xuu>, f = <N,Xuv>, g = <N,Xvv>,\n*                  E = <Xu,Xu>, F = <Xu,Xv> and G = <Xv,Xv>.\n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*-\n*  CALLS        :\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenerated (not regular) at the point\n*                    (u,v), it makes now sense to speak about T(u,v).\n*               (ii) If the surface is closed to degenerate, T(u,v)\n*                    can be numerical unstable.\n*              (iii) The surface should be C2, since the total c. is calculated\n*                    from the second derivatives.\n*               (iv) The dimension of the space in which the surface lies must\n*                    be 1,2 or 3.  The routine return jstat < 0.\n*\n*\n* WRITTEN BY :  Geir Westgaard, SINTEF, Oslo, Norway.            Date: 1995-1\n* CORRECTED BY :  Johannes Kaasa, SINTEF, Oslo, Norway.          Date: 1995-06\n*                 Used absolute valute in square for principal curvature.\n* CORRECTED BY :  Johannes Kaasa, SINTEF, Oslo, Norway.            Date: 1995-8\n*                 Calculated the fundamental form coefficients by\n*                 calls to s2513.\n*****************************************************************************\n*/\n{\n   double fundform[6]; /* The coefficients of the fundamental forms.\n\t\t\t  The sequence is: E, F, G, e, f, g.              */\n   double gc;          /* Gaussian curvature.                             */\n   double mc;          /* Mean curvature.                                 */\n   double k1,k2;       /* Max. and min. principal curvature.              */\n\n\n\n   if (surf->idim == 1 || surf->idim == 3) /* 1D and 3D surface */\n   {\n      s2513(surf, ider, 2, 0, derive, normal, fundform, jstat);\n      if (*jstat < 0) goto error;\n      \n      gc = (fundform[3]*fundform[5]-fundform[4]*fundform[4])\n\t /((fundform[0]*fundform[2] - fundform[1]*fundform[1])*\n\t   (fundform[0]*fundform[2] - fundform[1]*fundform[1]));\n      mc = 0.5*(fundform[3]*fundform[2] - 2*fundform[4]*fundform[1] \n\t\t\t    + fundform[5]*fundform[0])\n\t /((fundform[0]*fundform[2] - fundform[1]*fundform[1])\n\t   *sqrt(fundform[0]*fundform[2] - fundform[1]*fundform[1]));\n\n     k1 = mc + sqrt(fabs(mc*mc - gc));\n     k2 = mc - sqrt(fabs(mc*mc - gc));\n\n     *totalCurvature = k1*k1 + k2*k2;\n   }\n  else if (surf->idim == 2) /* 2D surface */\n  {\n    /* The surface lies in a plane => T(u,v) = 0 */\n\n    *totalCurvature = 0.0;\n  }\n  else /* When surf->idim != 1,2 or 3 */\n  {\n    goto err105;\n  }\n\n  /* Successful computations  */\n\n  *jstat = 0;\n  goto out;\n\n\n   /* Error in input, surf->idim != 1,2 or 3 */\nerr105:\n  *jstat = -105;\n  s6err(\"s2507\", *jstat, 0);\n  goto out;\n  \nerror:\n  s6err(\"s2507\",*jstat,0);\n  goto out;\n\nout:\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s2508.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2508.c,v 1.5 2001-03-19 15:58:59 afr Exp $\n *\n */\n\n\n#define S2508\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2508(SISLSurf *surf, int ider, int iside1, int iside2, double parvalue[],\n      int *leftknot1,int *leftknot2, double *mehlum, int *jstat)\n#else\n void s2508(surf, ider, iside1, iside2, parvalue, leftknot1, leftknot2, mehlum, jstat)\n      SISLSurf *surf;\n      int    ider;\n      int    iside1;\n      int    iside2;\n      double parvalue[];\n      int *leftknot1;\n      int *leftknot2;\n      double *mehlum;\n      int *jstat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the second order Mehlum curvature M(u,v) of a \n*                  surface for given values (u,v) = (parvalue[0],parvalue[1]), \n*                  where:\n*\n*                          et1[leftknot1] <= parvalue[0] < et1[leftknot1+1],\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*                  See also s2509().\n*\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Number of derivatives to calculate.\n*                     Only implemented for ider=0.\n*                       < 0 : No derivative calculated.\n*                       = 0 : Position calculated.\n*                       = 1 : Position and first derivative calculated.\n*                       etc.\n*          iside1   - Indicator telling if the derivatives in the first\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*          iside2   - Indicator telling if the derivatives in the second\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*      parvalue     - Parameter-value at which to evaluate. Dimension of\n*                     parvalue is 2.\n*\n*  INPUT/OUTPUT :\n*     leftknot1     - Pointer to the interval in the knot vector in the\n*                     first parameter direction where parvalue[0] is found,\n*                     that is:\n*                          et1[leftknot1] <= parvalue[0] < et1[leftknot1+1].\n*                     leftknot1 should be set equal to zero at the first call\n*                     to the routine.\n*\n*     leftknot2     - Pointer to the interval in the knot vector in the\n*                     second parameter direction where parvalue[1] is found,\n*                     that is:\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*                     leftknot2 should be set equal to zero at the first call\n*                     to the routine.\n*\n*  OUTPUT       :\n*     mehlum        - The second order Mehlum curvature of the surface in (u,v) =\n*                     (parvalue[0],parvalue[1]).\n*        jstat      - Status messages\n*                         = 2 : Surface is degenerate at the point, that is,\n*                               the surface is not regular at this point.\n*                         = 1 : Surface is close to degenerate at the point.\n*                               Angle between tangents is less than the angular\n*                               tolerance.\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*  METHOD       :  The second order Mehlum curvature is given by\n*\n*                      M(u,v) = 3(eG-2fF+gE)^2/8(EG-F*F)^3 - \n*                               (eg-f*f)/2(EG-F*F)^2.\n*\n*                  The variables E,F,G,e,f and g\n*                  are the coefficients of the first and second fundamental form.\n*                  They are given by: e = <N,Xuu>, f = <N,Xuv>, g = <N,Xvv>,\n*                  E = <Xu,Xu>, F = <Xu,Xv> and G = <Xv,Xv>. The routine will\n*                  test if the surface is degenerate (not regular) or close to\n*                  degenerate. Call s2509().\n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*-\n*  CALLS        :  s1422() and s2509().\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenerated (not regular) at the point\n*                    (u,v), it makes no sense to speak about the Mehlum\n*                    M(u,v). The routine returns jstat = 2.\n*               (ii) If the surface is closed to degenerate, the Mehlum\n*                    M(u,v) can be numerical instable. The routine returns\n*                    jstat = 1.\n*              (iii) The dimension of the space in which the surface lies must\n*                    be 1,2 or 3.\n*\n*\n* WRITTEN BY :    Johannes Kaasa, SINTEF, Oslo, Norway.            Date: 1995-8\n******************************************************************************\n*/\n{\n  int kwarn = 0;         /* Local staus variable(warning).                  */\n  int kistat = 0;        /* Local staus variable.                           */\n  double derive[18];     /* Array containing the computed derivatives.      */\n  double normal[3];      /* Array containing the computed normalvektor.     */\n\n\n  if (ider != 0) goto err178;\n\n\n  if (surf == SISL_NULL)  goto err150;\n  else\n  {\n    /* Compute derivates and normal. */\n\n    s1422(surf,2,iside1,iside2,parvalue,leftknot1,leftknot2,derive,normal,&kistat);\n    if (kistat > 0) kwarn=kistat;\n\n    if (kistat < 0) /* Error in lower level routine. */\n    {\n      goto error;\n    }\n    else if (kistat != 2) /* The surface is not degenerate */\n    {\n      s2509(surf, ider, derive, normal, mehlum, &kistat);\n\n      if (kistat < 0)\n\tgoto error;\n    }\n    else if (kistat == 2) /* The surface is degenerated. */\n    {\n      *mehlum = 0.0;\n      goto war002;\n    }\n\n  }\n\n\n  /* Successful computations  */\n\n  *jstat = kwarn;\n  goto out;\n\n\n   /* The surface is degenerated at (u,v) */\nwar002:\n  *jstat = 2;\n  goto out;\n\n  /* Error. Input (surface) pointer is SISL_NULL. */\nerr150:\n  *jstat = -150;\n  s6err(\"s2508\", *jstat, 0);\n  goto out;\n\n  /* Illegal derivative requested. */\nerr178:\n  *jstat = -178;\n  s6err(\"s2508\",*jstat,0);\n  goto out;\n  /* Error in lower level routine.  */\n\nerror:\n  *jstat = kistat;\n  s6err(\"s2508\",*jstat,0);\n  goto out;\n\n\nout:\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s2509.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2509.c,v 1.5 2001-06-12 11:07:34 jbt Exp $\n *\n */\n\n\n#define S2509\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2509(SISLSurf *surf, int ider, double derive[], double normal[],\n      double *mehlum, int *jstat)\n#else\n void s2509(surf, ider, derive, normal, mehlum, jstat)\n      SISLSurf *surf;\n      int ider;\n      double derive[];\n      double normal[];\n      double *mehlum;\n      int *jstat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the second Mehlum curvature M(u,v) of a surface \n*                  for given values (u,v). This is a lower level routine, used\n*                  for evaluation of many M(u,v)'s.\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Only implemented for ider=0 (derivative order).\n*       derive      - Array containing derivatives from routine s1421().\n*                     Size = idim*6.\n*       normal      - Array containing the normal from routine s1421().\n*                     Size = 3.\n*\n*  OUTPUT       :\n*       mehlum      - The second order Mehlum curvature of the surface.\n*        jstat      - Status messages\n*\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*  METHOD       :  The second order Mehlum curvature is given by\n*\n*                      M(u,v) = 3(eG-2fF+gE)^2/8(EG-F*F)^3 - \n*                               (eg-f*f)/2(EG-F*F)^2.\n*\n*                  The variables E,F,G,e,f and g\n*                  are the coefficients of the first and second fundamental form.\n*                  They are given by: e = <N,Xuu>, f = <N,Xuv>, g = <N,Xvv>,\n*                  E = <Xu,Xu>, F = <Xu,Xv> and G = <Xv,Xv>.\n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*-\n*  CALLS        :\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenerated (not regular) at the point\n*                    (u,v), it makes no sense to speak about the Mehlum\n*                    M(u,v).\n*               (ii) If the surface is closed to degenerate, the Mehlum\n*                    M(u,v) can be numerical unstable.\n*              (iii) The dimension of the space in which the surface lies must\n*                    be 1,2 or 3, if not, jstat = -105 is returned.\n*\n*\n* WRITTEN BY   :  Johannes Kaasa, SINTEF, Oslo, Norway.            Date: 1995-8\n*****************************************************************************\n*/\n{\n   double fundform[6]; /* The coefficients of the fundamental forms.\n\t\t\t  The sequence is: E, F, G, e, f, g.         */\n   double numerator;   /* Value of a numerator.                      */\n   double denominator; /* Value of a denominator.                    */\n\n   if (ider != 0) goto err178;\n\n   if (surf->idim == 1 || surf->idim == 3) /* 1D and 3D surface */\n   {\n      s2513(surf, ider, 2, 0, derive, normal, fundform, jstat);\n      if (*jstat < 0) goto error;\n      \n      numerator = fundform[3]*fundform[2] - 2*fundform[4]*fundform[1]\n\t + fundform[5]*fundform[0];\n      denominator = fundform[0]*fundform[2] - fundform[1]*fundform[1];\n      \n      *mehlum = (3*numerator*numerator)/(8*denominator*denominator*denominator)\n\t - (fundform[3]*fundform[5]-fundform[4]*fundform[4])/\n\t (2*denominator*denominator);\n  }\n\n  else if (surf->idim == 2) /* 2D surface */\n  {\n    /* The surface lies in a plane => K(u,v) = 0 */\n\n    *mehlum = 0.0;\n  }\n  else /* When surf->idim != 1,2 or 3 */\n  {\n    goto err105;\n  }\n\n  /* Successful computations  */\n\n  *jstat = 0;\n  goto out;\n\n\n   /* Error in input, surf->idim != 1,2 or 3 */\nerr105:\n  *jstat = -105;\n  s6err(\"s2509\",*jstat,0);\n  goto out;\n\n  /* Illegal derivative requested. */\nerr178:\n  *jstat = -178;\n  s6err(\"s2509\",*jstat,0);\n  goto out;\n  \nerror:\n  s6err(\"s2509\",*jstat,0);\n  goto out;\n\nout:\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s2510.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2510.c,v 1.4 2001-03-19 15:58:59 afr Exp $\n *\n */\n\n\n#define S2510\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s2510(SISLSurf *surf, int ider, int iside1, int iside2, double parvalue[],\n      int *leftknot1,int *leftknot2, double *mehlum, int *jstat)\n#else\n void s2510(surf, ider, iside1, iside2, parvalue, leftknot1, leftknot2, mehlum, jstat)\n      SISLSurf *surf;\n      int    ider;\n      int    iside1;\n      int    iside2;\n      double parvalue[];\n      int *leftknot1;\n      int *leftknot2;\n      double *mehlum;\n      int *jstat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the third order Mehlum curvature M(u,v) of a \n*                  surface for given values (u,v) = (parvalue[0],parvalue[1]), \n*                  where:\n*\n*                          et1[leftknot1] <= parvalue[0] < et1[leftknot1+1],\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Number of derivatives to calculate.\n*                     Only implemented for ider=0.\n*                       < 0 : No derivative calculated.\n*                       = 0 : Position calculated.\n*                       = 1 : Position and first derivative calculated.\n*                       etc.\n*          iside1   - Indicator telling if the derivatives in the first\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*          iside2   - Indicator telling if the derivatives in the second\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*      parvalue     - Parameter-value at which to evaluate. Dimension of\n*                     parvalue is 2.\n*\n*  INPUT/OUTPUT :\n*     leftknot1     - Pointer to the interval in the knot vector in the\n*                     first parameter direction where parvalue[0] is found,\n*                     that is:\n*                          et1[leftknot1] <= parvalue[0] < et1[leftknot1+1].\n*                     leftknot1 should be set equal to zero at the first call\n*                     to the routine.\n*\n*     leftknot2     - Pointer to the interval in the knot vector in the\n*                     second parameter direction where parvalue[1] is found,\n*                     that is:\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*                     leftknot2 should be set equal to zero at the first call\n*                     to the routine.\n*\n*  OUTPUT       :\n*     mehlum        - Third order Mehlum curvature of the surface in (u,v) =\n*                     (parvalue[0],parvalue[1]).\n*        jstat      - Status messages\n*                         = 2 : Surface is degenerate at the point, that is,\n*                               the surface is not regular at this point.\n*                         = 1 : Surface is close to degenerate at the point.\n*                               Angle between tangents is less than the angular\n*                               tolerance.\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*  METHOD       :  The third order Mehlum curvature is given by\n*\n*                      M(u,v) = (5G^3P^2 \n*                             + (EG + 4F^2)\n*                             *(9GQ^2 + 9ES^2 + 6GPS + 6EQT) \n*                             + 5E^3T^2 \n*                             - 2F(3EG + 2F^2)(PT + 9QS)\n*                             - 30F(G^2PQ + E^2ST))\n*                             /(16(EG - F^2)^3).\n*\n*                  The variables E,F,G,P,Q,S and T\n*                  are the coefficients of the first and third fundamental form.\n*                  They are given by: \n*                  E = <Xu,Xu>, F = <Xu,Xv> and G = <Xv,Xv>. \n*                  P = <N,Xuuu> + 3(a*alpha + b*beta), \n*                  Q = <N,Xuuv> + c*alpha + d*beta + 2a*gamma + 2b*delta, \n*                  S = <N,Xuvv> + 2c*gamma + 2d*delta + a*epsilon + b*mu,\n*                  T = <N,Xvvv> + 3(c*epsilon + d*mu), \n*                  where N is normalized, and\n*                  a = Ff - Ge,\n*                  b = Fe - Ef,\n*                  c = Fg - Gf,\n*                  d = Ff - Eg,\n*                  e, f and g being the second fundamental form coefficients\n*                  (e = <N,Xuu>, f = <N,Xuv> and g = <N,Xvv>), and\n*                  alpha   = <Xuu,Xu>/||N||^2,\n*                  beta    = <Xuu,Xv>/||N||^2,\n*                  gamma   = <Xuv,Xu>/||N||^2,\n*                  delta   = <Xuv,Xv>/||N||^2,\n*                  epsilon = <Xvv,Xu>/||N||^2,\n*                  mu      = <Xvv,Xv>/||N||^2.\n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*-\n*  CALLS        :  s1422() and s2511().\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenerated (not regular) at the point\n*                    (u,v), it makes no sense to speak about the Mehlum\n*                    M(u,v). The routine returns jstat = 2.\n*               (ii) If the surface is closed to degenerate, the Mehlum\n*                    M(u,v) can be numerical instable. The routine returns\n*                    jstat = 1.\n*              (iii) The dimension of the space in which the surface lies must\n*                    be 1,2 or 3.\n*\n*\n* WRITTEN BY :    Johannes Kaasa, SINTEF, Oslo, Norway.            Date: 1995-9\n******************************************************************************\n*/\n{\n  int kwarn = 0;         /* Local staus variable(warning).                  */\n  int kistat = 0;        /* Local staus variable.                           */\n  double derive[30];     /* Array containing the computed derivatives.      */\n  double normal[3];      /* Array containing the computed normalvektor.     */\n\n\n  if (ider != 0) goto err178;\n\n\n  if (surf == SISL_NULL)  goto err150;\n  else\n  {\n    /* Compute derivates and normal. */\n\n     s1422(surf,3,iside1,iside2,parvalue,leftknot1,leftknot2,derive,normal,\n\t  &kistat);\n    if (kistat > 0) kwarn=kistat;\n\n    if (kistat < 0) /* Error in lower level routine. */\n    {\n      goto error;\n    }\n    else if (kistat != 2) /* The surface is not degenerate */\n    {\n      s2511(surf, ider, derive, normal, mehlum, &kistat);\n\n      if (kistat < 0)\n\tgoto error;\n    }\n    else if (kistat == 2) /* The surface is degenerated. */\n    {\n      *mehlum = 0.0;\n      goto war002;\n    }\n\n  }\n\n\n  /* Successful computations  */\n\n  *jstat = kwarn;\n  goto out;\n\n\n   /* The surface is degenerated at (u,v) */\nwar002:\n  *jstat = 2;\n  goto out;\n\n  /* Error. Input (surface) pointer is SISL_NULL. */\nerr150:\n  *jstat = -150;\n  s6err(\"s2510\", *jstat, 0);\n  goto out;\n\n  /* Illegal derivative requested. */\nerr178:\n  *jstat = -178;\n  s6err(\"s2510\",*jstat,0);\n  goto out;\n  /* Error in lower level routine.  */\n\nerror:\n  *jstat = kistat;\n  s6err(\"s2510\",*jstat,0);\n  goto out;\n\n\nout:\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s2511.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2511.c,v 1.3 2001-06-12 11:07:34 jbt Exp $\n *\n */\n\n\n#define S2511\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s2511(SISLSurf *surf, int ider, double derive[], double normal[],\n      double *mehlum, int *jstat)\n#else\n void s2511(surf, ider, derive, normal, mehlum, jstat)\n      SISLSurf *surf;\n      int ider;\n      double derive[];\n      double normal[];\n      double *mehlum;\n      int *jstat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the third order Mehlum curvature M(u,v) of a \n*                  surface for given values (u,v). This is a lower level \n*                  routine, used for evaluation of many M(u,v)'s.\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Only implemented for ider=0 (derivative order).\n*       derive      - Array containing derivatives from routine s1421().\n*                     Size = idim*6.\n*       normal      - Array containing the normal from routine s1421().\n*                     Size = 3.\n*\n*  OUTPUT       :\n*       mehlum      - Third order Mehlum curvature of the surface.\n*        jstat      - Status messages\n*\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*  METHOD       :  The third order Mehlum curvature is given by\n*\n*                      M(u,v) = (5G^3P^2 \n*                             + (EG + 4F^2)\n*                             *(9GQ^2 + 9ES^2 + 6GPS + 6EQT) \n*                             + 5E^3T^2 \n*                             - 2F(3EG + 2F^2)(PT + 9QS)\n*                             - 30F(G^2PQ + E^2ST))\n*                             /(16(EG - F^2)^3).\n*\n*                  The variables E,F,G,P,Q,S and T\n*                  are the coefficients of the first and third fundamental form.\n*                  They are given by: \n*                  E = <Xu,Xu>, F = <Xu,Xv> and G = <Xv,Xv>. \n*                  P = <N,Xuuu> + 3(a*alpha + b*beta), \n*                  Q = <N,Xuuv> + c*alpha + d*beta + 2a*gamma + 2b*delta, \n*                  S = <N,Xuvv> + 2c*gamma + 2d*delta + a*epsilon + b*mu,\n*                  T = <N,Xvvv> + 3(c*epsilon + d*mu), \n*                  where N is normalized, and\n*                  a = Ff - Ge,\n*                  b = Fe - Ef,\n*                  c = Fg - Gf,\n*                  d = Ff - Eg,\n*                  e, f and g being the second fundamental form coefficients\n*                  (e = <N,Xuu>, f = <N,Xuv> and g = <N,Xvv>), and\n*                  alpha   = <Xuu,Xu>/||N||^2,\n*                  beta    = <Xuu,Xv>/||N||^2,\n*                  gamma   = <Xuv,Xu>/||N||^2,\n*                  delta   = <Xuv,Xv>/||N||^2,\n*                  epsilon = <Xvv,Xu>/||N||^2,\n*                  mu      = <Xvv,Xv>/||N||^2.\n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*-\n*  CALLS        : s2513()\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenerated (not regular) at the point\n*                    (u,v), it makes no sense to speak about the Mehlum\n*                    M(u,v).\n*               (ii) If the surface is closed to degenerate, the Mehlum\n*                    M(u,v) can be numerical unstable.\n*              (iii) The dimension of the space in which the surface lies must\n*                    be 1,2 or 3, if not, jstat = -105 is returned.\n*\n*\n* WRITTEN BY   :  Johannes Kaasa, SINTEF, Oslo, Norway.            Date: 1995-9\n*****************************************************************************\n*/\n{\n   double fundform[10]; /* The coefficients of the fundamental forms.\n\t\t\t   The sequence is: E, F, G, e, f, g, P, Q, S, T. */\n   double length;       /* Square of normal length.                       */\n   double a, b, c, d;   /* Utility coefficients.                          */\n   double alpha;        /* Utility coefficient.                           */\n   double beta;         /* Utility coefficient.                           */\n   double gamma;        /* Utility coefficient.                           */\n   double delta;        /* Utility coefficient.                           */\n   double epsilon;      /* Utility coefficient.                           */\n   double mu;           /* Utility coefficient.                           */\n   double P, Q, S, T;   /* Third order coefficients.                      */\n   double numerator;    /* Value of a numerator.                          */\n   double denominator;  /* Value of a denominator.                        */\n\n   if (ider != 0) goto err178;\n\n   if (surf->idim == 1 || surf->idim == 3) /* 1D and 3D surface */\n   {\n      s2513(surf, ider, 3, 1, derive, normal, fundform, jstat);\n      if (*jstat < 0) goto error;\n      \n      if (surf->idim == 3)\n\t length = normal[0]*normal[0] + normal[1]*normal[1] +\n\t    normal[2]*normal[2];\n      else if (surf->idim == 1)\n\t length = 1. + derive[1]*derive[1] + derive[2]*derive[2];\n\t \n      \n      alpha   = s6scpr(&derive[3*(surf->idim)], &derive[surf->idim],\n\t\t     surf->idim)/length;\n      beta    = s6scpr(&derive[3*(surf->idim)], &derive[2*(surf->idim)],\n\t\t     surf->idim)/length;\n      gamma   = s6scpr(&derive[4*(surf->idim)], &derive[surf->idim],\n\t\t     surf->idim)/length;\n      delta   = s6scpr(&derive[4*(surf->idim)], &derive[2*(surf->idim)],\n\t\t     surf->idim)/length;\n      epsilon = s6scpr(&derive[5*(surf->idim)], &derive[surf->idim],\n\t\t     surf->idim)/length;\n      mu      = s6scpr(&derive[5*(surf->idim)], &derive[2*(surf->idim)],\n\t\t     surf->idim)/length;\n      \n      a = fundform[1]*fundform[4] - fundform[2]*fundform[3];\n      b = fundform[1]*fundform[3] - fundform[0]*fundform[4];\n      c = fundform[1]*fundform[5] - fundform[2]*fundform[4];\n      d = fundform[1]*fundform[4] - fundform[0]*fundform[5];\n      \n      P = fundform[6] + 3*(a*alpha + b*beta);\n      Q = fundform[7] + c*alpha + d*beta + 2*a*gamma + 2*b*delta;\n      S = fundform[8] + 2*c*gamma + 2*d*delta + a*epsilon + b*mu;\n      T = fundform[9] + 3*(c*epsilon + d*mu);\n      \n      numerator = 5*fundform[2]*fundform[2]*fundform[2]*P*P\n\t + (fundform[0]*fundform[2] + 4*fundform[1]*fundform[1])\n\t *(9*fundform[2]*Q*Q\n\t + 9*fundform[0]*S*S\n\t + 6*fundform[2]*P*S\n\t + 6*fundform[0]*Q*T)\n\t + 5*fundform[0]*fundform[0]*fundform[0]*T*T\n\t - 2*fundform[1]*(3*fundform[0]*fundform[2] + 2*fundform[1]*fundform[1])\n\t *(P*T + 9*Q*S)\n\t - 30*fundform[1]*(fundform[2]*fundform[2]*P*Q\n\t + fundform[0]*fundform[0]*S*T);\n      \n      denominator = fundform[0]*fundform[2] - fundform[1]*fundform[1];\n      \n      *mehlum = numerator/(16*denominator*denominator*denominator);\n  }\n\n  else if (surf->idim == 2) /* 2D surface */\n  {\n    /* The surface lies in a plane => K(u,v) = 0 */\n\n    *mehlum = 0.0;\n  }\n  else /* When surf->idim != 1,2 or 3 */\n  {\n    goto err105;\n  }\n\n  /* Successful computations  */\n\n  *jstat = 0;\n  goto out;\n\n\n   /* Error in input, surf->idim != 1,2 or 3 */\nerr105:\n  *jstat = -105;\n  s6err(\"s2511\",*jstat,0);\n  goto out;\n\n  /* Illegal derivative requested. */\nerr178:\n  *jstat = -178;\n  s6err(\"s2511\",*jstat,0);\n  goto out;\n  \nerror:\n  s6err(\"s2511\",*jstat,0);\n  goto out;\n\nout:\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s2512.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2512.c,v 1.3 2005-02-28 09:04:49 afr Exp $\n *\n */\n\n\n#define S2512\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s2512(SISLSurf *surf, int ider, int iside1, int iside2, double parvalue[],\n      int *leftknot1,int *leftknot2, double gaussian[], int *stat)\n#else\n void s2512(surf, ider, iside1, iside2, parvalue, leftknot1, leftknot2, \n\t    gaussian, stat)\n      SISLSurf *surf;\n      int    ider;\n      int    iside1;\n      int    iside2;\n      double parvalue[];\n      int *leftknot1;\n      int *leftknot2;\n      double gaussian[];\n      int *stat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the numerator and denominator in the\n*                  Gaussian expression K(u,v) of a Surface for given\n*                  values (u,v) = (parvalue[0],parvalue[1]), where:\n*\n*                          et1[leftknot1] <= parvalue[0] < et1[leftknot1+1],\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*                  See also s2500(), s2501().\n*\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Number of derivatives to calculate.\n*                     Only implemented for ider=0.\n*                       < 0 : No derivative calculated.\n*                       = 0 : Position calculated.\n*                       = 1 : Position and first derivative calculated.\n*                       etc.\n*          iside1   - Indicator telling if the derivatives in the first\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*          iside2   - Indicator telling if the derivatives in the second\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*      parvalue     - Parameter-value at which to evaluate. Dimension of\n*                     parvalue is 2.\n*\n*  INPUT/OUTPUT :\n*     leftknot1     - Pointer to the interval in the knot vector in the\n*                     first parameter direction where parvalue[0] is found,\n*                     that is:\n*                          et1[leftknot1] <= parvalue[0] < et1[leftknot1+1].\n*                     leftknot1 should be set equal to zero at the first call\n*                     to the routine.\n*\n*     leftknot2     - Pointer to the interval in the knot vector in the\n*                     second parameter direction where parvalue[1] is found,\n*                     that is:\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*                     leftknot2 should be set equal to zero at the first call\n*                     to the routine.\n*\n*  OUTPUT       :\n*     gaussian      - The nominator and denominator of the Gaussian for the \n*                     surface in (parvalue[0],parvalue[1]).\n*                     Size = 2.\n*     gaussian[0]   - (eg-f*f) * (n.n)\n*     gaussian[1]   - (EG-F*F) * (n.n), where n is the normal.\n*     \t\t      The Gaussian for the surface is gaussian[0]/gaussian[1]\n*        stat      - Status messages\n*                         = 2 : Surface is degenerate at the point, that is,\n*                               the surface is not regular at this point.\n*                         = 1 : Surface is close to degenerate at the point.\n*                               Angle between tangents is less than the angular\n*                               tolerance.\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*  METHOD       :  The Gaussian is given by\n*\n*                      K(x,y) = (hxx*hyy-hxy^2)/((1+hx^2+hy^2)^2),\n*\n*                  if the surface (h(x,y)) is 1D, and\n*\n*                      K(u,v) = (eg-f*f)/(EG-F*F),\n*\n*                  if the surface (X(u,v)) is 3D. The variables E,F,G,e,f and g\n*                  are the coefficients of the first and second fundamental form.\n*                  They are given by: e = <N,Xuu>, f = <N,Xuv>, g = <N,Xvv>,\n*                  E = <Xu,Xu>, F = <Xu,Xv> and G = <Xv,Xv>. The routine will\n*                  test if the surface is degenerate (not regular) or close to\n*                  degenerate. \n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*-\n*  CALLS        :  s1422(),s2514().\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenerated (not regular) at the point\n*                    (u,v), it makes no sense to speak about the Gaussian\n*                    K(u,v). The routine returns stat = 2.\n*               (ii) If the surface is closed to degenerate, the Gaussian\n*                    K(u,v) can be numerical instable. The routine returns\n*                    stat = 1.\n*              (iii) If the surface is Cr the curvature calculated is C(r-2).\n*               (iv) The dimension of the space in which the surface lies must\n*                    be 1,2 or 3.\n*\n*\n* WRITTEN BY :    Geir Westgaard, SINTEF, Oslo, Norway.            Date: 1995-1\n* CORRECTED BY :  Ulf J Krystad, SINTEF, Oslo, Norway.             Date: 1995-1\n*                 Added ider, iside1 and iside2 parameters.\n* REVISED BY :    Johannes Kaasa, SINTEF, Oslo, Norway.            Date: 1995-8\n******************************************************************************\n*/\n{\n   double derive[18];     /* Array containing the computed derivatives.      */\n   double normal[3];      /* Array containing the computed normalvektor.     */\n      \n      \n   if (ider != 0) goto err178;\n      \n   if (surf == SISL_NULL)  goto err150;\n   else\n   {\n\t \n      /* Compute derivates and normal. */\n\t \n      s1422(surf,2,iside1,iside2,parvalue,leftknot1,leftknot2,derive,normal,\n\t    stat);\n      if (*stat < 0)       /* Error in lower level routine. */\n         goto error;\n      else if (*stat != 2) /* The surface is not degenerate */\n      {\n\t s2514(surf, ider, derive, normal, gaussian, stat);\n\t if (*stat < 0) goto error;\n      }\n      else if (*stat == 2) /* The surface is degenerated. */\n\t goto out;\n\t \n   }\n      \n   /* Successful computations  */\n      \n   goto out;\n\n   /* Error. Input (surface) pointer is SISL_NULL. */\n err150:\n   *stat = -150;\n   s6err(\"s2512\", *stat, 0);\n   goto out;\n      \n   /* Illegal derivative requested. */\n err178:\n   *stat = -178;\n   s6err(\"s2512\", *stat, 0);\n   goto out;\n   \n   /* Error in lower level routine.  */      \n error:\n   s6err(\"s2512\",*stat,0);\n   goto out;\n      \n out:\n\t \n   return;\n      \n}\n"
  },
  {
    "path": "src/s2513.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2513.c,v 1.8 1995-09-22 13:45:15 jka Exp $\n *\n */\n\n\n#define S2513\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s2513(SISLSurf *surf, int ider, int type, int normalized, double derive[], \n\t double normal[], double fundform[], int *stat)\n#else\n   void s2513(surf, ider, type, normalized, derive, normal, fundform, stat)\n      SISLSurf *surf;\n      int ider;\n      int type;\n      int normalized;\n      double derive[];\n      double normal[];\n      double fundform[];\n      int *stat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the coefficients of the first and second\n*                  fundamental form. \n*  INPUT        :\n*     surf         - Pointer to the surface to evaluate.\n*     ider         - Only implemented for ider=0 (derivative order).\n*     type         - Type of fundamental form:\n*                    = 1 : first fundamental form,\n*                    = 2 : first and second fundamental form,\n*                    = 3 : first, second and third fundamental form.\n*     normalized   - Flag telling if the second fundamental form\n*                    coefficients shall be calculated from normalized or\n*                    not normalized normals:\n*                    = 0 : not normalized,\n*                    = 1 : normalized,\n*     derive       - Array containing derivatives from routine s1421().\n*                    Size = idim*6. The sequence is:\n*                    S, Su, Sv, Suu, Suv, Svv. \n*     normal       - Array containing the normal from routine s1421().\n*                    Size = 3, only used for dim = 3.\n*\n*  OUTPUT       :\n*     fundform     - Array for the fundamental form. The sequence is\n*                    (E,F,G,e,f,g,P,Q,S,T,Eu,...,Ev,...,Euu,...,Euv,...,Evv,...).\n*     stat         - Status messages\n*\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*  METHOD       :  \n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*-\n*  CALLS        :\n*\n*  LIMITATIONS  :\n*               (i) The dimension of the space in which the surface lies must\n*                   be 1 or 3, if not, stat = -105 is returned.\n*\n*\n* WRITTEN BY   :  Johannes Kaasa, SINTEF, Oslo, Norway.            Date: 1995-6\n*****************************************************************************\n*/\n{\n   double norm_scale; /* Scalation of the surface normal. */\n      \n   if (ider != 0) goto err178;\n   if (type < 1 || type > 3) goto err178;\n      \n   if (surf->idim == 1) \n   {\n\t \n      /* 1D surface. */\n\t \n      if (normalized == 0)\n         norm_scale = 1.;\n      else\n\t norm_scale = sqrt(1. + derive[1]*derive[1] + derive[2]*derive[2]);\n\t \n      fundform[0] = 1. + derive[1]*derive[1];\n      fundform[1] = derive[1]*derive[2];\n      fundform[2] = 1. + derive[2]*derive[2];\n\t \n      if (type > 1)\n      {\n\t fundform[3] = derive[3]/norm_scale;\n\t fundform[4] = derive[4]/norm_scale;\n\t fundform[5] = derive[5]/norm_scale;\n      }\n      if (type > 2)\n      {\n\t fundform[6] = derive[6]/norm_scale;\n\t fundform[7] = derive[7]/norm_scale;\n\t fundform[8] = derive[8]/norm_scale;\n\t fundform[9] = derive[9]/norm_scale;\n      }\n   }\n      \n   else if (surf->idim == 3) \n   {\n\t \n      /* 3D surface */\n\t \n      if (normalized == 0)\n         norm_scale = 1.;\n      else\n\t norm_scale = sqrt(normal[0]*normal[0] + normal[1]*normal[1] +\n\t\t\t   normal[2]*normal[2]);\n\t \n      fundform[0] = s6scpr(&derive[3], &derive[3], 3);\n      fundform[1] = s6scpr(&derive[3], &derive[6], 3);\n      fundform[2] = s6scpr(&derive[6], &derive[6], 3);\n\t \n      if (type > 1)\n      {\n\t fundform[3] = (s6scpr(normal, &derive[9], 3))/norm_scale;\n\t fundform[4] = (s6scpr(normal, &derive[12], 3))/norm_scale;\n\t fundform[5] = (s6scpr(normal, &derive[15], 3))/norm_scale;\n      }\n      \n      if (type > 2)\n      {\n\t fundform[6] = (s6scpr(normal, &derive[18], 3))/norm_scale;\n\t fundform[7] = (s6scpr(normal, &derive[21], 3))/norm_scale;\n\t fundform[8] = (s6scpr(normal, &derive[24], 3))/norm_scale;\n\t fundform[9] = (s6scpr(normal, &derive[27], 3))/norm_scale;\n      }\n   }\n   else \n   {\n      /* Not 1D or 3D surface */\n\t \n      goto err105;\n   }\n      \n            \n   /* Successful computations  */\n      \n   *stat = 0;\n   goto out;\n      \n      \n   /* Error in input, surf->idim != 1 or 3 */\nerr105:\n   *stat = -105;\n   s6err(\"s2513\",*stat,0);\n   goto out;\n      \n   /* Illegal derivative requested. */\nerr178:\n   *stat = -178;\n   s6err(\"s2513\",*stat,0);\n   goto out;\n      \nout:\t \n   return;\n      \n}\n"
  },
  {
    "path": "src/s2514.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2514.c,v 1.3 2001-06-12 11:07:34 jbt Exp $\n *\n */\n\n\n#define S2514\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s2514(SISLSurf *surf, int ider, double derive[], double normal[],\n      double gaussian[], int *stat)\n#else\n void s2514(surf, ider, derive, normal, gaussian, stat)\n      SISLSurf *surf;\n      int ider;\n      double derive[];\n      double normal[];\n      double gaussian[];\n      int *stat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the numerator and denominator of the Gaussian \n*                  K(u,v) of a Surface for given\n*                  values (u,v). This is a lower level routine, used\n*                  for evaluation of many K(u,v)'s.\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Only implemented for ider=0 (derivative order).\n*       derive      - Array containing derivatives from routine s1421().\n*                     Size = idim*6.\n*       normal      - Array containing the normal from routine s1421().\n*                     Size = 3.\n*\n*  OUTPUT       :\n*     gaussian      - The nominator and denominator of the Gaussian for the \n*                     surface in (parvalue[0],parvalue[1]).\n*                     Size = 2.\n*        stat       - Status messages\n*\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*  METHOD       :  The Gaussian is given by\n*\n*                      K(x,y) = (hxx*hyy-hxy^2)/((1+hx^2+hy^2)^2),\n*\n*                  if the surface (h(x,y)) is 1D, and\n*\n*                      K(u,v) = (eg-f*f)/(EG-F*F),\n*\n*                  if the surface (X(u,v)) is 3D. The variables E,F,G,e,f and g\n*                  are the coefficients of the first and second fundamental form.\n*                  They are given by: e = <N,Xuu>, f = <N,Xuv>, g = <N,Xvv>,\n*                  E = <Xu,Xu>, F = <Xu,Xv> and G = <Xv,Xv>.\n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*-\n*  CALLS        :\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenerated (not regular) at the point\n*                    (u,v), it makes no sense to speak about the Gaussian\n*                    K(u,v).\n*               (ii) If the surface is closed to degenerate, the Gaussian\n*                    K(u,v) can be numerical unstable.\n*              (iii) The surface is Cr the Gaussian calculated is C(r-2).\n*                    To get the correct behavior use the sided evaluator s1422\n*\t\t     instead of s1421.\n*               (iv) The dimension of the space in which the surface lies must\n*                    be 1,2 or 3, if not, stat = -105 is returned.\n*\n*\n* WRITTEN BY   :  Johannes Kaasa, SINTEF, Oslo, Norway.            Date: 1995-8\n*****************************************************************************\n*/\n{\n   double fundform[6]; /* The coefficients of the fundamental forms.\n\t\t\t  The sequence is: E, F, G, e, f, g.         */\n\n   if (ider != 0) goto err178;\n\n   if (surf->idim == 1 || surf->idim == 3) /* 1D and 3D surface */\n   {\n      s2513(surf, ider, 2, 0, derive, normal, fundform, stat);\n      if (*stat < 0) goto error;\n      \n      gaussian[0] = fundform[3]*fundform[5]-fundform[4]*fundform[4];\n      gaussian[1] = (fundform[0]*fundform[2] - fundform[1]*fundform[1])*\n\t   (fundform[0]*fundform[2] - fundform[1]*fundform[1]);\n  }\n\n  else if (surf->idim == 2) /* 2D surface */\n  {\n    /* The surface lies in a plane => K(u,v) = 0 */\n\n    gaussian[0] = 0.0;\n    gaussian[1] = 1.0;\n  }\n  else /* When surf->idim != 1,2 or 3 */\n  {\n    goto err105;\n  }\n\n  /* Successful computations  */\n\n  *stat = 0;\n  goto out;\n\n\n   /* Error in input, surf->idim != 1,2 or 3 */\nerr105:\n  *stat = -105;\n  s6err(\"s2514\",*stat,0);\n  goto out;\n\n  /* Illegal derivative requested. */\nerr178:\n  *stat = -178;\n  s6err(\"s2514\",*stat,0);\n  goto out;\n  \nerror:\n  s6err(\"s2514\",*stat,0);\n  goto out;\n\nout:\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s2515.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2515.c,v 1.3 2005-02-28 09:04:49 afr Exp $\n *\n */\n\n\n#define S2515\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s2515(SISLSurf *surf, int ider, int iside1, int iside2, double parvalue[],\n      int *leftknot1,int *leftknot2, double mehlum[], int *stat)\n#else\n void s2515(surf, ider, iside1, iside2, parvalue, leftknot1, leftknot2, \n\t    mehlum, stat)\n      SISLSurf *surf;\n      int    ider;\n      int    iside1;\n      int    iside2;\n      double parvalue[];\n      int *leftknot1;\n      int *leftknot2;\n      double mehlum[];\n      int *stat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the numerator and denominator in the\n*                  mehlum expression M(u,v) of a Surface for given\n*                  values (u,v) = (parvalue[0],parvalue[1]), where:\n*\n*                          et1[leftknot1] <= parvalue[0] < et1[leftknot1+1],\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*                  See also s2508(), s2509().\n*\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Number of derivatives to calculate.\n*                     Only implemented for ider=0.\n*                       < 0 : No derivative calculated.\n*                       = 0 : Position calculated.\n*                       = 1 : Position and first derivative calculated.\n*                       etc.\n*          iside1   - Indicator telling if the derivatives in the first\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*          iside2   - Indicator telling if the derivatives in the second\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*      parvalue     - Parameter-value at which to evaluate. Dimension of\n*                     parvalue is 2.\n*\n*  INPUT/OUTPUT :\n*     leftknot1     - Pointer to the interval in the knot vector in the\n*                     first parameter direction where parvalue[0] is found,\n*                     that is:\n*                          et1[leftknot1] <= parvalue[0] < et1[leftknot1+1].\n*                     leftknot1 should be set equal to zero at the first call\n*                     to the routine.\n*\n*     leftknot2     - Pointer to the interval in the knot vector in the\n*                     second parameter direction where parvalue[1] is found,\n*                     that is:\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*                     leftknot2 should be set equal to zero at the first call\n*                     to the routine.\n*\n*  OUTPUT       :\n*     mehlum        - The nominator and denominator of the Mehlum curvature for the \n*                     surface in (parvalue[0],parvalue[1]).\n*                     Size = 2.\n*     mehlum[0]     - 3((eG-2fF+gE)^2)/8 - (eg-f*f)(EG-F*F)/2, where e,g and f are\n*                     calculated using real length normals.\n*     mehlum[1]     - (EG-F*F)^3, where e,g and f are calculated using real length \n*                     normals.\n*     \t\t      The Mehlum curvature for the surface is mehlum[0]/mehlum[1]\n*        stat       - Status messages\n*                         = 2 : Surface is degenerate at the point, that is,\n*                               the surface is not regular at this point.\n*                         = 1 : Surface is close to degenerate at the point.\n*                               Angle between tangents is less than the angular\n*                               tolerance.\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*  METHOD       :  The Mehlum curvature is given by\n*\n*                      M(u,v) = (3((eG-2fF+gE)^2)/8 - (eg-f*f)(EG-F*F)/2)/\n*                               (EG-F*F)^3,\n*\n*                  The variables E,F,G,e,f and g\n*                  are the coefficients of the first and second fundamental form.\n*                  They are given by: e = <N,Xuu>, f = <N,Xuv>, g = <N,Xvv>,\n*                  E = <Xu,Xu>, F = <Xu,Xv> and G = <Xv,Xv>. The routine will\n*                  test if the surface is degenerate (not regular) or close to\n*                  degenerate. \n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*-\n*  CALLS        :  s1422(),s2516().\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenerated (not regular) at the point\n*                    (u,v), it makes no sense to speak about the Mehlum\n*                    curvature M(u,v). The routine returns stat = 2.\n*               (ii) If the surface is closed to degenerate, the Mehlum\n*                    curvature M(u,v) can be numerical instable. The routine returns\n*                    stat = 1.\n*              (iii) If the surface is Cr the curvature calculated is C(r-2).\n*               (iv) The dimension of the space in which the surface lies must\n*                    be 1,2 or 3.\n*\n*\n*  WRITTEN BY :  Johannes Kaasa, SINTEF, Oslo, Norway.            Date: 1995-8\n******************************************************************************\n*/\n{\n   double derive[18];     /* Array containing the computed derivatives.      */\n   double normal[3];      /* Array containing the computed normalvektor.     */\n      \n      \n   if (ider != 0) goto err178;\n      \n   if (surf == SISL_NULL)  goto err150;\n   else\n   {\n\t \n      /* Compute derivates and normal. */\n\t \n      s1422(surf,2,iside1,iside2,parvalue,leftknot1,leftknot2,derive,normal,\n\t    stat);\n      if (*stat < 0)       /* Error in lower level routine. */\n         goto error;\n      else if (*stat != 2) /* The surface is not degenerate */\n      {\n\t s2516(surf, ider, derive, normal, mehlum, stat);\n\t if (*stat < 0) goto error;\n      }\n      else if (*stat == 2) /* The surface is degenerated. */\n\t goto out;\n\t \n   }\n      \n   /* Successful computations  */\n      \n   goto out;\n\n   /* Error. Input (surface) pointer is SISL_NULL. */\n err150:\n   *stat = -150;\n   s6err(\"s2515\", *stat, 0);\n   goto out;\n      \n   /* Illegal derivative requested. */\n err178:\n   *stat = -178;\n   s6err(\"s2515\", *stat, 0);\n   goto out;\n   \n   /* Error in lower level routine.  */      \n error:\n   s6err(\"s2515\",*stat,0);\n   goto out;\n      \n out:\n\t \n   return;\n      \n}\n"
  },
  {
    "path": "src/s2516.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2516.c,v 1.3 2001-06-12 11:07:34 jbt Exp $\n *\n */\n\n\n#define S2516\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s2516(SISLSurf *surf, int ider, double derive[], double normal[],\n      double mehlum[], int *stat)\n#else\n void s2516(surf, ider, derive, normal, mehlum, stat)\n      SISLSurf *surf;\n      int ider;\n      double derive[];\n      double normal[];\n      double mehlum[];\n      int *stat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the numerator and denominator of the Mehlum \n*                  curvature M(u,v) of a Surface for given\n*                  values (u,v). This is a lower level routine, used\n*                  for evaluation of many M(u,v)'s.\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Only implemented for ider=0 (derivative order).\n*       derive      - Array containing derivatives from routine s1421().\n*                     Size = idim*6.\n*       normal      - Array containing the normal from routine s1421().\n*                     Size = 3.\n*\n*  OUTPUT       :\n*     mehlum        - The nominator and denominator of the Mehlum curvature \n*                     for the surface in (parvalue[0],parvalue[1]).\n*                     Size = 2.\n*        stat       - Status messages\n*\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*  METHOD       :  The Mehlum curvature is given by\n*\n*                      M(u,v) = (3((eG-2fF+gE)^2)/8 - (eg-f*f)(EG-F*F)/2)/\n*                               (EG-F*F)^3,\n*\n*                  The variables E,F,G,e,f and g\n*                  are the coefficients of the first and second fundamental form.\n*                  They are given by: e = <N,Xuu>, f = <N,Xuv>, g = <N,Xvv>,\n*                  E = <Xu,Xu>, F = <Xu,Xv> and G = <Xv,Xv>. The routine will\n*                  test if the surface is degenerate (not regular) or close to\n*                  degenerate. \n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*-\n*  CALLS        :\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenerated (not regular) at the point\n*                    (u,v), it makes no sense to speak about the Mehlum\n*                    curvature M(u,v).\n*               (ii) If the surface is closed to degenerate, the Mehlum\n*                    curvature M(u,v) can be numerical unstable.\n*              (iii) If the surface is Cr the curvature calculated is C(r-2).\n*               (iv) The dimension of the space in which the surface lies must\n*                    be 1,2 or 3, if not, stat = -105 is returned.\n*\n*\n* WRITTEN BY   :  Johannes Kaasa, SINTEF, Oslo, Norway.            Date: 1995-8\n*****************************************************************************\n*/\n{\n   double fundform[6];  /* The coefficients of the fundamental forms.\n\t\t\t   The sequence is: E, F, G, e, f, g.         */\n   double coef1, coef2; /* Utility coefficients.                      */\n\n   if (ider != 0) goto err178;\n\n   if (surf->idim == 1 || surf->idim == 3) /* 1D and 3D surface */\n   {\n      s2513(surf, ider, 2, 0, derive, normal, fundform, stat);\n      if (*stat < 0) goto error;\n      \n      coef1 = fundform[3]*fundform[2] - 2*fundform[4]*fundform[1]\n\t\t     + fundform[5]*fundform[0];\n      coef2 = fundform[0]*fundform[2] - fundform[1]*fundform[1];\n      \n      mehlum[0] = 3.*coef1*coef1/8. - (fundform[3]*fundform[5] \n\t\t\t\t       - fundform[4]*fundform[4])*coef2/2.;\n      mehlum[1] = coef2*coef2*coef2;\n  }\n\n  else if (surf->idim == 2) /* 2D surface */\n  {\n    /* The surface lies in a plane => K(u,v) = 0 */\n\n     mehlum[0] = 0.0;\n     mehlum[1] = 1.0;\n  }\n  else /* When surf->idim != 1,2 or 3 */\n  {\n    goto err105;\n  }\n\n  /* Successful computations  */\n\n  *stat = 0;\n  goto out;\n\n\n   /* Error in input, surf->idim != 1,2 or 3 */\nerr105:\n  *stat = -105;\n  s6err(\"s2516\",*stat,0);\n  goto out;\n\n  /* Illegal derivative requested. */\nerr178:\n  *stat = -178;\n  s6err(\"s2516\",*stat,0);\n  goto out;\n  \nerror:\n  s6err(\"s2516\",*stat,0);\n  goto out;\n\nout:\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s2532.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2532.c,v 1.3 2001-03-19 15:58:59 afr Exp $\n *\n */\n\n#define S2532\n\n#include \"sislP.h\"\n\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2532(SISLSurf *surf, int u_continuity, int v_continuity, \n      int *u_surfnumb, int *v_surfnumb, SISLSurf ***gauss_surf, int *stat)\n#else\nvoid s2532(surf, u_continuity, v_continuity, u_surfnumb, \n\t   v_surfnumb, gauss_surf, stat)\n     SISLSurf *surf;\n     int      u_continuity;\n     int      v_continuity;\n     int      *u_surfnumb;\n     int      *v_surfnumb;\n     SISLSurf ***gauss_surf;\n     int      *stat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n* PURPOSE : To interpolate the Gaussian curvature of a B-SPLINE or NURBS \n*           surface, as a NURBS surface. \n*           The desired continuity of the Gauss-curvature surface is given as \n*           input, this may lead to a patchwork of output surfaces. \n*           THE INTERPOLATION RESULTS IN A HIGH ORDER SURFACE (IF THE ORIGINAL \n*           SURFACE IS A B-SPLINE OF ORDER K, THE RESULT IS OF ORDER 8K - 11, \n*           IN THE NURBS CASE THE ORDER IS 32K - 35). TO AVOID UNSTABILITY\n*           BECAUSE OF THIS, A MAX. ORDER IS APPLIED. THIS MAY LEAD TO AN\n*           APPROXIMATION INSTEAD OF AN INTERPOLATION.\n*\n*\n* INPUT   : surf         - The original surface.\n*           u_continuity - Desired continuity of the Gauss-curvature surfaces\n*                          in u direction:\n*                          = 0 : Positional continuity,\n*                          = 1 : Tangential continuity,\n*                          and so on.\n*                          SISL only accepts surfaces of continuity 0 or larger.\n*                          If the surface is to be intersected with another,\n*                          the continuity must be 1 or larger to find all the\n*                          intersection curves.\n*           v_continuity - Desired continuity of the Gauss-curvature surfaces\n*                          in v direction:\n*                          = 0 : Positional continuity,\n*                          = 1 : Tangential continuity,\n*                          and so on.\n*                          SISL only accepts surfaces of continuity 0 or larger.\n*                          If the surface is to be intersected with another,\n*                          the continuity must be 1 or larger to find all the\n*                          intersection curves.\n*\n*\n* OUTPUT  : u_surfnumb   - Number of Gauss-curvature surface patches\n*                          in u direction.\n*           v_surfnumb   - Number of Gauss-curvature surface patches\n*                          in v direction.\n*           gauss_surf   - The Gaussian curvature interpolation surfaces.\n*                          This will be a pointer to an array of length\n*                          u_surfnum*v_surfnumb of SISLSurf pointers,\n*                          where the indexing is running fastest in the\n*                          u direction.\n*           stat         - Status message.\n*                          > 0      : Warning.\n*                          = 2      : The surface is degenerated.\n*                          = 0      : Ok.\n*                          < 0      : Error.\n*\n*\n* METHOD  :\n*\n*\n* CALLS   : s2535(), s2534()\n*\n* WRITTEN BY : Johannes Kaasa, SINTEF, Oslo, Norway, Aug. 1995.\n*\n*********************************************************************\n*/\n{\n   int ki;                     /* Index in for loops.                    */\n   int u_multinc;              /* Increased knot multiplicity.           */\n   int v_multinc;              /* Increased knot multiplicity.           */\n   int newik1;                 /* New order in u direction.              */\n   int newik2;                 /* New order in v direction.              */\n   int eval_dim;               /* Evaluation dimention.                  */\n   int max_order = 20;         /* Max. order of the curvature surface.   */\n   SISLSurf *temp = SISL_NULL;      /* Temporary surface.                     */\n   SISLSurf *regular = SISL_NULL;   /* k-regular surface.                     */\n   SISLSurf **org_surf = SISL_NULL; /* Array of pointers to original patches. */\n   \n   \n   /* Check input. */\n   \n   if (surf == SISL_NULL || u_continuity < 0 || v_continuity < 0)\n      goto err150;\n   \n   /* Curvature continuity decrease. */\n   \n   u_multinc = 2;\n   v_multinc = 2;\n   \n   /* Make sure we have a k-regular surface. */\n\n   if (surf->cuopen_1 == SISL_SURF_PERIODIC || \n       surf->cuopen_2 == SISL_SURF_PERIODIC )\n   {\n      make_sf_kreg(surf, &regular, stat);\n      if (*stat < 0) goto error;\n   }\n   else\n      regular = surf;\n   \n   /* Split the surface to meet the continuity requirements. */\n   \n   s2535(regular, (u_continuity + u_multinc), (v_continuity + v_multinc), \n\t u_surfnumb, v_surfnumb, &org_surf, stat);\n   if (*stat < 0) goto error;\n   \n   /* Allocate output array. */\n   \n   if ((*gauss_surf = newarray((*u_surfnumb)*(*v_surfnumb), SISLSurf*)) \n       == SISL_NULL) goto err101;\n   for (ki = 0; ki < (*u_surfnumb)*(*v_surfnumb); ki++)\n      (*gauss_surf)[ki] = SISL_NULL;\n   \n   /* Calculate curvature order. */\n   \n   if (regular->ikind == 1 || regular->ikind == 3)\n   {\n      newik1 = 8*regular->ik1 - 11;\n      newik2 = 8*regular->ik2 - 11;\n   }\n   else\n   {\n      newik1 = 32*regular->ik1 - 35;\n      newik2 = 32*regular->ik2 - 35;\n   }\n   newik1 = min(newik1, max_order);\n   newik2 = min(newik2, max_order);\n   \n   eval_dim = 2;\n   \n   /* Interpolate. */\n   \n   if (*u_surfnumb == 1 && *v_surfnumb == 1)\n   {\n      s2534(regular, u_multinc, v_multinc, newik1, newik2, s2512, eval_dim,\n\t    &temp, stat);\n      if (*stat < 0) goto error;\n      if (*stat == 2) goto war002;\n      \n      (*gauss_surf)[0] = newSurf(temp->in1, temp->in2, temp->ik1, temp->ik2,\n\t\t\t\t temp->et1, temp->et2, temp->ecoef, 2, 1, 1);\n      \n      if (temp != SISL_NULL)\n      {\n\t freeSurf(temp);\n\t temp = SISL_NULL;\n      }\n   }\n   else\n   {\n      for (ki = 0; ki < (*u_surfnumb)*(*v_surfnumb); ki++)\n      {\n\t s2534(org_surf[ki], u_multinc, v_multinc, newik1, newik2, s2512, \n\t       eval_dim, &temp, stat);\n         if (*stat < 0) goto error;\n\t if (*stat == 2) goto war002;\n      \n         (*gauss_surf)[ki] = newSurf(temp->in1, temp->in2, temp->ik1, \n\t\t\t\t     temp->ik2, temp->et1, temp->et2, \n\t\t\t\t     temp->ecoef, 2, 1, 1);\n\t \n\t if (temp != SISL_NULL)\n         {\n\t    freeSurf(temp);\n\t    temp = SISL_NULL;\n         }\n      }\n   }\n\n\n   goto out;\n\n\n\n   /* ---------------------- ERROR EXITS ------------------------------- */\n   \n   /* The surface is degenerated at (u,v) */\n   \n war002:\n   if (*gauss_surf != SISL_NULL)\n   {\n      for (ki = 0; ki < ((*u_surfnumb)*(*v_surfnumb)); ki++)\n\t if ((*gauss_surf)[ki] != SISL_NULL) freeSurf((*gauss_surf)[ki]);\n      freearray(*gauss_surf);\n   }\n   *u_surfnumb = 0;\n   *v_surfnumb = 0;\n   goto out;\n  \n  /* Error in space allocation */\n   \n err101: \n   *stat = -101;\n   s6err(\"s2532\", *stat, 0);\n   goto out;\n\n   /* Error in input. */\n   \n err150:\n   *stat = -150;\n   s6err(\"s2532\", *stat, 0);\n   goto out;\n\n   /* Error in lower level routine. */\n   \n error:\n   s6err(\"s2532\", *stat, 0);\n   goto out;\n\n   /* ---------------------- NORMAL EXIT ------------------------------- */\n\n out:\n   if (regular != surf ) freeSurf(regular);\n   if (org_surf != SISL_NULL)\n   {\n      for (ki = 0; ki < ((*u_surfnumb)*(*v_surfnumb)); ki++)\n\t if (org_surf[ki] != SISL_NULL) freeSurf(org_surf[ki]);\n      freearray(org_surf);\n   }\n   \n   return;\n\n}\n"
  },
  {
    "path": "src/s2533.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2533.c,v 1.2 2001-03-19 15:58:59 afr Exp $\n *\n */\n\n\n#define S2533\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s2533(double *et, int ik, int in, int multinc, int newik, int *newin,\n\t   double **newet, int *stat)\n#else\nvoid s2533(et, ik, in, multinc, newik, newin, newet, stat)\n      double *et;\n      int ik;\n      int in;\n      int multinc; \n      int newik;\n      int *newin;\n      double **newet;\n      int *stat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE : To derive a new knot vector from an existing one, given a new\n*           order and a new internal knot multiplicity.\n*\n*           We assume that the input knot vectors are k-regular, and that the\n*           knot multiplicity is prechecked to avoid interior knot multiplicity\n*           equal to or larger than the order.\n*\n*\n*\n* INPUT   : et        - The original knot vector.\n*           ik        - The original order.\n*           in        - The original number of coefficients.\n*           multinc   - The multiplicity increment.\n*                       In addition the multiplicity is increased by the order\n*                       increase.\n*           newik     - The new order.\n*\n*\n*\n* OUTPUT   : newin    - The new number of coefficients.\n*            newet    - The new knot vector.\n*            stat     - Status messages\n*                       > 0      : Warning\n*                       = 0      : Ok\n*                       < 0      : Error\n*\n*\n* METHOD   : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : \n*\n* WRITTEN BY :  Johannes Kaasa, SINTEF, Oslo, Norway.    Date: 1995-8\n*\n*********************************************************************\n*/\n{\n   int ki, kj, kl;          /* Indices.                         */\n   int add_knot;            /* Number of interior knots to add. */\n   int knot_pos;            /* Number of knot positions.        */\n   int *new_mult = SISL_NULL;    /* Array of new multiplicities.     */\n   double *knot_par = SISL_NULL; /* Array of knot parameters.        */\n\n\n   /* Check input. */\n\n   if (et == SISL_NULL || multinc < 0 || newik < (multinc + 2)) \n      goto err150;\n\n   /* Initiation and allocation of utility arrays. */\n\n   if (in > ik)\n   {\n      /* Inner knots. */\n      \n      add_knot = (newik - ik) + multinc;\n      \n      if ((new_mult = newarray(in - ik, INT)) == SISL_NULL) goto err101;\n      if ((knot_par = newarray(in - ik, DOUBLE)) == SISL_NULL) goto err101;\n   }\n   \n   /* Examine the original knot multiplicity. */\n   \n   *newin = newik;\n   knot_pos = 0;\n   for (ki = ik, kl = 0; ki < in; kl++)\n   {\n      knot_par[kl] = et[ki];\n      \n      new_mult[kl] = add_knot + 1;\n      kj = ki + 1;\n      while (DEQUAL(et[kj], et[ki]))\n      {\n\t new_mult[kl]++;\n\t kj++;\n      }\n      \n      if (new_mult[kl] >= newik)\n\t goto err150;\n      \n      *newin += new_mult[kl];\n      knot_pos++;\n      ki = kj;\n   }\n   \n   /* Allocate the output array. */\n   \n   if ((*newet = newarray((*newin + newik), DOUBLE)) == SISL_NULL) goto err101;\n   \n   /* Fill in the new values. */\n   \n   for (kl = 0; kl < newik; kl++)\n      (*newet)[kl] = et[ik - 1];\n   \n   for (ki = 0; ki < knot_pos; ki++)\n   {\n      for (kj = 0; kj < new_mult[ki]; kj++, kl++)\n\t (*newet)[kl] = knot_par[ki];\n   }\n   \n   for (ki = 0; ki < newik; ki++, kl++)\n      (*newet)[kl] = et[in];\n   \n   goto out;\n  \n  \n  \n   /* ---------------------- ERROR EXITS ------------------------------- */\n\n   /* Error in space allocation */\n   \n err101: \n   *stat = -101;\n   s6err(\"s2533\", *stat, 0);\n   goto out;\n\n   /* Error in input. */\n   \n err150:\n   *stat = -150;\n   s6err(\"s2533\", *stat, 0);\n   goto out;\n\n   /* ---------------------- NORMAL EXIT ------------------------------- */\n\n out:\n   if (new_mult != SISL_NULL) freearray(new_mult); \n   if (knot_par != SISL_NULL) freearray(knot_par); \n   \n   return;\n}\n"
  },
  {
    "path": "src/s2534.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2534.c,v 1.2 2001-03-19 15:58:59 afr Exp $\n *\n */\n\n\n#define S2534\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   s2534(SISLSurf *surf, \n\t  int u_multinc, \n\t  int v_multinc, \n\t  int newik1, \n\t  int newik2,\n\t  void evalp(SISLSurf *surf, int ider, int iside1, int iside2, \n\t\t     double parvalue[], int *leftknot1, int *leftknot2, \n\t\t     double *result, int *istat),\n\t  int eval_dim, \n\t  SISLSurf **rsurf, \n\t  int *stat)\n#else\n   void \n      s2534(surf, u_multinc, v_multinc, newik1, newik2, evalp, eval_dim, \n\t     rsurf, stat)\n      SISLSurf *surf;\n      int u_multinc;\n      int v_multinc;\n      int newik1; \n      int newik2;\n      void evalp();\n      int eval_dim;\n      SISLSurf **rsurf;\n      int *stat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE : To derive a properity surface from an original surface.\n*           The new spline space is based on the original, but new orders\n*           and knot multiplicities are given. The property is evaluated with\n*           the evaluator evalp.\n*\n*           We assume that the input knot vectors are k-regular, and that the\n*           knot multiplicity is prechecked to avoid interior knot multiplicity\n*           equal to or larger than the order.\n*\n*\n*\n* INPUT   : surf      - The original k-regular surface.\n*           u_multinc - The multiplicity increment in the first direction.\n*                       In addition the multiplicity is increased by the order\n*                       increase.\n*           v_multinc - The multiplicity increment in the second direction.\n*                       In addition the multiplicity is increased by the order\n*                       increase.\n*           newik1    - The new order in the first direction.\n*           newik2    - The new order in the second direction.\n*           evalp     - The generic property evaluator.\n*           eval_dim  - Dimension of the result from the evaluator.\n*\n*\n*\n* OUTPUT   : rsurf    - The resulting surface\n*            stat     - Status messages\n*                       > 0      : Warning\n*                       = 2      : Degenerated surface\n*                       = 0      : Ok\n*                       < 0      : Error\n*\n*\n* METHOD   : We first make the appropriate knot vectors, then we calulate\n*            parameter values for the interpolation. The evaluator evalp\n*            is used to calculate the interpolation points at these parameter\n*            values. At last these points are interpolated.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s2533(),evalp(),s1891().\n*\n* WRITTEN BY   :  Ulf J Krystad, SINTEF, Oslo, Norway.     Date: 1995-1\n* REWRITTEN BY :  Johannes Kaasa, SINTEF, Oslo, Norway.    Date: 1995-8\n*\n*********************************************************************\n*/\n{\n   int ki, kj;            /* Indices.                                   */\n   int newin1;            /* Number of coefficents in first direction.  */\n   int newin2;            /* Number of coefficents in second direction. */\n   int leftknot1;         /* Pointer into knot array.                   */\n   int leftknot2;         /* Pointer into knot array.                   */\n   int open;              /* Open flag.                                 */\n   int local_in;          /* Local number of coefficients.              */\n   int nlr = 0;           /* Parameter to s1891.                        */\n   int nrc = 0;           /* Parameter to s1891.                        */\n   int *u_eder = SISL_NULL;    /* Parametrization of derivatives.            */\n   int *v_eder = SISL_NULL;    /* Parametrization of derivatives.            */\n   double par[2];         /* Surface parameters.                        */\n   double *newet1 = SISL_NULL; /* Knot vector in first direction.            */\n   double *newet2 = SISL_NULL; /* Knot vector in second direction.           */\n   double *coef1 = SISL_NULL;  /* Surface coefficients.                      */\n   double *coef2 = SISL_NULL;  /* Surface coefficients.                      */\n   double *coef3 = SISL_NULL;  /* Surface coefficients.                      */\n   double *u_par = SISL_NULL;  /* Schoenberg parameters in first direction.  */\n   double *v_par = SISL_NULL;  /* Schoenberg parameters in second direction. */\n\n\n   /* Check input */\n   \n   if (surf == SISL_NULL || u_multinc < 0 || v_multinc < 0 ||\n       newik1 < (u_multinc + 2) || newik2 < (v_multinc + 2)) goto err150;\n\n   /* Generate the knot array (spline space) in first direction. */\n\n   s2533 (surf->et1, surf->ik1, surf->in1, u_multinc, newik1, &newin1, \n\t  &newet1, stat);\n   if (*stat < 0) goto error;\n\n   /* Generate the knot array (spline space) in second direction. */\n\n   s2533 (surf->et2, surf->ik2, surf->in2, v_multinc, newik2, &newin2, \n\t  &newet2, stat);\n   if (*stat < 0) goto error;\n   \n   /* Allocate utility arrays. */\n   \n   if ((coef1 = newarray(newin1*newin2*eval_dim, DOUBLE)) == SISL_NULL) \n      goto err101;\n   if ((u_par = newarray(newin1, DOUBLE)) == SISL_NULL) goto err101;\n   if ((v_par = newarray(newin2, DOUBLE)) == SISL_NULL) goto err101;\n   if ((u_eder = newarray(newin1, INT)) == SISL_NULL) goto err101;\n   if ((v_eder = newarray(newin2, INT)) == SISL_NULL) goto err101;\n   \n   /* Evaluate the property in the Schoenberg points. */\n   \n   for (ki = 0; ki < newin1; ki++)\n   {\n      u_par[ki] = 0.;\n      for (kj = 1; kj < newik1; kj++)\n\t u_par[ki] += newet1[ki + kj];\n      u_par[ki] /= (newik1 - 1);\n      \n      u_eder[ki] = 0;\n   }\n   \n   for (ki = 0; ki < newin2; ki++)\n   {\n      v_par[ki] = 0.;\n      for (kj = 1; kj < newik2; kj++)\n\t v_par[ki] += newet2[ki + kj];\n      v_par[ki] /= (newik2 - 1);\n      \n      v_eder[ki] = 0;\n      \n      par[1] = v_par[ki];\n      for (kj = 0; kj < newin1; kj++)\n      {\n\t par[0] = u_par[kj];\n\t evalp(surf, 0, 1, 1, par, &leftknot1, &leftknot2,\n\t       &coef1[(ki*newin1 + kj)*eval_dim], stat);\n\t if (*stat < 0 || *stat == 2) goto error;\n      }\n   }\n   \n   /* Interpolate curves in 1. parameter direction.  */\n  \n   open = SISL_CRV_OPEN;\n   s1891(u_par, coef1, eval_dim, newin1, newin2, u_eder, open, newet1,\n\t &coef2, &local_in, newik1, nlr, nrc, stat);\n   if (*stat < 0) goto error;\n  \n   /* Interpolation in 2. parameter direction.                */\n  \n   s1891(v_par, coef2, newin1*eval_dim, newin2, 1, v_eder, open, newet2,\n\t &coef3, &local_in, newik2, nlr, nrc, stat);\n   if (*stat < 0) goto error;\n\n   /* Create surface.  */\n\t\t \n   if ((*rsurf = newSurf(newin1, newin2, newik1, newik2, newet1, newet2,\n\t\t\t coef3, 1, eval_dim, 2)) == SISL_NULL) goto err101;\n\n  \n   goto out;\n  \n  \n  \n   /* ---------------------- ERROR EXITS ------------------------------- */\n\n   /* Error in space allocation */\n   \n err101: \n   *stat = -101;\n   s6err(\"s2534\", *stat, 0);\n   goto out;\n\n   /* Error in input. */\n   \n err150:\n   *stat = -150;\n   s6err(\"s2534\", *stat, 0);\n   goto out;\n\n   /* Error in lower level routine. */\n   \n error:\n   s6err(\"s2534\", *stat, 0);\n   goto out;\n\n   /* ---------------------- NORMAL EXIT ------------------------------- */\n\n out:\n   if (coef1 != SISL_NULL)  freearray(coef1);\n   if (coef2 != SISL_NULL)  freearray(coef2);\n   if (u_par != SISL_NULL)  freearray(u_par);\n   if (v_par != SISL_NULL)  freearray(v_par);\n   if (u_eder != SISL_NULL) freearray(u_eder);\n   if (v_eder != SISL_NULL) freearray(v_eder);\n   \n   return;\n}\n"
  },
  {
    "path": "src/s2535.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2535.c,v 1.3 2006-05-02 15:06:04 sbr Exp $\n *\n */\n\n#define S2535\n\n#include \"sislP.h\"\n\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s2535(SISLSurf *surf, int u_continuity, int v_continuity, int *u_surfnumb, \n\t int *v_surfnumb, SISLSurf ***patches, int *stat)\n#else\nvoid s2535(surf, u_continuity, v_continuity, u_surfnumb, v_surfnumb, patches,\n\t   stat)\n     SISLSurf *surf;\n     int      u_continuity;\n     int      v_continuity;\n     int      *u_surfnumb;\n     int      *v_surfnumb;\n     SISLSurf ***patches;\n     int      *stat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n* PURPOSE : To split a surface in order to meet given continuity requirements.\n*\n*\n* INPUT   : surf         - The original surface.\n*           u_continuity - Desired continuity of the surface in u direction:\n*                          = 0 : Positional continuity,\n*                          = 1 : Tangential continuity,\n*                          and so on.\n*                          SISL only accepts surfaces of continuity 0 or larger.\n*                          If the surface is to be intersected with another,\n*                          the continuity must be 1 or larger to find all the\n*                          intersection curves.\n*           v_continuity - Desired continuity of the surface in v direction:\n*                          = 0 : Positional continuity,\n*                          = 1 : Tangential continuity,\n*                          and so on.\n*                          SISL only accepts surfaces of continuity 0 or larger.\n*                          If the surface is to be intersected with another,\n*                          the continuity must be 1 or larger to find all the\n*                          intersection curves.\n*\n*\n* OUTPUT  : u_surfnumb   - Number of surface patches in u direction.\n*           v_surfnumb   - Number of surface patches in v direction.\n*           patches      - Array of patches with the given continuity. The\n*                          array index runs fastest in the u direction.\n*                          If u_surfnumb and v_surfnumb are both 1, no split\n*                          is necessary and patches is empty.\n*           stat         - Status message.\n*                          > 0      : Warning.\n*                          = 0      : Ok.\n*                          < 0      : Error.\n*\n*\n* METHOD  :\n*\n*\n* CALLS   : s1711()\n*\n* WRITTEN BY : Johannes Kaasa, SINTEF, Oslo, Norway, Aug. 1995.\n*\n*********************************************************************\n*/\n{\n   int ki, kj;        /* Array indexes.                                   */\n   int mult;          /* Knot multiplicity.                               */\n   int u_mult;        /* Knot multiplicity giving a split in u direction. */\n   int v_mult;        /* Knot multiplicity giving a split in v direction. */\n   double *u_splitpar = SISL_NULL; /* Split parameters in u direction.         */\n   double *v_splitpar = SISL_NULL; /* Split parameters in v direction.         */\n   SISLSurf *u_surf;  /* Surface pointer used in the surface splitting.   */\n   SISLSurf *u_lsurf; /* Surface pointer used in the surface splitting.   */\n   SISLSurf *u_rsurf; /* Surface pointer used in the surface splitting.   */\n   SISLSurf *v_surf;  /* Surface pointer used in the surface splitting.   */\n   SISLSurf *v_lsurf; /* Surface pointer used in the surface splitting.   */\n   SISLSurf *v_rsurf; /* Surface pointer used in the surface splitting.   */\n   \n   /* Check input. */\n   \n   if (surf == SISL_NULL || u_continuity < 0 || v_continuity < 0) \n      goto err150;\n   \n   /* Initiation and allocation of split parameters. */\n   \n   u_mult = max(surf->ik1 - u_continuity, 1);\n   v_mult = max(surf->ik2 - v_continuity, 1);\n   \n   if ((u_splitpar = newarray(((int) floor((double) surf->in1/u_mult)) - 1, DOUBLE)) \n       == SISL_NULL) goto err101;\n   if ((v_splitpar = newarray(((int) floor((double) surf->in2/v_mult)) - 1, DOUBLE)) \n       == SISL_NULL) goto err101;\n   \n   *u_surfnumb = 0;\n   *v_surfnumb = 0;\n   \n   /* Generate the split points. */\n   \n   ki = surf->ik1;\n   while(ki < surf->in1)\n   {\n      mult = 1;\n      kj = ki;\n      while (DEQUAL(surf->et1[kj], surf->et1[ki]))\n      {\n\t mult++;\n\t kj++;\n      }\n      if (mult > u_mult)\n      {\n\t u_splitpar[*u_surfnumb] = surf->et1[ki];\n\t *u_surfnumb += 1;\n      }\n      ki = kj;\n   }\n   \n   ki = surf->ik2;\n   while(ki < surf->in2)\n   {\n      mult = 1;\n      kj = ki;\n      while (DEQUAL(surf->et2[kj], surf->et2[ki]))\n      {\n\t mult++;\n\t kj++;\n      }\n      if (mult > v_mult)\n      {\n\t v_splitpar[*v_surfnumb] = surf->et2[ki];\n\t *v_surfnumb += 1;\n      }\n      ki = kj;\n   }   \n\n\n   *u_surfnumb += 1;\n   *v_surfnumb += 1;\n   \n   if (*u_surfnumb == 1 && *v_surfnumb == 1)\n      goto out;\n   \n   /* Allocate the output array. */\n   \n   if ((*patches = newarray((*u_surfnumb)*(*v_surfnumb), SISLSurf*)) \n       == SISL_NULL) goto err101;\n   \n   /* Split the surfaces. */\n   \n   v_surf = surf;\n   for (ki = 0; ki < (*v_surfnumb - 1); ki++)\n   {\n      \n      /* Split in v direction. */\n      \n      s1711(v_surf, 2, v_splitpar[ki], &v_lsurf, &v_rsurf, stat);\n      if (*stat < 0) goto error;\n      \n      if (v_surf != surf && v_surf != SISL_NULL) freeSurf(v_surf);\n      v_surf = v_rsurf;\n      \n      /* Split in u direction. */\n      \n      u_surf = v_lsurf;\n      for (kj = 0; kj < (*u_surfnumb - 1); kj++)\n      {\n\t s1711(u_surf, 1, u_splitpar[kj], &u_lsurf, &u_rsurf, stat);\n\t if (*stat < 0) goto error;\n\t \n\t if (u_surf != SISL_NULL) freeSurf(u_surf);\n         u_surf = u_rsurf;\n\t \n\t (*patches)[ki*(*u_surfnumb) + kj] = u_lsurf;\n      }\n      \n      /* Take care of the last column. */\n      \n      (*patches)[ki*(*u_surfnumb) + (*u_surfnumb - 1)] = u_surf;\n   }\n   \n   /* Split the last row. */\n   \n   u_surf = v_surf;\n   for (kj = 0; kj < (*u_surfnumb - 1); kj++)\n   {\n      s1711(u_surf, 1, u_splitpar[kj], &u_lsurf, &u_rsurf, stat);\n      if (*stat < 0) goto error;\n      \n      if (u_surf != surf && u_surf != SISL_NULL) freeSurf(u_surf);\n      u_surf = u_rsurf;\n      \n      (*patches)[(*v_surfnumb - 1)*(*u_surfnumb) + kj] = u_lsurf;\n   }\n   \n   /* Take care of the last column. */\n   \n   (*patches)[(*v_surfnumb)*(*u_surfnumb) - 1] = u_surf;\n\n   goto out;\n\n\n\n   /* ---------------------- ERROR EXITS ------------------------------- */\n\n   /* Error in space allocation */\n   \n err101: \n   *stat = -101;\n   s6err(\"s2535\",*stat,0);\n   goto out;\n\n   /* Error in input. */\n   \n err150:\n   *stat = -150;\n   s6err(\"s2535\", *stat, 0);\n   goto out;\n   \n   /* Error in lower level routine. */\n   \n error:\n   s6err(\"s2535\", *stat, 0);\n   goto out;\n\n   /* ---------------------- NORMAL EXIT ------------------------------- */\n\n out:\n   if (u_splitpar != SISL_NULL) freearray(u_splitpar);\n   if (v_splitpar != SISL_NULL) freearray(v_splitpar);\n   return;\n\n}\n"
  },
  {
    "path": "src/s2536.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2536.c,v 1.3 2001-03-19 15:58:59 afr Exp $\n *\n */\n\n\n#define S2536\n\n#include \"sislP.h\"\n\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s2536(SISLSurf *surf, int u_continuity, int v_continuity, \n      int *u_surfnumb, int *v_surfnumb, SISLSurf ***mehlum_surf, int *stat)\n#else\nvoid s2536(surf, u_continuity, v_continuity, u_surfnumb, \n\t   v_surfnumb, mehlum_surf, stat)\n     SISLSurf *surf;\n     int      u_continuity;\n     int      v_continuity;\n     int      *u_surfnumb;\n     int      *v_surfnumb;\n     SISLSurf ***mehlum_surf;\n     int      *stat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n* PURPOSE : To interpolate the Mehlum curvature of a B-SPLINE or NURBS \n*           surface, as a NURBS surface. \n*           The desired continuity of the Mehlum-curvature surface is given as \n*           input, this may lead to a patchwork of output surfaces. \n*           THE INTERPOLATION RESULTS IN A HIGH ORDER SURFACE (IF THE ORIGINAL \n*           SURFACE IS A B-SPLINE OF ORDER K, THE RESULT IS OF ORDER 12K - 17, \n*           IN THE NURBS CASE THE ORDER IS 48K - 53). TO AVOID UNSTABILITY\n*           BECAUSE OF THIS, A MAX. ORDER IS APPLIED. THIS MAY LEAD TO AN\n*           APPROXIMATION INSTEAD OF AN INTERPOLATION.\n*\n*\n* INPUT   : surf         - The original surface.\n*           u_continuity - Desired continuity of the Mehlum-curvature surfaces\n*                          in u direction:\n*                          = 0 : Positional continuity,\n*                          = 1 : Tangential continuity,\n*                          and so on.\n*                          SISL only accepts surfaces of continuity 0 or larger.\n*                          If the surface is to be intersected with another,\n*                          the continuity must be 1 or larger to find all the\n*                          intersection curves.\n*           v_continuity - Desired continuity of the Mehlum-curvature surfaces\n*                          in v direction:\n*                          = 0 : Positional continuity,\n*                          = 1 : Tangential continuity,\n*                          and so on.\n*                          SISL only accepts surfaces of continuity 0 or larger.\n*                          If the surface is to be intersected with another,\n*                          the continuity must be 1 or larger to find all the\n*                          intersection curves.\n*\n*\n* OUTPUT  : u_surfnumb   - Number of Mehlum-curvature surface patches\n*                          in u direction.\n*           v_surfnumb   - Number of Mehlum-curvature surface patches\n*                          in v direction.\n*           mehlum_surf  - The Mehlum curvature interpolation surfaces.\n*                          This will be a pointer to an array of length\n*                          u_surfnum*v_surfnumb of SISLSurf pointers,\n*                          where the indexing is running fastest in the\n*                          u direction.\n*           stat         - Status message.\n*                          > 0      : Warning.\n*                          = 2      : The surface is degenerated.\n*                          = 0      : Ok.\n*                          < 0      : Error.\n*\n*\n* METHOD  :\n*\n*\n* CALLS   : s2535(), s2534()\n*\n* WRITTEN BY : Johannes Kaasa, SINTEF, Oslo, Norway, Aug. 1995.\n*\n*********************************************************************\n*/\n{\n   int ki;                     /* Index in for loops.                    */\n   int u_multinc;              /* Increased knot multiplicity.           */\n   int v_multinc;              /* Increased knot multiplicity.           */\n   int newik1;                 /* New order in u direction.              */\n   int newik2;                 /* New order in v direction.              */\n   int eval_dim;               /* Evaluation dimention.                  */\n   int max_order = 20;         /* Max. order of the curvature surface.   */\n   SISLSurf *temp = SISL_NULL;      /* Temporary surface.                     */\n   SISLSurf *regular = SISL_NULL;   /* k-regular surface.                     */\n   SISLSurf **org_surf = SISL_NULL; /* Array of pointers to original patches. */\n   \n   \n   /* Check input. */\n   \n   if (surf == SISL_NULL || u_continuity < 0 || v_continuity < 0)\n      goto err150;\n   \n   /* Curvature continuity decrease. */\n   \n   u_multinc = 2;\n   v_multinc = 2;\n   \n   /* Make sure we have a k-regular surface. */\n\n   if (surf->cuopen_1 == SISL_SURF_PERIODIC || \n       surf->cuopen_2 == SISL_SURF_PERIODIC )\n   {\n      make_sf_kreg(surf, &regular, stat);\n      if (*stat < 0) goto error;\n   }\n   else\n      regular = surf;\n   \n   /* Split the surface to meet the continuity requirements. */\n   \n   s2535(regular, (u_continuity + u_multinc), (v_continuity + v_multinc), \n\t u_surfnumb, v_surfnumb, &org_surf, stat);\n   if (*stat < 0) goto error;\n   \n   /* Allocate output array. */\n   \n   if ((*mehlum_surf = newarray((*u_surfnumb)*(*v_surfnumb), SISLSurf*)) \n       == SISL_NULL) goto err101;\n   for (ki = 0; ki < (*u_surfnumb)*(*v_surfnumb); ki++)\n      (*mehlum_surf)[ki] = SISL_NULL;\n   \n   /* Calculate curvature order. */\n   \n   if (regular->ikind == 1 || regular->ikind == 3)\n   {\n      newik1 = 12*regular->ik1 - 17;\n      newik2 = 12*regular->ik2 - 17;\n   }\n   else\n   {\n      newik1 = 48*regular->ik1 - 53;\n      newik2 = 48*regular->ik2 - 53;\n   }\n   newik1 = min(newik1, max_order);\n   newik2 = min(newik2, max_order);\n   \n   eval_dim = 2;\n   \n   /* Interpolate. */\n   \n   if (*u_surfnumb == 1 && *v_surfnumb == 1)\n   {\n      s2534(regular, u_multinc, v_multinc, newik1, newik2, s2515, eval_dim,\n\t    &temp, stat);\n      if (*stat < 0) goto error;\n      if (*stat == 2) goto war002;\n      \n      (*mehlum_surf)[0] = newSurf(temp->in1, temp->in2, temp->ik1, temp->ik2,\n\t\t\t\t temp->et1, temp->et2, temp->ecoef, 2, 1, 1);\n      \n      if (temp != SISL_NULL)\n      {\n\t freeSurf(temp);\n\t temp = SISL_NULL;\n      }\n   }\n   else\n   {\n      for (ki = 0; ki < (*u_surfnumb)*(*v_surfnumb); ki++)\n      {\n\t s2534(org_surf[ki], u_multinc, v_multinc, newik1, newik2, s2515, \n\t       eval_dim, &temp, stat);\n         if (*stat < 0) goto error;\n\t if (*stat == 2) goto war002;\n      \n         (*mehlum_surf)[ki] = newSurf(temp->in1, temp->in2, temp->ik1, \n\t\t\t\t     temp->ik2, temp->et1, temp->et2, \n\t\t\t\t     temp->ecoef, 2, 1, 1);\n\t \n\t if (temp != SISL_NULL)\n         {\n\t    freeSurf(temp);\n\t    temp = SISL_NULL;\n         }\n      }\n   }\n\n\n   goto out;\n\n\n\n   /* ---------------------- ERROR EXITS ------------------------------- */\n   \n   /* The surface is degenerated at (u,v) */\n   \n war002:\n   if (*mehlum_surf != SISL_NULL)\n   {\n      for (ki = 0; ki < ((*u_surfnumb)*(*v_surfnumb)); ki++)\n\t if ((*mehlum_surf)[ki] != SISL_NULL) freeSurf((*mehlum_surf)[ki]);\n      freearray(*mehlum_surf);\n   }\n   *u_surfnumb = 0;\n   *v_surfnumb = 0;\n   goto out;\n  \n  /* Error in space allocation */\n   \n err101: \n   *stat = -101;\n   s6err(\"s2536\", *stat, 0);\n   goto out;\n\n   /* Error in input. */\n   \n err150:\n   *stat = -150;\n   s6err(\"s2536\", *stat, 0);\n   goto out;\n\n   /* Error in lower level routine. */\n   \n error:\n   s6err(\"s2536\", *stat, 0);\n   goto out;\n\n   /* ---------------------- NORMAL EXIT ------------------------------- */\n\n out:\n   if (regular != surf ) freeSurf(regular);\n   if (org_surf != SISL_NULL)\n   {\n      for (ki = 0; ki < ((*u_surfnumb)*(*v_surfnumb)); ki++)\n\t if (org_surf[ki] != SISL_NULL) freeSurf(org_surf[ki]);\n      freearray(org_surf);\n   }\n   \n   return;\n\n}\n"
  },
  {
    "path": "src/s2540.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2540.c,v 1.4 1999-01-06 12:23:42 jka Exp $\n *\n */\n\n#define S2540\n\n#include \"sislP.h\"\n\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2540(SISLSurf *surf, int curvature_type, int export_par_val, int pick_subpart,\n      double boundary[], int n_u, int n_v,\n      double **garr, int *stat)\n#else\nvoid\ns2540(surf, curvature_type, export_par_val, pick_subpart, boundary, n_u, n_v,\n      garr, stat)\n     SISLSurf *surf;\n     int curvature_type;\n     int export_par_val;\n     int pick_subpart;\n     double boundary[];\n     int n_u;\n     int n_v;\n     double **garr;\n     int *stat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n* PURPOSE : To compute a set of curvature values on an uniform grid\n*           in a selected subset of the parameter domain for a\n*           NURBS surface.\n*\n*\n* INPUT   : surf  \t   - The surface to evaluate.\n*\t    curvature_type - The type of curvature:\n*                            0 - Gaussian.\n*                            1 - Mean.\n*                            2 - Absolute.\n*                            3 - Total.\n*                            4 - second order Mehlum (curvature).\n*                            5 - third order Mehlum (variation of curvature).\n*\t    export_par_val - Flag telling if the parameter values for each grid\n*                            point is to be exported:\n*                            0 - False, do not export parameter values,\n*                            1 - True, do export parameter values.\n*           pick_subpart   - Flag teliing if the grid is to be calculated on a\n*                            subpart of the surface:\n*                            0 - False, calculate grid on the complete surface,\n*                            1 - True, calculate grid on a part of the surface.\n*           boundary       - A rectangular subset of the parameter domain.\n*              \t             [0] - Min value 1. parameter direction.\n*                            [1] - Min value 2. parameter direction.\n*                            [2] - Max value 1. parameter direction.\n*                            [3] - Max value 2. parameter direction.\n*                            ONLY USED WHEN pick_subpart = 1. If pick_subpart\n*                            = 0, the parameter area of surf is given out here.\n*           n_u            - Number of segments in 1. parameter direction.\n*           n_v            - Number of segments in 2. parameter direction.\n*\n*\n*\n* OUTPUT  : garr  \t   - Array containing the computed values on the grid.\n*\t\t             The allocation is done internally and the dimension\n*\t\t\t     is  3*(n_u+1)*(n_v+1) if export_par_val is true,\n*\t\t             and (n_u+1)*(n_v+1) if export_par_val is false.\n*                            Each gridpoint consist of a triple\n*                            (Ui,Vj,curvature(Ui,Vj)) or only curvature(Ui,Vj).\n*\t\t\t     The sequence is running first in the\n*                            1. parameter direction.\n**\n*           stat           - Status message.\n*                               > 0      : Warning.\n*                               = 0      : Ok.\n*                               < 0      : Error.\n*\n*\n* METHOD  :\n*\n*\n* CALLS   :s2541(), ( s2500(), s2502(), s2504(), s2506(), s2508(), s2510()).\n*\n* WRITTEN BY :  Ulf J Krystad,  SINTEF, Oslo, Norway, Jan. 1995.\n* REVISED BY :  Johannes Kaasa, SINTEF, Oslo, Norway, Aug. 1995.\n*               (Mehlum curvature added).\n*\n*********************************************************************\n*/\n{\n  int dim=1;              /* Dimension of evaluator output.\t  */\n\n  if (curvature_type == 0)\n     s2541(surf, s2500, dim, export_par_val, pick_subpart, boundary, n_u, n_v,\n\t   garr, stat);\n  else if (curvature_type == 1)\n     s2541(surf, s2502, dim, export_par_val, pick_subpart, boundary, n_u, n_v,\n\t   garr, stat);\n  else if (curvature_type == 2)\n     s2541(surf, s2504, dim, export_par_val, pick_subpart, boundary, n_u, n_v,\n\t   garr, stat);\n  else if (curvature_type == 3)\n     s2541(surf, s2506, dim, export_par_val, pick_subpart, boundary, n_u, n_v,\n\t   garr, stat);\n  else if (curvature_type == 4)\n     s2541(surf, s2508, dim, export_par_val, pick_subpart, boundary, n_u, n_v,\n\t   garr, stat);\n  else if (curvature_type == 5)\n     s2541(surf, s2510, dim, export_par_val, pick_subpart, boundary, n_u, n_v,\n\t   garr, stat);\n  else\n     goto err151;\n  if (*stat < 0) goto error;\n\n\n  *stat = 0;\n  goto out;\n\n  /* ___________________________________________________________________ */\n  /*                         ERROR EXITS                                 */\n  /* ___________________________________________________________________ */\n\n  /* Error in input, uknown type specified */\nerr151:\n  *stat = -151;\n  s6err(\"s2540\", *stat, 0);\n  goto out;\n\n  /* Error in lower level routine. */\nerror:\n  s6err(\"s2540\", *stat, 0);\n  goto out;\n\n  /* ___________________________________________________________________ */\n  /*                         THE ONE AND ONLY EXIT                       */\n  /* ___________________________________________________________________ */\n\nout:\n  return;\n\n}\n"
  },
  {
    "path": "src/s2541.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2541.c,v 1.4 2005-02-28 09:04:49 afr Exp $\n *\n */\n\n#define S2541\n\n#include \"sislP.h\"\n\n\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n   s2541(SISLSurf *surf,\n\t void evalp(SISLSurf *surf, int ider,int iside1,int iside2,\n\t\t    double parvalue[], int *leftknot1, int *leftknot2,\n\t\t    double *result, int *istat),\n\t int dim,\n\t int export_par_val,\n\t int pick_subpart,\n\t double boundary[],\n\t int n_u,\n\t int n_v,\n\t double **garr,\n\t int *stat)\n#else\nvoid\n   s2541(surf, evalp, dim, export_par_val, pick_subpart, boundary, n_u, n_v,\n\t garr, stat)\n      SISLSurf *surf;\n      void evalp();\n      int dim;\n      int export_par_val;\n      int pick_subpart;\n      double boundary[];\n      int n_u;\n      int n_v;\n      double **garr;\n      int *stat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n* PURPOSE : To compute a set of values on an uniform grid\n*           in a selected subset of the parameter domain for a\n*           NURBS surface. The values given is based on the evaluator evalp().\n*\n*\n* INPUT   : surf           - The surface to evaluate.\n*           evalp   \t   - A pointer to the function/evaluator to be used\n*                            when computing the wanted values.\n*           dim    \t   - The spatial dimension required for the output\n*                            values, must be consistent with the result from\n*                            the evaluator.\n*\t    export_par_val - Flag telling if the parameter values for each grid\n*                            point is to be exported:\n*                            0 - False, do not export parameter values,\n*                            1 - True, do export parameter values.\n*           pick_subpart   - Flag teliing if the grid is to be calculated on a\n*                            subpart of the surface:\n*                            0 - False, calculate grid on the complete surface,\n*                            1 - True, calculate grid on a part of the surface.\n*           boundary       - A rectangular subset of the parameter domain.\n*              \t\t     [0] - Min value 1. parameter direction.\n*                            [1] - Min value 2. parameter direction.\n*                            [2] - Max value 1. parameter direction.\n*                            [3] - Max value 2. parameter direction.\n*                            ONLY USED WHEN pick_subpart = 1.\n*           n_u            - Number of segments in 1. parameter direction.\n*           n_v            - Number of segments in 2. parameter direction.\n*\n*\n*\n* OUTPUT  : garr  \t   - Array containing the computed values on the grid.\n*\t\t             The allocation is done internally and the dimension\n*\t\t\t     is  3*(n_u+1)*(n_v+1) if export_par_val is true,\n*\t\t             and (n_u+1)*(n_v+1) if export_par_val is false.\n*                            Each gridpoint consist of a triple\n*                            (Ui,Vj,curvature(Ui,Vj)) or only curvature(Ui,Vj).\n*\t\t\t     The sequence is running first in the\n*                            1. parameter direction.\n*\n*           stat           - Status message.\n*                               > 0      : Warning.\n*                               = 0      : Ok.\n*                               < 0      : Error.\n*\n*\n* METHOD  :\n*\n*\n* CALLS   :s1001(), ( s2500(), s2502(), s2504(), s2506(), s2508()).\n*\n* WRITTEN BY :  Ulf J Krystad, SINTEF, Oslo, Norway, Jan. 1995.\n* REVISED BY :  Johannes Kaasa, SINTEF, Oslo, Norway, Aug. 1995.\n*\n*********************************************************************\n*/\n{\n  int dimpnt;\t\t\t/* Dimesion of each gridpoint        \t*/\n  int kder = 0;                 /* Derivativ indicator          \t*/\n  int ki, kj;               \t/* Loop control variable        \t*/\n  int klfs = 0;                 /* Pointer into knot vector           \t*/\n  int klft = 0;            \t/* Pointer into knot vector   \t\t*/\n  int kside1=0,kside2=0;    \t/* Left,right evaluations             \t*/\n  int incr;    \t\t\t/* Increment, space for par values.    \t*/\n  double duv[2];\t\t/* Increment in 1.+2. par dir.  \t*/\n  double UV[2];\t\t\t/* Current grid value in par space.\t*/\n  double *sarr = SISL_NULL;    \t/* Local pointer eq (*garr)\t\t*/\n  double *sp = SISL_NULL;      \t/* Local pointer into (*garr)\t\t*/\n  SISLSurf *temp = SISL_NULL;  \t/* Temp surface. \t\t\t*/\n  /* __________________________________________________________________ */\n\n\n  /* Initiate output variables . */\n\n  *garr  = SISL_NULL;\n  *stat = 0;\n\n\n  /* Check input. */\n  if ( !surf ) \t\tgoto err150;\n  if (dim < 1) \t        goto err102;\n  if ( n_u < 1) \tgoto err172;\n  if ( n_v < 1) \tgoto err172;\n\n  /* Pick the surface defined over the subset wanted. */\n\n  if (pick_subpart == 1)\n  {\n     s1001 (surf, boundary[0], boundary[1], boundary[2], boundary[3],\n   \t &temp, stat);\n     if (*stat < 0) goto error;\n  }\n  else\n  {\n     temp = surf;\n     boundary[0] = temp->et1[temp->ik1 - 1];\n     boundary[1] = temp->et2[temp->ik2 - 1];\n     boundary[2] = temp->et1[temp->in1];\n     boundary[3] = temp->et2[temp->in2];\n  }\n\n  /* Allocate space needed */\n  incr = (export_par_val? 2 : 0);\n  dimpnt = incr+dim;\n  if ((sarr = newarray(dimpnt*(n_u+1)*(n_v+1), double)) == SISL_NULL) goto err101;\n\n  /* The evaluation loop, note that to ensure that we get boundary values\n     correct, we stop the main loops one step too early and then jump\n     to the maximum boundary. */\n\n  duv[0] = (boundary[2] - boundary[0])/n_u;\n  duv[1] = (boundary[3] - boundary[1])/n_v;\n\n  for (kj=0,UV[1]=boundary[1],sp=sarr;kj<n_v;kj++,UV[1] += duv[1])\n  {\n     for (ki=0,UV[0]=boundary[0];ki<n_u;ki++,UV[0] += duv[0],sp += dimpnt)\n     {\n\tif (export_par_val)\n\t{\n\t   sp[0] = UV[0];\n\t   sp[1] = UV[1];\n\t}\n\tevalp(temp,kder=0,kside1=0,kside2=0,UV,&klfs,&klft,\n\t      sp+incr, stat);\n\tif (*stat < 0) goto error;\n     }\n\n     /* Last column. */\n\n     UV[0] = boundary[2];\n     if (export_par_val)\n     {\n\tsp[0] = UV[0];\n\tsp[1] = UV[1];\n     }\n     evalp(temp,kder=0,kside1=0,kside2=0,UV,&klfs,&klft,\n\t   sp+incr, stat);\n     if (*stat < 0) goto error;\n     sp += dimpnt;\n  }\n\n  /* Last row. */\n\n  for (ki=0,UV[0]=boundary[0];ki<n_u;ki++,UV[0] += duv[0],sp += dimpnt)\n  {\n     UV[1] = boundary[3];\n     if (export_par_val)\n     {\n\tsp[0] = UV[0];\n\tsp[1] = UV[1];\n     }\n     evalp(temp,kder=0,kside1=0,kside2=0,UV,&klfs,&klft,\n\t   sp+incr, stat);\n     if (*stat < 0) goto error;\n  }\n\n  /* Last column in last row. */\n\n  UV[0] = boundary[2];\n  UV[1] = boundary[3];\n  if (export_par_val)\n  {\n     sp[0] = UV[0];\n     sp[1] = UV[1];\n  }\n  evalp(temp,kder=0,kside1=0,kside2=0,sp,&klfs,&klft,\n\tsp+incr, stat);\n  if (*stat < 0) goto error;\n\n\n  /* OK, we are thru, hand over the array: */\n  *garr  = sarr;\n  sarr   = SISL_NULL;\n  *stat = 0;\n\n  goto out;\n\n\n\n  /* ___________________________________________________________________ */\n  /*                         ERROR EXITS                                 */\n  /* ___________________________________________________________________ */\n\n\n  /* Error in space allocation */\nerr101:\n  *stat = -101;\n  s6err(\"s2541\", *stat, 0);\n  goto out;\n\n   /* Error in input, dim < 1 */\nerr102:\n   *stat = -102;\n   s6err(\"s2541\", *stat, 0);\n   goto out;\n\n   /* Error. Input (surface) pointer is SISL_NULL. */\nerr150:\n  *stat = -150;\n  s6err(\"s2541\", *stat, 0);\n  goto out;\n\n  /* Error. Too few segments in input. */\nerr172:\n  *stat = -172;\n  s6err(\"s2541\", *stat, 0);\n  goto out;\n\n  /* Error in lower level routine. */\nerror:\n  s6err(\"s2541\", *stat, 0);\n  goto out;\n\n  /* ___________________________________________________________________ */\n  /*                         THE ONE AND ONLY EXIT                       */\n  /* ___________________________________________________________________ */\n\nout:\n  /* Free local heap space. */\n\n  if (pick_subpart == 1 && temp) freeSurf(temp);\n  if ( sarr )  \t\t         freearray(sarr);\n  return;\n\n}\n"
  },
  {
    "path": "src/s2542.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2542.c,v 1.3 2001-03-19 15:59:00 afr Exp $\n *\n */\n\n\n#define S2542\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   s2542(SISLSurf *surf, int ider, int iside1, int iside2, double parvalue[],\n      int *leftknot1,int *leftknot2, double *k1, double *k2,  \n      double d1[], double d2[],int *jstat)\n#else\n void s2542(surf, ider, iside1, iside2,  parvalue, leftknot1, leftknot2, \n\t    k1, k2, d1, d2, jstat)\n      SISLSurf *surf;\n      int    ider;\n      int    iside1;\n      int    iside2;\n      double parvalue[];\n      int *leftknot1;\n      int *leftknot2;\n      double *k1;\n      double *k2;\n      double d1[];\n      double d2[];\n      int *jstat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute principal curvature (k1,k2) with corresponding \n*                  principal directions (d1,d2) of a surface for \n*                  given values (u,v) = (parvalue[0],parvalue[1]), where:\n*\n*                          etl[leftknot1] <= parvalue[0] < etl[leftknot1+1],\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Number of derivatives to calculate.\n*                     Only implemented for ider=0.\n*                       < 0 : No derivative calculated.\n*                       = 0 : Principal curvature calculated.\n*                       = 1 : Principal curvature and its first derivative \n*                             calculated.\n*                       etc.\n*          iside1   - Indicator telling if the principal curvature in the first\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate principal curvature from the left hand \n*                             side\n*                        >= 0 calculate principal curvature from the right hand \n*                             side.\n*          iside2   - Indicator telling if the principal curvature in the second\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate principal curvature from the left hand \n*                             side\n*                        >= 0 calculate principal curvature from the right hand \n*                             side.\n*      parvalue     - Parameter-value at which to evaluate. Dimension of\n*                     parvalue is 2.\n*\n*  INPUT/OUTPUT :\n*     leftknot1     - Pointer to the interval in the knot vektor in the \n*                     first parameter direction where parvalue[0] is found,\n*                     that is: \n*                          etl[leftknot1] <= parvalue[0] < etl[leftknot1+1].\n*                     leftknot1 should be set equal to zero at the first call\n*                     to the rutine.\n*          \n*     leftknot1     - Pointer to the interval in the knot vektor in the \n*                     second parameter direction where parvalue[1] is found,\n*                     that is: \n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*                     leftknot2 should be set equal to zero at the first call\n*                     to the rutine.\n*\n*  OUTPUT       :\n*         k1        - Max. principal curvature.\n*         k2        - Min. principal curvature.\n*         d1        - Max. direction of the principal curvature k1, given \n*                     in local coordiantes (with regard to Xu,Xv).\n*                     Dimension = 2.\n*         d2        - Min. direction of the principal curvature k2, given \n*                     in local coordiantes (with regard to Xu,Xv).\n*                     Dimension = 2.\n*        jstat      - Status messages\n*                         = 2 : Surface is degenerate at the point, that is,\n*                               the surface is not regular at this point.\n*                         = 1 : Surface is close to degenerate at the point.\n*                               Angle between tangents is less than the angular\n*                               tolerance.\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*\n*  METHOD        :  The princpal curvatures -k1 and -k2 are eigenvalues of\n*                   dN, thus it turn out that we have to solve a \n*                   eigenvalue/eigenvector problem, see references.\n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*\n*                  Elementary Linear Algebra 5e\n*                    (Howard Anton, Wiley, ISBN:0-471-84819-0)\n*-\n*  CALLS        :  s1422() and s2543().\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenrated (not regular) at the point\n*                    (u,v), it makes now sence to speak about curvature.\n*                    The routine return istat == 2.\n*               (ii) If the surface is close to degenrate, the resuts\n*                    can be numerical unstable. The routine return \n*                    istat == 1.\n*              (iii) The dimension of the space in which the surface lies must \n*                    be 1,2 or 3.\n*  \n*\n* WRITTEN BY    :  Geir Westgaard,  SINTEF, Oslo, Norway.         Date: 1995-1\n******************************************************************************\n*/\n{\n  int kwarn = 0;         /* Local staus variable(warning).                  */\n  int der = 0;           /*  (dummy) */\n  double derive[18];     /* Array containing the computed derivatives.      */\n  double normal[3];      /* Array containing the computed normalvektor.     */\n\n\n  if (ider != 0) goto err178;\n\n\n  if (surf == SISL_NULL)  goto err150;\n  else\n  {\n    /* Compute derivates and normal. */\n\n    s1422(surf,2,iside1,iside2,parvalue,leftknot1,leftknot2,derive,normal,\n\t  jstat);\n    if (*jstat > 0) kwarn = *jstat;\n\n    if (*jstat < 0) /* Error in lower level routine. */\n    {\n      goto error;\n    }\n    else if (*jstat != 2) /* The surface is not degenerate */\n    {\n      s2543(surf, der, derive, normal, k1, k2, d1, d2, jstat);\n\n      if (*jstat < 0)\n\tgoto error;\n    }\n    else if (*jstat == 2) /* The surface is degenerated. */\n    {\n      *k1 = 0.0;\n      *k2 = 0.0;\n      d1[0] = 1.0;\n      d1[1] = 0.0;\n      d2[0] = 0.0;\n      d2[1] = 1.0;\n      \n      goto war002;\n    }\n\n  }\n  \n  /* Successful computations  */\n  \n  *jstat = kwarn;\n  goto out;\n    \n  /* The surface is degenerated at (u,v) */\n  war002:\n     *jstat = 2;\n  goto out;\n  \n  /* Error. Input (surface) pointer is SISL_NULL. */\n  err150:\n     *jstat = -150;\n  s6err(\"s2542\", *jstat, 0);\n  goto out;\n  \n  /* Illegal derivative requested. */\n  err178:\n     *jstat = -178;\n  s6err(\"s2542\",*jstat,0);\n  goto out;\n  /* Error in lower level routine.  */\n  \n  error:\n     s6err(\"s2542\",*jstat,0);\n  goto out;\n  \n  \n  out:\n     \n     return;\n\n}\n\n\n"
  },
  {
    "path": "src/s2543.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2543.c,v 1.7 1996-08-02 07:29:05 jka Exp $\n *\n */\n\n\n#define S2543\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns2543(SISLSurf *surf, int ider, double derive[], double normal[], double *k1,\n      double *k2, double d1[], double d2[], int *jstat)\n#else\n void s2543(surf, ider, derive, normal, k1, k2, d1, d2, jstat)\n      SISLSurf *surf;\n      int ider;\n      double derive[];\n      double normal[];\n      double *k1;\n      double *k2;\n      double d1[];\n      double d2[];\n      int *jstat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute principal curvature (k1,k2) with corresponding \n*                  principal directions (d1,d2) of a surface for \n*                  given values (u,v). This is a lower level routine,\n*                  used for evaluation of many T(u,v)'s.\n*\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Number of derivatives to calculate.\n*                     Only implemented for ider=0.\n*                       < 0 : No derivative calculated.\n*                       = 0 : Principal curvature calculated.\n*                       = 1 : Principal curvature and its first derivative \n*                             calculated.\n*       derive      - Array containing derivatives from routine s1421().\n*                     Size = idim*6.\n*       normal      - Array containing the normal from routine s1421().\n*                     Size = 3.\n*\n*  INPUT/OUTPUT :\n*\n*  OUTPUT       :\n*         k1        - Max. principal curvature.\n*         k2        - Min. principal curvature.\n*         d1        - Max. direction of the principal curvature k1, given \n*                     in local coordiantes (with regard to Xu,Xv).\n*                     Dimension = 2.\n*         d2        - Min. direction of the principal curvature k2, given \n*                     in local coordiantes (with regard to Xu,Xv).\n*                     Dimension = 2.\n*        jstat      - Status messages\n*                         = 0 : Ok.\n*                         < 0 : error.\n*\n*  METHOD        :  The princpal curvatures -k1 and -k2 are eigenvalues of\n*                   dN, thus it turn out that we have to solve a \n*                   eigenvalue/eigenvector problem, see references. \n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*\n*                  Elementary Linear Algebra 5e\n*                    (Howard Anton, Wiley, ISBN:0-471-84819-0)\n*-\n*  CALLS        :  \n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenrated (not regular) at the point\n*                    (u,v), it makes now sence to speak about curvature.\n*               (ii) If the surface is closed to degenrate, the resuts\n*                    can be numerical unstable. \n*               (iv) The dimension of the space in which the surface lies must \n*                    be 1,2 or 3.  The routine return istat < 0.\n*  \n*\n* WRITTEN BY :  Geir Westgaard, SINTEF, Oslo, Norway.            Date: 1995-1\n* REWRITTEN BY : Johannes Kaasa, SINTEF, Oslo, Norway.           Date: 1995-9\n*****************************************************************************\n*/\n{\n   double denom;        /* Denominator in a fraction.                 */\n   double a, b, c;      /* Coefficients of second degree equation.    */\n   double sqrt_arg;     /* Square argument.                           */\n   double ratio;        /* Ratio of principal direction.              */\n   double length;       /* Parameter length.                          */\n   double fundform[6];  /* The coefficients of the fundamental forms.\n\t\t\t   The sequence is: E, F, G, e, f, g.         */\n   double transform[4]; /* Transformation matrix.\n\t\t\t   The sequence is a11, a12, a21, a22.        */\n   double Su[3];        /* Tangent in first parameter direction.      */\n   double Sv[3];        /* Tangent in second parameter direction.     */\n   double H, K;\n   double k1_2, k2_2, lambda1, lambda2, du1, du2, dv1, dv2;\n   double swap;\n\n   if (surf->idim == 1 || surf->idim == 3) /* 1D and 3D surface */\n   {\n      \n      /* Set up the tangents. */\n      \n      if (surf->idim == 1)\n      {\n\t Su[0] = 1.;\n\t Su[1] = 0.;\n\t Su[2] = derive[1];\n\t Sv[0] = 0.;\n\t Sv[1] = 1.;\n\t Sv[2] = derive[2];\n      }\n      else\n      {\n\t Su[0] = derive[3];\n\t Su[1] = derive[4];\n\t Su[2] = derive[5];\n\t Sv[0] = derive[6];\n\t Sv[1] = derive[7];\n\t Sv[2] = derive[8];\n      }\n      \n      /* Calculate the fundamental forms. */\n      \n      s2513(surf, ider, 2, 1, derive, normal, fundform, jstat);\n      if (*jstat < 0) goto error;\n      \n      /* Calculate the transformation matrix. */\n      \n      denom = fundform[0]*fundform[2] - fundform[1]*fundform[1];\n      \n      transform[0] = (fundform[1]*fundform[4] - fundform[2]*fundform[3])/\n\t denom;\n      transform[1] = (fundform[1]*fundform[5] - fundform[2]*fundform[4])/\n\t denom;\n      transform[2] = (fundform[1]*fundform[3] - fundform[0]*fundform[4])/\n\t denom;\n      transform[3] = (fundform[1]*fundform[4] - fundform[0]*fundform[5])/\n\t denom;\n\n      /* H = (fundform[2]*fundform[3] + fundform[0]*fundform[5] - */\n      /* \t   2.0*fundform[1]*fundform[4])/(2.0*denom); */\n      /* K = (fundform[3]*fundform[5] - fundform[4]*fundform[4])/denom; */\n      /* k1_2 = H + sqrt(H*H - K); */\n      /* k2_2 = H - sqrt(H*H - K); */\n      /* if (fabs(fundform[5]-k1_2*fundform[2]) > fabs(fundform[4]-k1_2*fundform[1])) */\n      /* \tlambda1 = -(fundform[4] - k1_2*fundform[1])/(fundform[5]-k1_2*fundform[2]); */\n      /* else */\n      /* \tlambda1 = -(fundform[3] - k1_2*fundform[0])/(fundform[4]-k1_2*fundform[1]); */\n      /* if (fabs(fundform[5]-k2_2*fundform[2]) > fabs(fundform[4]-k2_2*fundform[1])) */\n      /* \tlambda2 = -(fundform[4] - k2_2*fundform[1])/(fundform[5]-k2_2*fundform[2]); */\n      /* else */\n      /* \tlambda2 = -(fundform[3] - k2_2*fundform[0])/(fundform[4]-k2_2*fundform[1]); */\n\n      /* Calculate the principal curvature. */\n      \n      a = 1.;\n      b = transform[0] + transform[3];\n      c = transform[0]*transform[3] - transform[1]*transform[2];\n      \n      sqrt_arg = b*b - 4.*a*c;\n      if (sqrt_arg < REL_PAR_RES)\n\t goto war100;\n      \n      *k1 = (- b + sqrt(sqrt_arg))/(2.*a);\n      *k2 = (- b - sqrt(sqrt_arg))/(2.*a);\n      \n      /* Calculate the principal directions. */\n      \n      /* Maximal curvature direction. */\n      \n      if (fabs(transform[0] + *k1) < REL_PAR_RES && \n\t  fabs(transform[1]) < REL_PAR_RES)\n      {\n\t \n\t /* Parallel to the u direction. */\n\t \n\t length = 1./sqrt(Su[0]*Su[0] + Su[1]*Su[1] + Su[2]*Su[2]);\n\t \n\t d1[0] = length;\n\t d1[1] = 0.;\n      }\n      else if (fabs(transform[3] + *k1) < REL_PAR_RES && \n\t       fabs(transform[2]) < REL_PAR_RES)\n      {\n\t \n\t /* Parallel to the v direction. */\n\t \n\t length = 1./sqrt(Sv[0]*Sv[0] + Sv[1]*Sv[1] + Sv[2]*Sv[2]);\n\t \n\t d1[0] = 0.;\n\t d1[1] = length;\n      }\n      else if (fabs(transform[0] + *k1) < fabs(transform[1]))\n      {\n\t ratio = (transform[0] + *k1)/transform[1];\n\t length = 1./sqrt((Su[0] - ratio*Sv[0])*(Su[0] - ratio*Sv[0]) +\n\t\t\t  (Su[1] - ratio*Sv[1])*(Su[1] - ratio*Sv[1]) +\n\t\t\t  (Su[2] - ratio*Sv[2])*(Su[2] - ratio*Sv[2]));\n\t \n\t d1[0] = length;\n\t d1[1] = -ratio*length;\n      }\n      else\n      {\n\t ratio = transform[1]/(transform[0] + *k1);\n\t length = 1./sqrt((Sv[0] - ratio*Su[0])*(Sv[0] - ratio*Su[0]) +\n\t\t\t  (Sv[1] - ratio*Su[1])*(Sv[1] - ratio*Su[1]) +\n\t\t\t  (Sv[2] - ratio*Su[2])*(Sv[2] - ratio*Su[2]));\n\t \n\t d1[0] = -ratio*length;\n\t d1[1] = length;\n      }\n      \n      /* Minimal curvature direction. */\n      \n      if (fabs(transform[0] + *k2) < REL_PAR_RES && \n\t  fabs(transform[1]) < REL_PAR_RES)\n      {\n\t \n\t /* Parallel to the u direction. */\n\t \n\t length = 1./sqrt(Su[0]*Su[0] + Su[1]*Su[1] + Su[2]*Su[2]);\n\t \n\t d2[0] = length;\n\t d2[1] = 0.;\n      }\n      else if (fabs(transform[3] + *k2) < REL_PAR_RES && \n\t       fabs(transform[2]) < REL_PAR_RES)\n      {\n\t \n\t /* Parallel to the v direction. */\n\t \n\t length = 1./sqrt(Sv[0]*Sv[0] + Sv[1]*Sv[1] + Sv[2]*Sv[2]);\n\t \n\t d2[0] = 0.;\n\t d2[1] = length;\t \n      }\n      else if (fabs(transform[0] + *k2) < fabs(transform[1]))\n      {\n\t ratio = (transform[0] + *k2)/transform[1];\n\t length = 1./sqrt((Su[0] - ratio*Sv[0])*(Su[0] - ratio*Sv[0]) +\n\t\t\t  (Su[1] - ratio*Sv[1])*(Su[1] - ratio*Sv[1]) +\n\t\t\t  (Su[2] - ratio*Sv[2])*(Su[2] - ratio*Sv[2]));\n\t \n\t d2[0] = length;\n\t d2[1] = -ratio*length;\n      }\n      else\n      {\n\t ratio = transform[1]/(transform[0] + *k2);\n\t length = 1./sqrt((Sv[0] - ratio*Su[0])*(Sv[0] - ratio*Su[0]) +\n\t\t\t  (Sv[1] - ratio*Su[1])*(Sv[1] - ratio*Su[1]) +\n\t\t\t  (Sv[2] - ratio*Su[2])*(Sv[2] - ratio*Su[2]));\n\t \n\t d2[0] = -ratio*length;\n\t d2[1] = length;\n      }\n      \n   }\n   else if (surf->idim == 2) /* 2D surface */\n   {\n      /* The surface lies in a plane => T(u,v) = 0 */\n      \n      *k1 = 0.0;\n      *k2 = 0.0;\n      d1[0] = 1.0;\n      d1[1] = 0.0;\n      d2[0] = 0.0;\n      d2[1] = 1.0;\n   }\n   else /* When surf->idim != 1,2 or 3 */\n   {\n      goto err105;\n   }\n\n   if (fabs(*k1) > fabs(*k2))\n     {\n       swap = *k1;\n       *k1 = *k2;\n       *k2 = swap;\n       swap = d1[0];\n       d1[0] = d2[0];\n       d2[0] = swap;\n       swap = d1[1];\n       d1[1] = d2[1];\n       d2[1] = swap;\n     }\n   \n   /* Successful computations  */\n   \n   *jstat = 0;\n   goto out;\n   \n   \n   /* The surface does not have principal curvatures. */\n   war100:\n      if (fabs(sqrt_arg) < REL_PAR_RES)\n      {\n\t *k1 = - b/(2.*a);\n\t *k2 = *k1;\n      }\n      else\n      {\n\t *k1 = 0.0;\n\t *k2 = 0.0;\n      }\n   d1[0] = 1.0;\n   d1[1] = 0.0;\n   d2[0] = 0.0;\n   d2[1] = 1.0;\n   goto out;\n   \n   /* Error in input, surf->idim != 1,2 or 3. */\n   err105:\n      *jstat = -105;\n   s6err(\"s2543\",*jstat,0);\n   goto out;\n   \n   error:\n      s6err(\"s2543\",*jstat,0);\n   goto out;\n   \n   out:\n      \n      return;\n\n}\n"
  },
  {
    "path": "src/s2544.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2544.c,v 1.6 2005-02-28 09:04:49 afr Exp $\n *\n */\n\n\n#define S2544\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2544(SISLSurf *surf, int ider, int iside1, int iside2, double parvalue[],\n      int *leftknot1,int *leftknot2, double norcurv[], int *jstat)\n#else\n void s2544(surf, ider, iside1, iside2, parvalue, leftknot1, leftknot2, norcurv,\n\t    jstat)\n      SISLSurf *surf;\n      int    ider;\n      int    iside1;\n      int    iside2;\n      double parvalue[];\n      int *leftknot1;\n      int *leftknot2;\n      double norcurv[];\n      int *jstat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n*  PURPOSE      :  To compute the Normal curvature of a Surface for given\n*                  values (u,v) = (parvalue[0],parvalue[1]), in the\n*                  direction (parvalue[2],parvalue[3])\n*                  where:\n*\n*                          et1[leftknot1] <= parvalue[0] < et1[leftknot1+1],\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*                  \n*\n*  INPUT        :\n*          surf     - Pointer to the surface to evaluate.\n*          ider     - Number of derivatives to calculate.\n*                     Only implemented for ider=0 and 1.\n*                       < 0 : No derivative calculated.\n*                       = 0 : Position calculated.\n*                       = 1 : Position and first derivative calculated.\n*                       etc.\n*          iside1   - Indicator telling if the derivatives in the first\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*          iside2   - Indicator telling if the derivatives in the second\n*                     parameter direction is to be calculated from the\n*                     left or from the right:\n*                        <  0 calculate derivative from the left hand side\n*                        >= 0 calculate derivative from the right hand side.\n*      parvalue     - Parameter-value at which to evaluate pluss the direction\n*                     Dimension of parvalue is 4.\n*\n*  INPUT/OUTPUT :\n*     leftknot1     - Pointer to the interval in the knot vector in the\n*                     first parameter direction where parvalue[0] is found,\n*                     that is:\n*                          et1[leftknot1] <= parvalue[0] < et1[leftknot1+1].\n*                     leftknot1 should be set equal to zero at the first call\n*                     to the routine.\n*\n*     leftknot2     - Pointer to the interval in the knot vector in the\n*                     second parameter direction where parvalue[1] is found,\n*                     that is:\n*                          et2[leftknot2] <= parvalue[1] < et2[leftknot2+1].\n*                     leftknot2 should be set equal to zero at the first call\n*                     to the routine.\n*\n*  OUTPUT       :\n*     norcurv      - Normal curvature and derivatives of normal curvature\n*                    of the surface in (u,v) =(parvalue[0],parvalue[1])\n*                    in the direction (parvalue[2],parvalue[3]).\n*        jstat      - Status messages\n*                         = 2 : Surface is degenerate at the point, that is,\n*                               the surface is not regular at this point.\n*                         = 1 : Surface is close to degenerate at the point.\n*                               Angle between tangents is less than the angular\n*                               tolerance.\n*                         = 0 : Ok.\n*                         < 0 : Error.\n*\n*  METHOD       :  The Normal curvature is given by\n*\n*                      <Xuu,N>d1*d1 + 2<Xuv,N>d1*d2 + <Xvv,N>d2*d2\n*                      --------------------------------------------\n*                      <Xu,Xu>d1*d1 + 2<Xu,Xv>d1*d2 + <Xv,Xv>d2*d2\n*                  \n*                  \n*\t\t   Where (d1,d2) is the normalised parameter direction\n*                  (parvalue[2],parvalue[3]) and the other numbers are\n*                  the factors for the first and second fundamental forms.\n*\n*                  The routine will\n*                  test if the surface is degenerate (not regular) or close to\n*                  degenerate. \n*\n*  REFERENCES   :  Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*-\n*  CALLS        :  s1422() and s2513().\n*\n*  LIMITATIONS  :\n*                (i) If the surface is degenerated (not regular) at the point\n*                    (u,v), it makes no sense to speak about the Normal Curvature.\n*                    The routine returns jstat = 2.\n*               (ii) If the surface is close to degenerate, the calculations\n*                    can be numerical instable. The routine returns\n*                    jstat = 1.\n*              (iii) If the surface is Cr the curvature calculated is C(r-2).\n*               (iv) The dimension of the space in which the surface lies must\n*                    be 1,2 or 3.\n*\n*\n* WRITTEN BY :    Ulf J Krystad, SINTEF, Oslo, Norway.            Date: 1995-1\n* REVISED BY :    Johannes Kaasa, SINTEF, Oslo, Norway.           Date: 1995-9\n* REWRITTEN BY :  Johannes Kaasa, SINTEF, Oslo, Norway.           Date: 1995-11\n*                 (Added first derivative of normal curvature).\n******************************************************************************\n*/\n{\n  int kwarn = 0;      \t /* Local staus variable(warning).                  */\n  double derive[30];     /* Array containing the computed derivatives.      */\n  double normal[3];      /* Array containing the computed normalvektor.     */\n  double fundform[10];   /* The coefficients of the fundamental forms.\n\t\t\t    The sequence is: E, F, G, e, f, g, P, Q, S, T.  */\n  double d1, d2;         /* The normalised parameter direction\n\t\t\t    (parvalue[2],parvalue[3]) and their length      */\n  double temp1, temp2;   /* Temporary values\t\t\t\t    */\n  double length;         /* Square of normal length.                        */\n  double a, b, c, d;     /* Utility coefficients.                           */\n  double sigma;          /* Utility coefficient.                            */\n  double alpha;          /* Utility coefficient.                            */\n  double beta;           /* Utility coefficient.                            */\n  double gamma;          /* Utility coefficient.                            */\n  double delta;          /* Utility coefficient.                            */\n  double epsilon;        /* Utility coefficient.                            */\n  double mu;             /* Utility coefficient.                            */\n  double P, Q, S, T;     /* Third order coefficients.                       */\n  double D;              /* Utility coefficient.                            */\n  double H;              /* The mean curvature.                             */\n  double K;              /* The Gaussian curvature.                         */\n  double k1;             /* Max. principal curvature.                       */\n  double k2;             /* Min. principal curvature.                       */\n  double theta;          /* Angle in the tangent plane.                     */\n  double phi;            /* Angle in the tangent plane.                     */\n  double psi;            /* Angle in the tangent plane.                     */\n  double tanglenA;       /* Length of tangentA.                             */\n  double tanglenB;       /* Length of tangentB.                             */\n  double asin_result;    /* Result of asin.                                 */\n  double sin_contrib;    /* Contribution from sinus.                        */\n  double cos_contrib;    /* Contribution form cosinus.                      */\n  double max_dir[2];     /* Max. direction of the principal curvature k1.   */\n  double min_dir[2];     /* Min. direction of the principal curvature k2.   */\n  double tangentA[3];    /* Tangent to the surface.                         */\n  double tangentB[3];    /* Tangent to the surface.                         */\n  double cross[3];       /* Cross product vector.                           */\n  /* ______________________________________________________________________ */\n  \n\n  if (ider < 0 || ider > 1) goto err178;\n  \n  length = sqrt(parvalue[2]*parvalue[2] + parvalue[3]*parvalue[3]);\n  if (length < REL_PAR_RES) goto err174;\n  d1 = parvalue[2]/length;\n  d2 = parvalue[3]/length;\n\n\n  if (surf == SISL_NULL)  goto err150;\n  else\n  {\n    /* Compute derivates and normal. */\n\n    s1422(surf, ider+2, iside1, iside2, parvalue, leftknot1, leftknot2, derive,\n\t  normal, jstat);\n    if (*jstat > 0) kwarn = *jstat;\n\n    if (*jstat < 0) /* Error in lower level routine. */\n    {\n      goto error;\n    }\n    else if (*jstat != 2) /* The surface is not degenerate */\n    {\n       /* Find factors in fundamental form */\n       s2513(surf, 0, ider+2, 1, derive, normal, fundform, jstat);\n       \n       if (*jstat < 0)\n\t  goto error;\n       \n       temp1    = fundform[0]*d1*d1 + 2*fundform[1]*d1*d2 + fundform[2]*d2*d2;\n       if (temp1 < REL_PAR_RES) goto err174;\n       temp2    = fundform[3]*d1*d1 + 2*fundform[4]*d1*d2 + fundform[5]*d2*d2;\n       \n       norcurv[0] = temp2/temp1;\n       \n       if (ider > 0)\n       {\n\t  \n\t  /* Calculate the derivative of the normal curvature. */\n\t  \n\t  if (surf->idim == 3)\n\t     length = normal[0]*normal[0] + normal[1]*normal[1] +\n\t\tnormal[2]*normal[2];\n\t  else if (surf->idim == 1)\n\t     length = 1. + derive[1]*derive[1] + derive[2]*derive[2];\n\t  sigma = sqrt(length);\n\t  \n\t  /* Find the coefficients in the expression. */\n\t  \n\t  alpha   = s6scpr(&derive[3*(surf->idim)], &derive[surf->idim],\n\t\t\t   surf->idim)/length;\n\t  beta    = s6scpr(&derive[3*(surf->idim)], &derive[2*(surf->idim)],\n\t\t\t   surf->idim)/length;\n\t  gamma   = s6scpr(&derive[4*(surf->idim)], &derive[surf->idim],\n\t\t\t   surf->idim)/length;\n\t  delta   = s6scpr(&derive[4*(surf->idim)], &derive[2*(surf->idim)],\n\t\t\t   surf->idim)/length;\n\t  epsilon = s6scpr(&derive[5*(surf->idim)], &derive[surf->idim],\n\t\t\t   surf->idim)/length;\n\t  mu      = s6scpr(&derive[5*(surf->idim)], &derive[2*(surf->idim)],\n\t\t\t   surf->idim)/length;\n\t  \n\t  a = fundform[1]*fundform[4] - fundform[2]*fundform[3];\n\t  b = fundform[1]*fundform[3] - fundform[0]*fundform[4];\n\t  c = fundform[1]*fundform[5] - fundform[2]*fundform[4];\n\t  d = fundform[1]*fundform[4] - fundform[0]*fundform[5];\n\t  \n\t  P = fundform[6] + 3*(a*alpha + b*beta);\n\t  Q = fundform[7] + c*alpha + d*beta + 2*a*gamma + 2*b*delta;\n\t  S = fundform[8] + 2*c*gamma + 2*d*delta + a*epsilon + b*mu;\n\t  T = fundform[9] + 3*(c*epsilon + d*mu);\n\t  \n\t  /* Calculate the principal curvatures. */\n\t  \n\t  s2543(surf, 0, derive, normal, &k1, &k2, max_dir, min_dir, jstat);\n\t  \n\t  if (*jstat < 0)\n\t     goto error;\n\t  \n\t  H = (k1 + k2)/2.;\n\t  K = k1*k2;\n\t  \n\t  D = sqrt(H*H - K);\n\t  if (fabs(D) < REL_PAR_RES)\n\t  {\n\t     /* Umbilical point, derivative is zero. */\n\t     \n\t     norcurv[1] = 0.;\n\t     goto out;\n\t  }\n\t  \n\t  /* Calculate the angles theta, phi and psi. */\n\t  \n\t  if (surf->idim == 3)\n\t  {\n\t     tangentA[0] = max_dir[0]*derive[3] + max_dir[1]*derive[6];\n\t     tangentA[1] = max_dir[0]*derive[4] + max_dir[1]*derive[7];\n\t     tangentA[2] = max_dir[0]*derive[5] + max_dir[1]*derive[8];\n\t     tangentB[0] = parvalue[2]*derive[3] + parvalue[3]*derive[6];\n\t     tangentB[1] = parvalue[2]*derive[4] + parvalue[3]*derive[7];\n\t     tangentB[2] = parvalue[2]*derive[5] + parvalue[3]*derive[8];\n\t  }\n\t  else\n\t  {\n\t     tangentA[0] = max_dir[0];\n\t     tangentA[1] = max_dir[1];\n\t     tangentA[2] = max_dir[0]*derive[1] + max_dir[1]*derive[2];\n\t     tangentB[0] = parvalue[2];\n\t     tangentB[1] = parvalue[3];\n\t     tangentB[2] = parvalue[2]*derive[1] + parvalue[3]*derive[2];\n\t  }\n\t  \n\t  tanglenA = s6length(tangentA, 3, jstat);\n\t  if (*jstat < 0)\n\t     goto error;\n\t  tanglenB = s6length(tangentB, 3, jstat);\n\t  if (*jstat < 0)\n\t     goto error;\n\n\t  theta = acos(max(-1., min(1., s6scpr(tangentA, tangentB, 3)/\n\t\t\t\t     (tanglenA*tanglenB))));\n\t  \n\t  /* Check rotational direction. */\n\t  \n\t  s6crss(normal, tangentA, cross);\n\t  if (s6scpr(cross, tangentB, 3) < 0.)\n\t     theta = TWOPI - theta;\n\t  \n\t  /* Calculate phi. */\n\n\t  phi = acos(max(-1., min(1., (fundform[5] - H*fundform[2])/\n\t\t\t\t   (fundform[2]*D))));\n\t  asin_result = asin(max(-1.,min(1., (fundform[4]*fundform[2] - \n\t\t\tfundform[5]*fundform[1])/(sigma*fundform[2]*D))));\n\t  if (asin_result < 0)\n\t     phi = TWOPI - phi;\n\t  if (fabs(phi - asin_result) > ANGULAR_TOLERANCE &&\n\t      fabs(PI - phi - asin_result) > ANGULAR_TOLERANCE &&\n\t      fabs(phi - TWOPI - asin_result) > ANGULAR_TOLERANCE)\n\t     goto err180;\n\n\t  phi /= 2.;\n\t  \n\t  /* Calculate psi. */\n\n          psi = acos(max(-1., min(1., sigma/sqrt(fundform[0]*fundform[2]))));\n          asin_result = asin(max(-1.,min(1., fundform[1]/\n\t\t\t\t\t sqrt(fundform[0]*fundform[2]))));\n\t  if (asin_result < 0)\n\t     psi = TWOPI - psi;\n\t  if (fabs(psi - asin_result) > ANGULAR_TOLERANCE &&\n\t      fabs(PI - psi - asin_result) > ANGULAR_TOLERANCE &&\n\t      fabs(psi - TWOPI - asin_result) > ANGULAR_TOLERANCE)\n\t     goto err180;\n\t  \n\t  /* Calculate the derivative. */\n\t  \n\t  sin_contrib = sin(theta + phi);\n\t  cos_contrib = cos(theta + phi + psi);\n\t  \n\t  norcurv[1] = (P*sqrt(fundform[2]*fundform[2]*fundform[2])*\n\t\t\tsin_contrib*sin_contrib*sin_contrib\n\t\t\t+ 3*Q*fundform[2]*sqrt(fundform[0])*cos_contrib*\n\t\t\tsin_contrib*sin_contrib\n\t\t\t+ 3*S*sqrt(fundform[2])*fundform[0]*cos_contrib*\n\t\t\tcos_contrib*sin_contrib\n\t\t\t+ T*sqrt(fundform[0]*fundform[0]*fundform[0])*\n\t\t\tcos_contrib*cos_contrib*cos_contrib)/(sigma*length);\n       }\n       \n    }\n    else if (*jstat == 2) /* The surface is degenerated. */\n    {\n      norcurv[0] = 0.0;\n      goto war002;\n    }\n\n  }\n\n\n  /* Successful computations  */\n\n  *jstat = kwarn;\n  goto out;\n\n\n  /* ____________________________________________________________________ */\n  /*                           ERROR EXIT\t\t\t\t  */\n  /* ____________________________________________________________________ */\n  \n   /* The surface is degenerated at (u,v) */\nwar002:\n  *jstat = 2;\n  goto out;\n\n  /* Error. Input (surface) pointer is SISL_NULL. */\nerr150:\n  *jstat = -150;\n  s6err(\"s2544\", *jstat, 0);\n  goto out;\n\n  /* Degenerate condition. */\nerr174:\n  *jstat = -174;\n  s6err(\"s2544\",*jstat,0);\n  goto out;\n  \n  /* Illegal derivative requested. */\nerr178:\n  *jstat = -178;\n  s6err(\"s2544\",*jstat,0);\n  goto out;\n\n  /* Problems in angle calculation. */\nerr180:\n  *jstat = -180;\n  s6err(\"s2544\",*jstat,0);\n  goto out;\n  \n  /* Error in lower level routine.  */\nerror:\n  s6err(\"s2544\",*jstat,0);\n  goto out;\n\n\n  /* ____________________________________________________________________ */\n  /*                        THE ONE AND ONLY EXIT\t\t\t  */\n  /* ____________________________________________________________________ */\nout:\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s2545.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s2545.c,v 1.8 2001-06-12 11:07:34 jbt Exp $\n *\n */\n\n#define S2545\n\n#include \"sislP.h\"\n\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2545(SISLSurf *surf, int curvature_type, int export_par_val, int pick_subpart,\n      double boundary[], int n_u, int n_v, double scale,\n      double **garr, int *stat)\n#else\nvoid\ns2545(surf, curvature_type, export_par_val, pick_subpart, boundary, n_u, n_v,\n      scale, garr, stat)\n     SISLSurf *surf;\n     int curvature_type;\n     int export_par_val;\n     int pick_subpart;\n     double boundary[];\n     int n_u;\n     int n_v;\n     double scale;\n     double **garr;\n     int *stat;\n#endif\n/*\n***************************************************************************\n*\n***************************************************************************\n* PURPOSE : To compute a set of focal values on an uniform grid\n*           in a selected subset of the parameter domain for a\n*           NURBS surface. The focal value is a surface position offseted\n*           with the surface curvature.\n*\n*\n* INPUT   : surf  \t   - The surface to evaluate.\n*\t    curvature_type - The type of curvature:\n*                            0 - Gaussian.\n*                            1 - Mean.\n*                            2 - Absolute.\n*                            3 - Total.\n*                            4 - second order Mehlum (curvature).\n*                            5 - third order Mehlum (variation of curvature).\n*\t    export_par_val - Flag telling if the parameter values for each grid\n*                            point is to be exported:\n*                            0 - False, do not export parameter values,\n*                            1 - True, do export parameter values.\n*           pick_subpart   - Flag teliing if the grid is to be calculated on a\n*                            subpart of the surface:\n*                            0 - False, calculate grid on the complete surface,\n*                            1 - True, calculate grid on a part of the surface.\n*           boundary       - A rectangular subset of the parameter domain.\n*              \t             [0] - Min value 1. parameter direction.\n*                            [1] - Min value 2. parameter direction.\n*                            [2] - Max value 1. parameter direction.\n*                            [3] - Max value 2. parameter direction.\n*                            ONLY USED WHEN pick_subpart = 1. If pick_subpart\n*                            = 0, the parameter area of surf is given out here.\n*           n_u            - Number of segments in 1. parameter direction.\n*           n_v            - Number of segments in 2. parameter direction.\n*           scale          - Scaling factor.\n*\n*\n*\n* OUTPUT  : garr  \t   - Array containing the computed values on the grid.\n*\t\t             The allocation is done internally and the dimension\n*\t\t\t     is  (dim+2)*(n_u+1)*(n_v+1) if export_par_val is\n*                            true, and dim*(n_u+1)*(n_v+1) if export_par_val is\n*                            false.\n*                            Each gridpoint consist of dim+2 values\n*                            (Ui,Vj,x(Ui,Vj),...) or only the\n*                            focal points (x(Ui,Vj),....).\n*\t\t\t     The sequence is running first in the\n*                            1. parameter direction.\n**\n*           stat           - Status message.\n*                               > 0      : Warning.\n*                               = 0      : Ok.\n*                               < 0      : Error.\n*\n*\n* METHOD  :\n*\n*\n* CALLS   :s2540(),s1421(),s6norm()\n*\n* WRITTEN BY :  Johannes Kaasa,  SINTEF, Oslo, Norway, Sep. 1995.\n*\n*********************************************************************\n*/\n{\n   int ki, kj, kl;        /* Indices in for loops.            */\n   int idx1, idx2;        /* Array indices.                   */\n   int incr;              /* Increment in the 3D array.       */\n   int leftknot1;         /* Pointer into knot array.         */\n   int leftknot2;         /* Pointer into knot array.         */\n   double length;         /* Length of normal.                */\n   double par[2];         /* Parameter values.                */\n   double derive[9];      /* Surface evaluation.              */\n   double normal[3];      /* Surface normal.                  */\n   double Nnormal[3];     /* Normalized normal.               */\n   double *offset = SISL_NULL; /* Offset distances.                */\n\n\n   /* Generate the scalar valued curvature grid with parameter values. */\n\n   s2540(surf, curvature_type, 1, pick_subpart, boundary, n_u, n_v,\n\t &offset, stat);\n   if (*stat < 0) goto error;\n\n   /* Allocate the output. */\n\n   incr = (export_par_val? (surf->idim + 2) : surf->idim);\n\n   if (((*garr) = newarray(incr*(n_u + 1)*(n_v + 1), double)) == SISL_NULL)\n      goto err101;\n\n   /* Generate the focal points. */\n\n   idx1 = 0;\n   idx2 = 0;\n   for (ki = 0; ki < (n_v + 1); ki++)\n   {\n      par[1] = offset[idx1 + 1];\n\n      for (kj = 0; kj < (n_u + 1); kj++)\n      {\n\t par[0] = offset[idx1];\n\n\t if (export_par_val)\n\t {\n\t    (*garr)[idx2] = par[0];\n\t    idx2++;\n\t    (*garr)[idx2] = par[1];\n\t    idx2++;\n\t }\n\n\t /* Calculate the normal. */\n\n\t s1421(surf, 1, par, &leftknot1, &leftknot2, derive, normal, stat);\n\t if (*stat < 0) goto error;\n\n\t /* Calculate the point. */\n\n\t if (surf->idim == 1)\n\t {\n\t    (*garr)[idx2] = derive[0] + scale*offset[idx1 + 2];\n\t    idx2 += 1;\n\t }\n\t else if (surf->idim == 2)\n\t {\n\t    (*garr)[idx2] = scale*offset[idx1 + 2];\n\t    idx2 += 1;\n\t }\n\t else if (surf->idim == 3)\n\t {\n\t    length = s6norm(normal, 3, Nnormal, stat);\n\t    if (*stat < 0) goto error;\n\t    for (kl = 0; kl < 3; kl++)\n\t       (*garr)[idx2 + kl] = derive[kl]\n\t\t  + scale*offset[idx1 + 2]*Nnormal[kl];\n\t    idx2 += 3;\n\t }\n\n\t idx1 += 3;\n      }\n   }\n\n\n  *stat = 0;\n  goto out;\n\n  /* ___________________________________________________________________ */\n  /*                         ERROR EXITS                                 */\n  /* ___________________________________________________________________ */\n\n  /* Error in space allocation. */\nerr101:\n  *stat = -101;\n  s6err(\"s2545\", *stat, 0);\n  goto out;\n\n  /* Error in lower level routine. */\nerror:\n  s6err(\"s2545\", *stat, 0);\n  goto out;\n\n  /* ___________________________________________________________________ */\n  /*                         THE ONE AND ONLY EXIT                       */\n  /* ___________________________________________________________________ */\n\nout:\n   if (offset) freearray(offset);\n  return;\n\n}\n"
  },
  {
    "path": "src/s2550.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n\n#define S2550\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2550( SISLCurve *curve,\n       double     ax[],\n       int        num_ax,\n       double     curvature[],\n       int       *jstat )\n#else\nvoid s2550( curve, ax, num_ax, curvature, jstat )\n     SISLCurve  *curve;\n     double      ax[];\n     int         num_ax;\n     double      curvature[];\n     int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate the curvature of a curve at given parameter values\n*              ax[ 0 ],...,ax[ num_ax - 1 ].\n*\n*\n*\n* INPUT      : curve    - Pointer to the curve.\n*              ax       - The parameter values\n*          num_ax       - No. of parameter values\n*\n*\n*\n*\n* OUTPUT     :\n*              curvature - The \"num_ax\" curvature values computed\n*              jstat  - Status messages\n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : Call the SISL rutine s2551() num_ax times\n*\n* REFERENCES :\n*\n*\n* CALLS      : s2551()\n*\n* WRITTEN BY  :   Geir Westgaard, SINTEF, Oslo, November 1999\n* MODIFIED BY :\n* REVISED BY  :\n*\n*********************************************************************\n*/\n{\n  int i;                      /* Index variable                      */\n  int kstat = 0;              /* local status variable               */\n  int kpos = 0;               /* local error position                */\n  int leftknot = 0;           /* Knot index                          */\n  double *derive = SISL_NULL;      /* Derivatives                         */\n\n\n\n  /* Allocate local arrays */\n\n  derive = newarray( 3*curve->idim, DOUBLE );\n\n  if ( derive == SISL_NULL )      goto err101;\n\n\n  /* Evaluate the curvature in all ax[i] position */\n\n  for ( i = 0; i < num_ax; i++ )\n  {\n    s2551( curve, ax[i], &leftknot, derive, curvature + i, &kstat );\n\n    if ( kstat < 0 ) goto error;\n  }\n\n\n\n\n /* Successful computations.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation */\n err101:\n  *jstat = -101;\n  s6err( \"s2550\",*jstat,kpos);\n\n  /* Error in lower level routine.  */\n\n error:  *jstat = kstat;\n  s6err( \"s2550\", *jstat, kpos );\n  goto out;\n\n\n out:\n  /* Free local arrays */\n\n if ( derive != SISL_NULL ) freearray( derive );\n\n return;\n\n}\n"
  },
  {
    "path": "src/s2551.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n\n#define S2551\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2551( SISLCurve *curve,\n       double     parvalue,\n       int       *leftknot,\n       double     derive[],\n       double    *curvature,\n       int       *jstat )\n#else\nvoid s2551( curve, parvalue, leftknot, derive, curvature, jstat )\n     SISLCurve  *curve;\n     double      parvalue;\n     int        *leftknot;\n     double      derive[];\n     double     *curvature;\n     int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate the curvature of a curve at a given parameter value,\n*              from the right hand side.\n*\n*\n*\n* INPUT      : curve    - Pointer to the curve.\n*              parvalue - The parameter value at which to compute\n*                         curvature.\n*\n*\n*\n* INPUT/OUTPUT : leftknot - Pointer to the interval in the knot vector\n*                        where ax is located. If et is the knot vector,\n*                        the relation\n*\n*                          et[ileft] < parvalue <= et[ileft+1]\n*\n*                        should hold. (If parvalue == et[ik-1] then ileft\n*                        should be ik-1. Here in is the number of B-spline\n*                        coefficients.)\n*                        If ileft does not have the right value upon\n*                        entry to the routine, its value will be changed\n*                        to the value satisfying the above condition.\n*\n*\n*\n* OUTPUT     : derive   - Double array of dimension [(ider+1)*idim]\n*                       containing the position and derivative vectors.\n*                       (idim is the number of components of each B-spline\n*                       coefficient, i.e. the dimension of the Euclidean\n*                       space in which the curve lies.)\n*                       These vectors are stored in the following order:\n*                       First the idim components of the position vector,\n*                       then the idim components of the tangent vector,\n*                       then the idim components of the second derivative\n*                       vector, and so on.\n*                       (The C declaration of eder as a two dimensional array\n*                       would therefore be eder[ider+1,idim].)\n*              curvature - The curvature value computed\n*              jstat  - Status messages\n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : The derivatives are evaluated from the right hand\n*              side by  s1221\n*              The curvature are evaluated by s1307\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1221, s1307\n*\n* WRITTEN BY  :   Geir Westgaard, SINTEF, Oslo, November 1999\n* MODIFIED BY :\n* REVISED BY  :\n*\n*********************************************************************\n*/\n{\n  int kdim = curve -> idim;   /* copy curve attribute to local parameter  */\n  int kstat = 0;              /* local status variable                    */\n  int kpos = 0;               /* local error position                     */\n  double *egeo = SISL_NULL;        /* pointer to store pos, tangent vector,\n\t\t\t\t curvature vector and radius of curvature */\n\n\n\n  /* Allocate local arrays */\n\n  egeo = newarray( 3*kdim+1, DOUBLE );\n\n  if ( egeo == SISL_NULL )      goto err101;\n\n\n  /* Evaluate the derivatives */\n\n  s1221( curve, 2, parvalue, leftknot, derive, &kstat );\n\n  if ( kstat < 0 ) goto error;\n\n\n  /* Evaluate the curvature vector and the radius_of_curvature */\n\n  s1307( derive, kdim, egeo, &kstat );\n\n  if ( kstat < 0 ) goto error;\n\n\n  /* Evaluate curvature */\n\n  *curvature = s6length( egeo+2*kdim, kdim, &kstat );\n\n\n\n\n /* Successful computations.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation */\n err101:\n  *jstat = -101;\n  s6err( \"s2551\",*jstat,kpos);\n\n  /* Error in lower level routine.  */\n\n error:  *jstat = kstat;\n  s6err( \"s2551\", *jstat, kpos );\n  goto out;\n\n\n out:\n  /* Free local arrays */\n\n if ( egeo != SISL_NULL ) freearray( egeo );\n\n return;\n\n}\n"
  },
  {
    "path": "src/s2553.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n\n#define S2553\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2553( SISLCurve *curve,\n       double     ax[],\n       int        num_ax,\n       double     torsion[],\n       int       *jstat )\n#else\nvoid s2553( curve, ax, num_ax, torsion, jstat )\n     SISLCurve  *curve;\n     double      ax[];\n     int         num_ax;\n     double      torsion[];\n     int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate the torsion of a curve at given parameter values\n*              ax[ 0 ],...,ax[ num_ax - 1 ].\n*\n*\n*\n* INPUT      : curve    - Pointer to the curve.\n*              ax       - The parameter values\n*          num_ax       - No. of parameter values\n*\n*\n*\n*\n* OUTPUT     :\n*             torsion - The \"num_ax\" torsion values computed\n*              jstat  - Status messages\n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : Call the SISL rutine s2554() num_ax times\n*\n* REFERENCES :\n*\n*\n* CALLS      : s2554()\n*\n* WRITTEN BY  :   Geir Westgaard, SINTEF, Oslo, November 1999\n* MODIFIED BY :\n* REVISED BY  :\n*\n*********************************************************************\n*/\n{\n  int i;                      /* Index variable                      */\n  int kstat = 0;              /* local status variable               */\n  int kpos = 0;               /* local error position                */\n  int leftknot = 0;           /* Knot index                          */\n  double *derive = SISL_NULL;      /* Derivatives                         */\n\n\n\n  /* Allocate local arrays */\n\n  derive = newarray( 4*curve->idim, DOUBLE );\n\n  if ( derive == SISL_NULL )      goto err101;\n\n\n  /* Evaluate the torsion in all ax[i] positions. */\n\n  for ( i = 0; i < num_ax; i++ )\n  {\n    s2554( curve, ax[i], &leftknot, derive, torsion + i, &kstat );\n\n    if ( kstat < 0 ) goto error;\n  }\n\n\n\n\n /* Successful computations.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation */\n err101:\n  *jstat = -101;\n  s6err( \"s2553\",*jstat,kpos);\n\n  /* Error in lower level routine.  */\n\n error:  *jstat = kstat;\n  s6err( \"s2553\", *jstat, kpos );\n  goto out;\n\n\n out:\n  /* Free local arrays */\n\n if ( derive != SISL_NULL ) freearray( derive );\n\n return;\n\n}\n"
  },
  {
    "path": "src/s2554.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n\n#define S2554\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2554( SISLCurve *curve,\n       double     parvalue,\n       int       *leftknot,\n       double     derive[],\n       double    *torsion,\n       int       *jstat )\n#else\nvoid s2554( curve, parvalue, leftknot, derive, torsion, jstat )\n     SISLCurve  *curve;\n     double      parvalue;\n     int        *leftknot;\n     double      derive[];\n     double     *torsion;\n     int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate the torsion of a curve at a given parameter value,\n*              from the right hand side.\n*\n*\n*\n* INPUT      : curve    - Pointer to the curve.\n*              parvalue - The parameter value at which to compute\n*                         torsion.\n*\n*\n*\n* INPUT/OUTPUT : leftknot - Pointer to the interval in the knot vector\n*                        where ax is located. If et is the knot vector,\n*                        the relation\n*\n*                          et[ileft] < parvalue <= et[ileft+1]\n*\n*                        should hold. (If parvalue == et[ik-1] then ileft\n*                        should be ik-1. Here in is the number of B-spline\n*                        coefficients.)\n*                        If ileft does not have the right value upon\n*                        entry to the routine, its value will be changed\n*                        to the value satisfying the above condition.\n*\n*\n*\n* OUTPUT     : derive   - Double array of dimension [4*idim]\n*                       containing the position and derivative vectors.\n*                       (idim is the number of components of each B-spline\n*                       coefficient, i.e. the dimension of the Euclidean\n*                       space in which the curve lies.)\n*                       These vectors are stored in the following order:\n*                       First the idim components of the position vector,\n*                       then the idim components of the tangent vector,\n*                       then the idim components of the second derivative\n*                       vector, and so on.\n*              torsion - The torsion value computed\n*              jstat  - Status messages\n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : The derivatives are evaluated from the right hand\n*              side by  s1221(), and the torsion are evaluated by s2555()\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1221(), s2555()\n*\n* WRITTEN BY  :   Geir Westgaard, SINTEF, Oslo, November 1999\n* MODIFIED BY :\n* REVISED BY  :\n*\n*********************************************************************\n*/\n{\n  int kdim = curve -> idim;   /* copy curve attribute to local parameter  */\n  int kstat = 0;              /* local status variable                    */\n  int kpos = 0;               /* local error position                     */\n\n\n  /* Check input */\n\n  if ( kdim != 3 )\n  {\n    *torsion = 0.0;\n    goto out;\n  }\n\n\n\n  /* Evaluate the derivatives */\n\n  s1221( curve, 3, parvalue, leftknot, derive, &kstat );\n\n  if ( kstat < 0 ) goto error;\n\n\n  /* Evaluate the torsion based on the derivatives in \"derive\" */\n\n  s2555( derive, torsion, &kstat );\n\n  if ( kstat < 0 ) goto error;\n\n\n\n /* Successful computations.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n error:  *jstat = kstat;\n  s6err( \"s2554\", *jstat, kpos );\n  goto out;\n\n\n out:\n return;\n\n}\n"
  },
  {
    "path": "src/s2555.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n\n\n#define S2555\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2555( double     derive[],\n       double    *torsion,\n       int       *jstat )\n#else\nvoid s2555( derive, torsion, jstat )\n     double      derive[];\n     double     *torsion;\n     int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate the torsion of a curve based on the\n*              derivatives in \"derive\". We assume that the\n*              curve lies in IR^3.\n*\n*\n* INPUT      :\n*            derive   - Double array of dimension [4*3]\n*                       containing the position and derivative vectors.\n*                       These vectors are stored in the following order:\n*                       First the position vector, then the tangent vector,\n*                       then the 3 components of the second derivative\n*                       vector, and so on.\n*\n*\n* OUTPUT     : torsion - The torsion value computed\n*              jstat  - Status messages\n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : See formula in the book of Do Carmo\n*              (Differential Geometry of Curves and Surfaces).\n*\n* REFERENCES : Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*\n*\n* CALLS       : s6length(), s6scpr()\n*\n* WRITTEN BY  :   Geir Westgaard, SINTEF, Oslo, November 1999\n* MODIFIED BY :\n* REVISED BY  :\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;        /* Local status variable       */\n  double crpr[3], a;    /* Temp. variable.             */\n\n\n  /* Evaluate torsion */\n\n  s6crss( derive + 3, derive + 6, crpr );\n\n  a = s6length( crpr, 3, &kstat );\n\n  if ( a != 0.0 )\n    {\n      *torsion = ( s6scpr( derive + 9, crpr, 3 ) ) / ( a*a ) ;\n    }\n  else\n    {\n      *torsion = 0.0;\n\n      goto war002;\n    }\n\n\n\n /* Successful computations.  */\n\n  *jstat = 0;\n  goto out;\n\n\n  /* Torsion undefined, since the curvature = 0.0.  */\nwar002:\n  *jstat = 2;\n  goto out;\n\n\n out:\n\n return;\n\n}\n"
  },
  {
    "path": "src/s2556.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n\n#define S2556\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2556( SISLCurve *curve,\n       double     ax[],\n       int        num_ax,\n       double     VoC[],\n       int       *jstat )\n#else\nvoid s2556( curve, ax, num_ax, VoC, jstat )\n     SISLCurve  *curve;\n     double      ax[];\n     int         num_ax;\n     double      VoC[];\n     int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate the Variation of Curvature (VoC) of a curve\n*              at given parameter values ax[ 0 ],...,ax[ num_ax - 1 ].\n*\n*\n*\n* INPUT      : curve    - Pointer to the curve.\n*              ax       - The parameter values\n*          num_ax       - No. of parameter values\n*\n*\n*\n*\n* OUTPUT     :\n*           VoC - The \"num_ax\" Variation of Curvature (VoC) values computed\n*        jstat  - Status messages\n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : Call the SISL rutine s2557() num_ax times\n*\n* REFERENCES :\n*\n*\n* CALLS      : s2557()\n*\n* WRITTEN BY  :   Geir Westgaard, SINTEF, Oslo, November 1999\n* MODIFIED BY :\n* REVISED BY  :\n*\n*********************************************************************\n*/\n{\n  int i;                      /* Index variable                      */\n  int kstat = 0;              /* local status variable               */\n  int kpos = 0;               /* local error position                */\n  int leftknot = 0;           /* Knot index                          */\n  double *derive = SISL_NULL;      /* Derivatives                         */\n\n\n\n  /* Allocate local arrays */\n\n  derive = newarray( 4*curve->idim, DOUBLE );\n\n  if ( derive == SISL_NULL )      goto err101;\n\n\n  /* Evaluate the VoC in all ax[i] positions. */\n\n  for ( i = 0; i < num_ax; i++ )\n  {\n    s2557( curve, ax[i], &leftknot, derive, VoC + i, &kstat );\n\n    if ( kstat < 0 ) goto error;\n  }\n\n\n\n\n /* Successful computations.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation */\n err101:\n  *jstat = -101;\n  s6err( \"s2556\", *jstat, kpos );\n\n  /* Error in lower level routine.  */\n\n error:  *jstat = kstat;\n  s6err( \"s2556\", *jstat, kpos );\n  goto out;\n\n\n out:\n  /* Free local arrays */\n\n if ( derive != SISL_NULL ) freearray( derive );\n\n return;\n\n}\n"
  },
  {
    "path": "src/s2557.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n\n#define S2557\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2557( SISLCurve *curve,\n       double     parvalue,\n       int       *leftknot,\n       double     derive[],\n       double    *VoC,\n       int       *jstat )\n#else\nvoid s2557( curve, parvalue, leftknot, derive, VoC, jstat )\n     SISLCurve  *curve;\n     double      parvalue;\n     int        *leftknot;\n     double      derive[];\n     double     *VoC;\n     int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate the Variation of Curvature (VoC) of a curve\n*              at a given parameter value, from the right hand side.\n*\n*\n*\n* INPUT      : curve    - Pointer to the curve.\n*              parvalue - The parameter value at which to compute\n*                         VoC.\n*\n*\n*\n* INPUT/OUTPUT : leftknot - Pointer to the interval in the knot vector\n*                        where ax is located. If et is the knot vector,\n*                        the relation\n*\n*                          et[ileft] < parvalue <= et[ileft+1]\n*\n*                        should hold. (If parvalue == et[ik-1] then ileft\n*                        should be ik-1. Here in is the number of B-spline\n*                        coefficients.)\n*                        If ileft does not have the right value upon\n*                        entry to the routine, its value will be changed\n*                        to the value satisfying the above condition.\n*\n*\n*\n* OUTPUT     : derive   - Double array of dimension [4*idim]\n*                       containing the position and derivative vectors.\n*                       (idim is the number of components of each B-spline\n*                       coefficient, i.e. the dimension of the Euclidean\n*                       space in which the curve lies.)\n*                       These vectors are stored in the following order:\n*                       First the idim components of the position vector,\n*                       then the idim components of the tangent vector,\n*                       then the idim components of the second derivative\n*                       vector, and so on.\n*              VoC - The Variation of Curvature (VoC) value computed\n*              jstat  - Status messages\n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : The derivatives are evaluated from the right hand\n*              side by  s1221(), and the VoC are evaluated by s2558()\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1221(), s2558()\n*\n* WRITTEN BY  :   Geir Westgaard, SINTEF, Oslo, November 1999\n* MODIFIED BY :\n* REVISED BY  :\n*\n*********************************************************************\n*/\n{\n  int kdim = curve -> idim;   /* copy curve attribute to local parameter  */\n  int kstat = 0;              /* local status variable                    */\n  int kpos = 0;               /* local error position                     */\n\n\n\n\n\n  /* Evaluate the derivatives */\n\n  s1221( curve, 3, parvalue, leftknot, derive, &kstat );\n\n  if ( kstat < 0 ) goto error;\n\n\n  /* Evaluate the VoC based on the derivatives in \"derive\" */\n\n  s2558( derive, kdim, VoC, &kstat );\n\n  if ( kstat < 0 ) goto error;\n\n\n\n /* Successful computations.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n error:  *jstat = kstat;\n  s6err( \"s2557\", *jstat, kpos );\n  goto out;\n\n\n out:\n return;\n\n}\n"
  },
  {
    "path": "src/s2558.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n\n\n#define S2558\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2558( double     derive[],\n       int        idim,\n       double    *VoC,\n       int       *jstat )\n#else\nvoid s2558( derive, idim, VoC, jstat )\n     double      derive[];\n     int         idim;\n     double     *VoC;\n     int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate the Variation of Curvature (VoC) of a curve\n*              based on the derivatives in \"derive\". We assume that\n*              the curve lies in R, R^2 or R^3.\n*\n*\n* INPUT      :\n*            derive   - Double array of dimension [4*idim]\n*                       containing the position and derivative vectors.\n*                       These vectors are stored in the following order:\n*                       First the position vector, then the tangent vector,\n*                       then the idim components of the second derivative\n*                       vector, and so on.\n*\n*\n* OUTPUT     : VoC    - The Variation of Curvature (VoC) value computed\n*              jstat  - Status messages\n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : See formula in given in the reference.\n*\n*\n* REFERENCES :   Westgaard G., Heimann J.:\n*                Analysis and Visualization of Geometric Curve Properties,\n*                in M. D{\\ae}hlen, T. Lyche and L. L. Schumaker (Eds.)\n*                Mathematical Methods in CAGD IV, 1998.\n*\n*\n*\n* CALLS       : s6length(), s6scpr(), s6crss()\n*\n* WRITTEN BY  :   Geir Westgaard, SINTEF, Oslo, November 1999\n* MODIFIED BY :\n* REVISED BY  :\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;                         /* Local status variable       */\n\n  double a, atimes2, atimes4, a1dota2;   /* Temp. variable.             */\n  double crpr12[3];          \t\t /* Temp. variable.             */\n  double crpr13[3];   \t\t\t /* Temp. variable.             */\n  double crpr13dotcrpr12, normcrpr12;    /* Temp. variable.             */\n  double D[15];   \t\t\t /* Derivatives on canonical\n\t\t\t\t\t    R^3 form                    */\n\n\n  /* Put the derivatives on canonical R^3 form */\n\n  if ( idim == 1 )\n  {\n      D[0]  = 0.0;   D[1] = derive[0];  D[2]  = 0.0;\n      D[3]  = 1.0;   D[4] = derive[1];  D[5]  = 0.0;\n      D[6]  = 0.0;   D[7] = derive[2];  D[8]  = 0.0;\n      D[9]  = 0.0;  D[10] = derive[3];  D[11] = 0.0;\n      D[12] = 0.0;  D[13] = derive[4];  D[14] = 0.0;\n  }\n  else if ( idim == 2 )\n  {\n      D[0]  = derive[0];   D[1] = derive[1];   D[2]  = 0.0;\n      D[3]  = derive[2];   D[4] = derive[3];   D[5]  = 0.0;\n      D[6]  = derive[4];   D[7] = derive[5];   D[8]  = 0.0;\n      D[9]  = derive[6];  D[10] = derive[7];   D[11] = 0.0;\n      D[12] = derive[8];  D[13] = derive[9];   D[14] = 0.0;\n  }\n  else\n  {\n      D[0]  = derive[0];   D[1] = derive[1];   D[2]  = derive[2];\n      D[3]  = derive[3];   D[4] = derive[4];   D[5]  = derive[5];\n      D[6]  = derive[6];   D[7] = derive[7];   D[8]  = derive[8];\n      D[9]  = derive[9];  D[10] = derive[10];  D[11] = derive[11];\n      D[12] = derive[12]; D[13] = derive[13];  D[14] = derive[14];\n  }\n\n\n\n  /* Evaluate VoC */\n\n  a = s6length( D + 3, 3, &kstat );\n\n  atimes2 = a*a;\n  atimes4 = atimes2*atimes2;\n\n  a1dota2 = s6scpr( D + 3, D + 6, 3 );\n\n  s6crss( D + 3, D + 6, crpr12 );\n  s6crss( D + 3, D + 9, crpr13 );\n\n\n  crpr13dotcrpr12 = s6scpr( crpr13, crpr12, 3 );\n\n  normcrpr12 = s6length( crpr12, 3, &kstat );\n\n\n  if ( a != 0.0 && normcrpr12 != 0.0 )\n    {\n      *VoC = ( ( crpr13dotcrpr12 / normcrpr12 ) -\n                 ( 3.0 * a1dota2 * normcrpr12 / atimes2 ) ) / atimes4 ;\n    }\n  else\n    {\n      *VoC = 0.0;\n    }\n\n\n\n\n /* Successful computations.  */\n\n  *jstat = 0;\n  goto out;\n\n\n out:\n\n return;\n\n}\n"
  },
  {
    "path": "src/s2559.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n\n#define S2559\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2559( SISLCurve *curve,\n       double     ax[],\n       int        num_ax,\n       double     p[],\n       double     t[],\n       double     n[],\n       double     b[],\n       int       *jstat )\n#else\nvoid s2559( curve, ax, num_ax, p, t, n, b, jstat )\n     SISLCurve  *curve;\n     double      ax[];\n     int         num_ax;\n     double      p[];\n     double      t[];\n     double      n[];\n     double      b[];\n     int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate the Frenet Frame (t,n,b) of a curve\n*              at given parameter values ax[ 0 ],...,ax[ num_ax - 1 ].\n*\n*\n*\n* INPUT      : curve    - Pointer to the curve.\n*              ax       - The parameter values\n*          num_ax       - No. of parameter values\n*\n*\n*\n*\n* OUTPUT     :\n*         (t,n,b) - The Frenet Frame (in 3D) computed. Each of the arrays\n*                   (t,n,b) are of dim. 3*num_ax, and the data are\n*                   stored like this: tx(ax[0]), ty(ax[0]), tz(ax[0]),\n*                   ...,tx(ax[num_ax-1]), ty(ax[num_ax-1]), tz(ax[num_ax-1]).\n*\n*         p     - 3D curve posistions at  ax[ 0 ],...,ax[ num_ax - 1 ]\n*\n*        jstat  - Status messages\n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : Call the SISL rutine s2560() num_ax times\n*\n* REFERENCES :\n*\n*\n* CALLS      : s2560()\n*\n* WRITTEN BY  :   Geir Westgaard, SINTEF, Oslo, November 1999\n* MODIFIED BY :\n* REVISED BY  :\n*\n*********************************************************************\n*/\n{\n  int i, m;                   /* Index variable                      */\n  int kstat = 0;              /* local status variable               */\n  int kpos = 0;               /* local error position                */\n  int leftknot = 0;           /* Knot index                          */\n  double *derive = SISL_NULL;      /* Derivatives                         */\n\n\n\n  /* Allocate local arrays */\n\n  derive = newarray( 3*curve->idim, DOUBLE );\n\n  if ( derive == SISL_NULL )      goto err101;\n\n\n  /* Evaluate the Frenet Frame in all ax[i] positions. */\n\n  m = 0;\n  for ( i = 0; i < num_ax; i++ )\n  {\n    s2560( curve, ax[i], &leftknot, derive,\n\t   p + m, t + m, n + m, b + m, &kstat );\n\n    m = m + 3;\n\n    if ( kstat < 0 ) goto error;\n  }\n\n\n\n\n /* Successful computations.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation */\n err101:\n  *jstat = -101;\n  s6err( \"s2559\", *jstat, kpos );\n\n  /* Error in lower level routine.  */\n\n error:  *jstat = kstat;\n  s6err( \"s2559\", *jstat, kpos );\n  goto out;\n\n\n out:\n  /* Free local arrays */\n\n if ( derive != SISL_NULL ) freearray( derive );\n\n return;\n\n}\n"
  },
  {
    "path": "src/s2560.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n\n#define S2560\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2560( SISLCurve *curve,\n       double     parvalue,\n       int       *leftknot,\n       double     derive[],\n       double     p[],\n       double     t[],\n       double     n[],\n       double     b[],\n       int       *jstat )\n#else\nvoid s2560( curve, parvalue, leftknot, derive, p, t, n, b, jstat )\n     SISLCurve  *curve;\n     double      parvalue;\n     int        *leftknot;\n     double      derive[];\n     double      p[];\n     double      t[];\n     double      n[];\n     double      b[];\n     int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate the Frenet Frame (t,n,b) of a curve\n*              at a given parameter value, from the right hand side.\n*\n*\n*\n* INPUT      : curve    - Pointer to the curve.\n*              parvalue - The parameter value at which to compute\n*                         the Frenet Frame.\n*\n*\n*\n* INPUT/OUTPUT : leftknot - Pointer to the interval in the knot vector\n*                        where ax is located. If et is the knot vector,\n*                        the relation\n*\n*                          et[ileft] < parvalue <= et[ileft+1]\n*\n*                        should hold. (If parvalue == et[ik-1] then ileft\n*                        should be ik-1. Here in is the number of B-spline\n*                        coefficients.)\n*                        If ileft does not have the right value upon\n*                        entry to the routine, its value will be changed\n*                        to the value satisfying the above condition.\n*\n*\n*\n* OUTPUT     : derive   - Double array of dimension [3*idim]\n*                       containing the position and derivative vectors.\n*                       (idim is the number of components of each B-spline\n*                       coefficient, i.e. the dimension of the Euclidean\n*                       space in which the curve lies.)\n*                       These vectors are stored in the following order:\n*                       First the idim components of the position vector,\n*                       then the idim components of the tangent vector,\n*                       then the idim components of the second derivative\n*                       vector, and so on.\n*\n*         (t,n,b) - The Frenet Frame (in 3D) computed. Each of the vectors\n*                   (t,n,b) are of dim. 3, and the data are\n*                   stored like this: tx(parvalue), ty(parvalue), tz(parvalue).\n*\n*         p     - 3D curve posistions at parvalue.\n*\n*              jstat  - Status messages\n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : The derivatives are evaluated from the right hand\n*              side by  s1221(), and the Frenet Frame are evaluated by s2561()\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1221(), s2561()\n*\n* WRITTEN BY  :   Geir Westgaard, SINTEF, Oslo, November 1999\n* MODIFIED BY :\n* REVISED BY  :\n*\n*********************************************************************\n*/\n{\n  int kdim = curve -> idim;   /* copy curve attribute to local parameter  */\n  int kstat = 0;              /* local status variable                    */\n  int kpos = 0;               /* local error position                     */\n\n\n\n\n\n  /* Evaluate the derivatives */\n\n  s1221( curve, 2, parvalue, leftknot, derive, &kstat );\n\n  if ( kstat < 0 ) goto error;\n\n\n  /* Evaluate the Frenet Frame based on the derivatives in \"derive\" */\n\n  s2561( derive, kdim, p, t, n, b, &kstat );\n\n  if ( kstat < 0 ) goto error;\n\n\n\n /* Successful computations.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n error:  *jstat = kstat;\n  s6err( \"s2560\", *jstat, kpos );\n  goto out;\n\n\n out:\n return;\n\n}\n"
  },
  {
    "path": "src/s2561.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n\n\n#define S2561\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2561( double     derive[],\n       int        idim,\n       double     p[],\n       double     t[],\n       double     n[],\n       double     b[],\n       int       *jstat )\n#else\nvoid s2561( derive, idim, p, t, n, b, jstat )\n     double      derive[];\n     int         idim;\n     double      p[];\n     double      t[];\n     double      n[];\n     double      b[];\n     int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate the Frenet Frame (t,n,b) of a curve\n*              based on the derivatives in \"derive\". We assume that\n*              the curve lies in R, R^2 or R^3.\n*\n*\n* INPUT      :\n*            derive   - Double array of dimension [3*idim]\n*                       containing the position and derivative vectors.\n*                       These vectors are stored in the following order:\n*                       First the position vector, then the tangent vector,\n*                       then the idim components of the second derivative\n*                       vector, and so on.\n*\n*\n* OUTPUT     :\n*\n*         (t,n,b) - The Frenet Frame (in 3D) computed. Each of the vectors\n*                   (t,n,b) are of dim. 3, and the data are\n*                   stored like this: tx(parvalue), ty(parvalue), tz(parvalue).\n*\n*         p     - 3D curve posistions at parvalue.\n*\n*              jstat  - Status messages\n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*  METHOD     : See formula in the book of Do Carmo\n*              (Differential Geometry of Curves and Surfaces).\n*\n* REFERENCES : Differential Geometry of Curves and Surfaces,\n*                    (Manfredo P. Do Carmo, Prentice Hall,\n*                      ISBN: 0-13-212589-7).\n*\n*\n*\n* CALLS       : s6length(), s6crss()\n*\n* WRITTEN BY  :   Geir Westgaard, SINTEF, Oslo, November 1999\n* MODIFIED BY :\n* REVISED BY  :\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;        /* Local status variable      */\n  double a;             /* Tmp. variable.             */\n  double crpr[3];       /* Tmp. variable.             */\n  double D[9];          /* Derivatives on canonical\n\t\t\t   R^3 form                   */\n\n\n  /* Put the derivatives on canonical R^3 form */\n\n  if ( idim == 1 )\n  {\n      D[0]  = 0.0;   D[1] = derive[0];  D[2]  = 0.0;\n      D[3]  = 1.0;   D[4] = derive[1];  D[5]  = 0.0;\n      D[6]  = 0.0;   D[7] = derive[2];  D[8]  = 0.0;\n  }\n  else if ( idim == 2 )\n  {\n      D[0]  = derive[0];   D[1] = derive[1];   D[2]  = 0.0;\n      D[3]  = derive[2];   D[4] = derive[3];   D[5]  = 0.0;\n      D[6]  = derive[4];   D[7] = derive[5];   D[8]  = 0.0;\n  }\n  else\n  {\n      D[0]  = derive[0];   D[1] = derive[1];   D[2]  = derive[2];\n      D[3]  = derive[3];   D[4] = derive[4];   D[5]  = derive[5];\n      D[6]  = derive[6];   D[7] = derive[7];   D[8]  = derive[8];\n  }\n\n  /* Set 3D curve pos. */\n\n  p[0] = D[0];\n  p[1] = D[1];\n  p[2] = D[2];\n\n\n  /* Compute the Frenet Frame (t,n,b). */\n\n  a = s6length( D + 3, 3, &kstat );\n\n  t[0] = D[3]/a;\n  t[1] = D[4]/a;\n  t[2] = D[5]/a;\n\n\n  s6crss( D + 3, D + 6, crpr );\n\n  a = s6length( crpr, 3, &kstat );\n\n  if ( kstat != 0 )\n  {\n    b[0] = crpr[0]/a;\n    b[1] = crpr[1]/a;\n    b[2] = crpr[2]/a;\n\n    s6crss( b, t, n );\n  }\n  else\n  {\n    n[0] = 0.0;\n    n[1] = 0.0;\n    n[2] = 0.0;\n\n    b[0] = 0.0;\n    b[1] = 0.0;\n    b[2] = 0.0;\n\n    goto war002;\n  }\n\n\n\n /* Successful computations.  */\n\n  *jstat = 0;\n  goto out;\n\n\n  /* Frenet Frame undefined, since the curvature = 0.0.  */\nwar002:\n  *jstat = 2;\n  goto out;\n\n\n out:\n\n return;\n\n}\n"
  },
  {
    "path": "src/s2562.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id:\n *\n */\n\n#define S2562\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns2562( SISLCurve *curve,\n       double     ax[],\n       int        num_ax,\n       int        val_flag,\n       double     p[],\n       double     t[],\n       double     n[],\n       double     b[],\n       double     val[],\n       int       *jstat )\n#else\nvoid s2562( curve, ax, num_ax, val_flag, p, t, n, b, val, jstat )\n     SISLCurve  *curve;\n     double      ax[];\n     int         num_ax;\n     int         val_flag;\n     double      p[];\n     double      t[];\n     double      n[];\n     double      b[];\n     double     val[];\n     int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate the 3D position, the Frenet Frame (t,n,b) and\n*              geometric property (curvature, torsion or variation of\n*              curvature) of a curve at given parameter values\n*              ax[0],...,ax[num_ax-1].\n*              These data are needed to produce spike plots (using the\n*              Frenet Frame and the geometric property) and circular\n*              tube plots (using circular in the normal plane (t,b),\n*              where the radius is equal to the geometric property times\n*              a scaling factor for visual effects).\n*\n*\n* INPUT      : curve    - Pointer to the curve.\n*              ax       - The parameter values\n*          num_ax       - No. of parameter values\n*          val_flag     - Compute geometric property\n*                                = 1  : curvature\n*                                = 2  : torsion\n*                                = 3  : variation of curvature\n*\n*\n*\n* OUTPUT     :\n*         (t,n,b) - The Frenet Frame (in 3D) computed. Each of the arrays\n*                   (t,n,b) are of dim. 3*num_ax, and the data are\n*                   stored like this: tx(ax[0]), ty(ax[0]), tz(ax[0]),\n*                   ...,tx(ax[num_ax-1]), ty(ax[num_ax-1]), tz(ax[num_ax-1]).\n*\n*         p     - 3D curve positions at ax[0],...,ax[num_ax-1]\n*\n*         val   -  Geometric property (curvature, torsion or\n*                  variation of curvature) of a curve at given parameter\n*                  values ax[0],...,ax[num_ax-1].\n*\n*        jstat  - Status messages\n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n** METHOD     : See formulas in given in the reference.\n*\n*\n* REFERENCES :   Westgaard G., Heimann J.:\n*                Analysis and Visualization of Geometric Curve Properties,\n*                in M. D{\\ae}hlen, T. Lyche and L. L. Schumaker (Eds.)\n*                Mathematical Methods in CAGD IV, 1998.\n*\n*\n* CALLS      : s1221(), s2561(), s1307(), s6length(), s2555(), s2558().\n*\n* WRITTEN BY  :   Geir Westgaard, SINTEF, Oslo, November 1999\n* MODIFIED BY :\n* REVISED BY  :\n*\n*********************************************************************\n*/\n{\n  int i, m;                 /* Index variable                      */\n  int kstat = 0;            /* Local status variable               */\n  int kpos = 0;             /* Local error position                */\n  int leftknot = 0;         /* Knot index                          */\n  int kdim = curve -> idim; /* Dim. of the space in which the\n\t\t\t       curve lies                          */\n  double *derive = SISL_NULL;    /* Derivatives                         */\n  double *egeo = SISL_NULL;      /* Array to store pos, tangent vector,\n                               curvature vector and radius of\n\t\t\t       curvature, used by s1307()          */\n\n\n\n\n  /* Allocate local arrays */\n\n  derive = newarray( 4*kdim, DOUBLE );\n\n  if ( derive == SISL_NULL )      goto err101;\n\n  egeo = newarray( 3*kdim+1, DOUBLE );\n\n  if ( egeo == SISL_NULL )        goto err101;\n\n\n  /* Evaluate in all ax[i] positions. */\n\n  m = 0;\n  for ( i = 0; i < num_ax; i++ )\n  {\n\n    /* Evaluate the derivatives */\n\n    s1221( curve, 3, ax[i], &leftknot, derive, &kstat );\n\n    if ( kstat < 0 ) goto error;\n\n\n    /* Evaluate 3D position (p) and the 3D Frenet Frame (t,n,b) */\n\n    s2561( derive, kdim, p + m, t + m, n + m, b + m, &kstat );\n\n    if ( kstat < 0 ) goto error;\n\n    m = m + 3;\n\n\n    /* Evaluate the geometric property */\n\n    if ( val_flag == 1 ) /* Curvature */\n      {\n\ts1307( derive, kdim, egeo, &kstat );\n\n\tif ( kstat < 0 ) goto error;\n\n\tval[ i ] = s6length( egeo+2*kdim, kdim, &kstat );\n      }\n    else if ( val_flag == 2 ) /* Torsion */\n      {\n\ts2555( derive, val + i, &kstat );\n\n\tif ( kstat < 0 ) goto error;\n      }\n    else if ( val_flag == 3 )  /* Variation of curvature */\n      {\n\ts2558( derive, kdim, val + i, &kstat );\n\n\tif ( kstat < 0 ) goto error;\n      }\n  }\n\n\n\n\n /* Successful computations.  */\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation */\n err101:\n  *jstat = -101;\n  s6err( \"s2562\", *jstat, kpos );\n\n\n  /* Error in lower level routine.  */\n error:  *jstat = kstat;\n  s6err( \"s2562\", *jstat, kpos );\n  goto out;\n\n\n out:\n  /* Free local arrays */\n if ( derive != SISL_NULL ) freearray( derive );\n if ( egeo   != SISL_NULL ) freearray( egeo   );\n\n return;\n\n}\n"
  },
  {
    "path": "src/s6addcurve.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6addcurve.c,v 1.2 2001-03-19 15:59:00 afr Exp $\n *\n */\n\n\n#define S6ADDCURVE\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void s6addcurve_s9moveknots(double [],int,double,double,\n\t\t\t\t   double [],int *); \n#else\nstatic void s6addcurve_s9moveknots(); \n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid s6addcurve(SISLCurve *pc1,SISLCurve *pc2,int isign,\n\t\tSISLCurve **rcurve,int *jstat)\n#else\nvoid s6addcurve(pc1,pc2,isign,rcurve,jstat)\n     SISLCurve *pc1;\n     SISLCurve *pc2;\n     int isign;\n     SISLCurve **rcurve;\n     int *jstat;\n#endif   \n/*\n*********************************************************************\n* \n* PURPOSE    : Compute the sum or difference between two B-spline\n*              curves depending on the constang isign. That is find\n*              the curve pc1 + isign*pc2.\n* \n* \n* \n* INPUT      : pc1      - First curve in expression.\n*              pc2      - Second curve in expression.\n*              isign    - Sign of second curve. \n*\n* \n* OUTPUT     : rcurve   - Sum/difference between the input curves.\n*              jstat    - status messages \n*                         > 0 : warning\n*                         = 0 : ok \n*                         < 0 : error \n* \n* \n* METHOD     : Express the curves on the same knot vector. Compute the\n*              sum difference between corresponding vertices.\n*\n*\n* REFERENCES : \n*              \n*\n* USE        :\n*\n*-\n* CALLS      : s1932  - Express curve-set in given basis.  \n*              s1363  - Pick parametrisation of curve.\n*              s6takeunion - Union of two ordered vectors. \n*              make_cv_kreg - Make curve k-regular.\n*              s1333_count - Count continuity in ends of closed curves.\n*              make_cv_cyclic - Represent curve in a periodic basis.\n*              newCurve  -   Create new curve-object. \n*              s6addcurve_s9moveknots() - Move knotvector into new parameter interval.\n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 08.90.\n* REWISED BY : Vibeke Skytt, SI, 05.92. To treat periodic curves.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;         /* Status variable.  */\n  int ki;                /* Counter.          */\n  int kdim = pc1->idim;  /* Dimension of geometry space.              */\n  int knbcrv = 2;        /* Number of input curves.                   */\n  int kknot1 = pc1->in + pc1->ik;  /* Number of knots of first curve. */\n  int kknot2 = pc2->in + pc2->ik;  /* Number of knots of second curve. */\n  int korder;            /* Order of output curve.     */\n  int ktau;              /* Number of knots / number of vertices of \n\t\t\t    output curve.                             */\n  int kcont;             /* Continuity at ends in periodic case.      */\n  int kopen;             /* Open/closed/periodic parameter.           */\n  int kkind = pc1->ikind;  /* Kind of curves.                         */\n  int kcopy = 1;         /* Copy arrays when creating new curve.      */\n  double tmin1,tmax1;    /* Parameter interval of first input curve.  */\n  double tmin2,tmax2;    /* Parameter interval of second input curve. */\n  double *st = SISL_NULL;     /* Knot vector of second curve.              */\n  double *stau = SISL_NULL;   /* Knot vector of output curve.              */\n  double *scoef = SISL_NULL;  /* Vertices of input curves represented in \n\t\t\t    the same knot vector, then of output curve. */\n  SISLCurve *ucurves[2];     /* Local pointer array to input curves.      */\n  \n  ucurves[0] = ucurves[1] = SISL_NULL;\n  \n  /* Test input.  */\n\n  if (kdim != pc2->idim) goto err106;\n  \n  /* Make curves k-regular.  */\n\n  make_cv_kreg(pc1,ucurves,&kstat);\n  if (kstat < 0) goto error;\n \n  make_cv_kreg(pc2,ucurves+1,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Allocate scratch for local knot vector.  */\n\n  if ((st = newarray(kknot2,DOUBLE)) == SISL_NULL) goto err101;\n  \n  /* Fetch endparameter values of the input curves.  */\n   \n  s1363(ucurves[0],&tmin1,&tmax1,&kstat);\n  if (kstat < 0) goto error;\n  \n  s1363(ucurves[1],&tmin2,&tmax2,&kstat);\n  if (kstat < 0) goto error;\n  \n  if (DNEQUAL(tmin1,tmin2) || DNEQUAL(tmax1,tmax2))\n    {\n      /* Move the knot vector of the second curve into the parameter\n\t interval of the first curve.  */\n\n       s6addcurve_s9moveknots(ucurves[1]->et,kknot2,tmin1,tmax1,st,&kstat);\n      if (kstat < 0) goto error;\n    }\n  else memcopy(st,ucurves[1]->et,kknot2,DOUBLE);\n  \n  /* Find the union of the knot vectors of the two curves.  */\n\n  s6takeunion(ucurves[0]->et,kknot1,st,kknot2,&stau,&ktau,&kstat);\n  if (kstat < 0) goto error;\n  \n  korder = MAX(ucurves[0]->ik,ucurves[1]->ik);\n  ktau -= korder;\n  \n  /* Express the curves in the basis.  */\n\n  s1932(2,ucurves,tmin1,tmax1,stau,ktau,korder,&scoef,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Find the coefficients of the sum/difference curve.  */\n\n  for (ki=0; ki<ktau*kdim; ki++)\n    scoef[ki] += (double)isign*scoef[ktau*kdim+ki];\n  \n  /* Present the sum/difference as a curve.  */\n\n  if ((*rcurve = newCurve(ktau,korder,stau,scoef,kkind,kdim,kcopy)) == SISL_NULL)\n    goto err101;\n  \n  (*rcurve)->cuopen = kopen = MAX(pc1->cuopen,pc2->cuopen);\n  if (kopen == SISL_CRV_PERIODIC)\n  {\n     /* Represent the output curve cyclic. First find continuity. */\n     \n     s1333_count(knbcrv,ucurves,&kcont,&kstat);\n     if (kstat < 0) goto error;\n     \n     make_cv_cyclic(*rcurve,kcont,&kstat);\n     if (kstat < 0) goto error;\n  }\n  \n  /* Task performed.  */\n\n  *jstat = 0;\n  goto out;\n  \n  /* Error in scratch allocation.  */\n\n  err101 :\n    *jstat = -101;\n  goto out;\n  \n  /* Error in input. Conflicting dimensions.  */\n\n  err106 :\n    *jstat = -106;\n  goto out;\n  \n  /* Error in lower order routine.  */\n\n  error :\n    *jstat = kstat;\n  goto out;\n  \n  out :\n\n    /* Free scratch occupied by local arrays.  */\n\n    if (st != SISL_NULL) freearray(st);\n  if (stau != SISL_NULL) freearray(stau);\n  if (scoef != SISL_NULL) freearray(scoef);\n  if (ucurves[0] != SISL_NULL) freeCurve(ucurves[0]);\t\t     \n  if (ucurves[1] != SISL_NULL) freeCurve(ucurves[1]);\t\t     \n  \n  return;\n}\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  s6addcurve_s9moveknots(double et[],int inmbknot,double astart,\n\t\t\t double aend,double etmoved[],int *jstat)\n#else\nstatic void s6addcurve_s9moveknots(et,inmbknot,astart,aend,etmoved,jstat)\n     double et[];\n     int inmbknot;\n     double astart;\n     double aend;\n     double etmoved[];\n     int *jstat;\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : Move knot vector into the parameter interval\n*              [astart,aend].  \n* \n* \n* \n* INPUT      : et       - Knot vector.\n*              inmbknot - Number of knots in the vector et.\n*              astart   - Start parameter value of new parameter interval.\n*              aend     - End parameter value of new parameter interval. \n*\n* \n* OUTPUT     : etmoved  - Knot vector on new parameter interval.\n*              jstat    - status messages \n*                         = 1 : Parameter interval changed. Thus,\n*                               reparametrization is performed.\n*                         = 0 : ok \n*                         < 0 : error \n* \n* \n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        :\n*\n*-\n* CALLS      : \n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 07.90.\n*\n*********************************************************************\n*/\n{\n  int kwarn = 0;             /* Indicates if reparametrization is performed. */\n  double tstart = et[0];     /* Start parameter of original knot vector.     */\n  double tend = et[inmbknot-1];   /* End parameter of original knot vector.  */\n  double tfac = (aend - astart)/(tend - tstart);  /* Factor used when moving\n\t\t\t\t\t\t     knot vector.            */\n  double *s1,*s2,*s3;        /* Pointers used to traverse knot vectors.      */\n  \n  /* Test if reparametrization is performed.  */\n\n  if (DNEQUAL(aend-astart,tend-tstart)) kwarn = 1;\n  \n  /* Put knot vector into new parameter interval.  */\n\n  for (s1=et,s2=et+inmbknot,s3=etmoved; s1<s2; s1++,s3++)\n    *s3 = astart + (*s1 - tstart)*tfac;\n  \n  *jstat = kwarn;\n  return;\n}\n\n\n"
  },
  {
    "path": "src/s6affdist.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6affdist.c,v 1.2 2001-03-19 15:59:00 afr Exp $\n *\n */\n\n\n#define S6AFFDIST\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\ndouble\n     s6affdist(double e1[],double e2[],double emat[],int idim)\n#else\ndouble s6affdist(e1,e2,emat,idim)\n   double e1[];\n   double e2[];\n   double emat[];\n   int    idim;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Compute the distance between two points using an\n*              affine metric described by the matrix emat.\n*\n*\n*\n* INPUT      : e1     - First point.\n*              e2     - Second point.\n*              emat   - Matrix of affine metric.\n*              idim   - Dimension of geometry space.\n*              \n*\n* OUTPUT     : s6affdist - Distance between two points.\n*\n*\n* METHOD     : \n*\n* REFERENCES :\n*\n*-\n* CALLS      : \n*\n* WRITTEN BY : Vibeke Skytt, SI, 91-03.\n*\n*********************************************************************\n*/\n{\n   int ki,kj;              /* Counters.  */\n   double tdist = DZERO;   /* Distance.  */\n   \n   for (ki=0; ki<idim; ki++)\n      for (kj=0; kj<idim; kj++)\n\t tdist += emat[ki*idim+kj]*(e1[ki]-e2[ki])*(e1[kj]-e2[kj]);\n   \n   tdist = sqrt(idim*tdist);\n   \n   return tdist;\n}\n"
  },
  {
    "path": "src/s6ang.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6ang.c,v 1.2 2001-03-19 15:59:00 afr Exp $\n *\n */\n\n\n#define S6ANG\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\ndouble \ns6ang(double evec1[],double evec2[],int idim)\n#else\ndouble s6ang(evec1,evec2,idim)\n     double evec1[];\n     double evec2[];\n     int    idim;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Compute the angle (in radians) between two vectors\n*\n*\n*\n* INPUT      : evec1   - First vector \n*              evec2   - Second vector \n*              idim    - Dimension of the space in which the vectors lie.\n*\n*\n*\n* OUTPUT     : s6ang   - Angle in radians between vectors\n*\n*\n* METHOD     : Make cosine of the angle by computing the scalar product,\n*              then divide by the length of the two vectors.\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken SI, 88-07.\n*              Arne Laksaa SI, 89-07.\n*\n*********************************************************************\n*/                                     \n{\n  double tscpr,tang,tlength1,tlength2,tcos;\n  int    kstat1,kstat2;\n  \n  tscpr = s6scpr(evec1,evec2,idim);\n  \n  tlength1 = s6length(evec1,idim,&kstat1);\n  tlength2 = s6length(evec2,idim,&kstat2);\n  \n  if (!kstat1 || !kstat2)\n    tang = DZERO;\n  else\n    {\n      tcos = fabs(tscpr/(tlength1*tlength2));\n      tcos = MIN((double)1.0,tcos);\n      tang = acos(tcos);\n    }\n  \n  return(tang);\n}\n"
  },
  {
    "path": "src/s6angle.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6angle.c,v 1.2 2001-03-19 15:59:00 afr Exp $\n *\n */\n\n\n#define S6ANGLE\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\ndouble\n     s6angle(double evec1[],double evec2[],double enorm[],int idim,int *jstat) \n#else\ndouble s6angle(evec1,evec2,enorm,idim,jstat)\n     double evec1[];\n     double evec2[];\n     double enorm[];\n     int    idim;\n     int *jstat;\n#endif     \n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Compute the angle (in radians) between two vectors\n*              projected down into a given plane.\n*\n*\n*\n* INPUT      : evec1   - First vector \n*              evec2   - Second vector \n*              enorm   - Normal of plane\n*              idim    - Dimension of the space in which the vectors lie.\n*\n*\n*\n* OUTPUT     : s6ang   - Angle in radians between vectors\n*              jstat   - Status messages\n*\n*\n* METHOD     : Make cosine of the angle by computing the scalar product,\n*              then divide by the length of the two vectors.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6scpr   - Scalar product between two vector.\n*              s6length - Length of vector.\n*              s6crss   - Cross product between two vector.\n*\n* WRITTEN BY : Tor Dokken SI, 88-07.\n*              Arne Laksaa SI, 89-07.\n*              Vibeke Skytt, SI, 90-08.\n*\n*********************************************************************\n*/                                     \n{\n  double sa[3];\n  double sb[3];\n  double sn[3];\n  \n  double tscpr1,tscpr2,tang,tlength1,tlength2,tcos;\n  int    kstat1,kstat2,ki;\n    \n  if (idim != 3) goto err104;\n  \n  tscpr1 = s6scpr(evec1,enorm,idim);\n  tscpr2 = s6scpr(evec2,enorm,idim);\n  \n  for (ki=0; ki<idim; ki++)\n    {\n      sa[ki] = evec1[ki] - tscpr1*enorm[ki];\n      sb[ki] = evec2[ki] - tscpr2*enorm[ki];\n    }\n  \n  tscpr1 = s6scpr(sa,sb,idim);\n\n  tlength1 = s6length(sa,idim,&kstat1);\n  tlength2 = s6length(sb,idim,&kstat2);\n  \n  if (!kstat1 || !kstat2)\n    tang = DZERO;\n  else\n    {\n      tcos = tscpr1/(tlength1*tlength2);\n      tcos = MIN((double)1.0,tcos);\n      tcos = MAX(-(double)1.0,tcos);\n      tang = acos(tcos);\n    }\n  \n  s6crss(sa,sb,sn);\n  if (s6scpr(sn,enorm,idim) < DZERO) tang = TWOPI - tang;\n  \n  *jstat = 0;\n  goto out;\n  \n err104:\n  *jstat = -104;\n  goto out;\n  \n out:\n  return(tang);\n}\n"
  },
  {
    "path": "src/s6bezpowsf.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S6BEZPOWSF\n\n#include \"sislP.h\"\n\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6bezpowsf(double *c1, int order11,int order12, int power, \n\t\t double *Pascal, double *c1_power)\n#else\n   void s6bezpowsf(c1, order11, order12, power, Pascal, c1_power)\n      double *c1;\n      int order11;\n      int order12;\n      int power;\n      double *Pascal;\n      double *c1_power;\n#endif      \n{\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Multiply a given 1D Bezier surface with itself till a\n*              specified power.\n*\n*\n*\n* INPUT      : c1      - Coefficients of Bezier surface.\n*              order11 - Order of surface in first par. dir.\n*              order12 - Order of surface in second par. dir.\n*              power   - The factor into which the surfaces are\n*                        to be multiplied.\n*              Pascal  - Factors used in curve multiplication.\n*\n*\n*\n* OUTPUT     : c1_power - Coefficients of product surface.\n*\n*\n* REFERENCES : s6multsfs\n*\n* NOTE       : Factors necessary for the multiplication must be\n*              precomputed. If the multiplication routine is to be\n*              calles severatl times, it speeds up the computations\n*              if this factors are called only once.\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SINTEF, 1993. \n* COMMENTED BY : Vibeke Skytt, SINTEF, 06.94.\n*\n*********************************************************************\n*/\n  int p;\n  int kgrad11=order11-1;\n  int kgrad12=order12-1;\n  int kdum1,kdum2;\n  double *c1_p;\n  double *c1_pm1;\n  int pgrad11, pgrad12;\n\n  c1_power[0] = 1;\n  for(p=1,pgrad11=0,pgrad12=0,c1_pm1=c1_power,c1_p=c1_power+1;p<=power;\n      p++,pgrad11+=kgrad11,pgrad12+=kgrad12,c1_pm1=c1_p,c1_p+=(pgrad11+1)*(pgrad12+1))\n    {\n\n      s6multsfs(c1, order11,order12, c1_pm1,pgrad11+1,pgrad12+1,\n                 Pascal, c1_p, &kdum1,&kdum2);\n            }\n  \n}\n"
  },
  {
    "path": "src/s6castelja.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6castelja.c,v 1.2 2001-03-19 15:59:00 afr Exp $\n *\n */\n\n\n#define S6DECASTELJAU\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n    s6deCasteljau(double C[], double a, double b, double t, int k, double D[],\n\t\t     int* jstat)\n#else\nvoid s6deCasteljau(C,a,b,t,k,D,jstat)\n     double C[];\n     double a,b,t;\n     int k;\n     double D[];\n     int* jstat;\n#endif\n/*\n***************************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To subdivide a 1-dim Bezier curve 'f' at a point 't'\n*\t       using the deCasteljau lgorithm, and to calculate \n*              the value f(t).\n*              \n*\n*\n*\n* INPUT      : C[0:k-1]\t- Bezier coefficients of f relative to the \n*\t\t\t  intervall [a,b].\n*              a\t- start of parameter intervall.\n*              b\t- end of parameter intervall.\n*              t \t- parameter value at which to subdivide.\n*                         Assumes: a < b , and a <= t <= b.\n*              k\t- polynomial order (=degree+1) of f.\n*              D[0:2*k-1] - allocated space.\n*\n*\n* OUTPUT     : D[] \t- Bezier coefficients for the subdivided repr of 'f'.\n*\t\t\t  D[r],  r=0,...,k-1\t-\tcoeffs. on [a,t],\n*\t\t\t  D[k+r], r=0,...,k-1\t-\tcoeffs. on [t,b],\n*                         D[k-1] = D[k]\t\t-\tvalue of f at t.\n*\n* METHOD     : \t\t- The multiaffine blossom  F of f at argument\n*                         bags consisting of multipla of a,c, and t are \n*                         calculated using the deCasteljau algorithm. These\n*                         values are stored in an local array A[0:k*k-1]\n*                         as follows:\n*\t\t\t  A[k*r+j] = F(a,..,a,t,..,t,b,..,b)\n*                             where a is repeated k-1-j times,\n*                                   t is repeated r times,\n*                                   b is repeated j-r times.\n*\t\t\t  In particular\n*\t\t\t  A[k*r+r] r=0,...,k-1 are Bezier coeffs. on [a,t],\n*\t\t\t  A[k*(k-1-r)+k-1] r=0,...,k-1 : coeffs. on [t,b],\n*\t\t\t  A[k*(k-1)+k-1] : value of f at t.\n*                        \n\n*              jstat     - status messages \n*                          < 0 - error\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Kyrre Strom, SI, 93-01.\n*\n*\n****************************************************************************\n*/\n{\n  int r,j,kk=k*k,kr;\n  double alpha;\n  double Al[16];\n  double* A = SISL_NULL;\n\n\n  *jstat = 1;\n  if (a > b || DEQUAL(a,b) ) goto err109;\n\n  if (k > 4 )\n    {\n      A = newarray(kk,double);\n      if (A == SISL_NULL) goto err101;\n    }\n  else\n    A = Al;\n\n  for (j=0; j<k; j++)\n    A[j] = C[j];\n\n  alpha = (b-t)/(b-a);\n  for (r = 1; r < k; r++)\n    for (j = r; j < k; j++)\n      A[k*r+j] = alpha*A[k*(r-1)+j-1] + (1-alpha)*A[k*(r-1)+j];\n  \n  for (kk--,kr=r=0; r<k; r++,kr+=k)\n    {\n      D[r] = A[kr+r];\n      D[k+r] = A[kk-kr];\n    }\n\n  goto out;\n\n err109: *jstat = -109;\n  goto out;\n\n err101: *jstat = -101;\n  goto out;\n\n out: \n  if (A != SISL_NULL && A != Al)\n    freearray(A);\n  return ;\n}\n\n"
  },
  {
    "path": "src/s6chpar.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6chpar.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S6CHPAR\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6chpar(double ecoef1[],int in1,int in2,int idim,double ecoef2[])\n#else\nvoid s6chpar(ecoef1,in1,in2,idim,ecoef2)\n     double ecoef1[];\n     int    in1;\n     int    in2;\n     int    idim;\n     double ecoef2[];\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Change parameter directions of vertices of surface.\n*\n*\n*\n* INPUT      : ecoef1 - Vertices of original surface.\n*              in1    - Number of vertices in first parameter direction.\n*              in2    - Number of vertices in second parameter direction.\n*              idim   - Dimension of the space in which the surfac lies.\n*\n*\n* OUTPUT     : ecoef2 - Vertices after the changing of parameter directions.\n*\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n*\n*********************************************************************\n*/\n{\n  register int ki,kj,kk;  /* Counters.  */\n  \n  for (ki=0; ki<in1; ki++)\n    for (kj=0; kj<in2; kj++)\n      for (kk=0; kk<idim; kk++)\n\tecoef2[(ki*in2+kj)*idim+kk] = ecoef1[(kj*in1+ki)*idim+kk];\n}\n"
  },
  {
    "path": "src/s6crss.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6crss.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S6CRSS\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6crss(double e1[],double e2[],double e3[])\n#else\nvoid s6crss(e1,e2,e3)\n     double e1[];\n     double e2[];\n     double e3[];\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To make the cross product of two 3-D vectors\n*\n* INPUT      : e1      - First 3-D vector\n*              e2      - Second 3-D vector\n*\n* OUTPUT     : e3      - The vector containing the cross product e1xe2\n*\n*\n* METHOD     : The cross product is calculated by using its definition.\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. 1988-may-03\n*\n*********************************************************************\n*/\n{\n  e3[0] = e1[1]*e2[2] - e1[2]*e2[1];\n  e3[1] = e1[2]*e2[0] - e1[0]*e2[2];\n  e3[2] = e1[0]*e2[1] - e1[1]*e2[0];\n}\n"
  },
  {
    "path": "src/s6crvature.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6crvature.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S6CURVATURE\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      s6curvature(double eder[],int idim,double ecurv[],int *jstat)\n#else\t \nvoid s6curvature(eder,idim,ecurv,jstat)\n     int idim,*jstat;\n     double eder[],ecurv[];\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Given position, first and second derivative of a curve at\n*              a point, compute curvature vector.\n*\n*\n*\n* INPUT      : eder    - Array containing position, 1. and 2. derivative of\n*                        curve. Dimension is 3*idim.\n*              idim    - Dimension of geometry space.\n*                       \n*\n* OUTPUT     : ecurv   - Curvature vector.\n*              jstat   - status messages  \n*                                         = 1      : Tangent vector zero.\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Express the curve using cord length parametrisation. Then the\n*              curvature is equal to the 2. derivative of the curve.\n*\n* REFERENCES : \n*\n* USE        : \n*\n*-\n* CALLS      : s6length - Length of vector.   \n*              s6scpr   - Scalar product between two vectors.  \n*\n* WRITTEN BY : Vibeke Skytt, SI, 04.90.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;    /* Status variable.  */\n  int ki;           /* Counter.   */\n  double tleng;     /* Length of first derivative.  */\n  double tleng2;    /* Square of length.  */\n  double tdot;      /* Scalar product between 1. and 2. derivative. */\n  \n  /* Compute length of 1. derivative. */\n\n  tleng = s6length(eder+idim,idim,&kstat);\n  \n  if (kstat == 0)\n    {\n      /* The first derivative is zero. */\n\n      for (ki=0; ki<idim; ki++) ecurv[ki] = (double)0.0;\n      goto warn1;\n    }\n  else\n    {\n      tleng2 = tleng*tleng;\n      tdot = s6scpr(eder+idim,eder+2*idim,idim);\n      \n      for (ki=0; ki<idim; ki++)\n\tecurv[ki] = (eder[2*idim+ki] - eder[idim*ki]*tdot/tleng2)/tleng2;\n    }\n  \n  *jstat = 0;\n  goto out;\n  \n  warn1 :\n    *jstat = 1;\n  goto out;\n  \n  out :\n    return;\n}\n\n  \n"
  },
  {
    "path": "src/s6crvcheck.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6crvcheck.c,v 1.3 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6CRVCHECK\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6crvcheck(SISLCurve *pc,int *jstat)\n#else\nvoid s6crvcheck(pc,jstat)\n     SISLCurve *pc;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To check a curve descripiton and remove unneccessary\n*              knots and vertices. Such that no continuous curve will\n*              have knots with more than the order minus one in \n*              multiplicity.\n*\n*\n*\n* INPUT/OUTPUT:pc     - The curve identifcation\n*\n* OUTPUT     : kstat  - Status variable\n*                        < 0 - Error\n*                        = 0 - SISLCurve object not changed\n*                        = 1 - SISLCurve object changed\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6dist  - Distance between two points.\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway,  August 1989\n* REWISED BY : Vibeke Skytt, SI, August 1990\n* REVISED BY : Johannes Kaasa, SI, April 1992 (Intoduced NURBS)\n* REVISED BY : Christophe Rene Birkeland, SINTEF, May 1993 (Status variable)\n*\n*********************************************************************\n*/                                                               \n{\n  int kstat = 0;              /* Status variable.                 */\n  int ki,kj;                  /* Counter.                         */\n  int kdim;                   /* Dimension of space               */\n  int rdim;                   /* Rational dimension.              */\n  int kn;                     /* Number of knots                  */\n  int kk;                     /* Number of vertices               */\n  int kmark;                  /* Indicates if k-tupple knots      */\n  int knnew;                  /* New number of vertices           */\n  int kind;                   /* Type of curve, 2 and 4 rational. */\n  double *snt=SISL_NULL;           /* Compressed knot vector           */\n  double *sncoef=SISL_NULL;        /* Compressed vertex vector         */\n  double *srcoef=SISL_NULL;        /* Compressed vertex vector         */\n  double *st;                 /* Knots                            */\n  double *scoef;              /* Vertices                         */\n  double *rcoef;              /* Rational vertices.               */\n  \n  *jstat = 0;\n\n  if (pc == SISL_NULL) goto out;\n  \n  kk    = pc -> ik;\n  kn    = pc -> in;\n  kdim  = pc -> idim;\n  rdim  = kdim + 1;\n  kind  = pc -> ikind;\n  st    = pc -> et;\n  scoef = pc -> ecoef;\n  rcoef = pc -> rcoef;\n  \n  /* Run through all knots to detect if st[ki]=st[ki+kk-1] e.g. that we\n     have at least kk-tupple internal knots */\n  \n  kmark = 0;\n  for (ki=1 ; ki < kn-1 ; ki++)\n    if (st[ki] == st[ki+kk-1] && \n\tDEQUAL(s6dist(scoef+(ki-1)*kdim,scoef+ki*kdim,kdim),DZERO))\n      {\n        kmark = 1;\n        break;\n      }\n  \n  if (kmark == 0) goto out;\n  \n  /* We have at least kk-tupple knots, remove not necessary knots and vertices */\n  \n  if((snt = newarray(kn+kk,DOUBLE)) == SISL_NULL) goto err101;  \n  if((sncoef = newarray(kn*kdim,DOUBLE)) == SISL_NULL) goto err101;\n\n  if (kind == 2 || kind == 4)\n    {\n      srcoef = newarray(kn*rdim,DOUBLE);\n      if (srcoef == SISL_NULL) goto err101;\n      for (ki=0,kj=0 ; ki < kn ; ki ++)\n        if (ki == 0 || ki == kn-1 || st[ki] < st[ki+kk-1] || \n\t  DNEQUAL(s6dist(rcoef+(ki-1)*rdim,rcoef+ki*rdim,rdim),DZERO))\n          {\n            snt[kj] = st[ki];\n            memcopy(sncoef+kdim*kj,scoef+kdim*ki,kdim,DOUBLE);\n            memcopy(srcoef+rdim*kj,rcoef+rdim*ki,rdim,DOUBLE);\n            kj++;\n          }\n    }\n  else\n    {\n      for (ki=0,kj=0 ; ki < kn ; ki ++)\n        if (ki == 0 || ki == kn-1 || st[ki] < st[ki+kk-1] || \n\t  DNEQUAL(s6dist(scoef+(ki-1)*kdim,scoef+ki*kdim,kdim),DZERO))\n          {\n            snt[kj] = st[ki];\n            memcopy(sncoef+kdim*kj,scoef+kdim*ki,kdim,DOUBLE);\n            kj++;\n          }\n    }\n  \n  for (ki=kn ; ki<kn+kk ; ki++,kj++)\n    snt[kj] = st[ki];\n  \n  knnew = kj - kk;\n  \n  /* An additional end knot might have been left */\n  \n  if (snt[knnew-1] == snt[knnew+kk-1]) knnew--;\n  \n  /* Put compressed description back to curve object */      \n  \n  if (pc->icopy > 0)\n    {\n      pc -> in = knnew;\n      memcopy(pc->et,snt,knnew+kk,DOUBLE);\n      memcopy(pc->ecoef,sncoef,knnew*kdim,DOUBLE);\n      if (kind == 2 || kind == 4)\n        memcopy(pc->rcoef,srcoef,knnew*rdim,DOUBLE);\n      kstat = 1;\n    }\n  \n  /* Task done. */\n  \n  *jstat = kstat;\n  goto out;\n  \n  /* Error in space allocation. */\n  \n  err101: \n    *jstat = -101;\n    goto out;\n  \n  out:\n    if (snt != SISL_NULL) freearray(snt);\n    if (sncoef != SISL_NULL) freearray(sncoef);\n}\n"
  },
  {
    "path": "src/s6curvrad.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6curvrad.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6CURVRAD\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      s6curvrad(double epnt1[],double epnt2[],double etang[],int idim,\n\t\tdouble *crad,int *jstat)\n#else\t \nvoid s6curvrad(epnt1,epnt2,etang,idim,crad,jstat)\n     int idim,*jstat;\n     double epnt1[],epnt2[],etang[],*crad;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Given both endpoints of a curve segment and the tangent in\n*              one of the endpoints, estimate the curvature radius of the \n*              curve segment in the endpoint where the tangent is given.\n*\n*\n* INPUT      : epnt1   - First endpoint.\n*              epnt2   - Second endpoint.\n*              etang   - Given tangent.\n*              idim    - Dimension of geometry space.\n*                       \n*\n* OUTPUT     : crad    - Estimated curvature radius.\n*              jstat   - status messages  \n*                                         = 1      : Tangent vector zero.\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Pass a circle through the points having the given tangent\n*              in the given endpoint. Compute the radius of this circle.\n*\n* REFERENCES : \n*\n* USE        : \n*\n*-\n* CALLS      : s6dist - Distance between two points.  \n*              s6diff - Difference vector between two vectors. \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.90.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;        /* Status variable.                  */\n  double tdist;         /* Distance between the endpoints.   */\n  double tdot;          /* Scalar product between tangent and vector\n                           between endpoints.                */\n  double tlmid;         /* Length of tangent vector.         */\n  double tcos;          /* Cosinus to the angle between the tangent\n                           and the vector between the endpoints. */\n  double tang;          /* Angle at the centre of the circle\n                           between the vectors from origo to\n                           the given endpoints.              */\n  double tdum;          /* Denominator in expression to find \n                           the  radius of the circle.        */\n  double trad;          /* The curvature radius, i.e. the radius\n                           of the circle.                    */\n  double sdiff[3];      /* Difference vector between the endpoints. */\n  \n  /* Test input.  */\n\n  if (idim != 3) goto err104;\n  \n  /* Estimate curvature radius based on endpoints and tangent.  */\n\n  tdist = s6dist(epnt1,epnt2,idim);\n  s6diff(epnt2,epnt1,idim,sdiff);\n\n  tdot = s6scpr(etang,sdiff,idim);\n  tlmid = s6length(etang,idim,&kstat);\n  \n  tcos = (tlmid*tdist != DZERO) ? fabs(tdot/(tlmid*tdist)) : fabs(tdot);\n  tcos = MIN((double)1.0,tcos);\n  \n  tang = 2*acos(tcos);\n  tdum = sqrt(2-2*cos(tang));\n  trad = (tdum > REL_COMP_RES) ? tdist/tdum : -1.0;\n  \n  /* Set curvature radius. */\n  \n  *crad = trad;\n  *jstat = 0;\n  goto out;\n\n  /* Error in input.  */\n\n  err104 :\n    *jstat = -104;\n  goto out;\n\n  out :\n    return;\n}    \n"
  },
  {
    "path": "src/s6decomp.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6decomp.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6DECOMP\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6decomp(double ea[],double gx[],double eb1[],double eb2[],double eb3[],int *jstat)\n#else\nvoid s6decomp(ea,gx,eb1,eb2,eb3,jstat)\n     double ea[];\n     double gx[];\n     double eb1[];\n     double eb2[];\n     double eb3[];\n     int    *jstat;\n#endif\n/*\n***********************************************************************\n*\n************************************************************************\n*\n*   PURPOSE : In dimention tree we change basis from a euclides bases\n*             to eb1, eb2, eb3.\n*\n*\n*   INPUT   : ea   - The orginale vector.\n*             eb1  - the first bases vector.\n*             eb2  - the first bases vector.\n*             eb3  - the first bases vector.\n*\n*\n*   \n*   OUTPUT  : gx    - The new vector\n*             jstat - Status variable.\n*                       < 0 : error\n*                       = 0 : ok\n*                       > 0 : warning\n*\n*\n*   METHOD  : \n*\n*\n*   REFERENCES : \n*-\n*   CALLS      :\n*\n*   WRITTEN BY : Arne Laksaa, SI, 89-07.\n*\n************************************************************************\n*/\n{\n  int kstat =0;       /* Local status variable.    */\n  int ki;             /* Counter.                  */\n  int n1[3];          /* Array for use in lufac.   */\n  double sc[9],se[3]; /* Matrix and help vector.   */\n  \n  \n  /* Copy new bases into local matrix.  */\n  \n  memcopy(sc,eb1,3,double);\n  memcopy(sc+3,eb2,3,double);\n  memcopy(sc+6,eb3,3,double);\n  \n  \n  s6lufacp(sc,n1,3,&kstat);\n  if (kstat < 0) goto error;\n  else if (kstat > 0) goto warn1;\n  \n  for (ki=0; ki<3; ki++)\n    {                      \n      se[0] = se[1] = se[2] = DZERO;\n      se[ki] = (double)1;\n      \n      s6lusolp(sc,se,n1,3,&kstat);\n      if (kstat < 0) goto error;\n      else if (kstat > 0) goto warn1;\n      \n      gx[ki] = s6scpr(ea,se,3);\n    }\n  \n  /* Change of bases performed.  */\n  \n  *jstat = 0;\n  goto out;\n\n/* Singular equation system.  */\n\nwarn1 : *jstat = 1;\n        goto out;\n\n/* Error in subrutines.  */\n\nerror: *jstat = kstat;\n        s6err(\"s6decomp\",*jstat,0);\n        goto out;\n\n out: ;\n}\n\n                                    \n\n                                        \n"
  },
  {
    "path": "src/s6degnorm.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6degnorm.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S6DEGNORM\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   s6degnorm(SISLSurf *ps1,int ider,double epar[],double eder[],\n\t\tdouble utang[],double vtang[],double enorm[],int *jstat)\n#else\nvoid s6degnorm(ps1,ider,epar,eder,utang,vtang,enorm,jstat)\n     SISLSurf   *ps1;\n     int    ider;\n     double epar[];\n     double eder[];\n     double utang[];\n     double vtang[];\n     double enorm[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Evaluate the (3d) surface tangents and normal\n*              (at an edge or corner) when the surface is\n*              degenerate (at an edge or corner).\n*              All three vectors (if found) are normalised to length 1.\n*         \n*\n*\n* INPUT      : ps1    - Pointer to the surface to evaluate.\n*              ider   - Number of derivatives calculated.\n*                       Must be >=2.\n*              epar   - Parameter-value at which to calculate. Dimension\n*                       of epar is 2.\n*              eder   - Array where the derivative of the curve in\n*                       apar is placed. The sequence is position,\n*                       first derivative in first parameter direction,\n*                       first derivative in second parameter direction,\n*                       (2,0) derivative, (1,1) derivative, (0,2) \n*                       derivative, etc. Dimension of eder is \n*                       idim*(1+2+...+(ider+1)).\n*             \n*\n* OUTPUT     : utang -  Tangent to surface in u direction, length 1.\n*              vtang -  Tangent to surface in v direction, length 1.\n*              enorm  - Normal of surface, length 1.\n*              jstat  - status messages  \n*                             = 4      : Nothing found.\n*                                        both tangents and normal are 0.\n*                             = 3      : Only v tangent found.\n*                                        u tangent and normal are 0.\n*                             = 2      : Only u tangent found.\n*                                        v tangent and normal are 0.\n*                             = 1      : Only the tangents found.\n*                                        Normal is 0.\n*                             = 0      : OK. Both tangents and\n*                                        normal are length 1.\n*                             < 0      : error\n*                      \n*\n* METHOD     :  Find the smallest non-zero derivatives and\n*               use them in a Taylor expansion.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : \n*\n* WRITTEN BY : Michael Floater, 17/1/92.\n* Revised by : Christophe Rene Birkeland, SINTEF OSLO, June 1993.\n*   \n*********************************************************************\n*/                                     \n{\n  int kstat=0;        /* Local status variable.                          */\n  int kpos=0;         /* Position of error.                              */\n  int kdim;           /* Dimension of the space in which the surface lies. */\n  int ki;             /* Control variables in for loop                   */\n  double *et1,*et2;   /* Local pointer to knot vectors. */\n  int in1,in2;        /* Number of points in ps1 in the 2 direcs. */\n  int ik1,ik2;        /* Degree of ps1 in the 2 direcs. */\n  double upar,vpar;   /* Parameter values. */\n  double *xu,*xv;         /* Pointers to first derivatives. */\n  double *xuu,*xuv,*xvv;  /* Pointers to second derivatives. */\n  double len;        /* Vector length. */\n  int ius,ivs,is;    /* Flags. u=min => ius = 1, u=max => ius = -1. */\n  int endu,endv;     /* Flags for whether u or v are extreme. */\n  int iu,iv;         /* Which first derivs are zero? */\n  int iuu,iuv,ivv;   /* Which second derivs are zero? */\n  double vec[3];     /* Temporary vector. */\n  double vec1[3],vec2[3];  /* Temporary vectors. */\n  double normal[3];  /* Temporary normal. */\n  int usuccess;      /* Flag if u tangent found. */\n  int vsuccess;      /* Flag if v tangent found. */\n  \n  \n  /* Set up local variables. */\n\n  kdim = ps1 -> idim;\n  et1 = ps1 -> et1;\n  et2 = ps1 -> et2;\n  in1 = ps1 -> in1;\n  in2 = ps1 -> in2;\n  ik1 = ps1 -> ik1;\n  ik2 = ps1 -> ik2;\n\n  /* Check input. */\n\n  if(kdim != 3) goto err101;\n  if(ider < 2) goto err101;\n  \n\n  upar = epar[0];\n  vpar = epar[1];\n\n  xu  = eder + kdim;\n  xuu = xu   + kdim;\n  xv  = xuu  + kdim;\n  xuv = xv   + kdim;\n  xvv = xuv  + kdim + kdim;\n\n  /* Find out whether (u,v) is at a corner, edge or in the\n     middle of the surface ps1. */\n\n  ius = 0;\n  ivs = 0;\n  is = 0;\n\n  if(upar == et1[ik1-1])\n  {\n      endu = TRUE;\n      ius = 1;\n  }\n  else if(upar == et1[in1])\n  {\n      endu = TRUE;\n      ius = -1;\n  }\n  else\n  {\n      endu = FALSE;\n  }\n\n  if(vpar == et2[ik2-1])\n  {\n      endv = TRUE;\n      ivs = 1;\n  }\n  else if(vpar == et2[in2])\n  {\n      endv = TRUE;\n      ivs = -1;\n  }\n  else\n  {\n      endv = FALSE;\n  }\n\n  if(endu && endv) is = ius * ivs;\n\n  if(!endu && !endv) goto err101;\n\n  /* For each derivative, set flag to 0 or 1 according to\n     whether the length is 0 or non-zero. */\n\n  len = s6length(xu,kdim,&iu);\n  len = s6length(xv,kdim,&iv);\n  len = s6length(xuu,kdim,&iuu);\n  len = s6length(xuv,kdim,&iuv);\n  len = s6length(xvv,kdim,&ivv);\n\n\n  /* Calculate tangent in u using higher derivatives. */\n\n  usuccess = FALSE;\n\n  if(iu == 0)\n  {\n      if(endu && iuu == 1)\n      {\n          len = s6norm(xuu,kdim,vec,&kstat);\n          for(ki=0; ki<kdim; ki++) vec[ki]*=ius;\n          usuccess = TRUE;\n      }\n      else if(endv && iuv == 1)\n      {\n          len = s6norm(xuv,kdim,vec,&kstat);\n          for(ki=0; ki<kdim; ki++) vec[ki]*=ivs;\n          usuccess = TRUE;\n      }\n  }\n  else\n  {\n      len = s6norm(xu,kdim,vec,&kstat);\n      usuccess = TRUE;\n  }\n\n\n  if(usuccess)\n  {\n      /* u tangent found. Return result. */\n\n      for(ki=0; ki<kdim; ki++) utang[ki] = vec[ki];\n  }\n  else\n  {\n      /* No u tangent found. Return zero and flag. */\n\n      for(ki=0; ki<kdim; ki++) utang[ki] = (double)0.0;\n  }\n\n  /* Calculate tangent in v using higher derivatives. */\n\n  vsuccess = FALSE;\n\n  if(iv == 0)\n  {\n      if(endu && iuv == 1)\n      {\n          len = s6norm(xuv,kdim,vec,&kstat);\n          for(ki=0; ki<kdim; ki++) vec[ki]*=ius;\n          vsuccess = TRUE;\n      }\n      else if(endv && ivv == 1)\n      {\n          len = s6norm(xvv,kdim,vec,&kstat);\n          for(ki=0; ki<kdim; ki++) vec[ki]*=ivs;\n          vsuccess = TRUE;\n      }\n  }\n  else\n  {\n      len = s6norm(xv,kdim,vec,&kstat);\n      vsuccess = TRUE;\n  }\n\n\n  if(vsuccess)\n  {\n      /* v tangent found. Return result. */\n\n      for(ki=0; ki<kdim; ki++) vtang[ki] = vec[ki];\n  }\n  else\n  {\n      /* No v tangent found. Return zero and flag. */\n\n      for(ki=0; ki<kdim; ki++) vtang[ki] = (double)0.0;\n  }\n\n\n  /* Calculate normal using higher derivatives. */\n\n  if(iu == 0)\n  {\n      if(iv == 0)\n      {\n\t  if(endu && iuu == 1 && iuv == 1)\n\t  {\n\t      s6crss(xuu,xuv,vec);\n\t      len = s6norm(vec,kdim,normal,&kstat);\n\t      if(kstat == 1) goto normfound;\n\t  }\n\t  if(endv && iuv == 1 && ivv == 1)\n\t  {\n\t      s6crss(xuv,xvv,vec);\n\t      len = s6norm(vec,kdim,normal,&kstat);\n\t      if(kstat == 1) goto normfound;\n\t  }\n\t  if(endu && endv && iuu == 1 && ivv == 1)\n\t  {\n\t      s6crss(xuu,xvv,vec);\n\t      for(ki=0; ki<kdim; ki++) vec[ki]*=is;\n\t      len = s6norm(vec,kdim,normal,&kstat);\n\t      if(kstat == 1) goto normfound;\n\t  }\n      }\n      else\n      {\n\t  if(endu && iuu == 1)\n\t  {\n\t      s6crss(xuu,xv,vec);\n\t      for(ki=0; ki<kdim; ki++) vec[ki]*=ius;\n\t      len = s6norm(vec,kdim,normal,&kstat);\n\t      if(kstat == 1) goto normfound;\n\t  }\n\t  if(endv && iuv == 1)\n\t  {\n\t      s6crss(xuv,xv,vec);\n\t      for(ki=0; ki<kdim; ki++) vec[ki]*=ivs;\n\t      len = s6norm(vec,kdim,normal,&kstat);\n\t      if(kstat == 1) goto normfound;\n\t  }\n      }\n  }\n  else\n  {\n      if(iv == 0)\n      {\n\t  if(endu && iuv == 1)\n\t  {\n\t      s6crss(xu,xuv,vec);\n\t      for(ki=0; ki<kdim; ki++) vec[ki]*=ius;\n\t      len = s6norm(vec,kdim,normal,&kstat);\n\t      if(kstat == 1) goto normfound;\n\t  }\n\t  if(endv && iuv == 1)\n\t  {\n\t      s6crss(xuv,xv,vec);\n\t      for(ki=0; ki<kdim; ki++) vec[ki]*=ivs;\n\t      len = s6norm(vec,kdim,normal,&kstat);\n\t      if(kstat == 1) goto normfound;\n\t  }\n      }\n      else\n      {\n\t  if(endu && (iuu == 1 || iuv == 1))\n\t  {\n\t      s6crss(xuu,xv,vec1);\n\t      s6crss(xu,xuv,vec2);\n\t      for(ki=0; ki<kdim; ki++) vec[ki]=vec1[ki]+vec2[ki];\n\t      for(ki=0; ki<kdim; ki++) vec[ki]*=ius;\n\t      len = s6norm(vec,kdim,normal,&kstat);\n\t      if(kstat == 1) goto normfound;\n\t  }\n\t  if(endv && (iuv == 1 || ivv == 1))\n\t  {\n\t      s6crss(xuv,xv,vec1);\n\t      s6crss(xu,xvv,vec2);\n\t      for(ki=0; ki<kdim; ki++) vec[ki]=vec1[ki]+vec2[ki];\n\t      for(ki=0; ki<kdim; ki++) vec[ki]*=ivs;\n\t      len = s6norm(vec,kdim,normal,&kstat);\n\t      if(kstat == 1) goto normfound;\n\t  }\n      }\n  }\n\n  /* No normal found. Return zero and flag. */\n\n  for(ki=0; ki<kdim; ki++) enorm[ki] = (double)0.0;\n\n  /* Set diagnostics flag. */\n  if(usuccess)\n  {\n      if(vsuccess) *jstat = 1;\n      else *jstat = 2;\n  }\n  else\n  {\n      if(vsuccess) *jstat = 3;\n      else *jstat = 4;\n  }\n  goto out;\n\n   /* Normal found and hence tangents found. Return result. */\n\nnormfound:\n\n  for(ki=0; ki<kdim; ki++) enorm[ki] = normal[ki];\n  *jstat = 0;\n  goto out;\n\n\n  /* Error in input. */\n\nerr101: *jstat = -101;\n  s6err(\"s6degnorm\",*jstat,kpos);\n  goto out;\n  \n  \n out:\n  \n  return;\n}\n\n"
  },
  {
    "path": "src/s6dertopt.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6dertopt.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6DERTOPT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s6dertopt(double eder[],int ntype[],int inpt,int idim,\n\t       double epoint[],int *jstat)\n#else\nvoid s6dertopt(eder,ntype,inpt,idim,epoint,jstat)\n   double eder[];\n   int    ntype[];\n   int    inpt;\n   int    idim;\n   double epoint[];\n   int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Translate derivateve conditions in an interpolation\n*              problem to position conditions.\n*\n*\n*\n* INPUT      : eder   - Array of interpolation conditions. The last\n*                       condition must be a point. Dimension is inpt*idim.\n*              ntype  - Array containing kind of condition. Dimension \n*                       is inpt.\n*                       =  0 : A point is given.\n*                       =  d : The d'th derivatative condition to the\n*                              previous point is given.\n*                       = -d : The d'th derivatative condition to the\n*                              next point is given.\n*              inpt   - Number of interpolation conditions.\n*              idim   - Dimension of geometry space.\n*              \n*\n* OUTPUT     : epoint - Positional interpolation conditions.\n*                       The dimension is inpt*idim.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6lufacp  -  LU-factorization of matrix.\n*              s6lusolp  -  Solve equation system.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 91-04.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;        /* Status variable.                        */\n   int ki,kj,kk,kh,kl;   /* Counters.                               */\n   int kord;             /* Order of Bezier segment.                */\n   int kder;             /* Order of derivative condition.          */\n   int ksgn;             /* Indicates endpoint of Bezier segment.   */\n   int *lpiv = SISL_NULL;     /* Pivot array.                            */\n   double *sc = SISL_NULL;    /* Matrix of equation system.              */\n   double *sd = SISL_NULL;    /* Right side of equation system.          */\n   double *s1;           /* Pointer into matrix of equation system. */\n   double *spt;          /* Pointer to interpolation condition.     */\n   double *sdum1 = SISL_NULL; /* Help array.                             */\n   double *sdum2 = SISL_NULL; /* Help array.                             */\n   \n   /* Test if the last condition is a point. */\n   \n   if (ntype[inpt-1] != 0) goto err151;\n   \n   /* Copy interpolation conditions to output array. */\n   \n   memcopy(epoint,eder,inpt*idim,DOUBLE);\n   \n   /* Allocate scratch for equation system. Make sure that the arrays\n      are large enough.  */\n   \n   if ((sc = newarray(inpt*inpt,DOUBLE)) == SISL_NULL) goto err101;\n   if ((sd = newarray(inpt,DOUBLE)) == SISL_NULL) goto err101;\n   if ((lpiv = newarray(inpt,INT)) == SISL_NULL) goto err101;\n   \n   /* Allocate scratch for local help arrays. */\n   \n   if ((sdum1 = newarray(idim,DOUBLE)) == SISL_NULL) goto err101;\n   if ((sdum2 = newarray(idim,DOUBLE)) == SISL_NULL) goto err101;\n   \n   /* Traverse interpolation conditions. */\n   \n   for (ki=0; ki<inpt; ki=kj)\n   {\n      for (kj=ki+1; kj<inpt && ntype[kj]!=0; kj++);\n      \n      if (kj-ki > 1)\n      {\n\t /* A derivative condition is found. Express the segment between\n\t    two positional conditions as a Bezier segment in [0,1]. The \n\t    order is given by the number of derivative conditions. First\n\t    put up matrix of equation system. */\n\t \n\tkord = kj - ki + 1;  /* Order of Bezier segment.  */\n\t\n\t/* Traverse conditions.  */\n\t\n\tfor (kk=0, s1=sc; kk<kord; kk++, s1+=kord)\n\t{\n\t   /* Set line of matrix to zero.  */\n\t   \n\t   for (kh=0; kh<kord; kh++) s1[kh] = DZERO;\n\t   \n\t   /* Fetch order of differentiation and endpoint of Bezier\n\t      segment.  */\n\t   \n\t   kder = abs(ntype[ki+kk]);\n\t   ksgn = (ntype[ki+kk] > 0) ? 1 : -1;\n\t   if (kk == 0) ksgn = 1;\n\t   \n\t   if (ksgn == 1)\n\t   {\n\t      /* Condition in startpoint of segment. Initiate to\n\t\t positional condition.  */\n\t      \n\t      s1[0] = (double)1.0;\n\t      \n\t      /* Compute coefficients to derivative of segment recursively. */\n\t      \n\t      for (kh=0; kh<kder; kh++)\n\t      {\n\t\t for (kl=kder; kl>0; kl--)\n\t\t    s1[kl] = (double)(kord-1)*(s1[kl-1] - s1[kl]);\n\t\t s1[0] *= -(double)(kord-1);\n\t      }\n\t   }\n\t   else\n\t   {\n\t      /* Condition in endpoint of segment. */\n\t      \n\t      s1[kord-1] = (double)1.0;\n\t      for (kh=0; kh<kder; kh++)\n\t      {\n\t\t for (kl=kord-kder-1; kl<kord-1; kl++)\n\t\t    s1[kl] = (double)(kord-1)*(s1[kl]-s1[kl+1]);\n\t\t s1[kord-1] *= (double)(kord-1);\n\t      }\n\t   }\n\t}\n\t\n\t/* Perform LU-factorization of matrix.  */\n\t\n\ts6lufacp(sc,lpiv,kord,&kstat);\n\tif (kstat < 0) goto error;\n\t\t       \n        for (kh=0; kh<idim; kh++)\n\t{\n\t   /* Set up right side of equation system.  */\n\t   \n\t   for (kk=0; kk<kord; kk++) sd[kk] = epoint[(ki+kk)*idim+kh];\n\t   \n\t   /* Solve equation system. */\n\t   \n\t   s6lusolp(sc,sd,lpiv,kord,&kstat);\n\t   if (kstat < 0) goto error;\n\t\t\t  \n  \t   /* Move result into condition array.  */\n\t\n\t   for (kk=1; kk<kord-1; kk++) epoint[(ki+kk)*idim+kh] = sd[kk];\n\t}\n\t\n\t/* Now the output array contains the coefficients of a Bezier\n\t   segment at the current position. Estimate positional\n\t   conditions that would give about the same Bezier segment. */\n\t\n\tmemcopy(sdum1,epoint+ki*idim,idim,DOUBLE);\n\tfor (kk=ki+1, spt=epoint+kk*idim; kk<kj; kk++, spt+=idim)\n\t{\n\t   /* Traverse inner coefficients of segment. */\n\t   \n\t   memcopy(sdum2,spt,idim,DOUBLE);\n\t   for (kh=0; kh<idim; kh++)\n\t      spt[kh] = (double)0.25*(sdum1[kh]+spt[idim+kh])\n\t\t + (double)0.5*spt[kh];\n\t   memcopy(sdum1,sdum2,idim,DOUBLE);\n\t}\n      }\n   }\n   \n   /* Derivative conditions translated.  */\n   \n   *jstat = 0;\n   goto out;\n   \n   /* Error in scratch allocation.  */\n   \n   err101 : *jstat = -101;\n   goto out;\n   \n   /* Illegal interpolation point.  */\n   \n   err151 : *jstat = -151;\n   goto out;\n   \n   /* Error in lower level routine.  */\n   \n   error : *jstat = kstat;\n   goto out;\n   \n   out :\n      /* Free scratch occupied by local arrays. */\n      \n      if (sc != SISL_NULL) freearray(sc);\n      if (sd != SISL_NULL) freearray(sd);\n      if (lpiv != SISL_NULL) freearray(lpiv);\n      if (sdum1 != SISL_NULL) freearray(sdum1);\t\t\t\n      if (sdum2 != SISL_NULL) freearray(sdum2);\n\t\t\t \n      return;\n}\n"
  },
  {
    "path": "src/s6diff.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6diff.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S6DIFF\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6diff(double e1[],double e2[],int idim,double e3[])\n#else\nvoid s6diff(e1,e2,idim,e3)\n     double e1[];\n     double e2[];\n     double e3[];\n     int    idim;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate the difference between two vectors\n*\n* INPUT      : e1      - The first vector\n*              e2      - The second vector\n*              idim    - Number of dimensions in the space the vectors lie\n*\n* OUTPUT     : \n*              e3      - The difference of e1 and e2\n*\n* METHOD     : The difference is calculated by vetor substraction\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. 1988-june-1988\n*                                  \n*********************************************************************\n*/\n{\n  int ki;\n  for (ki=0;ki<idim;ki++)\n    e3[ki] = e1[ki] - e2[ki];\n  return;\n}\n"
  },
  {
    "path": "src/s6dist.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6dist.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6DIST\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\ndouble \ns6dist(double epoint1[],double epoint2[],int idim)\n#else\ndouble s6dist(epoint1,epoint2,idim)\n     double epoint1[];\n     double epoint2[];\n     int    idim;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Compute the distance between the points epoint1 and\n*              epoint2.\n*\n*\n*\n* INPUT      : epoint1 - First point in distance calculation.\n*              epoint2 - Second point in distance calculation.\n*              idim    - Dimension of the space in which the points lie.\n*\n*\n*\n* OUTPUT     : s6dist  - Distance between the points.\n*\n*\n* METHOD     : Compute lenght of the vector epoint1-epoint2.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-06.\n*\n*********************************************************************\n*/                                     \n{\n  register double *s1,*s2,*s3; /* Pointers used to travers epoint1 and epoint2\n\t\t\t\t  arrays.                                      */\n  register double tdist=DZERO; /* Distance between the points.                 */\n  \n  for (s1=epoint1,s2=epoint2,s3=epoint1+idim; s1<s3; s1++,s2++)\n    tdist += (*s1 - *s2)*(*s1 - *s2);\n  \n  return(sqrt(tdist));\n}\n"
  },
  {
    "path": "src/s6dline.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6dline.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6DLINE\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\ndouble\n  s6dline(double estart[],double eend[],double epoint[],\n\t  int idim,int *jstat)\n#else\ndouble s6dline(estart,eend,epoint,idim,jstat)\n   double estart[];\n   double eend[];\n   double epoint[];\n   int    idim;\n   int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Compute the distance between a line segment and a point.\n*\n*\n*\n* INPUT      : estart - Start point of line segment. Dimension is idim.\n*              eend   - End point of line segment. Dimension is idim.\n*              epoint - Point. Dimension is idim.\n*              idim   - Dimension of geometry space.\n*\n*\n*\n* OUTPUT     : s6dline - Distance between line and point.\n*              jstat   - status messages \n*                        = 2      : Zero line segment. Closest point\n*                                   is outside segment.\n*                        = 1      : Closest point on the extended\n*                                   line through estart and end is\n*                                    outside the segment.\n*                        = 0      : ok\n*                        < 0      : error\n*\n*\n* METHOD     : \n*              \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6scpr   -  Scalar product between two vectors.\n*              s6diff   -  Difference vector between two vectors.  \n*              s6length -  Length of vector.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 91-02.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;         /* Local status varaible.           */\n   int ki;                /* Counter.                         */\n   double tpar;           /* Parameter of closest point.      */\n   double tdist;          /* Distance between point and line. */\n   double t1;             /* Scalar product.                  */\n   double *sline = SISL_NULL;  /* Line vector.                     */\n   double *sdiff = SISL_NULL;  /* Difference vector.               */\n   \n   /* Allocate scratch for local vectors.  */\n   \n   if ((sline = newarray(idim,DOUBLE)) == SISL_NULL) goto err101;\n   if ((sdiff = newarray(idim,DOUBLE)) == SISL_NULL) goto err101;\n   \n   /* Compute help vectors.  */\n   \n   s6diff(eend,estart,idim,sline);\n   s6diff(epoint,estart,idim,sdiff);\n   \n   /* Compute parameter of closest point. */\n   \n   t1 = s6scpr(sline,sline,idim);\n   if (t1 <= REL_COMP_RES) \n   {\n      /* Compute distance between point and first endpoint of line. */\n      \n      tdist = s6dist(estart,epoint,idim);\n       \n      /* Set a warning.  */\n      \n      *jstat = 2;\n      goto out;\n   }\n   \n   tpar = s6scpr(sline,sdiff,idim)/t1;\n   \n   /* Compute vector between input point and closest point on\n      line.      */\n   \n   for (ki=0; ki<idim; ki++)\n      sdiff[ki] = estart[ki] + tpar*sline[ki] - epoint[ki];\n   \n   /* Compute length of vector.  */\n   \n   tdist = s6length(sdiff,idim,&kstat);\n   \n   /* Set status.  */\n   \n   *jstat = (tpar < 0 || tpar > 1) ? 1 : 0;\n   goto out;\n   \n   /* Error in scratch allocation.  */\n   \n   err101 : *jstat = -101;\n   goto out;\n   \n   out :\n      /* Free space occupied by local arrays.  */\n      \n      if (sline != SISL_NULL) freearray(sline); \n      if (sdiff != SISL_NULL) freearray(sdiff);\n\t\t\t \n      return tdist;\n }\n"
  },
  {
    "path": "src/s6dplane.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6dplane.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S6DPLANE\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\ndouble\n  s6dplane(double eq1[],double eq2[],double eq3[],double epoint[],\n\t   int idim,int *jstat)\n#else\ndouble s6dplane(eq1,eq2,eq3,epoint,idim,jstat)\n   double eq1[];\n   double eq2[];\n   double eq3[];\n   double epoint[];\n   int    idim;\n   int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Compute the distance between a plane given by three\n*              points in the plane and a fourth point.\n*\n*\n*\n* INPUT      : eq1    - Point in the plane\n*              eq2    - Point in the plane\n*              eq3    - Point in the plane\n*              epoint - Point. Dimension is idim.\n*              idim   - Dimension of geometry space.\n*\n*\n*\n* OUTPUT     : s6dplane - Distance between plane and point.\n*              jstat   - status messages  \n*                        > 0      : warning\n*                        = 0      : ok\n*                        < 0      : error\n*\n*\n* METHOD     : \n*              \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6scpr   -  Scalar product between two vectors.\n*              s6diff   -  Difference vector between two vectors.  \n*              s6norm   -  Normalize vector.\n*              s6crss   -  Cross product between two vectors.\n*              s6dist   -  Distance between points.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 91-02.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;         /* Local status varaible.           */\n   double tdist;          /* Distance between point and line. */\n   double snorm[3];       /* Normal vector to the plane.      */\n   double sdiff1[3];      /* Difference vector between points in the plane. */\n   double sdiff2[3];      /* Difference vector between points in the plane. */\n   double sdiff3[3];      /* Difference vector.               */\n   \n   /* Test dimension.     */\n   \n   if (idim != 3) goto err104;\n   \n   /* Compute difference vectors.  */\n   \n   s6diff(eq2,eq1,idim,sdiff1);\n   s6diff(eq3,eq1,idim,sdiff2);\n   s6diff(epoint,eq1,idim,sdiff3);\n   \n   /* Compute normalized plane normal.  */\n   \n   s6crss(sdiff1,sdiff2,snorm);\n   (void)s6norm(snorm,idim,snorm,&kstat);\n   \n   /* Compute distance to closest point in plane. */\n   \n   if (kstat)\n      tdist = fabs(s6scpr(sdiff3,snorm,idim));\n   else \n      tdist = s6dist(eq1,epoint,idim);   /* Normal of zero length.  */\n\n   /* Set status.  */\n   \n   *jstat = 0;\n   goto out;\n   \n   /* Error in input, dimension not equal to 3.  */\n   \n   err104 : *jstat = -104;\n   goto out;\n   \n   out :\n      return tdist;\n }\n"
  },
  {
    "path": "src/s6drawseq.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6drawseq.c,v 1.3 1994-12-19 16:58:19 pfu Exp $\n *\n */\n\n\n#define S6DRAWSEQ\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nextern void s6move(DOUBLE[]);\nextern void s6line(DOUBLE[]);\n#else\nextern void s6move();\nextern void s6line();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n  s6drawseq(double epoint[],int ipoint)\n#else\nvoid s6drawseq(epoint,ipoint)\n     double epoint[];\n     int ipoint;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Draw a broken line as a sequence of straight lines\n*              described by the array epoint.\n*\n*\n*\n* INPUT      : epoint - Array describing the corners of the broken line\n*                       to draw. Each corner is given as a 3-dimensional\n*                       point. The corners is placed continuous in the\n*                       array.\n*              ipoint - Number of points in epoint.\n*\n*\n* OUTPUT     :\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* REMARK     : This routine is machine-dependant and the internal of\n*              this routine has to be reprogrammed if the functions\n*              s6move() and s6line() are not defined for your graphics\n*              sub-system.\n*\n*\n*-\n* CALLS      : s6move - Place pen at given position (empty dummy routine).\n*              s6line - Draw a line from the current position to the given one\n*                       (empty dummy routine).\n*\n* WRITTEN BY :\n*\n*********************************************************************\n*/\n{\n  int ki;          /* Counter.                                    */\n  double *spoint;  /* Pointer to corner point in the broken line. */\n\n  /* Position pen at start of the broken line.  */\n\n  s6move(epoint);\n\n  /* Draw sequence of line-segments.  */\n\n  for (ki=1,spoint=epoint+3; ki<ipoint; ki++,spoint+=3)\n    s6line(spoint);\n\n  return;\n}\n"
  },
  {
    "path": "src/s6equal.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6equal.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6EQUAL\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nint \ns6equal(double a1,double a2,double aref)\n#else\nint s6equal(a1,a2,aref)\n     double a1;\n     double a2;\n     double aref;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Test if two numbers are equal.\n*\n*\n*\n* INPUT      : a1     - First number.\n*              a2     - Second number.\n*              aref   - Reference value.\n*\n*\n*\n* OUTPUT     : s6equal - Tells if numbers are equal.\n*                        = 1 : Equal.\n*                        = 0 : Not equal.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n*\n*********************************************************************\n*/\n{\n  double tval;   /* Number used to test equality.  */\n  \n  tval = a1 - a2;\n  tval += aref;\n  tval -= aref;\n  \n  return(DEQUAL(tval,DZERO));\n}\n\n\n"
  },
  {
    "path": "src/s6err.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6err.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S6ERR\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid s6err(char *rut,int jstat,int ipos)\n#else\nvoid s6err(rut,jstat,ipos)\n     char *rut;\n     int  jstat;\n     int  ipos;\n#endif\n{\n   (void)fprintf(stderr,\"\\nError status : %d\",jstat);\n   (void)fprintf(stderr,\"   Call from routine : %s\",rut);\n   (void)fprintf(stderr,\"   Position : %d\\n\",ipos);\n}\n"
  },
  {
    "path": "src/s6existbox.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6existbox.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6EXISTBOX\n\n#include \"sislP.h\" \n\n#if defined(SISLNEEDPROTOTYPES)\nint s6existbox(SISLbox *pbox,int itype,double aepsge)\n#else\nint s6existbox(pbox,itype,aepsge)\n     SISLbox *pbox;\n     int    itype;\n     double aepsge;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Test if a particular box exist within an existing\n*              box instance.\n*\n*\n*\n* INPUT      : pbox   - Box to test.\n*              itype  - Kind of box to test existance of.\n*                       = 0 : Do not expand box.\n*                       = 1 : Make a totally expanded box.\n*                       = 2 : Make a box expanded in the inner of the\n*                             object, and reduced along the edges/endpoints.\n*              aepsge - Geometry resolution.\n*\n* OUTPUT     : s6existbox -  Status.\n*                            -1 : Kind of box exist, but is expanded\n*                                 with another tolerance.\n*                             0 : Kind of box do not exist.\n*                             1 : Requested box exist.\n*                                                                     \n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :  \n*\n* WRITTEN BY : Vibeke Skytt, SI, 91-01.\n*\n*********************************************************************\n*/                                     \n{\n   if (pbox->e2min[itype] == SISL_NULL) return(0);  /* No box is made. */\n   \n   if (itype != 0 && DNEQUAL(pbox->etol[itype],aepsge))\n      return(-1);  /* Box exist, but with another size of the expansion. */\n   \n   return(1);\n}\n   \n"
  },
  {
    "path": "src/s6findfac.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6findfac.c,v 1.4 2005-02-28 09:04:49 afr Exp $\n *\n */\n\n\n#define S6FINDFAC\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6findfac(double evecu[],double evecv[],double evecw[],double etang[],\n               int idim,int isign,double *coef1,double *coef2,double *coef3,int *jstat)\n\n#else\nvoid s6findfac(evecu,evecv,evecw,etang,idim,isign,coef1,coef2,coef3,jstat)\n     double evecu[];\n     double evecv[];\n     double evecw[];\n     double etang[];\n     int    idim;\n     int    isign;\n     double *coef1;\n     double *coef2;\n     double *coef3;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Given four vectors, evecu, evecv, evecw and etang, find \n*              the factors, coef1, coef2 and coef3, such that the vector\n*              coef1*evecu + coef2*evecv + coef3*evecw = isign*etang.\n*              \n*\n* INPUT      : evecu      - First vector.\n*              evecv      - Second vector.\n*              evecw      - Third vector.\n*              etang      - Vector to approximate.\n*              idim       - Dimension of geometry space.\n*              isign      - Sign with wich etang is to be multiplied.\n*\n*\n* OUTPUT     : coef1      - First factor.\n*              coef2      - Second factor.\n*              coef3      - Third factor.\n*              jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Minimize the square of the expression \n*                   dist(coef1*evecu+coef2*evecv,isign*etang)\n*              over coef1 and coef2.\n*              The expression is differentiated and set equal to\n*              zero. Then this equation system of 2 equations\n*              with two unknowns is solved. \n*              If the three vectors evecu, evecv and evecw span\n*              3D, |coef3| = |d|/|evecw| where \n*              d = isign*etang - coef1*evecu - coef2*evecv\n*\n*********************************************************************\n*/\n{\n\n  int kstat = 0;           /* Status variable.                    */\n  int ki;                  /* Counter.                            */\n  double tdotuu;           /* Scalar product of evecu and evecu.  */\n  double tdotuv;           /* Scalar product of evecu and evecv.  */\n  double tdotutang;        /* Scalar product of evecu and etang.  */\n  double tdotvv;           /* Scalar product of evecv and evecv.  */\n  double tdotvtang;        /* Scalar product of evecv and etang.  */\n  double tdiv;             /* Determinant of equation system.     */\n  double sdum[3];          /* Help vector.     */\n\n  *jstat = 0;\n  \n  /* Test input.  */\n\n  /* if (idim != 3) goto err104; */\n  \n  /* Set output to zero. */\n\n  *coef1 = (double)0.0;\n  *coef2 = (double)0.0;\n  \n  /* Compute coefficients of equation system.  */\n\n  tdotuu = s6scpr(evecu,evecu,idim);\n  tdotuv = s6scpr(evecu,evecv,idim);\n  tdotutang = (double)isign*s6scpr(evecu,etang,idim);\n  tdotvv = s6scpr(evecv,evecv,idim);\n  tdotvtang = (double)isign*s6scpr(evecv,etang,idim);\n\n  tdiv = tdotuv*tdotuv - tdotuu*tdotvv;\n  if (DEQUAL(tdiv,DZERO))\n    {\n      if (DEQUAL(tdotuu,DZERO) && DEQUAL(tdotvv,DZERO));\n      else if (DEQUAL(tdotuu,DZERO))\n\t  *coef2 = s6length(etang,idim,&kstat)/sqrt(tdotvv);\n      else\n\t*coef1 = s6length(etang,idim,&kstat)/sqrt(tdotuu);\n      goto out;\n    }\n  \n  /* Compute the first two output factors.  */\n\n  *coef1 = (tdotvtang*tdotuv - tdotutang*tdotvv)/tdiv;\n  *coef2 = (tdotutang*tdotuv - tdotvtang*tdotuu)/tdiv;\n\n  /* Find third output factor.  */\n\n  for (ki=0; ki<idim; ki++) \n    sdum[ki] = (double)isign*etang[ki] - *coef1*evecu[ki] - *coef2*evecv[ki];\n  *coef3 = s6length(sdum,idim,&kstat)/s6length(evecw,idim,&kstat);\n  \n  if (s6scpr(sdum,evecw,idim) < DZERO) (*coef3) *= -(double)1.0;\n\n  goto out;\n\n\n  out :\n    return;\n}\n"
  },
  {
    "path": "src/s6fndintv.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define SFNDINTVL\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   s6fndintvl(double *et,int ik,int in,int *ileft,\n\t      double ax1,double ax2,int mu_max,int *jstat)\n#else\nvoid s6fndintvl(et,ik,in,ileft,ax1,ax2,mu_max,jstat)\n     double *et;\n     int    ik;\n     int    in;\n     int    *ileft;\n     double ax1;\n     double ax2;\n     int mu_max;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To examine if two parameter values are separated by a knot\n*              of multiplicity more than mu_max including boarders.\n*                          \n*\n*\n* INPUT      : et     - Double array of dimension [in+ik] containing\n*                       the knot vector.\n*              ik     - The polynomial order of the B-splines associated\n*                       with et.\n*              in     - The dimension of the spline space associated with\n*                       the knot vector et.\n*              ax1    - First parameter value\n*              ax2    - Second parameter value\n*              mu_max - Maximum allowed multiplicity.\n*\n*                \n*\n* INPUT/OUTPUT : ileft - Pointer to the interval in the knot vector\n*                       where the first separating knot is located.\n*                *jstat - Status:\n*                         = 0 : No separating knot found.\n*                         = 1 : Separating knot found.\n*     \t\t\t  < 0 : Error.\n*\n*\n* METHOD     :\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Ulf J. Krystad, SINTEF Oslo, 18.07.93.\n*\n*********************************************************************\n*/                                     \n{\n  int kpos=0;           /* The position of the error.                      */\n  int kstat=0;          /* Local status                                    */\n  int kleft_1=*ileft;   /* Local version of ileft to avoid the pointer.    */\n  int kleft_2=*ileft;   /* Local version of ileft to avoid the pointer.    */\n  int mu = 0;           /* Knot mltiplicity.                               */\n  double tmp;\n  double tval;\n  /* _____________________________________________________________________ */\n  *jstat = 0;\n\n  /* Sort position */\n  if (ax1 > ax2)\n  {\n     tmp = ax1;\n     ax1 = ax2;\n     ax2 = tmp;\n  }\n  \n  \n  /* Find knot navigators */\n  s1219(et,ik,in,&kleft_1,ax1,&kstat);\n  if (kstat < 0) goto error;\n  \n  tval = et[kleft_1+1];\n  while (tval < ax2 && tval < et[in])\n  {\n     mu = s6knotmult(et,ik,in,&kleft_2,tval, &kstat);\n     if (mu > mu_max)\n     {\n\t*jstat = 1;\n\t*ileft = kleft_2;\n\tbreak;\n     }\n     tval = et[kleft_2 +1];\n  }\n  \n  /* Successful computations.  */\n  goto out;\n  \n  \n  /* Error */\n error: *jstat = kstat;\n  s6err(\"s6fndintvl\",*jstat,kpos);\n  goto out;\n  \n out: return;\n}\n"
  },
  {
    "path": "src/s6herm.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6herm.c,v 1.3 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n#define S6HERM\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns6herm(double *pt,double *uknots,double *vknots,int unum,int vnum,\n\t int dim,int uindex,int vindex,double herminfo[],int *jstat)\n#else\nvoid\ns6herm(pt,uknots,vknots,unum,vnum,dim,uindex,vindex,herminfo,jstat)\n     double *pt;\n     double *uknots;\n     double *vknots;\n     int    unum;\n     int    vnum;\n     int    dim;\n     int    uindex;\n     int    vindex;\n     double herminfo[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Fit p_u, p_v derivatives and cross deriv p_uv to\n*              one point in a given rectangular grid of interpolation\n*              points.\n*              The derivatives are taken from the\n*              local biquadratic surface which interpolates the\n*              nearest 9 points. This information can be used to\n*              fit a cubic Hermite surface.\n*\n*\n*\n* INPUT      : pt     - The input grid of points.\n*                       This should contain unum*vnum*dim doubles.\n*              uknots - The parameter values of the points in u direc.\n*              vknots - The parameter values of the points in u direc.\n*              unum   - Number of points (and knots) in u direc (>=2).\n*              vnum   - Number of points (and knots) in u direc (>=2).\n*              dim    - Dimension of points (<= 3).\n*              uindex - Index in u of given point (0 to unum-1).\n*              vindex - Index in v of given point (0 to unum-1).\n*\n*\n* OUTPUT     : herminfo - The derivs p_u, p_v, p_uv. This\n*                         array must have room for 9 doubles\n*                         (3 vectors of max dimension 3).\n*              jstat  - status messages\n*                     = 2      : Surface is degenerate\n*                                at the point, normal\n*                                has zero length\n*                     = 1      : Surface is close to\n*                                degenerate at the point\n*                                Angle between tangents,\n*                                less than angular tolerance\n*                     = 0      : ok\n*                     < 0      : error\n*\n* METHOD     : The unique interpolating biquadratic polynomial\n*              which fits the nearest 3x3 grid of points is\n*              calculated (if unum > 2, vnum > 2).\n*              The derivatives are then found\n*              from this function.\n*              The function is expressed explicitly by\n*              Lagrange polynomials.\n*              If unum = 2, we fit a 1 x 2 surface.\n*              If vnum = 2, we fit a 2 x 1 surface.\n*              If unum = vnum = 2, we fit a 1 x 1 surface.\n*\n* EXAMPLE OF USE:\n*\n*\n* REFERENCES :\n*\n*\n*\n* WRITTEN BY : Michael Floater, SI, 3/2/92.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;      /* Position of error.          */\n  int ki,kj,kk;       /* Loop variable. */\n  double Lu[3];         /* Lagrange polynomials in u. */\n  double Lv[3];         /* Lagrange polynomials in v. */\n  double Ldu[3];        /* 1st derivatives of Lagrange polys in u. */\n  double Ldv[3];        /* 1st derivatives of Lagrange polys in v. */\n  double temp[3],temp2[3]; /* Temporary storage. */\n  double upar,vpar;        /* Parameter values to evaluate at. */\n  double diff[3];     /* Temporary storage for Lag polys. */\n  double kdiff[3];    /* Temporary storage for Lag polys. */\n  int uind,vind;   /* Indices of umin,vmin, in interpolation grid. */\n  int i00;                  /* Index in pt array of umin,vmin. */\n  int udeg,vdeg; /* Degree of polynomial in each direction (1 or 2). */\n  int ind;  /* Temporary index. */\n\n  /* Check input. */\n\n  if(dim < 1 || dim > 3) goto err105;\n  if(unum < 2  || vnum < 2) goto err105;\n  if(uindex < 0  || uindex > unum) goto err105;\n  if(vindex < 0  || vindex > vnum) goto err105;\n\n  /* Set parameter values to evaluate biquadratic at. */\n\n  upar = uknots[uindex];\n  vpar = vknots[vindex];\n\n  /* Decide on the degree of the interpolating polynomial. */\n\n  udeg = (unum > 2 ? 2 : 1);\n  vdeg = (vnum > 2 ? 2 : 1);\n\n  /* Find bottom left hand corner of grid to interpolate at. */\n\n  if(udeg == 2)\n  {\n      if(uindex == 0) uind = 0;\n      if(uindex > 0) uind = uindex - 1;\n      if(uindex == unum-1) uind = uindex - 2;\n  }\n  else\n  {\n      uind = 0;\n  }\n\n  if(vdeg == 2)\n  {\n      if(vindex == 0) vind = 0;\n      if(vindex > 0) vind = vindex - 1;\n      if(vindex == vnum-1) vind = vindex - 2;\n  }\n  else\n  {\n      vind = 0;\n  }\n\n\n  /* Calculate Lagrange polynomials in u\n     and calculate their 1st derivatives. */\n\n  if(udeg == 2)\n  {\n      diff[0] = upar-uknots[uind];\n      diff[1] = upar-uknots[uind+1];\n      diff[2] = upar-uknots[uind+2];\n\n      kdiff[0] = uknots[uind]-uknots[uind+1];\n      kdiff[1] = uknots[uind]-uknots[uind+2];\n      kdiff[2] = uknots[uind+1]-uknots[uind+2];\n\n      Lu[0] =   diff[1] * diff[2] / (kdiff[0] * kdiff[1]);\n      Lu[1] = - diff[0] * diff[2] / (kdiff[0] * kdiff[2]);\n      Lu[2] =   diff[0] * diff[1] / (kdiff[1] * kdiff[2]);\n\n      Ldu[0] =   (diff[1] + diff[2]) / (kdiff[0] * kdiff[1]);\n      Ldu[1] = - (diff[0] + diff[2]) / (kdiff[0] * kdiff[2]);\n      Ldu[2] =   (diff[0] + diff[1]) / (kdiff[1] * kdiff[2]);\n  }\n  else\n  {\n      diff[1] = upar-uknots[uind];\n      diff[2] = upar-uknots[uind+1];\n\n      kdiff[2] = uknots[uind]-uknots[uind+1];\n\n      Lu[0] =   diff[2]  / kdiff[2];\n      Lu[1] = - diff[1]  / kdiff[2];\n      Lu[2] =   DZERO;\n\n      Ldu[0] =   (double)1.0  / kdiff[2];\n      Ldu[1] = - (double)1.0  / kdiff[2];\n      Ldu[2] = DZERO;\n  }\n\n\n  /* Calculate Lagrange polynomials in v\n     and calculate their 1st derivatives. */\n\n  if(vdeg == 2)\n  {\n      diff[0] = vpar-vknots[vind];\n      diff[1] = vpar-vknots[vind+1];\n      diff[2] = vpar-vknots[vind+2];\n\n      kdiff[0] = vknots[vind]-vknots[vind+1];\n      kdiff[1] = vknots[vind]-vknots[vind+2];\n      kdiff[2] = vknots[vind+1]-vknots[vind+2];\n\n      Lv[0] =   diff[1] * diff[2] / (kdiff[0] * kdiff[1]);\n      Lv[1] = - diff[0] * diff[2] / (kdiff[0] * kdiff[2]);\n      Lv[2] =   diff[0] * diff[1] / (kdiff[1] * kdiff[2]);\n\n      Ldv[0] =   (diff[1] + diff[2]) / (kdiff[0] * kdiff[1]);\n      Ldv[1] = - (diff[0] + diff[2]) / (kdiff[0] * kdiff[2]);\n      Ldv[2] =   (diff[0] + diff[1]) / (kdiff[1] * kdiff[2]);\n  }\n  else\n  {\n      diff[1] = vpar-vknots[vind];\n      diff[2] = vpar-vknots[vind+1];\n\n      kdiff[2] = vknots[vind]-vknots[vind+1];\n\n      Lv[0] =   diff[2]  / kdiff[2];\n      Lv[1] = - diff[1]  / kdiff[2];\n      Lv[2] =   DZERO;\n\n      Ldv[0] =   (double)1.0  / kdiff[2];\n      Ldv[1] = - (double)1.0  / kdiff[2];\n      Ldv[2] = DZERO;\n  }\n\n  /* Calculate derivative of biquadratic in u. */\n\n  i00 = (vind*unum+uind)*dim;\n\n  for(ki=0; ki<dim; ki++)\n  {\n      ind = i00+ki;\n\n      for(kj=0; kj<=vdeg; kj++)\n      {\n\t  temp[kj] = 0.0;\n\t  temp2[kj] = 0.0;\n\n          for(kk=0; kk<=udeg; kk++,ind+=dim)\n          {\n\t      temp[kj] += Lu[kk] * pt[ind];\n\t      temp2[kj] += Ldu[kk] * pt[ind];\n\t  }\n\n\t  ind += (unum - udeg - 1) * dim;\n      }\n\n      herminfo[ki] = 0.0;\n      herminfo[dim+ki] = 0.0;\n      herminfo[dim+dim+ki] = 0.0;\n\n      for(kj=0; kj<=vdeg; kj++)\n      {\n\t  /* Calculate u derivative. */\n\n\t  herminfo[ki] += Lv[kj] * temp2[kj];\n\n\t  /* Calculate v derivative. */\n\n\t  herminfo[dim+ki] += Ldv[kj] * temp[kj];\n\n\t  /* Calculate uv derivative. */\n\n\t  herminfo[dim+dim+ki] += Ldv[kj] * temp2[kj];\n      }\n  }\n\n\n\n  /* Derivatives calculated. */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in input. */\n\n  err105: *jstat = -105;\n  s6err(\"s6herm\",*jstat,kpos);\n  goto out;\n\n  out: return;\n}\n"
  },
  {
    "path": "src/s6herm_bez.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6herm_bez.c,v 1.3 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6HERMITE_BEZIER\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n    s6hermite_bezier(SISLSurf* s,double a[],double b[],int idim, double c[],\n\t\t     int* jstat)\n#else\nvoid s6hermite_bezier(s,a,b,idim,c,jstat)\n     SISLSurf *s;\n     double a[],b[];\n     int idim;\n     double c[];\n     int *jstat;\n#endif\n/*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE     : Returning the Hermite interpolant to the restriction of the\n*               surface s to line segment [a,b].\n*               The Hermite interpolant is a Bezier\n*               curve of degree 3 parametrized over the intervall [0,1].\n*\n*\n*\n*\n* INPUT      : s          - Pointer to surface object.\n*              a[0:1]     - Start point of line segment.\n*              b[0:1]     - End point of line segment.\n*\t       idim       - space dimension.\n*              c[0:3*idim]- allocated space;\n*\n*\n* OUTPUT     : c          - Bezier coeffs of the Hermite interpolant.\n*              jstat      - status messages\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n*\n* WRITTEN BY : Kyrre Strom, SI, 93-01.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov.1994. Initialized\n*              'jstat' to zero when no error.\n*\n**********************************************************************/\n{\n  int i,kstat,left1=0,left2=0;\n  double dblocal[9];\n  double *derive=SISL_NULL;\n\n\n  if (DEQUAL(a[0],b[0]) && DEQUAL(a[1],b[1])) goto error;\n  if (s->idim != idim) goto error;\n\n  if ( idim > 3)\n  {\n    derive = newarray(3*idim,double);\n    if (derive == SISL_NULL) goto err101;\n  }\n  else\n    derive = dblocal;\n\n  /* evaluate s and its derivative at a */\n\n  s1424(s,1,1,a,&left1,&left2,derive,&kstat);\n  if (kstat < 0) goto error;\n  for (i=0; i < idim; i++)\n  {\n    c[i] = derive[i];\n    c[idim+i] = c[i] + (derive[idim+i]*(b[0]-a[0])\n\t\t\t+ derive[2*idim+i]*(b[1]-a[1]))/3.0;\n  }\n\n  /* evaluate s and its derivative at b */\n\n  s1424(s,1,1,b,&left1,&left2,derive,&kstat);\n  if (kstat < 0) goto error;\n  for (i=0; i < idim; i++)\n  {\n    c[3*idim+i] = derive[i];\n    c[2*idim+i] = c[3*idim+i] - (derive[idim+i]*(b[0]-a[0])\n\t\t\t\t + derive[2*idim+i]*(b[1]-a[1]))/3.0;\n  }\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n  err101 :\n    *jstat = -101;\n    goto out;\n\n\n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n    goto out;\n\n\n  out :\n\n    if (derive != SISL_NULL && derive != dblocal)\n      freearray(derive);\n\n  return;\n\n}\n"
  },
  {
    "path": "src/s6idcon.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6idcon.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6IDCON\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns6idcon_s9turn(SISLIntpt *);\nstatic void\ns6idcon_s9endturn(SISLIntdat *,SISLIntpt *);\n#else\nstatic void s6idcon_s9turn();\nstatic void s6idcon_s9endturn();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6idcon(SISLIntdat **pintdat,SISLIntpt **pintpt1,SISLIntpt **pintpt2,int *jstat)\n#else\nvoid s6idcon(pintdat,pintpt1,pintpt2,jstat)\n     SISLIntdat **pintdat;\n     SISLIntpt  **pintpt1;\n     SISLIntpt  **pintpt2;\n     int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To connect two intersection points in pintdat into a list.\n*              If pintdat is SISL_NULL a new pintdat is also made.\n*              If  one of pintpt is close to an other intersection point\n*              the object pintpt is pointing to is freed, and\n*              pintpt is set to point to the already inserted point.\n*\n*\n*\n* INPUT      : pintpt1  - Pointer to a pointer to new intersection point.\n*              pintpt2  - Pointer to a pointer to new intersection point.\n*              pintdat  - Pointer to a pointer to intersection date.\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                               = 3      : Only \"one\" junction point.\n*                               = 2      : Only one point.\n*                               = 1      : Already connected.\n*                               = 0      : Connection done.\n*                               < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err      - Gives error message.\n*              s6idnpt    - Insert a new intpt structure.\n*              copyIntpt  - Copy an intpt structure.\n*              newIntdat  - Create new intdat structure.\n*\n* WRITTEN BY : Arne Laksaa, 05.89.\n*\n*********************************************************************\n*/                                     \n{\n  int kstat;                /* Local status variable.                     */\n/*guen  int kpos;   */               /* Position of error.                         */\n/*guen changed into:*/\n  int kpos=0;                 /* Position of error.                         */\n\n  int kfirst1,kfirst2;      /* To mark if the point is first in the list. */\n  int ki1,ki2;              /* Counters                                   */\n  SISLIntpt *qpt1,*qpt2;\n  \n  \n  /* First we have to be sure that pintdat contain the two points. */\n  \n  s6idnpt(pintdat,pintpt1,1,&kstat);\n  if (kstat < 0) goto error;\n  \n  s6idnpt(pintdat,pintpt2,1,&kstat);\n  if (kstat < 0) goto error;\n  \n  \n  qpt1 = *pintpt1;\n  qpt2 = *pintpt2;\n  \n  \n  /* Then we have to be sure that we do not have the same points as\n     copies, junction points. */\n  \n  if (qpt1->iinter == 2 || qpt2->iinter == 2)\n    {\n      if (qpt1->iinter == 2 && qpt2->iinter == 2)\n\t{\n\t  for (ki1=0; ki1 < qpt1->ipar; ki1++)\n\t    if (qpt1->epar[ki1] != qpt2->epar[ki1]) break;\n\t  \n\t  if (ki1 == qpt1->ipar)\n\t    {\n\t      *jstat = 3;\n\t      goto out;\n\t    }\n\t}\n      \n      if (qpt1->iinter == 2)\n\t{\n\t  for (ki1=0; ki1 < (*pintdat)->ipoint; ki1++)\n\t    {\n\t      for (ki2=0; ki2 < qpt1->ipar; ki2++)\n\t\tif (qpt1->epar[ki2] != (*pintdat)->vpoint[ki1]->epar[ki2])\n\t\t  break;\n\t      \n\t      if (ki2 == qpt1->ipar)\n\t\t{\n\t\t  /* UJK && ALA 19.09.90 qpt1 changed to qpt2. */\n\t\t  \n\t\t  if (qpt2->pcurve == (*pintdat)->vpoint[ki1] || \n\t\t      (*pintdat)->vpoint[ki1]->pcurve == qpt2)\n\t\t    {\n\t\t      /* The points are already connected. */\n\t\t      *jstat = 1;\n\t\t      goto out;\n\t\t    }\n\t\t}\n\t    }\n\t}\n      \n      if (qpt2->iinter == 2)\n\t{\n\t  for (ki1=0; ki1 < (*pintdat)->ipoint; ki1++)\n\t    {\n\t      for (ki2=0; ki2 < qpt2->ipar; ki2++)\n\t\tif (qpt2->epar[ki2] != (*pintdat)->vpoint[ki1]->epar[ki2])\n\t\t  break;\n\t      \n\t      if (ki2 == qpt2->ipar)\n\t\t{\n\t\t  /* UJK && ALA 19.09.90 qpt2 changed to qpt1. */\n\t\t  if (qpt1->pcurve == (*pintdat)->vpoint[ki1] || \n\t\t      (*pintdat)->vpoint[ki1]->pcurve == qpt1)\n\t\t    {\n\t\t      /* The points are already connected. */\n\t\t      *jstat = 1;\n\t\t      goto out;\n\t\t    }\n\t\t}\n\t    }\n\t}\n    }\n  \n  \n  \n  if (qpt1 == qpt2)\n    /* There is only one point. */\n    *jstat = 2;\n  if (qpt1->pcurve == qpt2 || qpt2->pcurve == qpt1)\n    /* The points are already connected. */\n    *jstat = 1;\n  else\n    {\n      /* We have to be sure that if one of the points is in the end of \n\t a list than this point is the first point. */\n      \n      if (qpt1->pcurve != SISL_NULL && qpt2->pcurve == SISL_NULL)\n        {\n\t  SISLIntpt *pt;\n\t  \n\t  pt = qpt1;\n\t  qpt1 = qpt2;\n\t  qpt2 = pt;\n        }\n      \n      /* Computing the index of the point pointing to the first point.    */\n      \n      for (ki1=0; ki1<(*pintdat)->ipoint; ki1++)\n        if ((*pintdat)->vpoint[ki1]->pcurve == qpt1)\n\t  break;\n      \n      if ( ki1 < (*pintdat)->ipoint)\n        kfirst1 = 0;\n      else\n        kfirst1 = 1;\n      \n      /* Computing the index of the point pointing to the sescond point.  */\n      \n      for (ki2=0; ki2<(*pintdat)->ipoint; ki2++)\n        if ((*pintdat)->vpoint[ki2]->pcurve == qpt2)\n\t  break;\n      \n      if ( ki2 < (*pintdat)->ipoint)\n        kfirst2 = 0;\n      else\n        kfirst2 = 1;\n      \n      /* If the first point is not at end, than we have to\n\t reorganize the first list.  */\n      \n      if (qpt1->pcurve != SISL_NULL)\n        {\n\t  if (kfirst1)\n\t    s6idcon_s9turn(qpt1);                  /* First point is at start. */\n\t  else                               /* First point is internal. */\n\t    {\n\t      /* We have a junction point. We therfor make a copy of\n\t\t this point, and set this copy to the first point. */\n\t      \n\t      qpt1->iinter = 2;\n\t      \n\t      if((qpt1 = copyIntpt(qpt1)) == SISL_NULL) goto err101;\n\t      \n\t      s6idnpt(pintdat,&qpt1,0,&kstat);\n\t      if (kstat < 0) goto error;\n\t    }\n        }\n      \n      \n      if (kfirst2)                             /*Second point is at start.*/\n        qpt1->pcurve = qpt2;\n      else if (qpt2->pcurve == SISL_NULL)     /* Second point is at end. */\n        {\n\t  s6idcon_s9endturn(*pintdat,qpt2);\n\t  qpt1->pcurve = qpt2;\n        }\n      else                          /* Second point is an internal point. */\n        {\n\t  /* We have a junction point. We therfor make a copy of\n\t     this point, and set the first point  to point to this copy. */\n\t  \n\t  qpt2->iinter = 2;\n\t  \n\t  if((qpt2 = copyIntpt(qpt2)) == SISL_NULL) goto err101;\n\t  \n\t  s6idnpt(pintdat,&qpt2,0,&kstat);\n\t  if (kstat < 0) goto error;\n\t  \n\t  qpt1->pcurve = qpt2;\n        }\n      *jstat = 0;\n    }\n  \n  goto out;\n  \n\n/* Error in space allocation.  */\n\nerr101: *jstat = -101;\n        s6err(\"s6idcon\",*jstat,kpos);\n        goto out;\n\n/* Error in sub function.  */\n\nerror:  *jstat = kstat;\n        s6err(\"s6idcon\",*jstat,kpos);\n        goto out;\n\n out: ;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns6idcon_s9turn(SISLIntpt *pt)\n#else\nstatic void s6idcon_s9turn(pt)\n     SISLIntpt *pt;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To turn a list of intersection points where we have\n*              a pointer at the start of the list.\n*\n*\n* INPUT      : pt      - Pointer to the first intersection point in list.\n*\n*\n* OUTPUT     : \n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, 05.89.\n*\n*********************************************************************\n*/                                     \n{\n  register SISLIntpt *pt1,*pt2;/* Help pointer to traverse lists.*/\n  \n  pt1 = pt->pcurve;\n  pt2 = pt1->pcurve;\n  pt->pcurve = SISL_NULL;  \n  pt1->pcurve = pt;\n  \n  while (pt2 != SISL_NULL)\n    {\n      pt  = pt1;\n      pt1 = pt2;\n      pt2 = pt2->pcurve;\n      pt1->pcurve = pt;\n    }\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns6idcon_s9endturn(SISLIntdat *pintdat,SISLIntpt *pt)\n#else\nstatic void s6idcon_s9endturn(pintdat,pt)\n     SISLIntdat *pintdat;\n     SISLIntpt  *pt;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To turn a list of intersection points where we\n*              just have the last element in the list.\n*\n*\n* INPUT      : pt      - Pointer to the last intersection point in list.\n*\n*\n* OUTPUT     : pintdat - Intersection dates where the list to be\n*                        turned is.\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, 05.89.\n*\n*********************************************************************\n*/                                     \n{\n  register int ki;\n  \n  while(1)\n    {\n      for (ki=0; ki < pintdat->ipoint; ki++)\n        if (pintdat->vpoint[ki]->pcurve == pt)\n\t  break;\n      \n      if (ki < pintdat->ipoint)\n\tpt = pintdat->vpoint[ki];\n      else\n\tbreak;\n    }\n  \n  s6idcon_s9turn(pt);\n}\n"
  },
  {
    "path": "src/s6idcpt.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6idcpt.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6IDCPT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6idcpt(SISLIntdat *pintdat,SISLIntpt *pintpt,SISLIntpt **rintpt)\n#else\nvoid s6idcpt(pintdat,pintpt,rintpt)\n     SISLIntdat *pintdat;\n     SISLIntpt  *pintpt;\n     SISLIntpt  **rintpt;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To find the point which is closest to pintpt\n*              in the parametric space. If pintpt is the only\n*              point in pintdat *rintpt is SISL_NULL.\n*\n*\n*\n* INPUT       :pintpt   - Pointer to an intersection point.\n*              pintdat  - Pointer to intersection data.\n*\n*\n* OUTPUT     : rintpt   - Pointer to a pointer to a point closest\n*                         to pintpt.\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : \n*\n* WRITTEN BY : Arne Laksaa, 05.89.\n*\n*********************************************************************\n*/                                     \n{\n  if (pintdat == SISL_NULL)\n    *rintpt = SISL_NULL;\n  else\n    {\n      int ki,knr;                /* Counters.          */\n      double tdist,td;           /* To store distanse. */\n      \n      if (pintpt == pintdat->vpoint[0])\n        tdist = HUGE;\n      else\n        tdist = s6dist(pintdat->vpoint[0]->epar,pintpt->epar,pintpt->ipar);\n      \n      for (knr=0,ki=1; ki<pintdat->ipoint; ki++)\n        {\n\t  if (pintpt == pintdat->vpoint[ki])\n\t    td = HUGE;\n\t  else\n\t    td = s6dist(pintdat->vpoint[ki]->epar,pintpt->epar,pintpt->ipar);\n\t  \n\t  if (td < tdist)\n\t    {\n\t      knr = ki;\n\t      tdist = td;\n\t    }\n        }\n      \n      if (tdist == HUGE)\n        *rintpt = SISL_NULL;\n      else\n        *rintpt = pintdat->vpoint[knr];\n    }\n}\n\n"
  },
  {
    "path": "src/s6idedg.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6idedg.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6IDEDG\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6idedg(SISLObject *po1,SISLObject *po2,int iobj,int ipar,double apar,\n\t     SISLIntdat *pintdat,SISLPtedge **rptedge,int *jnum,int *jstat)\n#else\nvoid s6idedg(po1,po2,iobj,ipar,apar,pintdat,rptedge,jnum,jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     int    iobj;\n     int    ipar;\n     double apar;\n     SISLIntdat *pintdat;\n     SISLPtedge **rptedge;\n     int    *jnum;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To make a list of ptedges pointing to intersection\n*              points with one constant parameter value apar and if it\n*              exist more than one parameter the other value have to\n*              be between tstart and tend. A pointer to this list\n*              is returned by rptedge.\n*\n*\n*\n* INPUT      : po1      - First object in intersection.\n*              po2      - Second object in intersection.\n*              iobj     - Number of object to pick edge of.\n*              ipar     - Number of parameter direction to pick edge  of.\n*              apar     - The edge/end parameter value.\n*              pintdat  - Pointer to intersection data.\n*\n*\n* OUTPUT     : rptedge  - Pointer to a pointer to the ptedge list.\n*              jnum     - += number of elements in list.\n*              jstat    - status messages  \n*                               = 0      : OK!\n*                               < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err      - Gives error message.\n*              s6idnpt    - Insert a new intpt structure.\n*              copyIntpt  - Copy an intpt structure.\n*              newIntdat  - Create new intdat structure.\n*\n* WRITTEN BY : Arne Laksaa, 05.89.\n* Revised by : Christophe Rene Birkeland, SINTEF Oslo, May 1993.\n*              Error message corrected\n*\n*********************************************************************\n*/                                     \n{\n  int kpos=0;                /* Position of error.                       */\n  int kpar=0;                /* Numper of parameter direction second obj.*/\n  int ki,kj;                 /* Counters                                 */\n  double sstart[4],send[4];  /* Parameter boarders on the other obj.     */\n  SISLPtedge *pte = SISL_NULL;    /* Pointers to new ptedge.                  */\n  \n  /* Initiate to emty list. */\n  \n  *rptedge = SISL_NULL;  \n  *jstat = 0;\n  \n  /* We have to be sure that we have an intdat structure. */\n  \n  if (pintdat == SISL_NULL) goto out;\n  \n  /* Uppdate parameter boarder. */\n  \n  if (po1->iobj == SISLCURVE)\n    {\n      if (iobj == 1)\n        {\n\t  sstart[0] = apar;\n\t  send[0]   = apar;\n        }\n      else\n        {\n\t  sstart[0] = po1->c1->et[po1->c1->ik - 1];\n\t  send[0]   = po1->c1->et[po1->c1->in];\n        }\n      kpar = 1;\n    }\n  else if (po1->iobj == SISLSURFACE)\n    {\n      if (iobj == 1 && ipar == 1)\n        {\n\t  sstart[0] = apar;\n\t  send[0]   = apar;\n        }\n      else\n        {\n\t  sstart[0] = po1->s1->et1[po1->s1->ik1 - 1];\n\t  send[0]   = po1->s1->et1[po1->s1->in1];\n        }\n      if (iobj == 1 && ipar == 2)\n        {\n\t  sstart[1] = apar;\n\t  send[1]   = apar;\n        }\n      else\n        {\n\t  sstart[1] = po1->s1->et2[po1->s1->ik2 - 1];\n\t  send[1] = po1->s1->et2[po1->s1->in2];\n        }\n      kpar = 2;\n    }\n  \n  \n  if (po2->iobj == SISLCURVE)\n    {\n      if (iobj == 2)\n        {\n\t  sstart[kpar] = apar;\n\t  send[kpar]   = apar;\n        }\n      else\n        {\n\t  sstart[kpar] = po2->c1->et[po2->c1->ik - 1];\n\t  send[kpar]   = po2->c1->et[po2->c1->in];\n        }\n    }\n  else if (po2->iobj == SISLSURFACE)\n    {\n      if (iobj == 2 && ipar == 1)\n        {\n\t  sstart[kpar] = apar;\n\t  send[kpar]   = apar;\n        }\n      else\n        {\n\t  sstart[kpar] = po2->s1->et1[po2->s1->ik1 - 1];\n\t  send[kpar] = po2->s1->et1[po2->s1->in1];\n        }\n      if (iobj == 2 && ipar == 2)\n        {\n\t  sstart[kpar+1] = apar;\n\t  send[kpar+1]   = apar;\n        }\n      else\n        {\n\t  sstart[kpar+1] = po2->s1->et2[po2->s1->ik2 - 1];\n\t  send[kpar+1]   = po2->s1->et2[po2->s1->in2];\n        }\n    }\n    \n  /* We have to go trough all intersection points to search for edges. */\n  \n  for (ki=0; ki<pintdat->ipoint; ki++)\n    {\n      for (kj=0; kj<pintdat->vpoint[ki]->ipar; kj++)\n        if ((DEQUAL(sstart[kj],pintdat->vpoint[ki]->epar[kj]) ||\n\t     sstart[kj] < pintdat->vpoint[ki]->epar[kj]) &&\n\t    (DEQUAL(send[kj],pintdat->vpoint[ki]->epar[kj]) ||\n\t     send[kj] > pintdat->vpoint[ki]->epar[kj]));\n\telse\n\t  goto end;\n      \n      if (pte == SISL_NULL)\n        {\n\t  pte = newPtedge(pintdat->vpoint[ki]);\n\t  if (pte == SISL_NULL) goto err101;\n\t  \n\t  (*rptedge) = pte;\n\t  \n\t  (*jnum)++;\n        }\n      else\n        {\n\t  pte->pnext = newPtedge(pintdat->vpoint[ki]);\n\t  if (pte->pnext == SISL_NULL) goto err101;\n\t  \n\t  pte = pte->pnext;\n\t  \n\t  (*jnum)++;\n        }\n    end:;\n    }\n  \n  goto out;\n  \n  /* Error in space allocation.  */\n\n  err101: \n    *jstat = -101;\n    s6err(\"s6idedg\",*jstat,kpos);\n    goto out;\n\n out:  ;\n}\n"
  },
  {
    "path": "src/s6identify.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6identify.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6IDENTIFY\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n    s6identify(SISLSurf* s,double a[], double b[], double level_val,\n\t       double eps1,double eps2,int* jstat)\n#else\nvoid s6identify(s,a,b,level_val,eps1,eps2,jstat)\n     SISLSurf* s;\n     double a[],b[];\n     double level_val;\n     double eps1,eps2;\n     int* jstat;\n#endif\n/***********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE     : To check if the to points a,b in the parameter plane of\n*               s should be identified according to certain criteria.\n*               See METHOD below for the criteria.\n*\n*\n*\n*\n* INPUT      : s          - Pointer to 1-dimensional surface object.\n*              a[0:1]     - first point in parameter plane\n*              b[0:1]     - second point in parameter plane\n*\t       idim       - space dimension.\n*              level_val  - constant crucial for the identification criterium.\n*                           ( represents usually the constant surface with\n*                             wich s is intersected )\n*              eps1\t  - radius of ball used in the criteria for\n*\t\t\t    separate points in parameter plane.\n*              eps2       - resolution in space.\n*\n*\n* OUTPUT     : \t\t- jstat      - status messages\n*\t\t\t\t\t  = 1      : identify points a,b\n*                                         = 0      : a,b are separate points\n*                                         < 0      : error\n*\n*\n* METHOD     : a and b are identified iff (i) and (ii) are satisfied:\n*                (i)           |a-b| <= eps1.\n*\t\t (ii)          |c(g)-level_val| <= eps2 . \n*\t\t \tHere\n*\t\t\t    g is the degree 3 polynomial Hermite interpolant \n*                           to the restriction of\n*                           the surface s to the line segment [a,b], i.e.\n*                           g(0) = s(a), g'(0) = Ds(a)(b-a),\n*                           g(1) = s(b), g'(1) = Ds(b)(b-a) where\n*                           Ds is the gradient of s.\n*                           Furthermore,\n*                           c(g) is the spline control polygon of g for the \n*                           spline representation of g with k-tuple knots \n*                           at 0,1/2,1.\n*                           \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*              \n*\n* WRITTEN BY : Kyrre Strom, SI, 93-01.\n* MODIFIED BY :\n*\n**********************************************************************/\n{\n  double c[4],cref[8];\n  int i,kstat;\n\n  if ( s == SISL_NULL ||\n      (a[0] < s->et1[0] || a[0] > s->et1[s->in1]) ||\n      (a[1] < s->et2[0] || a[1] > s->et2[s->in2]) ||\n      (b[0] < s->et1[0] || b[0] > s->et1[s->in1]) ||\n      (b[1] < s->et2[0] || b[1] > s->et2[s->in2])   )\n    goto err109;\n\n  if (DEQUAL(a[0],b[0]) && DEQUAL(a[1],b[1]))\n    {\n      kstat = 1;\n      goto out;\n    }\n  if ( sqrt((a[0]-b[0])*(a[0]-b[0]) + (a[1]-b[1])*(a[1]-b[1])) > eps1 )\n    kstat = 0;\n  else\n    {\n      s6hermite_bezier(s,a,b,1,c,&kstat);\n      if (kstat < 0) goto error;\n\n      s6deCasteljau(c,0.0,1.0,0.5,4,cref,&kstat);\n      if (kstat < 0) goto error;\n\n      kstat = 1;\n      for (i=0; i<8; i++)\n\tif (fabs(cref[i]-level_val) > eps2)\n\t  kstat = 0;\n    }\n  \n  goto out;\n\n err109: kstat = -109;\n  s6err(\"s6identify\",kstat,0);\n  goto out;\n\n\n error: \n  s6err(\"s6identify\",kstat,0);\n  goto out;\n\n out: \n    *jstat = kstat;\n    return ;\n} \n"
  },
  {
    "path": "src/s6idget.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6idget.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6IDGET\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6idget(SISLObject *po1,SISLObject *po2,int ipar,double apar,SISLIntdat *pintdat,\n\t     SISLIntdat **rintdat,int *jstat)\n#else\nvoid s6idget(po1,po2,ipar,apar,pintdat,rintdat,jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     int    ipar;\n     double apar;\n     SISLIntdat *pintdat;\n     SISLIntdat **rintdat;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To insert all points in one intdat with one less number\n*              of parameters into rintdat. New copies is made with\n*              the missing parameter. All listes is also to\n*              be uppdated.\n*\n*\n*\n* INPUT      : po1     - First object in the intersection.\n*              po2     - Second object in the intersection.\n*              ipar    - Number of the parameter that is missing in rintdat.\n*              apar    - Parameter value of the missing parameter.\n*              pintdat - Pointer to intersection data on the mother problem.\n*\n*\n* OUTPUT     : rintdat  - Pointer to a pointer to intersection data.\n*              jstat    - status messages  \n*                               = 0      : Inserting done.\n*                               < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err      - Gives error message.\n*              s6idnpt    - Insert a new intpt structure.\n*              copyIntpt  - Copy an intpt structure.\n*              newIntdat  - Create new intdat structure.\n*\n* WRITTEN BY : Arne Laksaa, 06.89.\n* Revised by : Christophe Rene Birkeland, SINTEF Oslo, May 1993.\n*              Error message corrected\n*\n*********************************************************************\n*/                                     \n{\n  int kstat;                    /* Local status variable.                 */\n  int kpos=0;                   /* Position of error.                     */\n  int ki,kj,kn;\n  double tstart[4];\n  double tend[4];\n  double spar[4];               /* Storing uppdated parametervalues.      */\n  SISLIntpt *qpt;\n  \n  \n  if (pintdat == SISL_NULL)\n    goto out;\n  \n  if (po1->iobj == SISLCURVE)\n    {\n      tstart[0] = po1->c1->et[po1->c1->ik - 1];\n      tend[0]   = po1->c1->et[po1->c1->in];\n    }\n  else if (po1->iobj == SISLSURFACE)\n    {\n      tstart[0] = po1->s1->et1[po1->s1->ik1 - 1];\n      tend[0]   = po1->s1->et1[po1->s1->in1];\n      tstart[1] = po1->s1->et2[po1->s1->ik2 - 1];\n      tend[1]   = po1->s1->et2[po1->s1->in2];\n    }\n  \n  if (po2->iobj == SISLCURVE)\n    {\n      tstart[po1->iobj]   = po2->c1->et[po2->c1->ik - 1];\n      tend[po1->iobj]     = po2->c1->et[po2->c1->in];\n    }\n  else if (po2->iobj == SISLSURFACE)\n    {\n      tstart[po1->iobj]   = po2->s1->et1[po2->s1->ik1 - 1];\n      tend[po1->iobj]     = po2->s1->et1[po2->s1->in1];\n      tstart[po1->iobj+1] = po2->s1->et2[po2->s1->ik2 - 1];\n      tend[po1->iobj+1]   = po2->s1->et2[po2->s1->in2];\n    }\n  \n  tstart[ipar] = tend[ipar] = apar;\n  \n  \n  /* Uppdate the array. */\n  \n  for (ki=0; ki<pintdat->ipoint; ki++)\n    {\n      for (kj=0; kj<pintdat->vpoint[ki]->ipar; kj++)\n\tif((DNEQUAL(pintdat->vpoint[ki]->epar[kj],tstart[kj]) &&\n\t    pintdat->vpoint[ki]->epar[kj] < tstart[kj]) ||\n\t   (DNEQUAL(pintdat->vpoint[ki]->epar[kj],tend[kj]) &&\n\t    pintdat->vpoint[ki]->epar[kj] > tend[kj]))\n\t  break;\n      \n      if (kj == pintdat->vpoint[ki]->ipar)\n\t{\n\t  for(kn=0; kn<ipar; kn++) spar[kn] = pintdat->vpoint[ki]->epar[kn];\n\t  for(; kn<pintdat->vpoint[ki]->ipar-1; kn++)\n\t    spar[kn] = pintdat->vpoint[ki]->epar[kn+1];\n\t  \n\t  /* Than we can insert all new intersection points in rintdat. */\n\t  \n\t  qpt = newIntpt(pintdat->vpoint[ki]->ipar-1,spar,DZERO);\n\t  if (qpt == SISL_NULL) goto err101;\n\t  \n\t  s6idnpt(rintdat,&qpt,1,&kstat);\n\t  if (kstat < 0) goto error;\n\t}\n    }\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation.  */\n\n  err101: \n    *jstat = -101;\n    s6err(\"s6idget\",*jstat,kpos);\n    goto out;\n\n  /* Error in sub function.  */\n\n  error: \n    *jstat = kstat;\n    s6err(\"s6idget\",*jstat,kpos);\n    goto out;\n\n  out: ;\n}\n"
  },
  {
    "path": "src/s6idint.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6idint.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6IDINT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6idint(SISLObject *po1,SISLObject *po2,SISLIntdat *pintdat,SISLIntpt **rpt,int iob)\n#else\nvoid s6idint(po1,po2,pintdat,rpt,iob)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntdat *pintdat;\n     SISLIntpt  **rpt;\n     int    iob;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To find an internal intersection point in object iob\n*              from pintdat.\n*\n*\n*\n* INPUT      : pintdat  - Pointer to intersection data.\n*              po1      - Pointer to first object\n*              po2      - Pointer to second object\n*              iob      - Number of object to find internal \n*                         intersection poin in.\n*\n*\n* OUTPUT     : rpt      - Pointer to an internal intersection point.\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : \n*\n* WRITTEN BY : Arne Laksaa, 05.89.\n*\n*********************************************************************\n*/                                     \n{\n  register int  ki,kj;\n  int  kpar1,kpar2;\n  double sstart1[2],send1[2];\n  double sstart2[2],send2[2];\n  \n  \n  /* Initiate to emty list. */\n  \n  *rpt = SISL_NULL;\n  \n  \n  /* We have to be sure that we have an intdat structure. */\n  \n  if (pintdat == SISL_NULL)\n    goto out;\n  \n  \n  if (po1 == SISL_NULL || po1->iobj == SISLPOINT)\n    kpar1 = 0;\n  else if (po1->iobj == SISLCURVE)\n    {\n      kpar1 = 1;\n      sstart1[0] = po1->c1->et[po1->c1->ik-1];\n      send1[0] = po1->c1->et[po1->c1->in];\n    }\n  else if (po1->iobj == SISLSURFACE)\n    {\n      kpar1 = 2;\n      sstart1[0] = po1->s1->et1[po1->s1->ik1-1];\n      send1[0] = po1->s1->et1[po1->s1->in1];\n      sstart1[1] = po1->s1->et2[po1->s1->ik2-1];\n      send1[1] = po1->s1->et2[po1->s1->in2];\n    }\n  \n  \n  if (po2 == SISL_NULL || po2->iobj == SISLPOINT)\n    kpar2 = 0;\n  else if (po2->iobj == SISLCURVE)\n    {\n      kpar2 = 1;\n      sstart2[0] = po2->c1->et[po2->c1->ik-1];\n      send2[0] = po2->c1->et[po2->c1->in];\n    }\n  else if (po2->iobj == SISLSURFACE)\n    {\n      kpar2 = 2;\n      sstart2[0] = po2->s1->et1[po2->s1->ik1-1];\n      send2[0] = po2->s1->et1[po2->s1->in1];\n      sstart2[1] = po2->s1->et2[po2->s1->ik2-1];\n      send2[1] = po2->s1->et2[po2->s1->in2];\n    }\n  \n  \n  if (iob == 1 && kpar1 == 0)\n    goto out;\n  \n  if (iob == 2 && kpar2 == 0)\n    goto out;\n  \n  \n  /* We have to go trough all intersection points to search for internal\n     intersection points. */\n  \n  for (ki=pintdat->ipoint-1; ki>=0; ki--)\n    {\n      if (pintdat->vpoint[ki]->iinter < 0)\n\tcontinue;  /* Help point */\n      for (kj=0; kj<kpar1; kj++)\n        if (sstart1[kj] > pintdat->vpoint[ki]->epar[kj]  ||\n\t    send1[kj] < pintdat->vpoint[ki]->epar[kj])\n\t  goto end;\n      for (kj=0; kj<kpar2; kj++)\n        if (sstart2[kj] > pintdat->vpoint[ki]->epar[kpar1+kj]  ||\n\t    send2[kj] < pintdat->vpoint[ki]->epar[kpar1+kj])\n\t  goto end;\n      \n      if (iob == 1)\n        {\n\t  for (kj=0; kj<kpar1; kj++)\n\t    if (DEQUAL(sstart1[kj],pintdat->vpoint[ki]->epar[kj]) ||\n\t        DEQUAL(send1[kj],pintdat->vpoint[ki]->epar[kj]))\n\t      goto end;\n        }\n      else\n        {\n\t  for (kj=0; kj<kpar2; kj++)\n\t    if (DEQUAL(sstart2[kj],pintdat->vpoint[ki]->epar[kpar1+kj]) ||\n\t        DEQUAL(send2[kj],pintdat->vpoint[ki]->epar[kpar1+kj]))\n\t      goto end;\n        }\n      \n      \n      (*rpt) = pintdat->vpoint[ki];\n      goto out;\n    end:;\n    }\n out:;\n}\n"
  },
  {
    "path": "src/s6idklist.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6idklist.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6IDKLIST\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6idklist(SISLIntdat **pintdat,SISLIntlist *pintlist,int *jstat)\n#else\nvoid s6idklist(pintdat,pintlist,jstat)\n     SISLIntdat  **pintdat;\n     SISLIntlist *pintlist;\n     int     *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To remove an intersection list including all intersection points\n*              in the list. The mother pintdat is updated.\n*              If pintdat is empty, pintdat is killed and set to SISL_NULL.\n*\n*\n*\n* INPUT/OUTPUT:pintlist - Pointer to a list.\n*              pintdat  - Pointer to a pointer to intersection data.\n*\n*\n* OUTPUT     :jstat    - status messages  \n*                               = 1      : Pintlist is not in pintdat.\n*                               = 0      : OK!\n*                               < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err      - Gives error message.\n*              s6idkpt    - Kills a point.\n*              freeIntpt  - free instant of intpt structure.\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 08.89.\n*\n*********************************************************************\n*/                                     \n{\n  SISLIntpt *qkillpt,*qnext,*qdum1,*qdum2;\n  \n  int ki,knum,kstat;  \n  \n  *jstat = 0;\n  \n  /* We have to be sure that we have an intdat structure. */\n  \n  if ((*pintdat) == SISL_NULL)\n    goto out;\n  \n  if (pintlist == SISL_NULL)\n    {\n      *jstat = 1;\n      goto out;\n    }\n  \n  /* Now we have to find the index in the vlist array in pintdat. */\n  \n  \n  for (ki=0,knum = -1; ki < (*pintdat)->ilist; ki++)\n    if ((*pintdat)->vlist[ki] == pintlist)\n      {\n\tknum = ki;\n\tbreak;\n      }\n  \n  if (knum == -1)\n    /* Not in the pintdat list. */\n    *jstat = 1;\n  else\n    {\n      pintlist->plast->pcurve = SISL_NULL;\n      \n      /* Kill all points in the list. */\n      for (ki=0,qkillpt=pintlist->pfirst,qnext=qkillpt->pcurve;\n\t   qnext!=SISL_NULL;\n\t   qkillpt=qnext,qnext=qnext->pcurve)\n\t{\n\t  s6idkpt(pintdat,&qkillpt,&qdum1,&qdum2,&kstat);\n\t  if (kstat < 0) goto error;\n\t}\n      s6idkpt(pintdat,&qkillpt,&qdum1,&qdum2,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Update pintdat. */\n      if ((*pintdat) != SISL_NULL)\n\t{\n\t  (*pintdat)->vlist[knum] = (*pintdat)->vlist[(*pintdat)->ilist-1];\n\t  ((*pintdat)->ilist)--;\n\t  (*pintdat)->vlist[(*pintdat)->ilist] = SISL_NULL;\n\t}\n      freeIntlist(pintlist);\n    }\n  \n  goto out;  \n  \n  error : *jstat = kstat;\n  s6err(\"s6idklist\",*jstat,0);\n  goto out;                       \n  \n  out: ;\n}\n"
  },
  {
    "path": "src/s6idkpt.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6idkpt.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6IDKPT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6idkpt(SISLIntdat **pintdat,SISLIntpt **pintpt,SISLIntpt **rtpt,SISLIntpt **rfpt,int *jstat)\n#else\nvoid s6idkpt(pintdat,pintpt,rtpt,rfpt,jstat)\n     SISLIntdat **pintdat;\n     SISLIntpt  **pintpt;\n     SISLIntpt  **rtpt;\n     SISLIntpt  **rfpt;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To remove an intersection point pintpt from pintdat.\n*              Pintpt is than killed. If there is a point pointing on\n*              pintdat ptpt is set to point to this point otherwise\n*              ptpt is SISL_NULL. If pintdat is pointing to a point pfpt is\n*              set to point to this point otherwise pfpt is SISL_NULL.\n*              If pintdat is empty pintdat is killed and set to SISL_NULL.\n*              pintpt is set to SISL_NULL.\n*\n*\n*\n* INPUT/OUTPUT:pintpt   - Pointer to a pointer to new intersection point.\n*              pintdat  - Pointer to a pointer to intersection data.\n*\n*\n* OUTPUT     : rtpt     - Pointer to a pointer to a point pointing to pintpt.\n*              rfpt     - Pointer to a pointer to a point pintpt points to.\n*              jstat    - status messages  \n*                               = 1      : Pintpt is not in pintdat.\n*                               = 0      : OK!\n*                               < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err      - Gives error message.\n*              freeIntpt  - free instant of intpt structure.\n*\n* WRITTEN BY : Arne Laksaa, 05.89.\n*\n*********************************************************************\n*/                                     \n{\n  int ki;              /* Counters.    */\n  int knum;\n  \n  (*rtpt) = (*rfpt) = SISL_NULL;\n  *jstat = 0;\n  \n  /* We have to be sure that we have an intdat structure. */\n  \n  if ((*pintdat) == SISL_NULL)\n    goto out;\n  \n  if ((*pintpt) == SISL_NULL)\n    {\n      *jstat = 1;\n      goto out;\n    }\n  \n  \n  /* Than we have to be sure that we do not have the intersection point\n     before or an equal point. */\n  \n  for (knum = -1,ki=0; ki<(*pintdat)->ipoint; ki++)\n    {\n      if ((*pintdat)->vpoint[ki] == (*pintpt))\n\tknum = ki;\n      \n      if ((*pintdat)->vpoint[ki] == (*pintpt)->pcurve)\n\t(*rfpt) = (*pintdat)->vpoint[ki];\n      \n      if ((*pintdat)->vpoint[ki]->pcurve == (*pintpt))\n\t(*rtpt) = (*pintdat)->vpoint[ki];\n    }\n  \n  \n  if (knum == -1)\n    *jstat = 1;\n  else\n    {\n      (*pintdat)->vpoint[knum] = (*pintdat)->vpoint[(*pintdat)->ipoint-1];\n      ((*pintdat)->ipoint)--;\n      (*pintdat)->vpoint[(*pintdat)->ipoint] = SISL_NULL;\n      \n      if ((*rtpt) != SISL_NULL)\n\t(*rtpt) ->pcurve = SISL_NULL;\n      \n      if ((*pintdat)->ipoint == 0)\n\t{\n\t  freeIntdat(*pintdat);\n\t  (*pintdat) = SISL_NULL;\n\t}\n    }\n  \n  freeIntpt(*pintpt);\n  (*pintpt) = SISL_NULL;\n  \n out: ;\n}\n"
  },
  {
    "path": "src/s6idlis.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6idlis.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n#define S6IDLIS\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void s6idlis_s9ssexamin(SISLSurf *,SISLSurf *,SISLIntdat **,int *);\nstatic void s6idlis_s9psexamin(SISLSurf *,double,SISLIntdat **,int *);\n#else\nstatic void s6idlis_s9ssexamin();\nstatic void s6idlis_s9psexamin();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s6idlis(SISLObject *po1,SISLObject *po2,SISLIntdat **pintdat,int *jstat)\n#else\nvoid s6idlis(po1,po2,pintdat,jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntdat **pintdat;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To update vlist in pintdat.\n*\n*\n* INPUT      : pintdat  - Pointer to a pointer to intersection data.\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                               = 0      : OK !\n*                               < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err       - Gives error message.\n*              newIntlist  - Create new intlist structure.\n*              freeIntlist - Free an intlist structure.\n*\n* WRITTEN BY : Arne Laksaa, 05.89.\n*\n*********************************************************************\n*/                                     \n{\n  int kstat;                /* Local status variable.          */\n  int kpos=0;               /* Position of error.              */\n  int kj,ki1,ki2;           /* Counters                        */\n  int ktype;                /* To indicate type of list.       */\n  SISLIntpt   *pt;       /* to traverse list of points.     */\n  \n  *jstat = 0;\n  \n  /* If we do not have any intersection data we just return. */\n  \n  if ((*pintdat) == SISL_NULL) goto out;\n  \n  /* We first destroy existing intersection lists. */\n  \n  for (kj=0; kj<(*pintdat)->ilist; kj++) freeIntlist((*pintdat)->vlist[kj]);\n  \n  \n  /* Then we split lists with internal junction points. We have to\n     be sure that all junction points are end points in the lists. */\n  \n  for (kj=0; kj<(*pintdat)->ipoint; kj++)\n    if ((*pintdat)->vpoint[kj]->iinter == 2)\n      {\n\tif ((*pintdat)->vpoint[kj]->pcurve != SISL_NULL)\n\t  {\n\t    for (ki1=0; ki1<(*pintdat)->ipoint; ki1++)\n\t      if ((*pintdat)->vpoint[ki1]->pcurve == (*pintdat)->vpoint[kj])\n\t\tbreak;\n\t    \n\t    if (ki1<(*pintdat)->ipoint)\n\t      {\n\t\tpt = copyIntpt((*pintdat)->vpoint[kj]);\n\t\t\n\t\ts6idnpt(pintdat,&pt,0,&kstat);\n\t\tif (kstat < 0) goto error;\n\t\t\n\t\tpt->pcurve = (*pintdat)->vpoint[kj]->pcurve;\n\t\t\n\t\t(*pintdat)->vpoint[kj]->pcurve = SISL_NULL;\n\t      }\n\t  }\n      }\n  \n  \n  /* At least we can traverse all intersection points to look for\n     start points to lists. If a point have a next point\n     and no other point pointing on itself. It is a start point. */\n  \n  for (ki1=0,ki2=0; ki1 < (*pintdat)->ipoint; ki1++)\n    if ((*pintdat)->vpoint[ki1]->pcurve != SISL_NULL)\n      {\n\tfor (kj=0; kj<(*pintdat)->ipoint; kj++)\n\t  if ((*pintdat)->vpoint[kj]->pcurve == (*pintdat)->vpoint[ki1])\n\t    break;\n\t\n\tif (kj == (*pintdat)->ipoint)\n\t  {\n\t    /* To be sure that list array is big enough. */\n\t    \n\t    if (ki2 == (*pintdat)->ilmax)\n\t      {\n\t\t(*pintdat)->ilmax += 20;\n\t\t\n\t\tif (((*pintdat)->vlist = increasearray((*pintdat)->vlist,\n\t\t\t\t\t\t       (*pintdat)->ilmax,SISLIntlist *)) == SISL_NULL)\n\t\t  \n\t\t  goto err101;\n\t      }\n\t    \n\t    \n\t    /* Finding the last point in the list, and number of points. */\n\t    \n\t    kj = 0;\n\t    for (pt=(*pintdat)->vpoint[ki1];pt->pcurve!=SISL_NULL;\n\t\t pt=pt->pcurve,kj++);\n\t    \n\t    \n\t    /* Computing type of point, junctions in the end points. */\n\t    \n\t    ktype = 0;\n\t    \n\t    if ((*pintdat)->vpoint[ki1]->iinter == 2)\n\t      ktype = 2;\n\t    \n\t    if (pt->iinter == 2)\n\t      ktype = (ktype == 2 ? 4 : 3);\n\t    \n\t    \n\t    /* Making a new list structure. */\n\t    \n\t    if (((*pintdat)->vlist[ki2] = newIntlist((*pintdat)->vpoint[ki1],\n\t\t\t\t\t\t     pt,ktype)) == SISL_NULL) goto err101;\n\t    \n\t    (*pintdat)->vlist[ki2]->inumb = kj + 1;\n\t    ki2++;\n\t    \n\t  }\n      }\n  \n  /*------------------------------------------------------------------*/\n  \n  /* We also have to find closed lists.    */\n  \n  /* Mark found list elements: */\n  for (ki1=0; ki1 < ki2; ki1++)\n    for (pt=(*pintdat)->vlist[ki1]->pfirst;pt!=SISL_NULL;pt=pt->pcurve)\n      pt->iinter += 10;\n  \n  /* Now travers the point array untill we find an unmarked point.\n     This point has to be a single (unconnected) one or a member \n     of a closed connection. Mark points in the closed connection and \n     establish a new list. */\n  \n  for (ki1=0; ki1 < (*pintdat)->ipoint; ki1++)\n    {\n      if ((*pintdat)->vpoint[ki1]->iinter>=10)\n\t/* Unmark point. */\n\t(*pintdat)->vpoint[ki1]->iinter -= 10;\n      \n      else  if ((*pintdat)->vpoint[ki1]->pcurve != SISL_NULL)\n\t{\n\t  /* It has to be a closed connection, travers all elements. */\n\t  kj = 1;\n\t  for (pt=(*pintdat)->vpoint[ki1]->pcurve;pt!=(*pintdat)->vpoint[ki1];\n\t       pt=pt->pcurve)\n\t    {\t\n\t      if (pt == SISL_NULL) goto err105;\n\t      /* Mark found list elements: */\n\t      pt->iinter += 10;\n\t      kj++;\n\t    }\n\t  \n\t  /*Create new list element. */\n\t  \n\t  /* To be sure that list array is big enough. */\n\t  if (ki2 == (*pintdat)->ilmax)\n\t    {\n\t      (*pintdat)->ilmax += 20;\n\t      \n\t      if (((*pintdat)->vlist = increasearray((*pintdat)->vlist,\n\t\t\t\t\t\t     (*pintdat)->ilmax,SISLIntlist *)) == SISL_NULL) \n\t\tgoto err101;\n\t    }\n\t  \n\t  /* Closed curves will have no singularities: */\n\t  ktype = 1;\n\t  \n\t  /* Making a new list structure. */\n\t  if (((*pintdat)->vlist[ki2] = \n\t       newIntlist((*pintdat)->vpoint[ki1]->pcurve,\n\t\t\t  (*pintdat)->vpoint[ki1],ktype)) == SISL_NULL) \n\t    goto err101;\n\t  (*pintdat)->vlist[ki2]->inumb = kj;\n\t  ki2++;\n\t  \n\t}\n    }\n  \n  (*pintdat)->ilist = ki2;\n  \n  /*------------------------------------------------------------------*/\n  \n  /* A final check if the geometry found is ok. */\n  \n  if (po1->iobj == SISLSURFACE && po2->iobj == SISLSURFACE && po1->s1->idim == 3)\n    {\n       s6idlis_s9ssexamin(po1->s1,po2->s1,pintdat,&kstat);\n      if (kstat < 0) goto error;\n    }\n  else if (po1->iobj == SISLPOINT && po2->iobj == SISLSURFACE && po1->p1->idim == 1)\n    {\n       s6idlis_s9psexamin(po2->s1,po1->p1->ecoef[0],pintdat,&kstat);\n      if (kstat < 0) goto error;\n    }\n  else if (po1->iobj == SISLSURFACE && po2->iobj == SISLPOINT && po2->p1->idim == 1)\n    {\n       s6idlis_s9psexamin(po1->s1,po2->p1->ecoef[0],pintdat,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  goto out;\n  \n  /* Error in space allocation.  */\n  \n  err101: *jstat = -101;\n  s6err(\"s6idlis\",*jstat,kpos);\n  goto out;\n  \n  /* Error in vpoint array.  */\n  \n  err105: *jstat = -105;\n  s6err(\"s6idlis\",*jstat,kpos);\n  goto out;\n  \n  /* Error in sub function.  */\n  \n  error:  *jstat = kstat;\n  s6err(\"s6idlis\",*jstat,kpos);\n  goto out;\n  \n  out: ;\n  \n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\n   static\n      void\n            s6idlis_s9ssexamin(SISLSurf *ps1,SISLSurf *ps2,\n\t\t\t       SISLIntdat **rintdat,int *jstat)\n#else\nstatic void s6idlis_s9ssexamin(ps1,ps2,rintdat,jstat)\n     SISLSurf   *ps1;\n     SISLSurf   *ps2;\n     SISLIntdat **rintdat;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To examin if the intersection beetween two surfaces\n*              is correct. If something wrong is found the error is\n*              is removed.\n*\n*\n* INPUT      : ps1      - First surface in intersection.\n*              ps2      - Second surface in intersection.\n*\n*\n* OUTPUT     : rintdat  - Intersection dates to be examin.\n*              jstat    - status messages  \n*                           = 0     : OK.\n*                           < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-07.\n*              Ulf J. Krystad\n*********************************************************************\n*/                                     \n{\n  int kstat;\n  int kdirstat;\n  \n  unsigned char edg=0;\n  SISLIntpt **uipt=SISL_NULL;\n  SISLIntlist **uilst=SISL_NULL;\n  \n  int ki,kj,kv,klnr,kpnr,klfs,klft,kdir,kpar;\n  SISLIntpt  *qpt1,*qpt2;\n  SISLIntpt  *qipt, *qp;\n  \n  double tepsge, tang,sedg[8];\n  double sval1[9],sval2[9],snorm1[3],snorm2[3];\n  double stang[3],sdec1[3],sdec2[3];\n  double epar1[4],epar2[4];\n  \n  tepsge = (double)0.001;\n  \n  sedg[0] = ps1->et1[ps1->ik1-1];\n  sedg[1] = ps1->et1[ps1->in1];\n  sedg[2] = ps1->et2[ps1->ik2-1];\n  sedg[3] = ps1->et2[ps1->in2];\n  sedg[4] = ps2->et1[ps2->ik1-1];\n  sedg[5] = ps2->et1[ps2->in1];\n  sedg[6] = ps2->et2[ps2->ik2-1];\n  sedg[7] = ps2->et2[ps2->in2];\n  \n  /* Init */  \n  if (!(*rintdat)) goto out;\n  if (ps1->idim != 3 || ps2->idim != 3) goto err200;\n  *jstat = 0;\n  \n  \n  /* SISLCurve analyse section --------------------------------------------------*/\n  if ((*rintdat)->ilist != 0)\n    {\n      /* Allocate array of pointers to the lists. */\n      klnr = (*rintdat)->ilist;\n      if ((uilst = newarray(klnr,SISLIntlist *)) == SISL_NULL) goto err101;\n      \n      /* Update the list array. */\n      \n      /* Get all open curves into array. */\n      for (kv=ki=0; ki<klnr; ki++)\n        if ((*rintdat)->vlist[ki]->itype != 1)\n\t  uilst[kv++] = (*rintdat)->vlist[ki];\n      \n      /* Correct number of curves.*/\n      klnr = kv;\n      \n      /* Remove all open curves with endpoints on edges or singular \n\t endpoints from array.(they are ok.) */\n      for (ki=0; ki<klnr; ki++)\n\t{\n\t  for (kj=0; kj<8; kj++)\n\t    if (DEQUAL(uilst[ki]->pfirst->epar[(kj/2)],sedg[kj]))\n\t      break;\n\t  \n\t  \n\t  if (kj == 8)\n\t    {\n\t      /* Start point is NOT on edge, test if the point \n\t\t is a singular point. */\n\t      \n\t      klfs=klft=0;\n\t      s1421(ps1,1,uilst[ki]->pfirst->epar,&klfs,&klft,sval1,\n\t\t    snorm1,&kstat);\n\t      if (kstat < 0) goto error;\n\t      else if (kstat > 0 ) kj--;\n\t      \n\t      klfs=klft=0;\n\t      s1421(ps2,1,uilst[ki]->pfirst->epar+2,&klfs,&klft,sval2,\n\t\t    snorm2,&kstat);\n\t      if (kstat < 0) goto error;\n\t      else if (kstat > 0 ) kj--;\n\t      \n\t      tang = s6ang(snorm1,snorm2,3);\n\t      if (tang < ANGULAR_TOLERANCE) kj--;\n\t    }\t    \n\t  \n\t  \n\t  if (kj<8)\n\t    {\n\t      /* Start point is ok, test end point*/\n\t      for (kj=0; kj<8; kj++)\n\t\tif (DEQUAL(uilst[ki]->plast->epar[(kj/2)],sedg[kj]))\n\t\t  break;\n\t      \n\t      \n\t      if (kj == 8)\n\t\t{\n\t\t  /* End point is NOT on edge, test if the point \n\t\t     is a singular point. */\n\t\t  klfs=klft=0;\n\t\t  s1421(ps1,1,uilst[ki]->plast->epar,&klfs,&klft,sval1,\n\t\t\tsnorm1,&kstat);\n\t\t  if (kstat < 0) goto error;\n\t\t  else if (kstat > 0 ) kj--;\n\t\t  \n\t\t  klfs=klft=0;\n\t\t  s1421(ps2,1,uilst[ki]->plast->epar+2,&klfs,&klft,sval2,\n\t\t\tsnorm2,&kstat);\n\t\t  if (kstat < 0) goto error;\n\t\t  else if (kstat > 0 ) kj--;\n\t\t  \n\t\t  tang = s6ang(snorm1,snorm2,3);\n\t\t  if (tang < ANGULAR_TOLERANCE) kj--;\n\t\t}\t    \n\t      \n\t      \n\t      if (kj<8)\n\t\t{\n\t\t  /* Start point and end point is ok, remove it from the array*/\n\t\t  klnr--;\n\t\t  if (ki<klnr)\n\t\t    {\n\t\t      uilst[ki] = uilst[klnr];\n\t\t      ki--;\n\t\t    }\n\t\t  \n\t\t}\n\t    }\n\t}\n      \n      /* Now we only have curves with bad endpoints in the array. */\n      \n      for (ki=0; ki< klnr; ki++)\n\t{\n\t  /* Now we kill all the points in the list except the\n\t     end point that is an internal point . */\n\t  \n\t  for (kj=0; kj<8; kj++)\n\t    if (DEQUAL(uilst[ki]->pfirst->epar[(kj/2)],sedg[kj]))\n\t      break;\n\t  \n\t  if (kj<8)\n\t    {\n\t      \n\t      /* The first point is on the edge, keep the last. */\n\t      qipt = uilst[ki]->pfirst;\n\t      for (qp=qipt->pcurve; qipt != uilst[ki]->plast;qipt=qp,qp=qp->pcurve)\n\t\t{\n\t\t  s6idkpt(rintdat,&qipt,&qpt1,&qpt2,&kstat);\n\t\t  if (kstat < 0) goto error;\n\t\t}\n\t      \n\t      qipt = uilst[ki]->plast;\n\t      uilst[ki]->pfirst = uilst[ki]->plast =  qipt;\n\t      uilst[ki]->inumb = 1;\n\t    }\n\t  else\n\t    {\n\t      /* The first point is not on the edge, keep it. */\n\t      \n\t      for (qipt = uilst[ki]->pfirst->pcurve; qipt != SISL_NULL;qipt=qp)\t      \n\t\t{\n\t\t  s6idkpt(rintdat,&qipt,&qpt1,&qp,&kstat);\n\t\t  if (kstat < 0) goto error;\n\t\t}\n\t      \n\t      qipt = uilst[ki]->pfirst;\n\t      uilst[ki]->pfirst = uilst[ki]->plast =  qipt;\n\t      uilst[ki]->inumb = 1;\n\t      \n\t    }\n\t  \n\t  /* March from point qipt */\n\t  s1788(ps1,ps2,tepsge,qipt->epar,epar1,epar2,&kstat);\n          if (kstat<0) goto error;\n\t  \n\t  if (kstat == 0)\n            {\n\t      /* No succes. */\n\t      /* Kill point and the list */\n\t      s6idklist(rintdat,uilst[ki],&kstat);\n\t      if (kstat<0) goto error;\n\t      klnr--;\n\t      if (ki < klnr)\n\t\t{\n\t\t  uilst[ki] = uilst[klnr];\n\t\t  ki--;\n\t\t}\n\t      \n\t    }\n\t  else if (kstat == 11 || kstat == 12 || kstat == 13 ||\n\t           kstat == 14 || kstat == 21 || kstat == 22 || kstat == 24 )\n\t    {\n\t      /* Making a new open curve with endpoint in epar1 and epar2.*/\n\t      \n\t      uilst[ki]->pfirst = newIntpt(4,epar1,DZERO);\n\t      if (uilst[ki]->pfirst == SISL_NULL) goto err101;\n\t      \n\t      s6idnpt(rintdat,&uilst[ki]->pfirst,0,&kstat);\n\t      if (kstat < 0)goto error;\n\t      \n\t      uilst[ki]->plast = newIntpt(4,epar2,DZERO);\n\t      if (uilst[ki]->plast == SISL_NULL) goto err101;\n\t      \n\t      s6idnpt(rintdat,&uilst[ki]->plast,0,&kstat);\n\t      if (kstat < 0)goto error;\n\t      \n\t      uilst[ki]->pfirst->pcurve = qipt;\n\t      qipt->pcurve = uilst[ki]->plast;\n\t      uilst[ki]->inumb = 3;\n              uilst[ki]->itype = 4;\n\t    }\n\t  \n\t  else if (kstat == 16 || kstat == 17 || kstat == 26 || kstat == 27)\n\t    {\n\t      /* Making a new closed curve with pfirst and plast\n                 pointing on qipt.*/\n\t      \n              uilst[ki]->pfirst = uilst[ki]->plast = qipt;\n\t      uilst[ki]->inumb = 1;\n              uilst[ki]->itype = 1;\n\t      qipt->pcurve = qipt;\n\t      \n\t    }\n\t}\n      /* Now we check equality between the remaining curves in the array. */\n      for (ki=0;ki<klnr-1;ki++)\n\tfor (kj=ki+1;kj<klnr;kj++)\n\t  {\n\t    if ((s6dist(uilst[ki]->pfirst->epar,uilst[kj]->pfirst->epar,4)\n\t\t < REL_COMP_RES &&\n\t\t s6dist(uilst[ki]->plast->epar,uilst[kj]->plast->epar,4)\n\t\t < REL_COMP_RES)  ||\n\t\t(s6dist(uilst[ki]->pfirst->epar,uilst[kj]->plast->epar,4)\n\t\t < REL_COMP_RES &&\n\t\t s6dist(uilst[ki]->plast->epar,uilst[kj]->pfirst->epar,4)\n\t\t < REL_COMP_RES))\n\t      /* The two curves has common start+end, remove the last one of them. */\n\t      {\n\t\t\n\t\ts6idklist(rintdat,uilst[kj],&kstat);\n\t\tif (kstat<0) goto error;\n\t\t\n\t\tklnr--;\n\t\tif (kj < klnr)\n\t\t  {\n\t\t    uilst[kj] = uilst[klnr];\n\t\t    kj--;\n\t\t  }\n\t\t\n\t      }\n\t  }\n      \n    }\n  \n  \n  /* End of curve analyse section -------------------------------------------*/\n  \n  /* SISLPoint analyse section --------------------------------------------------*/\n  \n  if ((*rintdat) && (*rintdat)->ipoint != 0)\n    /* Update the point array. */\n    {     \n      kpnr = (*rintdat)->ipoint;\n      if ((uipt = newarray(kpnr,SISLIntpt *)) == SISL_NULL) goto err101;\n      \n      \n      for (kv=ki=0; ki<kpnr; ki++)\n        if ((*rintdat)->vpoint[ki]->pcurve == SISL_NULL)\n\t  uipt[kv++] = (*rintdat)->vpoint[ki];\n      \n      for (ki=0; ki<kpnr; ki++)\n        for (kj=0; kj<kv; kj++)\n          if ((*rintdat)->vpoint[ki]->pcurve == uipt[kj])\n            {\n\t      kv--;\n      \t      uipt[kj] = uipt[kv];\n              break;\n            }\n      \n      /* All single points found. */\n      kpnr = kv;\n      \n      \n      /* Sorting out and killing all points but single touch points. */\n      \n      for (ki=0; ki<kpnr; ki++)\n\t{\n\t  klfs=klft=0;\n\t  s1421(ps1,1,uipt[ki]->epar,&klfs,&klft,sval1,snorm1,&kstat);\n\t  if (kstat < 0) goto error;\n\t  else if (kstat > 0 ) continue;\n\t  \n\t  if (s6length(snorm1,3,&kstat) <= REL_COMP_RES) continue;\n\t  \n\t  klfs=klft=0;\n\t  s1421(ps2,1,uipt[ki]->epar+2,&klfs,&klft,sval2,snorm2,&kstat);\n\t  if (kstat < 0) goto error;\n\t  else if (kstat > 0 ) continue;\n\t  \n\t  if (s6length(snorm2,3,&kstat) <= REL_COMP_RES) continue;\n\t  \n\t  tang = s6ang(snorm1,snorm2,3);\n\t  if (tang < ANGULAR_TOLERANCE) continue;\t    \n\t  \n\t  \n\t  /* All singular points or degenerated points is ok. We\n\t     then remove all other internal points. */\n\t  \n\t  for (kj=0,edg=0; kj<8; kj++)\n\t    if (DEQUAL(uipt[ki]->epar[(kj/2)],sedg[kj]))\n\t      edg |= 1<<kj;\n\t  \n\t  if (edg == 0)\n\t    {\n\t      /* The point is removed. */\n\t      \n\t      s6idkpt(rintdat,&uipt[ki],&qpt1,&qpt2,&kstat);\n\t      if (kstat < 0) goto error;\n\t      \n\t      kpnr--;\n\t      \n\t      if (ki < kpnr)\n\t\t{\n\t\t  uipt[ki] = uipt[kpnr];\n\t\t  ki--;\n\t\t}\n\t      \n\t      continue;\n\t    }\n\t  \n\t  \n\t  s6crss(snorm1,snorm2,stang);\n\t  \n\t  s6decomp(stang,sdec1,sval1+3,sval1+6,snorm1,&kstat);\n\t  if (kstat < 0) goto error;\n\t  else if (kstat > 0 ) continue;\n\t  \n\t  s6decomp(stang,sdec2,sval2+3,sval2+6,snorm2,&kstat);\n\t  if (kstat < 0) goto error;\n\t  else if (kstat > 0 ) continue;\n\t  \n\t  for (kpar=1,kdir=kdirstat=0,kj=0; kj<8; kj++)\n\t    if ((edg & 1<<kj) == 1<<kj)\n\t      {\n\t\tswitch (kj) \n\t\t  {\n\t\t  case 0: tang = s6ang(stang,sval1+3,3);\n\t\t    kdir = (sdec1[1] > DZERO ?  1 : -1);\n\t\t    break;\n\t\t  case 4: tang = s6ang(stang,sval2+3,3);\n\t\t    kdir = (sdec2[1] > DZERO ?  1 : -1);\n\t\t    break;\n\t\t  case 1: tang = s6ang(stang,sval1+6,3);\n\t\t    kdir = (sdec1[0] > DZERO ?  -1 : 1);\n\t\t    break;\n\t\t  case 5: tang = s6ang(stang,sval2+6,3);\n\t\t    kdir = (sdec2[0] > DZERO ?  -1 : 1);\n\t\t    break;\n\t\t  case 2: tang = s6ang(stang,sval1+3,3);\n\t\t    kdir = (sdec1[1] > DZERO ?  -1 : 1);\n\t\t    break;\n\t\t  case 6: tang = s6ang(stang,sval2+3,3);\n\t\t    kdir = (sdec2[1] > DZERO ?  -1 : 1);\n\t\t    break;\n\t\t  case 3: tang = s6ang(stang,sval1+6,3);\n\t\t    kdir = (sdec1[0] > DZERO ?  1 : -1);\n\t\t    break;\n\t\t  case 7: tang = s6ang(stang,sval2+6,3);\n\t\t    kdir = (sdec2[0] > DZERO ?  1 : -1);\n\t\t  }\n\t\t\n\t\tif (tang < ANGULAR_TOLERANCE) kdir = 0;\n\t\t\n\t\tif (kdir == 0)\n\t\t  kpar = 0;\n\t\telse if (kdirstat != kdir)\n\t\t  {\n\t\t    if (kdirstat == 0)\n\t\t      kdirstat = kdir;\n\t\t    else\n\t\t      {\n\t\t\tkdirstat = 10;\n\t\t\tbreak;\n\t\t      }\n\t\t  }\n\t      }\n\t  \n\t  if (kpar == 0 && kdirstat != 10) kdirstat = 0;\n\t  \n\t  /* Test if the point is to be removed.*/\n\t  if (kdirstat == 1 || kdirstat == -1)\n\t    {\n\t      /* The point is removed. */\n\t      \n\t      s6idkpt(rintdat,&uipt[ki],&qpt1,&qpt2,&kstat);\n\t      if (kstat < 0) goto error;\n\t      \n\t      kpnr--;\n\t      \n\t      if (ki < kpnr)\n\t\t{\n\t\t  uipt[ki] = uipt[kpnr];\n\t\t  ki--;\n\t\t}\n\t      \n\t      continue;\n\t    }\n\t  \n\t} /* End of for ki= .... */\n      \n    }\n  /* End of point analyse section ---------------------------------------------*/ \n  \n  \n  goto out;\n  \n  /* Error in sub rutines.      */\n  \n  error : *jstat = kstat;\n  s6err(\"s6idlis_s9ssexamin\",*jstat,0);\n  goto out;                       \n  \n  /* Error in memory allocation.      */\n  \n  err101 : *jstat = -101;\n  s6err(\"s6idlis_s9ssexamin\",*jstat,0);\n  goto out;                       \n  \n  /* Error dimention.      */\n  \n  err200 : *jstat = -200;\n  s6err(\"s6idlis_s9ssexamin\",*jstat,0);\n  goto out;                       \n  \n  out:\n  if (uipt != SISL_NULL)  freearray(uipt);\n  if (uilst != SISL_NULL)   freearray(uilst);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\n   static\n      void\n            s6idlis_s9psexamin(SISLSurf *ps1,double alevel,\n\t\t\t       SISLIntdat **rintdat,int *jstat)\n#else\nstatic void s6idlis_s9psexamin(ps1,alevel,rintdat,jstat)\n     SISLSurf   *ps1;\n     double alevel;\n     SISLIntdat **rintdat;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To examin if the intersection beetween a surface\n*              and a point in dim 1 is correct. If something wrong \n*              is found the error is\n*              is removed.\n*\n*\n* INPUT      : ps1      - First surface in intersection.\n*              alevel   - The point value.\n*\n*\n*INPUT/OUTPUT: rintdat  - Intersection dates to be examin.\n*\n* OUTPUT     : jstat    - status messages  \n*                           = 0     : OK.\n*                           < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 10.08.89\n* Revised by : Christophe Rene Birkeland, SINTEF Oslo, May 1993.\n*              jstat set to 0 in start.\n*\n*********************************************************************\n*/                                     \n{\n  int kstat;\n  int kdirstat;\n  \n  unsigned char edg=0;\n  SISLIntpt **uipt=SISL_NULL;\n  SISLIntlist **uilst=SISL_NULL;\n  \n  int ki,kj,kv,klnr,kpnr,klfs,klft,kdir,kpar;\n  SISLIntpt *qpt1,*qpt2;\n  SISLIntpt *qipt, *qp;\n  \n  double tepsge, tmax,sedg[4];\n  double sval1[9],snorm1[3];\n  double epar1[2],epar2[2];\n/* ALA && UJK 19.09.90 */\n  double ttol= 10000.0 * REL_COMP_RES;\n  \n  tepsge = (double)0.001;\n  \n  sedg[0] = ps1->et1[ps1->ik1-1];\n  sedg[1] = ps1->et1[ps1->in1];\n  sedg[2] = ps1->et2[ps1->ik2-1];\n  sedg[3] = ps1->et2[ps1->in2];\n  \n  \n  /* Init */ \n  if (!(*rintdat)) goto out;\n  if (ps1->idim != 1) goto err200;\n  *jstat = 0;\n  \n  \n  /* SISLCurve analyse section --------------------------------------------------*/\n  \n  if ((*rintdat)->ilist != 0)\n    {\n      /* Allocate array of pointers to the lists. */\n      klnr = (*rintdat)->ilist;\n      if ((uilst = newarray(klnr,SISLIntlist *)) == SISL_NULL) goto err101;\n      \n      /* Update the list array. */\n      \n      /* Get all open curves into array. */\n      for (kv=ki=0; ki<klnr; ki++)\n        if ((*rintdat)->vlist[ki]->itype != 1)\n\t  uilst[kv++] = (*rintdat)->vlist[ki];\n      \n      /* Correct number of curves.*/\n      klnr = kv;\n      \n      /* Remove all open curves with endpoints on edges or singular \n\t endpoints from array.(they are ok.) */\n      for (ki=0; ki<klnr; ki++)\n\t{\n\t  for (kj=0; kj<4; kj++)\n\t    if (DEQUAL(uilst[ki]->pfirst->epar[(kj/2)],sedg[kj]))\n\t      break;\n\t  \n\t  \n\t  if (kj == 4)\n\t    {\n\t      /* Start point is NOT on edge, test if the point \n\t\t is a singular point. */\n\t      \n\t      klfs=klft=0;\n\t      s1421(ps1,1,uilst[ki]->pfirst->epar,&klfs,&klft,sval1,\n\t\t    snorm1,&kstat);\n\t      if (kstat < 0) goto error;\n\t      else if (kstat > 0 ) kj--;\n\t      \n\t      tmax = sqrt(sval1[1]*sval1[1] + sval1[2]*sval1[2]);\n\t      if ( tmax < ttol ) kj--;\n\t      \n\t    }\t    \n\t  \n\t  \n\t  if (kj<4)\n\t    {\n\t      /* Start point is ok, test end point*/\n\t      for (kj=0; kj<4; kj++)\n\t\tif (DEQUAL(uilst[ki]->plast->epar[(kj/2)],sedg[kj]))\n\t\t  break;\n\t      \n\t      \n\t      if (kj == 4)\n\t\t{\n\t\t  /* End point is NOT on edge, test if the point \n\t\t     is a singular point. */\n\t\t  klfs=klft=0;\n\t\t  s1421(ps1,1,uilst[ki]->plast->epar,&klfs,&klft,sval1,\n\t\t\tsnorm1,&kstat);\n\t\t  if (kstat < 0) goto error;\n\t\t  else if (kstat > 0 ) kj--;\n\t\t  \n\t\t  tmax = sqrt(sval1[1]*sval1[1] + sval1[2]*sval1[2]);\n\t\t  if ( tmax < ttol ) kj--;\n\t\t  \n\t\t}\t    \n\t      \n\t      \n\t      if (kj<4)\n\t\t{\n\t\t  /* Start point and end point is ok, remove it from the array*/\n\t\t  klnr--;\n\t\t  if (ki<klnr)\n\t\t    {\n\t\t      uilst[ki] = uilst[klnr];\n\t\t      ki--;\n\t\t    }\n\t\t  \n\t\t}\n\t    }\n\t}\n      \n      /* Now we only have curves with bad endpoints in the array. */\n      \n      for (ki=0; ki< klnr; ki++)\n\t{\n\t  /* Now we kill all the points in the list except the\n\t     end point that is an internal point . */\n\t  \n\t  for (kj=0; kj<4; kj++)\n\t    if (DEQUAL(uilst[ki]->pfirst->epar[(kj/2)],sedg[kj]))\n\t      break;\n\t  \n\t  if (kj<4)\n\t    {\n\t      \n\t      /* The first point is on the edge, keep the last. */\n\t      qipt = uilst[ki]->pfirst;\n\t      for (qp=qipt->pcurve; qipt != uilst[ki]->plast;qipt=qp,qp=qp->pcurve)\n\t\t{\n\t\t  s6idkpt(rintdat,&qipt,&qpt1,&qpt2,&kstat);\n\t\t  if (kstat < 0) goto error;\n\t\t}\n\t      \n\t      qipt = uilst[ki]->plast;\n\t      uilst[ki]->pfirst = uilst[ki]->plast =  qipt;\n\t      uilst[ki]->inumb = 1;\n\t    }\n\t  else\n\t    {\n\t      /* The first point is not on the edge, keep it. */\n\t      \n\t      for (qipt = uilst[ki]->pfirst->pcurve; qipt != SISL_NULL;qipt=qp)\t      \n\t\t{\n\t\t  s6idkpt(rintdat,&qipt,&qpt1,&qp,&kstat);\n\t\t  if (kstat < 0) goto error;\n\t\t}\n\t      qipt = uilst[ki]->pfirst;\n\t      uilst[ki]->pfirst = uilst[ki]->plast =  qipt;\n\t      uilst[ki]->inumb = 1;\n\t    }\n\t  \n\t  /* March from point qipt */\n\t  s1787(ps1,alevel,tepsge,qipt->epar,epar1,epar2,&kstat);\n          if (kstat<0) goto error;\n\t  \n\t  if (kstat == 0)\n            {\n\t      /* No succes. */\n\t      /* Kill point and the list */\n\t      s6idklist(rintdat,uilst[ki],&kstat);\n\t      if (kstat<0) goto error;\n\t      \n\t      klnr--;\n\t      if (ki < klnr)\n\t\t{\n\t\t  uilst[ki] = uilst[klnr];\n\t\t  ki--;\n\t\t}\n\t      \n\t    }\n\t  else if (kstat == 11 || kstat == 12 || kstat == 13 ||\n\t           kstat == 14 || kstat == 21 || kstat == 22 || kstat == 24 )\n\t    {\n\t      /* Making a new open curve with endpoint in epar1 and epar2.*/\n\t      \n\t      uilst[ki]->pfirst = newIntpt(2,epar1,DZERO);\n\t      if (uilst[ki]->pfirst == SISL_NULL) goto err101;\n\t      \n\t      s6idnpt(rintdat,&uilst[ki]->pfirst,0,&kstat);\n\t      if (kstat < 0)goto error;\n\t      \n\t      uilst[ki]->plast = newIntpt(2,epar2,DZERO);\n\t      if (uilst[ki]->plast == SISL_NULL) goto err101;\n\t      \n\t      s6idnpt(rintdat,&uilst[ki]->plast,0,&kstat);\n\t      if (kstat < 0)goto error;\n\t      \n\t      uilst[ki]->pfirst->pcurve = qipt;\n\t      qipt->pcurve = uilst[ki]->plast;\n\t      uilst[ki]->inumb = 3;\n              uilst[ki]->itype = 4;\n\t    }\n\t  \n\t  else if (kstat == 16 || kstat == 17 || kstat == 26 || kstat == 27)\n\t    {\n\t      /* Making a new closed curve with pfirst and plast\n                 pointing on qipt.*/\n\t      \n              uilst[ki]->pfirst = uilst[ki]->plast = qipt;\n\t      uilst[ki]->inumb = 1;\n              uilst[ki]->itype = 1;\n\t      qipt->pcurve = qipt;\n\t    }\n\t}\n      /* Now we check equality between the remaining curves in the array. */\n      for (ki=0;ki<klnr-1;ki++)\n\tfor (kj=ki+1;kj<klnr;kj++)\n\t  {\n\t    if ((s6dist(uilst[ki]->pfirst->epar,uilst[kj]->pfirst->epar,2)\n\t\t < REL_COMP_RES &&\n\t\t s6dist(uilst[ki]->plast->epar,uilst[kj]->plast->epar,2)\n\t\t < REL_COMP_RES)  ||\n\t\t(s6dist(uilst[ki]->pfirst->epar,uilst[kj]->plast->epar,2)\n\t\t < REL_COMP_RES &&\n\t\t s6dist(uilst[ki]->plast->epar,uilst[kj]->pfirst->epar,2)\n\t\t < REL_COMP_RES))\n\t      /* The two curves has common start+end, remove the last one of them. */\n\t      {\n\t\t\n\t\ts6idklist(rintdat,uilst[kj],&kstat);\n\t\tif (kstat<0) goto error;\n\t\t\n\t\tklnr--;\n\t\tif (kj < klnr)\n\t\t  {\n\t\t    uilst[kj] = uilst[klnr];\n\t\t    kj--;\n\t\t  }\n\t\t\n\t      }\n\t  }\n      \n    }\n  \n  \n  /* End of curve analyse section -------------------------------------------*/\n  \n  /* SISLPoint analyse section --------------------------------------------------*/\n  \n  if ((*rintdat) && (*rintdat)->ipoint != 0)\n    \n    /* Update the point array. */\n    {     \n      kpnr = (*rintdat)->ipoint;\n      if ((uipt = newarray(kpnr,SISLIntpt *)) == SISL_NULL) goto err101;\n      \n      \n      for (kv=ki=0; ki<kpnr; ki++)\n        if ((*rintdat)->vpoint[ki]->pcurve == SISL_NULL)\n\t  uipt[kv++] = (*rintdat)->vpoint[ki];\n      \n      for (ki=0; ki<kpnr; ki++)\n        for (kj=0; kj<kv; kj++)\n          if ((*rintdat)->vpoint[ki]->pcurve  == uipt[kj])\n            {\n\t      kv--;\n      \t      uipt[kj] = uipt[kv];\n              break;\n            }\n      \n      /* All single points found. */\n      kpnr = kv;\n      \n      \n      /* Sorting out and killing all points but single touch points. */\n      \n      for (ki=0; ki<kpnr; ki++)\n\t{\n\t  klfs=klft=0;\n\t  s1421(ps1,1,uipt[ki]->epar,&klfs,&klft,sval1,snorm1,&kstat);\n\t  if (kstat < 0) goto error;\n\t  else if (kstat > 0 ) continue;\n\t  \n\t  tmax = sqrt(sval1[1]*sval1[1] + sval1[2]*sval1[2]);\n\t  if ( tmax < ttol ) continue;\n\t  \n\t  \n\t  /* All singular points or degenerated points is ok. We\n\t     then remove all other internal points. */\n\t  \n\t  for (kj=0,edg=0; kj<4; kj++)\n\t    if (DEQUAL(uipt[ki]->epar[(kj/2)],sedg[kj]))\n\t      edg |= 1<<kj;\n\t  \n\t  if (edg == 0)\n\t    {\n\t      /* The point is removed. */\n\t      \n\t      s6idkpt(rintdat,&uipt[ki],&qpt1,&qpt2,&kstat);\n\t      if (kstat < 0) goto error;\n\t      \n\t      kpnr--;\n\t      \n\t      if (ki < kpnr)\n\t\t{\n\t\t  uipt[ki] = uipt[kpnr];\n\t\t  ki--;\n\t\t}\n\t      \n\t      continue;\n\t    }\n\t  \n\t  /* Now we remove all edge points with in/out component. */\n\t  for (kpar=1,kj=0,kdir=kdirstat=0; kj<4; kj++)\n\t    if ((edg & 1<<kj) == 1<<kj)\n\t      {\n\t\tswitch (kj) \n\t\t  {\n\t\t  case 0:\n\t\t    if (fabs(sval1[1]/tmax) < ttol)\n\t\t      kdir = 0;\n\t\t    else\n\t\t      kdir = (sval1[1] > DZERO ?  1 : -1);\n\t\t    break;\n\t\t  case 1:\n\t\t    if (fabs(sval1[2]/tmax) < ttol)\n\t\t      kdir = 0;\n\t\t    else\n\t\t      kdir = (sval1[2] > DZERO ?  1 : -1);\n\t\t    break;\n\t\t  case 2:\n\t\t    if (fabs(sval1[1]/tmax) < ttol)\n\t\t      kdir = 0;\n\t\t    else\n\t\t      kdir = (sval1[1] > DZERO ?  -1 : 1);\n\t\t    break;\n\t\t  case 3:\n\t\t    if (fabs(sval1[2]/tmax) < ttol)\n\t\t      kdir = 0;\n\t\t    else\n\t\t      kdir = (sval1[2] > DZERO ?  -1 : 1);\n\t\t  }\n\t\t\n\t\tif (kdir == 0)\n\t\t  kpar = 0;\n\t\telse if (kdirstat != kdir)\n\t\t  {\n\t\t    if (kdirstat == 0)\n\t\t      kdirstat = kdir;\n\t\t    else\n\t\t      {\n\t\t\tkdirstat = 10;\n\t\t\tbreak;\n\t\t      }\n\t\t  }\n\t      }\n\t  \n\t  if (kpar == 0 && kdirstat != 10) kdirstat = 0;\n\t  \n\t  /* Test if the point is to be removed.*/\n\t  if (kdirstat == 1 || kdirstat == -1)\n\t    {\n\t      /* The point is removed. */\n\t      \n\t      s6idkpt(rintdat,&uipt[ki],&qpt1,&qpt2,&kstat);\n\t      if (kstat < 0) goto error;\n\t      \n\t      kpnr--;\n\t      \n\t      if (ki < kpnr)\n\t\t{\n\t\t  uipt[ki] = uipt[kpnr];\n\t\t  ki--;\n\t\t}\n\t      \n\t      continue;\n\t    }\n\t  \n\t} /* End of for ki= .... */\n      \n    }\n  /* End of point analyse section ---------------------------------------------*/ \n    \n  goto out;\n  \n  /* Error in sub rutines.      */\n  \n  error : \n    *jstat = kstat;\n    s6err(\"s6idlis_s9psexamin\",*jstat,0);\n    goto out;                       \n  \n  /* Error in memory allocation.      */\n  \n  err101 : \n    *jstat = -101;\n    s6err(\"s6idlis_s9psexamin\",*jstat,0);\n    goto out;                       \n  \n  /* Error dimention.      */\n  \n  err200 : \n    *jstat = -200;\n    s6err(\"s6idlis_s9psexamin\",*jstat,0);\n    goto out;                       \n  \n  out:\n    if (uipt != SISL_NULL)  freearray(uipt);\n    if (uilst != SISL_NULL) freearray(uilst);\n}\n"
  },
  {
    "path": "src/s6idnpt.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6idnpt.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6IDNPT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6idnpt(SISLIntdat **pintdat,SISLIntpt **pintpt,int itest,int *jstat)\n#else\nvoid s6idnpt(pintdat,pintpt,itest,jstat)\n     SISLIntdat **pintdat;\n     SISLIntpt  **pintpt;\n     int    itest;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To insert a new intersection point into pintdat.\n*              If pintdat is SISL_NULL a new pintdat is also made.\n*              If pintpt is close to an other intersection point\n*              the object pintpt is pointing to is freed, and\n*              pintpt is set to point to the already inserted point.\n*\n*\n*\n* INPUT      : pintpt   - Pointer to a pointer to new intersection point.\n*              pintdat  - Pointer to a pointer to intersection data.\n*              itest    - Indikate testing equalety.\n*                               = 1      : Testing.\n*                               = 0      : No testing.\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                               = 2      : Already existing.\n*                               = 1      : Already inserted.\n*                               = 0      : Intersection point inserted.\n*                               < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err      - Gives error message.\n*              newIntdat  - Create new intdat structure.\n*              freeIntpt  - free instant of intpt structure.\n*\n* WRITTEN BY : Arne Laksaa, 05.89.\n*\n*********************************************************************\n*/                                     \n{\n  register int ki,kj;              /* Counters.    */\n  \n  /* We have to be sure that we have an intdat structure. */\n  \n  if ((*pintdat) == SISL_NULL)\n    {\n      if (((*pintdat) = newIntdat()) == SISL_NULL) goto err101;\n    }\n  \n  \n  /* Than we have to be sure that we do not have the intersection point\n     before or an equal point. */\n  \n  for (ki=0; ki<(*pintdat)->ipoint; ki++)\n    if ((*pintdat)->vpoint[ki] == (*pintpt))\n      {\n\t*jstat = 1;\n\tgoto out;\n      }\n    else if (itest && (*pintpt)->iinter != 2)\n      {\n\tfor (kj=0; kj<(*pintpt)->ipar; kj++)\n\t  if (DNEQUAL((*pintpt)->epar[kj],(*pintdat)->vpoint[ki]->epar[kj]))\n\t    break;\n\t\n\tif (kj == (*pintpt)->ipar)\n\t  {\n\t    freeIntpt(*pintpt);\n\t    (*pintpt) = (*pintdat)->vpoint[ki];\n\t    *jstat = 2;\n\t    goto out;\n\t  }\n      }\n  \n  \n  /* Than we have to be sure that the array vpoint is great enought. */\n  \n  if (ki == (*pintdat)->ipmax)\n    {\n      (*pintdat)->ipmax += 20;\n      \n      if (((*pintdat)->vpoint = increasearray((*pintdat)->vpoint,\n\t\t\t\t\t      (*pintdat)->ipmax,SISLIntpt *)) == SISL_NULL) \n\tgoto err101;\n    }\n  \n  \n  /* Now we can insert the new point. */\n  \n  (*pintdat)->vpoint[ki] = (*pintpt);\n  (*pintdat)->ipoint++;\n  *jstat = 0;\n  goto out;\n  \n\n/* Error in space allocation.  */\n\nerr101: *jstat = -101;\n        s6err(\"s6idnpt\",*jstat,0);\n        goto out;\n\n out: ;\n}\n"
  },
  {
    "path": "src/s6idput.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6idput.c,v 1.2 2001-03-19 15:59:01 afr Exp $\n *\n */\n\n\n#define S6IDPUT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6idput(SISLIntdat **rintdat,SISLIntdat *pintdat,int inr,double apar,int *jstat)\n#else\nvoid s6idput(rintdat,pintdat,inr,apar,jstat)\n     SISLIntdat **rintdat;\n     SISLIntdat *pintdat;\n     int    inr;\n     double apar;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To insert all points in one intdat with one less number\n*              of parameters into rintdat. New copies is made with\n*              the missing parameter. All listes is also to\n*              be uppdated.\n*\n*\n*\n* INPUT      : pintdat  - Pointer to intersection data with one less\n*                         parameter than rintdat.\n*              inr      - Number of the parameter that is missing in pintdat.\n*              apar     - Parameter value of the missing parameter.\n*\n*\n* OUTPUT     : rintdat  - Pointer to a pointer to intersection data.\n*              jstat    - status messages  \n*                               = 0      : Inserting done.\n*                               < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err      - Gives error message.\n*              s6idnpt    - Insert a new intpt structure.\n*              copyIntpt  - Copy an intpt structure.\n*              newIntdat  - Create new intdat structure.\n*\n* WRITTEN BY : Arne Laksaa, 05.89.\n*              UJK, 01.91 Changed a call to newIntpt, copying the\n*                         attribute adist.\n*********************************************************************\n*/                                     \n{\n  int kstat;                    /* Local status variable.               */\n/*guen  int kpos;    */                 /* Position of error.                   */\n/*guen changed into: */\n  int kpos=0;                     /* Position of error.                   */\n  int ki,kj;                    /* Counters                             */\n  int kant;                     /* Number of parameters in new points.  */\n  double *spar = SISL_NULL;          /* Storing uppdated parametervalues.    */\n  SISLIntpt **uintpt = SISL_NULL; /* Pointers to new intersection points. */\n  \n  \n  /* We have to be sure that we have an intdat structure. */\n  \n  if (pintdat == SISL_NULL)\n    {\n      *jstat = 0;\n      goto out;\n    }\n  \n  /* Computing number of new parameter direction. */\n  \n  kant = pintdat->vpoint[0]->ipar + 1;\n  \n  \n  if (inr<0 || inr>=kant) goto err191;\n  \n  \n  /* Allocating an array for intersection points. */\n  \n  if ((uintpt = newarray(pintdat->ipoint,SISLIntpt *)) == SISL_NULL)\n    goto err101;\n  \n  /* Allocating an array for parametervalues. */\n  \n  if ((spar = newarray(kant,double)) == SISL_NULL)\n    goto err101;\n  \n  \n  /* Making copies of all intersection points. */\n  \n  for (ki=0; ki<pintdat->ipoint; ki++)\n    {\n      /* First we have to insert the missing parameter value. */\n      \n      for(kj=0; kj<inr; kj++) spar[kj] = pintdat->vpoint[ki]->epar[kj];\n      spar[kj] = apar;\n      for(kj++; kj<kant; kj++) spar[kj] = pintdat->vpoint[ki]->epar[kj-1];\n      \n      \n      /* UJK,01-91 bringing over the adist value ! */\n      uintpt[ki] = newIntpt(kant,spar,pintdat->vpoint[ki]->adist);\n    }\n  \n  \n  /* Than we can insert all new intersection points in rintdat. */\n  \n  for (ki=0; ki<pintdat->ipoint; ki++)\n    {\n      s6idnpt(rintdat,&uintpt[ki],1,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* Than we can uppdate all pcurve pointers (lists). */\n  \n  for (ki=0; ki<pintdat->ipoint; ki++)\n    if (pintdat->vpoint[ki]->pcurve != SISL_NULL)\n      {\n\tfor (kj=0;kj<pintdat->ipoint;kj++)\n\t  if (pintdat->vpoint[ki]->pcurve == pintdat->vpoint[kj])\n\t    break;\n\t\n\tif (kj == pintdat->ipoint) goto err190;\n\t\n\ts6idcon(rintdat,&uintpt[ki],&uintpt[kj],&kstat);\n\tif (kstat < 0) goto error;\n      }\n  \n  \n  *jstat = 0;\n  goto out;\n  \n\n/* Error in inserted parameter number.  */\n\nerr191: *jstat = -191;\n        s6err(\"s6idput\",*jstat,kpos);\n        goto out;\n/* Error in intersection list.  */\n\nerr190: *jstat = -190;\n        s6err(\"s6idput\",*jstat,kpos);\n        goto out;\n\n/* Error in space allocation.  */\n\nerr101: *jstat = -101;\n        s6err(\"s6idput\",*jstat,kpos);\n        goto out;\n\n/* Error in sub function.  */\n\nerror: *jstat = kstat;\n        s6err(\"s6idput\",*jstat,kpos);\n        goto out;\n\n out: if (uintpt != SISL_NULL) freearray(uintpt);\n      if (spar   != SISL_NULL) freearray(spar);\n}\n"
  },
  {
    "path": "src/s6inv4.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6inv4.c,v 1.2 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n\n#define S6INV4\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns6inv4 (double em[], double einv[], int *jstat)\n#else\nvoid\ns6inv4 (em, einv, jstat)\n     double em[];\n     double einv[];\n     int *jstat;\n#endif\n/*\n*************************************************************************\n*\n* Purpose: To invert a 4*4-matrix.\n*\n* Input:\n*        Em      - Array (length 16) containing the matrix to be inverted.\n*\n* Output:\n*        Einv    - The inverted matrix.\n*\n* Calls: s6err.\n*\n* Written by: A.M. Ytrehus, SI Oslo Feb.92.\n*\n*****************************************************************\n*/\n{\n  int ki;\n  double det;\n\n  *jstat = 0;\n\n\n  /* Calculate the determinant of the matrix em. */\n\n  det = em[0] * em[5] * (em[10] * em[15] - em[14] * em[11])\n    - em[0] * em[6] * (em[9] * em[15] - em[13] * em[11])\n    + em[0] * em[7] * (em[9] * em[14] - em[13] * em[10])\n    - em[1] * em[4] * (em[10] * em[15] - em[14] * em[11])\n    + em[1] * em[6] * (em[8] * em[15] - em[12] * em[11])\n    - em[1] * em[7] * (em[8] * em[14] - em[12] * em[10])\n    + em[2] * em[4] * (em[9] * em[15] - em[13] * em[11])\n    - em[2] * em[5] * (em[8] * em[15] - em[12] * em[11])\n    + em[2] * em[7] * (em[8] * em[13] - em[12] * em[9])\n    - em[3] * em[4] * (em[9] * em[14] - em[13] * em[10])\n    + em[3] * em[5] * (em[8] * em[14] - em[12] * em[10])\n    - em[3] * em[6] * (em[8] * em[13] - em[12] * em[9]);\n\n\n  /* Calculate the inverse matrix. */\n\n  einv[0] = em[5] * (em[10] * em[15] - em[14] * em[11])\n    - em[6] * (em[9] * em[15] - em[13] * em[11])\n    + em[7] * (em[9] * em[14] - em[13] * em[10]);\n\n  einv[4] = -em[4] * (em[10] * em[15] - em[14] * em[11])\n    + em[6] * (em[8] * em[15] - em[12] * em[11])\n    - em[7] * (em[8] * em[14] - em[12] * em[10]);\n\n  einv[8] = em[4] * (em[9] * em[15] - em[13] * em[11])\n    - em[5] * (em[8] * em[15] - em[12] * em[11])\n    + em[7] * (em[8] * em[13] - em[12] * em[9]);\n\n  einv[12] = -em[4] * (em[9] * em[14] - em[13] * em[10])\n    + em[5] * (em[8] * em[14] - em[12] * em[10])\n    - em[6] * (em[8] * em[13] - em[12] * em[9]);\n\n\n  einv[1] = -em[1] * (em[10] * em[15] - em[14] * em[11])\n    + em[2] * (em[9] * em[15] - em[13] * em[11])\n    - em[3] * (em[9] * em[14] - em[13] * em[10]);\n\n  einv[5] = em[0] * (em[10] * em[15] - em[14] * em[11])\n    - em[2] * (em[8] * em[15] - em[12] * em[11])\n    + em[3] * (em[8] * em[14] - em[12] * em[10]);\n\n  einv[9] = -em[0] * (em[9] * em[15] - em[13] * em[11])\n    + em[1] * (em[8] * em[15] - em[12] * em[11])\n    - em[3] * (em[8] * em[13] - em[12] * em[9]);\n\n  einv[13] = em[0] * (em[9] * em[14] - em[13] * em[10])\n    - em[1] * (em[8] * em[14] - em[12] * em[10])\n    + em[2] * (em[8] * em[13] - em[12] * em[9]);\n\n\n  einv[2] = em[1] * (em[6] * em[15] - em[14] * em[7])\n    - em[2] * (em[5] * em[15] - em[13] * em[7])\n    + em[3] * (em[5] * em[14] - em[13] * em[6]);\n\n  einv[6] = -em[0] * (em[6] * em[15] - em[14] * em[7])\n    + em[2] * (em[4] * em[15] - em[12] * em[7])\n    - em[3] * (em[4] * em[14] - em[12] * em[6]);\n\n  einv[10] = em[0] * (em[5] * em[15] - em[13] * em[7])\n    - em[1] * (em[4] * em[15] - em[12] * em[7])\n    + em[3] * (em[4] * em[13] - em[12] * em[5]);\n\n  einv[14] = -em[0] * (em[5] * em[14] - em[13] * em[6])\n    + em[1] * (em[4] * em[14] - em[12] * em[6])\n    - em[2] * (em[4] * em[13] - em[12] * em[5]);\n\n\n  einv[3] = -em[1] * (em[6] * em[11] - em[10] * em[7])\n    + em[2] * (em[5] * em[11] - em[9] * em[7])\n    - em[3] * (em[5] * em[10] - em[9] * em[6]);\n\n  einv[7] = em[0] * (em[6] * em[11] - em[10] * em[7])\n    - em[2] * (em[4] * em[11] - em[8] * em[7])\n    + em[3] * (em[4] * em[10] - em[8] * em[6]);\n\n  einv[11] = -em[0] * (em[5] * em[11] - em[9] * em[7])\n    + em[1] * (em[4] * em[11] - em[8] * em[7])\n    - em[3] * (em[4] * em[9] - em[8] * em[5]);\n\n  einv[15] = em[0] * (em[5] * em[10] - em[9] * em[6])\n    - em[1] * (em[4] * em[10] - em[8] * em[6])\n    + em[2] * (em[4] * em[9] - em[8] * em[5]);\n\n\n  for (ki = 0; ki < 16; ++ki)\n    einv[ki] /= det;\n\n  return;\n}\n"
  },
  {
    "path": "src/s6invert.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6invert.c,v 1.2 2001-03-19 15:59:02 afr Exp $\n *\n */\n\n\n#define S6INVERT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s6invert(double emat[],int im,double einvertmat[],int *jstat)\n#else\nvoid s6invert(emat,im,einvertmat,jstat)\n   double emat[];\n   int    im;\n   double einvertmat[];\n   int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Compute the inverse of a given square matrix.\n*\n*\n*\n* INPUT      : emat   - The matrix of which to find the inverse.\n*                       NB! The elements of emat will be changed!!!\n*                       The dimension of the array is im*im.\n*              im     - Dimension of the square matrix.\n*              \n*\n* OUTPUT     : emat   - The contents of the input matrix is changed \n*                       during the computations. If you want to keep\n*                       the original matrix, copy it before the inverse\n*                       computation is performed.\n*              einvertmat - The inverse of the input matrix. The\n*                            dimension is im*im.\n*              jstat  - status messages  \n*                                         = 1      : singular equation system\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6lufacp - LU-factorization of matrix.\n*              s6lusolp - Solve equation system given LU-factorization.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 91-03.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;     /* Status variable.  */\n   int ki;            /* Counter.          */\n   int *lpiv = SISL_NULL;  /* Array indicating order of rows in the matrix\n\t\t\t after pivoting.                               */\n   double *scol = SISL_NULL;  /* Column of identity matrix.                 */\n   double *s1,*s2,*s3;   /* Pointers into double array.                */\n   \n   /* Allocate scratch for local arrays.  */\n   \n   if ((lpiv = newarray(im,INT)) == SISL_NULL) goto err101;\n   if ((scol = newarray(im,DOUBLE)) == SISL_NULL) goto err101;\n\n   /* Perform LU-factorization of input matrix.  */\n   \n   s6lufacp(emat,lpiv,im,&kstat);\n   if (kstat < 0) goto error;\n   if (kstat == 1) goto sing;\t\t  \n\t\t  \n   /* Solve the equation systems using the LU-factorization of the\n      input matrix as the left side and the columns of the identity\n      matrix as the right side, to find the inverse of the input matrix. */\n\t\t  \n   for (ki=0; ki<im; ki++)\n   {\n      /* Set up column of identity matrix.  */\n      \n      for (s1=scol, s2=s1+im; s1<s2; s1++) *s1 = DZERO;\n      scol[ki] = (double)1.0;\n      \n      /* Solve equation system.  */\n      \n      s6lusolp(emat,scol,lpiv,im,&kstat);\n      if (kstat < 0) goto error;\n      if (kstat == 1) goto sing;\n\t\t     \n      /* Copy contents of column to output matrix.  */\n\t\t     \n      for (s1=scol, s2=s1+im, s3=einvertmat+ki;\n           s1<s2; s1++, s3+=im)\n\t *s3 = *s1;\n   }\n   \n   /* Inverse of matrix computed.  */\n   \n   *jstat = 0;\n   goto out;\n   \n   /* Singular equation system.  */\n   \n   sing : *jstat = 1;\n   goto out;\n   \n   /* Error in scratch allocation.  */\n   \n   err101 : *jstat = -101;\n   goto out;\n   \n   /* Error in lower level routine.  */\n   \n   error : *jstat = kstat;\n   goto out;\n   \n   out :\n      /* Free space occupied by local arrays.  */\n      \n      if (lpiv != SISL_NULL) freearray(lpiv);\n      if (scol != SISL_NULL) freearray(scol);\n\t\t\t\n      return;\n}\n"
  },
  {
    "path": "src/s6knotmult.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6knotmult.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S6KNOTMULT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nint \ns6knotmult(double et[],int ik,int in,int *ileft,double ax,int *jstat)\n#else\nint s6knotmult(et,ik,in,ileft,ax,jstat)\n     double et[];\n     int    in;\n     int    ik;\n     int    *ileft;\n     double ax;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To determine the multiplicity of a knot at a specified\n*              parameter value.\n*\n*\n* INPUT      : et     - Double array of dimension [in+ik] containing\n*                       the knot vector.\n*              ik     - The polynomial order of the B-splines associated\n*                       with et.\n*              in     - The dimension of the spline space associated with\n*                       the knot vector et.\n*              ax     - The point at which the B-spline values and derivatives\n*                       are to be computed.\n*\n*                \n*\n* INPUT/OUTPUT :\n*              ileft - Pointer to the interval in the knot vector\n*                       where ax is located, check the relations above.\n*              jstat  - Status messages  \n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     : The aim is to do as little work as possible in the cases\n*              where ileft has the right or almost the right value.\n*              First of all we make sure that ileft has a legal value\n*              (a value in the range ik-1 to in-1). Then we check\n*              if the current value is OK.\n*              If it is not we check that ax is in the interior of et\n*              or if the right value is obtained by either increasing\n*              or decreasing ileft by 1. If the right value still has\n*              not been found we do a binary search.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1219\n*\n* WRITTEN BY : Knut Moerken, University of Oslo, August 1988.\n*\n*********************************************************************\n*/                                     \n{\n  int kpos=0;         /* The position of the error.                      */\n  int kstat;          /* Local status variable                           */\n  int kmult=0;        /* Multiplicity of knot                            */\n  int ki;             /* Loop variable                                   */\n  \n  /* Localize knot interval */\n  \n  s1219(et,ik,in,ileft,ax,&kstat);\n  if (kstat<0) goto error;\n  \n  if (et[*ileft] == ax)\n    {\n      kmult = 1;\n      ki    = *ileft-1;\n      for (ki=(*ileft)-1; 0 <= ki; ki--)\n        if (et[ki] == ax) kmult++;\n    }\n  if (et[in] == ax)\n    {\n      for (ki=in ; ki<in+ik;ki++)\n        if (et[ki] == ax) kmult++;\n    }\n  \n  *jstat = 0;\n  goto out;\n\n/* Error in lower level function */\n\nerror:  *jstat = kstat;\n        s6err(\"s6knotmult\",*jstat,kpos);\n        goto out;\n\nout:\nreturn(kmult);\n}\n"
  },
  {
    "path": "src/s6length.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6length.c,v 1.2 2001-03-19 15:59:02 afr Exp $\n *\n */\n#define S6LENGTH\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\ndouble \ns6length(double e1[],int idim,int *jstat)\n#else\ndouble s6length(e1,idim,jstat)\n     double e1[]; \n     int    idim;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate the length of a vector\n*\n* INPUT      : e1      - The vector \n*              idim    - Number of dimensions in the space the vectors lie\n*\n* OUTPUT     : jstat   - Status message\n*                         0 - The length of the vector is zero\n*                         1 - The length of the vector is not zero\n*              s6norm  - The actual length of the vector\n*\n* METHOD     : The length of the input vector is calulated. \n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. 1988-june 1988\n*                                  \n*********************************************************************\n*/\n{\n  register int ki;            /* Running variable in loop */\n  register double tsum=DZERO; /* Dummy variables in summing loop */\n  \n  /* If the dimension is 1 the length of the vector is the same as the\n   *  absolute value of the number */\n  \n  if (idim == 1)\n    tsum = fabs(e1[0]);\n  else\n    {\n      for (ki=0;ki<idim;ki++)\n\ttsum += (e1[ki]*e1[ki]);\n\n      tsum = sqrt(tsum);\n    }\n  \n  if (DNEQUAL(tsum,DZERO))\n    goto mes01;\n\n  /* Length of vector is zero    */\n\n  *jstat = 0;\n  goto out;\n\n  /* Length of vector different from zero   */\n\n mes01: *jstat = 1;\n        goto out;\n\n out: return(tsum);\n}\n"
  },
  {
    "path": "src/s6line.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6line.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S6LINE\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6line(double epoint[])\n#else\nvoid s6line(epoint)\n     double epoint[];\n#endif\n{\n  printf(\"\\n s6line: %f    %f    %f \",epoint[0],epoint[1],epoint[2]);\n}\n"
  },
  {
    "path": "src/s6lprj.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6lprj.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n#define S6LPRJ\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\ndouble\ns6lprj(double e1[],double e2[],int idim)\n#else\ndouble s6lprj(e1,e2,idim)\n     double e1[];\n     double e2[];\n     int    idim;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate the length of the projection of a vector on \n*              an arbitrary axis.\n*\n* INPUT      : e1      - The vector to be projected\n*              e2      - The arbitrary axis vector\n*              dim     - Number of dimensions in the space the vectors lie\n*\n* OUTPUT     : s6lprj  - The length of the projection vector\n*\n* METHOD     : The length of the projection vector is calculated as:\n*                       __     __\n*                       e1 dot e2\n*              ||e3|| = ---------\n*                       __     __  1/2\n*                      (e2 dot e2)\n*-\n* CALLS      : s6scpr, s6length\n*\n* WRITTEN BY : Per Evensen, SI, Oslo, Norway. 1991-aug-16\n*                                  \n*********************************************************************\n*/\n{\n  int kstat;\n  double scpr1,scpr2,lproj; \n\n  scpr1 = s6scpr(e1,e2,idim);\n  scpr2 = s6length(e2,idim,&kstat);\n  if (kstat == 0) scpr2=0.000001;\n  \n  lproj = scpr1/scpr2;\n  return(lproj);\n}\n\n"
  },
  {
    "path": "src/s6lufacp.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6lufacp.c,v 1.2 2001-03-19 15:59:02 afr Exp $\n *\n */\n\n\n#define S6LUFACP\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6lufacp(double ea[],int nl[],int im,int *jstat)\n#else\nvoid s6lufacp(ea,nl,im,jstat)\n     double ea[];\n     int    nl[];\n     int    im;\n     int    *jstat;\n#endif\n/*\n***********************************************************************\n*\n************************************************************************\n*\n*   PURPOSE : LU-factorisation of a full matrix. The matrix is stored \n*             in a one-dimensional array. \n*\n*\n*   INPUT   : im   - The number of equations.\n*\n*\n*\n*   INPUT/OUTPUT : eb - the array in which the matrix is stored.\n*                       The elements are stored row-wise.\n*\n*   \n*   OUTPUT  : nl    - Array that indicates order of rows after pivoting.\n*             jstat - Status variable.\n*                       < 0 : error\n*                       = 0 : ok\n*                       > 0 : warning\n*\n*\n*   METHOD  : Gauss-elimination with partial pivoting.\n*\n*\n*   REFERENCES : Cheney & Kincaid : Numerical Mathematics and\n*                                   Computing.\n*                                  \n*-\n*   CALLS      :\n*\n*   WRITTEN BY : Vibeke Skytt, SI, 86-12.\n*\n************************************************************************\n*/\n{\n  int kpos = 0;   /* Position of error.                               */\n  int ki,kj,kk;   /* Counters.                                        */\n  int kmax = 0;   /* Number of row with maximum greates element.      */\n  int kchange;    /* Help variable to change order of two rows.       */\n  double tmult;   /* Factor with which to multiply a row before it is \n\t\t     added to another.                                */\n  double t1;      /* Help variabel to find maximum of a number of elements.*/\n  double tmax;    /* Maximum of a number of elements.                 */\n  double tdiv;    /* Dividend in expression.                          */\n  double *smax = SISL_NULL; /* Maximum elements in the rows of ea.         */\n  \n  /* Allocate space for local array.  */\n  \n  if ((smax = new0array(im,double)) == SISL_NULL) goto err101;\n  \n  /* Find largest element in each row.  */\n  \n  for (ki=0; ki<im; ki++)\n    {                      \n      nl[ki] = ki;\n      for (kj=0; kj<im; kj++) \n\tsmax[ki] = MAX(smax[ki],fabs(ea[ki*im+kj]));\n    }\n  \n  for (ki=0; ki<im-1; ki++)\n    {\n      \n      /* Find row with maximum greates element to treat now.  */\n      \n      tmax = DZERO;  \n      for (kj=ki; kj<im; kj++)\n\t{\n\t  tdiv = smax[nl[kj]];\n\t  if (DEQUAL(tdiv,DZERO)) goto warn1;\n\t  t1 = fabs(ea[nl[kj]*im+ki]/tdiv);\n\t  if (t1 > tmax)\n\t    {\n\t      tmax = t1; \n\t      kmax = kj;\n\t    }\n\t}\n      kchange  = nl[kmax];\n      nl[kmax] = nl[ki];\n      nl[ki]   = kchange;\n      \n      /* Add a multiplum of current row to all later rows in order to\n\t get an upper triangular matrix ea.                           */\n      \n      for (kj=ki+1; kj<im; kj++)\n\t{\n\t  tdiv = ea[ki+kchange*im];\n\t  if (DEQUAL(tdiv,DZERO)) goto warn1;\n\t  tmult = ea[ki+nl[kj]*im]/tdiv;\n\t  ea[ki+nl[kj]*im] = tmult;\n\t  \n\t  for (kk=ki+1; kk<im; kk++)\n\t    ea[kk+nl[kj]*im] -= ea[kk+kchange*im]*tmult;\n\t}                                     \n    }\n  \n  /* LU-factorizing performed.  */\n  \n  *jstat = 0;\n  goto out;\n\n/* Singular equation system.  */\n\nwarn1 : *jstat = 1;\n        goto out;\n\n/* Error in space allocation.  */\n\nerr101: *jstat = -101;\n        s6err(\"s6lufacp\",*jstat,kpos);\n        goto out;\n\nout:\n\n/* Free space occupied by local array.  */\n\nif (smax != SISL_NULL) freearray(smax);\n\nreturn;\n}\n\n                                    \n\n                                        \n"
  },
  {
    "path": "src/s6lusolp.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6lusolp.c,v 1.2 2001-03-19 15:59:02 afr Exp $\n *\n */\n\n\n#define S6LUSOLP\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6lusolp(double ea[],double eb[],int nl[],int im,int *jstat)\n#else\nvoid s6lusolp(ea,eb,nl,im,jstat)\n     double ea[];\n     double eb[];\n     int    nl[];\n     int    im;\n     int    *jstat;\n#endif\n/*\n************************************************************************\n*\n***********************************************************************\n*\n*   PURPOSE : Solve the equationsystem LU=eb by forth- and back-\n*             substitution. L and U are stored in ea.\n*\n*\n*   INPUT   : ea   - The factorized coeffecient-matrix.\n*             im   - The number of equations.\n*             nl   - Ordering of lines in the matrix.\n*\n*\n*   INPUT/OUTPUT : eb - the right side of the equationsystem and\n*                       the found values for the unknowns.\n*\n*   OUTPUT  : jstat  - Status variable.\n*                        < 0 : Error\n*                        = 0 : ok\n*                        > 0 : Warning\n*\n*                                                                       \n*   METHOD  : Solve on the equation-system LU=eb.\n*\n*\n*   REFERENCES : Cheney & Kincaid : Numerical Mathematics and\n*                                   Computing.\n*\n*-\n*   CALLS      :\n*\n*   WRITTEN BY : Vibeke Skytt, SI, 86-10.\n*\n************************************************************************\n*/\n{\n  int kpos = 0;      /* Position of error.                             */\n  int ki,kj;         /* Counters.                                      */\n  double *sx = SISL_NULL; /* Array used to keep solution of equation system\n\t\t\tinternally.                                    */\n  double tdiv;       /* Dividend in expression.                        */\n  \n  /* Allocate space for local array.  */\n  \n  if ((sx = newarray(im,double)) == SISL_NULL) goto err101;\n  \n  for (ki=0; ki<im-1; ki++)\n    {\n      /*  Gauss on right side of equation  */\n      \n      for (kj=ki+1; kj<im; kj++)      \n\teb[nl[kj]] -= eb[nl[ki]]*ea[ki+nl[kj]*im];\n    }\n  \n  tdiv = ea[im-1+nl[im-1]*im];\n  if (DEQUAL(tdiv,DZERO)) goto warn1;\n  sx[im-1] = eb[nl[im-1]]/tdiv;\n  \n  for (ki=im-2; ki>=0; ki--)\n    {\n      /*  Backwards substitution.   */\n      \n      for (kj=ki+1; kj<im; kj++)\n\teb[nl[ki]] -= sx[kj]*ea[kj+nl[ki]*im];\n      \n      tdiv = ea[ki+nl[ki]*im];\n      if (DEQUAL(tdiv,DZERO)) goto warn1;\n      sx[ki] = eb[nl[ki]]/tdiv;\n    }   \n  for (ki=0; ki<im; ki++) eb[ki] = sx[ki];\n  \n  /* Equation system solved.  */\n  \n  *jstat = 0; \n  goto out;\n\n/* Singular equation system.  */\n\nwarn1 : *jstat = 1;\n        goto out;\n\n/* Error in space allocation.  */\n\nerr101: *jstat = -101;\n        s6err(\"s6lusolp\",*jstat,kpos);\n        goto out;\n\nout:\n\n/* Free space occupied by local array.  */\n\nif (sx != SISL_NULL) freearray(sx);\n\nreturn;\n}\n"
  },
  {
    "path": "src/s6metric.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6metric.c,v 1.2 2001-03-19 15:59:02 afr Exp $\n *\n */\n\n\n#define S6METRIC\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     s6metric(double epoint[],int in,int idim,double emat[],int *jstat)\n#else\nvoid s6metric(epoint,in,idim,emat,jstat)\n   double epoint[];\n   int    in;\n   int    idim;\n   double emat[];\n   int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Set up matrix used for distance computation in an\n*              affine metric.\n*\n*\n*\n* INPUT      : epoint - Point set used to set up the metric. The metric\n*                       is to be used to compute distances between\n*                       points in the set. Dimension is in*idim, and the\n*                       points are stored in sequence.\n*              in     - Number of points in the point set.\n*              idim   - Dimension of geometry space.\n*              \n*\n* OUTPUT     : emat   - Matrix used to compute distances in the metric.\n*                       The dimension is idim*idim.\n*              jstat  - status messages  \n*                                         = 1      : singular equation system\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6invert - Find the inverse of a given square matrix.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 91-03.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;        /* Status variable.  */\n   int ki,kk;            /* Counter.          */\n   double tmedium;       /* Medium of a number of coordinates. */\n   double tdot;          /* Scalar product.                    */\n   double *smat1 = SISL_NULL; /* Input points minus weight points.  */\n   double *smat2 = SISL_NULL; /* Inverse matrix to output matrix.   */\n   double *s1,*s2,*s3;   /* Pointers into arrays.              */\n   \n   /* Allocate scratch for internal matrices.  */\n   \n   if ((smat1 = newarray(in*idim,DOUBLE)) == SISL_NULL) goto err101;\n   if ((smat2 = newarray(idim*idim,DOUBLE)) == SISL_NULL) goto err101;\n   \n   /* Set up a matrix consisting of the input points minus\n      the weight point of the pointset. First copy the array of points\n      into the matrix.  */\n   \n   memcopy(smat1,epoint,in*idim,DOUBLE);\n   \n   for (kk=0; kk<idim; kk++)\n   {\n      /* Compute weight point of coordinate.  */\n      \n      for (tmedium=DZERO, s1=smat1+kk, s2=s1+in*idim; s1<s2; s1+=idim)\n\t tmedium += (*s1);\n      tmedium /= in;\n      \n      /* Set up column in difference matrix.  */\n      \n      for (s1=smat1+kk; s1<s2; s1+=idim) *s1 -= tmedium;\n   }\n   \n   /* Compute the inverse of the output matrix as the matrix product\n      between the difference matrix and the transpose of that matrix. */\n   \n   for (ki=0; ki<idim; ki++)\n      for (kk=0; kk<idim; kk++)\n      {\n\t for (tdot=DZERO, s1=smat1+ki, s2=smat1+kk, s3=s1+in*idim;\n\t      s1<s3; s1+=idim, s2+=idim)\n\t    tdot += (*s1)*(*s2);\n\t smat2[ki*idim+kk] = tdot;\n      }\n   \n   /* Compute the matrix corresponding to the metric.  */\n   \n   s6invert(smat2,idim,emat,&kstat);\n   if (kstat < 0) goto error;\n\t\t  \n   /* The matrix of the metric is computed.  */\n\t\t  \n   *jstat = kstat;\n   goto out;\n   \n   /* Error in scratch allocation.  */\n   \n   err101 : *jstat = -101;\n   goto out;\n   \n   /* Error in lower level routine.  */\n   \n   error : *jstat = kstat;\n   goto out;\n   \n   out :\n      /* Free scratch occupied by local arrays.  */\n      \n      if (smat1 != SISL_NULL) freearray(smat1);\n      if (smat2 != SISL_NULL) freearray(smat2);\n\t\t\t \n      return;\n}\n      \n"
  },
  {
    "path": "src/s6move.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6move.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S6MOVE\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6move(double epoint[])\n#else\nvoid s6move(epoint)\n     double epoint[];\n#endif\n{\n  printf(\"\\n s6move: %f    %f    %f \",epoint[0],epoint[1],epoint[2]);\n}\n"
  },
  {
    "path": "src/s6multsfs.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S6MULTSFS\n\n#include \"sislP.h\"\n\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6multsfs(double *c1, int order11,int order12,\n\t\tdouble* c2, int order21,int order22,\n                double *Pascal,\n\t\tdouble *newsurf, int *order_newsurf1,int *order_newsurf2)\n#else\n   void s6multsfs(c1, order11, order12, c2, order21, order22, Pascal,\n\t\t  newsurf, order_newsurf1, order_newsurf2)\n      double *c1;\n      int order11;\n      int order12;\n      double *c2;\n      int order21;\n      int order22;\n      double *Pascal;\n      double *newsurf;\n      int *order_newsurf1;\n      int *order_newsurf2;\n#endif      \n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Multiply two Bezier surfaces of dimension 1.\n*\n*\n*\n* INPUT      : c1      - Coefficients of first Bezier surface.\n*              order11 - Order of first surface in first parameter dir.\n*              order12 - Order of first surface in second parameter dir.\n*              c2      - Coefficients of second Bezier surface\n*              order21 - Order of second surface in first parameter dir.\n*              order22 - Order of second surface in first parameter dir.\n*              Pascal  - Factors used in surface multiplication.\n*\n*\n*\n* OUTPUT     : newsurf - Coefficients of product surface.\n*              order_newsurf1 - Number of coefficients of product surface\n*                               in first parameter direction.\n*              order_newsurf2 - Number of coefficients of product surface\n*                               in second parameter direction.\n*\n*\n* REFERENCES :\n*\n* NOTE       : Factors necessary for the multiplication must be\n*              precomputed. If the multiplication routine is to be\n*              calles severatl times, it speeds up the computations\n*              if this factors are called only once.\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SINTEF, 1993. \n* COMMENTED BY : Vibeke Skytt, SINTEF, 06.94.\n*\n*********************************************************************\n*/                                     \n{\n  int p1,p2,r01,r02,r1,r2,h,h1;\n  int kgrad11=order11-1;\n  int kgrad12=order12-1;\n  int kgrad21=order21-1;\n  int kgrad22=order22-1;\n  int kgrad1 = kgrad11 + kgrad21;\n  int kgrad2 = kgrad12 + kgrad22;\n  int kstop2=order12+order22-1;\n  int kstop1=order11+order21-1;\n  double *psl_kgrad11=Pascal+kgrad11*(kgrad11+1)/2;\n  double *psl_kgrad12=Pascal+kgrad12*(kgrad12+1)/2;\n  double *psl_kgrad21=Pascal+kgrad21*(kgrad21+1)/2;\n  double *psl_kgrad22=Pascal+kgrad22*(kgrad22+1)/2;\n  double *psl_kgrad1 =Pascal+kgrad1 *(kgrad1 +1)/2;\n  double *psl_kgrad2 =Pascal+kgrad2 *(kgrad2 +1)/2;\n  double *qsc1,*qsc2;\n  double tsum, sumi;\n  double *temp;\n  double tdiv, t2;\n  int kstop3, kstop4;\n  double scratch[190];\n  double *binom = NULL;\n\n  if (kstop1*order11 < 190)\n      binom = scratch;\n  else\n  {\n      binom = newarray(kstop1*order11, double);\n  }\n      \n\n      \n  for (p1=0, h=0; p1<kstop1; p1++)\n  {\n      kstop3 = MIN(p1,kgrad11);\n      for (r1=MAX(0,p1-kgrad21); r1<=kstop3; r1++)\n\t  binom[h++] = psl_kgrad11[r1]*psl_kgrad21[p1-r1];\n  }\n      \t  \n  \n\n  for(p2=0,temp=newsurf;p2<kstop2;p2++)\n  {\n      kstop4 = MIN(p2,kgrad12);\n      r02 = MAX(0,p2-kgrad22);\n      for(p1=0, h=h1=0; p1<kstop1; p1++, temp++)\n      {\n\t  tdiv = psl_kgrad1[p1]*psl_kgrad2[p2];\n\t  kstop3 = MIN(p1,kgrad11);\n\t  r01 = MAX(0,p1-kgrad21);\n\t  for(r2=r02, tsum=(double)0; r2<=kstop4; r2++)\n\t  {\n\t      t2 = psl_kgrad12[r2]*psl_kgrad22[p2-r2];\n\t      for(r1=r01, h=h1, qsc1=c1+r2*order11, qsc2=c2+(p2-r2)*order21, sumi=0.0;\n\t\t  r1<=kstop3; r1++, h++)\n\t\t  sumi += binom[h]*qsc1[r1]*qsc2[p1-r1];\n\t      tsum += t2*sumi;\n\t  }\n\t  h1 += (kstop3+1-r01);\n\t  tsum /= tdiv;\n\t \n\t  *temp = tsum;\n      }\n  }\n\n  *order_newsurf1=kstop1;\n  *order_newsurf2=kstop2;\n \n  if (binom && binom != scratch)\n      freearray(binom);\n}\n\n"
  },
  {
    "path": "src/s6mulvec.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6mulvec.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S6MULVEC\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns6mulvec (double ematrix[], double evect[], double eright[])\n#else\nvoid\ns6mulvec (ematrix, evect, eright)\n     double ematrix[];\n     double evect[];\n     double eright[];\n#endif\n/*\n*************************************************************************\n*\n* Purpose: To multiply a 4*4 matrix by a 3-D vector.\n*\n* Input:\n*        Ematrix - The matrix (length 16).\n*        Evect   - The vector (length 3).\n*\n* Output:\n*        Eright   - The resulting 3-D vector.\n*\n* Written by: A.M. Ytrehus, SI Oslo Nov.91.\n* After FORTRAN (P6mvec), written by: S. Meen  SI.\n*****************************************************************\n*/\n{\n  double svect[4];\n  double sright[4];\n  double tdum;\n  int ki;\n  int kj;\n\n  /* Store the 3D evect-array in the 4D svect-array. */\n\n  for (ki = 0; ki < 3; ki++)\n    svect[ki] = evect[ki];\n\n  svect[3] = (double) 1.0;\n\n\n  /* Multiply the matrix by the vector svect.\n     The result is stored in the 4-D local vector sright.*/\n\n  for (ki = 0; ki < 4; ki++)\n    {\n      tdum = (double) 0.0;\n\n      for (kj = 0; kj < 4; kj++)\n\ttdum += ematrix[4 * ki + kj] * svect[kj];\n\n      sright[ki] = tdum;\n    }\n\n\n  /* \n   * Check if the bottom line of the matrix is 0,0,0,1.\n   * In that case, just store the first three elements of svect in evect.\n   * Else, divide all 3 first elements of svect by svect[3]. \n   * --------------------------------------------------------------------\n   */\n\n  for (ki = 0; ki < 3; ki++)\n    eright[ki] = sright[ki];\n\n  if (!(ematrix[12] == (double) 0.0) && (ematrix[13] == (double) 0.0) &&\n      (ematrix[14] == (double) 0.0) && (ematrix[15] == (double) 1.0))\n    {\n      tdum = sright[3];\n\n      for (ki = 0; ki < 3; ki++)\n\teright[ki] = sright[ki] / tdum;\n    }\n\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s6mvec.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6mvec.c,v 1.2 2001-03-19 15:59:02 afr Exp $\n *\n */\n\n\n#define S6MVEC\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6mvec(double emat[],double evec1[],int inbvec,double evec2[])\n#else\nvoid s6mvec(emat,evec1,inbvec,evec2)\n     double emat[];\n     double evec1[];\n     int    inbvec;\n     double evec2[];\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To post multiply a matrix by inbvec 3-D vectors.\n*\n* INPUT      : emat    - The matrix (16 elements, Homogenous coordinates)\n*              evec1   - The input vectors (3-D coordinates)\n*              inbvec  - The number of input vectors\n*\n* OUTPUT     : evec2   - The resulting vectors (3-D coordinates)\n*\n*-  \n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. 1988-may-24\n*                                  \n*********************************************************************\n*/\n{\n  double svec2[3];           /* Temporary vector                        */\n  double *svec1;             /* Pointer to current vector               */\n  double *svec3;             /* pointer to current result vector        */\n  register double tdum;      /* Temporary storage of real               */\n  register int ki,kj,kl,kp;  /* Control variables in loops              */\n  int kstop;                 /* Stop condition for loop                 */\n  \n  /* Multiply matrix by all vectors */\n  \n  kstop = 3*inbvec;\n  \n  for (kl=0;kl<kstop;kl=kl+3)\n    {\n      /* Multiply rotational part of the matrix by the vector */\n      \n      svec1 = evec1 + kl;\n      svec3 = evec2 + kl;\n      \n      for (ki=0;ki<3;ki++)\n        {\n\t  kp = ki;\n\t  \n\t  tdum = DZERO;\n\t  for (kj=0;kj<3;kj++)\n            {\n\t      tdum += emat[kp]*svec1[kj];\n\t      kp += 4;\n            }\n\t  \n\t  /* Add translation part */\n\t  svec2[ki]  = tdum + emat[kp];\n        }\n      /*  Check if the bottom row is 0,0,0,1 */                     \n      \n      if (DNEQUAL(emat[3],DZERO) || DNEQUAL(emat[7],DZERO) ||\n\t  DNEQUAL(emat[11],DZERO) || DNEQUAL(emat[15],(double)1.0))\n        {\n\t  /* Compute last element of vector */\n\t  \n\t  tdum = evec1[0]*emat[3] + evec1[1]*emat[7] + evec1[2]*emat[11];\n\t  if (DNEQUAL(tdum,DZERO))\n            {\n\t      for (ki=0;ki<3;ki++)\n\t\tsvec2[ki] /= tdum;\n            }\n\t}\n      svec3[0] = svec2[0];    \n      svec3[1] = svec2[1];\n      svec3[2] = svec2[2];\n    }\n  \n  return;\n}\n"
  },
  {
    "path": "src/s6newbox.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6newbox.c,v 1.2 2001-03-19 15:59:02 afr Exp $\n *\n */\n\n\n#define S6NEWBOX\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid s6newbox(SISLbox *pbox,int inum,int itype,\n\t      double aepsge,int *jstat)\n#else\nvoid s6newbox(pbox,inum,itype,aepsge,jstat)\n     SISLbox *pbox;\n     int    inum;\n     int    itype;\n     double aepsge;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Create a particular box exist within an existing\n*              box instance.\n*\n*\n*\n* INPUT      : pbox   - Box to modify.\n*              inum   - Number of elements in min- and max-arrays.\n*              itype  - Kind of box to create.\n*                       = 0 : Do not expand box.\n*                       = 1 : Make a totally expanded box.\n*                       = 2 : Make a box expanded in the inner of the\n*                             object, and reduced along the edges/endpoints.\n*              aepsge - Geometry resolution.\n*\n* OUTPUT     :  jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                                                                     \n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :  \n*\n* WRITTEN BY : Vibeke Skytt, SI, 91-01.\n*\n*********************************************************************\n*/                                     \n{\n   int knum = (inum == 1) ? inum : 2*inum;  /* If the geometry space has\n\t\t\t\t\t       dimension larger than 1,\n\t\t\t\t\t       a double set of min- and\n\t\t\t\t\t       max-arrays is to be made. */\n\n   if (itype < 0 || itype > 2) goto err126;\n   \n   /* Test no such box exist, create the necessary arrays.  */\n   \n   if (pbox->e2min[itype] == SISL_NULL)\n   {\n      if ((pbox->e2min[itype] = newarray(knum,DOUBLE)) == SISL_NULL) goto err101;\n      if ((pbox->e2max[itype] = newarray(knum,DOUBLE)) == SISL_NULL) goto err101;\n   }\n  \n   /* Set the tolerance. */\n   \n   if (itype != 0) pbox->etol[itype] = aepsge;\n   \n   *jstat = 0;\n   goto out;\n   \n   /* Error in scratch allocation.  */\n   \n   err101 : *jstat = -101;\n   goto out;\n   \n   /* Error in input.  Kind of box do not exist.  */\n   \n   err126 : *jstat = -126;\n   goto out;\n   \n   out :\n      return;\n}\n"
  },
  {
    "path": "src/s6norm.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6norm.c,v 1.2 2001-03-19 15:59:02 afr Exp $\n *\n */\n#define S6NORM\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\ndouble \ns6norm(double e1[],int idim,double e2[],int *jstat)\n#else\ndouble s6norm(e1,idim,e2,jstat)\n     double e1[];\n     int    idim;\n     double e2[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To normalize a vector to length 1\n*\n* INPUT      : e1      - The vector to be normalized\n*              idim    - Number of dimensions in the space the vectors lie\n*\n* OUTPUT     : jstat   - Status message\n*                         0 - The length of the vector is zero\n*                         1 - The length of the vector is one\n*              s6norm  - The actual length of the vector\n*              e2      - The nomalized version of the vector\n*\n* METHOD     : The length of the input vector is calulated, and the\n*              output is assigned the values of the input vector and \n*              divided by the length.\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. 1988-may-03\n*                                  \n*********************************************************************\n*/\n{\n  register int ki;      /* Running variable in loop */\n  register double tsum=DZERO; /* Dummy variables in summing loop */\n  \n  /* If the dimension is 1 the length of the vector is the same as the\n   *  absolute value of the number */\n  \n  if (idim == 1)\n    tsum = fabs(e1[0]);\n  else\n    {\n      for (ki=0;ki<idim;ki++)\n\ttsum += (e1[ki]*e1[ki]);\n      \n      tsum = sqrt(tsum);\n    }\n  \n  if (DNEQUAL(tsum,DZERO))\n    for (ki=0;ki<idim;ki++)\n      e2[ki] = e1[ki]/tsum;\n  else\n    {\n      for (ki=0;ki<idim;ki++)\n        e2[ki] = DZERO;\n      goto mes00;\n    }\n  goto mes01;\n\n  /* Length of vector is zero    */\n\n mes00: \n  *jstat = 0;\n       goto out;\n\n  /* Length of vector different from zero   */\n\n mes01: \n  *jstat = 1;\n  goto out;\nout: return(tsum);\n}\n"
  },
  {
    "path": "src/s6nullspace.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S6NULLSPACE\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n   s6nullspace(double ea[],int im1,int im2,double aepsge,\n\t\t double **nullspace,int *numbvect,int *jstat)\n#else\nvoid s6nullspace(ea,im1,im2,aepsge,nullspace,numbvect,jstat)\n     double ea[];\n     int    im1;\n     int    im2;\n     double aepsge;\n     double **nullspace;\n     int    *numbvect;\n     int    *jstat;\n#endif\n/*\n***********************************************************************\n*\n************************************************************************\n*\n*   PURPOSE : To find the nullspace of a matrix within the tolerance\n*             aepsge\n*\n*\n*   INPUT   : ea     - The matrix\n*             im1    - The number of rows\n*             im2    - The number of columns\n*             aepsge - The size of numbers to be regarded zero\n*\n*\n*\n*   OUTPUT  : nullspace    - Array of vectors spanning the approximated\n*                            nullspace\n*             numbvect     - Number of vectors spanning the null space\n*             jstat - Status variable.\n*                       < 0 : error\n*                       = 0 : ok\n*                       > 0 : warning\n*\n*\n*-\n*   CALLS      :\n*\n*   WRITTEN BY : Vibeke Skytt, SI, 86-12.\n*   Change to nullspace search by: Tor dokken, SINTEF, 94-06\n*\n************************************************************************\n*/\n{\n  int *ellimvert=NULL; /* Array telling which column has been ellimnated */\n  int *ellimhort=NULL; /* Array telling which row has been elliminated */\n  int knoneell;        /* Variable for accumulateing none elliminated variables */\n\n  int kpos = 0;   /* Position of error.                               */\n  int ki,kj,kl;   /* Counters.                                        */\n  int kpek1,kpek2; /* Pointer pair to maximum element */\n\n  double *sellim=NULL; /* The row used as current row for ellimination*/\n  double tmax;    /* Variable used for storing maximale values */\n  double tscale;  /* Variable used for storing scaling factors */\n  double *qs=NULL;/* Temporary array pointer */\n  double *qr=NULL;/* Temporary array pointer */\n  double temp;    /* Temporary value */\n  double *tempmat=NULL; /* Error storing ellimination matrix row by row */\n  double *tempres=NULL;\n\n  /* Allocate space for local array.  */\n\n  if ((ellimvert = newarray(im2,int)) == NULL) goto err101;\n  if ((ellimhort = newarray(im1,int)) == NULL) goto err101;\n  if ((tempmat = newarray(im2*im2,double)) == NULL) goto err101;\n\n  /* Initite ellimvert and ellimhort to -1 */\n\n  for(ki=0;ki<im2;ki++)\n    ellimvert[ki]=-1;\n\n  for(ki=0;ki<im1;ki++)\n    ellimhort[ki]=-1;\n\n  /* Find largest element in each row.  */\n\n  for (ki=0; ki < MIN(im1,im2-1); ki++)\n    {\n      /* Elliminate in column with biggest remaining element */\n\n      tmax = (double)0;\n      kpek1=-1;\n      kpek2=-1;\n\n      for (kj=0,qs=ea; kj<im1; kj++,qs+=im2)\n\tif(ellimhort[kj]==-1)\n\t  {\n\t    /* Row not used as bases for reduction */\n\t    for(kl=0; kl<im2; kl++)\n\t      if(ellimvert[kl]==-1)\n\t\t{\n\t\t  /* column not used in reduction */\n\t\t  temp = fabs(qs[kl]);\n\t\t  if(temp>=tmax)\n\t\t    {\n\t\t      tmax=temp;\n                      kpek1=kj;\n\t\t      kpek2=kl;\n\t\t    }\n\t\t}\n\t  }\n      /* fprintf(stdout,\"\\n tmax %lf\",tmax); */\n      if(tmax>aepsge)\n\t{\n\t  /* If kpek1 and kpek2 greater than -1 then an element remain.\n\t     It tmax <=aepsge then the remaining matrix should be regarded\n\t     as zero. Elliminate based on row kpek1 in column kpek2 */\n\n\t  /* Find the row to use in the ellimination and scale element such\n\t     that ellement kpek2 is 1 */\n\t  sellim = &ea[kpek1*im2];\n\t  tscale = sellim[kpek2];\n\t  for(kl=0;kl<im2;kl++)\n\t    sellim[kl]/=tscale;\n\n\t  /* Elliminate from all other rows */\n\n\t  for (kj=0,qs=ea; kj<im1; kj++,qs+=im2)\n\t    if(kj != kpek1)\n\t      {\n\t\t/* We exclude ellimination from row used for ellimination */\n\t\ttscale = qs[kpek2];\n\t\tfor(kl=0; kl<im2; kl++)\n\t\t  qs[kl]-=tscale*sellim[kl];\n\t      }\n\t  ellimhort[kpek1]=1;\n\t  ellimvert[kpek2]=kpek1;\n\t}\n    }\n/* Build matrix */\n\n\nfor(ki=0,knoneell = 0,qs=tempmat;ki<im2;ki++,qs+=im2)\n  {\n    /* Check i variable elliminated */\n\n    if(ellimvert[ki]==-1)\n      {\n\t/* Variable not elliminated,make row\n           that projects current remianing variable\n           onto the right position */\n\tfor(kj=0;kj<im2;kj++)\n\t  qs[kj]=(double)0;\n\tqs[knoneell]=-(double)1;\n        knoneell+=1;\n      }\n    else\n      {\n\t/* Variable elliminated, ellimvert[ki] gives actual row */\n        qr = ea + im2*ellimvert[ki];\n\tfor(kj=0,kl=0;kj<im2;kj++)\n\t  if(ellimvert[kj]==-1)\n\t    {\n\t      qs[kl] = qr[kj];\n\t      kl++;\n\t    }\n      }\n  }\n\n\nif ((tempres = newarray(knoneell*im2,double)) == NULL) goto err101;\n\n/* The result is stored row wise, with the first knoenell elements\n   relevant to the result, store result column wise */\n\nfor(ki=0,qs=tempres,qr=tempmat;ki<knoneell;ki++,qs+=im2,qr+=1)\n  for(kj=0;kj<im2;kj++)\n    qs[kj] = qr[im2*kj];\n\n*nullspace = tempres;\n*numbvect = knoneell;\n\n  *jstat = 0;\n  goto out;\n\n/* Error in space allocation.  */\n\nerr101: *jstat = -101;\n        s6err(\"s6lufacp\",*jstat,kpos);\n        goto out;\n\nout:\n\n/* Free space occupied by local array.  */\n\nif (ellimhort != NULL) freearray(ellimhort);\nif (ellimvert != NULL) freearray(ellimvert);\nif (tempmat != NULL)   freearray(tempmat);\nreturn;\n}\n"
  },
  {
    "path": "src/s6ratder.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6ratder.c,v 1.3 2001-03-19 15:59:02 afr Exp $\n *\n */\n\n\n#define S6RATDER\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns6ratder(double eder[],int idim,int ider,double gder[],int *jstat)\n#else\nvoid s6ratder(eder,idim,ider,gder,jstat)\n     double eder[];\n     int    idim;\n     int    ider;\n     double gder[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To calculate the ider derivatives of a rational\n*              point described in homogenous coordinates\n*\n* INPUT      : eder    - The derivatives in homogenous coordinates\n*                        In sequence:\n*                         Position (x,y,...h)\n*                         1st der (x,y,...h)\n*                         2nd der (x,y,...h)\n*                         etc.\n*              idim    - The dimension of the non homogenous space\n*              ider    - The number of input derivatives\n*\n*\n* OUTPUT     : jstat   - Status message\n*                                        >0      : Warning\n*                                        =0      : ok\n*                                        <0      : Error\n*              gder    - The derivatives in the nonhomogenous space\n*\n*\n* METHOD     :  The curve P(u) can be written as the quotient\n*               P(u) = T(u) / w(u) where T and w are ordinary splines.\n*               The dimensions of T and w are idim and 1\n*               respectively. The array eder contains position\n*               and derivatives of the idim+1 dimensional curve\n*               (T(u),w(u)).\n*\n*               Now, since wP = T, we find, by the Leibnitz formula,\n*\n*                 k\n*                         k!     (k-i) (i)         (k)\n*                sum   -------- w     P       =   T    .\n*                      i!(k-i)!\n*                i=0\n*\n*               Therefore\n*\n*\n*                   --         k-1                      --\n*             (k)   |   (k)             k!     (k-i) (i) |\n*            P    = |  T    -  sum   -------- w     P    | / w .\n*                   |                i!(k-i)!            |\n*                   --         i=0                      --\n*\n*               This formula is applied recursively to evaluate P's derivatives.\n*\n*                                                          MF.\n*\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. 1988-des-1988\n* REVISED BY : Michael Floater, SI, 30/9/91 Removed division by t=1.\n* REWRITTEN BY : Michael Floater, SI, 16/12/91. New algorithm.\n* REWRITTEN BY : Michael Floater, SI, 25/8/92. Extend to arbitrary\n*                   number of derivatives (by Leibnitz). Finally!\n* REVISED BY : Paal Fugelli, SINTEF, 07/07-94. Added free'ing of binom and\n*              initiation to SISL_NULL to avoid memory leakage.\n*********************************************************************\n*/\n{\n  int kpos=0;          /* Position of error.                     */\n  double w0;           /* The denominator.                       */\n  int ki;              /* Count through dimensions.              */\n  int id;              /* Count through derivatives.             */\n  int *binom = SISL_NULL;   /* Array for binomial coefficients.       */\n  double sum;          /* Binomial (Leibnitz) expansion.         */\n  int idimp1;          /* idim + 1.                              */\n  int iw;              /* Pointer to a weight.                   */\n  int igder;           /* Pointer to already calculated derivs.  */\n  int i,j,k;           /* Counters.                              */\n  int iwfix;           /* Initial value of iw in Leibnitz loop.  */\n\n  if (ider<0) goto err178;\n  if (idim<1) goto err102;\n\n  idimp1 = idim + 1;\n\n  /* Find denominator. */\n\n  w0 = eder[idim];\n  if (DEQUAL(w0,DZERO)) w0 = (double)1.0;\n\n  /* Set up initial binomial coefficient (1). */\n\n  binom = newarray(ider+1, INT);\n  if(binom == SISL_NULL) goto err179;\n\n  binom[0] = 1;\n\n\n  /* Calculate position first. */\n\n  for(ki=0; ki<idim; ki++)\n  {\n      gder[ki] = eder[ki] / w0;\n  }\n\n\n\n  /* Then derivatives if there are any. */\n\n  for(id=1,j=idim,k=idimp1; id<=ider; id++,k++)\n  {\n      /* Calculate the new row of binomial coefficients. */\n\n      binom[id] = 1;\n\n      for(i=id-1; i>=1; i--)\n      {\n\t  binom[i] += binom[i-1];\n      }\n\n\n      /* Run through the idim dimensions, calculating each\n\t coefficient of the id'th derivative of\n\t the rational curve (in gder). */\n\n      iwfix = k + idim;\n\n      for(ki=0; ki<idim; ki++,j++,k++)\n      {\n\t  /* Calculate the Leibnitz sum (the binomial\n\t     coefficient in the first term is always 1). */\n\n\t  sum = eder[iwfix] * gder[ki];\n\n          for(i=1,igder=idim+ki,iw=iwfix-idimp1;\n\t  i<id;\n\t  i++,igder+=idim,iw-=idimp1)\n          {\n\t      sum += (double)binom[i] * eder[iw] * gder[igder];\n          }\n\n\t  gder[j] = (eder[k] - sum) / w0;\n\n      }\n\n  }\n\n  /* Done. */\n\n\n  *jstat = 0;\n  goto out;\n\n/* idim less than 1. */\n err102: *jstat = -102;\n         s6err(\"s6ratder\",*jstat,kpos);\n         goto out;\n\n/* Derivative negative */\n err178: *jstat = -178;\n         s6err(\"s6ratder\",*jstat,kpos);\n         goto out;\n\n\n/* Not enough memory */\n err179: *jstat = -179;\n         s6err(\"s6ratder\",*jstat,kpos);\n         goto out;\n\n\nout:\n  if (binom != SISL_NULL) freearray(binom);\n\n  return;\n}\n"
  },
  {
    "path": "src/s6rotax.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6rotax.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S6ROTAX\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6rotax(double ep[],double eaxis[],double expnt[],double emat[],int *jstat)\n#else\nvoid s6rotax(ep,eaxis,expnt,emat,jstat)\n     double ep[];\n     double eaxis[];\n     double expnt[];\n     double emat[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To make a matrix that transforms the z-axis ont to\n*              the axis specified by ep and eaxis, and transforms\n*              the point (1,0,0) onto the point expnt. The matrix is\n*              prepared for post multiplication of vectors.\n*\n* INPUT      : ep      - SISLPoint on axis\n*              eaxis   - Direction of axis \n*              expnt   - The point (1,0,0) is trnasformed on to.\n*\n* OUTPUT     : jstat   - Status message\n*                                        >0      : Warning\n*                                        =0      : ok\n*                                        <0      : Error\n*              emat    - The 4x4 matrix produced.\n*\n*\n* METHOD     : \n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. 1988-may-23\n*\n*********************************************************************\n*/\n{\n  double sdiff[3];            /* Vector for storage of  expnt-ep        */\n  double saxis[3];            /* Storage of normalized eaxis            */\n  double tradius;             /* Distance from expnt to axis            */\n  double sxdir[3];            /* Transformation direction of x-axis     */\n  double sydir[3];            /* Transformation direction of y-axis     */\n  double strans[3];           /* Translation vector for the origin      */\n  double zfak;                /* Length of projection                   */\n  int    kdim=3;              /* The dimension of the space we work in  */\n  int    kstat;               /* Local status varaible                  */\n  int    ki;                  /* Variable used in for loop              */\n  \n  \n  /* Normalize direction of axis */\n  \n  (void)s6norm(eaxis,kdim,saxis,&kstat);\n  \n  \n  /*  Make difference of expnt  and ep  */\n  \n  for (ki=0;ki<3;ki++)\n    sdiff[ki] = expnt[ki] - ep[ki];\n  \n  /* Find projection of expnt-ep onto saxis */\n  \n  zfak = s6scpr(sdiff,saxis,kdim);\n  \n  \n  /* Make transformation of the vector (1,0,0) */\n  \n  for (ki=0;ki<3;ki++)\n    sxdir[ki] = sdiff[ki] - zfak*saxis[ki];\n\n  /* Normalize sxdir */\n  \n  tradius = s6norm(sxdir,kdim,sxdir,&kstat);\n  \n  /* Make the vector (0,1,0) is to be projected onto */\n  \n  s6crss(saxis,sxdir,sydir);\n  (void)s6norm(sydir,kdim,sydir,&kstat);\n  \n  /* Make translation of origo */\n  \n  for (ki=0;ki<3;ki++)\n    strans[ki] = ep[ki] + zfak*saxis[ki];\n  \n  /* Build transformation matrix for post multiplication of vectors */\n  \n  emat[0]  = tradius*sxdir[0];\n  emat[1]  = tradius*sxdir[1];\n  emat[2]  = tradius*sxdir[2];\n  emat[3]  = (double)0.0;\n  emat[4]  = tradius*sydir[0];\n  emat[5]  = tradius*sydir[1];\n  emat[6]  = tradius*sydir[2];\n  emat[7]  = (double)0.0;\n  emat[8]  = tradius*saxis[0];\n  emat[9]  = tradius*saxis[1];\n  emat[10] = tradius*saxis[2];\n  emat[11] = (double)0.0;\n  emat[12] = strans[0];\n  emat[13] = strans[1];\n  emat[14] = strans[2];\n  emat[15] = (double)1.0;\n  \n  /* Matrix made */\n  \n  *jstat = 0;\n  goto out;\n  \n out: \n  return;\n}\n"
  },
  {
    "path": "src/s6rotmat.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6rotmat.c,v 1.2 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n#define S6ROTMAT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6rotmat (double eorigo[], double exaxis[], double enorm[],\n\t  double ematrix[], int *jstat)\n#else\nvoid \ns6rotmat (eorigo, exaxis, enorm, ematrix, jstat)\n     double eorigo[];\n     double exaxis[];\n     double enorm[];\n     double ematrix[];\n     int *jstat;\n#endif\n/*\n*************************************************************************\n*\n* Purpose: To compute the transformation matrix (dim = 4X4), given\n*\t   points (of dim = 3), in the local coordinate system.\n*\n* Input:\n*        Eorigo  - Origo of the local coordinate system.\n*        Exaxis  - Point on (local) positive x-axis.\n*        Enorm   - Normal to the xy-plane. (z-axis).\n*\n* Output:\n*        Ematrix - Transformation metrix to the local coordinate system.\n*        Jstat   - Output status.\n*\n* Calls: s6scpr, s6crss, s6err.\n*\n* Written by: A.M. Ytrehus, SI Oslo Nov.91.\n* After FORTRAN (P6INN).\n*****************************************************************\n*/\n{\n  double syaxis[3], sxaxis[3];\n  double teps = (double) 0.000001;\n  double tdum, tdum1, tdum2, tdum3;\n  int kp;\n  int idim = 3;\n\n  int kpos = 0;\n\n  *jstat = 0;\n\n\n  /* First column will be the relative X-axis, second column\n     the relative Y-axis, third column the relative Z-axis, and\n     fourth column the local origo. The fourth line will be 0,0,0,1. */\n\n\n  /* Find the local X-axis. */\n\n  for (kp = 0; kp < idim; kp++)\n    sxaxis[kp] = exaxis[kp] - eorigo[kp];\n\n\n  /* Calculate the local Y-axis = (Z) X (X). */\n\n  s6crss (enorm, sxaxis, syaxis);\n\n\n  /* Normalise the three axis-vectors, and put into the matrix. */\n\n  tdum = s6scpr (sxaxis, sxaxis, idim);\n  tdum1 = sqrt (tdum);\n  if (tdum1 < teps)\n    goto err166;\n\n  tdum = s6scpr (syaxis, syaxis, idim);\n  tdum2 = sqrt (tdum);\n  if (tdum2 < teps)\n    goto err166;\n\n  tdum = s6scpr (enorm, enorm, idim);\n  tdum3 = sqrt (tdum);\n  if (tdum3 < teps)\n    goto err166;\n\n\n  for (kp = 0; kp < idim; kp++)\n    {\n      ematrix[4 * kp] = sxaxis[kp] / tdum1;\n      ematrix[4 * kp + 1] = syaxis[kp] / tdum2;\n      ematrix[4 * kp + 2] = enorm[kp] / tdum1;\n      ematrix[4 * kp + 3] = eorigo[kp];\n      ematrix[12 + kp] = (double) 0.0;\n    }\n\n  ematrix[15] = (double) 1.0;\n\n  goto out;\n\n  /* Impossible to create matrix. */\n\nerr166:\n  *jstat = -166;\n  s6err (\"s6rotmat\", *jstat, kpos);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/s6schoen.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6schoen.c,v 1.2 2001-03-19 15:59:02 afr Exp $\n *\n */\n\n\n\n#define S6SCHOEN\n\n#include \"sislP.h\"\n#if defined(SISLNEEDPROTOTYPES)\ndouble\ns6schoen(double et[], int ik, int index)\n#else\ndouble s6schoen(et,ik,index)\n     double et[];\n     int    ik;\n     int    index;\n#endif\n\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To determine the knot value of a specified vertice.\n*\n*\n* INPUT      : et     - Double array of dimension [in+ik] containing\n*                       the knot vector.\n*              ik     - The polynomial order of the B-splines associated\n*                       with et.\n*              index  - The vertice index at where the knot values are to \n*                       be computed.\n*\n*                \n*\n* INPUT/OUTPUT :\n*              s6schoen - The knot value at index.\n*\n*\n* METHOD     : The aim is to calculate the knot value of a vertice, using the\n*              Schoenberg spline expression:\n*\n*               *\n*              t  = (t    + .............. +t     )/k-1.\n*               i     i+1                    i+k-1\n*\n* REFERENCES :\n*\n*-\n* CALLS      : \n*\n* WRITTEN BY : Per Evensen,SI, August 1991.\n*\n*********************************************************************\n*/                                     \n{\n  int i;             /* Loop variable                                   */\n  double kval=DZERO; /* knot value variable                             */\n  \n  for (i=index+1;i<index+ik;i++) kval+=et[i];\n  kval = kval/(ik-1);\n\nreturn(kval);\n}\n\n"
  },
  {
    "path": "src/s6scpr.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6scpr.c,v 1.2 2001-03-19 15:59:02 afr Exp $\n *\n */\n\n\n#define S6SCPR\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\ndouble \ns6scpr(double e1[],double e2[],int idim)\n#else\ndouble s6scpr(e1,e2,idim)\n     double e1[];\n     double e2[];\n     int    idim;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To make the scalar product of two vectors\n*\n* INPUT      : e1      - The first vector in the scalar product\n*              e2      - The second vector in the scalar product\n*              idim    - Number of dimensions in the space the vectors lie\n*\n* OUTPUT     : s6scpr  - The value of the scalar product\n*\n* METHOD     : The scalar product is calculated according to the definition\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. 1988-may-03\n*                                  \n*********************************************************************\n*/\n{\n  register int ki;\n  register double tsum=DZERO; \n\n  for (ki=0;ki<idim;ki++)\n    tsum += e1[ki]*e2[ki];\n\n  return(tsum);\n}\n"
  },
  {
    "path": "src/s6sortpar.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6sortpar.c,v 1.2 2001-03-19 15:59:02 afr Exp $\n *\n */\n\n\n#define S6SORTPAR\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      s6sortpar(double evec1[],double epar1[],int ipar,int idim,\n\t\tdouble evec2[],double epar2[],int *jstat)\n#else\nvoid s6sortpar(evec1,epar1,ipar,idim,evec2,epar2,jstat)\n     double evec1[];\n     double epar1[];\n     int ipar;\n     int idim;\n     double evec2[];\n     double epar2[];\n     int *jstat;\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : Sort vector of parameter values and a corresponding vector\n*              after increasing parameter value. \n* \n* \n* INPUT      : evec1    - Vector corresponding to vector of parameter \n*                         values. To each parameter value idim elements\n*                         correspond. Dimension of array is ipar*idim.\n*              epar1    - Parameter values to be sorted. Dimension is ipar.\n*              ipar     - Number of parameter value.\n*              idim     - Dimension of geometry space.\n*\n* \n* OUTPUT     : evec2    - Vector sorted according to corresponding parameter\n*                         values. Dimension is ipar*idim. This array may\n*                         be the same as evec1.\n*              epar2    - Sorted parameter value. Dimension is ipar. This\n*                         array may be the same as epar1.\n*              jstat    - status messages \n*                          > 0 : warning \n*                          = 0 : ok \n*                          < 0 : error \n* \n* \n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        :\n*\n*-\n* CALLS      : \n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 08.90.\n*\n*********************************************************************\n*/\n{\n  int ki,kj;            /* Counters.  */\n  double tpar;          /* Intermediate storage of double.  */\n  double *svec = SISL_NULL;  /* Intermediate storage of double vector.  */\n  \n  /* Allocate scratch for local array.  */\n\n  if ((svec = newarray(idim,DOUBLE)) == SISL_NULL) goto err101;\n  \n  /* Move input arrays to output arrays.  */\n\n  memcopy(evec2,evec1,idim*ipar,DOUBLE);\n  memcopy(epar2,epar1,ipar,DOUBLE);\n  \n  /* Sort output arrays according to parameter value.  */\n\n  for (ki=0; ki<ipar-1; ki++)\n    for (kj=ki+1; kj<ipar; kj++)\n      if (epar2[kj] < epar2[ki])\n\t{\n\t  /* Interchange parameter values.  */\n\n\t  tpar = epar2[kj];\n\t  epar2[kj] = epar2[ki];\n\t  epar2[ki] = tpar;\n\n\t  /* Interchange elements of corresponding vector.  */\n\n\t  memcopy(svec,evec2+kj*idim,idim,DOUBLE);\n\t  memcopy(evec2+kj*idim,evec2+ki*idim,idim,DOUBLE);\n\t  memcopy(evec2+ki*idim,svec,idim,DOUBLE);\n\t}\n  \n  /* Arrays sorted.  */\n\n  *jstat = 0;\n  goto out;\n  \n  /* Error in scratch allocation.  */\n\n err101:\n  *jstat = -101;\n  goto out;\n  \n out:\n  \n  /* Free space occupied by local array.  */\n\n  if (svec != SISL_NULL) freearray(svec);\n  \n  return;\n}\n"
  },
  {
    "path": "src/s6sratder.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6sratder.c,v 1.3 2001-03-19 15:59:02 afr Exp $\n *\n */\n\n\n#define S6SRATDER\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6sratder(double eder[],int idim,int ider1,int ider2,double gder[],int *jstat)\n#else\nvoid s6sratder(eder,idim,ider1,ider2,gder,jstat)\n     double eder[];\n     int    idim;\n     int    ider1;\n     int    ider2;\n     double gder[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate the value and ider1*ider2 derivatives of \n*              a rational B-spline surface.\n*\n* INPUT      : eder    - Double array of dimenson [(ider2+1)*(ider1+1)*(idim+1)]\n*                        containing the position and the derivative vectors\n*                        of the surface at the point with parameter value\n*                        (epar[0],epar[1]).\n*                        (idim+1 is the number of components of each B-spline\n*                        coefficient, i.e. the dimension of the homogemous\n*                        space in which the surface lies.)\n*                        These vectors are stored in the following order:\n*                        First the idim+1 components of the position vector,\n*                        then the idim+1 components of the D(1,0) vector,\n*                        and so on up to the idim+1 components of the D(ider1,0)\n*                        vector,\n*                        then the idim+1 components of the D(0,1) vector etc.\n*                        Equivalently, if eder is considered to be a\n*                        three dimensional array, then its declaration in C\n*                        would be eder[ider2+1,ider1+1,idim+1]\n*              idim    - The dimension of the non homogenous space\n*              ider1   - The number of input derivatives with respect\n*                        to the first parameter direction.\n*              ider2   - The number of input derivatives with respect\n*                        to the second parameter direction.\n*\n*\n* OUTPUT     : jstat   - Status message\n*                                        >0      : Warning\n*                                        =0      : ok\n*                                        <0      : Error\n*              gder    - Double array of dimension [(ider2+1)*(ider1+1)*idim]\n*                        containing the position and the derivative vectors\n*                        of the surface at the point with parameter value\n*                        (epar[0],epar[1]).\n*                        (idim is the number of components of each B-spline\n*                        coefficient, i.e. the dimension of the Euclidean\n*                        space in which the surface lies.)\n*                        These vectors are stored in the following order:\n*                        First the idim components of the position vector,\n*                        then the idim components of the D(1,0) vector,\n*                        and so on up to the idim components of the D(ider1,0)\n*                        vector,\n*                        then the idim components of the D(0,1) vector etc.\n*                        Equivalently, if eder is considered to be a\n*                        three dimensional array, then its declaration in C\n*                        would be gder[ider2+1,ider1+1,idim]\n*\n*\n* METHOD     :  The surface P(u,v) can be written as the quotient\n*               P(u,v) = T(u,v) / w(u,v) where T and w are ordinary splines.\n*               The dimensions of T and w are idim and 1\n*               respectively. The array eder contains position\n*               and derivatives of the idim+1 dimensional surface\n*               (T(u,v),w(u,v)).\n*\n*               Now, since wP = T, we find, by the Leibnitz formula,\n*\n*      k   l\n*                  k!       l!     (k-i,l-j) (i,j)         (k,l)\n*     sum sum   -------- -------- w         P         =   T       .\n*               i!(k-i)! j!(l-j)!\n*     i=0 j=0\n*\n*               Therefore\n*               \n*\n*              --            k   l                                     --\n*      (k,l)   |   (k,l)                k!       l!     (k-i,l-j) (i,j) |    \n*     P      = |  T      -  sum sum  -------- -------- w         P      | / w .\n*              |                     i!(k-i)! j!(l-j)!                  |\n*              --           i=0 j=0                                    --\n*                               i+j<k+l\n*\n*               This formula is applied recursively to evaluate P's derivatives.\n*\n*                                                          MF.\n*\n*\n*\n* CALLS      :\n*\n* WRITTEN BY : Per Evensen, SI, Oslo, Norway. 1989-apr-1989\n* REVISED BY : Michael Floater, 30/9/91 Bug fix for derivatives.\n* REWRITTEN BY : Michael Floater, SI, 16/12/91. New algorithm.\n* REWRITTEN BY : Michael Floater, SI, 25/8/92. Extend to arbitrary\n*                   number of derivatives (by Leibnitz). Finally!\n* REVISED BY : Michael Floater, SI, 8/9/92. Optimised.\n*\n*********************************************************************\n*/\n{\n  int kpos=0;          /* Position of error.                     */\n  double w0;           /* The denominator.                       */\n  int ki;              /* Count through dimensions.              */\n  int idu;             /* Count through derivatives in u.        */\n  int idv;             /* Count through derivatives in v.        */\n  int *binom=SISL_NULL;     /* Array for binomial coefficients.       */\n  int *binomu=SISL_NULL;    /* Pointer to binomial coefficients in u. */\n  int *binomv=SISL_NULL;    /* Pointer to binomial coefficients in v. */\n  double *sum1=SISL_NULL;   /* Leibnitz expansion in u                */\n  double *sum2=SISL_NULL;   /* Leibnitz expansion in u and v.         */\n  double sumdum1[4];   /* Fixed space for sum1.                  */\n  double sumdum2[4];   /* Fixed space for sum2.                  */\n  int idimp1;          /* idim + 1.                              */\n  int iw;              /* Pointer to a weight.                   */\n  int iwbase;          /* Starting value of iw on each row.      */\n  int igder;           /* Pointer to already calculated derivs.  */\n  int igbase;          /* Starting value of igder on each row.   */\n  int i,iu,iv,j,k;     /* Counters.                              */\n  int ider1p1;         /* ider1 + 1.                             */\n  int ider2p1;         /* ider2 + 1.                             */\n  int igrow;           /* (ider1+1) * idim.                      */  \n  int iwrow;           /* (ider1+1) * idimp1.                    */  \n  int iwfix;           /* Index of initial weight in sum.        */\n  int bidum[10];       /* Array for storing binomial coeffs.     */\n  int idermax;         /* maximum of ider1 and ider2.            */\n  double temp;         /* Temporary multiple.                    */\n  \n  if (ider1<0 || ider2<0) goto err178;\n  if (idim<1) goto err102;\n  \n  *jstat = 0;\n\n  /* Find denominator. */ \n  \n  w0 = eder[idim];\n  if (DEQUAL(w0,DZERO)) w0 = (double)1.0;\n\n  /* If we're only asked for position, we'll do it\n     now and exit for the sake of speed. */\n\n  if(ider1 == 0 && ider2 == 0)\n  {\n      for(ki=0; ki<idim; ki++)\n      {\n          gder[ki] = eder[ki] / w0;\n      }\n\n      goto out;\n  }\n\n  /* Set up some constants. */\n\n  idimp1  = idim + 1;\n  ider1p1 = ider1 + 1;\n  ider2p1 = ider2 + 1;\n  igrow   = ider1p1 * idim;\n  iwrow   = igrow + ider1p1;  /* = iderp1 * idimp1  */\n\n\n  /* Set up  binomial coefficients.\n     Use new array only when ider1 > 3 or ider2 > 3. */\n\n  idermax = max(ider1,ider2);\n\n  if (idermax > 3)\n  { \n      binom = newarray(((idermax+1)*(idermax+2)) >> 1, INT);\n      if(binom == SISL_NULL) goto err179;\n  }\n  else\n  { \n      binom = bidum;\n  }\n\n  for(j=0,k=0; j<=idermax; j++,k+=j)\n  {\n      /* Calculate the new row of binomial coefficients. */\n  \n      binom[k] = 1;\n  \n      for(i=k+1; i<k+j; i++)\n      {\n          binom[i] = binom[i-j-1] + binom[i-j];\n      }\n\n      binom[k+j] = 1;\n  }\n  \n\n  /* Set up space for sum1 and sum2 if necessary.\n     Use new arrays only when idim > 4. */\n\n  if (idim > 4)\n  { \n      sum1 = newarray(idim, DOUBLE);\n      if(sum1 == SISL_NULL) goto err179;\n      sum2 = newarray(idim, DOUBLE);\n      if(sum2 == SISL_NULL) goto err179;\n  }\n  else\n  { \n      sum1=sumdum1;\n      sum2=sumdum2;\n  }\n\n\n  /* Loop through derivatives in u and v. */\n\n  for(idv=0,binomv=binom,j=0,k=0; idv<=ider2; idv++,binomv+=idv)\n  {\n\n      for(idu=0,binomu=binom; idu<=ider1; idu++,k++,binomu+=idu)\n      {\n\n    \n          if(idu == 0 && idv == 0)\n          {\n  \t      /* Position is a special case. */\n    \n              for(ki=0; ki<idim; ki++,j++,k++)\n              {\n                  gder[j] = eder[k] / w0;\n              }\n    \n          }\n          else\n          {\n    \n              /* Calculate each coefficient of the (idu,idv)'th\n\t\t derivative of the rational surface (in gder).\n        \n  \t       This requires calculating the Liebnitz sum from\n  \t       the subarray of gder (0,..,idu, 0,...,idv) and\n  \t       the subarray of eder (0,..,idu, 0,...,idv). */\n  \n  \t      iwfix = k + idim;\n  \n  \t      /* Calculate the Leibnitz sum. */\n        \n              for(ki=0; ki<idim; ki++)\n\t      {\n  \t          sum2[ki] = (double)0.0;\n\t      }\n        \n              for(iv=0,igbase=0,iwbase=iwfix;\n  \t      iv<=idv;\n  \t      iv++,igbase+=igrow,iwbase-=iwrow)\n              {\n        \n                  for(ki=0; ki<idim; ki++)\n\t          {\n  \t              sum1[ki] = (double)0.0;\n\t          }\n \n                  for(iu=0,igder=igbase,iw=iwbase;\n  \t          iu<=idu;\n  \t          iu++,iw-=idimp1)\n                  {\n  \t\t      /* Add the next Leibnitz term unless we\n  \t\t         have reached the last one (the unknown). */\n  \n  \t              if(iu<idu || iv<idv)\n  \t\t      {\n  \t\t\t  /* If iu=0 or iu=idu, the u binomial\n  \t\t\t     coefficient is 1 so don't multiply. */\n  \n  \t\t          if(iu>0 && iu<idu)\n  \t\t\t  {\n  \t\t\t    temp = (double)binomu[iu] * eder[iw];\n\n                            for(ki=0; ki<idim; ki++,igder++)\n                            {\n  \t\t\t      sum1[ki] += temp * gder[igder];\n  \t\t\t    }\n  \t\t\t  }\n  \t\t\t  else\n  \t\t\t  {\n                            for(ki=0; ki<idim; ki++,igder++)\n                            {\n  \t\t\t      sum1[ki] += eder[iw] * gder[igder];\n  \t\t\t    }\n  \t\t\t  }\n  \n  \t\t      }\n                  }\n  \n  \t\t  /* If iv=0 or iv=idv, the v binomial\n  \t\t     coefficient is 1 so don't multiply. */\n  \n  \t\t  if(iv>0 && iv<idv)\n  \t\t  {\n                    for(ki=0; ki<idim; ki++)\n\t\t    {\n  \t\t        sum2[ki] += (double)binomv[iv] * sum1[ki];\n\t\t    }\n  \t\t  }\n  \t\t  else\n  \t\t  {\n                    for(ki=0; ki<idim; ki++)\n\t\t    {\n  \t\t        sum2[ki] += sum1[ki];\n\t\t    }\n  \t\t  }\n  \n              }\n        \n              for(ki=0; ki<idim; ki++,j++,k++)\n\t      {\n  \t          gder[j] = (eder[k] - sum2[ki]) / w0;\n\t      }\n        \n          }\n  \n      }\n    \n  }\n\n\n  /* Free arrays. */\n\n  if (idermax > 3)\n  { \n      freearray(binom);\n  }\n  \n  if (idim > 4)\n  { \n      freearray(sum1);\n      freearray(sum2);\n  }\n  \n\n\n  /* Done. */\n\n  \n  goto out;\n\n\n/* idim less than 1. */\n err102: *jstat = -102;\n         s6err(\"s6ratder\",*jstat,kpos);\n         goto out;\n\n/* Derivative negative */\n err178: *jstat = -178;\n         s6err(\"s6ratder\",*jstat,kpos);\n         goto out;\n\n\n/* Not enough memory */\n err179: *jstat = -179;\n         s6err(\"s6ratder\",*jstat,kpos);\n         goto out;\n\n\nout: \nreturn;\n}\n\n"
  },
  {
    "path": "src/s6strider.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6strider.c,v 1.3 2001-03-19 15:59:02 afr Exp $\n *\n */\n\n\n#define S6STRIDER\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6strider(double eder[],int idim,int ider,double gder[],int *jstat)\n#else\nvoid s6strider(eder,idim,ider,gder,jstat)\n     double eder[];\n     int    idim;\n     int    ider;\n     double gder[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate the value and ider*ider derivatives of \n*              a rational B-spline surface.\n*\n* INPUT      : eder    - Double array of dimenson [(ider+1)*(ider+2)*(idim+1)/2]\n*                        containing the position and the derivative vectors\n*                        of the homogeneous surface at the point with parameter value\n*                        (epar[0],epar[1]).\n*                        (idim+1 is the number of components of each B-spline\n*                        coefficient, i.e. the dimension of the homogemous\n*                        space in which the surface lies.)\n*                        These vectors are stored in the following order:\n*                        First the idim+1 components of the position vector,\n*                        then the idim+1 components of the D(1,0) vector,\n*                        then the idim+1 components of the D(0,1) vector,\n*                        then the idim+1 components of the D(2,0) vector,\n*                        followed by D(1,1), D(0,2)\n*                        and so on up to the idim+1 components of the D(0,ider).\n*              idim    - The dimension of the non homogenous space\n*              ider    - The number of input derivatives with respect\n*                        to both parameter directions.\n*\n*\n* OUTPUT     : jstat   - Status message\n*                                        >0      : Warning\n*                                        =0      : ok\n*                                        <0      : Error\n*              gder    - Double array of dimension [(ider+1)*(ider+2)*idim/2]\n*                        containing the position and the derivative vectors\n*                        of the surface at the point with parameter value\n*                        (epar[0],epar[1]).\n*                        (idim is the number of components of each B-spline\n*                        coefficient, i.e. the dimension of the Euclidean\n*                        space in which the surface lies.)\n*                        These vectors are stored in the following order:\n*                        First the idim components of the position vector,\n*                        then the idim components of the D(1,0) vector,\n*                        then the idim components of the D(0,1) vector,\n*                        then the idim components of the D(2,0) vector,\n*                        followed by D(1,1), D(0,2)\n*                        and so on up to the idim components of the D(0,ider).\n*\n*\n* METHOD     :  The surface P(u,v) can be written as the quotient\n*               P(u,v) = T(u,v) / w(u,v) where T and w are ordinary splines.\n*               The dimensions of T and w are idim and 1\n*               respectively. The array eder contains position\n*               and derivatives of the idim+1 dimensional surface\n*               (T(u,v),w(u,v)).\n*\n*               Now, since wP = T, we find, by the Leibnitz formula,\n*\n*      k   l\n*                  k!       l!     (k-i,l-j) (i,j)         (k,l)\n*     sum sum   -------- -------- w         P         =   T       .\n*               i!(k-i)! j!(l-j)!\n*     i=0 j=0\n*\n*               Therefore\n*               \n*\n*              --            k   l                                     --\n*      (k,l)   |   (k,l)                k!       l!     (k-i,l-j) (i,j) |    \n*     P      = |  T      -  sum sum  -------- -------- w         P      | / w .\n*              |                     i!(k-i)! j!(l-j)!                  |\n*              --           i=0 j=0                                    --\n*                               i+j<k+l\n*\n*               This formula is applied recursively to evaluate P's derivatives.\n*\n*                                                          MF.\n*\n*\n*\n* CALLS      :\n*\n* WRITTEN BY : Michael Floater, SI, 3.9.92.\n*                Essentially the same as s6sratder\n*                except that we work with triangular matrices\n*                ((0,0), (1,0), (0,1), (2,0), (1,1), ...)\n*                instead of rectangular ones.\n* Revised by : Christophe Rene Birkeland, SINTEF Oslo, May 1993.\n*              Error message corrected\n*\n*********************************************************************\n*/\n{\n  int kpos=0;          /* Position of error.                     */\n  double w0;           /* The denominator.                       */\n  int ki;              /* Count through dimensions.              */\n  int idu;             /* Count through derivatives in u.        */\n  int idv;             /* Count through derivatives in v.        */\n  int *binom=SISL_NULL;     /* Array for binomial coefficients.       */\n  int *binomu=SISL_NULL;    /* Pointer to binomial coefficients in u. */\n  int *binomv=SISL_NULL;    /* Pointer to binomial coefficients in v. */\n  double *sum1=SISL_NULL;   /* Leibnitz expansion in u                */\n  double *sum2=SISL_NULL;   /* Leibnitz expansion in u and v.         */\n  double sumdum1[4];   /* Fixed space for sum1.                  */\n  double sumdum2[4];   /* Fixed space for sum2.                  */\n  int idimp1;          /* idim + 1.                              */\n  int iw;              /* Pointer to a weight.                   */\n  int igder;           /* Pointer to already calculated derivs.  */\n  int i,iu,iv,j,k;     /* Counters.                              */\n  int iderp1;          /* ider + 1.                              */\n  int igrow;           /* (ider+1) * idim.                       */  \n  int iwrow;           /* (ider+1) * idimp1.                     */  \n  int iutemp,ivtemp;   /* Used to find next weight in the sum.   */\n  int tot,temp1;       /* Temporary variables.                   */\n  int bidum[10];       /* Array for storing binomial coeffs.     */\n  double temp;         /* Temporary multiple.                    */\n  \n  if (ider<0) goto err178;\n  if (idim<1) goto err102;\n  \n  *jstat = 0;\n\n  /* Find denominator. */ \n  \n  w0 = eder[idim];\n  if (DEQUAL(w0,DZERO)) w0 = (double)1.0;\n\n  /* If we're only asked for position, we'll do it\n     now and exit for the sake of speed. */\n\n  if(ider == 0)\n  {\n    for(ki=0; ki<idim; ki++)\n      gder[ki] = eder[ki] / w0;\n\n    goto out;\n  }\n\n  /* Set up some constants. */\n\n  idimp1  = idim + 1;\n  iderp1 = ider + 1;\n  igrow   = iderp1 * idim;\n  iwrow   = igrow + iderp1;  /* = iderp1 * idimp1 */\n\n  /* Set up  binomial coefficients.\n     Use new array only when ider > 3. */\n\n  if (ider > 3)\n  { \n    binom = newarray((iderp1*(iderp1+1)) >> 1, INT);\n    if(binom == SISL_NULL) goto err179;\n  }\n  else\n  { \n    binom = bidum;\n  }\n\n  for(j=0,k=0; j<=ider; j++,k+=j)\n  {\n      /* Calculate the new row of binomial coefficients. */\n  \n      binom[k] = 1;\n  \n      for(i=k+1; i<k+j; i++)\n      {\n          binom[i] = binom[i-j-1] + binom[i-j];\n      }\n\n      binom[k+j] = 1;\n  }\n\n  /* Set up space for sum1 and sum2 if necessary.\n     Use new arrays only when idim > 4. */\n\n  if (idim > 4)\n  { \n    sum1 = newarray(idim, DOUBLE);\n    if(sum1 == SISL_NULL) goto err179;\n    sum2 = newarray(idim, DOUBLE);\n    if(sum2 == SISL_NULL) goto err179;\n  }\n  else\n  { \n    sum1=sumdum1;\n    sum2=sumdum2;\n  }\n  \n  /* Loop through derivatives in u and v. */\n\n  for(idv=0,binomv=binom; idv<=ider; idv++,binomv+=idv)\n  {\n    for(idu=0,binomu=binom; idu<=ider-idv; idu++,binomu+=idu)\n    {\n      if(idu == 0 && idv == 0)\n      {\n          /* Position is a special case. */\n    \n          for(ki=0; ki<idim; ki++)\n            gder[ki] = eder[ki] / w0;\n      }\n      else\n      {\n          /* Calculate indices in eder and gder. */\n    \n          tot = idu + idv;\n          temp1 = ((tot * (tot+1)) >> 1) + idv;\n    \n          j = temp1 * idim;\n          k = j + temp1;\n\n          /* Calculating each coefficient of the (idu,idv)'th\n\t     derivative of the rational surface (in gder).\n        \n  \t     This requires calculating the Liebnitz sum from\n  \t     the subarray of gder (0,..,idu, 0,...,idv) and\n             the subarray of eder (0,..,idu, 0,...,idv). */\n\n          /* Calculate the Leibnitz sum. */\n\n          for(ki=0; ki<idim; ki++)\n            sum2[ki] = (double)0.0;        \n\n          for(iv=0; iv<=idv; iv++)\n          {\n            for(ki=0; ki<idim; ki++)\n               sum1[ki] = (double)0.0;\t               \n            ivtemp = idv-iv;\n\n            for(iu=0; iu<=idu; iu++)\n            {\n                tot = iu + iv;\n                temp1 = ((tot * (tot+1)) >> 1) + iv;\n\n\t        igder = temp1 * idim;\n                iutemp = idu-iu;\n\n                tot = iutemp + ivtemp;\n\t        temp1 = ((tot * (tot+1)) >> 1) + ivtemp;\n\n                iw   = temp1 * idimp1 + idim;\n\n     \t      /* Add the next Leibnitz term unless we\n       \t\t have reached the last one (the unknown). */\n  \n                if(iu<idu || iv<idv)\n  \t        {\n  \t       \t  /* If iu=0 or iu=idu, the u binomial\n  \t       \t     coefficient is 1 so don't multiply. */\n  \n  \t            if(iu>0 && iu<idu)\n  \t       \t    {\n  \t\t      temp = (double)binomu[iu] * eder[iw];\n                      for(ki=0; ki<idim; ki++,igder++)\n  \t       \t         sum1[ki] += temp * gder[igder];\n  \t\t     }\n  \t\t     else\n                       for(ki=0; ki<idim; ki++,igder++)\n  \t\t         sum1[ki] += eder[iw] * gder[igder];\n                }\n            }\n  \n  \t    /* If iv=0 or iv=idv, the v binomial\n  \t       coefficient is 1 so don't multiply. */\n  \n  \t    if(iv>0 && iv<idv)\n              for(ki=0; ki<idim; ki++)\n  \t          sum2[ki] += (double)binomv[iv] * sum1[ki];\n  \t    else\n              for(ki=0; ki<idim; ki++)\n\t\t sum2[ki] += sum1[ki];\t\t    \n          }\n          for(ki=0; ki<idim; ki++,j++,k++)\n            gder[j] = (eder[k] - sum2[ki]) / w0;\n      }\n    }\n  }  \n\n  /* Free arrays. */\n\n  if (ider > 3 && binom != SISL_NULL)\n     freearray(binom);\n  \n  if (idim > 4)\n  { \n     if(sum1 != SISL_NULL) freearray(sum1);\n     if(sum2 != SISL_NULL) freearray(sum2);\n  }\n\n  /* Done. */\n\n  goto out;\n\n  /* idim less than 1. */\n\n  err102: \n    *jstat = -102;\n    s6err(\"s6strider\",*jstat,kpos);\n    goto out;\n\n  /* Derivative negative */\n\n  err178: \n    *jstat = -178;\n    s6err(\"s6strider\",*jstat,kpos);\n    goto out;\n\n  /* Not enough memory */\n\n  err179: \n    *jstat = -179;\n    s6err(\"s6strider\",*jstat,kpos);\n    goto out;\n\n  out:\n    return;\n}\n\n"
  },
  {
    "path": "src/s6takunion.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6takunion.c,v 1.2 2001-03-19 15:59:02 afr Exp $\n *\n */\n\n\n#define S6TAKEUNION\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid s6takeunion(double evec1[],int ielem1,double evec2[],int ielem2,\n\t\t double **gunion,int *jnmbelem,int *jstat)\n#else\t \nvoid s6takeunion(evec1,ielem1,evec2,ielem2,gunion,jnmbelem,jstat)\n     int ielem1,ielem2,*jnmbelem,*jstat;\n     double evec1[],evec2[],**gunion;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Take the union between two sorted double vectors. Identical \n*              elements in the two vectors are only represented once. \n*              If several elements in one array are equal, all are\n*              represented.\n*\n*\n* INPUT      : evec1    - First vector.\n*              ielem1   - Number of elements of evec1.\n*              evec2    - Second vector.\n*              ielem2   - Number of elements of evec2.\n*                       \n*\n* OUTPUT     : gunion   - Union vector.\n*              jnmbelem - Number of elements of gunion.\n*              jstat    - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n* REFERENCES : \n*\n* USE        : \n*\n*-\n* CALLS      : \n*\n* WRITTEN BY : Vibeke Skytt, SI, 06.90.\n*\n*********************************************************************\n*/\n{\n  int knelem;\n  int knunion;\n  double *sunion = SISL_NULL;\n  double *s1,*s1stop;\n  double *s2,*s2stop;\n  \n  /* Make local array to store the union of the vectors.  */\n\n  knelem = ielem1 + ielem2;\n  if ((sunion = newarray(knelem,DOUBLE)) == SISL_NULL) goto err101;\n  \n  /* Produce union vector. */\n\n  for (s1=evec1,s1stop=s1+ielem1,s2=evec2,s2stop=s2+ielem2,knunion=0; \n       s1<s1stop && s2<s2stop;)\n      {\n\tif (*s1 < *s2)\n\t  sunion[knunion++] = *s1++;\n\telse if (*s2 < *s1)\n\t  sunion[knunion++] = *s2++;\n\telse\n\t  {\n\t    sunion[knunion++] = *s1++;\n\t    s2++;\n\t  }\n      }\n\n  for (; s1<s1stop; s1++,knunion++)\n    sunion[knunion] = *s1;\n\n  for (; s2<s2stop; s2++,knunion++)\n    sunion[knunion] = *s2;\n  \n  /* Allocate scratch for output union vector.  */\n\n  *gunion = SISL_NULL;\n  if ((*gunion = newarray(knunion,DOUBLE)) == SISL_NULL) goto err101;\n  \n  /* Copy union vector to output vector.  */\n\n  memcopy(*gunion,sunion,knunion,DOUBLE);\n  *jnmbelem = knunion;\n  \n  /* Union found.  */\n\n  *jstat = 0;\n  goto out;\n  \n  /* Error in scratch allocation.  */\n\n  err101 :\n    *jstat = -101;\n  goto out;\n  \n  out :\n    /* Free scratch occupied by local array.  */\n\n    if (sunion != SISL_NULL) freearray(sunion);\n  \n  return;\n}\n"
  },
  {
    "path": "src/s6testimpl.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n#define S6TESTIMPL\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic int s6testimpl_classify(SISLSurf *ps1, SISLSurf *ps2, SISLIntpt *vintpt[],\n\t\t\t       int inmbpt, int ndir[], int *jstat);\n#else\nstatic int s6testimpl_classify();\n#endif\n\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns6testimpl(SISLSurf *ps1, SISLSurf *ps2, int first, SISLIntpt *vintpt[],\n\t   int inmbpt, double aepsge, int *jstat)\n#else\nvoid\n  s6testimpl(ps1, ps2, first, vintpt, inmbpt, aepsge, jstat)\n   SISLSurf *ps1;\n   SISLSurf *ps2;\n   int first;\n   SISLIntpt *vintpt[];\n   int inmbpt;\n   double aepsge;\n   int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Try to intercept intersection between two B-spline\n*              surfaces by finding a computing an implicit surface\n*              approximating the first surface and inserting the\n*              second surface into the implicit expression. Box test\n*              and simple case test is performed.\n*\n*\n* INPUT      : ps1      - First surface.\n*              ps2      - Second surface.\n*              first    - Indicates if first surface is to be implicitized\n*              vintpt   - Intersection points on edges\n*              inmbpt   - Number of intersection points on edges\n*              aepsge   - Geometry tolerance. \n*\n*\n* OUTPUT     : jstat    - status messages\n*                                = 3   : Simple case encountered\n*                                = 1   : Intersection still possible.\n*                                = 0   : Ok. No intersection is possible.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      : \n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 2023-03.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;   /* Local status variable.  */\n   int kdim = ps1->idim;  /* Dimension of space. */\n   double tang;     /* Angle between normal cone axes */\n   int deg = 3;     /* Implicit degree                */\n   double tepsge;   /* Local tolerance.        */\n   SISLSurf *qs1 = SISL_NULL; /* 1D surface.                     */\n   SISLSurf *qs2 = SISL_NULL; /* 1D surface.                     */\n   int kk1, kk2;    /* Orders of first 1D surface.       */\n   int kk3, kk4;    /* Orders of second 1D surface.      */\n   int kn1, kn2;    /* Number of vertices of 1. 1D surface. */\n   int kn3, kn4;    /* Number of vertices of 2. 1D surface. */\n   double *st1 = NULL;   /* Knot vector of 1. 1D surface in 1. par. dir. */\n   double *st2 = NULL;   /* Knot vector of 1. 1D surface in 2. par. dir. */\n   double *st3 = NULL;   /* Knot vector of 2. 1D surface in 1. par. dir. */\n   double *st4 = NULL;   /* Knot vector of 2. 1D surface in 2. par. dir. */\n   double *sc = NULL;    /* Matrix of equation system for unknown implicit\n\t\t\t    coefficients */\n   double *sc1 = NULL;   /* Coefficients of 1D surface.     */\n   double *sc2 = NULL;   /* Coefficients of 1D surface.     */\n   double *scimp = NULL; /* Implicit coefficents.           */\n   int numscimp = 0;\n   double grad;          /* Estimate of medium gradient.               */\n   SISLSurf *ps3 = (first) ? ps1 : ps2;\n   SISLSurf *ps4 = (first) ? ps2 : ps1;\n   int ldir[10];\n   int conn = 0;\n   int ki;\n\n   /* Check if the surfaces are of Bezier type */\n   if (ps1->in1 > ps1->ik1 || ps1->in2 > ps1->ik2 ||\n       ps2->in1 > ps2->ik1 || ps2->in2 > ps2->ik2)\n     {\n       *jstat = 1;\n       goto out;\n     }\n\n   /* Check for normal cones in approximately the same area */\n   tang = s6ang(ps1->pdir->ecoef,ps2->pdir->ecoef,kdim);\n   if (tang > 0.25*PI)\n   {\n      *jstat = 1;\n      goto out; \n   } \n   \n   *jstat = 1;  /* Initiate to possibility of intersection.  */\n\n   /* Make matrix if implicitization equation */\n   s1326(ps3, deg, NULL, 1, &st1, &st2, &sc, &kk1, &kk2, &kn1, &kn2,\n\t &numscimp, &kstat);\n   if (kstat < 0)\n     goto error;\n   \n   if (st1) freearray(st1);\n   st1 = NULL;\n   if (st2) freearray(st2);\n   st2 = NULL;\n\n   /* Solve underdetermined equation system to find implicit coefficents. */\n   if ((scimp = newarray(numscimp, DOUBLE)) == NULL)\n     goto err101;\n   s1339(ps3, deg, sc, numscimp, kn1*kn2, aepsge, scimp, &grad, &kstat);\n   if (kstat < 0)\n     goto error;\n   if (kstat == 1)\n     goto warn1;  /* No implicit approximation computed. */\n   if (sc != NULL) freearray(sc);\n   sc = NULL;\n\n   /* Local tolerance */\n   tepsge = fabs(grad)*aepsge;\n\n   /* Put the description of the surfaces into the implicit equation */\n    s1326(ps3, deg, scimp, 1, &st1, &st2, &sc1, &kk1, &kk2, &kn1, &kn2,\n\t &numscimp, &kstat);\n   if (kstat < 0)\n     goto error;\n   \n   if ((qs1 = newSurf(kn1, kn2, kk1, kk2, st1, st2, sc1, 1, 1, 2)) == NULL)\n      goto err101;\n   \n   s1326(ps4, deg, scimp, 1, &st3, &st4, &sc2, &kk3, &kk4, &kn3, &kn4,\n\t &numscimp, &kstat);\n   if (kstat < 0)\n     goto error;\n   \n   if ((qs2 = newSurf(kn3, kn4, kk3, kk4, st3, st4, sc2, 1, 1, 2)) == NULL)\n      goto err101;\n\t \n   /* Make box of first 1D surface. */\n   sh1992su(qs1,0,tepsge,&kstat);\n   if (kstat < 0)\n     goto error;\n   sh1992su(qs1,2,tepsge,&kstat);\n   if (kstat < 0)\n     goto error;\n   \n   /* Make box of second 1D surface. */\n   sh1992su(qs2,0,tepsge,&kstat);\n   if (kstat < 0)\n     goto error;\n   sh1992su(qs2,2,tepsge,&kstat);\n   if (kstat < 0)\n     goto error;\n   \n   /* Check if the boxes overlap.  */\n   if (qs1->pbox->e2min[2][0] > qs2->pbox->e2max[2][0] ||\n       qs1->pbox->e2max[2][0] < qs2->pbox->e2min[2][0])\n     {\n       if (inmbpt > 0 &&\n\t   (qs1->pbox->e2min[0][0] <= qs2->pbox->e2max[0][0] &&\n\t    qs1->pbox->e2max[0][0] >= qs2->pbox->e2min[0][0]))\n\t {\n\t   /* Extra test on point configuration */\n\t   if (inmbpt <= 10)\n\t     {\n\t       /* Classify points */\n\t       conn = s6testimpl_classify(ps1, ps2, vintpt, inmbpt, ldir, &kstat);\n\t       if (kstat < 0)\n\t\t goto error;\n\t       for (ki=0; ki<inmbpt; ++ki)\n\t\t if (ldir[ki] == -1 || ldir[ki] == 1)\n\t\t   break;   /* Intersection curve tangens points in or out */\n\t       if (conn || ki == inmbpt)\n\t\t {\n\t\t   *jstat = 0;  /* No more intersections are possible */\n\t\t   goto out;\n\t\t }\n\t       \n\t     }\n\t }\n       else\n\t {\n\t   *jstat = 0;  /* No intersection possible */\n\t   goto out;\n\t }\n     }\n\n   /* Perform simple case test. */\n   if (ps1->pdir->igtpi != 0 || ps2->pdir->igtpi != 0)\n     goto warn1;\n   if (max(fabs(qs1->pbox->e2min[0][0]), fabs(qs1->pbox->e2max[0][0])) > tepsge)\n     goto warn1;   /* Check with non-expanded box. \n\t\t      The implicit approximation is not accurate enough\n\t\t      for a reliable simple case test */\n   sh1994(qs2, tepsge, &kstat);\n   *jstat = (kstat == 1) ? 3 : 1;\n   goto out;\n   \n   warn1 : *jstat = 1; /* No implicit approximation computed or \n\t\t\t  complex surface. */\n   goto out;           /* Possibility of intersection.        */\n   \n   error : *jstat = kstat;\n   goto out;\n   \n   err101 : *jstat = -101;         /* Error in scratch allocation. */\n   s6err(\"s6testimpl\",*jstat,0);\n   goto out;\n   \n   out:\n      if (qs1) freeSurf(qs1);\n      if (qs2) freeSurf(qs2);\n      if (sc) freearray(sc);\n      if (scimp) freearray(scimp);\n      \n      return;\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic int\ns6testimpl_classify(SISLSurf *ps1, SISLSurf *ps2, SISLIntpt *vintpt[],\n\t\t    int inmbpt, int ndir[], int *jstat)\n#else\nstatic int\n  s6testimpl_classify(ps1, ps2, vintpt, inmbpt, ndir, jstat)\n     SISLSurf *ps1;\n     SISLSurf *ps2;\n     SISLIntpt *vintpt[];\n     int inmbpt;\n     int ndir[];\n     int *jstat;\n#endif\n /*\n *********************************************************************\n *\n *********************************************************************\n *\n * PURPOSE    : To classify intersection points on edges on two surfaces\n *\n *\n *\n * INPUT      : ps1      - First surface in intersection.\n *              ps2      - Second surface in intersection.\n *              vintpt   - Intersection points on edges\n *              inmbpt   - Number of intersection points\n *\n * OUTPUT     : retur    - Whether (1) or not (0) the edge points are connected\n *              ndir     - Classification of intersection curve in each point\n *                               * 0 - The intersect.curve is parallel to one\n\t\t\t\t *      parameter direction.\n\t\t\t\t *  1 - The intersect.curve has direction into the\n\t\t\t\t *      domain.\n\t\t\t\t * -1 - The intersect.curve has direction out of the\n\t\t\t\t *      domain.\n\t\t\t\t *  2 - The point is singulear.\n\t\t\t\t * 10 - The intersect.curve touch one corner of the\n\t\t\t\t *      domain.\n *              jstat    - status messages\n *                           = 0     : OK.\n *                           < 0     : error\n *\n *\n * METHOD     :\n *\n *\n * REFERENCES :\n *\n *\n * WRITTEN BY : Vibeke Skytt, SINTEF, 23-03\n *\n *********************************************************************\n */\n{\n  int kstat = 0;\n  int ki, kj, kn, kv;\n  int klist1, klist2;\n  int klfs1 = 0, klft1 = 0, klfs2 = 0, klft2 = 0;\n  int conn = 0;\n  int dim = ps1->idim;\n  double sstart[4], send[4];\n  double tang;\n  int kdir;\n  double *sval1 = SISL_NULL;\n  double *sval2, *snorm1, *snorm2, *stang, *sdec1, *sdec2;\n  double *stmp, *stmp2;\n  int ix;\n  double tolpar = (double)0.001;\n\n  *jstat = 0;\n\n  sstart[0] = ps1->et1[ps1->ik1-1];\n  send[0] = ps1->et1[ps1->in1];\n  sstart[1] = ps1->et2[ps1->ik2-1];\n  send[1] = ps1->et2[ps1->in2];\n  sstart[2] = ps2->et1[ps2->ik1-1];\n  send[2] = ps2->et1[ps2->in1];\n  sstart[3] = ps2->et2[ps2->ik2-1];\n  send[3] = ps2->et2[ps2->in2];\n  \n  /* Check if the intersection points are connected */\n  for (ki=0; ki<inmbpt; ++ki)\n    {\n      for (kj=ki+1; kj<inmbpt; ++kj)\n\t{\n\t  sh6getlist(vintpt[ki], vintpt[kj], &klist1, &klist2, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  if (kstat == 0)\n\t    break;   /* Connection */\n\t}\n      if (kj == inmbpt)\n\tbreak;  /* No connection is found */\n    }\n  if (ki == inmbpt)\n    conn = 1;\n\n  /* Classify points */\n  if ((sval1 = newarray (11*dim, double)) == SISL_NULL)\n\tgoto err101;\n  sval2 = sval1 + 3*dim;\n  snorm1 = sval2 + 3*dim;\n  snorm2 = snorm1 + dim;\n  stang = snorm2 + dim;\n  sdec1 = stang + dim;\n  sdec2 = sdec1 + dim;\n\n  for (ki=0; ki<inmbpt; ++ki)\n    {\n      ndir[ki] = -20;  /* Direction not set */\n      s1421(ps1, 1, vintpt[ki]->epar, &klfs1, &klft1, sval1, snorm1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      \n       s1421(ps2, 1, vintpt[ki]->epar+2, &klfs2, &klft2, sval2, snorm2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      tang = s6ang (snorm1, snorm2, dim);\n      if (tang < REL_PAR_RES)\n\t{\n\t  ndir[ki] = 2;  /* Singularity */\n\t  continue;\n\t}\n\n      s6crss (snorm1, snorm2, stang);\n\n      s6decomp (stang, sdec1, sval1+dim, sval1+2*dim, snorm1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      else if (kstat > 0)\n\t{\n\t  ndir[ki] = 2;\n\t  continue;\n\t}\n\n      s6decomp (stang, sdec2, sval2+dim, sval2+2*dim, snorm2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      else if (kstat > 0)\n\t{\n\t  ndir[ki] = 2;\n\t  continue;\n\t}\n\n      for (int kj=0; kj<4; ++kj)\n\t{\n\t  kdir = -20;\n\t  stmp = (kj < 2) ? sval1 : sval2;\n\t  stmp2 = (kj < 2) ? sdec1 : sdec2;\n\t  ix = (kj == 0 || kj == 2) ? 2 : 1;\n\t  if (DEQUAL(vintpt[ki]->epar[kj], sstart[kj])) \n\t    {\n\t      tang = s6ang(stang, stmp+ix*dim, dim);\n\t      kdir = (stmp2[2-ix] < DZERO) ? 1 : -1;\n\t    }\n\t  else if (DEQUAL(vintpt[ki]->epar[kj], send[kj]))\n\t    {\n\t      tang = s6ang(stang, stmp+ix*dim, dim);\n\t      kdir = (stmp2[2-ix] < DZERO) ? -1 : 1;\n\t    }\n\t  if (kdir != -20 && tang < tolpar)\n\t    kdir = 0;\n\t  if (ndir[ki] == -20)\n\t    ndir[ki] = kdir;\n\t  else if (ndir[ki] != kdir)\n\t    {\n\t      if (ndir[ki] == 0)\n\t\tndir[ki] = kdir;\n\t      else\n\t\t{\n\t\t  ndir[ki] = 10;\n\t\t  break;\n\t\t}\n\t    }\n\t}\n    }\n\n  goto out;\n  \n  /* Error in sub rutines.      */\n error:*jstat = kstat;\n  goto out;\n\n  /* Error in memory allocation.      */\n err101:*jstat = -101;\n  goto out;\n\n out:\n  if (sval1 != SISL_NULL)\n    freearray(sval1);\n\n  return conn;\n}\n"
  },
  {
    "path": "src/s6twonorm.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s6twonorm.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S6TWONORM\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns6twonorm(double evec[],double enorm1[],double enorm2[],int *jstat)\n#else\nvoid s6twonorm(evec,enorm1,enorm2,jstat)\n     double evec[];\n     double enorm1[];\n     double enorm2[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To make two normal vectors of length 1 to the input\n*              vector which should be 3-dimensional\n*\n* INPUT      : evec    - The input vector (3-D)\n*\n* OUTPUT     : enorm1  - First normal vector\n*              enorm2  - Second normal vector\n*                        enorm1 and enorm2 are normal to each other\n*\n*              jstat   - Status message\n*                         0 - The length of the vector is zero\n*                         1 - The length of the vector is one\n*\n*\n* METHOD     : The length of the input vector is calulated, and the\n*              output is assigned the values of the input vector and \n*              divided by the length.\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. 1988-may-03\n*                                  \n*********************************************************************\n*/\n{\n  int kstat;                 /* Local status variable                        */\n  int kdim = 3;              /* We work in 3-D                               */\n  int kpos=0;                /* Position of eror                             */\n  double svec[3],sdum[3];    /* Local dummy arrays                           */\n  double t1,t2,t3;           /* Absolute value of components of svec         */\n  \n  \n  /* If the dimension is 1 the length of the vector is the same as the\n     absolute value of the number */\n  \n  \n  /* Normalize input vector */\n  \n  (void)s6norm(evec,kdim,svec,&kstat);\n  \n  if (kstat == 0) goto err174;\n  \n  t1 =fabs(svec[0]);\n  t2 =fabs(svec[1]);\n  t3 =fabs(svec[2]);\n  \n  /* Make along one of the main axis that has component 1 in the direction\n     that svec has the smalles component */\n  \n  sdum[0] = (double)0.0;\n  sdum[1] = (double)0.0;\n  sdum[2] = (double)0.0;\n  \n  if (t1 < t2 && t1 < t3)\n    {\n      sdum[0] = (double)1.0;\n    }\n  else if (t2 < t3)\n    {\n      sdum[1] = (double)1.0;\n    }\n  else\n    {\n      sdum[2] = (double)1.0;\n    }\n  \n  /* Make normal of sdum and svec */\n  \n  s6crss(svec,sdum,enorm1);\n  \n  /* Normalize enorm1 */\n  \n  (void)s6norm(enorm1,kdim,enorm1,&kstat);\n  \n  /* Make normal of enorm1 and svec */\n  \n  s6crss(svec,enorm1,enorm2);\n  \n  /* Normalize enorm2 */\n  \n  (void)s6norm(enorm2,kdim,enorm2,&kstat);\n  \n  *jstat = 0;\n  goto out;\n\n/* Direction vector of zero length */\n\nerr174: *jstat = -174;\n        s6err(\"s6twonorm\",*jstat,kpos);\ngoto out;\nout:\nreturn;\n}\n"
  },
  {
    "path": "src/s9adsimp.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s9adsimp.c,v 1.2 2001-03-19 15:59:02 afr Exp $\n *\n */\n\n\n#define S9ADSIMP\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\ndouble \ns9adsimp(double epnt1[],double epar1[],double eimpli[],int ideg,double egd1[],\n\t\tdouble epgd1[],double etang[],double eptan[],double astep,int *jstat)\n#else\ndouble s9adsimp(epnt1,epar1,eimpli,ideg,egd1,epgd1,etang,eptan,astep,jstat)\n     double epnt1[];\n     double epar1[];\n     double eimpli[];\n     int    ideg;\n     double egd1[];\n     double epgd1[];\n     double etang[];\n     double eptan[];\n     double astep;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To decide if we should step directly on to a guide point\n*\n* INPUT      : epnt1  - start point, in first surface of iteration step\n*              epar1  - Parameter value of epnt1\n*              eimpli - Description of the implicit surface\n*              ideg   - The degree of the implicit surface\n*                        ideg=1: Plane\n*                        ideg=2; Quadric surface\n*                        ideg=1001: Torus surface\n*                        ideg=1003: Silhouette line parallel projection\n*                        ideg=1004: Silhouette line perspective projection\n*                        ideg=1005: Silhouette line circular projection\n*              egd1   - Guide point in first surface\n*                       For ideg=1,2 and 1001 the sequence is position,\n*                       first derivative in first parameter direction,\n*                       first derivative in second parameter direction,\n*                       (2,0) derivative, (1,1) derivative, (0,2) derivative\n*                       and normal. (21 numbers)\n*                       For ideg=1003,1004,1005 the second derivatives are followed\n*                       by the third derivatives and the normal (33 numbers)\n*                       Compatible with output of s1421\n*              epgd1  - Parameter value of egd1\n*              etang  - Tangent in step direction at epoint\n*              eptan  - Tangent in parameter plane at current point\n*              idim   - Dimension of space the vectors lie in\n*              astep  - Current step length\n*\n*\n* OUTPUT     : s9adsimp - Distance to guide point\n*              jstat  - Status  variable\n*                        = 0  :  Don't step onto the guide point\n*                        = 1  :  Step through the guide point\n*\n* METHOD     : The step is changed if\n*               - The guide point lies in the tangent direction\n*               - The distance between the guide point and start point\n*                 of iteration step is less than or equal to astep\n*\n* USE        : This routine is only working in 3-D\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6diff,s6scpr,s6length,s6crss\n*\n* WRITTEN BY : Tor Dokken, SI, 1988-june-11\n* Revised by : Tor Dokken, SI, 1989-03\n*              Corrected stepping through singular points.\n* Revised by : Mike Floater, SI, 1991-01\n*                   Add perspective and circular silhouettes (ideg=1004,ideg=1005)\n*\n*********************************************************************\n*/\n{\n  int kpos=1;              /* Position indicator for errors           */\n  int kstat;               /* Dummy status variable                   */\n  int kdim=3;              /* This routine is only working in 3-D     */\n  int k2dim=2;             /* Dimension of parameter plane            */\n  int ksize;               /* Number of doubles for storage of derivateves\n\t\t\t      and normal vector */\n  int ksizem3;             /* ksize - 3                               */\n  double tdum;             /* Variable for storage of reals           */\n  double tdist=(double)0.0;/* Distance between guide point and point  */\n  double sdiff[3];         /* Vector for difference between two points*/\n  double scr1[3],scr2[3];  /* Normal vectors                          */\n  double snorm[3];         /* Normal vector                           */\n  \n  \n  /* If ideg=1,2 or 1001 then only derivatives up to second order\n     are calculated, then 18 doubles for derivatives and 3 for the\n     normal vector are to be used for calculation of points in the\n     spline surface. For ideg=1003,1004,1005 we have a silhouette curve and\n     derivatives up to the third are to be calculated,\n     thus 30 +3 a total of 33 doubles are to be calculated */\n  \n  if (ideg==1003 || ideg==1004 || ideg==1005)\n    {\n      ksize = 33;\n    }\n  else\n    {\n      ksize = 21;\n    }\n  ksizem3 = ksize -3;\n  \n  /* First see that we are not turning direction in the parameter plane */\n  \n  s6diff(epgd1,epar1,k2dim,sdiff);\n  if (s6scpr(sdiff,eptan,k2dim) < DZERO) goto dontstepthrough;\n  \n  s6diff(egd1,epnt1,kdim,sdiff);\n  tdum  = s6scpr(sdiff,etang,kdim);\n  tdist = s6length(sdiff,kdim,&kstat);\n  \n  /* Step onto point if it is within 2.0*aepsge */\n  \n  if (tdum > DZERO)\n    {\n      if (DZERO < tdist && tdist <= (double)2.0*astep)\n        {\n\t  /* Guide point lies within step length and in step direction, test\n\t     if cross products of normal vectors at current point and guide point\n\t     point in the same direction, this is not possible to test on for\n\t   silhouette curves */\n\t  \n\t  if (ideg < 1003)\n            {\n\t      \n\t      /* Make normal to implicit surface at epnt1 */\n\t      s1308(epnt1,3,eimpli,ideg,snorm,&kstat);\n\t      if (kstat<0) goto error;\n\t      \n\t      /* Make cross product of normals in start point */\n\t      s6crss(epnt1+ksizem3,snorm,scr1);\n\t      \n\t      \n\t      /* Make normal to implicit surface at epnt1 */\n\t      s1308(epnt1,3,eimpli,ideg,snorm,&kstat);\n\t      if (kstat<0) goto error;\n\t      \n\t      /* Make cross product of normals in guide point */\n\t      s6crss(egd1+ksizem3,snorm,scr2);\n\t      \n\t      \n\t      /* Make scalar product of these two vectors     */\n\t      tdum = s6scpr(scr1,scr2,kdim);\n\t      if (kstat<0) goto error;\n\t      \n\t      /* If positive scalar product the curve at the two points point in\n\t\t the same direction, step through point */\n\t      if (tdum > DZERO) goto stepthrough;\n\t      else if (tdum == DZERO)\n                {\n\t\t  \n\t\t  double tl1,tl2;\n\t\t  \n\t\t  /* Vectors orthogonal or at least one has length zero */\n\t\t  \n\t\t  tl1 = s6length(scr1,kdim,&kstat);\n\t\t  tl2 = s6length(scr2,kdim,&kstat);\n\t\t  \n\t\t  if (tl1 != DZERO && tl2 != DZERO)\n\t\t    goto dontstepthrough;\n\t\t  else if (tl1 == DZERO && tl2 == DZERO)\n\t\t    goto stepthrough;\n\t\t  else if (tl2 == DZERO)\n\t\t    goto stepthrough;\n\t\t  else if (tl2 != DZERO)\n\t\t    {\n\t\t      /* Test if scr2 points in the direction from start */\n\t\t      \n\t\t      tl1 = s6scpr(sdiff,scr2,kdim);\n\t\t      \n\t\t      if (tl1 < DZERO)\n\t\t\tgoto dontstepthrough;\n\t\t      else \n\t\t\tgoto stepthrough;\n\t\t    }\n                }\n            }\n\t  else\n            goto stepthrough;\n        }\n    }\n  \n dontstepthrough:\n  \n  *jstat = 0;\n  goto out;\n  \n stepthrough:\n  *jstat = 1;\n  goto out;\n  \n  /* Error in lower leve function */\n error:\n  *jstat = kstat;\n  s6err(\"s9adsimp\",*jstat,kpos);\n  goto out;\n  \n out:\n  return(tdist);\n}\n"
  },
  {
    "path": "src/s9adstep.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s9adstep.c,v 1.3 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n#define S9ADSTEP\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\ndouble \ns9adstep(double epnt1[],double epar1[],double epnt2[],double epar2[],\n\t\tdouble egd1[],double epgd1[],double egd2[],double epgd2[],\n\t\tdouble etang[],double eptan1[],double eptan2[],double astep,int *jstat)\n#else\ndouble s9adstep(epnt1,epar1,epnt2,epar2,egd1,epgd1,egd2,epgd2,etang,\n                eptan1,eptan2,astep,jstat)\n     double epnt1[];\n     double epar1[];\n     double epnt2[];\n     double epar2[];\n     double egd1[];\n     double epgd1[];\n     double egd2[];\n     double epgd2[];\n     double etang[];\n     double eptan1[];\n     double eptan2[];\n     double astep;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To decide if we should step directly on to a guide point\n*\n* INPUT      : epnt1  - start point, in first surface of iteration step\n*              epar1  - parameter pair of epnt1\n*              epnt2  - start point, in second surface of iteration step\n*              epar2  - parameter pair of epnt2\n*              egd1   - Guide point in first surface\n*              epgd1  - parameter pair of egd1\n*              egd2   - Guide point in second surface.\n*                       For all these points we have stored the following\n*                       values: Position, (1,0)-der, (0,1)-der, normal,\n*                       (2,0)-der, (1,1)-der and (0,2)-der. Thus the\n*                       normal is stored in (edg2+18).\n*              epgd2  - parameter pair of egd2\n*              etang  - Tangent in step direction at epnt1 and epnt2\n*              eptan1 - Tangent direction in parameter pair at epnt1\n*              eptan2 - Tangent direction in parameter pair at epnt2\n*              idim   - Dimension of space the vectors lie in\n*              astep  - Current step length\n*\n*\n* OUTPUT     : s9adstep - Distance to guide point\n*              jstat  - Status  variable\n*                        = 0  :  Don't step onto the guide point\n*                        = 1  :  Step through the guide point\n*\n* METHOD     : The step is changed if\n*               - The guide point lies in the tangent direction\n*               - The distance between the guide point and start point\n*                 of iteration step is less than or equal to astep\n*\n* USE        : This routine is only working in 3-D\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6diff,s6scpr,s6length,s6crss\n*\n* WRITTEN BY : Tor Dokken, SI, 1988-june-11\n* Revised by : Tor Dokken, SI, 1989-april-04\n*              Correction of stepping onto singular points\n*\n*********************************************************************\n*/\n{\n  int kstat;               /* Dummy status variable                   */\n  int kdim=3;              /* This routine is only working in 3-D     */\n  int k2dim=2;             /* Dimension of parameter plane            */\n  double tdum;             /* Variable for storage of reals           */\n  double tdist=DZERO;      /* Distance between guide point and point  */\n  double sdiff[3];         /* Vector for difference between two points*/\n  double scr1[3],scr2[3];  /* Normal vectors                          */\n  \n  \n  \n  /* First see that we are not turning direction in the parameter plane 1\n   */\n  \n  s6diff(epgd1,epar1,k2dim,sdiff);\n  if (s6scpr(sdiff,eptan1,k2dim) <= DZERO) goto dontstepthrough;\n  \n  /* Then see that we are not turning direction in the parameter plane 2\n   */\n  \n  s6diff(epgd2,epar2,k2dim,sdiff);\n  if (s6scpr(sdiff,eptan2,k2dim) <= DZERO) goto dontstepthrough;\n  \n  \n  s6diff(egd1,epnt1,kdim,sdiff);\n  tdum  = s6scpr(sdiff,etang,kdim);\n  tdist = s6length(sdiff,kdim,&kstat);\n  *jstat = 0;\n  if (tdum > DZERO)\n    {\n      \n      /* Step onto point if it is within 2.0*astep */\n      \n      if (DZERO < tdist && tdist <= (double)2.0*astep)\n        {\n\t  /* Guide point lies within step length and in step direction, test\n\t     if cross products of normal vectors at current point and guide point\n\t     point in the same direction */\n\t  \n\t  /* Make cross product of normals in start point */\n\t  s6crss(epnt1+18,epnt2+18,scr1);\n\t  \n\t  /* Make cross product of normals in guide point */\n\t  s6crss(egd1+18,egd2+18,scr2);\n\t  \n\t  /* Make scalar product of these two vectors     */\n\t  tdum = s6scpr(scr1,scr2,kdim);\n\t  \n\t  /* If positive scalar product the curve at the two points point in\n\t     the same direction, step through point */\n\t  if (tdum > DZERO) goto stepthrough;\n\t  else if (tdum == DZERO)\n            {\n\t      \n\t      double tl1,tl2;\n\t      \n\t      /* Vectors orthogonal or at least one has length zero */\n\t      \n\t      tl1 = s6length(scr1,kdim,&kstat);\n\t      tl2 = s6length(scr2,kdim,&kstat);\n\t      \n\t      if (tl1 != DZERO && tl2 != DZERO)\n\t\tgoto dontstepthrough;\n\t      else if (tl1 == DZERO && tl2 == DZERO)\n\t\tgoto stepthrough;\n\t      else if (tl2 == DZERO)\n\t\tgoto stepthrough;\n\t      else if (tl2 != DZERO)\n\t\t{\n\t\t  /* Test if scr2 points in the direction from start */\n\t\t  \n\t\t  tl1 = s6scpr(sdiff,scr2,kdim);\n\t\t  \n\t\t  if (tl1 < DZERO)\n\t\t    goto dontstepthrough;\n\t\t  else \n\t\t    goto stepthrough;\n\t\t}\n            }\n        }\n    }\n  \n dontstepthrough:\n  \n  *jstat = 0;\n  goto out;\n  \n stepthrough:\n  *jstat = 1;\n  goto out;\n  \n out:\n  return(tdist);\n}\n\n\n"
  },
  {
    "path": "src/s9boundimp.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s9boundimp.c,v 1.3 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n#define S9BOUNDIMP\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns9boundimp(double epnt1[],double epar1[],SISLSurf *psurf1,double eimpli[],\n\t\tint ideg,double apar,int idir,double aepsge,\n\t\tdouble gpnt1[],double gpar1[],int *jstat)\n#else\nvoid s9boundimp(epnt1,epar1,psurf1,eimpli,ideg,apar,idir,aepsge,\n               gpnt1,gpar1,jstat)\n     double epnt1[];\n     double epar1[];\n     SISLSurf   *psurf1;\n     double eimpli[];\n     int    ideg;\n     double apar;\n     int    idir;\n     double aepsge;\n     double gpnt1[];\n     double gpar1[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To iterate to an intersection point between a B-spline\n*              surfaces, an implicit surface and a constant parameter line.\n*\n*\n* INPUT      : epnt1  - 0-2 Derivatives + normal of start point for\n*                       iteration in B-spline surface\n*              epar1  - Parameter pair of start point in B-spline surface\n*              psurf1 - Description of B-spline surface              \n*              eimpli - Description of implicit surface\n*              ideg   - Degree of implicit surface\n*                        ideg=1: Plane\n*                        ideg=2; Quadric surface\n*                        ideg=1001: Torus surface\n*                        ideg=1003: Silhouette line parallel projection\n*                        ideg=1004: Silhouette line perspective projection\n*                        ideg=1005: Silhouette line circular projection\n*              apar   - The constant parameter value\n*              idir   - The parameter direction of the constant parameter\n*                       values:\n*                         idir = 1: The line has constant parameter value\n*                                   in first direction\n*                         idir = 2: The line has constant parameter value\n*                                   in second direction\n*              aepsge - Absolute tolerance\n*\n*\n* OUTPUT     : gpnt1  - 0-2 Derivatives + normal of result of iteration\n*                       in B-spline surface\n*              gpar1  - Parameter pair of result of iteration in B-spline\n*                       surface\n*              jstat  - status messages  \n*                       = 2      : Iteration diverged or to many iterations\n*                       = 1      : iteration converged, singular point found\n*                       = 0      : ok, iteration converged\n*                       < 0      : error\n*\n*\n* METHOD     : We want to find the intersection point between the three\n*              surfaces.\n*\n*              Ideg=1:\n*                P(s,t)\n*                AX = 0     The implicit represented plane given by econic\n*                s  = apar  If idir = 1\n*                t  = apar  If idir = 2\n*\n*\n*              Ideg=2:\n*                P(s,t)\n*                XAX = 0 The implicit second degree surface\n*                s  = apar  If idir = 1\n*                t  = apar  If idir = 2\n*\n*              By making a Newton iteration on the functions we get when\n*              P(s,t) is put into the implicit equations we can iterate to\n*              an intersection point.\n*\n* USE        : The function is only working in 3-D\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 4-July-1988\n* Revised by : Tor Dokken, SI, Oslo, Norway, 24-feb-1989\n*              Detects now degenerate points\n* Revised by : Tor Dokken, SI, Oslo; Norway, march 1989\n*              Corrected sequence of statements\n* Revised by : Mike Floater, SI, 1991-01\n*                   Add perspective and circular silhouettes (ideg=1004,ideg=1005)\n*\n*********************************************************************\n*/\n{\n  int kcont;              /* Indicator telling if iteration is not finished */\n  int kder = 2;           /* Derivative indicator                           */\n  int klfu=0;             /* Pointer into knot vector                       */\n  int klfv=0;             /* Pointer into knot vector                       */\n  int kstat;              /* Status variable                                */\n  int knbit=0;            /* Counter for number of iterations               */\n  int kmaxit = 100;       /* Maximal number of iterations allowed           */\n  int kpos=0;             /* Position indicator ofr errors                  */\n  int ksize;              /* Number of doubles for storage of derivateves\n\t\t\t     and normal vector */\n  int ksizem3;            /* ksize - 3                                      */\n  double *sp,*spu,*spv,*spn; /* Pointers into gpnt1                         */\n  double ta11,ta12,tb1;   /* Variables used in equation systems             */\n  double tdu,tdv;         /* Increments of u and v parameter directions     */\n  double tdist;           /* Distance between two points in iteration        */\n  double tcurdst;         /* Distance between points in both surfaces       */\n  double sder[3];         /* Derivatives of comb. of impl. surf and par.surf*/\n  double sproj[3];        /* Projection direction                           */\n  \n  \n  /* If ideg=1,2 or 1001 then only derivatives up to second order\n     are calculated, then 18 doubles for derivatives and 3 for the\n     normal vector are to be used for calculation of points in the\n     spline surface. For ideg=1003,1004,1005 we have a silhouette curve and\n     derivatives up to the third are to be calculated,\n     thus 30 +3 a total of 33 doubles are to be calculated */\n  \n  if (ideg==1003 || ideg==1004 || ideg==1005)\n    {\n      kder = 3;\n      ksize = 33;\n    }\n  else\n    {\n      ksize = 21;\n      kder =2;\n    }\n  ksizem3 = ksize -3;\n  \n  /* Copy input variables to output variables */\n  \n  memcopy(gpnt1,epnt1,21,DOUBLE); \n  memcopy(gpar1,epar1,2,DOUBLE); \n  \n  /* At the start of the iteration the point gpnt1 is put into both implicit\n     equations */\n  \n  /* Set a number of local pointers that are used often */\n  sp  = gpnt1;\n  spu = gpnt1 + 3;\n  spv = gpnt1 + 6; \n  spn = gpnt1 + 18;\n  \n  kcont = 1;\n  \n  while (kcont)\n    \n    {\n      /*  Independent of which parameter direction is constant we want to\n       *   make an equation:\n       *           du*ta11 + dv*ta12 = tb1\n       *   describing the connection between du and dv. Afterwards du or dv can\n       *   be fixed and dv or du calculated\n       */\n      \n      /* Calculate value and derivatives of the parametric surface put into\n\t the equation of the implicit surface */\n      \n      s1331(gpnt1,eimpli,ideg,1,sder,sproj,&kstat);\n      \n      ta11 = sder[1];\n      ta12 = sder[2];\n      tb1  = -sder[0];\n      \n      \n      /*  Now we can branch on the constant parameter dircection */\n      \n      if (idir == 1)\n        {\n\t  /* First parameter is constant  */\n\t  \n\t  tdu = apar - gpar1[0];\n\t  if (DNEQUAL(ta12,DZERO) )\n\t    {\n\t      tdv = (tb1-tdu*ta11)/ta12;\n\t    }\n\t  else\n\t    {\n\t      /* spv is normal to normalvector */\n\t      goto war02;\n\t    }\n\t  \n\t  gpar1[0]  = apar;\n\t  gpar1[1] += tdv;\n        }\n      else\n        {\n\t  /* Second parameter direction constant */\n\t  tdv = apar - gpar1[1];\n\t  if (DNEQUAL(ta11,DZERO))\n\t    {\n\t      tdu = (tb1-tdv*ta12)/ta11;\n\t    }\n\t  else\n\t    {\n\t      /* spv is normal to normalvector */\n\t      goto war02;\n\t    }\n\t  gpar1[0] += tdu;\n\t  gpar1[1]  = apar;\n        }\n      \n      \n      /*  Calculate value of new point */\n      \n      s1421(psurf1,kder,gpar1,&klfu,&klfv,gpnt1,gpnt1+18,&kstat); \n      if (kstat<0) goto error;\n      \n      /*  Stop iteration if degenerate point */\n      if (kstat == 2) goto war02;\n      \n      /*  Find distance between point and point on implicit surface along sproj\n       */\n      tcurdst = s1309(gpnt1,sproj,eimpli,ideg,&kstat);\n      if (kstat < 0) goto error;\n      \n      tcurdst = fabs(tcurdst);\n      \n      /*  tcurdst now contains the distance between the point in the parametric\n\t  surface and the projection along sproj of this point onto the implicit\n\t  surface if ideg== 1,2 or 1001. In the case ideg==1003,1004,1005 we have a\n\t  silhouette line and tcurdst contains the angle PI minus the angle \n\t  between the view direction and the normal of the surface */\n      \n      \n      /*  We continue iteration so long as the error tcurdst is not decreasing */\n      \n      knbit = knbit + 1;\n      \n      if (DEQUAL(tcurdst,DZERO))\n        {\n\t  /* Length is zero iteration has converged   */\n\t  kcont = 0;\n\t  goto war00;\n        }\n      \n      if (knbit<=1)\n        {\n\t  /* First iteration intitate distance variable, if the equation\n\t     systems were not singular */\n\t  tdist = tcurdst;\n        }\n      else\n        {\n\t  /*  More than one iteration done, stop if distance or angle is not\n\t      decreasing. */\n\t  if (tcurdst>=tdist)\n            {\n\t      /*  Distance or angle is not decreasing */\n\t      if (  (ideg < 1003 && tdist <= aepsge) ||\n                    (  (ideg==1003 || ideg==1004 || ideg==1005) &&\n                       tdist <= ANGULAR_TOLERANCE))\n                {               \n\t\t  /*  Distance within tolerance */\n\t\t  goto war00; \n\t\t  \n                }\n\t      else\n                {\n\t\t  /* Distance is not within tolerance, divergence */\n\t\t  goto war02;\n                }\n            }\n\t  /* Distance still decreasing */\n\t  \n\t  tdist = tcurdst;\n        }\n      \n      /*  Make sure that not to many iteration are being done */\n      if (knbit > kmaxit) goto war02;\n    }\n  \n  \n  /* Iteration converged */\n war00:\n  \n  *jstat = 0;\n  goto out;\n  \n  /* To many iterations or iteration diverging */\n war02: *jstat = 2;\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"s9boundimp\",*jstat,kpos);\n  goto out;\n  \n out:\n  return;\n}\n"
  },
  {
    "path": "src/s9boundit.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s9boundit.c,v 1.2 2001-03-19 15:59:02 afr Exp $\n *\n */\n\n\n#define S9BOUNDIT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns9boundit(double epnt1[],double epnt2[],double epar1[],double epar2[],\n\t       SISLSurf *psurf1,SISLSurf *psurf2,double apar,int idir,double aepsge,\n\t       double gpnt1[],double gpnt2[],double gpar1[],double gpar2[],int *jstat)\n#else\nvoid s9boundit(epnt1,epnt2,epar1,epar2,psurf1,psurf2,apar,idir,aepsge,\n               gpnt1,gpnt2,gpar1,gpar2,jstat)\n     double epnt1[];\n     double epnt2[];\n     double epar1[];\n     double epar2[];\n     SISLSurf   *psurf1;\n     SISLSurf   *psurf2;\n     double apar;\n     int    idir;\n     double aepsge;\n     double gpnt1[];\n     double gpnt2[];\n     double gpar1[];\n     double gpar2[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To iterate to an intersection point between two surfaces\n*              and a constant parameter line.\n*\n*\n*\n* INPUT      : epnt1  - 0-2 Derivatives + normal of start point for\n*                       iteration in first surface\n*              epnt2  - 0-2 Derivatives + normal of start point for\n*                       iteration in second surface\n*              epar1  - Parameter pair of start point in first surface\n*              epar2  - Parameter pair of start point in second surface\n*              psurf1 - Description of first surface\n*              psurf2 - Description of second surface\n*              apar   - Parameter value\n*              idir   - Parameter direction\n*                         idir = 1: The line has constant parameter value\n*                                   in first direction of first surface\n*                         idir = 2: The line has constant parameter value\n*                                   in second direction of first surface\n*                         idir = 3: The line has constant parameter value\n*                                   in first direction of second surface\n*                         idir = 4: The line has constant parameter value\n*                                   in second direction of second surface\n*              aepsge - Absolute tolerance\n*\n*\n* OUTPUT     : gpnt1  - 0-2 Derivatives + normal of result of iteration\n*                       in first surface\n*              gpnt2  - 0-2 Derivatives + normal of result of iteration\n*                       in second surface\n*              gpar1  - Parameter pair of result of iteration in first surface\n*              gpar2  - Parameter pair of result of iteration in second\n*                       surface\n*              jstat  - status messages  \n*                       = 2      : Iteration diverged or to many iterations\n*                       = 1      : iteration converged, singular point found\n*                       = 0      : ok, iteration converged\n*                       < 0      : error\n*\n*\n* METHOD     :\n*\n* USE        : The function is only working i 3-D\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, oct-1988\n* Revised by : Tor Dokken, Si, Oslo, Norway, 24-feb-1989\n*              Finds degenerate points\n* Revised by : Tor Dokken, SI, Oslo, Norway, 1989-April-04\n*              Correction of wrong normal vector usage\n*\n*********************************************************************       \n*/\n{\n  int kcont;              /* Indicator telling if iteration is not finished */\n  int kder = 2;           /* Derivative indicator                           */\n  int klfu=0;             /* Pointer into knot vector                       */\n  int klfv=0;             /* Pointer into knot vector                       */\n  int klfs=0;             /* Pointer into knot vector                       */\n  int klft=0;             /* Pointer into knot vector                       */\n  int kstat;              /* Status variable                                */\n  int knbit=0;            /* Counter for number of iterations               */\n  int kdim = 3;           /* Set dimension to 3                             */\n  int kmaxit = 100;       /* Maximal number of iterations allowed           */\n  int kpos=1;             /* Position indicator ofr errors                  */\n  double snorm1[3];       /* Normalvector to constant parameter line        */\n  double snorm2[3];       /* Normalvector to constant parameter line        */\n  double *sp,*spu,*spv,*spn; /* Pointers into gpnt1                         */\n  double *sq,*sqs,*sqt,*sqn; /* Pointers into gpnt2                         */\n  double ta11,ta12,ta21;  /* Variables used in equation systems             */\n  double ta22,tb1,tb2;    /* Variables used in equation systems             */\n  double sdiff[3];        /* Difference between two vectors                 */\n  double tdum2;           /* Dummy variables                                */\n  double tdum3;           /* Dummy variables                                */\n  double tdist;           /* Distance betweentwo points in iteration        */\n  double tdu,tdv,tds,tdt; /* Increments of parameter values                 */\n  \n  \n  /* Copy input variables to output variables */\n  \n  memcopy(gpnt1,epnt1,21,DOUBLE); \n  memcopy(gpnt2,epnt2,21,DOUBLE);\n  memcopy(gpar1,epar1,2,DOUBLE); \n  memcopy(gpar2,epar2,2,DOUBLE);\n  \n  /* At the start of the iteration the two point gpnt1 and gpnt2 might be\n     very close since we in most cases start from a point on the intersection\n     curve. */\n  \n  /* Set a number of local pointers that are used often */\n  sp  = gpnt1;\n  spu = gpnt1 + 3;\n  spv = gpnt1 + 6;\n  spn = gpnt1 + 18;\n  sq  = gpnt2;\n  sqs = gpnt2 + 3;\n  sqt = gpnt2 + 6;\n  sqn = gpnt2 + 18;\n  \n  kcont = 1;\n  \n  while (kcont)\n    \n    {\n      if (idir==1 || idir==2)\n        {\n\t  /* The constant parameter direction is in the first surface, intersect\n\t     with implicit representation of tangent plane of second surface.\n\t     Independent of which parameter direction is constant we want to\n\t     make an equation:\n\t     du*ta11 + dv*ta12 = tb1\n\t     describing the connection between du and dv. Afterwards du or dv can\n\t     be fixed and dv or du calculated\n\t   \n\t     Put a parametric representation of the tangent plane of surface 1 into\n\t     the implicit representation of the tangent plane of surface 2.\n\t   */ \n\t  \n\t  ta11 = s6scpr(spu,sqn,kdim);\n\t  ta12 = s6scpr(spv,sqn,kdim);\n\t  s6diff(sq,sp,kdim,sdiff);\n\t  \n\t  tb1  = s6scpr(sdiff,sqn,kdim);\n\t  \n\t  /* Now we can branch on the constant parameter direction */\n\t  \n\t  if (idir == 1)\n            {\n\t      /* First parameter is constant  */\n\t      \n\t      tdu = apar - gpar1[0];\n\t      if (DNEQUAL(ta12,DZERO))\n\t\t{\n\t\t  tdv = (tb1-tdu*ta11)/ta12;\n\t\t}\n\t      else\n\t\t{\n\t\t  /* spv is normal to normalvector */\n\t\t  goto war02;\n\t\t}\n\t      \n\t      gpar1[0]  = apar;\n\t      gpar1[1] += tdv;\n            }\n\t  else\n            {\n\t      /* Second parameter direction constant */\n\t      tdv = apar - gpar1[1];\n\t      if (DNEQUAL(ta11,DZERO))\n\t\t{\n\t\t  tdu = (tb1-tdv*ta12)/ta11;\n\t\t}\n\t      else\n\t\t{\n\t\t  /* spv is normal to normalvector */\n\t\t  goto war02;\n\t\t}\n\t      gpar1[0] += tdu;\n\t      gpar1[1]  = apar;\n            }\n\t  \n\t  /* Calculate the point found in first surface */\n\t  \n\t  s1421(psurf1,kder,gpar1,&klfu,&klfv,gpnt1,gpnt1+18,&kstat); \n\t  if (kstat<0) goto error;\n\t  \n\t  /* If the surface has normal of zero length leave the routine */\n\t  \n\t  if (kstat == 2) goto war02;\n\t  \n\t  /* Make the difference of the found point and sq */\n\t  \n\t  s6diff(gpnt1,sq,kdim,sdiff);\n\t  \n\t  \n\t  /* Project the point onto surface 2 along the normal sqn */\n\t  \n\t  \n\t  /* Make two normals to the normal of surface two in last point */\n\t  \n\t  s6twonorm(sqn,snorm1,snorm2,&kstat);\n\t  if (kstat<0) goto error;\n\t  \n\t  ta11 = s6scpr(sqs,snorm1,kdim);\n\t  ta12 = s6scpr(sqt,snorm1,kdim);\n\t  ta21 = s6scpr(sqs,snorm2,kdim);\n\t  ta22 = s6scpr(sqt,snorm2,kdim);\n\t  \n\t  tb1  = s6scpr(sdiff,snorm1,kdim);\n\t  \n\t  tb2  = s6scpr(sdiff,snorm2,kdim);\n\t  \n\t  /*      Calculate determinant of equation system */\n\t  tdum2 = ta11*ta22 - ta12*ta21;\n\t  \n\t  /* If tdum2 = 0.0, then the equation system is singular, iteration not\n\t     possible. */\n\t  if (DNEQUAL(tdum2,DZERO))\n            {\n\t      gpar2[0] += (tb1*ta22-tb2*ta12)/tdum2;\n\t      gpar2[1] += (ta11*tb2-ta21*tb1)/tdum2;\n            }\n\t  \n\t  /* Calculate point in second surface */\n\t  \n\t  s1421(psurf2,kder,gpar2,&klfs,&klft,gpnt2,gpnt2+18,&kstat); \n\t  if (kstat<0) goto error;\n\t  \n\t  /* If the surface has normal of zero length leave the routine */\n\t  \n\t  if (kstat == 2) goto war02;\n        }\n      \n      else\n        {\n\t  /* idir==3 or idir==4 */\n\t  \n\t  /*  The constant parameter direction is in the second surface, intersect\n\t      with implicit representation of tangent plane of second surface.\n\t      Independent of which parameter direction is constant we want to\n\t      make an equation:\n\t      ds*ta11 + dt*ta12 = tb1\n\t      describing the connection between ds and dt. Afterwards ds or dt can\n\t      be fixed and dt or ds calculated\n\t   \n\t      Put a parametric representation of the tangent plane of surface 2 into\n\t      the implicit representation of the tangent plane of surface 1.\n\t   */ \n\t  \n\t  ta11 = s6scpr(sqs,spn,kdim);\n\t  ta12 = s6scpr(sqt,spn,kdim);\n\t  s6diff(sp,sq,kdim,sdiff);\n\t  \n\t  tb1  = s6scpr(sdiff,spn,kdim);\n\t  \n\t  /* Now we can branch on the constant parameter direction */\n\t  \n\t  if (idir == 3)\n            {\n\t      /* First parameter is constant  */\n\t      \n\t      tds = apar - gpar2[0];\n\t      if (DNEQUAL(ta12,DZERO))\n\t\t{\n\t\t  tdt = (tb1-tds*ta11)/ta12;\n\t\t}\n\t      else\n\t\t{\n\t\t  /* sqt is normal to normalvector */\n\t\t  goto war02;\n\t\t}\n\t      \n\t      gpar2[0]  = apar;\n\t      gpar2[1] += tdt;\n            }     \n\t  else\n            {\n\t      /* Second parameter direction constant */\n\t      tdt = apar - gpar2[1];\n\t      if (DNEQUAL(ta11,DZERO))\n\t\t{\n\t\t  tds = (tb1-tdt*ta12)/ta11;\n\t\t}\n\t      else\n\t\t{\n\t\t  /* spv is normal to normalvector */\n\t\t  goto war02;\n\t\t}\n\t      gpar2[0] += tds;\n\t      gpar2[1]  = apar;\n\t      \n            }\n\t  \n\t  /* Calculate the point found in first surface */\n\t  \n\t  s1421(psurf2,kder,gpar2,&klfs,&klft,gpnt2,gpnt2+18,&kstat); \n\t  if (kstat<0) goto error;\n\t  \n\t  /* If the surface has normal of zero length leave the routine */\n\t  \n\t  if (kstat == 2) goto war02;\n\t  \n\t  /* Make the difference of the found point and sq */\n\t  \n\t  s6diff(gpnt2,sp,kdim,sdiff);\n\t  \n\t  \n\t  /* Project the point onto surface 2 along the normal spn */\n\t  \n\t  \n\t  /* Make two normals to the normal of surface one in last point */\n\t  \n\t  s6twonorm(spn,snorm1,snorm2,&kstat);\n\t  if (kstat<0) goto error;\n\t  \n\t  \n\t  /* Put a parametric representation of the tangent plane of surface 1 into\n\t     the implicit representation of the tangent planes of the constant\n\t     parameter line of surface 2 */\n\t  \n\t  ta11 = s6scpr(spu,snorm1,kdim);\n\t  ta12 = s6scpr(spv,snorm1,kdim);\n\t  ta21 = s6scpr(spu,snorm2,kdim);\n\t  ta22 = s6scpr(spv,snorm2,kdim);\n\t  \n\t  tb1  = s6scpr(sdiff,snorm1,kdim);\n\t  \n\t  tb2  = s6scpr(sdiff,snorm2,kdim);\n\t  \n\t  /* Calculate determinant of equation system */\n\n\t  tdum2 = ta11*ta22 - ta12*ta21;\n\t  \n\t  /* If tdum2 = 0.0, then the equation system is singular, iteration not\n\t     possible. */\n\n\t  if (DNEQUAL(tdum2,DZERO))\n            {\n\t      gpar1[0] += (tb1*ta22-tb2*ta12)/tdum2;\n\t      gpar1[1] += (ta11*tb2-ta21*tb1)/tdum2;\n            }\n\t  \n\t  /* Calculate point in first surface */\n\t  \n\t  s1421(psurf1,kder,gpar1,&klfu,&klfv,gpnt1,gpnt1+18,&kstat); \n\t  if (kstat<0) goto error;\n\t  \n\t  /* If the surface has normal of zero length leave the routine */\n\t  \n\t  if (kstat == 2) goto war02;\n        }\n      \n      \n      /* Make difference between the two points, \n\t and calculate length of difference */\n\n      s6diff(gpnt1,gpnt2,kdim,sdiff);\n      tdum3 = s6length(sdiff,kdim,&kstat);\n      knbit = knbit + 1;\n      \n      if (kstat==0) \n        {\n\t  /* Length is zero iteration has converged   */\n\t  kcont = 0;\n\t  goto war00;\n        }\n      \n      if (knbit<=1)\n        {\n\t  /* First iteration intitate distance variable, if the equation\n\t     systems were not singular */\n\n\t  if (DEQUAL(tdum2,DZERO)) goto war02;\n\t  tdist = tdum3;\n        }\n      else\n        {\n\t  /* More than one iteration done, stop if distance is not decreasing.\n\t     Then decide if we converge distance between the points is within\n\t     the tolerance and the last step had singular or none singular\n\t     equation systems. */\n\n\t  if (tdum3>=tdist)\n            {\n\t      /* Distance is not decreasing */\n\t      if (tdist <= aepsge)\n                {\n\t\t  /* Distance within tolerance */\n\t\t  if (DEQUAL(tdum2,DZERO))\n                    {\n\t\t      /* Singular equation system */\n\t\t      goto war01;\n                    }\n\t\t  else\n                    {\n\t\t      /* Nonsingular equation system */\n\t\t      goto war00;\n                    }\n                }\n\t      else\n                {\n\t\t  /* Distance is not within tolerance, divergence */\n\t\t  goto war02;\n                }\n            }\n\t  /* Distance still decreasing */\n\t  \n\t  tdist = tdum3;\n        }\n      \n      /*  Make sure that not to many iteration are being done */\n      if (knbit > kmaxit) goto war02;\n    }\n  \n  \n  /* Iteration converged */\n\n  war00:\n    *jstat = 0;\n    goto out;\n  \n  /* Iteration converged, singular point found */\n\n  war01: \n    *jstat = 1;\n    goto out;\n  \n  /* To many iterations or iteration diverging */\n\n  war02: \n    *jstat = 2;\n    goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n    s6err(\"s9boundit\",*jstat,kpos);\n    goto out;\n  \n  out:\n    return;\n}\n"
  },
  {
    "path": "src/s9clipimp.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s9clipimp.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S9CLIPIMP\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns9clipimp(double epar1[],double epar2[],SISLSurf *psurf1,double eimpli[],\n\t       int ideg,double euval[],double evval[],double aepsge,\n\t       double gpnt1[],double gpar1[],int *jstat)\n#else\nvoid s9clipimp(epar1,epar2,psurf1,eimpli,ideg,euval,evval,\n               aepsge,gpnt1,gpar1,jstat)\n     double epar1[];\n     double epar2[];\n     SISLSurf   *psurf1;\n     double eimpli[];\n     int    ideg;\n     double euval[];\n     double evval[];\n     double aepsge;\n     double gpnt1[];\n     double gpar1[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To clip the intersection curve between epar1 and epar2\n*              against the parameter boundary of the patch defined\n*              by euval and evval.\n*\n*\n* INPUT      : epar1  - Parameter pair of start point of curve branch\n*              epar2  - Parameter pair of end   point of curve branch\n*              psurf1 - Description of B-spline surface              \n*              eimpli - Description of implicit surface\n*              ideg   - Degree of implicit surface\n*                        ideg=1:    Plane              \n*                        ideg=2;    Quadric surface\n*                        ideg=1001: Torus surface\n*                        ideg=1003: Silhouette line parallel projection\n*                        ideg=1004: Silhouette line perspective projection\n*                        ideg=1005: Silhouette line circular projection\n*              euval  - Parameter interval in first parameter direction\n*              evval  - Parameter interval in second parameter direction\n*              aepsge - Absolute tolerance\n*\n*\n* OUTPUT     : gpnt1  - 0-2 Derivatives + normal of result of iteration\n*                       in B-spline surface\n*              gpar1  - Parameter pair of result of iteration in B-spline\n*                       surface\n*              jstat  - status messages  \n*                       = 2      : Iteration diverged or to many iterations\n*                       = 1      : ok, The line cross the boundary, point\n*                                  found\n*                       = 0      : ok, The line does not cross the boundary\n*                       < 0      : error\n*\n*\n* METHOD     :\n* USE        : The function is only working i 3-D\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 4-July-1988\n* Revised by : Tor Dokken, Si, Oslo, Norway, March 1989\n*              Taken into consideration that when we step we might step\n*              from outside to outside of patch\n* Revised by : Mike Floater, SI, 1991-01\n*                   Add perspective and circular silhouettes (ideg=1004,ideg=1005)\n*\n*********************************************************************\n*/\n{\n  int kpos=0;                   /* Position of error                           */\n  int klfu=0;                   /* Variable used as pointer in knot vector     */\n  int klfv=0;                   /* Variable used as pointer in knot vector     */\n  int kder=2;                   /* Number of derivatives to be calculated      */\n  int kstat;                    /* Local status variable                       */\n  int kdir;                     /* Parameter direction of tpar                 */\n  int kcross;                   /* Control variable in while loop              */\n  int knbit;                    /* Number of iterations                        */\n  int krem;                     /* Remember status                             */\n  int kbound;                   /* Numbering of boundary                       */\n  int ksize;                    /* Number of doubles for storage of derivateves\n\t\t\t\t   and normal vector */\n  int ksizem3;                  /* ksize - 3                                   */\n  double tpar;                  /* Constant parameter value                    */\n  double spnt1[33];             /* Coordinates of point                        */\n  double spar1[2],spar2[2];     /* Local parameter values                      */\n  double spar3[2];              /* Local parameter values                      */\n  \n  \n  \n  /* If ideg=1,2 or 1001 then only derivatives up to second order\n     are calculated, then 18 doubles for derivatives and 3 for the\n     normal vector are to be used for calculation of points in the\n     spline surface. For ideg=1003,1004,1005 we have a silhouette curve and\n     derivatives up to the third are to be calculated,\n     thus 30 +3 a total of 33 doubles are to be calculated */\n  \n  if (ideg==1003 || ideg==1004 || ideg==1005)\n    {\n      kder = 3;\n      ksize = 33;\n    }\n  else\n    {\n      ksize = 21;\n      kder =2;\n    }\n  ksizem3 = ksize -3;\n  \n  \n  /* Make local copy of parameters */\n  \n  memcopy(spar1,epar1,2,DOUBLE);                        \n  memcopy(spar2,epar2,2,DOUBLE);\n  \n  kcross = 1;\n  knbit  = 0;\n  \n  while(kcross && knbit<4)\n    {\n      \n      /*  Find intersection between boundary of parameter area and patch */\n      \n      s1305(spar1,spar2,euval,evval,&kbound,spar3,&kstat);\n      if (kstat<0) goto error;\n      \n      /*  Remember status so that the line can be updated properly */\n      krem = kstat;\n      \n      if (kstat<2 || kbound == 0)\n        {\n\t  /*      No intersection */\n\t  kcross = 0;\n        }\n      else\n        {\n\t  \n\t  /*      Calculate start point */\n\t  \n\t  s1421(psurf1,kder,spar3,&klfu,&klfv,spnt1,spnt1+ksizem3,&kstat); \n\t  if (kstat<0) goto error;\n\t  \n\t  if (kbound==1)\n            {\n\t      kdir = 1;\n\t      tpar = euval[0];\n            }\n\t  else if (kbound==2)\n            {\n\t      kdir = 2;\n\t      tpar = evval[1];\n            }\n\t  else if (kbound==3)\n            {\n\t      kdir = 1;                                   \n\t      tpar = euval[1];\n            }\n\t  else if (kbound==4)\n            {\n\t      kdir = 2;\n\t      tpar = evval[0];\n            }\n\t  \n\t  \n\t  /* Iterate to boundary intersection */\n\t  \n\t  s9boundimp(spnt1,gpar1,psurf1,eimpli,ideg,tpar,kdir,aepsge,\n\t\t     gpnt1,gpar1,&kstat);\n\t  if (kstat<0) goto error;\n\t  if (kstat==2) goto war02;\n\t  \n\t  /* Iteration converged, copy output if new loop necessary */\n\t  \n\t  \n\t  if (krem == 2)\n            {\n\t      /* spar1 was inside, update spar2 */\n\t      memcopy(spar2,gpar1,2,double);\n            }\n\t  else\n            {\n\t      /* spar2 was inside, update spar1 */\n\t      memcopy(spar1,gpar1,2,double);\n            }\n\t  \n\t  /* Update number of iterations */\n\t  \n\t  knbit++;\n        }\n    }\n  \n  \n  \n  /* Problem solved if kcross==0. In this case we might have two cases:\n     - iteration not used: Then knbit=0\n     - iteration used    : Then knbit>0\n     \n     if kcross==1, then we have stopped on the condition knbit>3, and we\n     have no sucess. */\n  \n  if (kcross==0 && knbit ==0)\n    {\n      /*  Iteration not used because boundary not crossed */\n      *jstat = 0;\n    }\n  else if (kcross==0 && knbit > 0)\n    {\n      /*  Boundary crossed, point found, more than one intersection point\n\t  is possible, check which to return */\n      \n      if (spar1[0] == epar1[0] && spar1[1] == epar1[1])\n        {\n\t  memcopy(gpar1,spar2,2,double);\n        }\n      else\n        {\n\t  memcopy(gpar1,spar1,2,double);\n\t  \n\t  /*  Calculate crossing point, only necessary when we step into\n\t      the patch since we already could have stepped out and this\n\t      point is recorded in gpnt1 */\n\t  \n\t  s1421(psurf1,kder,gpar1,&klfu,&klfv,gpnt1,gpnt1+ksizem3,&kstat); \n\t  if (kstat<0) goto error;\n        }\n      \n      *jstat = 1;\n    }\n  else\n    {\n      /*  To many tries */\n      goto war02;\n    }\n  goto out;\n  \n  /* Iteration without sucess */\n  \n war02: *jstat = 2;\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"s9clipimp\",*jstat,kpos);\n  goto out;\n  \n out:\n  return;                                                                        \n  \n}\n\n"
  },
  {
    "path": "src/s9clipit.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s9clipit.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S9CLIPIT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns9clipit(double epar11[],double epar12[],double epar21[],double epar22[],\n\t      SISLSurf *psurf1,SISLSurf *psurf2,double euval[],double evval[],double esval[],\n\t      double etval[],double aepsge,double gpnt1[],double gpnt2[],\n\t      double gpar1[],double gpar2[],int *jstat)\n#else\nvoid s9clipit(epar11,epar12,epar21,epar22,psurf1,psurf2,\n              euval,evval,esval,etval,\n              aepsge,gpnt1,gpnt2,gpar1,gpar2,jstat)\n     double epar11[];\n     double epar12[];\n     double epar21[];\n     double epar22[];\n     SISLSurf   *psurf1;\n     SISLSurf   *psurf2;\n     double euval[];\n     double evval[];\n     double esval[];\n     double etval[];\n     double aepsge;\n     double gpnt1[];\n     double gpnt2[];\n     double gpar1[];\n     double gpar2[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To clip the intersection curve between epar1 and epar2\n*              against the parameter boundary of the patch 1 defined\n*              by euval and evval, and the parameter boundary of the\n*              patch 2 defined by esval and etval.\n*\n*\n* INPUT      : epar11  - Parameter pair of start point in first surface\n*              epar12  - Parameter pair of start point in second surface\n*              epar21  - Parameter pair of end point in first surface\n*              epar22  - Parameter pair of end point in second surface\n*              psurf1 - Description of B-spline surface 1\n*              psurf2 - Description of B-spline surface 2            \n*              euval  - Parameter interval in first parameter direction\n*              evval  - Parameter interval in second parameter direction\n*              esval  - Parameter interval in third parameter direction\n*              etval  - Parameter interval in fourth parameter direction\n*              aepsge - Absolute tolerance\n*\n*\n* OUTPUT     : gpnt1  - 0-2 Derivatives + normal of result of iteration\n*                       in B-spline surface 1\n*              gpnt2  - 0-2 Derivatives + normal of result of iteration\n*                       in B-spline surface 2\n*              gpar1  - Parameter pair of result of iteration in B-spline\n*                       surface 1\n*              gpar2  - Parameter pair of result of iteration in B-spline\n*                       surface 2\n*              jstat  - status messages  \n*                       = 2      : Iteration diverged or to many iterations\n*                       = 1      : ok, The line cross the boundary, point\n*                                  found\n*                       = 0      : ok, The line does not cross the boundary\n*                       < 0      : error\n*\n*\n* METHOD     :\n* USE        : The function is only working i 3-D\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 4-July-1988\n* Revised by : Tor Dokken, SI, Oslo, Norway, 4-APril-1989\n*              Correction of steps over two boundaries\n*\n*********************************************************************\n*/\n{\n  int kpos=0;                   /* Position of error                       */\n  int klfu=0;                   /* Variable used as pointer in knot vector */\n  int klfv=0;                   /* Variable used as pointer in knot vector */\n  int klfs=0;                   /* Variable used as pointer in knot vector */\n  int klft=0;                   /* Variable used as pointer in knot vector */\n  int kder=2;                   /* Number of derivatives to be calculated  */\n  int kstat;                    /* Local status variable                   */\n  int kdir;                     /* Parameter direction of tpar             */\n  int kcross;                   /* Control variable in while loop          */\n  int knbit;                    /* Number of iterations                    */\n  int krem;                     /* Remember status                         */\n  int kbound;                   /* Numbering of boundary                   */\n  double tpar;                  /* Constant parameter value                */\n  double spnt1[21];             /* Coordinates of point                    */\n  double spnt2[21];             /* Coordinates of point                    */\n  double spar11[2],spar12[2];   /* Local parameter values                  */\n  double spar21[2],spar22[2];   /* Local parameter values                  */\n  double spar31[2],spar32[2];   /* Local parameter values                  */\n  \n  /* Make local copy of parameters */\n  \n  memcopy(spar11,epar11,2,DOUBLE);\n  memcopy(spar12,epar12,2,DOUBLE);\n  memcopy(spar21,epar21,2,DOUBLE);\n  memcopy(spar22,epar22,2,DOUBLE);\n  \n  kcross = 1;\n  knbit  = 0;\n  \n  while(kcross && knbit<8)\n    {\n      \n      /* Find intersection between boundary of parameter area and patch */\n      \n      s1330(spar11,spar12,spar21,spar22,euval,evval,esval,etval,\n\t    &kbound,spar31,spar32,&kstat);\n      if (kstat<0) goto error;\n      \n      /* Remember status so that the line can be updated properly */\n\n      krem = kstat;\n      \n      if (kstat<2 || kbound == 0)\n        {\n\t  /* No intersection */\n\n\t  kcross = 0;\n        }\n      else\n        {\n\t  \n\t  /* Calculate start point for iteration */\n\t  \n\t  s1421(psurf1,kder,spar31,&klfu,&klfv,spnt1,spnt1+18,&kstat); \n\t  if (kstat<0) goto error;\n\t  \n\t  s1421(psurf2,kder,spar32,&klfs,&klft,spnt2,spnt2+18,&kstat); \n\t  if (kstat<0) goto error;\n\t  \n\t  if (kbound==1)\n            {\n\t      kdir = 1;\n\t      tpar = euval[0];\n            }\n\t  else if (kbound==2)\n            {\n\t      kdir = 2;\n\t      tpar = evval[1];\n            }\n\t  else if (kbound==3)\n            {\n\t      kdir = 1;                                   \n\t      tpar = euval[1];\n            }\n\t  else if (kbound==4)\n            {\n\t      kdir = 2;\n\t      tpar = evval[0];\n            }\n\t  else if (kbound==5)\n            {\n\t      kdir = 3;\n\t      tpar = esval[0];\n            }\n\t  else if (kbound==6)\n            {\n\t      kdir = 4;\n\t      tpar = etval[1];\n            }\n\t  else if (kbound==7)\n            {\n\t      kdir = 3;                                   \n\t      tpar = esval[1];\n            }\n\t  else if (kbound==8)\n            {\n\t      kdir = 4;\n\t      tpar = etval[0];\n            }\n\t  \n\t  \n\t  /* Iterate to boundary intersection */\n\t  \n\t  s9boundit(spnt1,spnt2,spar31,spar32,psurf1,psurf2,tpar,kdir,aepsge,\n\t\t    gpnt1,gpnt2,gpar1,gpar2,&kstat);\n\t  if (kstat<0) goto error;\n\t  if (kstat==2) goto war02;\n\t  \n\t  /* Iteration converged, copy output if new loop necessary */\n\t  \n\t  if (krem == 2)\n            {\n\t      /* spar1 was inside, update spar2 */\n\n\t      memcopy(spar21,gpar1,2,double);\n\t      memcopy(spar22,gpar2,2,double);\n            }\n\t  else\n            {\n\t      /* spar2 was inside, update spar1 */\n\n\t      memcopy(spar11,gpar1,2,double);\n\t      memcopy(spar12,gpar2,2,double);\n            }\n\t  \n\t  /* Update number of iterations */\n\t  \n\t  knbit++;\n        }\n    }\n  \n  \n  \n  /* Problem solved if kcross==0. In this case we might have two cases:\n     - iteration not used: Then knbit=0\n     - iteration used    : Then knbit>0\n     \n     if kcross==1, then we have stopped on the condition knbit>7, and we\n     have no success. */\n  \n  if (kcross==0 && knbit ==0)\n    {\n      /* Iteration not used because boundary not crossed */\n\n      *jstat = 0;\n    }\n  else if (kcross==0 && knbit > 0)\n    {\n      /* Boundary crossed, point found, more than one intersection point\n\t is possible, check which to return */\n      \n      if (spar11[0] == epar11[0] && spar11[1] == epar11[1] &&\n\t  spar12[0] == epar12[0] && spar12[1] == epar12[1] )\n        {\n\t  memcopy(gpar1,spar21,2,double);\n\t  memcopy(gpar2,spar22,2,double);\n        }\n      else\n        {\n\t  memcopy(gpar1,spar11,2,double);\n\t  memcopy(gpar2,spar12,2,double);\n\t  \n\t  /* Calculate crossing point, only necessary when we step into\n\t     the patch since we already could have stepped out and this\n\t     point is recorded in gpnt1 */\n\t  \n\t  s1421(psurf1,kder,gpar1,&klfu,&klfv,gpnt1,gpnt1+18,&kstat); \n\t  if (kstat<0) goto error;\n\t  \n\t  s1421(psurf2,kder,gpar2,&klfu,&klfv,gpnt2,gpnt2+18,&kstat); \n\t  if (kstat<0) goto error;\n        }\n      \n      *jstat = 1;\n    }\n  else\n    {\n      /*  To many tries */\n      goto war02;\n    }\n  goto out;\n  \n  /* Iteration without success */\n  \n  war02: \n    *jstat = 2;\n    goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : \n    *jstat = kstat;\n    s6err(\"s9clipit\",*jstat,kpos);\n    goto out;\n  \n  out:\n    return;\n}\n"
  },
  {
    "path": "src/s9conmarch.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s9conmarch.c,v 1.2 2001-03-19 15:59:02 afr Exp $\n *\n */\n\n\n#define S9CONMARCH\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns9conmarch(SISLSurf *ps,double alevel,double epar[],int ndir[],int ipoint,\n\t\tdouble *gpar[],int *mpar[],int *jpoint,int *jstat)\n#else\nvoid s9conmarch(ps,alevel,epar,ndir,ipoint,gpar,mpar,jpoint,jstat)\n     SISLSurf   *ps;\n     double alevel;\n     double epar[];\n     int    ndir[];\n     int    ipoint;\n     double *gpar[];\n     int    *mpar[];\n     int    *jpoint;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To check which of the points in the epar array can be\n*              connected by marching. If the connection should be\n*              to internal point these points are returned. All points\n*              are assumed to lie on the boundary or close to the boundary\n*              of the patch (DEQUAL says that they lie on the boundary).\n*\n*              When ipoint = 2, we connect always if marching succeeds!!!!!!!\n*              without testing for equality between marching results and\n*              given point no 2.\n*\n* INPUT      : ps        - The surface in intersection.\n*              alevel    - The constant value the surface is intersected with.\n*              epar[2,*] - Parameter values for the  intersection points along\n*                          the boundary.\n*              ndir[*]   - Description of the points in epar.\n*                          -1 : tangent pointing out\n*                           0 : tangent parallel to boundary\n*                           1 : tangent pointing in\n*                           2 : singular point\n*                          The algorithm assumes that first all points\n*                          with status -1 and 1 lies first in epar.\n*              ipoint    - Number of parameter values\n*\n*\n* OUTPUT     : gpar      - Pointer to parameter values produced tor singular \n*                          points. Is allocated inside the function, must\n*                          be released by the calling function.\n*              mpar      - Array describing how the input parameter pairs were\n*                          connected to other in the input vector and to the\n*                          new parameter pairs made in gpar. Is allocated\n*                          inside the function, must be released by the\n*                          calling function.\n*                           -3             - point on closed curve\n*                           -2             - internal point onc other curve\n*                           -1             - Can not march from point\n*                           POSITIVE VALUE - SISLPoint connected to point in epar\n*              jpoint    - Number of new parameter pairs produced\n*              jstat   -  status messages  \n*                                = 2   : Only singular points, not connected\n*                                = 1   : Points connected\n*                                = 0   : Points not connected..\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway. August  1989\n*\n*********************************************************************\n*/\n{\n  int kstat;            /* Status variable                             */\n  int kpos=0;           /* Position of error                           */\n  int *lpar = SISL_NULL;     /* Pointer to output integer array             */\n  int ki,kj;\n  int kn1,kn2,kk1,kk2;  /* Surface attributes.           */\n  double tstart1,tstart2,tend1,tend2; /* Surface attributes.           */\n  int ksucc;            /* Success indicator                           */\n  double tepsge=1.0;    /* Not used                                    */\n  double *spar=SISL_NULL;    /* Pointer to output real array                */\n  double scand1[2];     /* Result of iteration process                 */\n  double scand2[2];     /* Result of iteration process                 */\n  double *sp,*sq;       /* Pointer used in loop                        */\n  double tdum1;         /* Max knot value used in DEQUAL comparing.    */\n  double tdum2;         /* Max knot value used in DEQUAL comparing.    */\n\n  /* Init */\n  kn1 = ps->in1;\n  kn2 = ps->in2;\n  kk1 = ps->ik1;\n  kk2 = ps->ik2;\n\n  tstart1 = ps->et1[kk1-1];\n  tend1   = ps->et1[kn1];\n  tstart2 = ps->et2[kk2-1];\n  tend2   = ps->et2[kn2];\n\n  tdum1 = (double)2.0*max(fabs(tstart1),fabs(tend1));\n  tdum2 = (double)2.0*max(fabs(tstart2),fabs(tend2));\n\n  /* Allocate output arrays */\n  \n  if ((*mpar=newarray(ipoint,INT     )) == SISL_NULL) goto err101;\n  if ((*gpar=newarray(6*ipoint,DOUBLE)) == SISL_NULL) goto err101;\n  \n  lpar = *mpar;\n  spar = *gpar;\n  \n  memcopy(spar,epar,2*ipoint,DOUBLE);\n  *jpoint = ipoint;\n  \n  /* Initiate output integer array to point to no points */\n  \n  for (ki=0 ; ki< ipoint ; ki++) *(lpar+ki) = 0;\n  \n\n  /* Loop for all input points. */      \n  for (ki=0, sp=spar ; ki< ipoint-1 ; ki++, sp+=2)\n    {\n      /* Start marching from point ki */\n\n      /* Exclude points already connected and parallell points. */\n      if (lpar[ki] != 0 || ndir[ki] == 0) \n\tcontinue;\n\t  \n      /* SISLPoint not marched to */\n\t  \n      s1787(ps,alevel,tepsge,sp,scand1,scand2,&kstat);\n      if (kstat<0) goto error;\n      if (kstat==0) goto war00;\n\t  \n      /* Run through remaining points to find if scand2 matches any\n\t of them. If we've got only two points, we connect them.*/\n\t  \n      ksucc = 0;\n\t  \n      for (kj=ki+1,sq=spar+2*ki+2 ; kj<ipoint ; kj++,sq+=2)\n\t{\n\t  /* SISLPoint found */\n\t      \n\t  if (DEQUAL(sq[0]+tdum1,scand2[0]+tdum1) && \n\t      DEQUAL(sq[1]+tdum2,scand2[1]+tdum2))\n\t    {\n\t      /* Accepted end point found */\n\t      \n\t      lpar[ki] = kj+1;\n\t      lpar[kj] = ki+1;\n\t      ksucc = 1;\n\t      break;\n\t    }\n\t}\n      /* If ksucc==0 then one of the searches was not successful */\n\t  \n      if (ksucc==0) goto war00;   \n\n    }\n  \n  goto success;\n\n success: \n  *jstat = 1;\n  goto out;\n\n  /* No success */\n war00: \n  *jstat=0;\n  /* If we got only singular points, set status. */\n  if (ndir[0] == 2) *jstat = 2;\n\n  goto out;\n\n  /* Error in space allocation */\n err101: \n  *jstat = -101;\n  s6err(\"s9conmarch\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level function */\n error:\n  *jstat = kstat;\n  s6err(\"s9conmarch\",*jstat,kpos);\n  goto out;\n\n out:;\n}\n"
  },
  {
    "path": "src/s9iterate.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s9iterate.c,v 1.2 2001-03-19 15:59:02 afr Exp $\n *\n */\n#define S9ITERATE\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns9iterate(double epoint[],double epnt1[],double epnt2[],double epar1[],\n\t       double epar2[],SISLSurf *psurf1,SISLSurf *psurf2,double astep,\n\t       double aepsge,double gpnt1[],double gpnt2[],double gpar1[],\n\t       double gpar2[],int *jstat)\n#else\nvoid s9iterate(epoint,epnt1,epnt2,epar1,epar2,psurf1,psurf2,astep,aepsge,\n               gpnt1,gpnt2,gpar1,gpar2,jstat)\n     double epoint[];\n     double epnt1[];\n     double epnt2[];\n     double epar1[];\n     double epar2[];\n     SISLSurf   *psurf1;\n     SISLSurf   *psurf2;\n     double astep;\n     double aepsge;\n     double gpnt1[];\n     double gpnt2[];\n     double gpar1[];\n     double gpar2[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To iterate to an intersection point between two surfaces\n*              and a plane.\n*\n*\n*\n* INPUT      : epoint - Array containing parts of plane description.\n*                       epoint[0:2] contains a position value.\n*                       epoint[3:5] contains the normal to the plane\n*                       A point in the plane is defined by\n*                       epoint[0:2] + astep*epoint[3:5]\n*              epnt1  - 0-2 Derivatives + normal of start point for\n*                       iteration in first surface\n*              epnt2  - 0-2 Derivatives + normal of start point for\n*                       iteration in second surface\n*              epar1  - Parameter pair of start point in first surface\n*              epar2  - Parameter pair of start point in second surface\n*              psurf1 - Description of first surface\n*              psurf2 - Description of second surface\n*              astep  - Step length\n*              aepsge - Absolute tolerance\n*\n*\n* OUTPUT     : gpnt1  - 0-2 Derivatives + normal of result of iteration\n*                       in first surface\n*              gpnt2  - 0-2 Derivatives + normal of result of iteration\n*                       in second surface\n*              gpar1  - Parameter pair of result of iteration in first surface\n*              gpar2  - Parameter pair of result of iteration in second\n*                       surface\n*              jstat  - status messages  \n*                       = 2      : Iteration diverged or to many iterations\n*                       = 1      : iteration converged, singular point found\n*                       = 0      : ok, iteration converged\n*                       < 0      : error\n*\n*\n* METHOD     :\n*\n* USE        : The function is only working i 3-D\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, June-1988\n* Revised by : Tor Dokken, SI, OSLO, Norway, 24-Feb-1989\n*              Prepared for degenerate points\n* Revised by : Tor Dokken, SI, Oslo, Norway, 3-April-1989\n*              Correct handling of small determinats\n*\n*********************************************************************\n*/\n{\n  int ki;                 /* Variable used in loop                          */\n  int kcont;              /* Indicator telling if iteration is not finished */\n  int kder = 2;           /* Derivative indicator                           */\n  int klfu=0;             /* Pointer into knot vector                       */\n  int klfv=0;             /* Pointer into knot vector                       */\n  int klfs=0;             /* Pointer into knot vector                       */\n  int klft=0;             /* Pointer into knot vector                       */\n  int kstat;              /* Status variable                                */\n  int knbit;              /* Counter for number of iterations               */\n  int kdim = 3;           /* Set dimension to 3                             */\n  int kmaxit = 100;       /* Maximal number of iterations allowed           */\n  int kpos=1;             /* Position indicator ofr errors                  */\n  double spoint[3];       /* SISLPoint in intersection plane                    */\n  double *snorm;          /* Pointer to normal vector of intersection plane */\n  double *sp,*spu,*spv,*spn; /* Pointers into gpnt1                         */\n  double *sq,*sqs,*sqt,*sqn; /* Pointers into gpnt2                         */\n  double ta11,ta12,ta21;  /* Variables used in equation systems             */\n  double ta22,tb1,tb2;    /* Variables used in equation systems             */\n  double sdiff[3];        /* Difference between two vectors                 */\n  double tdum1,tdum2;     /* Dummy variables                                */\n  double tdum3,tdum;      /* Dummy variables                                */\n  double tdist;           /* Distance betweentwo points in iteration        */\n  \n  \n  \n  /* Make description of intersection plane */\n  \n  for (ki=0;ki<3;ki++)\n    {\n      spoint[ki] = epoint[ki] + astep*epoint[ki+3];\n    }\n  \n  snorm = epoint + 3;\n  \n  /* Copy input variables to output variables */\n  \n  memcopy(gpnt1,epnt1,21,DOUBLE); \n  memcopy(gpnt2,epnt2,21,DOUBLE);\n  memcopy(gpar1,epar1,2,DOUBLE); \n  memcopy(gpar2,epar2,2,DOUBLE);\n  \n  /* At the start of the iteration the two point gpnt1 and gpnt2 might be\n     very close since we in most cases start from a point on the intersection\n     curve. */\n  \n  /* Set a number of local pointers that ar used often */\n  sp  = gpnt1;\n  spu = gpnt1 + 3;\n  spv = gpnt1 + 6;\n  spn = gpnt1 + 18;\n  sq  = gpnt2;\n  sqs = gpnt2 + 3;\n  sqt = gpnt2 + 6;\n  sqn = gpnt2 + 18;\n  \n  kcont = 1;\n  knbit = 0;\n  \n  while (kcont)\n    \n    {\n      \n      /* Put a parametric representation of the tangent \n\t plane of surface 1 into\n\t the implicit representation of the tangent \n\t plane of surface 2 and also\n\t into the implicit representation of \n\t the intersection plane */\n      \n      ta11 = s6scpr(spu,sqn,kdim);\n      ta12 = s6scpr(spv,sqn,kdim);\n      ta21 = s6scpr(spu,snorm,kdim);\n      ta22 = s6scpr(spv,snorm,kdim);\n      \n      s6diff(sq,sp,kdim,sdiff);\n      tb1  = s6scpr(sdiff,sqn,kdim);\n      \n      tdum = MAX(fabs(ta11),fabs(ta12));\n      tdum = MAX(tdum,fabs(tb1));\n      if (tdum == DZERO) tdum = (double)1.0;\n      ta11 /= tdum;\n      ta12 /= tdum;\n      tb1  /= tdum;\n      \n      s6diff(spoint,sp,kdim,sdiff);\n      tb2  = s6scpr(sdiff,snorm,kdim);\n      \n      tdum = MAX(fabs(ta21),fabs(ta22));\n      tdum = MAX(tdum,fabs(tb2));\n      if (tdum == DZERO) tdum = (double)1.0;\n      ta21 /= tdum;\n      ta22 /= tdum;\n      tb2  /= tdum;\n      \n      /* Calculate determinant of equation system */\n      \n      tdum1 = ta11*ta22 - ta12*ta21;\n      tdum  = MAX(fabs(ta11),fabs(ta22));\n      tdum  = MAX(fabs(ta12),tdum);\n      tdum  = MAX(fabs(ta21),tdum);\n      \n      if (DEQUAL((tdum+tdum1),tdum)) tdum1 =DZERO;\n      \n      \n      /* If tdum1 = 0.0, then the equation system is singular, \n\t iteration not possible */\n\n      if (DNEQUAL(tdum1,DZERO))\n        {\n\t  gpar1[0] += (tb1*ta22-tb2*ta12)/tdum1;\n\t  gpar1[1] += (ta11*tb2-ta21*tb1)/tdum1;\n        }\n      \n      /* Put a parametric representation of the \n\t tangent plane of surface 2 into\n\t the implicit representation of the \n\t tangent plane of surface 1 and also\n\t into the implicit representation \n\t of the intersection plane */\n      \n      ta11 = s6scpr(sqs,spn,kdim);\n      ta12 = s6scpr(sqt,spn,kdim);\n      ta21 = s6scpr(sqs,snorm,kdim);\n      ta22 = s6scpr(sqt,snorm,kdim);\n      \n      s6diff(sp,sq,kdim,sdiff);\n      tb1  = s6scpr(sdiff,spn,kdim);\n      \n      s6diff(spoint,sq,kdim,sdiff);\n      tb2  = s6scpr(sdiff,snorm,kdim);\n      \n      /*Calculate determinant of equation system */\n\n      tdum2 = ta11*ta22 - ta12*ta21;\n      \n      tdum2 = ta11*ta22 - ta12*ta21;\n      tdum  = MAX(fabs(ta11),fabs(ta22));\n      tdum  = MAX(fabs(ta12),tdum);\n      tdum  = MAX(fabs(ta21),tdum);\n      \n      if (DEQUAL((tdum+tdum2),tdum)) tdum2 =DZERO;\n      \n      /* If tdum2 = 0.0, then the equation system is singular, \n\t iteration not possible */\n\n      if (DNEQUAL(tdum2,DZERO))\n        {\n\t  gpar2[0] += (tb1*ta22-tb2*ta12)/tdum2;\n\t  gpar2[1] += (ta11*tb2-ta21*tb1)/tdum2;\n        }\n      \n      /* Calculate values of new points */\n      \n      s1421(psurf1,kder,gpar1,&klfu,&klfv,gpnt1,gpnt1+18,&kstat); \n      if (kstat<0) goto error;\n      \n      /* If the surface normal has zero length no use in continuing */\n      \n      if (kstat == 2) goto war02;\n      \n      s1421(psurf2,kder,gpar2,&klfs,&klft,gpnt2,gpnt2+18,&kstat); \n      if (kstat<0) goto error;\n      \n      /* If the surface normal has zero length no use in continuing */\n      \n      if (kstat == 2) goto war02;\n      \n      /* Make difference between the two points, \n\t and calculate length of difference */\n      s6diff(gpnt1,gpnt2,kdim,sdiff);\n      tdum3 = s6length(sdiff,kdim,&kstat);\n      if (kstat==0) \n        {\n\t  /* Length is zero iteration has converged */\n\n\t  kcont = 0;\n        }\n      \n      if (knbit==0)\n        {\n\t  /* First iteration intitate distance variable, if the equation\n\t     systems were not singular */\n\n\t  if (DEQUAL(tdum1,DZERO) || DEQUAL(tdum2,DZERO)) goto war02;\n\t  tdist = tdum3;\n\t  knbit = 1;\n        }\n      else\n        {\n\t  /* More than one iteration done, stop if distance is not decreasing.\n\t     Then decide if we converge distance between the points is within\n\t     the tolerance and the last step had singular or none singular\n\t     equation systems. */\n\n\t  knbit = knbit + 1;\n\t  if (tdum3>=tdist)\n            {\n\t      /* Distance is not decreasing */\n\t      if (tdist <= aepsge)\n                {\n\t\t  /* Distance within tolerance */\n\t\t  if (DEQUAL(tdum1,DZERO) || DEQUAL(tdum2,DZERO))\n                    {\n\t\t      /* Singular equation system */\n\t\t      goto war01;\n                    }\n\t\t  else\n                    {\n\t\t      /* Nonsingular equation system */\n\t\t      goto war00;\n                    }\n                }\n\t      else\n                {\n\t\t  /* Distance is not within tolerance, divergence */\n\t\t  goto war02;\n                }\n            }\n\t  /*      Distance still decreasing */\n\t  \n\t  tdist = tdum3;\n        }\n      \n      /*  Make sure that not to many iteration are being done */\n      if (knbit > kmaxit) goto war02;\n    }\n  \n  \n  /* Iteration converged */\n war00:\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Iteration converged, singular point found */\n war01: \n  *jstat = 1;\n  goto out;\n  \n  /* To many iterations or iteration diverging */\n war02: \n  *jstat = 2;\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : \n    *jstat = kstat;\n  s6err(\"s9iterate\",*jstat,kpos);\n  goto out;\n  \n out:\n  return;\n}\n"
  },
  {
    "path": "src/s9iterimp.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s9iterimp.c,v 1.3 2005-02-28 09:04:50 afr Exp $\n *\n */\n#define S9ITERIMP\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns9iterimp(double epoint[],double epnt1[],double epar1[],SISLSurf *psurf1,\n\t       double eimpli[],int ideg,double astep,double aepsge,\n\t       double gpnt1[],double gpar1[],int *jstat)\n#else\nvoid s9iterimp(epoint,epnt1,epar1,psurf1,eimpli,ideg,astep,aepsge,\n               gpnt1,gpar1,jstat)\n     double epoint[];\n     double epnt1[];\n     double epar1[];\n     SISLSurf   *psurf1;\n     double eimpli[];\n     int    ideg;\n     double astep;\n     double aepsge;\n     double gpnt1[];\n     double gpar1[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To iterate to an intersection point between a B-spline\n*              surfaces, an implicit surface and a plane.\n*\n*\n* INPUT      : epoint - Array containing parts of plane description.\n*                       epoint[0:2] contains a position value.\n*                       epoint[3:5] contains the normal to the plane\n*                       A point in the plane is defined by\n*                       epoint[0:2] + astep*epoint[3:5]\n*              epnt1  - 0-2 Derivatives + normal of start point for\n*                       iteration in B-spline surface\n*              epar1  - Parameter pair of start point in B-spline surface\n*              psurf1 - Description of B-spline surface              \n*              eimpli - Description of implicit surface\n*              ideg   - Degree of implicit surface\n*                        ideg=1:    Plane              \n*                        ideg=2;    Quadric surface\n*                        ideg=1001: Torus surface\n*                        ideg=1003: Silhouette line parallel projection\n*                        ideg=1004: Silhouette line perspective projection\n*                        ideg=1005: Silhouette line circular projection\n*              astep  - Step length\n*              aepsge - Absolute tolerance\n*\n*\n* OUTPUT     : gpnt1  - 0-2 Derivatives + normal of result of iteration\n*                       in B-spline surface\n*              gpar1  - Parameter pair of result of iteration in B-spline\n*                       surface\n*              jstat  - status messages  \n*                       = 2      : Iteration diverged or to many iterations\n*                       = 1      : iteration converged, singular point found\n*                       = 0      : ok, iteration converged\n*                       < 0      : error\n*\n*\n* METHOD     : We want to find the intersection point between the three\n*              surfaces.\n*\n*              Ideg=1:\n*                P(s,t)\n*                AX = 0  The implicit represented plane given by econic\n*                BX = 0  The implicit represented plane giving the step\n*\n*\n*              Ideg=2:\n*                P(s,t)\n*                XAX = 0 The implicit second degree surface\n*                BX  = 0 The implicit represented plane giving the step\n*\n*\n*              Ideg=1001; Torus surface\n*                P(s,t)\n*                Torus described by center, normal, big and small radius\n*\n*\n*              By making a Newton iteration on the functions we get when\n*              P(s,t) is put into the implicit equations we can iterate to\n*              an intersection point.\n*\n* USE        : The function is only working in 3-D\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Tor Dokken, SI, Oslo, Norway, 4-July-1988\n* Revised by : Tor Dokken, SI, Oslo, Norway, 24-Feb-1989\n*              Detects degenerate points\n* Revised by : Tor Dokken, SI, Oslo, Norway, March 1989\n*              Test for almost zero determinant introduced.\n* Revised by : Mike Floater, SI, 1991-01\n*                   Add perspective and circular silhouettes (ideg=1004,ideg=1005)\n*\n*********************************************************************\n*/\n{\n  int ki;                 /* Variable used in loop                          */\n  int kcont;              /* Indicator telling if iteration is not finished */\n  int kder = 1;           /* Derivative indicator                           */\n  int klfu=0;             /* Pointer into knot vector                       */\n  int klfv=0;             /* Pointer into knot vector                       */\n  int kstat;              /* Status variable                                */\n  int knbit;              /* Counter for number of iterations               */\n  int kdim = 3;           /* Set dimension to 3                             */\n  int kmaxit = 100;       /* Maximal number of iterations allowed           */\n  int kpos=1;             /* Position indicator ofr errors                  */\n  int ksing;              /* Singularity indicator                          */\n  int ksize;              /* Number of doubles for storage of derivateves\n\t\t\t     and normal vector */\n  int ksizem3;            /* ksize - 3                                      */\n  double spoint[3];       /* SISLPoint in intersection plane                    */\n  double *snorm;          /* Pointer to normal vector of intersection plane */\n  double sbinorm[3];      /* Vector normal tu curve tangent                 */\n  double *sp,*spu,*spv,*spn; /* Pointers into gpnt1                         */\n  double sprev[3];        /* Coordinates of previous point in iteration     */\n  double ta11,ta12,ta21;  /* Variables used in equation systems             */\n  double ta22,tb1,tb2;    /* Variables used in equation systems             */\n  double sdiff[3];        /* Difference between two vectors                 */\n  double tdum,tdum1;      /* Dummy variables                                */\n  double tdist;           /* Error so fare in iteration                     */\n  double tcurdst;         /* Error at current step in the iteration         */\n  double sder[3];         /* Derivatives of comb. of impl. surf and par.surf*/\n  double sproj[3];        /* Projection direction                           */\n  double tlnorm;          /* Length of normal vector of step plane          */\n  double tdiststep;       /* Distance from step plane                       */\n  double titer;           /* Iteration criteria                             */\n  \n  /* If ideg=1,2 or 1001 then only derivatives up to second order\n     are calculated, then 18 doubles for derivatives and 3 for the\n     normal vector are to be used for calculation of points in the\n     spline surface. For ideg=1003,1004,1005 we have a silhouette curve and\n     derivatives up to the third are to be calculated,\n     thus 30 +3 a total of 33 doubles are to be calculated */\n  \n  if (ideg==1003 || ideg==1004 || ideg==1005)\n    {\n      kder = 3;\n      ksize = 33;\n    }\n  else\n    {\n      ksize = 21;\n      kder =2;\n    }                                                       \n  ksizem3 = ksize -3;\n  \n  /* Make description of intersection plane */\n  \n  tlnorm = s6length(epoint+3,3,&kstat);\n  if (kstat<0) goto error;\n  if (DEQUAL(tlnorm,DZERO)) tlnorm = (double)1.0;\n  \n  for (ki=0;ki<3;ki++)\n    {\n      spoint[ki] = epoint[ki] + astep*epoint[ki+3]/tlnorm;\n    }\n  \n  snorm = epoint + 3;\n  \n  /* Copy input variables to output variables */\n  \n  memcopy(gpnt1,epnt1,ksize,DOUBLE); \n  memcopy(gpar1,epar1,2,DOUBLE); \n  \n  /* At the start of the iteration the point gpnt1 is put into both implicit\n     equations */\n  \n  /* Set a number of local pointers that are used often */\n  sp  = gpnt1;\n  spu = gpnt1 + 3;\n  spv = gpnt1 + 6;\n  spn = gpnt1 + ksizem3;\n  \n  kcont = 1;\n  knbit = 0;\n  \n  while (kcont)\n    \n    {             \n      \n      /* For all degrees we have to put the B-spline surface into the plane\n\t determining the step length before we branch degree on the degree\n\t of the implicit surface. */\n      \n      ta21 = s6scpr(spu,snorm,kdim);\n      ta22 = s6scpr(spv,snorm,kdim);\n      s6diff(spoint,sp,kdim,sdiff);\n      tb2  = s6scpr(sdiff,snorm,kdim);\n      tdum = max(fabs(ta21),fabs(ta22));\n      tdum = max(tdum,fabs(tb2));\n      if (DEQUAL(tdum,DZERO)) tdum = (double)1.0;\n      ta21 /= tdum;\n      ta22 /= tdum;\n      tb2  /= tdum;\n      \n      \n      /* Calculate value and derivatives of the parametric surface put into\n\t the equation of the implicit surface */\n      \n      s1331(gpnt1,eimpli,ideg,1,sder,sproj,&kstat);\n      \n      ta11 = sder[1];\n      ta12 = sder[2];\n      tb1  = -sder[0];\n      \n      tdum = max(fabs(ta11),fabs(ta12));\n      tdum = max(tdum,fabs(tb1));\n      if (DEQUAL(tdum,DZERO)) tdum = (double)1.0;\n      ta11 /= tdum;\n      ta12 /= tdum;\n      tb1  /= tdum;\n      \n      \n      /* Calculate determinant of equation system */\n      \n      tdum1 = ta11*ta22 - ta12*ta21;\n      tdum  = MAX(fabs(ta11),fabs(ta22));\n      tdum  = MAX(fabs(ta12),tdum);\n      tdum  = MAX(fabs(ta21),tdum);\n      \n      if (DEQUAL((tdum+tdum1),tdum)) tdum1 =DZERO;\n      \n      \n      /* If tdum1 = 0.0, then the equation system is singular, try an\n\t alternative setup of the equation system */\n      \n      if (tdum1 == DZERO && ideg < 1003)\n        {\n\t  s6crss(sproj,snorm,sbinorm);\n\t  ta11 = s6scpr(spu,sbinorm,kdim);\n\t  ta12 = s6scpr(spv,sbinorm,kdim);\n\t  tb1  = s6scpr(sdiff,sbinorm,kdim);\n\t  \n\t  tdum = max(fabs(ta11),fabs(ta12));\n\t  tdum = max(tdum,fabs(tb1));\n\t  if (DEQUAL(tdum,DZERO)) tdum = (double)1.0;\n\t  ta11 /= tdum;\n\t  ta12 /= tdum;\n\t  tb1  /= tdum;\n\t  \n\t  /* Calculate determinant of equation system */\n\t  \n\t  tdum1 = ta11*ta22 - ta12*ta21;\n\t  tdum  = MAX(fabs(ta11),fabs(ta22));\n\t  tdum  = MAX(fabs(ta12),tdum);\n\t  tdum  = MAX(fabs(ta21),tdum);\n\t  \n\t  if (DEQUAL((tdum+tdum1),tdum)) tdum1 =DZERO;\n        }\n      \n      if (DNEQUAL(tdum1,DZERO))\n        {\n\t  gpar1[0] += (tb1*ta22-tb2*ta12)/tdum1;\n\t  gpar1[1] += (ta11*tb2-ta21*tb1)/tdum1;\n        }\n      \n      /* Calculate value of new points */\n      \n      s1421(psurf1,kder,gpar1,&klfu,&klfv,gpnt1,gpnt1+ksizem3,&kstat); \n      if (kstat<0) goto error;\n      \n      /* If the surface normal has zero length no use in continuing */\n      \n      if (kstat == 2) goto war02;\n      \n      \n      tcurdst = s1309(gpnt1,sproj,eimpli,ideg,&kstat);\n      if (kstat < 0) goto error;\n      if (kstat ==2) goto war02;\n      \n      tcurdst = fabs(tcurdst);\n      \n      /* Calculate distance from step plane */\n      \n      s6diff(spoint,gpnt1,kdim,sdiff);\n      tdiststep  = fabs(s6scpr(sdiff,snorm,kdim)/tlnorm);\n      \n      \n      /* tcurdst now contains the distance between the point in the parametric\n\t surface and the projection along sproj of this point onto the implicit\n\t surface if ideg== 1,2 or 1001. In the case ideg==1003,1004,1005 we have a\n\t silhouette line and tcurdst contains the angle PI minus the angle \n\t between the view direction and the normal of the surface */\n      \n      /* We continue iteration so long as the error titer is not decreasing */\n      \n      \n      if (ideg==1003 || ideg==1004 || ideg==1005)\n        {\n\t  /* tcurdst contains an angle and is compared with ANGULAR_TOLERANCE,\n\t     while tdiststep contains a distance and is compared with aepsge.\n\t     To make a measure of these that is consistent they have to have\n\t     the same unit measure thus we make.   */\n\t  \n\t  titer = tcurdst*aepsge + tdiststep*ANGULAR_TOLERANCE;\n        }\n      else\n        titer = tcurdst + tdiststep;\n      \n      if (DEQUAL(tcurdst,DZERO) && DEQUAL(tdiststep,DZERO))\n        {\n\t  /* Length is zero iteration has converged   */\n\t  kcont = 0;\n        }\n      \n      if (knbit==0)\n        {\n\t  /* First iteration intitate distance variable, if the equation\n\t     systems were not singular */\n\n\t  if (DEQUAL(tdum1,DZERO)) goto war02;\n\t  tdist = titer;\n\t  knbit = 1;\n        }\n      else\n        {\n\t  /* More than one iteration done, stop if distance is not decreasing.\n\t     Then decide if we converge distance between the points is within\n\t     the tolerance and the last step had singular or none singular\n\t     equation systems. */\n\n\t  knbit = knbit + 1;\n\t  if (titer>=tdist)\n            {\n\t      /* Distance is not decreasing */\n\n\t      if (fabs(s6dist(sprev,gpnt1,kdim)) <= aepsge)\n                {               \n\t\t  /* Distance within tolerance */\n\t\t  \n\t\t  /* Check if singularity reached. \n\t\t     This is the case if tdum1=0.0\n\t\t     or if the relative distance between\n\t\t     the input point and\n\t\t     the output point is within the \n\t\t     relative computer resolution */\n\n\t\t  ksing = 1;\n\t\t  for (ki=0 ; ki<3; ki++)\n                    {\n\t\t      tdum = MAX(fabs(epnt1[ki]),fabs(gpnt1[ki]));\n\t\t      if (DEQUAL(tdum,DZERO)) tdum = (double)1.0;\n\t\t      if(fabs(epnt1[ki]-gpnt1[ki])/tdum > REL_COMP_RES)\n                        ksing = 0;\n                    }\n\t\t  if (DEQUAL(tdum1,DZERO) || ksing == 1)\n                    {\n\t\t      /* Singular equation system */\n\t\t      goto war01;\n                    }\n\t\t  else\n                    {\n\t\t      /* Nonsingular equation system */\n\t\t      goto war00; \n                    }\n                }\n\t      else\n                {\n\t\t  /* Distance is not within tolerance, divergence */\n\t\t  goto war02;\n                }\n            }\n\t  /* Distance still decreasing */\n\t  \n\t  tdist = titer;\n        }\n      \n      /*  Make sure that not to many iteration are being done */\n      if (knbit > kmaxit) goto war02;\n      /*  Remember this point */\n      memcopy(sprev,gpnt1,3,DOUBLE);\n    }\n  \n  /* Iteration converged, calculate also second derivatives */\n war00:\n  \n  kder = 2;\n  s1421(psurf1,kder,gpar1,&klfu,&klfv,gpnt1,gpnt1+ksizem3,&kstat); \n  if (kstat<0) goto error;\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Iteration converged, singular point found */\n war01: \n  *jstat = 1;\n  goto out;\n  \n  /* To many iterations or iteration diverging */\n war02: \n  *jstat = 2;\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : \n    *jstat = kstat;\n  s6err(\"s9iterimp\",*jstat,kpos);\n  goto out;\n  \n out:\n  return;\n}\n"
  },
  {
    "path": "src/s9smplknot.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s9smplknot.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define S9SIMPLE_KNOT\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\ns9simple_knot(SISLSurf* surf, int idiv, double epar[], \n\t\t   int *fixflag, int *jstat)\n#else\nvoid s9simple_knot(surf, idiv, epar, fixflag, jstat)\n     SISLSurf* surf;\n     int idiv; \n     double epar[];\n     int *fixflag;\n     int *jstat;\n#endif\n/*\n***************************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To check if the spline surface surf has more than one inner \n*              breakpoint in direction idiv (could be both directions).\n*\n*\n*\n* INPUT      : surf      - Pointer to the spline surface\n*              idiv      - direction to check, possible values:\n*\t\t\t                1 first parameter direction\n*\t\t\t                2 second parameter direction\n*\t\t\t                3 both parameter directions\n*\n*\n*\n* OUTPUT     : jstat     - status messages  \n*                                         = 1      : at most one inner \n*\t\t\t\t\t\t     breakpoint found in \n*\t\t\t\t\t\t     direction(s) idiv\n*                                         = 0      : more than one inner \n*\t\t\t\t\t\t     breakpoint found in \n*\t\t\t\t\t\t     direction idiv, (in one\n*\t\t\t\t\t\t     of them if idiv=3)\n*                                         < 0      : error\n*              epar[i]   - parameter value of simple inner knot in diretion i \n*\t\t\t   (i=0 first direc, i=1 second direc.),\n*\t\t\t   midpoint if no inner simple knot found in direc i,\n*                          not set if more than one inner breakpt in direc i or\n*\t\t\t   direc i not indicated by idiv.\n*\t\t\t   \n*              fixflag   - indicates simple inner breakpt found in \n*\t\t\t   any of the direcs given by idiv:\n*\t\t\t   1 simple knot found in first direc,\n*\t\t\t   2 simple knot found in second direc,\n*\t\t\t   3 simple knot found in both direc.\n*                          0 no or more than one simple breakpt found in all\n*                            the directions indicated by idiv.\n*\n* ASSUMPTIONS: k-tuple knots at the ends of the knot vector\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err      - Treating error situation.\n*              s6knotmult - Counting multiplicity of a knot\n*\n* WRITTEN BY : Kyrre Strom, SI, 93-01.\n*\n*\n****************************************************************************\n*/\n{\n  int k1,k2,kstat,mult;\n\n  k1 = k2 = *fixflag = 0;\n\n  if ( idiv < 1 || idiv > 3 ) goto err202;\n  if (idiv == 1 || idiv == 3) /* Check in first parameter direction */\n    {\n      if ( surf->in1 == surf->ik1 )\n\t{\n\t  epar[0] = (surf->et1[0] + surf->et1[surf->in1+surf->ik1-1])/2.0;\n\t  k1 = 1;\n\t}\n      else \n\t{\n\t  int left = surf->ik1;\n\t  mult = s6knotmult(surf->et1,surf->ik1,surf->in1, &left,\n\t\t\t    surf->et1[surf->ik1],&kstat);\n\t  if (kstat < 0 ) goto error;\n\t  if ( surf->ik1+mult == surf->in1 )\n\t    {\n\t      epar[0] = surf->et1[surf->ik1];\n\t      k1 = 1;\n\t      *fixflag += 1;\n\t    }\n\t}\n    }\n\n  if (idiv == 2 || idiv == 3)\n    {\n      if ( surf->in2 == surf->ik2 )\n\t{\n\t  epar[1] = (surf->et2[0] + surf->et2[surf->in2+surf->ik2-1])/2.0;\n\t  k1 += 2;\n\t}\n      else \n\t{\n\t  int left = surf->ik2;\n\t  mult = s6knotmult(surf->et2,surf->ik2,surf->in2, &left,\n\t\t\t    surf->et2[surf->ik2],&kstat);\n\t  if (kstat < 0 ) goto error;\n\t  if ( surf->ik2+mult == surf->in2 )\n\t    {\n\t      epar[1] = surf->et2[surf->ik2];\n\t      k1 += 2;\n\t      *fixflag += 2 ;\n\t    }\n\t}\n    }\n  \n  *jstat = ((idiv == k1 && (*fixflag)) ? 1 : 0);\n  goto out;\n\n error : *jstat = kstat;\n         s6err(\"s9simple_knot\",*jstat,0);\n  \t goto out;\n\n err202 : *jstat = -202;\n         s6err(\"s9simple_knot\",*jstat,0);\n\n out:  return;         \n }\n"
  },
  {
    "path": "src/s9surmarch.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: s9surmarch.c,v 1.2 2001-03-19 15:59:03 afr Exp $\n *\n */\n\n\n#define S9SURMARCH\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \ns9surmarch(SISLSurf *ps1,SISLSurf *ps2,double epar[],int ndir[],int ipoint,\n\t\tdouble *gpar[],int *mpar[],int *jpoint,int *jstat)\n#else\nvoid s9surmarch(ps1,ps2,epar,ndir,ipoint,gpar,mpar,jpoint,jstat)\n     SISLSurf   *ps1;\n     SISLSurf   *ps2;\n     double epar[];\n     int    ndir[];\n     int    ipoint;\n     double *gpar[];\n     int    *mpar[];\n     int    *jpoint;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To check which of the points in the epar array can be\n*              connected by marching. If the connection should be\n*              to internal point these points are returned. All points\n*              are assumed to lie on the boundary or close to the boundary\n*              of the patch (DEQUAL says that they lie on the boundary).\n*\n*              When ipoint = 2, we connect always if marching succeeds!!!!!!!\n*              without testing for equality between marching results and\n*              given point no 2.\n*\n* INPUT      : ps1       - The first surface in intersection.\n*              ps2       - The second surface in intersection.\n*              epar[2,*] - Parameter values for the  intersection points along\n*                          the boundary.\n*              ndir[*]   - Description of the points in epar.\n*                          -1 : tangent pointing out\n*                           0 : tangent parallel to boundary\n*                           1 : tangent pointing in\n*                           2 : singular point\n*                          The algorithm assumes that first all points\n*                          with status -1 and 1 lies first in epar.\n*              ipoint    - Number of parameter values\n*\n*\n* OUTPUT     : gpar      - Pointer to parameter values produced tor singular \n*                          points. Is allocated inside the function, must\n*                          be released by the calling function.\n*              mpar      - Array describing how the input parameter pairs were\n*                          connected to other in the input vector and to the\n*                          new parameter pairs made in gpar. Is allocated\n*                          inside the function, must be released by the\n*                          calling function.\n*                           -3             - point on closed curve\n*                           -2             - internal point onc other curve\n*                           -1             - Can not march from point\n*                           POSITIVE VALUE - SISLPoint connected to point in epar\n*              jpoint    - Number of new parameter pairs produced\n*              jstat   -  status messages  \n*                                = 2   : Only singular points, not connected\n*                                = 1   : Points connected\n*                                = 0   : Points not connected..\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, Oslo, Norway. August  1989\n*\n*********************************************************************\n*/\n{\n  int kstat;            /* Status variable                             */\n  int kpos=0;           /* Position of error                           */\n  int *lpar = SISL_NULL;     /* Pointer to output integer array             */\n  int ki,kj;\n  int kn1,kn2,kk1,kk2;  /* Surface attributes.           */\n  double tstart1,tstart2,tend1,tend2; /* Surface attributes.           */\n  int ksucc;            /* Success indicator                           */\n  double tepsge=1.0;    /* Not used                                    */\n  double *spar=SISL_NULL;    /* Pointer to output real array                */\n  double scand1[4];     /* Result of iteration process                 */\n  double scand2[4];     /* Result of iteration process                 */\n  double *sp,*sq;       /* Pointer used in loop                        */\n  double tdum1;         /* Max knot value used in DEQUAL comparing.    */\n  double tdum2;         /* Max knot value used in DEQUAL comparing.    */\n  double tdum3;         /* Max knot value used in DEQUAL comparing.    */\n  double tdum4;         /* Max knot value used in DEQUAL comparing.    */\n\n  /* Init */\n  kn1 = ps1->in1;\n  kn2 = ps1->in2;\n  kk1 = ps1->ik1;\n  kk2 = ps1->ik2;\n\n  tstart1 = ps1->et1[kk1-1];\n  tend1   = ps1->et1[kn1];\n  tstart2 = ps1->et2[kk2-1];\n  tend2   = ps1->et2[kn2];\n\n  tdum1 = (double)2.0*max(fabs(tstart1),fabs(tend1));\n  tdum2 = (double)2.0*max(fabs(tstart2),fabs(tend2));\n\n  kn1 = ps2->in1;\n  kn2 = ps2->in2;\n  kk1 = ps2->ik1;\n  kk2 = ps2->ik2;\n\n  tstart1 = ps2->et1[kk1-1];\n  tend1   = ps2->et1[kn1];\n  tstart2 = ps2->et2[kk2-1];\n  tend2   = ps2->et2[kn2];\n\n\n  tdum3 = (double)2.0*max(fabs(tstart1),fabs(tend1));\n  tdum4 = (double)2.0*max(fabs(tstart2),fabs(tend2));\n\n\n  /* Allocate output arrays */\n  \n  if ((*mpar=newarray(2*ipoint,INT     )) == SISL_NULL) goto err101;\n  if ((*gpar=newarray(8*ipoint,DOUBLE)) == SISL_NULL) goto err101;\n  \n  lpar = *mpar;\n  spar = *gpar;\n  \n  memcopy(spar,epar,4*ipoint,DOUBLE);\n  *jpoint = ipoint;\n  \n  /* Initiate output integer array to point to no points */\n  \n  for (ki=0 ; ki< 2*ipoint ; ki++) *(lpar+ki) = 0;\n  \n\n  /* Loop for all input points. */      \n  for (ki=0, sp=spar ; ki< ipoint-1 ; ki++, sp+=4)\n    {\n      /* Start marching from point ki */\n\n      /* Exclude points already connected and parallell points. */\n      if (lpar[ki] != 0 || ndir[ki] == 0) continue;\n\t  \n      /* SISLPoint not marched to */\n\t  \n      s1788(ps1,ps2,tepsge,sp,scand1,scand2,&kstat);\n      if (kstat<0) goto error;\n      if (kstat==0) goto war00;;\n\t  \n      /* Run through remaining points to find if scand2 matches any\n\t of them. If we've got only two points, we connect them.*/\n\t  \n      ksucc = 0;\n\t  \n      for (kj=ki+1,sq=spar+4*ki+4 ; kj<ipoint ; kj++,sq+=4)\n\t{\n\t      \n\t  /* SISLPoint found */\n\t      \n\t  if (DEQUAL(sq[0]+tdum1,scand2[0]+tdum1) && \n\t       DEQUAL(sq[1]+tdum2,scand2[1]+tdum2) &&\n\t       DEQUAL(sq[2]+tdum3,scand2[2]+tdum3) &&\n\t       DEQUAL(sq[3]+tdum4,scand2[3]+tdum4))\n\n\t    {\n\t      /* Accepted end point found */\n\t      \n\t      lpar[ki] = kj+1;\n\t      lpar[kj] = ki+1;\n\t      ksucc = 1;\n\t      break;\n\t    }\n\t}\n      /* If ksucc==0 then one of the searches was not successful */\n\t  \n      if (ksucc==0) goto war00;   \n\n    }\n  \n  goto success;\n\n success: \n  *jstat = 1;\n  goto out;\n\n  /* No success */\n war00: \n  *jstat=0;\n  /* If we got only singular points, set status.*/\n  if (ndir[0] == 2) *jstat = 2;\n  goto out;\n\n  /* Error in space allocation */\n err101: \n  *jstat = -101;\n  s6err(\"s9surmarch\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level function */\n error:\n  *jstat = kstat;\n  s6err(\"s9surmarch\",*jstat,kpos);\n  goto out;\n\n out:;\n}\n"
  },
  {
    "path": "src/sh1260.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define SH1260\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      sh1260(double aconst,SISLCurve *vcurve[],int icurve,int *jstat)\n#else\t \nvoid sh1260(aconst,vcurve,icurve,jstat)\n     double aconst;\n     SISLCurve *vcurve[];\n     int icurve;\n     int *jstat;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Check length of tangent vectors at the endpoints of a\n*              curve compared to the size of the curve. If the vectors\n*              are too long, reparametrize the curve and a number of\n*              corresponding curves.\n*\n*\n*\n* INPUT      : aconst     - Constant used to check when the tangent\n*                           vectors at the endpoints of the curve are\n*                           too long.\n*              icurve     - Number of curves. icurve >= 1.\n*              \n*\n* INPUT/OUTPUT : vcurve   - Array containing a curve set. The curves\n*                           are expected to have the same parametrization.\n*                           If the tangents in the endpoints of the\n*                           first curve is too long, all curves are\n*                           reparametrized. Dimension of the array is icurve.\n*                       \n*\n* OUTPUT     : jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        : 3D geometry only.\n*\n*-\n* CALLS      : s1221    - Evaluate curve.  \n*              s6diff   - Difference vector between two vectors.  \n*              s6scpr   - Scalar product between two vectors.  \n*              s6length - Length of vector.   \n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 06.90.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;      /* Status variable.   */\n  int ki;             /* Counter.           */\n  int kder = 1;       /* Number of derivatives of curve to evaluate. */\n  int kleft = 0;      /* Parameter used in curve evaluation.         */\n  int kdim = vcurve[0]->idim;   /* Dimension of first curve in the curve set.     */\n  double tpar1 = *(vcurve[0]->et + vcurve[0]->ik - 1);   /* Start of parameter\n                                                            interval of 1. curve. */\n  double tpar2 = *(vcurve[0]->et + vcurve[0]->in);       /* End of parameter\n                                                            interval of 1. curve. */\n  double *sder1 = SISL_NULL;  /* Value of 1. curve in start of parameter interval.   */\n  double *sder2 = SISL_NULL;  /* Value of 1. curve in end of parameter interval.     */\n  double *sdiff = SISL_NULL;  /* Difference vector between endpoints of 1. curve.    */\n  double tdiff;          /* Length of sdiff.  */\n  double t1,t2;          /* Length of the components of the tangent vectors in the \n                            endpoints along sdiff, compared with the length of sdiff.*/\n  double tscal;          /* The factor with which to scale the curves.  */\n  double tnewend;        /* New endpoint of parameter interval.         */\n  double *s1;            /* Pointer used to traverse knot vector of curve. */  \n  double *s2;            /* Pointer used to stop traversing knot vector.   */\n  SISLCurve *qcpt;           /* Pointer to curve in curve set. */\n  \n  /* Test input.  */\n\n  if (icurve < 1) goto err110;\n  for (ki=1; ki<icurve; ki++)\n    {\n      qcpt = vcurve[ki];\n      if (qcpt->idim != kdim) goto err106;\n      if (*(qcpt->et+qcpt->ik-1) != tpar1) goto err112;\n      if (*(qcpt->et+qcpt->in) != tpar2) goto err112;\n    }\n      \n  /* Allocate scratch for value and derivatives of the first curve\n     in the endpoints.  */\n\n  if ((sder1 = newarray(2*kdim,DOUBLE)) == SISL_NULL) goto err101;\n  if ((sder2 = newarray(2*kdim,DOUBLE)) == SISL_NULL) goto err101;\n  if ((sdiff = newarray(kdim,DOUBLE)) == SISL_NULL) goto err101;\n\n  /* Evaluate the first curve in the endpoints.  */\n\n  s1221(vcurve[0],kder,tpar1,&kleft,sder1,&kstat);\n  if (kstat < 0) goto error;\n  \n  s1221(vcurve[0],kder,tpar2,&kleft,sder2,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Compute difference vector between endpoints of position curve. */\n\n  s6diff(sder2,sder1,kdim,sdiff);\n  \n  /* Compute length of difference vector.  */\n\n  tdiff = s6length(sdiff,kdim,&kstat);\n  \n  /* Compute length of the component of the tangent in the first endpoint\n     along the difference vector compared to the distance between the\n     endpoints. The result lies between 0 and 1.  */\n\n  t1 = s6scpr(sder1+kdim,sdiff,kdim)/(tdiff*tdiff);   \n\n/*  t1 = s6length(sder1+kdim,kdim,&kstat);  */\n  \n  /* Compute length of the component of the tangent in the second endpoint\n     along the difference vector compared to the distance between the\n     endpoints. The result lies between 0 and 1.  */\n\n  t2 = s6scpr(sder2+kdim,sdiff,kdim)/(tdiff*tdiff);  \n  \n/*  t2 = s6length(sder2+kdim,kdim,&kstat);   */\n  \n  /* Check if any of the tangents are too long.  */\n\n  if (MAX(t1,t2) > aconst)\n    {\n      /* One of the tangents is too long. Reparametrize to reduce tangent\n\t length.   */\n\n      tscal = MAX(t1,t2)/aconst;\n      \n      /* Find new endpoint of parameter interval. The startpoint is kept. */\n\n      tnewend = tscal*(tpar2-tpar1) + tpar1;\n\n      for (ki=0; ki<3; ki++)\n\t{\n\t  qcpt = vcurve[ki];\n\t  \n\t  /* Traverse position and u- and v-derivative curves.  */\n\n\t  for (s1=qcpt->et,s2=qcpt->et+qcpt->in+qcpt->ik; s1<s2; s1++)\n\t    *s1 = tpar1 + (*s1 - tpar1)*(tnewend - tpar1)/(tpar2 - tpar1);\n\t}\n      \n    }\n \n  /* Testing and evt. reparametrization performed.  */\n\n  *jstat = 0;\n  goto out;\n  \n  /* Error in scratch allocation.  */\n\n  err101 :\n    *jstat = -101;\n  goto out;\n  \n  /* Error in input. Number of curve is less than one.  */\n\n  err110 :\n    *jstat = -110;\n  goto out;\n  \n  /* Error in input. Conflicting dimensions.  */\n\n  err106 :\n    *jstat = -106;\n  goto out;\n  \n  /* Error in input. The curves do not have the same parameter interval.  */\n\n  err112 :\n    *jstat = -112;\n  goto out;\n  \n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n  goto out;\n  \n  out :\n    \n    /* Free space occupied by local arrays and curves.  */\n\n    if (sder1 != SISL_NULL) freearray(sder1);\n  if (sder2 != SISL_NULL) freearray(sder2);\n  if (sdiff != SISL_NULL) freearray(sdiff);\n  \n  return;\n}     \n"
  },
  {
    "path": "src/sh1261.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define SH1261\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void sh1261_s9evalbez(double [],int,double,double,double,\n\t\t\t     double *,int *);\n#else\nstatic void sh1261_s9evalbez();\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      sh1261(SISLCurve *pcurve1,SISLCurve *pcurve2,double ecoef1[],\n\t     int ik1,double ecoef2[],int ik2,SISLCurve **rcrtanc,int *jstat)\n#else\nvoid sh1261(pcurve1,pcurve2,ecoef1,ik1,ecoef2,ik2,rcrtanc,jstat) \n   SISLCurve *pcurve1,*pcurve2,**rcrtanc; \n     double ecoef1[],ecoef2[]; \n     int ik1,ik2,*jstat; \n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE : Blend two curves to produce a new, higher order curve.\n*           Curves to be blended and blending functions are given.  \n* \n* \n* \n* INPUT   : pcurve1 - First curve to be blended.  \n*           pcurve2 - Second curve to be blended.  \n*           ecoef1  - Vertices of first blending function. The function \n*                     is a one-dimensional Bezier curve on the same \n*                     parameter interval as the input curves.  \n*           ik1     - Order of first blending function.  \n*           ecoef2  - Vertices of second blending function. The function \n*                     is a one-dimensional Bezier curve on the same \n*                      parameter interval as the input curves.  \n*           ik2     - Order of second blending function. \n*\n* \n* OUTPUT :  rcrtanc - Produced curve.  \n*           jstat - status messages \n*                   > 0 : warning \n*                   = 0 : ok \n*                   < 0 : error \n* \n* \n* METHOD :  Compute order and knot vector of the curve to \n*           produce. Then the number of vertices of the output \n*           curve is given. Evaluate the expression \n*           (first blending function)*(first input curve) \n*           + (second blending function)*(second input curve)\n*           in a number of points equal to the number of vertices. Interpolate\n*           in these pointes to find the vertices of the cross output curve.\n*\n*\n* REFERENCES : \n*              \n*\n* USE        :\n*\n*-\n* CALLS      : s1221  - Evaluate B-spline curve.       \n*              s1363  - Pick parametrization of curve.  \n*              s1891 - Interpolate.                    \n*              s6takeunion - Union of two ordered vectors.   \n*              newCurve    - Create new curve.           \n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 06.90.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;       /* Status variable.  */\n  int ki,kj;           /* Counters.         */\n  int kk;              /* Number increased in order.     */\n  int kleft = 0;       /* Parameter used in s1221.  */\n  int korder;          /* Order of cross tangent curve.  */\n  int knunion;         /* Number of knots in union knot vector.           */\n  int knvert;          /* Number of vertices of cross derivative curve.   */\n  int kn;              /* Number of vertices of cross derivative curve.   */\n  int kder = 0;        /* Number of derivatives of curve to compute.      */\n  int kind = pcurve1->ikind; /* Kind of curve.                     */\n  int kdim = pcurve1->idim;  /* Dimension of geometry space.       */\n  int kcopy = 1;             /* Parameter to newCurve.             */\n  int knlr = 0;              /* Parameter used in s1891.           */\n  int knrc = 0;              /* Parameter used in s1891.           */\n  int kopen = SISL_CRV_OPEN; /* Parameter used in s1891.           */\n  int *lder = 0;             /* Parameter to the interpolation.    */\n  double tpar;         /* Parameter value of interpolation point.  */\n  double tmin1,tmax1;  /* Parameter interval of first derivative curve.   */\n  double tmin2,tmax2;  /* Parameter interval of second derivative curve.  */\n  double tval1,tval2;  /* Values of blending functions.   */\n  double *stunion = SISL_NULL;  /* Union of knot vectors of derivative curves. */\n  double *stcross = SISL_NULL;  /* Knot vector of cross tangent curve.         */\n  double *spar = SISL_NULL;     /* Array containing parameter values of \n\t\t\t      interpolation points.       */\n  double *sbcoef = SISL_NULL;   /* Vertices of cross tangent curve.   */\n  double *spoint = SISL_NULL;   /* Interpolation points.       */\n  double *sder1 = SISL_NULL;\n  double *sder2 = SISL_NULL;    /* Value of second derivative curve.  */\n\n  /* Test input dimensions.  */\n\n  if (pcurve2->idim != kdim) goto err106;\n  \n  /* Test if the parameter intervals of the derivative curves are equal.\n     First pick parameter intervals.  */\n\n  s1363(pcurve1,&tmin1,&tmax1,&kstat);\n  if (kstat < 0) goto error;\n  \n  s1363(pcurve2,&tmin2,&tmax2,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Test parameter intervals.  */\n\n  if (tmin1 != tmin2 || tmax1 != tmax2) goto err121;\n  \n  /* Find order of cross tangent curve.  */\n\n  korder = MAX(pcurve1->ik+ik1-1,pcurve2->ik+ik2-1);\n  \n  /* Find union of knot vectors of derivative vectors.  */\n\n  s6takeunion(pcurve1->et,pcurve1->ik+pcurve1->in,pcurve2->et,\n\t  pcurve2->ik+pcurve2->in,&stunion,&knunion,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Compute number of vertices of cross derivative curve.  */\n\n  kk = MAX(ik1,ik2) - 1;\n  knvert = knunion - korder + kk + kk;\n  \n  /* Allocate scratch for local arrays.  */\n\n  if ((stcross = newarray(korder+knvert,DOUBLE)) == SISL_NULL) goto err101;\n  if ((spar = newarray(knvert,DOUBLE)) == SISL_NULL) goto err101;\n  if ((spoint = newarray(kdim*knvert,DOUBLE)) == SISL_NULL) goto err101;\n  if ((sder1 = newarray(kdim,DOUBLE)) == SISL_NULL) goto err101;\n  if ((sder2 = newarray(kdim,DOUBLE)) == SISL_NULL) goto err101;\n  if ((lder = new0array(knvert,INT)) == SISL_NULL) goto err101;\n  \n  /* Produce knot vector of cross tangent curve.  */\n\n  memcopy(stcross+kk,stunion,knunion,DOUBLE);\n  for (ki=1; ki<=kk; ki++)\n    {\n      stcross[kk-ki] = stcross[kk];\n      stcross[knunion+kk+ki-1] = stcross[knunion+kk-1];\n    }\n  \n  /* Set up interpolation conditions.  */\n\n  for (ki=0; ki<knvert; ki++)\n    {\n      /* Compute parameter value of coefficient nr ki.  */\n\n      for (tpar=(double)0.0,kj=1; kj<korder; kj++) tpar += stcross[ki+kj];\n      tpar /= (korder - 1);\n      \n      spar[ki] = tpar;\n      \n      /* Evaluate first blending function.  */\n\n      sh1261_s9evalbez(ecoef1,ik1,tmin1,tmax1,tpar,&tval1,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Evaluate second blending function.  */\n  \n\t\t     sh1261_s9evalbez(ecoef2,ik2,tmin2,tmax2,tpar,&tval2,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Evaluate first derivative curve.  */\n\n      s1221(pcurve1,kder,tpar,&kleft,sder1,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Evaluate second derivative curve.  */\n\n      s1221(pcurve2,kder,tpar,&kleft,sder2,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Compute interpolation point.  */\n\n      for (kj=0; kj<kdim; kj++)\n\tspoint[ki*kdim+kj] = tval1*sder1[kj] + tval2*sder2[kj];\n    }\n  \n  /* Perform interpolation.  */\n\n  s1891(spar,spoint,kdim,knvert,1,lder,kopen,stcross,&sbcoef,&kn,korder,\n\tknlr,knrc,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Create cross tangent curve.  */\n    if ((*rcrtanc = newCurve(kn,korder,stcross,sbcoef,\n\t\t\t   kind,kdim,kcopy)) == SISL_NULL) goto err101;\n    (*rcrtanc)->cuopen = MAX(pcurve1->cuopen,pcurve2->cuopen);\n  \n  /* Cross tangent curve produced. */\n\n  *jstat = 0;\n  goto out;\n  \n  /* Error in scratch allocation.  */\n\n  err101 :\n    *jstat = -101;\n  goto out;\n  \n  /* Error in input. Conflicting dimensions.  */\n\n  err106 :\n    *jstat = -106;\n  goto out;\n\n  /* Error in input. Derivative curves are not represented on the same\n     parameter interval.  */\n\n  err121 :\n    *jstat = -121;\n  goto out;\n  \n\n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n  goto out;\n  \n  out :     \n    /* Free space occupied by local arrays.  */\n\n    if (stunion != SISL_NULL) freearray(stunion);\n  if (stcross != SISL_NULL) freearray(stcross);\n  if (sbcoef != SISL_NULL) freearray(sbcoef);\n  if (spar != SISL_NULL) freearray(spar);\n  if (spoint != SISL_NULL) freearray(spoint);\n  if (sder1 != SISL_NULL) freearray(sder1);\n  if (sder2 != SISL_NULL) freearray(sder2);\n  if (lder != SISL_NULL) freearray(lder);\n  \n  return;\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\n   static\n      void\n\t    sh1261_s9evalbez(double ecoef[],int iorder,double amin,\n\t\t\t     double amax,double apar,double *cvalue,int *jstat)\n#else\t       \nstatic void sh1261_s9evalbez(ecoef,iorder,amin,amax,apar,cvalue,jstat)\n     int iorder,*jstat;\n     double ecoef[],amin,amax,apar,*cvalue;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Evaluate one-dimensional Bezier curve. Compute value\n*              at given parameter value.\n*\n*\n*\n* INPUT      : ecoef      - Vertices of curve.\n*              iorder     - Order of curve.\n*              amin       - Start parameter value of parameter interval.\n*              amax       - End parameter value of parameter interval.\n*              apar       - Parameter value of point to evaluate.\n*                       \n*\n* OUTPUT     : cvalue     - Value of curve.\n*              jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        :\n*\n*-\n* CALLS      : \n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 06.90.\n*\n*********************************************************************\n*/\n{\n  int ki,kj;\n  double *scoef = SISL_NULL;\n  double tdist = amax - amin;\n  \n  /* Test input.  */\n\n  if ( DEQUAL(tdist,DZERO)  )\n    {\n      *cvalue = ecoef[0];\n      *jstat = 1;\n      goto out;\n    }\n  \n  /* Copy coeficient array to local array. First create local array.  */\n\n  if ((scoef = newarray(iorder,DOUBLE)) == SISL_NULL) goto err101;\n  memcopy(scoef,ecoef,iorder,DOUBLE);\n  \n  /* Evaluate Bezier curve by subdividing in the parameter value apar. */\n\n  for (ki=1; ki<iorder; ki++)\n    for (kj=0; kj<iorder-ki; kj++)\n      scoef[kj] = (apar-amin)*scoef[kj+1]/tdist + (amax-apar)*scoef[kj]/tdist;\n  \n  /* Curve evaluated. */\n\n  *cvalue = scoef[0];\n  *jstat = 0;\n  goto out;\n  \n\n  /* Error in scratch allocation.  */\n\n  err101 :\n    *jstat = -101;\n  goto out;\n  \n  out :\n    /* Free space occupied by local array.  */\n\n    if (scoef != SISL_NULL) freearray(scoef);\n\n  return;\n}\n\n"
  },
  {
    "path": "src/sh1262.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define SH1262\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void sh1262_s9blendcoef(double [],double [],double [],int,int,double *,\n\t\t\t       double *,int *);\nstatic void sh1262_s9blendder(double [],double  [],int,int,int,double,double,\n\t\t\t      double,double,double [],double [],double [],\n\t\t\t      double [],int *);\nstatic void sh1262_s9hermit(double [],int,double,double,int,int *);\n#else\nstatic void sh1262_s9blendcoef();\nstatic void sh1262_s9blendder();\nstatic void sh1262_s9hermit();\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      sh1262(SISLCurve *vcurve[],int iedge,int inmbx,double ecoef[],int *jstat)\n#else\t \nvoid sh1262(vcurve,iedge,inmbx,ecoef,jstat)\n     int iedge,inmbx,*jstat;\n     double ecoef[];\n     SISLCurve *vcurve[];\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find coefficients of cubic blending functions used to\n*              blend two derivative curves along each edge of a vertex\n*              region into a cross derivative curve pr edge.\n*\n*\n*\n* INPUT      : qcurve     - Array containing pointers to edge curves \n*                           of the surfaces around the vertex region.\n*                           For each edge the position edge curve and\n*                           the derivative curves in the two parameter\n*                           directions of the surface, is given. The\n*                           sequence is the following : Position curve\n*                           along first edge, cross derivative curve along\n*                           first edge, derivative curve along first\n*                           edge, position curve along second edge, etc.\n*                           Dimension of the array is 3*iedge.\n*              iedge      - Number of edges of the vertex region.\n*                           iedge = 3, 4, 5 or 6.\n*              inmbx      - Number of coefficients of all the blending\n*                           functions.\n* \n*\n* OUTPUT     : ecoef      - Coefficients of blending functions. There is\n*                           two blending functions for each edge and the\n*                           functions are represented as one-dimensional \n*                           cubic Bezier curves. Then the number of coefficients \n*                           of each function is 4. First all the blending\n*                           functions corresponding to the first derivative\n*                           curve are represented counter clockwise around the\n*                           region, the all the functions corresponding to \n*                           the second derivative curve are stored. The dimension\n*                           of the array is inmbx, i.e. 2*4*iedge.\n*                           \n*              jstat      - status messages  \n*                                         = 2      : Requirements on tangent\n*                                                    not satisfied completely.\n*                                         = 1      : Requirements on twist\n*                                                    not satisfied completely.\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        : \n*\n*-\n* CALLS      : s1221          - Evaluator of B-spline curve.   \n*              s6crss         - Cross product of two vectors.  \n*              s6scpr         -  Scalar product of two vectors. \n*              sh1262_s9blendcoef    - \n*              sh1262_s9blendder     -\n*              sh1262_s9hermit       -\n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 06.90.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;     /* Status variable.     */\n  int kstat1 = 0;    /* Status variable used to check if the requirements\n\t\t\tto input is satisfied.         */\n  int ki,kj,kk;      /* Counters.            */\n  int ki4,ki12;      /* ki4 = 4*ki, and ki12 = 12*ki.  */\n  int kj4,kj12;      /* kj4 = 4*kj, and kj12 = 12*kj.  */\n  int kdim = 3;      /* Dimension of geometry space.   */\n  int kleft = 0;     /* Parameter used in curve evaluation.  */\n  int kder = 1;      /* Number of derivatives of curve to evaluate. */\n  int kncurve = 3*iedge;  /* Number of input curves.   */\n  int kncond = 4*iedge;   /* Number of coeffecients of blending\n                             functions corresponding to derivative\n                             curves in one parameter direction.    */\n  int ksign;              /* Indicates if the tangent along a\n                             position curve and the cross tangent\n                             of the adjacent edge in a corner is\n                             to have the same sign.                */\n  int krang;              /* Rang of equation system used to find derivatives\n                             in endpoints  of blending functions. */\n  double ang_tol = (double)0.00001;   /* Tolerance used in computing the\n\t\t\t\t\t space spanned by tang. vectors. */\n  double tfac;            /* Used in linearity test of blending function. */\n  double tref=(double)0.0; /* Refereance value in equality test.  */\n  double tpar1,tpar2;     /* Endpoints of parameter interval of curve. */\n  double thelp1,thelp2,thelp3,thelp4;   /* Help variables in computation \n\t\t\t\t\t   of rang.    */\n  double tnorm1,tnorm2;   /* Lenght of normals.        */\n  double *spar1 = SISL_NULL;   /* Startpoints of parameter intervals of \n                             input curves.       */\n  double *spar2 = SISL_NULL;   /* Endpoints of parameter intervals of \n                             input curves.       */\n  double *sder = SISL_NULL;    /* Result of curve evaluation. The values are\n                             stored as follows : Value and first derivative\n                             of all curves corresponding to an edge in\n                             first endpoint, the same values in the second\n                             endpoint. All curves of one edge is treated\n                             before the curve of the next edge is treated. */\n  double sa[12];          /* Matrix of equation system used to find\n                             derivatives of blending functions.     */\n  double sb[3];           /* Right side of equation system.         */\n  double snorm1[3];       /* Normal of tangent plane at a corner of\n                             the vertex region.                     */\n  double snorm2[3];       /* Normal of tangent plane at a corner of\n                             the vertex region.                     */\n  SISLCurve *qc;              /* Pointer to curve.                      */\n  \n  /* Test input.  */\n\n  for (ki=0; ki<iedge; ki++)\n    if (vcurve[ki]->idim != kdim) goto err104;\n  \n  /* Allocate space for array containing results of curve evaluation.  */\n  \n  if ((sder = newarray(12*kdim*iedge,DOUBLE)) == SISL_NULL) goto err101;\n  if ((spar1 = newarray(kncurve,DOUBLE)) == SISL_NULL) goto err101;\n  if ((spar2 = newarray(kncurve,DOUBLE)) == SISL_NULL) goto err101;  \n  \n  /* Evaluate boundary curves in the  endpoints.  */\n\n  for (ki=0; ki<kncurve; ki++)\n    {\n      qc=vcurve[ki];\n      \n      /* Fetch parameter values at endpoints.  */\n\n      spar1[ki] = tpar1 = *(qc->et + qc->ik - 1);\n      spar2[ki] = tpar2 = *(qc->et + qc->in);\n      \n      kj = ki/3;\n      kk = ki % 3;\n      \n      /* Evaluate curve in startpoint.  */\n\n      s1221(qc,kder,tpar1,&kleft,sder+2*(6*kj+kk)*kdim,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Evaluate curve in endpoint.  */\n\n      s1221(qc,kder,tpar2,&kleft,sder+2*(6*kj+kk+3)*kdim,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* Compute first and last coefficients of blending functions, i.e find\n     value of blending functions in the endpoints.  */\n\n  for (ki=0; ki<iedge; ki++)\n    {\n      /* For each edge, make sure that the endpoints of the cross tangent \n\t curve is equal (possibly expect from a sign) to the tangents of the\n         position curve along the adjacent edges.  */\n\n      kj = (ki > 0) ? ki-1 : iedge-1;\n      ki4 = 4*ki, ki12 = 12*ki;\n      kj4 = 4*kj, kj12 = 12*kj;\n      \n      /* Treat startpoint of edge.  */\n\n      ksign = -1;\n      sh1262_s9blendcoef(sder+(ki12+2)*kdim,sder+(ki12+4)*kdim,sder+(kj12+7)*kdim,\n\t\t  kdim,ksign,ecoef+ki4,ecoef+kncond+ki4,&kstat);\n      if (kstat < 0) goto error;\n      kstat1 = MAX(kstat,kstat1);\n      \n      /* Treat endpoint of edge.  */\n\n      ksign = 1;\n      sh1262_s9blendcoef(sder+(ki12+8)*kdim,sder+(ki12+10)*kdim,\n\t\t  sder+(((ki+1)%iedge)*12+1)*kdim,\n\t\t  kdim,ksign,ecoef+ki4+3,ecoef+kncond+ki4+3,&kstat);\n      if (kstat < 0) goto error;\n      kstat1 = MAX(kstat,kstat1);\n    }\n  \n  for (tref=(double)0.0, ki=0; ki<iedge; ki++)\n    {\n      /* For each edge, set up an equation system to find the derivatives\n\t of the blending functions excisting at the corner lying at the \n\t startpoint of the edge (also the blending functions corresponding\n\t to the previous edge). The equation system represent the conditions\n\t to be satisfied to have a consistent twist vector in this corner. */\n\n      kj = (ki > 0) ? ki-1 : iedge-1;\n      ki4 = 4*ki, ki12 = 12*ki;\n      kj4 = 4*kj, kj12 = 12*kj;\n      \n      for (kk=0; kk < kdim; kk++)\n\t{\n          sa[kk*4] = sder[(ki12+2)*kdim+kk];\n\t  sa[kk*4+1] = sder[(ki12+4)*kdim+kk];\n\t  sa[kk*4+2] = sder[(kj12+8)*kdim+kk];\n\t  sa[kk*4+3] = sder[(kj12+10)*kdim+kk];\n\n\t  sb[kk] = - ecoef[ki4]*sder[(ki12+3)*kdim+kk]\n\t    - ecoef[kncond+ki4]*sder[(ki12+5)*kdim+kk]\n\t    - ecoef[kj4+3]*sder[(kj12+9)*kdim+kk]\n\t\t- ecoef[kncond+kj4+3]*sder[(kj12+11)*kdim+kk];\n\t  \n\t  tref = MAX(tref,MAX(sa[kk*4],sa[kk*4+1]));\n\t  tref = MAX(tref,MAX(sa[kk*4+2],sa[kk*4+3]));\n\t}\n\n      /* Find rang of equation system, i.e. check wether the 4\n\t tangent vectors are able to span a plane.   */\n\n      s6crss(sder+(ki12+2)*kdim,sder+(ki12+4)*kdim,snorm1);\n      tnorm1 = s6length(snorm1,kdim,&kstat);\n      \n      s6crss(sder+(kj12+8)*kdim,sder+(kj12+10)*kdim,snorm2);\n      tnorm2 = s6length(snorm2,kdim,&kstat);\n      \n      thelp1 = s6ang(snorm1,sder+(kj12+8)*kdim,kdim);\n      thelp2 = s6ang(snorm1,sder+(kj12+10)*kdim,kdim);\n\n      thelp3 = s6ang(snorm2,sder+(ki12+2)*kdim,kdim);\n      thelp4 = s6ang(snorm2,sder+(ki12+4)*kdim,kdim);\n\n      if ((DNEQUAL(tnorm1+tref,tref) && \n\t   fabs(thelp1-PIHALF) < ang_tol &&\n\t   fabs(thelp2-PIHALF) < ang_tol) ||\n\t  (DNEQUAL(tnorm2+tref,tref) &&\n\t   fabs(thelp3-PIHALF) < ang_tol &&\n\t   fabs(thelp4-PIHALF) < ang_tol) ||\n\t  (DEQUAL(tnorm1+tref,tref) &&\n\t   (fabs(thelp1-PIHALF) < ang_tol ||\n \t    fabs(thelp2-PIHALF) < ang_tol)) ||\n\t  (DEQUAL(tnorm2+tref,tref) &&\n\t   (fabs(thelp3-PIHALF) < ang_tol ||\n \t    fabs(thelp4-PIHALF) < ang_tol)) ||\n\t  (DEQUAL(tnorm1+tref,tref) && DEQUAL(tnorm2+tref,tref)))\n\tkrang = 2;\n      else\n\tkrang = 3;\n      \n      /* Estimate derivatives in the current endpoints of the blending \n\t functions existing in this corner.  */\n\n\tsh1262_s9blendder(sa,sb,4,kdim,krang,spar1[3*ki],spar2[3*ki],spar1[3*kj],\n\t\t spar2[3*kj],ecoef+ki4,ecoef+kncond+ki4,ecoef+kj4,\n\t\t ecoef+kncond+kj4,&kstat);\n      if (kstat < 0) goto error;\n      kstat1 = MAX(kstat,kstat1);\n    }\n   \n  for (ki=0; ki<iedge; ki++)\n    {\n      /* Interpolate blending curves.  */\n\n       sh1262_s9hermit(ecoef+4*ki,4,spar1[3*ki],spar2[3*ki],1,&kstat);\n      if (kstat < 0) goto error;\n\n      sh1262_s9hermit(ecoef+kncond+4*ki,4,spar1[3*ki],spar2[3*ki],1,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Test blending curves. If the coeffecients deviate much from\n\t those of a linear curve, they are linearized. In addition, the\n\t coefficients of the blending curve corresponding to the input\n\t cross derivative curve is not allowed to be negative.      */\n      \n      tfac = MAX(MAX(fabs(ecoef[4*ki+3]),fabs(ecoef[4*ki])),\n\t\t  MAX(fabs(ecoef[kncond+4*ki+3]),fabs(ecoef[kncond+4*ki])));\n      for (kj=1; kj<3; kj++)\n      {\n\t if (ecoef[4*ki+kj] < MIN(ecoef[4*ki+3],ecoef[4*ki])-tfac ||\n\t     ecoef[4*ki+kj] > MAX(ecoef[4*ki+3],ecoef[4*ki])+tfac ||\n\t     ecoef[4*ki+kj] < DZERO)\n\t {\n\t    ecoef[4*ki+kj] = ((double)(3-kj)*ecoef[4*ki] +\n\t       (double)kj*ecoef[4*ki+3])/(double)3.0;\n\t    kstat1 = MAX(kstat1,1);\n\t }\n\t \n\t if (ecoef[kncond+4*ki+kj] < \n\t     MIN(ecoef[kncond+4*ki+3],ecoef[kncond+4*ki])-tfac ||\n\t     ecoef[kncond+4*ki+kj] > \n\t     MAX(ecoef[kncond+4*ki+3],ecoef[kncond+4*ki])+tfac)\n\t {\n\t    ecoef[kncond+4*ki+kj] = ((double)(3-kj)*ecoef[kncond+4*ki] +\n\t       (double)kj*ecoef[kncond+4*ki+3])/(double)3.0;\n\t    kstat1 = MAX(kstat1,1);\n\t }\n      }\n    }\n  \n  \n  /* Coefficients of blending functions found.  */\n\n  *jstat = kstat1;\n  goto out;\n  \n  /* Error in scratch allocation.  */\n\n  err101 :\n    *jstat = -101;\n  goto out;\n  \n  /* Error in input. Dimension not equal to 3.  */\n\n  err104 :\n    *jstat = -104;\n  goto out;\n  \n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n  goto out;\n  \n  out :\n    \n    /* Free space occupied by local arrays.  */\n\n    if (sder != SISL_NULL) freearray(sder);\n  if (spar1 != SISL_NULL) freearray(spar1);\n  if (spar2 != SISL_NULL) freearray(spar2);\n\n  return;\n}\n\n\t\t\t\t\t\n#if defined(SISLNEEDPROTOTYPES)\n   static\n      void\n\t    sh1262_s9blendcoef(double evecu[],double evecv[],double etang[],\n\t\t\t       int idim,int isign,double *coef1,\n\t\t\t       double *coef2,int *jstat)\n#else\nstatic void sh1262_s9blendcoef(evecu,evecv,etang,idim,isign,coef1,coef2,jstat)\n     int idim,isign,*jstat;\n     double evecu[],evecv[],etang[],*coef1,*coef2;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Given three vectors, evecu, evecv and etang, find the \n*              coefficients, coef1 and coef2, such that the vector\n*              coef1*evecu + coef2*evecv, is as close as possible\n*              to the vector etang. If the three vectors lie in a\n*              plane, coef1*evecu + coef2*evecv = etang.\n*              \n*\n* INPUT      : evecu      - First vector.\n*              evecv      - Second vector.\n*              etang      - Vector to approximate.\n*              idim       - Dimension of geometry space.\n*              isign      - Sign with wich etang is to be multiplied.\n*\n*\n* OUTPUT     : coef1      - First factor.\n*              coef2      - Second factor.\n*              jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Minimize the square of the expression \n*                   dist(coef1*evecu+coef2*evecv,isign*etang)\n*              over coef1 and coef2.\n*              The expression is differentiated and set equal to\n*              zero. Then this equation system of 2 equations\n*              with two unknowns is solved.\n*\n*********************************************************************\n*/\n{\n  \n  int kstat = 0;           /* Status variable.                    */\n  int ki;                  /* Counter.                            */\n  double tdotuu;           /* Scalar product of evecu and evecu.  */\n  double tdotuv;           /* Scalar product of evecu and evecv.  */\n  double tdotutang;        /* Scalar product of evecu and etang.  */\n  double tdotvv;           /* Scalar product of evecv and evecv.  */\n  double tdotvtang;        /* Scalar product of evecv and etang.  */\n  double tdiv;             /* Determinant of equation system.     */\n  \n  /* Set output to zero. */\n\n  *coef1 = (double)0.0;\n  *coef2 = (double)0.0;\n  \n  /* Compute coefficients of equation system.  */\n\n  tdotuu = s6scpr(evecu,evecu,idim);\n  tdotuv = s6scpr(evecu,evecv,idim);\n  tdotutang = (double)isign*s6scpr(evecu,etang,idim);\n  tdotvv = s6scpr(evecv,evecv,idim);\n  tdotvtang = (double)isign*s6scpr(evecv,etang,idim);\n\n  tdiv = tdotuv*tdotuv - tdotuu*tdotvv;\n  if (DEQUAL(tdiv,DZERO))\n    {\n      if (DEQUAL(tdotuu,DZERO) && DEQUAL(tdotvv,DZERO));\n      else if (DEQUAL(tdotuu,DZERO))\n\t  *coef2 = s6length(etang,idim,&kstat)/sqrt(tdotvv);\n      else\n\t*coef1 = s6length(etang,idim,&kstat)/sqrt(tdotuu);\n      goto out;\n    }\n  \n  /* Compute output factors.  */\n\n  *coef1 = (tdotvtang*tdotuv - tdotutang*tdotvv)/tdiv;\n  *coef2 = (tdotutang*tdotuv - tdotvtang*tdotuu)/tdiv;\n\n  /* Test result.  */\n\n  for (ki=0; ki<idim; ki++)\n    if (fabs((*coef1)*evecu[ki]+(*coef2)*evecv[ki]-isign*etang[ki]) > REL_PAR_RES) \n      break;\n  \n  if (ki < idim) goto warn1;\n\n  *jstat = 0;\n  goto out;\n  \n  /* Equality not achieved.  */\n\n  warn1 :\n    *jstat = 2;\n  goto out;\n  \n  out :\n    return;\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\n   static\n      void\n\t    sh1262_s9hermit(double econd[],int icond,double astart,\n\t\t\t    double aend,int idim,int *jstat)\n#else\nstatic void sh1262_s9hermit(econd,icond,astart,aend,idim,jstat)\n     int icond,idim,*jstat;\n     double econd[],astart,aend;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Hermite interpolation of position derivative in the\n*              two endpoints represented as a Bezier curve on the interval \n*              [astart,aend]. icond is expected to be 4.\n*              \n*\n*\n*\n* INPUT      : icond      - Number of interpolation conditions. \n*                           icond = 4.\n*              astart     - Start of parameter interval.\n*              aend       - End of parameter interval\n*              idim       - Dimension of geometry space.\n*\n*\n* INPUT/OUTPUT : econd    - Interpolation conditions as input, Bezier coefficients\n*                           as output. The dimension is icond*idim.\n*                       \n*\n* OUTPUT     : jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n*********************************************************************\n*/\n{\n  int ki;    /* Index.  */\n\n  /* Test input. The number of conditions has to be 4.  */\n\n  if (icond != 4) goto err001;\n  \n  /* Hermit interpolation with Bezier curve of order 4.  */\n\n  for (ki=0; ki<idim; ki++)\n    {\n      econd[idim+ki] = ONE_THIRD*(aend-astart)*econd[idim+ki] + econd[ki];\n      econd[2*idim+ki] = -ONE_THIRD*(aend-astart)*econd[2*idim+ki] + econd[3*idim+ki];\n    }\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in input. Number of coefficients not 4.  */\n\n  err001 :\n    *jstat = -1;\n  goto out;\n  \n  out :\n    return;\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\n   static\n      void\n\t    sh1262_s9blendder(double ea[],double eb[],int ix,int ieq,\n\t\t\t      int irang,double astarti,double aendi,\n\t\t\t      double astartj,double aendj,double ealfai[],\n\t\t\t      double ebetai[],double ealfaj[],\n\t\t\t      double ebetaj[],int *jstat)\n#else\nstatic void sh1262_s9blendder(ea,eb,ix,ieq,irang,astarti,aendi,astartj,aendj,ealfai,\n\t\t       ebetai,ealfaj,ebetaj,jstat)\n     int ix,ieq,irang,*jstat;\n     double ea[],eb[],astarti,aendi,astartj,aendj,ealfai[],ebetai[],\n       ealfaj[],ebetaj[];\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Estimate the derivatives in one endpoint of the blending \n*              functions meeting in a corner of a vertex region.\n*\n*\n* INPUT      : ea         - Matrix containg coefficients in equation\n*                           system representing conditions on the \n*                           derivatives.\n*              eb         - Rigth side of equation system.\n*              ix         - Number of coefficients. ix = 4.\n*              ieq        - Number of equations. ieq = 3.\n*              irang      - Rang of equation system.\n*\n*\n* INPUT/OUTPUT : ealfai   - Position and derivatives or first blending \n*                           function along first adjacent edge.\n*                           Estimate derivative of first endpoint.\n*                ebetai   - Position and derivatives or second blending \n*                           function along first adjacent edge.\n*                           Estimate derivative of first endpoint.\n*                ealfaj   - Position and derivatives or first blending \n*                           function along second adjacent edge.\n*                           Estimate derivative of second endpoint.\n*                ebetaj   - Position and derivatives or second blending \n*                           function along second adjacent edge.\n*                           Estimate derivative of second endpoint.\n*                \n* \n* OUTPUT     : jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES : \n*              \n*\n* USE        : \n*\n*-\n* CALLS      : s6lufacp - LU-factorizing of matrix in equation system. \n*              s6lusolp - Solve equtaion system. Matrix is LU-factorized. \n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 06.90.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;          /* Status variable.  */\n  int ki,kj,kk,kh;        /* Counters.         */\n  int l[2][2];            /* Pointer to lines of equation system to be used\n                             when solving with respect to two unknowns.   */\n  int lpiv[3];            /* Pivoting array. Used in LU-factorizing.      */\n  int kcount;             /* Number of iterations used to find derivatives. */\n  double teps = 0.001;    /* Local tolerance.                             */\n  double tdiff;           /* Difference between derivatives of linear blending\n                             function and current blending function.      */\n  double tdum;            /* Used in testing of result.                   */\n  double tdet;            /* Current determinant of equation system.      */\n  double sdet[2];         /* Determinant of equation system.              */\n  double sx[4];           /* Derivative of linear blending funtion.       */\n  double sxx[4];          /* Derivative of current cubic blending funtion. */\n  double sb[3];           /* Rigth side of local equation system.         */\n  double smat[9];         /* Matrix of local eqution system.              */\n  \n  /* Test input.  */\n\n  if (ix != 4 || ieq != 3) goto err001;\n  \n  /* Set up derivatives of linear blend.  */\n\n  sx[0] = (ealfai[3] - ealfai[0])/(aendi - astarti);\n  sx[1] = (ebetai[3] - ebetai[0])/(aendi - astarti);\n  sx[2] = (ealfaj[3] - ealfaj[0])/(aendj - astartj);\n  sx[3] = (ebetaj[3] - ebetaj[0])/(aendj - astartj);  \n  \n  if (irang == 2)\n    {\n      /* Rang of equation system equal to 2. */\n      /* Find equations to be used, i.e. find the lines in the\n\t equation system which gives the most stable 2x2 equation\n\t system when finding the 2 last derivatives when the 2\n\t first are set.  */\n\n      sdet[0] = sdet[1] = (double)0.0;\n      \n      for (ki=0; ki<ieq; ki++)\n\tfor (kj=ki+1; kj<ieq; kj++)\n\t  for (kk=0,kh=0; kh<2; kk+=2,kh++)\n\t    {\n\t      tdet = ea[4*ki+kk]*ea[4*kj+kk+1] - ea[4*ki+kk+1]*ea[4*kj+kk];\n\t      if (fabs(tdet) > fabs(sdet[kh]))\n\t\t{\n\t\t  sdet[kh] = tdet;\n\t\t  l[kh][0] = ki, l[kh][1] = kj;\n\t\t}\n\t    }\n      for (kh=0; kh<2; kh++)\n\tif (DEQUAL(sdet[kh],DZERO)) sdet[kh] = (double)1.0;\n      \n      kcount = 0;\n      \n      /* Set the two first derivatives equal to those of a corresponding\n\t linear blending function.   */\n\n      ki = 0, kk = 2;\n      sxx[ki] = sx[ki];\n      sxx[ki+1] = sx[ki+1];\n      \n      while (1)\n\t{\n\t  /* Iterate until the conditions on the derivatives is satisfied\n\t     and the difference from the linear case is eqal for all \n\t     derivatives or the number of iterations is equal to 4.   */\n\n\t  /* Find right side of local equation system for finding the \n\t     remaining two derivatives.   */\n\n\t  for (kj=0; kj<ieq; kj++)\n\t    sb[kj] = eb[kj] - ea[4*kj+ki]*sxx[ki] - ea[4*kj+ki+1]*sxx[ki+1];\n\t  \n\t  /* Compute the remaining two derivatives.  */\n\n\t  kj = kk/2;\n\t  sxx[kk] = (-ea[4*l[kj][0]+kk+1]*sb[l[kj][1]] \n\t\t       + ea[4*l[kj][1]+kk+1]*sb[l[kj][0]])/sdet[kj];\n\t  sxx[kk+1] = (ea[4*l[kj][0]+kk]*sb[l[kj][1]] \n\t\t       - ea[4*l[kj][1]+kk]*sb[l[kj][0]])/sdet[kj];\n\t  \n\t  /* Check if the difference between current derivatives and \n\t     derivatives of a linear blend is small.  */\n\n\t  tdiff = fabs(sxx[0] - sx[0]);\n\t  for (kh=1; kh<4; kh++)\n\t    if (fabs(tdiff-fabs(sxx[kh]-sx[kh])) > teps) break;\n\t  \n\t  if (kh == 4 || kcount == 4) break;   /* Stop iteration.  */\n\t  \n\t  /* Initiate next iteration step.  */\n\n\t  sxx[kk] = (sx[kk] + sxx[kk])/(double)2.0;\n\t  sxx[kk+1] = (sx[kk+1] + sxx[kk+1])/(double)2.0;\n\t  \n\t  ki = (ki + 2) % 4;\n\t  kk = (kk + 2) % 4;\n\n\t  kcount++;\n\t}\n    }\n  else if (irang == 3)\n    {\n      /* Rang of equation system equal to 3. */\n      ki = 0;\n      kcount = 0;\n      \n      while (1)\n\t{\n\t  /* Iterate until the conditions on the derivatives is satisfied\n\t     and the difference from the linear case is eqal for all \n\t     derivatives or the number of iterations is equal to 4.   */\n\n\t  /* Set the current derivative equal to those of a corresponding\n\t     linear blending function.   */\n\n\t  sxx[ki] = sx[ki];\n\t  \n\t  /* Set up local equation system.  */\n\n\t  for (kj=0; kj<ieq; kj++)\n\t    {\n\t      sb[kj] = eb[kj] - ea[kj*4+ki]*sxx[ki];\n\t      for (kk=0,kh=0; kk<ix; kk++)\n\t\t{\n\t\t  if (kk == ki) continue;\n\t\t  smat[kj*(ix-1)+kh] = ea[kj*ix+kk];\n\t\t  kh++;\n\t\t}\n\t    }\n\t  \n\t  /* Compute the remaining three derivatives.  */\n\n\t  s6lufacp(smat,lpiv,ieq,&kstat);\n\t  if (kstat < 0) goto error;\n\t  \n\t  s6lusolp(smat,sb,lpiv,ieq,&kstat);\n\t  if (kstat < 0) goto error;\n\t  \n\t  for (kk=0,kh=0; kk<ix; kk++)\n\t    {\n\t      if (kk == ki) continue;\n\t      sxx[kk] = sb[kh++];\n\t    }\n\t  \n\t  /* Check if the difference between current derivatives and \n\t     derivatives of a linear blend is small.  */\n\n\t  tdiff = fabs(sxx[0] - sx[0]);\n\t  for (kh=1; kh<4; kh++)\n\t    if (fabs(tdiff-fabs(sxx[kh]-sx[kh])) > teps) break;\n\t  \n\t  if (kh == 4 || kcount == 4) break;   /* Stop iteration.  */\n\t  \n\t  /* Initiate next iteration step.  */\n\n\t  kj = (ki + 1) % 4;\n\t  sxx[kj] = (sx[kj] + sxx[kj])/(double)2.0;\n\t  \n\t  ki = kj;\n\t  kcount++;\n\t}\n      \n    }\n  \n  /* Copy derivatives into output array.  */ \n\n  ealfai[1] = sxx[0];\n  ebetai[1] = sxx[1];\n  ealfaj[2] = sxx[2];\n  ebetaj[2] = sxx[3];\n  \n  /* Test result.  */\n\n  for (ki=0; ki<ieq; ki++)\n    {\n      tdum = (double)0.0;\n      for (kj=0; kj<ix; kj++)\n\ttdum += ea[ki*ix+kj]*sxx[kj];\n      if (fabs(tdum - eb[ki]) > REL_PAR_RES) break;\n    }\n  if (ki < ieq) goto warn1;\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Twist requirement not satisfied completely.  */\n\n  warn1 :\n    *jstat = 1;\n  goto out;\n  \n  /* Error in input.  */\n\n  err001 :\n    *jstat = -1;\n  goto out;\n  \n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n  goto out;\n  \n  out :\n    return;\n}\n"
  },
  {
    "path": "src/sh1263.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define SH1263\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void sh1263_s9makec0(SISLCurve **,int,int *);\nstatic void sh1263_s9checkcrtan(SISLCurve *,int *); \n#else\nstatic void sh1263_s9makec0();\nstatic void sh1263_s9checkcrtan(); \n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      sh1263(SISLCurve *vcurve[],int iedge,SISLCurve *vboundc[],int *jstat)\n#else\nvoid sh1263(vcurve,iedge,vboundc,jstat)\n   SISLCurve *vcurve[];\n     int iedge;\n   SISLCurve *vboundc[];\n     int *jstat;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Prepare interpolation conditions for blending an\n*              n-sided vertex region.\n*\n*\n*\n* INPUT      : vcurve     - Array containing pointers to edge curves \n*                           of the surfaces around the vertex region.\n*                           For each edge the position edge curve and\n*                           the derivative curves in the two parameter\n*                           directions of the surface, is given. The\n*                           sequence is the following : Position curve\n*                           along first edge, cross derivative curve along\n*                           first edge, derivative curve along first\n*                           edge, position curve along second edge, etc.\n*                           Dimension of the array is 3*iedge.\n*              iedge      - Number of edges of the vertex region.\n*                           iedge = 3, 4, 5 or 6.\n*                       \n*\n* OUTPUT     : vboundc    - Boundary conditions suitable for vertex blend.\n*                           For each edge a position curve and cross\n*                           derivative curve is given. The sequence is\n*                           position curve of first edge, cross derivative\n*                           curve of first edge, position curve of second\n*                           edge, etc. Dimension of the array is 2*iedge.\n*              jstat      - status messages  \n*                                         = 1      : Requirements on cross\n*                                                    tangent curve not satisfied\n*                                                    completely.\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : If necessary reparametrize the edge-curve in order to avoid\n*              tangent lengths of the position curves which very long.\n*              Blend the derivative curves to produce the cross tangent\n*              curves in such a way that :\n*              1. In a corner of the region, the cross tangent belonging to\n*                 one of the adjacent edges is equal to the tangent belonging\n*                 to the other adjacent edge (except for a sign).\n*              2. The derivatives of the two cross tangent curves meeting in a\n*                 corner are equal, i.e. consistent twist.\n*              Check that the cross tangent curves will not imply intersecting\n*              parameter curves of the blending surfaces.\n*\n*\n* REFERENCES : \n*              \n*\n* USE        : 3D geometry only.\n*\n*-\n* CALLS      : sh1260 - Reparametrize if tangents in endpoints\n*                       of position curve are long.            \n*              sh1261 - Compute cross tangent curve given \n*  \t\t        blending functions.                    \n*              sh1262 - Compute coefficients of cubic blending\n*\t\t        functions.                             \n*              freeCurve - Free space occupied by curve object.   \n*              newCurve  - Create new curve object.  \n*              sh1263_s9checkcrtan() - Routine to be implemented. \n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 06.90.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;        /* Status variable.  */\n  int kstat1 = 0;       /* Status on prepare. */\n  int ki;               /* Counter.          */\n  int kcopy = 1;        /* Indicates that data arrays is to be copied\n\t\t\t   when creating a new curve.                 */\n  int knmbx = 8*iedge;  /* Number of coefficients of blending functions. */\n\n  double tonethird = (double)1.0/(double)3.0;  /* Constant used to check\n\t\t\t\t\t\t  if tangent of position\n\t\t\t\t\t\t  curve is too long.     */\n  double *scoef = SISL_NULL;     /* Array containing coefficients fo blending\n\t\t\t       functions.                                */\n  double (*s1)[4],(*s2)[4]; /* Pointers to coefficients of one blending\n\t\t\t       function.                                 */\n  \n  SISLCurve* (*qc)[3];          /* Pointer to curves corresponding to one \n\t\t\t       edge of the vertex region.                */\n  SISLCurve **qcurve = SISL_NULL;    /* Array of pointers to reparametrized curves.*/\n  SISLCurve *qpt;               /* Pointer to current curve.                 */\n  \n  /* Allocate scratch for arrays used to store equation system.  */\n\n  if ((scoef = newarray(knmbx,DOUBLE)) == SISL_NULL) goto err101;\n  \n  /* Copy input curves to local arrays. First allocate scratch for\n     pointer array.  */\n\n  if ((qcurve = newarray(3*iedge,SISLCurve*)) == SISL_NULL) goto err101;\n  \n  for (ki=0; ki<3*iedge; qpt++,ki++)\n    {\n      qpt=vcurve[ki];\n\n      /* Copy curve.  */\n\n      if ((qcurve[ki] = newCurve(qpt->in,qpt->ik,qpt->et,qpt->ecoef,qpt->ikind,\n\t\t\t\t qpt->idim,kcopy)) == SISL_NULL) goto err101;\n     } \n\n  /* Make sure that all curves are represented with k-tupple knots in\n     the endpoints.  */\n  \n  s1349(3*iedge,qcurve,&kstat);\n  if (kstat < 0) goto error;\n\t\t \n  /* Check if reparametrization is necessary, and in that case perform\n     the reparametrization.  */\n\n  for (ki=0, qc=(SISLCurve*(*)[3])qcurve; ki<iedge; ki++,qc++)\n    {\n       sh1260(tonethird,*qc,3,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* Find the coeffecients of the blending functions.   */\n\n  sh1262(qcurve,iedge,knmbx,scoef,&kstat);\n  if (kstat < 0) goto error;\n\n  kstat1 = kstat;\n  \n  /* kstat may have the following non-negative values :\n            0 - The criterions on the blending functions are satisfied.\n\t    1 - The criterion is not satisfied regarding twist.\n\t    2 - The tangent vectors on some corners are not consistent. */\n  \n  /* Move position curves to output array. Compute and check cross \n     tangent curves.   */\n\n  for (ki=0,s1=(double(*)[4])scoef,s2=s1+iedge; ki<iedge; ki++,s1++,s2++)\n    {\n      /* Set pointer to position curve.  */\n\n      vboundc[2*ki] = qcurve[3*ki];\n      \n      /* Compute cross tangent curve.  */\n\n      sh1261(qcurve[3*ki+1],qcurve[3*ki+2],*s1,4,*s2,4,vboundc+2*ki+1,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Check cross tangent curve. Change curve if necessary. */\n\n      sh1263_s9checkcrtan(vboundc[2*ki+1],&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  if (kstat1 == 2)\n  {\n     /* The tangent conditions in some corner(s) of the vertex region\n\tare not satisfied. Thus, the blending will not be C0 in some\n\tareas. Make sure that the blend is C0, sacrifising the G1-\n\tcondition.      */\n     \n     sh1263_s9makec0(vboundc,iedge,&kstat);\n     if (kstat < 0) goto error;\n  }\n\n  /* Boundary conditions for vertex blend prepared.  */\n\n  *jstat = kstat1;\n  goto out;\n  \n  /* Error in scratch allocation.  */\n\n  err101 :\n    *jstat = -101;\n  goto out;\n  \n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n  goto out;\n  \n  out :\n    \n    /* Free space occupied by local arrays and curves.  */\n\n  if (scoef != SISL_NULL) freearray(scoef);\n  if (qcurve != SISL_NULL)\n    {\n      for (ki=0; ki<3*iedge; ki+=3)\n\t{\n\t  if (qcurve[ki+1] != SISL_NULL) freeCurve(qcurve[ki+1]);\n\t  if (qcurve[ki+2] != SISL_NULL) freeCurve(qcurve[ki+2]);\n\t}\n      freearray(qcurve);\n    }\n  \n  return;\n}\n\n  \n\n\n\n   \n#if defined(SISLNEEDPROTOTYPES)\n   static\n      void\n\t    sh1263_s9makec0(SISLCurve *vbound[],int iedge,int *jstat)\n#else\t       \nstatic void sh1263_s9makec0(vbound,iedge,jstat)\n   SISLCurve *vbound[];\n   int iedge;\n   int *jstat;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : The produced cross tangent curves are in some corners not\n*              consistent with the tangents of the adjacent curves.\n*              Change the cross tangent curves in order to achieve this\n*              consistency.\n*\n*\n*\n* INPUT      : vbound     - Produced boundary curves to vertex blend.\n*              iedge      - Number of edges in vertex region.\n*                       \n*\n* OUTPUT     : vbound     - Boundary curves after modification.\n*              jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        :\n*\n*-\n* CALLS      : s1221, s6lenght\n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 11.92.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;                /* Local status variable.       */\n   int ki,kj,kk,kl;              /* Counters.                    */\n   int kn;                       /* Number of vertices of cross tangent curve.*/\n   int kn2;                      /* Half the number of vertices. */\n   int k1;                       /* Counter.                     */\n   int kdim = vbound[0] -> idim; /* Dimension of geometry space. */\n   int kleft = 0;                /* Parameter used in s1221.     */\n   double tpar1,tpar2;           /* Parameter values of endpoints of curves. */\n   double tref;                  /* Referance value used in comparisement.   */\n   double tmult;                 /* Multiplicator used to smoothen curve.    */\n   double sdiff[3];              /* Difference between wanted and actual\n\t\t\t\t    cross tangent vector.                    */\n   double sder[9];               /* Result of curve evalutation.             */\n   SISLCurve *qcross;            /* Cross tangent curve.                     */\n   SISLCurve *qc;                /* Adjacent position curve.                 */\n   \n   /* Traverse the edges.  */\n   \n   for (ki=0; ki<iedge; ki++)\n   {\n      qcross = vbound[2*ki+1];\n      \n      /* Check if the cross tangent curve is consistent with\n\t the adjacent tangent in the startpoint of the curve. */\n      /* First fetch adjacent curve.   */\n      \n      kj = (ki > 0) ? ki-1 : iedge-1;\n      qc = vbound[2*kj];\n      \n      /* Fetch parameter values at the current corner.  */\n      \n      tpar1 = *(qc->et + qc->in);\n      tpar2 = *(qcross->et + qcross->ik - 1);\n      \n      /* Evaluate curves in corner.  */\n      \n      s1221(qc,1,tpar1,&kleft,sder,&kstat);\n      if (kstat < 0) goto error;\n      \n      s1221(qcross,0,tpar2,&kleft,sder+2*kdim,&kstat);\n      if (kstat < 0) goto error;\n      \n      tref = s6length(sder+kdim,kdim,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Check equality in each dimension. */\n      \n      for (kk=0; kk<kdim; kk++)\n\t if (DNEQUAL(tref+sder[kdim+kk],tref-sder[2*kdim+kk])) break;\n      \n      if (kk < kdim)\n      {\n\t /* Inconsistence. Change the first coefficient of the\n\t    cross tangent curve to be equal to the tangent (the cross \n\t    tangent curve is k-regular). Then smooth this change\n\t    out along the cross tangent curve.  */\n\t \n\t /* The sign of the cross tangent curve and the sign of the\n\t    tangent is opposite.   */\n\t \n\t for (kl=0; kl<kdim; kl++) sder[kdim+kl] *= -(double)1.0;\n\t \n\t /* Find difference between coefficient of cross tangent\n\t    curve and wanted coefficient.  */\n\t \n\t s6diff(sder+kdim,qcross->ecoef,kdim,sdiff);\n\t \n\t /* Change cross tangent curve, most at the corner, then\n\t    smoothen out the effect of the change. */\n\t    \n\t for (kn=qcross->in, kn2=kn/2, k1=0, tmult=(double)1.0;\n\t  k1<kn2; k1++, tmult -= (double)1.0/(double)kn2)\n\t    for (kl=0; kl<kdim; kl++)\n\t       qcross->ecoef[k1*kdim+kl] += tmult*sdiff[kl];\n      }\n\t    \n      /* Check if the cross tangent curve is consistent with\n\t the adjacent tangent in the endpoint of the curve. */\n      /* First fetch adjacent curve.   */\n      \n      kj = (ki < iedge-1) ? ki+1 : 0;\n      qc = vbound[2*kj];\n      \n      /* Fetch parameter values at the current corner.  */\n      \n      tpar1 = *(qc->et + qc->ik - 1);\n      tpar2 = *(qcross->et + qcross->in);\n      \n      /* Evaluate curves in corner.  */\n      \n      s1221(qc,1,tpar1,&kleft,sder,&kstat);\n      if (kstat < 0) goto error;\n      \n      s1221(qcross,0,tpar2,&kleft,sder+2*kdim,&kstat);\n      if (kstat < 0) goto error;\n      \n      tref = s6length(sder+kdim,kdim,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Check equality in each dimension. */\n      \n      for (kk=0; kk<kdim; kk++)\n\t if (DNEQUAL(sder[kdim+kk]+tref,sder[2*kdim+kk]+tref)) break;\n      \n      if (kk < kdim)\n      {\n\t /* Inconsistence. Change the last coefficient of the\n\t    cross tangent curve to be equal to the tangent (the cross \n\t    tangent curve is k-regular). Then smooth this change\n\t    out along the cross tangent curve.  */\n\t \n\t /* Find difference between coefficient of cross tangent\n\t    curve and wanted coefficient.  */\n\t \n\t s6diff(sder+kdim,qcross->ecoef+(qcross->in-1)*kdim,kdim,sdiff);\n\t \n\t /* Change cross tangent curve, most at the corner, then\n\t    smoothen out the effect of the change. */\n\t    \n\t for (kn=qcross->in, kn2=kn/2, k1=kn-1, tmult=(double)1.0;\n\t  k1>kn2; k1--, tmult -= (double)1.0/(double)kn2)\n\t    for (kl=0; kl<kdim; kl++)\n\t       qcross->ecoef[k1*kdim+kl] += tmult*sdiff[kl];\n      }\n      \n   }\n\n  *jstat = 0;\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  goto out;\n  \n  out:\n     return;\n}     \n\n   \n#if defined(SISLNEEDPROTOTYPES)\n   static\n      void\n\t    sh1263_s9checkcrtan(SISLCurve *pcrtan,int *jstat)\n#else\t       \nstatic void sh1263_s9checkcrtan(pcrtan,jstat)\n     int *jstat;\n     SISLCurve *pcrtan;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Check that the current cross tangent curve will not give\n*              rise to a surface with intersecting constant parameter\n*              curves in one parameter direction.\n*\n*\n*\n* INPUT/OUTPUT : pcrtan   - Cross tangent curve.\n*                       \n*\n* OUTPUT     : jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        :\n*\n*-\n* CALLS      : \n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 06.90.\n*\n*********************************************************************\n*/\n{\n\n  *jstat = 0;\n  \n  return;\n}     \n\n   \n   \n\n\n\n\n\n"
  },
  {
    "path": "src/sh1365.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1365.c,v 1.2 2001-03-19 15:59:03 afr Exp $\n *\n */\n\n#define SH1365\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      sh1365(SISLCurve *pcurve,double etau[],int ik,int in,int ileftfix,\n\t     int irightfix,SISLCurve **rnewcurve,double **gmaxerr,\n\t     double **gl2err,int *jstat)\n#else\nvoid sh1365(pcurve,etau,ik,in,ileftfix,\n\t    irightfix,rnewcurve,gmaxerr,gl2err,jstat)\n     SISLCurve *pcurve;\n     double etau[];\n     int ik;\n     int in;\n     int ileftfix;\n     int irightfix;\n     SISLCurve **rnewcurve;\n     double **gmaxerr;\n     double **gl2err;\n     int *jstat;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate an approximation to a given spline pcurve, f,\n*              in a spline space S0 (given by the knot vector and number\n*              of coefficients of the spline pcurve), from a subspace \n*              S1 (given by the knot vector etau which is a subseqence\n*              of the knotvector of pcurve) of dimension in. Both the \n*              input and the output spline is of order ik. The approximation\n*              rnewcurve, g, is to be a least squares approximation to pcurve\n*              in the sense that a weighted sum of the squares of the \n*              B-spline coefficients of f-g (expressed as a spline on the\n*              knotvector of pcurve, i.e. f) is minimized. In addition, the\n*              0 - ileftfix-1 derivatives at the left end of the curve pcurve\n*              and the 0 - irightfix-1 derivatives at the right end of the \n*              curve are to be kept fixed, i.e. there are ileftfix+irightfix\n*              side conditions.\n*\n*\n*\n* INPUT      : pcurve    - Curve to be approximated on a subspace of the spline\n*                          space in which the curve lies.\n*              etau      - Knot vector corresponding to the subspace in which\n*                          the approximating curve will lie.\n*              ik        - Order of approximating curve. Should be the same as \n*                          the order of the input curve.\n*              in        - Number of coefficients of the approximating spline.\n*                          The dimension of the subspace.\n*              ileftfix  - The number of derivatives that are to be kept fixed\n*                          at the left end of the spline.\n*              irightfix - The number of derivatives that are to be kept fixed\n*                          at the right end of the spline.\n*              \n*                       \n*\n* OUTPUT     : rnewcurve  - Curve in the given subspace approximating the\n*                           input spline curve.\n*              gmaxerr    - Array of dimension equal to the dimension of the \n*                           geometry space, containing the absolute value of \n*                           the largest B-spline coefficient of the error f-g\n*                           (see purpose above) in each component when f-g is\n*                           expressed as a spline on the knot vector of f, \n*                           i.e. pcurve.\n*              gl2err     - Array of dimension equal to the dimension of the\n*                           geometry space, containing a weighted L2-norm of\n*                           the B-spline coefficients of the error curve f-g.\n*              jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        : \n*\n*-\n* CALLS      : sh1922, sh1923, sh1924, sh1925, sh1926, sh1927, sh1928,\n*              sh1930, newCurve.\n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 07.90.\n* REWRITTEN BY: Vibeke Skytt, SI, 05.92 on a basis of a routine by\n*               Tom Lyche and Knut Moerken, 08.86 and 12.85.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;            /* Status variable. */\n  int kdim = pcurve->idim;  /* Dimension of geometry space.          */\n  int kkind = 1;            /* Indicates polynomial B-spline curve.  */\n  int kcopy = 1;            /* Copy input arrays when creating a\n\t\t\t       B-spline curve.      */\n  int kn = pcurve->in;      /* Number of vertices of input curve.    */\n  double *scoef = SISL_NULL;     /* Coeffecient array of approximating curve. */\n  double *sa = SISL_NULL;        /* Transformation matrix.  */\n  double *sb = SISL_NULL;\n  int *lfirst = SISL_NULL;\n  int *llast = SISL_NULL;\n  int *l2sta = SISL_NULL;\n  double *sc = SISL_NULL;\n  int kk = pcurve->ik;\n  int knh = in - ileftfix - irightfix;\n\n  /* Test order of input curve. */\n\n  if (kk != ik) goto err109;\n\n  /* Allocate scratch for error estimates.  */\n\n  if ((*gmaxerr = new0array(kdim,DOUBLE)) == SISL_NULL) goto err101;\n  if ((*gl2err = new0array(kdim,DOUBLE)) == SISL_NULL) goto err101;\n  \n  /* Allocate scratch for coefficients of approximating spline.  */\n\n  if ((scoef = newarray(in*kdim,DOUBLE)) == SISL_NULL) goto err101;\n  \n  /* If kn = in then pcurve->et = etau, and the problem is\n     trivial, the solution is the input spline itself resulting in\n     a zero error.  */\n  \n  if (kn == in)\n  {\n     memcopy(scoef,pcurve->ecoef,in*kdim,DOUBLE);\n     \n     /* Express the approximating curve as a curve.  */\n     \n     if ((*rnewcurve = newCurve(in,ik,etau,scoef,kkind,kdim,kcopy)) == SISL_NULL)\n\tgoto err101;\n     (*rnewcurve)->cuopen = pcurve->cuopen;\n  }     \n  else\n  {\n     /* Allocate scratch for local arrays. \n\tAllocate scratch for a transformation matrix. This is a\n\tkn*in matrix, but since at most  elements\n\tare nonzero in each row, it can be stored as a kn*ik\n\tmatrix together with two integer arrays of length kn\n\tindicating the position of the first and last nonzero elements\n\tof each row of the matrix.   \n\tAlso allocate scratch for the coefficient matrix sb of the\n\tnormal equations. This is a in*in symmetric positive definite\n\tmatrix, but since at most ik elemnts are nonzero in each row, it\n\tcan be stored as a in*ik matrix together with an integer array\n\tof length kn indicating the position of the first nonzero element\n\tof each row of sb.    */\n     \n     if ((sa = newarray(kn*ik,DOUBLE)) == SISL_NULL) goto err101;\n     if ((sb = newarray(in*ik,DOUBLE)) == SISL_NULL) goto err101;\n     if ((lfirst = newarray(kn,INT)) == SISL_NULL) goto err101;\n     if ((llast = newarray(kn,INT)) == SISL_NULL) goto err101;\n     if ((l2sta = newarray(kn,INT)) == SISL_NULL) goto err101;\n     \n     /* Compute the refinement matrix sa from etau to pcurve->et.  */\n     \n     sh1922(pcurve->et,kn,ik,etau,in,sa,lfirst,llast,&kstat);\n     if (kstat < 0) goto error;\n\t\t    \n     /* Set up the normal equations.  */\n\t\t    \n     if (ileftfix == 0 && irightfix == 0)\n     {\n\t/* If there is no side constraints, the number of unknowns is\n\t   in and the first unknown is no. 1. */\n\t\n\tsh1926(etau,ik,in,kdim,pcurve->et,pcurve->ecoef,kn,\n\t       sa,lfirst,llast,sb,l2sta,scoef,&kstat);\n\tif (kstat < 0) goto error;\n      }\n     else\n     {\n\t/* Make a local copy of the coefficients of the input spline.\n\t   This is necessary since the right-hand-side of the problem\n\t   will be adjusted and the original data should not be altered. */\n\t\n\tif ((sc = newarray(kn*kdim,DOUBLE)) == SISL_NULL) goto err101;\n\tmemcopy(sc,pcurve->ecoef,kn*kdim,DOUBLE);\n     \n\t/* Enforce the side conditions.  */\n\t\n\tsh1927(etau,ik,in,kdim,pcurve,ileftfix,irightfix,scoef,&kstat);\n\tif (kstat < 0) goto error;\n\t\t       \n        /* There are now in-ileftfix-irightfix unknowns left, and the first\n            of them is no. ileftfix+1.  */\n\t\t       \n        if (knh > 0)\n\t{\n\t   /* Adjust the left squares problem.  */\n\t   \n\t   sh1930(sa,lfirst,llast,sc,scoef,ik,in,kn,kdim,ileftfix,\n\t\t  irightfix,&kstat);\n\t   if (kstat < 0) goto error;\n\t\t\t  \n           /* Set up the normal equations for the modified least\n\t      squares problem.   */\n\t\t\t  \n\t   sh1928(etau,ik,in,kdim,pcurve->et,sc,kn,ileftfix,\n\t\t  irightfix,sa,knh,lfirst,llast,sb,scoef,l2sta,&kstat);\n\t   if (kstat < 0) goto error;\n        }\n     }\n     \n     if (knh > 0)\n     {\n\t/* Calculate the Cholesky factorization of the coefficient\n\t   matrix of the normal equations.  */\n\t\n\tsh1923(sb,knh,ik,l2sta,&kstat);\n\tif (kstat < 0) goto error;\n\t\t       \n        /* Solve the normal equations.  */\n\t\t       \n        sh1924(sb,scoef+ileftfix*kdim,knh,ik,kdim,l2sta,&kstat);\n\tif (kstat < 0) goto error;\n      }\n\n     /* Express the approximating curve as a curve.  */\n     \n     if ((*rnewcurve = newCurve(in,ik,etau,scoef,kkind,kdim,kcopy)) == SISL_NULL)\n\tgoto err101;\n     (*rnewcurve)->cuopen = pcurve->cuopen;\n     \n     /* Multiply by dtau(-1/2) and estimate error.  */\n     \n     sh1925(pcurve,*rnewcurve,kdim,sa,lfirst,llast,*gmaxerr,*gl2err,\n\t    ileftfix,irightfix,&kstat);\n     if (kstat < 0) goto error;\n  }\n  \n  /* Approximation performed.  */\n\n  *jstat = 0;\n  goto out;\n  \n  /* Error in scratch allocation.  */\n\n  err101 :\n    *jstat = -101;\n  goto out;\n  \n  /* Error in input. Order of input and output curve in conflict.  */\n\n  err109 :\n    *jstat = -109;\n  goto out;\n  \n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n  goto out;\n  \n  out :\n\n    /* Free scratch occupied by local arrays.  */\n\n    if (scoef != SISL_NULL) freearray(scoef);\n    if (sc != SISL_NULL) freearray(sc);\n    if (sa != SISL_NULL) freearray(sa);\n    if (sb != SISL_NULL) freearray(sb);\n    if (lfirst != SISL_NULL) freearray(lfirst);\n    if (llast != SISL_NULL) freearray(llast);\n    if (l2sta != SISL_NULL) freearray(l2sta);\n  \n    return;\n}\n"
  },
  {
    "path": "src/sh1369.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1369.c,v 1.4 2001-03-19 15:59:03 afr Exp $\n *\n */\n\n\n#define SH1369\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     sh1369(SISLSurf *ps,double ecentr[],double enorm[],double abigr,\n\t   double asmalr,int idim,double aepsco,double aepsge,\n\tint trackflag,int *jtrack,SISLTrack ***wtrack,\n\tint *jpt,double **gpar,int **pretop,int *jcrv,SISLIntcurve ***wcurve,int *jsurf,SISLIntsurf ***wsurf,int *jstat)\n#else\nvoid sh1369(ps,ecentr,enorm,abigr,asmalr,idim,aepsco,aepsge,\n\ttrackflag,jtrack,wtrack,jpt,gpar,pretop,jcrv,wcurve,jsurf,wsurf,jstat)\n     SISLSurf     *ps;\n     double   ecentr[];\n     double   enorm[];\n     double   abigr;\n     double   asmalr;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jsurf;\n     SISLIntsurf ***wsurf;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find all intersections between a surface and a torus.\n*\n* INPUT      : ps     - Pointer to the surface.\n*              ecentr - The center of the torus (lying in the symmetry plane)\n*              enorm  - Normal of symmetry plane\n*              abigr  - Distance from ecentr to center circle of torus\n*              asmalr - The radius of the torus surface\n*              idim   - Dimension of the space in which the torus\n*                       lies. idim should be equal to two or three.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie continuous.\n*              pretop - Topology info. for single intersection points.\n*                       Intersection curves are stored in wcurve.\n*              jcrv   - Number of intersection curves.\n*              wcurve - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the surface is put into the equation of the\n*              torus achieving a surface in the one-dimensional space.\n*              The zeroes of this surface are found.\n*\n*\n* REFERENCES :  \"How tolerances change in the topology part\n*                of SISL intersections\", MF 17/10/91.\n*\n*-\n* CALLS      : sh1761       - Find point/object intersections.\n*              hp_s1880       - Put intersections into output format.\n*              s1378       - Put surface into torus equation\n*              s6norm      - Normalize vector.\n*              make_sf_kreg   - Ensure k-regularity of surface.\n*              newObject   - Create new object.\n*              newPoint    - Create new point.\n*              freeObject  - Free the space occupied by a given object.\n*              freeIntdat  - Free space occupied by an intersection data.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n* REWRITTEN BY : Bjoern Olav Hoset, SI, 89-06.\n* REVISED BY:  Michael Floater, 93-02. Corrected 1D tolerance.\n* Changed by: Per OEyvind Hvidsten, SINTEF, 94-11.\n*             Added code to handle output parameters jcrv, jsurf\n*             when no intersection was found.\n* Chanbed by : Vibeke Skytt, SINTEF Oslo, 941202. Change in 1D tolerance\n*                                                 after scaling.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;              /* Local status variable.                      */\n  int kpos = 0;               /* Position of error.                          */\n  int kdim=1;                 /* Dimension of surface in surface/point\n\t\t\t\t intersection.                               */\n  int kdeg = 1001;            /* Code that the implice surface is a torus    */\n  double simpli[16];           /* Array for representation of torus-surface   */\n  double snorm[3];            /* Normalized normal vector                    */\n  double spoint[1];           /* SISLPoint in surface/point intersection.        */\n  double *spar = SISL_NULL;        /* Values of intersections in the parameter\n\t\t\t\t area of the second object.\n\t\t\t\t Empty in this case.   */\n  SISLSurf *qs = SISL_NULL;        /* Pointer to surface in\n\t\t\t     surface/point intersection.*/\n  SISLPoint *qp = SISL_NULL;       /* Pointer to point in\n\t\t\t     surface/point intersection.  */\n  SISLObject *qo1 = SISL_NULL;     /* Pointer to surface in\n\t\t\t     object/point intersection. */\n  SISLObject *qo2 = SISL_NULL;     /* Pointer to point in\n\t\t\t     object/point intersection    */\n  SISLIntdat *qintdat = SISL_NULL; /* Intersection result */\n  SISLObject *track_obj=SISL_NULL;\n  SISLSurf *qkreg=SISL_NULL; /* Input surface ensured k-regularity. */\n  double aepsge2;             /* 1 dimensional tolerance. */\n\n  int ki;\n  double nmax=(double)1.0;\n  /* -------------------------------------------------------- */\n\n  if (ps->cuopen_1 == SISL_SURF_PERIODIC ||\n      ps->cuopen_2 == SISL_SURF_PERIODIC)\n  {\n     /* Cyclic surface. */\n\n     make_sf_kreg(ps,&qkreg,&kstat);\n     if (kstat < 0) goto error;\n   }\n  else\n    qkreg = ps;\n\n  /*\n  * Create new object and connect surface to object.\n  * ------------------------------------------------\n  */\n\n  if (!(track_obj = newObject (SISLSURFACE)))\n    goto err101;\n  track_obj->s1 = ps;\n\n  /*\n   * Check dimension.\n   * ----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if (idim != 3) goto err104;\n  if (qkreg -> idim != idim) goto err106;\n\n  /*\n   * Normalize normal vector.\n   * ------------------------\n   */\n\n  (void)s6norm(enorm,idim,snorm,&kstat);\n  if (kstat<0) goto error;\n\n  /*\n   * Put the information concerning the torus in the following sequence\n   * into simpli: Center, normal, big radius, small radius\n   * ------------------------------------------------------------------\n   */\n\n  memcopy(simpli,ecentr,3,DOUBLE);\n  memcopy(simpli+3,snorm,3,DOUBLE);\n  simpli[6] = abigr;\n  simpli[7] = asmalr;\n\n  /*\n   * Put surface into torus equation\n   * -------------------------------\n   */\n\n  s1378(qkreg,simpli,kdeg,idim,&qs,&kstat);\n  if (kstat<0) goto error;\n\n  /*\n   * Create new object and connect surface to object.\n   * ------------------------------------------------\n   */\n\n  if(!(qo1 = newObject(SISLSURFACE))) goto err101;\n  qo1 -> s1 = qs;\n  qo1 -> o1 = qo1;\n\n  /*\n   * Create new object and connect point to object.\n   * ----------------------------------------------\n   */\n\n  if(!(qo2 = newObject(SISLPOINT))) goto err101;\n  spoint[0] = DZERO;\n  if(!(qp = newPoint(spoint,kdim,1))) goto err101;\n  qo2 -> p1 = qp;\n\n  /*\n   * Find intersections.\n   * -------------------\n   */\n\n  /* Apply corrected tolerance.\n     Reference: \"How tolerances change in the topology part\n     of SISL intersections\", MF 23/2/93. */\n\n  aepsge2 = (double)8.0 * aepsge * asmalr * abigr * abigr;\n\n  /* UJK,sept 93, Normalize to get angle tolerances correct */\n  for(ki=0; ki<qs->in1*qs->in2;ki++)\n     nmax = max(fabs(qs->ecoef[ki]),nmax);\n\n  /* VSK, 941202. Justify nmax in order to avoid a too small tolerance. */\n  \n  nmax = MIN(nmax, aepsge2*1.0e11);\n             \n  if (nmax >(double)10.0)\n  {\n     for(ki=0; ki<qs->in1*qs->in2;ki++)\n        qs->ecoef[ki] /= nmax;\n     aepsge2 /= nmax;\n  }\n\n  /* UJK,sept 93, End of change */\n\n  sh1761(qo1,qo2,aepsge2,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Represent degenerated intersection curves as one point.  */\n\n  sh6degen(track_obj,track_obj,&qintdat,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n\n      refine_all (&qintdat, track_obj, track_obj, simpli, kdeg, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj,track_obj,simpli,kdeg,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  if (trackflag && qintdat)\n    {\n      make_tracks (track_obj, track_obj, kdeg, simpli,\n\t\t   qintdat->ilist, qintdat->vlist,\n\t\t   jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n    }\n\n  /*\n   * Express intersections on output format.\n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(track_obj, track_obj, kdeg,\n\t       2,0,qintdat,jpt,gpar,&spar,pretop,jcrv,wcurve,jsurf,wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  else\n  {\n    *jcrv = 0;\n    *jsurf = 0;\n  }\n\n  /*\n   * Intersections found.\n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;\n         s6err(\"sh1369\",*jstat,kpos);\n         goto out;\n\n  /* Dimensions conflicting.  */\n\n err106: *jstat = -106;\n         s6err(\"sh1369\",*jstat,kpos);\n         goto out;\n\n  /* Dimension not equal to three.  */\n\n err104: *jstat = -104;\n         s6err(\"sh1369\",*jstat,kpos);\n         goto out;\n\n /* Error in lower level routine.  */\n\n error : *jstat = kstat;\n         s6err(\"sh1369\",*jstat,kpos);\n         goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if (spar)    freearray(spar);\n  if (qo1)     freeObject(qo1);\n  if (qo2)     freeObject(qo2);\n  if (qintdat) freeIntdat(qintdat);\n  if (track_obj)\n    {\n       track_obj->s1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n\n  /* Free local surface.  */\n    if (qkreg != SISL_NULL && qkreg != ps) freeSurf(qkreg);\n\nreturn;\n}\n"
  },
  {
    "path": "src/sh1371.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1371.c,v 1.2 2001-03-19 15:59:03 afr Exp $\n *\n */\n\n\n#define SH1371\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \nsh1371(SISLCurve *pc1,double ecentr[],double aradiu,int idim,\n       double aepsco,double aepsge,\n       int trackflag,int *jtrack,SISLTrack ***wtrack,\n       int *jpt,double **gpar,int **pretop,int *jcrv,\n       SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid sh1371(pc1,ecentr,aradiu,idim,aepsco,aepsge,\n\ttrackflag,jtrack,wtrack,jpt,gpar,pretop,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     double   ecentr[];\n     double   aradiu;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a curve and a sphere if\n*              the dimension is equal to three and a curve and a circle \n*              if the dimension is two.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve.\n*              ecentr - Center of circle/sphere\n*              aradiu - Radius of the circle or sphere\n*              idim   - Dimension of the space in which the plane/line\n*                       lies. idim should be equal to two or three.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              *jcrv  - Number of intersection curves.\n*              wcurve - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the curve is put into the equation of the\n*              sphere/circle achieving a curve in the one-dimentional space.\n*              The zeroes of this curve is found.\n*\n*\n* REFERENCES :\n*\n*- \n* CALLS      : sh1761      - Find point/curve intersections.\n*              hp_s1880      - Put intersections into output format.\n*              s1321      - Make implicit description of \n*                           circle/sphere as matrix\n*              s1370      - Put curve into implicit equation\n*              make_cv_kreg - Ensure k-regularity of input curve.\n*              newCurve   - Create new curve.\n*              newPoint   - Create new point.                        \n*              newObject  - Create new object.\n*              freeObject - Free the space occupied by a given object.\n*              freeIntdat - Free the space occupied by intersection result.\n*\n* WRITTEN BY : Tor Dokken, SI, 88-05.\n* REWRITTEN BY : Bjoern Olav Hoset, SI, 89-06.\n*\n*********************************************************************\n*/                                                               \n{                                                                     \n  double *nullp = SISL_NULL;\n  int kstat = 0;           /* Local status variable.                       */\n  int kpos = 0;            /* Position of error.                           */\n  int kdim=1;              /* Dimension of curve in curve/point intersection.*/\n  double sarray[16];       /* Array for represetnation of implicit surface */\n  double spoint[1];        /* SISLPoint in curve/point intersection.           */\n  double *spar = SISL_NULL;     /* Values of intersections in the parameter \n\t\t\t      area of the second object. Empty in this case. */\n  SISLCurve *qc = SISL_NULL;        /* Pointer to curve in curve/point intersection.  */\n  SISLPoint *qp = SISL_NULL;        /* Pointer to point in curve/point intersection.  */\n  SISLObject *qo1 = SISL_NULL;      /* Pointer to object in \n\t\t\t      object/point intersection.*/\n  SISLObject *qo2 = SISL_NULL;      /* Pointer to object in \n\t\t\t      object/point intersection.*/\n  SISLIntdat *qintdat = SISL_NULL;  /* Pointer to intersection data */\n  int      ksurf=0;         /* Dummy number of Intsurfs. */\n  SISLIntsurf **wsurf=SISL_NULL;    /* Dummy array of Intsurfs. */\n  int      kdeg=2000;       /* input to int_join_per. */\n  SISLObject *track_obj=SISL_NULL;\n  SISLCurve *qkreg=SISL_NULL; /* Input surface ensured k-regularity. */\n\n  /* -------------------------------------------------------- */  \n\n  if (pc1->cuopen == SISL_CRV_PERIODIC)\n  {\n     /* Cyclic curve. */\n\n     make_cv_kreg(pc1,&qkreg,&kstat);\n     if (kstat < 0) goto error;\n   }\n  else\n    qkreg = pc1;\n\n  /*\n  * Create new object and connect curve to object.\n  * ------------------------------------------------\n  */\n  \n  if (!(track_obj = newObject (SISLCURVE)))\n    goto err101;\n  track_obj->c1 = pc1;\n\n  /* \n   * Check dimension.  \n   * ----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if ( !(idim == 2 || idim == 3)) goto err104;\n  if (qkreg -> idim != idim) goto err103;\n\n  /* \n   * Make a matrix of dimension (idim+1)(idim+1) to describe the circle/sphere\n   * -------------------------------------------------------------------------\n   *\n   */\n\n  s1321(ecentr,aradiu,idim,kdim,sarray,&kstat);\n  if (kstat<0) goto error;\n\n  /* \n   * Put curve into sphere curve equation \n   * ------------------------------------\n   */ \n\n  s1370(qkreg,sarray,idim,kdim,0,&qc,&kstat);\n  if (kstat<0) goto error;\n\n  /* \n   * Create new object and connect curve to object.  \n   * ----------------------------------------------\n   */\n\n  if (!(qo1 = newObject(SISLCURVE))) goto err101;\n  qo1 -> c1 = qc;\n  qo1 -> o1 = qo1;\n\n  /*\n   * Create new object and connect point to object.\n   * ----------------------------------------------\n   */\n\n  if (!(qo2 = newObject(SISLPOINT))) goto err101;\n  spoint[0] = DZERO;\n  if (!(qp = newPoint(spoint,kdim,1))) goto err101;\n  qo2 -> p1 = qp;\n\n  /* \n   * Find intersections.  \n   * -------------------\n   */\n\n  sh1761(qo1,qo2,aepsge,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj,track_obj,nullp,kdeg,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n  \n  \n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n       make_tracks (qo1, qo2, 0, nullp,\n\t\t    qintdat->ilist, qintdat->vlist, \n\t\t    jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* \n   * Express intersections on output format.  \n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(track_obj, track_obj, kdeg,\n\t       1,0,qintdat,jpt,gpar,&spar,pretop,jcrv,wcurve,&ksurf,&wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;\n         s6err(\"sh1371\",*jstat,kpos);\n         goto out;\n\n  /* Dimensions conflicting.  */\n\n err103: *jstat = -103;\n         s6err(\"sh1371\",*jstat,kpos);\n         goto out;\n\n  /* Dimension not equal to two or three.  */\n\n err104: *jstat = -104;                          \n         s6err(\"sh1371\",*jstat,kpos);\n         goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n         s6err(\"sh1371\",*jstat,kpos);\n         goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if (spar)    freearray(spar);\n  if (qo1)     freeObject(qo1);\n  if (qo2)     freeObject(qo2);\n  if (qintdat) freeIntdat(qintdat);\n  if (track_obj)\n    {\n       track_obj->c1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n    \n  /* Free local curve.  */\n\n  if (qkreg != SISL_NULL && qkreg != pc1) freeCurve(qkreg);\nreturn;\n}                                               \n                                           \n                       \n\n"
  },
  {
    "path": "src/sh1372.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1372.c,v 1.4 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n#define SH1372\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh1372(SISLCurve *pc1,double epoint[],double edirec[],double aradiu,int idim,\n\t   double aepsco,double aepsge,\n\tint trackflag,int *jtrack,SISLTrack ***wtrack,\n\tint *jpt,double **gpar,int **pretop,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid sh1372(pc1,epoint,edirec,aradiu,idim,aepsco,aepsge,\n\ttrackflag,jtrack,wtrack,jpt,gpar,pretop,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     double   epoint[];\n     double   edirec[];\n     double   aradiu;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find all intersections between a curve and a cylinder if\n*              the dimension is equal to three (other dimensions are not\n*              handled).\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve.\n*              epoint - SISLPoint on cylinder axis\n*              edirec - Direction of cylinder axis\n*              aradiu - Radius of the circle or sphere\n*              idim   - Dimension of the space in which the cyliner lies.\n*                       idim should be equal to three.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie continuous.\n*                       Intersection curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the curve is put into the equation of the\n*              cylinder achieving a curve in the one-dimentional space.\n*              The zeroes of this curve is found.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1761      - Find point/curve intersections.\n*              hp_s1880      - Put intersections into output format.\n*              s1322      - Make matrix description of cylinder\n*              s1370      - Put curve into implicit surface/curve\n*              make_cv_kreg - Ensure k-regularity of input curve.\n*              newCurve   - Create new curve.\n*              newPoint   - Create new point.\n*              newObject  - Create new object.\n*              freeObject - Free the space occupied by a given object.\n*              freeIntdat - Free the space occupied by intersection result.\n*\n* WRITTEN BY : Tor Dokken, SI, 88-05.\n* REWRITTEN BY : Bjoern Olav Hoset, SI, 89-06.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov. 1994.  Updated header\n*              and comments to reflect the fact that only 3D input is handled.\n*\n*********************************************************************\n*/\n{\n  double *nullp = SISL_NULL;\n  int kstat = 0;          /* Local status variable.                       */\n  int kpos = 0;           /* Position of error.                           */\n  int kdim=1;             /* Dimension of curve in curve/point intersection.*/\n  double sarray[16];      /* Array for represetnation of implicit surface */\n  double spoint[1];       /* SISLPoint in curve/point intersection.           */\n  double *spar = SISL_NULL;    /* Values of intersections in the parameter\n\t\t\t     area of the second object. Empty in this case. */\n  SISLCurve *qc = SISL_NULL;       /* Pointer to curve in\n\t\t\t     curve/point intersection.  */\n  SISLPoint *qp = SISL_NULL;       /* Pointer to point in\n\t\t\t     curve/point intersection.  */\n  SISLObject *qo1 = SISL_NULL;     /* Pointer to object in\n\t\t\t     object/point intersection.*/\n  SISLObject *qo2 = SISL_NULL;     /* Pointer to object in\n\t\t\t     object/point intersection.*/\n  SISLIntdat *qintdat = SISL_NULL; /* Pointer to intersection data */\n  int      ksurf=0;         /* Dummy number of Intsurfs. */\n  SISLIntsurf **wsurf=SISL_NULL;    /* Dummy array of Intsurfs. */\n  int      kdeg=2000;       /* input to int_join_per. */\n  SISLObject *track_obj=SISL_NULL;\n  SISLCurve *qkreg=SISL_NULL; /* Input surface ensured k-regularity. */\n\n  /* -------------------------------------------------------- */\n\n  if (pc1->cuopen == SISL_CRV_PERIODIC)\n  {\n     /* Cyclic curve. */\n\n     make_cv_kreg(pc1,&qkreg,&kstat);\n     if (kstat < 0) goto error;\n   }\n  else\n    qkreg = pc1;\n\n  /*\n  * Create new object and connect curve to object.\n  * ------------------------------------------------\n  */\n\n  if (!(track_obj = newObject (SISLCURVE)))\n    goto err101;\n  track_obj->c1 = pc1;\n\n  /*\n   * Check dimension.\n   * ----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if ( idim != 3) goto err104;\n  if (qkreg -> idim != idim) goto err103;\n\n  /*\n   * Make a matrix of dimension (idim+1)(idim+1) to describe the cyliner\n   * -------------------------------------------------------------------------\n   */\n\n  s1322(epoint,edirec,aradiu,idim,kdim,sarray,&kstat);\n  if (kstat<0) goto error;\n\n  /*\n   * Put curve into curve into cylinder equation\n   * -------------------------------------------\n   */\n\n  s1370(qkreg,sarray,idim,kdim,0,&qc,&kstat);\n  if (kstat<0) goto error;\n\n  /*\n   * Create new object and connect curve to object.\n   * ----------------------------------------------\n   */\n\n  if ((qo1 = newObject(SISLCURVE)) == SISL_NULL)\n      goto err101;\n  qo1 -> c1 = qc;\n  qo1 -> o1 = qo1;\n\n  /*\n   * Create new object and connect point to object.\n   * ----------------------------------------------\n   */\n\n  if(!(qo2 = newObject(SISLPOINT))) goto err101;\n  spoint[0] = DZERO;\n  if(!(qp = newPoint(spoint,kdim,1))) goto err101;\n  qo2 -> p1 = qp;\n\n  /*\n   * Find intersections.\n   * -------------------\n   */\n\n  sh1761(qo1,qo2,aepsge,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj,track_obj,nullp,kdeg,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n      make_tracks (qo1, qo2, 0, nullp,\n\t\t   qintdat->ilist, qintdat->vlist, jtrack,\n\t\t   wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /*\n   * Express intersections on output format.\n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(track_obj, track_obj, kdeg,\n\t       1,0,qintdat,jpt,gpar,&spar,pretop,jcrv,wcurve,&ksurf,&wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n\n  /*\n   * Intersections found.\n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;\n        s6err(\"sh1372\",*jstat,kpos);\n        goto out;\n\n  /* Dimensions conflicting.  */\n\n err103: *jstat = -103;\n        s6err(\"sh1372\",*jstat,kpos);\n        goto out;\n\n  /* Dimension not equal to two or three.  */\n\n err104: *jstat = -104;\n        s6err(\"sh1372\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n        s6err(\"sh1372\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if (spar)    freearray(spar);\n  if (qo1)     freeObject(qo1);\n  if (qo2)     freeObject(qo2);\n  if (qintdat) freeIntdat(qintdat);\n  if (track_obj)\n    {\n       track_obj->c1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n  /* Free local curve.  */\n\n  if (qkreg != SISL_NULL && qkreg != pc1) freeCurve(qkreg);\n\nreturn;\n}\n"
  },
  {
    "path": "src/sh1373.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1373.c,v 1.2 2001-03-19 15:59:03 afr Exp $\n *\n */\n\n\n#define SH1373\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \nsh1373(SISLCurve *pc1,double etop[],double eaxis[],double econe[],int idim,\n\t   double aepsco,double aepsge,\n\tint trackflag,int *jtrack,SISLTrack ***wtrack,\n\tint *jpt,double **gpar,int **pretop,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid sh1373(pc1,etop,eaxis,econe,idim,aepsco,aepsge,\n\ttrackflag,jtrack,wtrack,jpt,gpar,pretop,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     double   etop[];\n     double   eaxis[];\n     double   econe[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a curve and a cone.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve.\n*              etop   - Top point on cone\n*              edirec - Direction of cone axis\n*              econe  - SISLPoint on cone surface\n*              idim   - Dimension of the space in which the plane/line\n*                       lies. idim should be equal to two or three.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the curve is put into the equation of the\n*              cone achieving a curve in the one-dimentional space.\n*              The zeroes of this curve is found.\n*\n*\n* REFERENCES :\n*\n*- \n* CALLS      : sh1761 - Find point/curve intersections.\n*              hp_s1880 - Put intersections into output format.\n*              s1323 - Make description of cone as matrix\n*              s1370 - Put curve into implicit equation\n*              make_cv_kreg - Ensure k-regularity of input curve.\n*              newCurve   - Create new curve.\n*              newPoint   - Create new point.                        \n*              newObject  - Create new object.\n*              freeObject - Free the space occupied by a given object.\n*              freeIntdat - Free the space occupied by intersection result.\n*\n* WRITTEN BY : Tor Dokken, SI, 88-05.\n* REWRITTEN BY : Bjoern Olav Hoset, SI, 89-06\n*\n*********************************************************************\n*/                                                               \n{                                                                     \n  double *nullp = SISL_NULL;\n  int kstat = 0;             /* Local status variable.                       */\n  int kpos = 0;              /* Position of error.                           */\n  int kdim=1;                /* Dimension of curve in curve/point intersection.*/\n  double sarray[16];         /* Array for represetnation of implicit surface */\n  double spoint[1];          /* SISLPoint in curve/point intersection.           */\n  double *spar = SISL_NULL;       /* Values of intersections in the parameter \n\t\t\t\tarea of the second object. Empty in this case. */\n  SISLCurve *qc = SISL_NULL;          /* Pointer to curve in \n\t\t\t\tcurve/point intersection.  */\n  SISLPoint *qp = SISL_NULL;          /* Pointer to point in \n\t\t\t\tcurve/point intersection.  */ \n  SISLObject *qo1 = SISL_NULL;        /* Pointer to object in \n\t\t\t\tobject/point intersection.*/\n  SISLObject *qo2 = SISL_NULL;        /* Pointer to object in \n\t\t\t\tobject/point intersection.*/\n  SISLIntdat *qintdat = SISL_NULL;   /* Pointer to intersection data */\n  int      ksurf=0;         /* Dummy number of Intsurfs. */\n  SISLIntsurf **wsurf=SISL_NULL;    /* Dummy array of Intsurfs. */\n  int      kdeg=2000;       /* input to int_join_per. */\n  SISLObject *track_obj=SISL_NULL;\n  SISLCurve *qkreg=SISL_NULL; /* Input surface ensured k-regularity. */\n\n  /* -------------------------------------------------------- */  \n\n  if (pc1->cuopen == SISL_CRV_PERIODIC)\n  {\n     /* Cyclic curve. */\n\n     make_cv_kreg(pc1,&qkreg,&kstat);\n     if (kstat < 0) goto error;\n   }\n  else\n    qkreg = pc1;\n\n\n  /*\n  * Create new object and connect curve to object.\n  * ------------------------------------------------\n  */\n  \n  if (!(track_obj = newObject (SISLCURVE)))\n    goto err101;\n  track_obj->c1 = pc1;\n\n  /* \n   * Check dimension.  \n   * ----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if ( idim != 3) goto err104;\n  if (qkreg -> idim != idim) goto err103;\n\n  /* \n   * Make a matrix of dimension (idim+1)(idim+1) to describe the circle/sphere\n   * -------------------------------------------------------------------------\n   */\n\n  s1323(etop,eaxis,econe,idim,kdim,sarray,&kstat);\n  if (kstat<0) goto error;\n\n  /* \n   * Put curve into curve into cylinder equation \n   * -------------------------------------------\n   */ \n\n  s1370(qkreg,sarray,idim,kdim,0,&qc,&kstat);\n  if (kstat<0) goto error;\n\n  /* \n   * Create new object and connect curve to object.  \n   * ----------------------------------------------\n   */\n\n  if (!(qo1 = newObject(SISLCURVE))) goto err101;\n  qo1 -> c1 = qc;\n  qo1 -> o1 = qo1;\n\n  /*\n   * Create new object and connect point to object.\n   * ----------------------------------------------\n   */\n\n  if (!(qo2 = newObject(SISLPOINT))) goto err101;\n  spoint[0] = DZERO;\n  if (!(qp = newPoint(spoint,kdim,1))) goto err101;\n  qo2 -> p1 = qp;\n\n  /* \n   * Find intersections.  \n   * -------------------\n   */\n\n  sh1761(qo1,qo2,aepsge,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj,track_obj,nullp,kdeg,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  \n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n      make_tracks (qo1, qo2, 0, nullp,\n\t\t   qintdat->ilist, qintdat->vlist, jtrack,\n\t\t   wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* \n   * Express intersections on output format.  \n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(track_obj, track_obj, kdeg,\n\t       1,0,qintdat,jpt,gpar,&spar,pretop,jcrv,wcurve,&ksurf,&wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;                                                   \n        s6err(\"sh1373\",*jstat,kpos);\n        goto out;\n\n  /* Dimensions conflicting.  */\n\n err103: *jstat = -103;\n        s6err(\"sh1373\",*jstat,kpos);\n        goto out;\n\n  /* Dimension not equal to two or three.  */\n\n err104: *jstat = -104;                          \n        s6err(\"sh1373\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n        s6err(\"sh1373\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if (spar)    freearray(spar);\n  if (qo1)     freeObject(qo1);\n  if (qo2)     freeObject(qo2);\n  if (qintdat) freeIntdat(qintdat);\n  if (track_obj)\n    {\n       track_obj->c1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n  /* Free local curve.  */\n\n  if (qkreg != SISL_NULL && qkreg != pc1) freeCurve(qkreg);\n\nreturn;\n}                                               \n                                           \n                       \n\n"
  },
  {
    "path": "src/sh1374.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1374.c,v 1.2 2001-03-19 15:59:03 afr Exp $\n *\n */\n\n\n#define SH1374\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \nsh1374(SISLCurve *pc1,double earray[],int idim,double aepsco,double aepsge,\n\tint trackflag,int *jtrack,SISLTrack ***wtrack,\n\tint *jpt,double **gpar,int **pretop,int *jcrv,SISLIntcurve ***wcurve,\n\tint *jstat)\n#else\nvoid sh1374(pc1,earray,idim,aepsco,aepsge,\n\ttrackflag,jtrack,wtrack,jpt,gpar,pretop,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     double   earray[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a curve and a quadric\n*              curve if idim=2 and a quadric surface if idim=3.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve.\n*              earray - Matrix of dimension (idim+1)x(idim+1) describing\n*                       the conic surface such for idim=2:\n*                                         T\n*                        (x,y,1) A (x,y,1)  = 0 is the implicit equation\n*                                               for the curve\n*\n*                       For idim=3:\n*                        (x,y,z,1) A (x,y,z,1) = 0 is the implicit equation\n*                                                  for the surface\n*\n*              idim   - Dimension of the space in which the plane/line\n*                       lies. idim should be equal to two or three.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the curve is put into the equation of the\n*              cone achieving a curve in the one-dimentional space.\n*              The zeroes of this curve is found.\n*\n*\n* REFERENCES :\n*\n*-                                   \n* CALLS      : sh1761 - Find point/curve intersections.\n*              hp_s1880 - Put intersections into output format.\n*              s1370 - Put curve into implicit equation\n*              make_cv_kreg - Ensure k-regularity of input curve.\n*              newCurve   - Create new curve.                        \n*              newPoint    - Create new point.\n*              newObject  - Create new object.\n*              freeObject - Free the space occupied by a given object.\n*              freeIntdat  - Free space occupied by an intersection data.\n*              \n* WRITTEN BY : Tor Dokken, SI, 88-05.\n* REWRITTEN BY : Bjoern Olav Hoset, SI, 89-06.\n*\n*********************************************************************\n*/                                                               \n{                                                                     \n  double *nullp = SISL_NULL;\n  int kstat = 0;              /* Local status variable.                   */\n  int kpos = 0;               /* Position of error.                       */\n  int kdim=1;                 /* Dimension of curve in \n\t\t\t\t curve/point intersection.                */\n  double spoint[1];           /* SISLPoint in curve/point \n\t\t\t\t intersection.                            */\n  double *spar = SISL_NULL;        /* Values of intersections in the parameter \n\t\t\t\t area of the second object. \n\t\t\t\t Empty in this case.                      */\n  SISLCurve *qc = SISL_NULL;           /* Pointer to curve in \n\t\t\t\t curve/point intersection.                */\n  SISLPoint *qp = SISL_NULL;           /* Pointer to point in \n\t\t\t\t surface/point intersection.              */\n  SISLObject *qo1 = SISL_NULL;         /* Pointer to object in \n\t\t\t\t object/point intersection.                */\n  SISLObject *qo2 = SISL_NULL;         /* Pointer to object in \n\t\t\t\t object/point intersection.                */\n  SISLIntdat *qintdat = SISL_NULL;     /* Pointer to intersection data          */\n  int      ksurf;         /* Dummy number of Intsurfs. */\n  SISLIntsurf **wsurf=SISL_NULL;    /* Dummy array of Intsurfs. */\n  int      kdeg=2000;       /* input to int_join_per. */\n  SISLObject *track_obj=SISL_NULL;\n  SISLCurve *qkreg=SISL_NULL; /* Input surface ensured k-regularity. */\n\n  /* -------------------------------------------------------- */  \n\n  if (pc1->cuopen == SISL_CRV_PERIODIC)\n  {\n     /* Cyclic curve. */\n\n     make_cv_kreg(pc1,&qkreg,&kstat);\n     if (kstat < 0) goto error;\n   }\n  else\n    qkreg = pc1;\n\n\n  /*\n  * Create new object and connect curve to object.\n  * ------------------------------------------------\n  */\n  \n  if (!(track_obj = newObject (SISLCURVE)))\n    goto err101;\n  track_obj->c1 = pc1;\n\n  /* \n   * Check dimension.  \n   * ----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if ( idim != 2 && idim != 3) goto err104;\n  if (qkreg -> idim != idim) goto err103;\n\n  /* \n   * Put curve into curve into quadric equation \n   * ------------------------------------------\n   */ \n\n  s1370(qkreg,earray,idim,kdim,0,&qc,&kstat);\n  if (kstat<0) goto error;\n\n  /* \n   * Create new object and connect curve to object.  \n   * ----------------------------------------------\n   */\n\n  if (!(qo1 = newObject(SISLCURVE))) goto err101;\n  qo1 -> c1 = qc;\n  qo1 -> o1 = qo1;\n\n  /*\n   * Create new object and connect point to object.\n   * ----------------------------------------------\n   */\n\n  if (!(qo2 = newObject(SISLPOINT))) goto err101;\n  spoint[0] = DZERO;\n  if (!(qp = newPoint(spoint,kdim,1))) goto err101;\n  qo2 -> p1 = qp;\n\n  /* \n   * Find intersections.  \n   * -------------------\n   */\n\n  sh1761(qo1,qo2,aepsge,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj,track_obj,nullp,kdeg,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n      make_tracks (qo1, qo2, 0, nullp,\n\t\t   qintdat->ilist, qintdat->vlist, jtrack,\n\t\t   wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* \n   * Express intersections on output format.  \n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(track_obj, track_obj, kdeg,\n\t       1,0,qintdat,jpt,gpar,&spar,pretop,jcrv,wcurve,&ksurf,&wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;\n        s6err(\"sh1374\",*jstat,kpos);\n        goto out;\n\n  /* Dimensions conflicting.  */\n\n err103: *jstat = -103;                                                   \n        s6err(\"sh1374\",*jstat,kpos);\n        goto out;\n\n  /* Dimension not equal to two or three.  */\n\n err104: *jstat = -104;                          \n        s6err(\"sh1374\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n        s6err(\"sh1374\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if (spar)    freearray(spar);\n  if (qo1)     freeObject(qo1);\n  if (qo2)     freeObject(qo2);\n  if (qintdat) freeIntdat(qintdat);\n  if (track_obj)\n    {\n       track_obj->c1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n\n  /* Free local curve.  */\n\n  if (qkreg != SISL_NULL && qkreg != pc1) freeCurve(qkreg);\nreturn;\n}                                               \n                                           \n                       \n\n"
  },
  {
    "path": "src/sh1375.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1375.c,v 1.2 2001-03-19 15:59:03 afr Exp $\n *\n */\n\n\n#define SH1375\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     sh1375(SISLCurve *pc1,double ecentr[],double enorm[],double abigr,\n\t   double asmalr,int idim,double aepsco,double aepsge,\n\tint trackflag,int *jtrack,SISLTrack ***wtrack,\n\tint *jpt,double **gpar,int **pretop,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid sh1375(pc1,ecentr,enorm,abigr,asmalr,idim,aepsco,aepsge,\n\ttrackflag,jtrack,wtrack,jpt,gpar,pretop,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     double   ecentr[];\n     double   enorm[];\n     double   abigr;\n     double   asmalr;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a curve and a torus. \n*\n* INPUT      : pc1    - Pointer to the curve.\n*              ecentr - The center of the torus (lying in the symmetri plane)\n*              enorm  - Normal of symmetri plane\n*              abigr  - Distance fro ecentr to center circle of torus\n*              asmalr - The radius of the torus surface\n*              idim   - Dimension of the space in which the plane/line\n*                       lies. idim should be equal to two or three.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the curve is put into the equation of the\n*              torus achieving a curve in the one-dimentional space of order\n*              4*(ik-1) + 1, when the order of the original curve is ik.\n*              The zeroes of this curve are found.\n*\n*\n* REFERENCES :\n*\n*- \n* CALLS      : sh1761 - Find point/curve intersections.\n*              hp_s1880 - Put intersections into output format.\n*              s1377 - Put curve into torus equation\n*              make_cv_kreg - Ensure k-regularity of input curve.\n*              newCurve   - Create new curve.                        \n*              newPoint   - Create new point.                        \n*              newObject  - Create new object.\n*              freeObject - Free the space occupied by a given object.\n*              freeIntdat - Free the space occupied by intersection result.\n*\n* WRITTEN BY : Tor Dokken, SI, 88-05.\n* REWRITTEN BY : Bjoern Olav Hoset, SI, 89-06.\n*\n*********************************************************************\n*/                                                               \n{                                                                     \n  double *nullp = SISL_NULL;\n  int kstat = 0;           /* Local status variable.                       */\n  int kpos = 0;            /* Position of error.                           */\n  int kdim=1;              /* Dimension of curve in curve/point intersection.*/\n  int kdeg = 1001;         /* Code that the implict surface is a torus     */\n  double simpli[8];        /* Array for represetnation of torus    surface */\n  double snorm[3];         /* Normalized normal vector                     */\n  double spoint[1];        /* SISLPoint in curve/point intersection.           */\n  double *spar = SISL_NULL;     /* Values of intersections in the parameter \n\t\t\t      area of the second object. \n\t\t\t      Empty in this case. */\n  SISLCurve *qc = SISL_NULL;        /* Pointer to curve in \n\t\t\t      curve/point intersection.  */\n  SISLPoint *qp = SISL_NULL;        /* Pointer to point in \n\t\t\t      curve/point intersection.  */\n  SISLObject *qo1 = SISL_NULL;      /* Pointer to object in \n\t\t\t      object/point intersection.*/\n  SISLObject *qo2 = SISL_NULL;      /* Pointer to object in \n\t\t\t      object/point intersection.*/\n  SISLIntdat *qintdat = SISL_NULL;  /* Pointer to intersection data */\n  int      ksurf=0;         /* Dummy number of Intsurfs. */\n  SISLIntsurf **wsurf=0;    /* Dummy array of Intsurfs. */\n  SISLObject *track_obj=SISL_NULL;\n  SISLCurve *qkreg=SISL_NULL; /* Input surface ensured k-regularity. */\n\n  /* -------------------------------------------------------- */  \n\n  if (pc1->cuopen == SISL_CRV_PERIODIC)\n  {\n     /* Cyclic curve. */\n\n     make_cv_kreg(pc1,&qkreg,&kstat);\n     if (kstat < 0) goto error;\n   }\n  else\n    qkreg = pc1;\n\n  /*\n  * Create new object and connect curve to object.\n  * ------------------------------------------------\n  */\n  \n  if (!(track_obj = newObject (SISLCURVE)))\n    goto err101;\n  track_obj->c1 = pc1;\n\n\n  /* \n   * Check dimension.  \n   * ----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if (idim != 3) goto err104;\n  if (qkreg -> idim != idim) goto err103;\n\n  /* \n   * Normalize normal vector \n   * ----------------------\n   */\n\n  (void)s6norm(enorm,idim,snorm,&kstat);\n  if (kstat<0) goto error;\n\n  /* \n   * Put the information concerning the torus in the following sequence\n   * into simpli: Center, normal, big radius, small radius \n   * ------------------------------------------------------------------\n   */\n\n  memcopy(simpli,ecentr,3,DOUBLE);\n  memcopy(simpli+3,snorm,3,DOUBLE);\n  simpli[6] = abigr;\n  simpli[7] = asmalr;\n\n  /* \n   * Put curve into torus equation \n   * -----------------------------\n   */ \n\n  s1377(qkreg,simpli,kdeg,idim,&qc,&kstat);\n  if (kstat<0) goto error;\n\n  /* \n   * Create new object and connect curve to object.  \n   * ----------------------------------------------\n   */\n\n  if (!(qo1 = newObject(SISLCURVE))) goto err101;\n  qo1 -> c1 = qc;\n  qo1 -> o1 = qo1;\n\n  /*\n   * Create new object and connect point to object.\n   * ----------------------------------------------\n   */\n\n  if (!(qo2 = newObject(SISLPOINT))) goto err101;\n  spoint[0] = DZERO;\n  if (!(qp = newPoint(spoint,kdim,1))) goto err101;\n  qo2 -> p1 = qp;\n\n  /* \n   * Find intersections.  \n   * -------------------\n   */\n\n  sh1761(qo1,qo2,aepsge,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj,track_obj,nullp,2000,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n      make_tracks (qo1, qo2, 0, nullp,\n\t\t   qintdat->ilist, qintdat->vlist,\n\t\t   jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* \n   * Express intersections on output format.  \n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(track_obj, track_obj, 2000,\n\t       1,0,qintdat,jpt,gpar,&spar,pretop,jcrv,wcurve,&ksurf,&wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;\n        s6err(\"sh1375\",*jstat,kpos);\n        goto out;\n\n  /* Dimensions conflicting.  */\n\n err103: *jstat = -103;\n        s6err(\"sh1375\",*jstat,kpos);\n        goto out;\n\n  /* Dimension not equal to two or three.  */\n\n err104: *jstat = -104;                          \n        s6err(\"sh1375\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n        s6err(\"sh1375\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if (spar)    freearray(spar);\n  if (qo1)     freeObject(qo1);\n  if (qo2)     freeObject(qo2);\n  if (qintdat) freeIntdat(qintdat);\n  if (track_obj)\n    {\n       track_obj->c1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n\n  /* Free local curve.  */\n\n  if (qkreg != SISL_NULL && qkreg != pc1) freeCurve(qkreg);\nreturn;\n}                                               \n                                           \n                       \n\n"
  },
  {
    "path": "src/sh1460.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1460.c,v 1.3 2001-03-19 15:59:03 afr Exp $\n *\n */\n\n\n#define SH1460\n\n#include \"sislP.h\"\n\n\ntypedef void (*fshapeProc)(\n#if defined(SISLNEEDPROTOTYPES)\n                           double [],\n  \t\t\t   double [],\n                           int,\n                           int,\n                           int *\n#endif\n);\n\ntypedef  void (*fevalmidProc)(\n#if defined(SISLNEEDPROTOTYPES)\n                              fshapeProc,\n                              SISLCurve *[],\n                              int,\n                              double [],\n                              double [],\n                              double [],\n                              int *\n#endif\n);\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh1460(fshapeProc fshape,SISLCurve *vboundc[],int icurv,\n\t    SISLSurf ***wsurf,int *jstat)\n#else\nvoid sh1460(fshape,vboundc,icurv,wsurf,jstat)\n     fshapeProc fshape;\n     SISLCurve  *vboundc[];\n     int        icurv;\n     SISLSurf   ***wsurf;\n     int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE   : To create a first derivative geometry continuous blend over a\n*             a 3-, 4-, 5- or 6-sided region in space. The boundary of the\n*             region are B-spline curves and the cross boundary derivatives\n*             are given as B-spline curves.\n*\n*\n* INPUT     : fshape    - Application driven routine that gives the user an\n*                         ability to change the middle point of the region\n*                         (the vertex at which the blending surfaces meet),\n*                         and the tangent vectors in the middle point along\n*                         the curves which divide the region.\n*             vboundc   - Pointers to the boundary curves. All curves must\n*                         have be parameterized counter clockwise around\n*                         the patch.\n*                         For each edge a position curve and a cross derivative\n*                         curve is given. The sequence is the following :\n*                         Pointer to position curve of first edge, pointer to\n*                         cross derivative curve of first edge, pointer\n*                         to position\n*                         curve of second edge etc. Dimension is 2*icurv.\n*             icurv     - (3, 4, 5 or 6), Number of edges of the region.\n*\n*\n* OUTPUT    : wsurf     - wsurf[0:icurve-1] are pointers to\n*                         the blending surfaces\n*             jstat     - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* Use        : void shape();\n*              SISLCurve uboundc[KCURVE];\n*              SISLSurf  usurf[KSURF];\n*              int jstat,icurve;\n*\n*              icurve = number of edges of the region (i.e. 3, 4, 5, or 6).\n*              uboundc[0] = curve one;\n*              .\n*              .\n*\n*              sh1460(shape,uboundc,icurve,usurf,&jstat);\n*\n*\n* Method     : Hahn's method. Split the region in n 4-sided regions. Define\n*              position and cross tangent conditions along the inner edges\n*              such that G1-continuity is satisfied. Define the blending\n*              patches over the 4-sided regions as Coons patches. The order\n*              of the blending surfaces is equal to 7 in one parameter\n*              direction and 5 in the other.\n*\n*\n* References : Joerg Hahn : \"Filling Polygonal Holes with Rectangular Patches\"\n*              Theory and Practice of Geometric Modeling, Blackburn Oct 1988.\n*\n*-\n* Calls      : sh1461 - Routine performing Hahn's method.\n*              sh1462 - Evaluate midpoint of 3-sided region.\n*              sh1463 - Evaluate midpoint of 4-sided region.\n*              sh1464 - Evaluate midpoint of 5-sided region.\n*              sh1465 - Evaluate midpoint of 6-sided region.\n*              s6err - Error messages.\n*\n* Written by : Vibeke Skytt, SI, May 90.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;         /* Status variable   */\n  int kpos = 0;          /* Position of error */\n\n  /* Define pointer to midpoint eveluator of vertex region. */\n\n  fevalmidProc fevalmid;\n/*\n #if defined(SISLNEEDPROTOTYPES)\n   void (*fevalmid)(fshapeProc,SISLCurve *[],int,double [],double [],\n \t\t   double [],int *);\n #else\n   void (*fevalmid)();\n #endif\n */\n  /* Allocate scratch for output surfaces.  */\n\n  *wsurf = SISL_NULL;\n  if ((*wsurf = newarray(icurv,SISLSurf*)) == SISL_NULL) goto err101;\n\n  /* Perform Hahn's method. Pass the routine evaluating the midpoint of the\n     region as a parameter to the routine performing Hahn's method.         */\n\n  if (icurv == 3)\n    {\n      /* 3-sided region.  First set pointer to midpoint evaluator. */\n\n      fevalmid = sh1462;\n      sh1461(fshape,fevalmid,vboundc,icurv,*wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  else if (icurv == 4)\n    {\n      /* 4-sided region.  First set pointer to midpoint evaluator. */\n\n       fevalmid = sh1463 ;\n       sh1461(fshape,fevalmid,vboundc,icurv,*wsurf,&kstat);\n       if (kstat < 0) goto error;\n    }\n  else if (icurv == 5)\n    {\n      /* 5-sided region.  First set pointer to midpoint evaluator. */\n\n      fevalmid = sh1464;\n      sh1461(fshape,fevalmid,vboundc,icurv,*wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  else if (icurv == 6)\n    {\n      /* 6-sided region.  First set pointer to midpoint evaluator. */\n\n      fevalmid = sh1465;\n      sh1461(fshape,fevalmid,vboundc,icurv,*wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  else\n    {\n      /* Illegal number of edges, not implemented.  */\n\n      goto err105;\n    }\n\n  /* Blending performed.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation.  */\n\n  err101:\n    *jstat = -101;\n    s6err(\"sh1460\",*jstat,kpos);\n    goto out;\n\n  /* Error in input. Wrong number of edges.  */\n\n  err105 :\n    *jstat = -105;\n    s6err(\"sh1460\",*jstat,kpos);\n    goto out;\n\n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n    s6err(\"sh1460\",*jstat,kpos);\n    goto out;\n\n  out :\n    return;\n}\n"
  },
  {
    "path": "src/sh1461.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1461.c,v 1.2 2001-03-19 15:59:03 afr Exp $\n *\n */\n\n\n#define SH1461\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\ntypedef void (*fshapeProc)(double [],double [],int,int,int *);\ntypedef void (*initProc)(fshapeProc,SISLCurve *[],int,double [],\n\t\t\t double [],double [],int *);\n#else\ntypedef void (*fshapeProc)();\ntypedef void (*initProc)();\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void sh1461_s9coef(double [],double [],double [],double [],int,\n\t\t\t  double *,double *,double *,double *,int *);\nstatic void sh1461_s9hermit(double [],int,int,int *);\nstatic void sh1461_s9chcoor(double [],int,double [],int,double [],\n\t\t\t    int,double [],double [],double [],int,\n\t\t\t    double [],int *,int *);\nstatic void sh1461_s9mult(double [],double [],int,int,double [],int *);\nstatic void sh1461_s9comder(int,int,double [],int,double,double,double,\n\t\t\t    double,double [],int *);\nstatic double sh1461_s9ang(double [],double [],int);\n#else\nstatic void sh1461_s9coef();\nstatic void sh1461_s9hermit(); \nstatic void sh1461_s9chcoor();\nstatic void sh1461_s9mult(); \nstatic void sh1461_s9comder(); \nstatic double sh1461_s9ang();   \n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n  sh1461(fshapeProc fshape,initProc f_initmid,\n\t SISLCurve *vboundc[],int icurv,SISLSurf *vsurf[],int *jstat)\n#else\t \nvoid sh1461(fshape,f_initmid,vboundc,icurv,vsurf,jstat)\n     fshapeProc  fshape;\n     initProc    f_initmid;\n     SISLCurve   *vboundc[];\n     SISLSurf    *vsurf[];\n     int         icurv;\n     int         *jstat;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make a blend consisting of n tensor-product surfaces over\n*              a vertex region with n edges, n>=3. Along each edge position\n*              and cross-tangent conditions are given. The blend is supposed\n*              to be G1.\n*\n*\n*\n* INPUT      : fshape    - Application driven routine that gives the user an\n*                          ability to change the middle point of the region\n*                          (the vertex at which the blending surfaces meet),\n*                          and the tangent vectors in the middle point along\n*                          the curves which divedes the region. \n*              f_initmid - Function used to compute the position and \n*                          derivatives of the first blending surface in\n*                          the middle of the vertex region. This function\n*                          is dependant on the number of edges of the region.\n*              vboundc   - Pointers to curves describing edge-conditions.\n*                          For each edge, two curves are given, one describing\n*                          position and one cross-derivatives. The edges are\n*                          sorted counter-clockwise around the region, and the\n*                          curves are oriented counter-clockwise. The array has\n*                          dimension 2*icurv, i.e. 6.\n*              icurv     - Number of boundary curves. icurv >= 3.\n*                       \n*\n* OUTPUT     : vsurf      - Pointers to blending surfaces. The array has dimension\n*                           icurv.\n*              jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Hahn's method. Split the region in n 4-sided regions. Define\n*              position and cross tangent conditions along the inner edges\n*              such that G1-continuity is satisfied. Define the blending\n*              patches over the 4-sided regions as Coons patches.\n*\n*\n* REFERENCES : Joerg Hahn : \"Filling Polygonal Holes with Rectangular Patches\"\n*              Theory and Practice of Geometric Modeling, Blackburn Oct 1988.\n*              \n*\n* USE        : 3D geometry only.\n*\n*-\n* CALLS      : s1221      - Evaluate curve.\n*              s1706      - Turn orientation of curve.\n*              s1401 - Rectangular blending.\n*              newCurve   - Create new curve.\n*              freeCurve  - Free space occupied by a curve.\n*              sh1461_s9coef - Compute coefficients used for computing \n*                              derivatives in the midpoint.  \n*              sh1461_s9hermit - Compute vertices of Bezier curve.  \n*              sh1461_s9chcoor - Perform coordinate change on derivative curve.  \n*              sh1461_s9mult   - Multiply two 4-order Bezier curves.  \n*              sh1461_s9comder - Compute given 2. derivative of patch in midpoint\n*\t\t\t         of region.\n*              sh1461_s9ang    - The angle between two vectors.  \n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 03.90.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;                /* Status variable.                */\n  int kdim = 3;                 /* Dimension of geometry space.    */\n  int ki,kj,kk,kh;              /* Counters.                       */\n  int kder = 2;                 /* Number of derivatives to\n                                   compute while evaluating curve. */\n  int knmb = 0;                 /* Number of derivatives computed\n                                   in midpoint of patch.           */\n  int kleft = 0;                /* Parameter of curve evaluation.  */\n  int kkcrt2;                   /* Order of cross tangent curve.   */\n  int lder[4];\n  double tpar;                  /* Parameter value at which to \n                                   evaluate curve.                 */\n  double tro00,tro01,tro10,tro11;  /* Coefficients used to compute\n                                      derivatives at midpoint of region. */\n  double *sder = SISL_NULL;          /* Array of derivatives at midpoint    */\n  double *stwist = SISL_NULL;        /* Twist vectors of corners of region. */\n  double *stang = SISL_NULL;         /* Tangent vectors at midpoint.        */\n  double spos[15];              /* Conditions and vertices of position\n                                   curve along inner edge of region.   */\n  double scrt1[21];             /* Conditions and vertices of cross tangent\n                                   curve along inner edge of region.   */\n  double scrt2[12];             /* Conditions and vertices of cross tangent\n                                   curve along inner edge of region.   */\n  double stpos[10];             /* Knot vector corresponding to spos.  */\n  double stcrt1[14];            /* Knot vector corresponding to scrt1. */\n  double stcrt2[8];             /* Knot vector corresponding to scrt2. */\n  double sblend[4];             /* Vertices of blending function.      */\n  double sdum[6];               /* Value and 1. derivative of position\n                                   boundary curve.                     */\n  double sdum2[6];              /* Value and 1. derivative of cross\n                                   tangent boundary curve.             */\n  double *stwist2 = SISL_NULL;       /* Twist vectors of 4-sided region.    */\n  double *st,*st2;              /* Pointers into knot vectors. Used to\n                                   change parametrization of curve.    */\n  double tstart;                /* Start parameter of knot vector.     */\n  SISLCurve *qc;                /* Pointer to curve.                   */\n  SISLCurve **qbound = SISL_NULL;    /* Boundary conditions of 4-sided regions. */\n  \n  for (ki=0; ki<4; ki++) lder[ki] = 2;\n  \n  for (ki=0; ki<=kder; ki++) knmb += ki + 1;\n  \n  /* Initiate knot vectors of position curve and cross tangent\n     curves of inner edges.  */\n\n  for (ki=0; ki<5; ki++)\n    {\n      stpos[ki] = (double)0.0;\n      stpos[5+ki] = (double)1.0;\n    }\n  for (ki=0; ki<4; ki++)\n    {\n      stcrt2[ki] = (double)0.0;\n      stcrt2[4+ki] = (double)1.0;\n    }\n  for (ki=0; ki<7; ki++)\n    {\n      stcrt1[ki] = (double)0.0;\n      stcrt1[7+ki] = (double)1.0;\n    }\n      \n      \n  /* Allocate scratch for local arrays.  */\n\n  if ((sder = new0array(icurv*kdim*knmb,DOUBLE)) == SISL_NULL) goto err101;\n  if ((stwist = newarray(icurv*kdim,DOUBLE)) == SISL_NULL) goto err101;\n  if ((stwist2 = newarray(4*icurv*kdim,DOUBLE)) == SISL_NULL) goto err101;\n  if ((stang = newarray(icurv*kdim,DOUBLE)) == SISL_NULL) goto err101;\n  if ((qbound = newarray(8*icurv,SISLCurve*)) == SISL_NULL) goto err101;\n  \n  for (ki=0; ki<icurv; ki++)\n    {\n      /* Test dimension of curve.   */\n\n      if (vboundc[ki]->idim != kdim) goto err102;\n      \n      /* Initiate twist vector of n-sided region.  */\n\n      tpar = (double)0.0;\n      s1221(vboundc[2*ki+1],1,tpar,&kleft,sdum,&kstat);\n      if (kstat < 0) goto error;\n      \n      memcopy(stwist+ki*kdim,sdum+kdim,kdim,double);\n    }\n \n  /* Initiate those twist vectors of the rectangular blending surfaces\n     that coincide with the twist vectors of the n-sided region.  */\n\n  for (ki=0; ki<kdim; ki++)\n    for (kj=0; kj<icurv; kj++)\n      {\n\tkk = (kj + 1) % icurv;\n\tstwist2[(kj*4+2)*kdim+ki] = stwist[kk*kdim+ki]/(double)4.0;\n      }\n  \n      \n  /* Set up blending function.  */\n\n  sblend[0] = (double)1.0;\n  sblend[1] = sblend[2] = sblend[3] = (double)0.0;\n  sh1461_s9hermit(sblend,4,1,&kstat);\n  \n  /* Set up value and derivative of the 1. blending surface in the\n     midpoint of the vertex region.  */\n\n  f_initmid(fshape,vboundc,icurv,stwist,stang,sder,&kstat);\n  if (kstat < 0) goto error;\n  \n  for (ki=1; ki<icurv; ki++)\n    {\n      /* Compute value and derivatives of the other blending surfaces\n\t in the midpoint of the vertex region.  */\n\n      /* Copy the value in the midpoint.  */\n\n      memcopy(sder+ki*knmb*kdim,sder,kdim,DOUBLE);\n      \n      /* Copy the first derivatives of the current patch.  */\n\n      memcopy(sder+(ki*knmb+1)*kdim,stang+(ki-1)*kdim,kdim,DOUBLE);\n      memcopy(sder+(ki*knmb+2)*kdim,stang+ki*kdim,kdim,DOUBLE);\n      \n      /* The second derivative in the first parameter direction \n\t is equal to the first derivative in the second parameter\n\t direction of the previous surface.    */\n\n      memcopy(sder+(ki*knmb+3)*kdim,sder+((ki-1)*knmb+5)*kdim,kdim,DOUBLE);\n      \n      /* Compute help variables used to define the rest of the derivatives. */\n\n      sh1461_s9coef(stang+(icurv-1)*kdim,stang,stang+(ki-1)*kdim,\n\t     stang+ki*kdim,kdim,&tro00,&tro01,&tro10,&tro11,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Compute mixed derivative of the patch.  */\n\n\t\t     sh1461_s9comder(1,1,sder+3*kdim,kdim,tro00,tro01,tro10,tro11,\n\t       sder+(ki*knmb+4)*kdim,&kstat);\n\t  \n      /* Compute the second derivative in the second parameter direction. */\n\n\t\t     sh1461_s9comder(0,2,sder+3*kdim,kdim,tro00,tro01,tro10,tro11,\n\t       sder+(ki*knmb+5)*kdim,&kstat);\n    }  \n\n  /* Set up conditions for 4-edged blending.  */\n\n  for (ki=0; ki<icurv; ki++)\n    {\n      /* Copy value and derivatives of the current patch of the midpoint of\n\t the vertex region into arrays containing interpolation conditions \n\t and twist vector of current blending surface. */\n\n      memcopy(spos,sder+ki*knmb*kdim,kdim,DOUBLE);\n      memcopy(spos+kdim,sder+(ki*knmb+2)*kdim,kdim,DOUBLE);\n      memcopy(spos+2*kdim,sder+(ki*knmb+5)*kdim,kdim,DOUBLE);\n      memcopy(scrt2,sder+(ki*knmb+1)*kdim,kdim,DOUBLE);\n      memcopy(scrt2+kdim,sder+(ki*knmb+4)*kdim,kdim,DOUBLE);\n      memcopy(stwist2+4*ki*kdim,sder+(ki*knmb+4)*kdim,kdim,DOUBLE);\n      \n      /* Compute value and derivatives of the current inner edge curve at \n\t the boundary of the vertex region.  */\n\n      kj = (ki < icurv-1) ? ki+1 : 0;\n      \n      qc = vboundc[2*kj];\n      tpar = (*(qc->et + qc->ik - 1) + *(qc->et + qc->in))/(double)2.0;\n      \n      s1221(qc,1,tpar,&kleft,sdum,&kstat);\n      if (kstat < 0) goto error;\n      \n      s1221(vboundc[2*kj+1],1,tpar,&kleft,sdum2,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Copy value and derivatives at the current edge into arrays containing \n\t interpolation conditions and twist vector of current blending surface. */\n\n      memcopy(spos+4*kdim,sdum,kdim,DOUBLE);\n      for (kh=0; kh<kdim; kh++)\n\t{\n\t  spos[3*kdim+kh] = sdum2[kh]/(double)2.0;\n\t  scrt2[3*kdim+kh] = -sdum[kdim+kh]/(double)2.0;\n\t  stwist2[(ki*4+3)*kdim+kh] = scrt2[2*kdim+kh] = -sdum2[kdim+kh]/(double)4.0;\n\t  stwist2[(kj*4+1)*kdim+kh] = -stwist2[(ki*4+3)*kdim+kh];\n\t}\n      \n      /* Perform Hermit interpolation of position and first cross tangent curve. */\n\n      sh1461_s9hermit(spos,5,kdim,&kstat);\n      if (kstat < 0) goto error;\n      \n\t\t     sh1461_s9hermit(scrt2,4,kdim,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Construct second cross tangent curve. */\n\n      sh1461_s9chcoor(sblend,4,spos,5,scrt2,4,sder+(knmb*ki+1)*kdim,sder+(knmb*ki+2)*kdim,\n\t       sder+(kj*knmb+2)*kdim,kdim,scrt1,&kkcrt2,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Represent inner boundary conditions as curves. */\n\n      if ((qbound[8*kj] = newCurve(5,5,stpos,spos,1,kdim,1)) == SISL_NULL) \n\tgoto err101;\n      if ((qbound[8*kj+1] = newCurve(kkcrt2,kkcrt2,stcrt1,scrt1,1,kdim,1)) == SISL_NULL)\n\tgoto err101;\n      if ((qbound[8*ki+6] = newCurve(5,5,stpos,spos,1,kdim,1)) == SISL_NULL) \n\tgoto err101;\n      if ((qbound[8*ki+7] = newCurve(4,4,stcrt2,scrt2,1,kdim,1)) == SISL_NULL)\n\tgoto err101;\n      \n      /* Split current boundary of the vertex region.  */\n\n      s1710(qc,tpar,qbound+8*ki+4,qbound+8*kj+2,&kstat);\n      if (kstat < 0) goto error;\n      \n      s1710(vboundc[2*kj+1],tpar,qbound+8*ki+5,qbound+8*kj+3,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Turn direction of curves corresponding to standard edge 3.  */\n\n      s1706(qbound[8*ki+4]);\n      s1706(qbound[8*ki+5]);\n\n      /* Adjust length of derivative curves. */\n\n      for (kk=0; kk<kdim*(qbound[8*ki+5]->in); kk++)\n\t*(qbound[8*ki+5]->ecoef+kk) *= (double)0.5;\n      \n      for (kk=0; kk<kdim*(qbound[8*kj+3]->in); kk++)\n\t*(qbound[8*kj+3]->ecoef+kk) *= (double)0.5;\n\n      /* Reparametrize boundary curves in order to get correct tangent length.  */\n\n      for (kh=2; kh<6; kh++)\n\t{\n\t  kk = (kh > 3) ? 8*ki : 8*kj;\n\t  kk += kh;\n\t  \n\t  for (st=qbound[kk]->et,tstart=st[0],\n\t       st2=st+qbound[kk]->in+qbound[kk]->ik;\n\t       st<st2; st++)\n\t    *st = (double)2.0*(*st - tstart);\n\t}\n      \n    }\n  \n  for (ki=0; ki<icurv; ki++)\n    {\n      /* Perform rectangular blending.  */\n\n       s1401(qbound+8*ki,stwist2+4*ki*kdim,vsurf+ki,&kstat);  \n       /* s1390(qbound+8*ki,vsurf+ki,lder,&kstat); */\n      if (kstat < 0) goto error;\n    }\n  \n  /* Blending performed.  */\n\n  *jstat = 0;\n  goto out;\n  \n  /* Error in scratch allocation.  */\n\n  err101 :\n    *jstat = -101;\n  goto out;\n  \n/* Dimension not equal to 3.  */\n\n  err102 :\n    *jstat = -102;\n  goto out;\n  \n  /* Error in lower level function.  */\n\n  error :\n    *jstat = kstat;\n  goto out;\n  \n  out :\n\n    /* Free space occupied by local arrays.  */\n\n    if (sder) freearray(sder);\n  if (stwist) freearray(stwist);\n  if (stwist2) freearray(stwist2);\n  if (stang) freearray(stang);\n  if (qbound)\n    {\n      for (ki=0; ki<8*icurv; ki++)\n\tif (qbound[ki]) freeCurve(qbound[ki]);\n      freearray(qbound);      \n    }\n  \n    return;\n}\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  sh1461_s9hermit(double econd[],int icond,int idim,int *jstat)\n#else\t       \nstatic void sh1461_s9hermit(econd,icond,idim,jstat)\n     int icond,idim,*jstat;\n     double econd[];\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Hermite interpolation of position and icond-3 derivatives\n*              in one endpoint and position and derivative in the other\n*              endpoint, represented as a Bezier curve on the interval [0,1].\n*\n*\n*\n* INPUT      : icond      - Number of interpolation conditions. \n*                           icond = 4 or icond = 5.\n*              idim       - Dimension of geometry space.\n*\n*\n* INPUT/OUTPUT : econd    - Interpolation conditions as input, Bezier coefficients\n*                           as output. The dimension is icond*idim.\n*                       \n*\n* OUTPUT     : jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n*********************************************************************\n*/\n{\n  int ki;    /* Index.  */\n\n  /* Test input. The number of conditions has to be 4 or 5.  */\n\n  if (icond != 4 && icond != 5) goto err001;\n  \n  if (icond == 4)\n    {\n      /* Hermit interpolation with Bezier curve of order 4.  */\n\n      for (ki=0; ki<idim; ki++)\n\t{\n\t  econd[idim+ki] = ONE_THIRD*econd[idim+ki] + econd[ki];\n\t  econd[2*idim+ki] = ONE_THIRD*econd[2*idim+ki] + econd[3*idim+ki];\n\t}\n    }\n  \n  if (icond == 5)\n    {\n      /* Hermit interpolation with Bezier curve of order 5.  */\n\n      for (ki=0; ki<idim; ki++)\n\t{\n\t  econd[idim+ki] = ONE_FOURTH*econd[idim+ki] + econd[ki];\n\t  econd[2*idim+ki] = econd[2*idim+ki]/(double)12.0 \n\t    + (double)2.0*econd[idim+ki] - econd[ki];\n\t  econd[3*idim+ki] = ONE_FOURTH*econd[3*idim+ki] + econd[4*idim+ki];\t  \n\t}\n    }\n   \n  *jstat = 0;\n  goto out;\n  \n  /* Error in input. Number of coefficients not 4 or 5.  */\n\n  err001 :\n    *jstat = -1;\n  goto out;\n  \n  out :\n    return;\n}\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  sh1461_s9coef(double evec1[],double evec2[],double evec3[],\n\t\tdouble evec4[],int idim,double *cro00,double *cro01,\n\t\tdouble *cro10,double *cro11,int *jstat)\n#else\nstatic void sh1461_s9coef(evec1,evec2,evec3,evec4,idim,cro00,cro01,\n\t\t\t  cro10,cro11,jstat)\n     int idim,*jstat;\n     double evec1[],evec2[],evec3[],evec4[];\n     double *cro00,*cro01,*cro10,*cro11;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Compute factors of expression to find derivatives of \n*              patches in the midpoint of the vertex region.\n*\n*\n*\n* INPUT      : evec1   - Derivative in first parameter direction of first patch.\n*              evec2   - Derivative in second parameter direction of first patch.\n*              evec3   - Derivative in first parameter direction of current patch.\n*              evec4   - Derivative in second parameter direction of current patch.\n*                        NB! All these derivative vectors are expected to lie in\n*                            the same plane.\n*              idim    - Dimension of geometry space.\n*\n*\n* OUTPUT     : cro00   - First factor.\n*              cro01   - Second factor.\n*              cro10   - Third factor.\n*              cro11   - Fourth factor.\n*              jstat   - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* CALLS      : s6length  - Length of vector.\n*              s6scpr    - Scalar product between two vectors.\n*              s6crss    - Cross product between two vectors.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;                       /* Status variable.              */\n  int ksin,ksin1,ksin2,ksin3,ksin4;    /* Sign of sinus of angles.      */\n  double tang,tang1,tang2,tang3,tang4; /* Angles between input vectors. */\n  double tl1,tl2,tl3,tl4;              /* Lengths of input vectors.     */\n  double tsin,tsin1,tsin2,tsin3,tsin4; /* Sinus of angles.              */\n  double snorm[3];                     /* Normal of plane spanned by\n                                          tangent vectors.              */\n  double svec[3];                      /* Vector in tangent plane normal\n                                          to a specific tangent vector. */\n  double tlvec;                        /* Length of the vector svec.    */\n  \n  /* Compute the normal to the tangent plane spanned by the input vectors.  */\n\n  s6crss(evec1,evec2,snorm);\n  \n  /* Compute the lengths of the vectors evec1 to evec4. */\n\n  tl1 = s6length(evec1,idim,&kstat);\n  tl2 = s6length(evec2,idim,&kstat);\n  tl3 = s6length(evec3,idim,&kstat);\n  tl4 = s6length(evec4,idim,&kstat);\n  \n  /* Compute the vector lying in the tangent plane normal to evec1. */\n\n  s6crss(snorm,evec1,svec);\n  tlvec = s6length(svec,idim,&kstat);\n  \n  /* Compute the sinus of angles between evec1 and the other input vectors. */\n\n  tsin = s6scpr(svec,evec2,idim)/(tlvec*tl2);\n  tsin1 = s6scpr(svec,evec3,idim)/(tlvec*tl3);\n  tsin2 = s6scpr(svec,evec4,idim)/(tlvec*tl4);\n  \n  /* Compute the vector lying in the tangent plane normal to evec2. */\n\n  s6crss(snorm,evec2,svec);\n  tlvec = s6length(svec,idim,&kstat);\n\n  /* Compute the sinus of angles between evec2 and the later input vectors. */\n\n  tsin3 = s6scpr(svec,evec3,idim)/(tlvec*tl3);\n  tsin4 = s6scpr(svec,evec4,idim)/(tlvec*tl4); \n  \n  /* Fetch the sign of the sinuses of the angles.  */\n\n  ksin = (tsin < DZERO) ? -1 : 1;\n  ksin1 = (tsin1 < DZERO) ? -1 : 1;\n  ksin2 = (tsin2 < DZERO) ? -1 : 1;\n  ksin3 = (tsin3 < DZERO) ? -1 : 1;\n  ksin4 = (tsin4 < DZERO) ? -1 : 1;\n  \n  /* Compute the angles in a more stable way. */\n\n  tang = sh1461_s9ang(evec1,evec2,idim);\n  tang1 = sh1461_s9ang(evec1,evec3,idim);\n  tang2 = sh1461_s9ang(evec1,evec4,idim);\n  tang3 = sh1461_s9ang(evec2,evec3,idim);\n  tang4 = sh1461_s9ang(evec2,evec4,idim);\n  \n  /* Compute the sinuses of the angles.  */\n\n  tsin = ksin*sin(tang);\n  tsin1 = ksin1*sin(tang1);\n  tsin2 = ksin2*sin(tang2);\n  tsin3 = ksin3*sin(tang3);\n  tsin4 = ksin4*sin(tang4);\n  \n  /* Compute the output factors.  */\n\n  *cro00 = (tl3*tsin1)/(tl2*tsin);\n  *cro01 = (tl4*tsin2)/(tl2*tsin);\n  *cro10 = -(tl3*tsin3)/(tl1*tsin);\n  *cro11 = -(tl4*tsin4)/(tl1*tsin);\n  \n  *jstat = 0;\n  \n  return;\n}\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  sh1461_s9chcoor(double eblend[],int iordblend,double epos[],\n\t\t  int iordpos,double ecrt1[],int iordcrt1,\n\t\t  double evec1[],double evec2[],double evec3[],\n\t\t  int idim,double ecrt2[],int *jordcrt2,int *jstat)\n#else\t       \nstatic void sh1461_s9chcoor(eblend,iordblend,epos,iordpos,ecrt1,iordcrt1,\n\t\t\t    evec1,evec2,evec3,idim,ecrt2,jordcrt2,jstat)\n     int iordblend,iordpos,iordcrt1,idim,*jordcrt2,*jstat;\n     double evec1[],evec2[],evec3[];\n     double eblend[],epos[],ecrt1[],ecrt2[];\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Compute that cross tangent curve belonging to one of the \n*              blending patches, that is a mapping of the derivative\n*              curves of the previous patch.\n*\n*\n*\n* INPUT      : eblend    - Vertices of blending function. The dimension\n*                          of the array is iordblend.\n*              iordblend - Number of vertices of blending function. \n*                          iordblend = 4.\n*              epos      - Vertices of position curve. This curve is\n*                          between the corners (0,0) and (0,1) of the\n*                          previous patch, and the corners (0,0) and \n*                          (1,0) of the current patch.\n*              iordpos   - Number of vertices of the position curve.\n*                          iordpos = 5.\n*              ecrt1     - Vertices of input cross tangent curve. This\n*                          curve is the derivative curve in the 1. parameter\n*                          direction along the edge from (0,0) to (0,1)\n*                          of the previous patch.\n*              iordcrt1  - Number of vertices of input cross tangent curve.\n*                          iordcrt1 = 4.\n*              evec1     - Tangent vector at the corner (0,0) in the 1. \n*                          parameter direction of the previous patch.\n*              evec2     - Tangent vector at the corner (0,0) in the 2. \n*                          parameter direction of the previous patch, and\n*                          in the 1. parameter direction of the current patch.\n*              evec3     - Tangent vector at the corner (0,0) in the 2. \n*                          parameter direction of the current patch.\n*              idim      - Dimension of geometry space.\n*\n*\n* OUTPUT     : ecrt2     - Vertices of the produced cross tangent curve. \n*                          This curve is the derivative curve in the 2.\n*                          parameter direction along the edge from (0,0) to\n*                          (1,0) of the current patch.\n*              jordcrt2  - Number of vertices of produced cross tangent curve.\n*                          *jordcrt2 = 7.\n*              jstat     - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Let pc1 be the input cross tangent curve, pc2 be the\n*              derivative curve along the position curve and alpha the \n*              blending function. Then the output cross tangent curve is \n*              given by :\n*              pc3(s) = ((my+1)*alpha(s)-1)*pc1(s) + lambda*alpha(s)*pc2(s)\n*              my and lambda are constants depending on the lengths of \n*              input vectors, evec1, evec2 and evec3, and the angles \n*              between them. See the paper of Hahn.\n*\n* CALLS     : s6length - Length of vector.\n*\n*********************************************************************\n*/\n{\n  int kstat;                       /* Status variable.              */\n  int ki;                          /* Counters.                     */\n  double tl1,tl2,tl3;              /* Lengths of the input vectors. */\n  double tang1,tang2;              /* Angles between input vectors. */\n  double tsin1,tsin2,tsin3;        /* Sinus of angles between input\n                                      vectors.                      */\n  double tmy,tmy1;                 /* Coefficients dependant on the\n                                      input vectors.                */\n  double tlambda;                  /* Coefficient dependant on the\n                                      input vectors.                */\n  double scoef[12];                /* Vertices of the derivative\n                                      curve along the position curve. */\n  double sc1[21],sc2[21];          /* Coefficients of products of curves. */\n  double sblend2[4];               /* Coefficients of curve equal to\n                                      a factor times the blending \n                                      curve minus 1.                 */\n  \n  if (iordblend != 4 || iordcrt1 != 4) goto err002;   \n\n  *jordcrt2 = iordblend + iordcrt1 - 1;\n  \n  /* Compute constants.  */\n\n  tl1 = s6length(evec1,idim,&kstat);\n  tl2 = s6length(evec2,idim,&kstat);\n  tl3 = s6length(evec3,idim,&kstat);\n  tang1 = sh1461_s9ang(evec1,evec2,idim);\n  tang2 = sh1461_s9ang(evec2,evec3,idim);\n  tsin1 = sin(tang1);\n  tsin2 = sin(tang2);\n  tsin3 = sin(tang1+tang2);\n  tmy = - (tl3*tsin2)/(tl1*tsin1);\n  tlambda = (tl3*tsin3)/(tl2*tsin1);\n  tmy1 = tmy + (double)1.0;\n  \n  /* Compute coefficients of the curve (my+1)alpha(s)-1.  */\n\n  for (ki=0; ki<4; ki++) sblend2[ki] = tmy1*eblend[ki] - (double)1.0;\n  \n  /* Compute coefficients of derivative curve along position curve. */\n\n  for (ki=0; ki<4*idim; ki++)\n    scoef[ki] = (double)4.0*(epos[idim+ki] - epos[ki]);\n\n   /* Compute first part of the second cross tangent curve. */\n\n  sh1461_s9mult(eblend,scoef,4,idim,sc1,&kstat);\n\n   /* Compute second part of the second cross tangent curve. */\n\n  sh1461_s9mult(sblend2,ecrt1,4,idim,sc2,&kstat);\n  \n  /* Compute cross tangent curve.  */\n\n  for (ki=0; ki<7*idim; ki++)\n    ecrt2[ki] = (tlambda*sc1[ki] + sc2[ki]);\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in input.  */\n\n  err002 :\n    *jstat = -2;\n  goto out;\n  \n  out :\n    return;\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  sh1461_s9mult(double eblend[],double ecoef[],int iord,\n\t\tint idim,double ecoefnew[],int *jstat)\n#else\t       \nstatic void sh1461_s9mult(eblend,ecoef,iord,idim,ecoefnew,jstat)\n     int iord,idim,*jstat;\n     double eblend[],ecoef[],ecoefnew[];\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Compute the product of two Bezier curves of order 4,\n*              one of which is a blending function of dimension 1.\n*\n*\n*\n* INPUT      : eblend    - Vertices of blending function. The dimension\n*                          of the array is iord, i.e. 4.\n*              ecoef     - Vertices of the other Bezier curve. The \n*                          dimension of the array is iord*idim, i.e. 4*idim.\n*              iord      - Order of the Bezier curves. iord = 4.\n*              idim      - Dimension of geometry space.\n*\n*\n* OUTPUT     : ecoefnew  - Vertices of the product curve. The array is\n*                          allocated outside this routine, and has\n*                          dimension (2*iord-1)*idim, i.e. 7*idim\n*              jstat     - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* USE        : Used in Hahn's method when computing the cross tangent\n*              curve which is a mapping of the derivative curves of the\n*              previous patch. Called from s9chcoor.\n*\n*********************************************************************\n*/\n{\n  int ki;   /* Index.   */\n  \n  /* Test if the order of the curves is equal to 4.  */\n\n  if (iord != 4) goto err001;\n  \n  for (ki=0; ki<idim; ki++)\n    {\n      /* Compute the vertices of the product curve. */\n\n      ecoefnew[ki] = eblend[0]*ecoef[ki];\n      ecoefnew[idim+ki] = (eblend[0]*ecoef[idim+ki] \n\t\t\t   + eblend[1]*ecoef[ki])/(double)2.0;\n      ecoefnew[2*idim+ki] = (eblend[0]*ecoef[2*idim+ki]\n\t\t\t     + (double)3.0*eblend[1]*ecoef[idim+ki]\n\t\t\t     + eblend[2]*ecoef[ki])/(double)5.0;\n      ecoefnew[3*idim+ki] = (eblend[0]*ecoef[3*idim+ki] + eblend[3]*ecoef[ki]\n\t\t\t     + (double)9.0*(eblend[1]*ecoef[2*idim+ki] + \n\t\t\t\t\t    eblend[2]*ecoef[idim+ki]))/(double)20.0;\n      ecoefnew[4*idim+ki] = (eblend[1]*ecoef[3*idim+ki]\n\t\t\t     + (double)3.0*eblend[2]*ecoef[2*idim+ki]\n\t\t\t     + eblend[3]*ecoef[idim+ki])/(double)5.0;      \n      ecoefnew[5*idim+ki] = (eblend[2]*ecoef[3*idim+ki] \n\t\t\t     + eblend[3]*ecoef[2*idim+ki])/(double)2.0;\n      ecoefnew[6*idim+ki] = eblend[3]*ecoef[3*idim+ki];\n    }\n\n  *jstat = 0;\n  goto out;\n  \n  /* Error in input. The order of the curves is not equal to 4.  */\n\n  err001 :\n    *jstat = -1;\n  goto out;\n  \n  out :\n    return;\n}\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic double\n  sh1461_s9ang(double evec1[],double evec2[],int idim)\n#else\t       \nstatic double sh1461_s9ang(evec1,evec2,idim)\n     double evec1[];\n     double evec2[];\n     int    idim;\n#endif     \n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Compute the angle (in radians) between two vectors\n*\n*\n*\n* INPUT      : evec1   - First vector \n*              evec2   - Second vector \n*              idim    - Dimension of the space in which the vectors lie.\n*\n*\n*\n* OUTPUT     : sh1461_s9ang   - Angle in radians between vectors\n*\n*\n* METHOD     : Make cosine of the angle by computing the scalar product,\n*              then divide by the length of the two vectors.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6scpr   - Scalar product between two vectors.\n*              s6length - Length of vector.\n*\n* WRITTEN BY : Tor Dokken SI, 88-07.\n*              Arne Laksaa SI, 89-07.\n*              Vibeke Skytt SI, 90-04.\n*\n*********************************************************************\n*/                                     \n{\n  double tscpr,tang,tlength1,tlength2,tcos;\n  int    kstat1,kstat2;\n  \n  tscpr = s6scpr(evec1,evec2,idim);\n  \n  tlength1 = s6length(evec1,idim,&kstat1);\n  tlength2 = s6length(evec2,idim,&kstat2);\n  \n  if (!kstat1 || !kstat2)\n    tang = DZERO;\n  else\n    {\n      tcos = tscpr/(tlength1*tlength2);\n      tcos = MIN((double)1.0,tcos);\n      tcos = MAX(-(double)1.0,tcos);\n      tang = acos(tcos);\n    }\n      \n  return(tang);\n}\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic  void\n  sh1461_s9comder(int ider1,int ider2,double ederprev[],int idim,\n\t\t  double aro00,double aro01,double aro10,\n\t\t  double aro11,double eder[],int *jstat)\n#else\t    \nstatic void sh1461_s9comder(ider1,ider2,ederprev,idim,aro00,aro01,aro10,\n\t\t\t    aro11,eder,jstat)\n     int ider1,ider2,idim,*jstat;\n     double ederprev[],aro00,aro01,aro10,aro11,eder[];\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Compute given 2. derivative of a blending surface at the \n*              midpoint of the vertex region when the 2. derivatives of the \n*              first blending patch are known.\n*\n*\n*\n* INPUT      : ider1    - Order of differentiation in first parameter direction.\n*              ider2    - Order of differentiation in second parameter direction.\n*              ederprev - 2. derivatives of 1. patch stored in the following \n*                         order, (2,0)-, (1,1)- and (0,2)-derivative.\n*              idim     - Dimension of geometry space.\n*              aro00    - First factor of coordinate transformation.\n*              aro01    - Second factor of coordinate transformation.\n*              aro10    - Third factor of coordinate transformation.\n*              aro11    - Fourth factor of coordinate transformation.\n*\n*\n* OUTPUT     : eder    - Actual 2. derivative.\n*              jstat   - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n*********************************************************************\n*/\n{\n  int kj,kk,kh;            /* Counters.  */\n  double t00,t01,t10,t11;  /* Coefficients used to compute\n\t\t\t      derivatives at midpoint of region. */\n  double tfac1,tfac2;      /* Factor used to compute derivatives \n\t\t\t      at midpoint of region.  */\n  \n  /* Test input.  */\n\n  if (ider1 + ider2 != 2) goto err001;\n  \n  /* Compute requested 2. derivative.  */\n\n  t00 = t10 = (double)1.0;\n  for (kj=0; kj<ider1; kj++) t00 *= aro00;\n\n  for (kj=0; kj<=ider1; kj++)\n    {\n      tfac1 = (ider1 > 0) ? (double)((kj % ider1) + 1) : (double)1.0;\n\n      t01 = t11 = (double)1.0;\n      for (kk=0; kk<ider2; kk++) t01*=aro01;\n\n      for (kk=0; kk<=ider2; kk++)\n\t{\n\t  tfac2 = (ider2 > 0) ? (double)((kk % ider2) + 1) : (double)1.0;\n\n\t  for (kh=0; kh<idim; kh++)\n\t    eder[kh] += tfac1*tfac2*t00*t01*t10*t11*ederprev[(2-kj-kk)*idim+kh];\n\t      \n\t  if (aro01 != DZERO) t01 /= aro01;\n\t  else if (kk == ider2-1) t01 = (double)1.0;\n\t  t11 *= aro11;\n\t}\n      if (aro00 != DZERO) t00 /= aro00;\n      else if (kj == ider1-1) t00 = (double)1.0;\n      t10 *= aro10;\t  \n    }\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in input. Wrong order of differentiation.  */\n\n  err001 :\n    *jstat = -1;\n  goto out;\n  \n  out :\n    return;\n}\n"
  },
  {
    "path": "src/sh1462.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1462.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define SH1462\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\ntypedef void (*fshapeProc)(double [],double [],int,int,int *);\n#else\ntypedef void (*fshapeProc)();\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n  sh1462(fshapeProc fshape,SISLCurve *vboundc[],int icurv,\n\t double etwist[],double etang[],double eder[],int *jstat)\n#else\t \nvoid sh1462(fshape,vboundc,icurv,etwist,etang,eder,jstat)\n     fshapeProc    fshape;\n     double        etwist[],etang[],eder[];\n     SISLCurve     *vboundc[];\n     int           icurv,*jstat;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Given a three sided vertex region, evaluate the first\n*              blending surface in the corner lying in the middle of the\n*              vertex region. Compute the tangent vectors in the middle \n*              vertex along the inner boundaries of the region.\n*\n*\n*\n* INPUT      : fshape  - Application driven routine that gives the user an\n*                        ability to change the middle point of the region\n*                        (the vertex at which the blending surfaces meet),\n*                        and the tangent vectors in the middle point along\n*                        the curves which divedes the region. \n*              vboundc - Position and cross-tangent curves around the vertex\n*                        region. For each edge of the region position and cross-\n*                        tangent curves are given. The curves follow each other\n*                        around the region and are oriented counter-clock-wise.\n*                        The dimension of the array is 6, i.e. 2*icurv.\n*              icurv   - Number of sides. icurv = 3.\n*              etwist  - Twist-vectors of the corners of the vertex region. The\n*                        first element of the array is the twist in the corner\n*                        before the first edge, etc. The dimension of the array\n*                        is 3*kdim.\n*                       \n*\n* OUTPUT     : etang   - Tangent vectors at the midpoint of the vertex region.\n*                        The dimension is icurv*idim.\n*              eder    - Value, first and second derivative of the first blending\n*                        surface in the corner at the midpoint. The sequence is the\n*                        following : Value, 1. derivative in 1. parameter direction,\n*                        1. derivative in the 2. parameter direction, 2. derivative\n*                        in the 1. parameter direction, mixed derivative and 2.\n*                        derivative in the 2. parameter direction. Dimension 6*idim.\n*              jstat   - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Evaluate the Gregory Charrot function in the midpoint of the\n*              vertex region. Compute the wanted derivatives.\n*\n* REFERENCES : \n*\n* USE        : 3D geometry only.\n*\n*-\n* CALLS      : sh1466  - Evaluate the Gregory Charrot function.  \n*\n* WRITTEN BY : Vibeke Skytt, SI, 03.90.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;         /* Status variable.  */\n  int kder = 2;          /* Number of derivatives to evaluate.  */\n  int ki;                /* Counter.  */\n  int kdim = 3;          /* Dimension of geometry space.  */\n  double tonethird = (double)1.0/(double)3.0;  /* 1/3     */\n  double tonesixth = (double)1.0/(double)6.0;  /* 1/6     */\n  double sbar[3];        /* Barycentric coordinates of point to evaluate. */\n  double sder[18];       /* Value and derivatives of blending. */\n\n  /* Set up the barycentric coordinates of the midpoint of the region. */\n\n  sbar[0] = sbar[1] = sbar[2] = tonethird;\n  \n  /* Evaluate the Gregory Charrot function at the midpoint. */\n\n  sh1466(vboundc,etwist,kder,sbar,sder,&kstat);\n  if (kstat < 0) goto error;\n   \n  /* Compute tangent vectors.  */\n\n  for (ki=0; ki<kdim; ki++)\n    {\n      etang[ki] = -sder[kdim+ki]*tonethird + sder[2*kdim+ki]*tonesixth;\n      etang[kdim+ki] = sder[kdim+ki]*tonesixth - sder[2*kdim+ki]*tonethird;\n      etang[2*kdim+ki] = sder[kdim+ki]*tonesixth + sder[2*kdim+ki]*tonesixth;\n    }\n  \n  /* Application driven routine to alter the midpoint and tangents in the\n     midpoint.  */\n\n  fshape(sder,etang,kdim,icurv,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Copy value and 1. derivatives of first patch.  */\n\n  memcopy(eder,sder,kdim,DOUBLE);\n  memcopy(eder+kdim,etang+2*kdim,kdim,DOUBLE);\n  memcopy(eder+2*kdim,etang,kdim,DOUBLE);\n  \n  /* Compute 2. derivatives.  */\n\n  for (ki=0; ki<kdim; ki++)\n    {\n      eder[3*kdim+ki] = sder[3*kdim+ki]*tonesixth*tonesixth \n\t+ (double)2.0*sder[4*kdim+ki]*tonesixth*tonesixth \n\t  + sder[5*kdim+ki]*tonesixth*tonesixth;\n      eder[4*kdim+ki] = -sder[3*kdim+ki]*tonesixth*tonethird \n\t+ sder[4*kdim+ki]*tonesixth*(tonesixth - tonethird)\n\t  + sder[5*kdim+ki]*tonesixth*tonesixth;\n      eder[5*kdim+ki] = sder[3*kdim+ki]*tonethird*tonethird \n\t- (double)2.0*sder[4*kdim+ki]*tonethird*tonesixth \n\t  + sder[5*kdim+ki]*tonesixth*tonesixth;\n    }\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in a lower level function.  */\n\n error:\n  *jstat = kstat;\n  goto out;\n  \n  out :\n    return;\n}\n"
  },
  {
    "path": "src/sh1463.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1463.c,v 1.2 2001-03-19 15:59:04 afr Exp $\n *\n */\n\n\n#define SH1463\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\ntypedef void (*fshapeProc)(double [],double [],int,int,int *);\n#else\ntypedef void (*fshapeProc)();\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n  sh1463(fshapeProc fshape,\n\t SISLCurve *vboundc[],int icurv,double etwist[],\n\t double etang[],double eder[],int *jstat)\n#else\t \nvoid sh1463(fshape,vboundc,icurv,etwist,etang,eder,jstat)\n     fshapeProc    fshape;\n     double        etwist[],etang[],eder[];\n     SISLCurve     *vboundc[];\n     int           icurv,*jstat;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Given a four sided vertex region, evaluate the first\n*              blending surface in the corner lying in the middle of the\n*              vertex region. Compute the tangent vectors in the middle \n*              vertex along the inner boundaries of the region.\n*\n*\n*\n* INPUT      : fshape  - Application driven routine that gives the user an\n*                        ability to change the middle point of the region\n*                        (the vertex at which the blending surfaces meet),\n*                        and the tangent vectors in the middle point along\n*                        the curves which divedes the region. \n*              vboundc - Position and cross-tangent curves around the vertex\n*                        region. For each edge of the region position and cross-\n*                        tangent curves are given. The curves follow each other\n*                        around the region and are oriented counter-clock-wise.\n*                        The dimension of the array is 8.\n*              icurv   - Number of sides. icurv = 4.\n*              etwist  - Twist-vectors of the corners of the vertex region. The\n*                        first element of the array is the twist in the corner\n*                        before the first edge, etc. The dimension of the array\n*                        is 4*kdim.\n*                       \n*\n* OUTPUT     : etang   - Tangent vectors at the midpoint of the vertex region.\n*                        The dimension is icurv*idim.\n*              eder    - Value, first and second derivative of the first blending\n*                        surface in the corner at the midpoint. The sequence is the\n*                        following : Value, 1. derivative in 1. parameter direction,\n*                        1. derivative in the 2. parameter direction, 2. derivative\n*                        in the 1. parameter direction, mixed derivative and 2.\n*                        derivative in the 2. parameter direction. Dimension 6*idim.\n*              jstat   - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Perform rectangular blending of the whole region. Evaluate\n*              the resulting surface in the midpoint.\n*\n* REFERENCES : \n*\n* USE        : 3D geometry only.\n*\n*-\n* CALLS      : s1401 - Rectangular blending. \n*             s1421        - Surface evaluation.   \n*             s1706        - Turn orientation of curve. \n*             freeCurve    - Free space occupied by a curve.\n*             newCurve     - Create new curve.     \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.90.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;     /* Status variable.  */\n  int kder = 2;      /* Number of derivatives of surface to evaluate. */\n  int ki;            /* Counters.         */\n  int kdim = 3;      /* Dimension of geometry space. */\n  int klfs = 0;      /* Parameter used in surface evaluation. */\n  int klft = 0;      /* Parameter used in surface evaluation. */\n  double spar[2];    /* Parameter value of midpoint of rectanular patch. */\n  double sder[18];   /* Value and derivatives of patch in the midpoint.  */\n  double snorm[3];   /* Normal of patch in the midpoint.      */\n  SISLSurf *qsurf = SISL_NULL;  /* Rectangular blending patch.  */\n  SISLCurve *qc[8];        /* Copy of edge curves.         */\n  SISLCurve *qpt;          /* Pointer to curve.            */\n\n  /* Make a copy of the edge curves.  */\n\n  for (ki=0; ki<8; ki++)\n    {\n      qpt = vboundc[ki];\n      \n      /* Test dimension of curves. */\n\n      if (qpt->idim != kdim) goto err104;\n      \n      qc[ki] = newCurve(qpt->in,qpt->ik,qpt->et,qpt->ecoef,qpt->ikind,kdim,1);\n      if (qc[ki] == SISL_NULL) goto err101;\n    }\n    \n  /* Turn the orientation of the curves at the 3. and 4. edge. */\n\n  s1706(qc[4]);\n  s1706(qc[5]);  \n  s1706(qc[6]);  \n  s1706(qc[7]);  \n\n  /* Compute Coon's patch.  */\n\n  s1401(qc,etwist,&qsurf,&kstat);\n  if (kstat < 0) goto error;\n   \n  /* Evaluate the surface in the middle.  */\n\n  spar[0] = (double)0.5*(*(qsurf->et1+qsurf->ik1-1) + *(qsurf->et1+qsurf->in1));\n  spar[1] = (double)0.5*(*(qsurf->et2+qsurf->ik2-1) + *(qsurf->et2+qsurf->in2));\n  \n  s1421(qsurf,kder,spar,&klfs,&klft,sder,snorm,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Compute tangent vectors at the midpoint of the vertex region as \n     half the tangent vectors at the rectangular patch.  */\n\n  for (ki=0; ki<kdim; ki++)\n    {\n      etang[ki] = (double)0.5*sder[2*kdim+ki];\n      etang[kdim+ki] = (double)0.5*sder[kdim+ki];\n      etang[2*kdim+ki] = -(double)0.5*sder[2*kdim+ki];\n      etang[3*kdim+ki] = -(double)0.5*sder[kdim+ki];\n    }\n  \n  /* Application driven routine to alter the midpoint and tangents in the\n     midpoint.  */\n\n  fshape(sder,etang,kdim,icurv,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Copy value and 1. derivatives of first patch.  */\n\n  memcopy(eder,sder,kdim,DOUBLE);\n  memcopy(eder+kdim,etang+3*kdim,kdim,DOUBLE);\n  memcopy(eder+2*kdim,etang,kdim,DOUBLE);\n  \n  /* Compute 2. derivatives.  */\n\n  for (ki=0; ki<kdim; ki++)\n    {\n      eder[3*kdim+ki] = (double)0.1*sder[5*kdim+ki];\n      eder[4*kdim+ki] = (double)0.1*sder[4*kdim+ki];\n      eder[5*kdim+ki] = (double)0.1*sder[3*kdim+ki];\n    }\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in scratch allocation. */\n\n  err101 :\n  *jstat = -101;\n  goto out;\n \n  /* Error in input. Dimension not equal to 3.  */\n\n  err104 :\n    *jstat = -104;\n  goto out;\n   \n  /* Error in a lower level function.  */\n\n error:\n  *jstat = kstat;\n  goto out;\n  \n  out :\n\n    /* Free space occupied by local curves and surface. */\n\n    for (ki=0; ki<8; ki++)\n      if (qc[ki] != SISL_NULL) freeCurve(qc[ki]);\n  if (qsurf != SISL_NULL) freeSurf(qsurf);\n  \n    return;\n}\n"
  },
  {
    "path": "src/sh1464.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1464.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define SH1464\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\ntypedef void (*fshapeProc)(double [],double [],int,int,int *);\n#else\ntypedef void (*fshapeProc)();\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n  sh1464(fshapeProc fshape,SISLCurve *vboundc[],int icurv,\n\t double etwist[],double etang[],double eder[],int *jstat)\n#else      \nvoid sh1464(fshape,vboundc,icurv,etwist,etang,eder,jstat)\n     fshapeProc    fshape;\n     double        etwist[],etang[],eder[];\n     SISLCurve     *vboundc[];\n     int           icurv,*jstat;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Given a five sided vertex region, evaluate the first\n*              blending surface in the corner lying in the middle of the\n*              vertex region. Compute the tangent vectors in the middle \n*              vertex along the inner boundaries of the region.\n*\n*\n*\n* INPUT      : fshape  - Application driven routine that gives the user an\n*                        ability to change the middle point of the region\n*                        (the vertex at which the blending surfaces meet),\n*                        and the tangent vectors in the middle point along\n*                        the curves which divedes the region. \n*              vboundc - Position and cross-tangent curves around the vertex\n*                        region. For each edge of the region position and cross-\n*                        tangent curves are given. The curves follow each other\n*                        around the region and are oriented counter-clock-wise.\n*                        The dimension of the array is 10.\n*              icurv   - Number of sides. icurv = 5.\n*              etwist  - Twist-vectors of the corners of the vertex region. The\n*                        first element of the array is the twist in the corner\n*                        before the first edge, etc. The dimension of the array\n*                        is icurve*kdim.\n*                       \n*\n* OUTPUT     : etang   - Tangent vectors at the midpoint of the vertex region.\n*                        The dimension is icurv*idim.\n*              eder    - Value, first and second derivative of the first blending\n*                        surface in the corner at the midpoint. The sequence is the\n*                        following : Value, 1. derivative in 1. parameter direction,\n*                        1. derivative in the 2. parameter direction, 2. derivative\n*                        in the 1. parameter direction, mixed derivative and 2.\n*                        derivative in the 2. parameter direction. Dimension 6*idim.\n*              jstat   - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : Evaluate the Gregory Charrot function in the midpoint of the\n*              vertex region. Compute the wanted derivatives.\n*\n* REFERENCES : \n*\n* USE        : 3D geometry only.\n*\n*-\n* CALLS      : sh1467  - Evaluate Gregory Charrot function over \n*\t\t\t 5-sided region.                       \n*\n* WRITTEN BY : Vibeke Skytt, SI, 03.90.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;         /* Status variable.    */\n  int kder = 2;          /* Number of derviatives to evaluate.  */\n  int ki;                /* Counter.  */\n  int kdim = 3;          /* Dimension of geometry space.     */\n  double tlambda = (double)1.0/sqrt((double)5.0);           /* Constant.  */\n  double tl1 = (double)2.0*tlambda*tan(PI/(double)5.0);     /* Constant.  */\n  double tl2 = sin((double)0.3*PI);                         /* Constant.  */\n  double tconst1 = tl1/(double)2.0 - tlambda;               /* Constant.  */\n  double tconst2 = tl2 - tlambda;                           /* Constant.  */\n  double sbar[5];        /* Barycentric coordinates of the blending function. */\n  double sder[18];       /* Value and derivatives of blending function.       */\n\n  /* Set up the barycentric coordinates of the midpoint of the region. */\n\n  sbar[0] = sbar[1] = sbar[2] = sbar[3] = sbar[4] = tlambda;\n  \n  /* Evaluate the Gregory Charrot function at the midpoint. */\n\n  sh1467(vboundc,etwist,kder,sbar,sder,&kstat);\n  if (kstat < 0) goto error;\n   \n  /* Compute tangent vectors.  */\n\n  for (ki=0; ki<kdim; ki++)\n    {\n      etang[ki] = sder[kdim+ki]*tconst1 + sder[2*kdim+ki]*tconst2;\n      etang[kdim+ki] = -sder[kdim+ki]*tlambda + sder[2*kdim+ki]*tconst1;\n      etang[2*kdim+ki] = sder[kdim+ki]*tconst1 - sder[2*kdim+ki]*tlambda;\n      etang[3*kdim+ki] = sder[kdim+ki]*tconst2 + sder[2*kdim+ki]*tconst1;\n      etang[4*kdim+ki] = sder[kdim+ki]*tconst2 + sder[2*kdim+ki]*tconst2;\n    }\n  \n  /* Application driven routine to alter the midpoint and tangents in the\n     midpoint.  */\n\n  fshape(sder,etang,kdim,icurv,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Copy value and 1. derivatives of first patch.  */\n\n  memcopy(eder,sder,kdim,DOUBLE);\n  memcopy(eder+kdim,etang+4*kdim,kdim,DOUBLE);\n  memcopy(eder+2*kdim,etang,kdim,DOUBLE);\n  \n  /* Compute 2. derivatives.  */\n\n  for (ki=0; ki<kdim; ki++)\n    {\n      eder[3*kdim+ki] = sder[3*kdim+ki]*tconst2*tconst2 \n\t+ (double)2.0*sder[4*kdim+ki]*tconst2*tconst2 \n\t  + sder[5*kdim+ki]*tconst2*tconst2;\n      eder[4*kdim+ki] = sder[3*kdim+ki]*tconst1*tconst2 \n\t+ sder[4*kdim+ki]*tconst2*(tconst1+tconst2)\n\t  + sder[5*kdim+ki]*tconst2*tconst2;\n      eder[5*kdim+ki] = sder[3*kdim+ki]*tconst1*tconst1 \n\t- (double)2.0*sder[4*kdim+ki]*tconst1*tconst2 \n\t  + sder[5*kdim+ki]*tconst2*tconst2;\n    }\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in a lower level function.  */\n\n error:\n  *jstat = kstat;\n  goto out;\n  \n  out :\n    return;\n}\n"
  },
  {
    "path": "src/sh1465.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1465.c,v 1.2 2001-03-19 15:59:04 afr Exp $\n *\n */\n\n\n#define SH1465\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\n   static void sh1465_s9der2(double [],double [],double [],double [],\n\t\t\t     double [],int,int,double [],int *);\n   typedef void (*fshapeProc)(double [],double [],int,int,int *);\n#else\n   static void sh1465_s9der2();\n   typedef void (*fshapeProc)();\n#endif  \n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n  sh1465(fshapeProc fshape,SISLCurve *vboundc[],int icurv,\n\t double etwist[],double etang[],double eder[],int *jstat)\n#else\nvoid sh1465(fshape,vboundc,icurv,etwist,etang,eder,jstat)\n     fshapeProc fshape;\n     double etwist[],etang[],eder[];\n     SISLCurve *vboundc[];\n     int icurv,*jstat;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Given a vertex region whith an equal number of sides, \n*              evaluate the first blending surface in the corner lying in \n*              the middle of the vertex region. Compute the tangent vectors \n*              in the middle vertex along the inner boundaries of the region.\n*\n*\n*\n* INPUT      : fshape  - Application driven routine that gives the user an\n*                        ability to change the middle point of the region\n*                        (the vertex at which the blending surfaces meet),\n*                        and the tangent vectors in the middle point along\n*                        the curves which divedes the region. \n*              vboundc - Position and cross-tangent curves around the vertex\n*                        region. For each edge of the region position and cross-\n*                        tangent curves are given. The curves follow each other\n*                        around the region and are oriented counter-clock-wise.\n*                        The dimension of the array is 2*icurv.\n*              icurv   - Number of sides.\n*              etwist  - Twist-vectors of the corners of the vertex region. The\n*                        first element of the array is the twist in the corner\n*                        before the first edge, etc. The dimension of the array\n*                        is icurv*kdim.\n*                       \n*\n* OUTPUT     : etang   - Tangent vectors at the midpoint of the vertex region.\n*                        The dimension is icurv*idim.\n*              eder    - Value, first and second derivative of the first blending\n*                        surface in the corner at the midpoint. The sequence is the\n*                        following : Value, 1. derivative in 1. parameter direction,\n*                        1. derivative in the 2. parameter direction, 2. derivative\n*                        in the 1. parameter direction, mixed derivative and 2.\n*                        derivative in the 2. parameter direction. Dimension 6*idim.\n*              jstat   - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n* REFERENCES : \n*\n* USE        : 3D geometry only.\n*\n*-\n* CALLS      : s6norm   - Normalize vector.  \n*              s6scpr   - Scalar product between two vectors.  \n*              s6length - Lenght of vector.  \n*              s6dist   - Distance between two vectors. \n*              s6crss   - Cross product between two vectors. \n*              s6diff   - Difference between two vectors.  \n*              s6curvrad - Estimate curvature radius in point. \n*              s1325    - Calculate tangent length given opening\n*                         angle of curve segment and curvature radius.\n*              s1221    - Evaluate curve.  \n*              sh1465_s9der2 - Compute 2. derivatives of the first \n*\t\t\t       blending patch.    \n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 04.90.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;      /* Status variable.  */\n  int kder = 0;       /* Number of derivatives of curve to evaluate. */\n  int kder1 = 1;      /* Number of derivatives of curve to evaluate. */\n  int ki,kj;          /* Counters.  */\n  int kdim = 3;       /* Dimension of geometry space.  */\n  int kleft = 0;      /* Parameter used in curve evaluation.  */\n  int kcurv2;         /* Number of edges diveded in two.  */\n  double tpar;        /* Parameter value at which to evaluate curve. */\n  double t1;          /* Scalar product between tangent in midpoint\n\t\t\t and normal of vertex region in midpoint.    */\n  double trad1,trad2; /* Estimate of curvature radius of curves in\n\t\t\t endpoints.   */\n  double ta1;         /* Opening angle of curve segment.  */\n  double tb1,tb2;     /* Length of original tangents in endpoints\n\t\t\t of curve segments.               */\n  double tang1,tang2; /* Length of tangents based on curvature radius. */\n  double tscal1;      /* Scaler product between unit tangent vectors.  */\n  double tdist;       /* Distance between endpoints of curve segment.  */\n  double smid[3];     /* Midpoint of vertex region.       */\n  double snorm1[3];   /* Cross product of two tangents in the midpoint. */\n  double snorm[3];    /* Normal of vertex region in the midpoint.      */\n  double svec[6];     /* Tangent along curve in the midpoint of the two\n\t\t\t first position curves.           */\n  double *sder = SISL_NULL;   /* Value of boundary curves at the midpoints of\n\t\t\t    the curves.                   */\n  double *stang = SISL_NULL;  /* Tangent vectors in the midpoint of the region. */\n  SISLCurve *qc;      /* Local pointer to edge curve.  */\n  \n  kcurv2 = icurv/2;\n\n  /* Allocate scratch for values on edge curves. */\n\n  if ((sder = newarray(2*icurv*kdim,DOUBLE)) == SISL_NULL) goto err101;\n  if ((stang = newarray(icurv*kdim,DOUBLE)) == SISL_NULL) goto err101;\n\n  for (ki=0; ki<icurv; ki++)\n    {  \n      qc = vboundc[2*ki];\n\n      /* Test dimension of curve. */\n\n      if (qc->idim != kdim) goto err102;\n\n      /* Evaluate boundary curves of current edge in the midpoint.\n\t First find midpoint.  */\n\n      tpar = (*(qc->et + qc->ik - 1) + *(qc->et + qc->in))/(double)2.0;\n      \n      /* Evaluate position curve. */\n\n      s1221(qc,kder1,tpar,&kleft,sder+2*ki*kdim,&kstat);\n      if (kstat < 0) goto error;\n      \n      if (ki < 2) memcopy(svec+ki*kdim,sder+(2*ki+1)*kdim,kdim,DOUBLE);\n      if (ki == 1) kder1 = 0;\n      \n      /* Evaluate cross derivative curve. */\n\n      s1221(vboundc[2*ki+1],kder,tpar,&kleft,sder+(2*ki+1)*kdim,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  for (ki=0; ki<kcurv2; ki++)\n    {\n       /* Set new tangent length based on curvature radius. First estimate\n         curvature radius.  */\n\n      s6curvrad(sder+2*ki*kdim,sder+2*(ki+kcurv2)*kdim,sder+(2*ki+1)*kdim,\n\t\tkdim,&trad1,&kstat);\n      s6curvrad(sder+2*ki*kdim,sder+2*(ki+kcurv2)*kdim,sder+(2*(ki+kcurv2)+1)*kdim,\n\t\tkdim,&trad2,&kstat);\n  \n      /* Normalize tangents. */\n\n      tb1 = s6norm(sder+(2*ki+1)*kdim,kdim,sder+(2*ki+1)*kdim,&kstat);\n      tb2 = s6norm(sder+(2*(ki+kcurv2)+1)*kdim,kdim,sder+(2*(ki+kcurv2)+1)*kdim,&kstat);\n      \n      /* Compute distance between endpoints of curve.  */\n\n      tdist = s6dist(sder+2*ki*kdim,sder+2*(ki+kcurv2)*kdim,kdim);\n      \n      /* Find opening angle of curve segment.  */\n\n      tscal1  = s6scpr(sder+(2*ki+1)*kdim,sder+(2*(ki+kcurv2)+1)*kdim,kdim);\n\n      if (tscal1 >= DZERO)\n\ttscal1  = MIN((double)1.0,tscal1);\n      else\n\ttscal1  = MAX((double)-1.0,tscal1);\n\n      ta1 = acos(tscal1);\n\n      if (fabs(ta1) < ANGULAR_TOLERANCE) ta1 = DZERO;\n\n      if (DNEQUAL(ta1,DZERO))\n\t{\n\t  /*  Make tangents based on radius of curvature */\n\n\t  tang1 = s1325(trad1,ta1);\n\t  tang2 = s1325(trad2,ta1);\n\t}\n\n      /* Test if the found tangent length can be used. Otherwise\n\t adjust the length.   */\n\n      if (DEQUAL(ta1,DZERO) || trad1 < 0) tang1 = tdist/(double)3.0;\n      if (DEQUAL(ta1,DZERO) || trad2 < 0) tang2 = tdist/(double)3.0;\n      if (tang1 > (double)0.5*tdist || tang2 > (double)0.5*tdist) \n\t{\n\t  tang1 = tb1;\n\t  tang2 = tb2;\n\t}\n      \n      /* Set tangent length of tangents in endpoints of the curves to find. */\n\n      for (kj=0; kj<kdim; kj++)\n\t{\n\t  sder[(2*ki+1)*kdim+kj] *= tang1;\n\t  sder[(2*(ki+kcurv2)+1)*kdim+kj] *= tang2;\n\t} \n    }  \n  \n\n  /* Estimate midpoint of region and tangent in midpoint.  */\n\n  for (kj=0; kj<kdim; kj++) \n    {\n      smid[kj] = (double)0.0;\n      snorm[kj] = (double)0.0;\n      \n      for (ki=0; ki<kcurv2; ki++)\n\t{\n\t  /* Estimate midpoint.  */\n\n\t  smid[kj] += (sder[2*ki*kdim+kj] + sder[2*(ki+kcurv2)*kdim+kj])/(double)2.0\n\t    + (sder[(2*ki+1)*kdim+kj] \n\t       + sder[2*(ki+kcurv2)*kdim+kdim+kj])/(double)8.0;\n\t  \n\t  /* Compute tangent.  */\n\n\t  stang[(ki+kcurv2)*kdim+kj] = (double)1.5*(sder[2*(ki+kcurv2)*kdim+kj]\n\t\t\t\t\t- sder[2*ki*kdim+kj])\n\t    + (double)0.25*(sder[2*(ki+kcurv2)*kdim+kdim+kj]\n\t\t\t   - sder[(2*ki+1)*kdim+kj]);\n\t  stang[ki*kdim+kj] = - stang[(ki+kcurv2)*kdim+kj];\n\t}\n      smid[kj] /= (double)kcurv2;\n    }\n\n  /* Find medium plane given by the tangents.  */\n\n  for (ki=0; ki<kcurv2; ki++)\n    {\n      s6crss(stang+ki*kdim,stang+(ki+1)*kdim,snorm1);\n  \n      for (kj=0; kj<kdim; kj++) \n\tsnorm[kj] += snorm1[kj]/(double)kcurv2;\n    }\n  \n  (void)s6norm(snorm,kdim,snorm,&kstat);\n  \n  /* Project the tangents into this plane.  */\n\n  for (ki=0; ki<icurv; ki++)\n    {\n      t1 = -s6scpr(stang+ki*kdim,snorm,kdim);\n      for (kj=0; kj<kdim; kj++) stang[ki*kdim+kj] += t1*snorm[kj];\n    }\n  \n  /* Application driven routine to alter the midpoint and tangents in the\n     midpoint.  */\n\n  fshape(smid,stang,kdim,icurv,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Compute second order derivatives of first surface in the midpoint.  */\n\n  sh1465_s9der2(sder,smid,stang,snorm,svec,icurv,kdim,eder+3*kdim,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Set lengths of tangents and second derivatives according to patches\n     whith side length equal to half the curvelengths considered in this\n     routine.  */\n\n  for (ki=0; ki<icurv*kdim; ki++) stang[ki] *= (double)0.5;\n  for (ki=3*kdim; ki<6*kdim; ki++) eder[ki] *= (double)0.25;\n  \n  /* Copy position and tangent information into the output array giving\n     derivatives of the first blending surface in the midpoint. */\n\n  memcopy(eder,smid,kdim,DOUBLE);\n  memcopy(eder+kdim,stang,2*kdim,DOUBLE);\n  \n  /* Copy tangents into output array containing tangents.  */\n\n  memcopy(etang,stang+kdim,(icurv-1)*kdim,DOUBLE);\n  memcopy(etang+(icurv-1)*kdim,stang,kdim,DOUBLE);\n\t\t\t\t\t\n  *jstat = 0;\n  goto out;\n  \n  /* Error in scratch allocation.  */\n\n  err101 :\n    *jstat = -101;\n  goto out;\n  \n  /* Error in input. Dimension not equal to 3.  */\n\n  err102 :\n    *jstat = -102;\n  goto out;\n  \n  /* Error in a lower level function.  */\n\n error:\n  *jstat = kstat;\n  goto out;\n  \n  out :\n\n    /* Free space occupied by local arrays.  */\n\n    if (sder) freearray(sder);\n  if (stang) freearray(stang);\n  \n  return;\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  sh1465_s9der2(double ebound[],double epoint[],double etang[],\n\t\tdouble enorm[],double evec[],int icurv,\n\t\tint idim,double eder2[],int *jstat)\n#else\t       \nstatic void sh1465_s9der2(ebound,epoint,etang,enorm,evec,icurv,\n\t\t\t  idim,eder2,jstat)\n     int       icurv,idim,*jstat;\n     double    ebound[],epoint[],etang[],enorm[],evec[],eder2[];\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Given a vertex region with an equal number of sides, \n*              estimate the 2. derivatives of the first blending surface \n*              in the midpoint of the region.\n*\n*\n*\n* INPUT      : ebound  - Position of boundary curve and cross tangent at the \n*                        midpoint of each edge. Dimension is 2*icurv*idim.\n*              epoint  - The midpoint of the vertex region. Dimension is idim.\n*              etang   - Tangents in epoint, pointing towards the midpoints of\n*                        the edges. Dimension is icurv*idim.\n*              enorm   - Normal to surface in midpoint of region. Dimension is idim.\n*              evec    - The tangent at the midpoint of the boundary curves at the\n*                        two first edges. Dimension is 2*idim.\n*              icurv   - Number of sides. icurv is an equal number.\n*              idim    - Dimension of the geometry space.\n*                       \n*\n* OUTPUT     : eder2   - Second derivative of the first blending surface in \n*                        the corner at the midpoint. The sequence is the\n*                        following : 2. derivative in the 1. parameter direction, \n*                        mixed derivative and 2. derivative in the 2. parameter \n*                        direction. Dimension is 3*idim.\n*              jstat   - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n* REFERENCES : \n*\n* USE        : 3D geometry only.\n*\n*-\n* CALLS      : s1221     - Curve evaluator.  \n*              s1334     - Curve interpolation. \n*              s6lufacp  - LU-factorizing of matrix. \n*              s6lusolp  - Solve to LU-factorized equation system. \n*              s6curvature - Compute curvature vector of curve. \n*              s6scpr    - Scalar product between two vectors. \n*              s6length  - Length of vector.  \n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 04.90.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;     /* Status variable.  */\n  int ki,kj;         /* Counters.         */\n  int kleft = 0;     /* Parameter to curve evaluator.  */\n  int knbpnt = 6;    /* Number of interpolation conditions. */\n  int kcnsta = 0;    /* No extra condition on startpoint in interpolation. */\n  int kcnend = 0;    /* No extra condition on endpoint in interpolation. */\n  int kopen = 1;     /* Produce open curve.   */\n  int kcurv2;        /* Number of edges divided into 2. */\n  int kord = 6;      /* Order of interpolated curve.    */\n  int knpar;         /* Number of different parameter values of \n\t\t\tinterpolation conditions.       */\n  int kder = 2;      /* Number of derivatives to evaluate. */\n  int ll[3];         /* Pivoting array in solving equation system. */\n  double tstpar = (double)0.0;   /* Start parameter of interpolated curve. */\n  double tendpar;    /* End parameter of interpolated curve. */\n  double tpar;       /* Parameter value at which to evaluate. */\n  double tncurv;     /* Normal curvature at midpoint of curve. */\n  double te,tf,tg;   /* Coefficients of first fundamental form of surface. */\n  double tl,tm,tn;   /* Coefficients of second fundamental form of surface. */\n  double talfa;      /* Angle between the two parameter directions of a\n\t\t\trectangular patch in the parameter area of the \n\t\t\tn-sided vertex region.       */\n  double tcos;       /* Cosinus of the angle talfa.  */\n  double tdudt;      /* Factor in parameter change.  */\n  double tdvdt;      /* Factor in parameter change.  */\n  double tform1;     /* First fundamental form.      */\n  double spoint[18]; /* Interpolation conditions.    */\n  double stype[6];   /* Type of interpolation conditions. */\n  double *spar = SISL_NULL;  /* Parameter value of interpolation conditions. */\n  double sder[18];   /* Value and derivatives of curve in the midpoint. */\n  double scurv[3];   /* Curvature vector in midpoint of curve. */\n  double smat[9];    /* Matrix in equation system to compute mixed derivative. */\n  SISLCurve *qc = SISL_NULL;  /* Curve across the vertex region between midpoint\n\t\t\t       of edge position curves through the midpoint\n\t\t\t       of the region.      */\n  \n  kcurv2 = icurv/2;\n  \n  /* Test input.  */\n\n  if (idim != 3) goto err104;\n  \n  /* Make curves that limits first blending surface. */\n\n  for (ki=0; ki<2; ki++)\n    {\n      /* Set up interpolation conditions of curve. */\n\n      for (kj=0; kj<idim; kj++)\n\t{\n\t  spoint[kj] = ebound[2*(kcurv2+ki)*idim+kj];\n\t  spoint[idim+kj] = ebound[(2*(kcurv2+ki)+1)*idim+kj];\n\t  spoint[2*idim+kj] = epoint[kj];\n\t  spoint[3*idim+kj] = etang[ki*idim+kj];\n\t  spoint[4*idim+kj] = ebound[2*ki*idim+kj];\n\t  spoint[5*idim+kj] = -ebound[(2*ki+1)*idim+kj];\n\t}\n      \n      /* Type of interpolation conditions.  */\n\n      stype[0] = (double)1.0;\n      stype[1] = (double)4.0;\n      stype[2] = (double)1.0;\n      stype[3] = (double)4.0;\n      stype[4] = (double)1.0;\n      stype[5] = (double)4.0;\n\n      /* Interpolate curve.  */\n\n      s1334(spoint,knbpnt,idim,stype,kcnsta,kcnend,kopen,kord,tstpar,&tendpar,\n\t    &qc,&spar,&knpar,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Evaluate curve in midpoint.  */\n\t\t\t\t\n      tpar = spar[1];\n      s1221(qc,kder,tpar,&kleft,sder+3*ki*idim,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* Copy 2. derivatives of the two curves to the 2. derivatives of the\n     surface in the midpoint in the 1. and 2. parameter direction. */\n\n  memcopy(eder2,sder+2*idim,idim,DOUBLE);\n  memcopy(eder2+2*idim,sder+5*idim,idim,DOUBLE);\n  \n  /* Compute curvature vector in the midpoint of the first curve.  */\n\n  s6curvature(sder,idim,scurv,&kstat);\n\n  /* Compute normal curvature of the first curve at the midpoint of the region. */\n  \n  tncurv = s6scpr(scurv,enorm,idim);\n\n  /* Compute parameter direction of the curve compared to that of the\n     first blending surface. */\n\n  talfa = TWOPI/(double)icurv;\n  tcos = cos(talfa);\n  tdudt = (DEQUAL(tcos+(double)1.0,(double)1.0)) ? (double)0.0 : (double)1.0/tcos;\n  tdvdt = (double)1.0;\n  \n  /* Compute coefficients of the first fundamental form of the surface. */\n\n  te = s6scpr(sder+idim,sder+idim,idim);\n  tf = s6scpr(sder+idim,sder+4*idim,idim);\n  tg = s6scpr(sder+4*idim,sder+4*idim,idim);\n  \n  /* Compute the first fundamental form.  */\n\n  tform1 = te*tdudt*tdudt + (double)2.0*tf*tdudt*tdvdt + tg*tdvdt*tdvdt;\n  \n  /* Compute 1. and 3. coefficient of the second fundamental form of the surface. */\n\n  tl = s6scpr(sder+2*idim,enorm,idim);\n  tn = s6scpr(sder+5*idim,enorm,idim);\n  \n  /* Compute 2. coefficient of the second fundamental form which is equal to\n     the length of the component of the twist along the surface normal.  */\n\n  eder2[idim] = tm = (tncurv*tform1 - tl*tdudt*tdudt - tn*tdvdt*tdvdt)/(double)2.0;\n  \n  /* Set the length of the component of the twist along the derivative in\n     the first parameter direction equal to zero.   */\n\n  eder2[idim+1] = (double)0.0;\n  \n  /* Set the length of the component of the twist along the derivative \n     in the second parameter direction equal to zero.   */\n\n  eder2[idim+2] = (double)0.0;\n  \n  /* Compute twist vector at the midpoint.  */\n\n  memcopy(smat,enorm,idim,DOUBLE);\n  memcopy(smat+idim,sder+idim,idim,DOUBLE);\n  memcopy(smat+2*idim,sder+4*idim,idim,DOUBLE);\n  \n  s6lufacp(smat,ll,3,&kstat);\n  if (kstat < 0) goto error;\n  \n  s6lusolp(smat,eder2+idim,ll,3,&kstat);\n  if (kstat < 0) goto error;\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in input. Dimension not equal to 3.  */\n\n  err104 :\n    *jstat = -104;\n  goto out;\n  \n  /* Error in lower level routine.  */\n\n  error :\n    *jstat = kstat;\n  goto out;\n  \n  out :\n    return;\n}     \n\n\n"
  },
  {
    "path": "src/sh1466.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1466.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define SH1466\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      sh1466(SISLCurve *ecurve[],double etwist[],int ider,double ebar[],\n\t     double eval[],int *jstat)\n#else\t \nvoid sh1466(ecurve,etwist,ider,ebar,eval,jstat)\n     double etwist[],ebar[],eval[];\n     SISLCurve *ecurve[];\n     int ider,*jstat;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Given the barycentric coordinates of a point in a 3-sided\n*              vertex region, evaluate the value of the ideal blending \n*              surface of the vertex region in this point.\n*\n*\n*\n* INPUT      : ecurve - Position and cross-tangent curves around the vertex\n*                       region. For each edge of the region position and cross-\n*                       tangent curves are given. The curves follow each other\n*                       around the region and are oriented counter-clock-wise.\n*                       The dimension of the array is 6.\n*              etwist - Twist-vectors of the corners of the vertex region. The\n*                       first element of the array is the twist in the corner\n*                       before the first edge, etc. The dimension of the array\n*                       is 3*kdim.\n*              ider   - Number of derivatives to compute. Directions of \n*                       differentiation is that of the two first barycentric\n*                       coordinates. 0 <= ider <= 2.\n*              ebar   - Barycentric coordinates of the point to be evaluated.\n*                       The dimension of the array is 3.\n*                       \n*\n* OUTPUT     : eval   - Value and derivatives of ideal blending surface in the \n*                       given point. Dimension of the array is 3*(1+..+(ider+1)).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : A functional description of the ideal surface is given as\n*              a blend between three surfaces, each of which fulfill the\n*              continuity requirements over two edges.\n*\n* REFERENCES : Gregory and Charrot : A C1 Triangular Interpolation Patch for\n*                                    Computer Aided Geometric Design\n*\n* USE        : 3D geometry only.\n*\n*-\n* CALLS      : s1221 - Evaluate curve at a given parameter value.\n*\n* WRITTEN BY : Vibeke Skytt, SI, Dec 89.\n*\n*********************************************************************\n*/\n{\n  int kstat=0;         /* Status variable.                                */\n  int ki,kj,kk,kh;     /* Counters.                                       */\n  int kder;            /* Number of derivatives to evaluate.              */\n  int kleft = 0;       /* Local parameter used in s1221.                  */\n  int kdim = 3;        /* Dimension of geometry.                          */\n  int kwarn = 0;       /* Indicates if a warning is to be sendt.          */\n  int knmb;            /* Number of doubles pr derivative.                */\n  int kl = 0;          /* Number of derivatives in the output array.      */\n  double tpar1;        /* Parameter value of edge between actual corner \n\t\t\t  and next corner.                                */\n  double tpar2;        /* Parameter value of edge between actual corner\n\t\t\t  and previous corner.                            */\n  double tlambi;       /* First barycentric coordinate.                   */\n  double tlambj;       /* Second barycentric coordinate.                  */\n  double tlambk;       /* Third barycentric coordinate.                   */\n  double salpha[3];    /* Weight of actual blending surface.              */\n  double sp[9];        /* Value of function interpolating two sides.      */\n  double sstart[3];    /* Start-parameters of edge-curves.                */\n  double send[3];      /* End-parameters of edge-curves.                  */\n  double sint[3];      /* Parameter intervals of edge-curves.             */\n  double spos1[27];    /* Position of edge-curve in tpar1.                */\n  double sder1[27];    /* Cross tangent in tpar1.                         */\n  double spos2[27];    /* Position of edge-curve in tpar2.                */\n  double sder2[27];    /* Cross tangent in tpar2.                         */\n  double scorn[9];     /* Position of edge-curves in actual corner of \n\t\t\t  vertex region.                                  */\n  double scornder1[9]; /* Tangent in corner along next edge.              */\n  double scornder2[9]; /* Tangent in corner along previous edge.          */\n\n  /* Test input.  */\n\n  if (ider > 2) kwarn = 1;\n  \n  /* Initialise.  */\n\n  kder = ider;\n  knmb = kdim*(ider+1);\n  for (ki=0; ki<ider; ki++) kl += ider + 1;\n  \n  /* Initiate output array to zero.  */\n\n  for (kh=0; kh<kl*kdim; kh++) eval[kh] = (double)0.0;\n        \n  /* Get endpoints of parameter intervals of edge curves.  */\n\n  for (ki=0; ki<3; ki++)\n    {\n      sstart[ki] = *(ecurve[2*ki] -> et + ecurve[2*ki] -> ik - 1);\n      send[ki] = *(ecurve[2*ki] -> et + ecurve[2*ki] -> in);\n      sint[ki] = send[ki] - sstart[ki];\n    }\n\n  /* Evaluate position and cross-tangent curves at points on\n     the edges needed when evaluating surface.        */\n  \n  for (ki=0; ki<3; ki++)\n    {\n      kj = (ki+1) % 3;\n      kk = (ki+2) % 3;\n\n      /* Copy barycentric coordinates to local variables.  */\n\n      tlambi = ebar[ki];      \n      tlambj = ebar[kj];\n      tlambk = ebar[kk];\n      \n      /* Find parameter values of points on edges used to evaluate\n\t actual blending surface.  */\n\n      tpar1 = ((double)1.0 - tlambj)*sstart[ki] + tlambj*send[ki];\n      tpar2 = tlambk*sstart[kk] + ((double)1.0 - tlambk)*send[kk];\n \n      /* Evaluate position and cross-tangent curves at first\n\t found parameter value.  */\n\n      s1221(ecurve[2*ki],kder,tpar1,&kleft,spos1+knmb*ki,&kstat);\n      if (kstat < 0) goto error;\n      \n      s1221(ecurve[2*ki+1],kder,tpar1,&kleft,sder1+knmb*ki,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Evaluate position and cross-tangent curves at second\n\t found parameter value.  */\n      \n      s1221(ecurve[2*kk],kder,tpar2,&kleft,spos2+knmb*ki,&kstat);\n      if (kstat < 0) goto error;\n      \n      s1221(ecurve[2*kk+1],kder,tpar2,&kleft,sder2+knmb*ki,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Evaluate position and both cross-tangents at the corner nr ki.  */\n\n      s1221(ecurve[2*ki],0,sstart[ki],&kleft,scorn+ki*kdim,&kstat);\n      if (kstat < 0) goto error;\n\n      s1221(ecurve[2*kk+1],0,send[kk],&kleft,scornder1+ki*kdim,&kstat);\n      if (kstat < 0) goto error;\n\n      s1221(ecurve[2*ki+1],0,sstart[ki],&kleft,scornder2+ki*kdim,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Compute the weigth of the actual blending surface.  */\n\n      salpha[ki] = tlambi*tlambi*((double)3.0 - (double)2.0*tlambi +\n\t\t\t\t  (double)6.0*tlambj*tlambk);\n      \n      /* Add the contribution of the value of this blending surface to the\n\t value of the ideal surface.   */\n\n      for (kh=0; kh<kdim; kh++)\n\t{\n\t  sp[ki*kdim+kh] = spos1[knmb*ki+kh] + tlambk*sder1[knmb*ki+kh] +\n\t    spos2[knmb*ki+kh] + tlambj*sder2[knmb*ki+kh] -\n\t      scorn[ki*kdim+kh] - tlambj*scornder1[ki*kdim+kh] \n\t\t- tlambk*scornder2[ki*kdim+kh] -\n\t\t  tlambj*tlambk*etwist[ki*kdim+kh];\n\t  \n\t  eval[kh] += salpha[ki]*sp[ki*kdim+kh];\n\t}\n    }\n  \n  if (ider >= 1)\n    {\n      /* Compute first derivatives of the Gregory Charrot function. */\n\n      double tl1,tl2,tl3;            /* Barycentric coordinates.  */\n      double sd1alpha[3],sd2alpha[3];  /* 1. derivative of weight functions. */\n      double sd1p[9],sd2p[9];        /* 1. derivative of blending functions. */\n      \n      /* Copy barycentric coordinates to local variables.  */\n\n      tl1 = ebar[0];\n      tl2 = ebar[1];\n      tl3 = ebar[2];\n      \n      /* Compute the 1. derivatives of the weight functions.  */\n\n      sd1alpha[0] = (double)6.0*tl1*((double)1.0 - tl1 - tl1*tl2 + \n\t\t\t\t  (double)2.0*tl2*tl3);\n      sd2alpha[0] = (double)6.0*tl1*tl1*(tl3 - tl2);\n\n      sd1alpha[1] = (double)6.0*tl2*tl2*(tl3 - tl1);\n      sd2alpha[1] = (double)6.0*tl2*((double)1.0 - tl2 - tl1*tl2 + \n\t\t\t\t  (double)2.0*tl1*tl3);\n\n      sd1alpha[2] = (double)6.0*tl3*(-(double)1.0 + tl3 + tl2*tl3 - \n\t\t\t\t  (double)2.0*tl1*tl2);\n      sd2alpha[2] = (double)6.0*tl3*(-(double)1.0 + tl3 + tl1*tl3 - \n\t\t\t\t  (double)2.0*tl1*tl2);\n      \n      /* Compute 1. derivatives of the functions which blends two sides\n\t of the region.  */\n\n      for (kh=0; kh<kdim; kh++)\n\t{\n\t  sd1p[kh] = (spos2[kdim+kh] + tl2*sder2[kdim+kh])*sint[2]\n\t    - sder1[kh] + scornder2[kh] + tl2*etwist[kh];\n\t  sd2p[kh] = (spos2[kdim+kh] + tl2*sder2[kdim+kh])*sint[2] \n\t    + (spos1[kdim+kh] + tl3*sder1[kdim+kh])*sint[0]\n\t      + sder2[kh] - sder1[kh] - scornder1[kh]\n\t\t+ scornder2[kh] + (tl2 - tl3)*etwist[kh];\n\n\t  sd1p[kdim+kh] = -sder2[knmb+kh] + sder1[knmb+kh]\n\t    - (spos2[knmb+kdim+kh] + tl3*sder2[knmb+kdim+kh])*sint[0] \n\t      - (spos1[knmb+kdim+kh] + tl1*sder1[knmb+kdim+kh])*sint[1] \n\t\t+ scornder1[kdim+kh] - scornder2[kdim+kh]\n\t\t  + (tl1 - tl3)*etwist[kdim+kh];\n\t  sd2p[kdim+kh] = - sder2[knmb+kh]\n\t    - (spos1[knmb+kdim+kh] + tl1*sder1[knmb+kdim+kh])*sint[1]\n\t      + scornder1[kdim+kh] + tl1*etwist[kdim+kh];\n\n\t  sd1p[2*kdim+kh] = sder2[2*knmb+kh]\n\t    + (spos1[2*knmb+kdim+kh] + tl2*sder1[2*knmb+kdim+kh])*sint[2]\n\t      - scornder1[2*kdim+kh] - tl2*etwist[2*kdim+kh];\n\t  sd2p[2*kdim+kh] = sder1[2*knmb+kh]\n\t     - (spos2[2*knmb+kdim+kh] + tl1*sder2[2*knmb+kdim+kh])*sint[1]\n\t      - scornder2[2*kdim+kh] - tl1*etwist[2*kdim+kh];\n\t  \n\t  /* Compute the first derivative of the Gregory Charrot function. */\n\n\t  for (ki=0; ki<3; ki++)\n\t    {\n\t      eval[kdim+kh] += sd1alpha[ki]*sp[ki*kdim+kh]\n\t\t+ salpha[ki]*sd1p[ki*kdim+kh];\n\n\t      eval[2*kdim+kh] += sd2alpha[ki]*sp[ki*kdim+kh]\n\t\t+ salpha[ki]*sd2p[ki*kdim+kh];\n\t    }\n\t}\n      \n      if (ider >= 2)\n\t{\n\t  double sd11alpha[3],sd12alpha[3],sd22alpha[3];  /* 2. derivatives of\n                                                             blending patches. */\n\t  double sd11p[9],sd12p[9],sd22p[9];  /* 2. derivatives of weight function. */\n\t  \n\t  /* Compute second derivatives of the Gregory Charrot function. */\n\n\t  /* Compute the 2. derivatives of the weight functions.  */\n\n\t  sd11alpha[0] = (double)6.0 - (double)12.0*tl1 \n\t    - (double)24.0*tl1*tl2 + (double)12.0*tl2*tl3;\n\t  sd12alpha[0] = tl1*((double)12.0 - (double)18.0*tl1\n\t\t\t      - (double)24.0*tl2);\n\t  sd22alpha[0] = -(double)12.0*tl1*tl1;\n\t  \n\t  sd11alpha[1] = -(double)12.0*tl2*tl2; \n\t  sd12alpha[1] = tl2*((double)12.0 - (double)18.0*tl2\n\t\t\t      - (double)24.0*tl1);\n\t  sd22alpha[1] = (double)6.0 - (double)12.0*tl2 \n\t    - (double)24.0*tl1*tl2 + (double)12.0*tl1*tl3;\n\n\t  sd11alpha[2] = (double)6.0 - (double)12.0*tl3 \n\t    - (double)24.0*tl2*tl3 + (double)12.0*tl1*tl2;\n\t  sd12alpha[2] = (double)6.0 + (double)6.0*tl3*tl3\n\t    + (double)12.0*(-tl3 + tl1*tl2 - tl1*tl3 - tl2*tl3);\n\t  sd22alpha[2] = (double)6.0 - (double)12.0*tl3 \n\t    - (double)24.0*tl1*tl3 + (double)12.0*tl1*tl2;\n\n\t  /* Compute 2. derivatives of the functions which blends two sides\n\t     of the region.  */\n\n\t  for (kh=0; kh<kdim; kh++)\n\t    {\n\t      sd11p[kh] = (spos2[2*kdim+kh]+ tl2*sder2[2*kdim+kh])*sint[2]*sint[2];\n\t      sd12p[kh] = ((spos2[2*kdim+kh] + tl2*sder2[2*kdim+kh])*sint[2]\n\t\t\t   + sder2[kdim+kh]*sint[2] - sder1[kdim+kh])*sint[0] \n\t\t\t      + etwist[kh];\n\t      sd22p[kh] = ((spos2[2*kdim+kh] + tl2*sder2[2*kdim+kh])*sint[2]\n\t\t\t   + (double)2.0*sder2[kdim+kh])*sint[2]\n\t\t\t     + ((spos1[2*kdim+kh] + tl3*sder1[2*kdim+kh])*sint[0]\n\t\t\t\t- (double)2.0*sder1[kdim+kh])*sint[0]\n\t\t\t\t  + (double)2.0*etwist[kh];\n\t      \n\t      sd11p[kdim+kh] = ((spos2[knmb+2*kdim+kh] \n\t\t\t\t + tl3*sder2[knmb+2*kdim+kh])*sint[0]\n\t\t\t\t+ (double)2.0*sder2[knmb+kdim+kh])*sint[0]\n\t\t\t\t  + ((spos1[knmb+2*kdim+kh] \n\t\t\t\t      + tl1*sder1[knmb+2*kdim+kh])*sint[1]\n\t\t\t\t     - (double)2.0*sder1[knmb+kdim+kh])*sint[1]\n\t\t\t\t       + (double)2.0*etwist[kdim+kh];\n\t      sd12p[kdim+kh] = ((spos1[knmb+2*kdim+kh] \n\t\t\t\t + tl1*sder1[knmb+2*kdim+kh])*sint[1]\n\t\t\t\t- sder1[knmb+kdim+kh])*sint[1]\n\t\t\t\t  + sder2[knmb+kdim+kh]*sint[0]\n\t\t\t\t  + etwist[kdim+kh];\n\t      sd22p[kdim+kh] = (spos1[knmb+2*kdim+kh]\n\t\t\t\t+ tl1*sder1[knmb+2*kdim+kh])*sint[1]*sint[1];\n\t      \n\t      sd11p[2*kdim+kh] = (spos1[2*knmb+2*kdim+kh]\n\t\t\t\t  + tl2*sder1[2*knmb+2*kdim+kh])*sint[2]*sint[2];\n\t      sd12p[2*kdim+kh] = -sder2[2*knmb+kdim+kh]*sint[1] \n\t\t+ sder1[2*knmb+kdim+kh]*sint[2] - etwist[2*kdim+kh];\n\t      sd22p[2*kdim+kh] = (spos2[2*knmb+2*kdim+kh]\n\t\t\t\t+ tl1*sder2[2*knmb+2*kdim+kh])*sint[1]*sint[1];\n\n\t      /* Compute the 2. derivative of the Gregory Charrot function. */\n\n\t      for (ki=0; ki<3; ki++)\n\t\t{\n\t\t  eval[3*kdim+kh] += sd11alpha[ki]*sp[ki*kdim+kh]\n\t\t    + (double)2.0*sd1alpha[ki]*sd1p[ki*kdim+kh]\n\t\t      + salpha[ki]*sd11p[ki*kdim+kh];\n\t\t  \n\t\t  eval[4*kdim+kh] += sd12alpha[ki]*sp[ki*kdim+kh]\n\t\t    + sd1alpha[ki]*sd2p[ki*kdim+kh] \n\t\t      + sd2alpha[ki]*sd1p[ki*kdim+kh]\n\t\t\t+ salpha[ki]*sd12p[ki*kdim+kh];\n\t\t  \n\t\t  eval[5*kdim+kh] += sd22alpha[ki]*sp[ki*kdim+kh]\n\t\t    + (double)2.0*sd2alpha[ki]*sd2p[ki*kdim+kh]\n\t\t      + salpha[ki]*sd22p[ki*kdim+kh];\n\t\t}\n\t    }\n\t}\n    }\n  \n  /* Ideal surface evaluated.  */\n\n  *jstat = kwarn;\n  goto out;\n\n\n  /* Error in lower level function.  */\n\n  error :\n    *jstat = kstat;\n  goto out;\n\n  out :\n    return;\n}\n\n\n\t\t\t      \n\t     \n\n\n"
  },
  {
    "path": "src/sh1467.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1467.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define SH1467\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void sh1467_s9fac1(double [],double [],double [],int,int,int,double *,\n\t\t\t  double *,double *);\nstatic void sh1467_s9fac2(double [],double [],double [],int,int,int,double *,\n\t\t\t  double *,double *,double *,double *,double *);\n#else\n  static void  sh1467_s9fac1(); \n  static void  sh1467_s9fac2(); \n#endif  \n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n  sh1467(SISLCurve *ecurve[],double etwist[],int ider,double ebar[],\n\t double eval[],int *jstat)\n#else\t   \nvoid sh1467(ecurve,etwist,ider,ebar,eval,jstat)\n     double etwist[],ebar[],eval[];\n     SISLCurve *ecurve[];\n     int ider,*jstat;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Given the barycentric coordinates of a point in a 5-sided\n*              vertex region, evaluate the value of the ideal blending \n*              surface of the vertex region in this point.\n*\n*\n*\n* INPUT      : ecurve - Position and cross-tangent curves around the vertex\n*                       region. For each edge of the region position and cross-\n*                       tangent curves are given. The curves follow each other\n*                       around the region and are oriented counter-clock-wise.\n*                       The dimension of the array is 10.\n*              etwist - Twist-vectors of the corners of the vertex region. The\n*                       first element of the array is the twist in the corner\n*                       before the first edge, etc. The dimension of the array\n*                       is 5*kdim.\n*              ider   - Number of derivatives to compute. Directions of \n*                       differentiation is that of the two first barycentric\n*                       coordinates. 0 <= ider <= 2.\n*              ebar   - Generalized barycentric coordinates of the point to be \n*                       evaluated. The dimension of the array is 5.\n*                       \n*\n* OUTPUT     : eval   - Value and derivatives of ideal blending surface in the \n*                       parameter directions of the two first coordinates in the \n*                       given point. Dimension of the array is 3*(1+..+(ider+1)).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : A functional description of the ideal surface is given as\n*              a blend between five surfaces, each of which fulfill the\n*              continuity requirements over two edges.\n*\n* REFERENCES : Gregory and Charrot : A pentagonal surface patch for\n*                                    computer aided geometric design\n*\n* USE        : 3D geometry only.\n*\n*-\n* CALLS      : s1221 - Evaluate curve at a given parameter value.\n*              sh1467_s9fac1() - Compute value and derivative of expression \n*\t\t\t         in the barycentric coordinates.  \n*              sh1467_s9fac2() - Compute value, first and second derivative.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 04.90.\n*\n*********************************************************************\n*/\n{\n  int kstat=0;         /* Status variable.                                */\n  int ki,kj,kk,kh;     /* Counters.                                       */\n  int kder;            /* Number of derivatives to evaluate.              */\n  int kleft = 0;       /* Local parameter used in s1221.                  */\n  int kdim = 3;        /* Dimension of geometry.                          */\n  int kwarn = 0;       /* Indicates if a warning is to be sendt.          */\n  int knmb;            /* Number of doubles pr derivative.                */\n  int kl = 0;          /* Number of derivatives in the output array.      */\n  double tdum;         /* Product of three barycentric coordinates.       */\n  double tdenom;       /* Denominator of weight function.                 */\n  double salpha[5];    /* Weigth of actual blending surface.              */\n  double sp[15];       /* Value of function interpolating two sides.      */\n  double sstart[5];    /* Start-parameters of edge-curves.                */\n  double send[5];      /* End-parameters of edge-curves.                  */\n  double sint[5];      /* Parameter intervals of edge-curves.             */\n  double sx1[5];       /* First local coordinates of the blending patches.  */\n  double sx2[5];       /* Second local coordinates of the blending patches. */\n  double spar[5];      /* Parameter values of edges.                      */\n  double spos[45];     /* Position of edge-curve.                         */\n  double sder[45];     /* Value of oss tangent.                           */\n  double scorn[15];    /* Position of edge-curves in actual corner of \n\t\t\t  vertex region.                                  */\n  double scornder1[15]; /* Tangent in corner along next edge.             */\n  double scornder2[15]; /* Tangent in corner along previous edge.         */\n\n  /* Test input.  */\n\n  if (ider > 2) kwarn = 1;\n  \n  /* Initialise.  */\n\n  kder = ider;\n  knmb = kdim*(ider+1);\n  for (ki=0; ki<ider; ki++) kl += ider + 1;\n  \n  /* Initiate output array to zero.  */\n\n  for (kh=0; kh<kl*kdim; kh++) eval[kh] = (double)0.0;\n        \n  for (ki=0; ki<5; ki++)\n    {\n\n      /* Get endpoints of parameter intervals of edge curves.  */\n\n      sstart[ki] = *(ecurve[2*ki] -> et + ecurve[2*ki] -> ik - 1);\n      send[ki] = *(ecurve[2*ki] -> et + ecurve[2*ki] -> in);\n      sint[ki] = send[ki] - sstart[ki];\n\n      /* Compute local coordinates corresponding to one blending patch. */\n      \n      kj = (ki + 2) % 5;\n      kk = (ki > 0) ? ki-1 : 4;\n      sx1[ki] = ebar[kj]/(ebar[kk] + ebar[kj]);\n      \n      kj = (ki > 1) ? ki-2 : 3+ki;\n      kk = (ki + 1) % 5;\n      sx2[ki] = ebar[kj]/(ebar[kk] + ebar[kj]);\n      \n      /* Compute parameter value corresponding to the current edge. */\n\n      spar[kj] = ((double)1.0 - sx1[ki])*sstart[ki] + sx1[ki]*send[ki];\n\n      /* Evaluate position and cross-tangent curves at points on\n\t the edges needed when evaluating surface.        */\n \n      /* Evaluate position and cross-tangent curves at parameter value.  */\n\n      s1221(ecurve[2*ki],kder,spar[kj],&kleft,spos+knmb*kj,&kstat);\n      if (kstat < 0) goto error;\n      \n      s1221(ecurve[2*ki+1],kder,spar[kj],&kleft,sder+knmb*kj,&kstat);\n      if (kstat < 0) goto error;\n \n      /* Evaluate position and both cross-tangents at the corner nr ki.  */\n\n      kk = (ki > 0) ? ki-1 : 4;\n      s1221(ecurve[2*ki],0,sstart[ki],&kleft,scorn+ki*kdim,&kstat);\n      if (kstat < 0) goto error;\n\n      s1221(ecurve[2*kk+1],0,send[kk],&kleft,scornder1+ki*kdim,&kstat);\n      if (kstat < 0) goto error;\n\n      s1221(ecurve[2*ki+1],0,sstart[ki],&kleft,scornder2+ki*kdim,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* Compute position of the Gregory Charrot patch at the given parameter\n     value.  First compute factors in the expression of the weight function. */\n\n  tdenom = (double)0.0;\n  for (kh=0; kh<5; kh++)\n    {\n      kj = (kh + 1) % 5;\n      kk = (kh > 0) ? kh-1 : 4;\t  \n\n      tdum = ebar[kk]*ebar[kh]*ebar[kj];\n      tdenom += tdum*tdum;\n    }\n\n  for (ki=0; ki<5; ki++)\n    {\n\n      kj = (ki + 1) % 5;\n      kk = (ki > 0) ? ki-1 : 4;\n\n      /* Compute the weigth of the actual blending surface.  */\n\n      tdum = ebar[kk]*ebar[ki]*ebar[kj];\n      salpha[ki] = tdum*tdum/tdenom;\n\n      /* Compute the blending surface.  */\n\n      kj = (ki + 2) % 5;\n      kk = (ki > 1) ? ki-2 : 3+ki;\n\n      for (kh=0; kh<kdim; kh++)\n\t{\n\t  sp[ki*kdim+kh] = spos[knmb*kj+kh] + sx1[ki]*sder[knmb*kj+kh] +\n\t    spos[knmb*kk+kh] + sx2[ki]*sder[knmb*kk+kh] -\n\t      scorn[ki*kdim+kh] - sx1[ki]*scornder1[ki*kdim+kh] \n\t\t- sx2[ki]*scornder2[ki*kdim+kh] -\n\t\t  sx1[ki]*sx2[ki]*etwist[ki*kdim+kh];\n\t  \n\t  /* Add the contribution of the value of this blending surface to the\n\t     value of the ideal surface.   */\n\n\t  eval[kh] += salpha[ki]*sp[ki*kdim+kh];\n\t}\n    }\n  \n  if (ider >= 1)\n    {\n      /* Compute first derivatives of the Gregory Charrot function. */\n\n      double tconst = (sqrt((double)5.0) - (double)1.0)/(double)2.0; /* Constant. */\n      double tdum1,tdum2; /* Factor in expression for derivative of weight function.*/\n      double tnom1,tnom2; /* Factor in expression for derivative of weight function.*/\n      double sd1alpha[5],sd2alpha[5]; /* 1. derivative of weight functions. */\n      double sd1p[15],sd2p[15];       /* 1. derivative of blending functions. */\n      double sd1bar[5],sd2bar[5];     /* 1. derivative of barycentric coordinates.*/\n      double sd1x1[5],sd2x1[5];       /* 1. derivative of local coordinates.  */      \n      double sd1x2[5],sd2x2[5];       /* 1. derivative of local coordinates.  */      \n      double sd1par[5],sd2par[5];     /* 1. derivative of parameter value at edge. */\n\n      /* Differentiate barycentric coordinates.  */\n\n      sd1bar[0] = (double)1.0;\n      sd1bar[1] = (double)0.0;\n      sd1bar[2] = -(double)1.0;\n      sd1bar[3] = -tconst;\n      sd1bar[4] = tconst;\n\n      sd2bar[0] = (double)0.0;\n      sd2bar[1] = (double)1.0;\n      sd2bar[2] = tconst;\n      sd2bar[3] = -tconst;\n      sd2bar[4] = -(double)1.0;\n\n      for (ki=0; ki<5; ki++)\n\t{\n\t  /* Differentiate local coordinates.  */      \n\n\t  kj = (ki + 2) % 5;\n\t  kk = (ki > 0) ? ki-1 : 4;\n\t  tdum = ebar[kk] + ebar[kj];\n\t  sd1x1[ki] = sd1bar[kj]/tdum\n\t    - ebar[kj]*(sd1bar[kk] + sd1bar[kj])/(tdum*tdum);\n\t  sd2x1[ki] = sd2bar[kj]/tdum\n\t    - ebar[kj]*(sd2bar[kk] + sd2bar[kj])/(tdum*tdum);\n\n\t  kj = (ki > 1) ? ki-2 : 3+ki;\n\t  kk = (ki + 1) % 5;\n\t  tdum = ebar[kk] + ebar[kj];\n\t  sd1x2[ki] = sd1bar[kj]/tdum\n\t    - ebar[kj]*(sd1bar[kk] + sd1bar[kj])/(tdum*tdum);\n\t  sd2x2[ki] = sd2bar[kj]/tdum\n\t    - ebar[kj]*(sd2bar[kk] + sd2bar[kj])/(tdum*tdum);\n\n\t  /* Compute derivative of parameter value corresponding to\n\t     the current edge.  */\n\n\t  sd1par[kj] = sint[ki]*sd1x1[ki];\n\t  sd2par[kj] = sint[ki]*sd2x1[ki];\n\t}\n      \n      /* Compute factors used in the expression for the 1. derivatives of\n\t the weight function.  */\n\n      tnom1 = tnom2 = (double)0.0;\n      for (kh=0; kh<5; kh++)\n\t{\n\t  kj = (kh + 1) % 5;\n\t  kk = (kh > 0) ? kh-1 : 4;\t  \n\t      \n\t  sh1467_s9fac1(ebar,sd1bar,sd2bar,kk,kh,kj,&tdum,&tdum1,&tdum2);\n\n\t  tnom1 += (double)2.0*tdum*tdum1;\n\t  tnom2 += (double)2.0*tdum*tdum2;\n\t}\n      \n\n      for (ki=0; ki<5; ki++)\n\t{\n\t  /* Compute the 1. derivatives of the weight functions.  */\n\n\t  kj = (ki + 1) % 5;\n\t  kk = (ki > 0) ? ki-1 : 4;\t  \n\t  \n\t  sh1467_s9fac1(ebar,sd1bar,sd2bar,kk,ki,kj,&tdum,&tdum1,&tdum2);    \n\n\t  sd1alpha[ki] = tdum*((double)2.0*tdum1 - tdum*tnom1/tdenom)/tdenom;\n\t  sd2alpha[ki] = tdum*((double)2.0*tdum2 - tdum*tnom2/tdenom)/tdenom;\n      \n\t  /* Compute 1. derivatives of the functions which blends two sides\n\t     of the region.  */\n\n\t  kj = (ki + 2) % 5;\n\t  kk = (ki > 1) ? ki-2 : 3+ki;\t  \n\n\t  for (kh=0; kh<kdim; kh++)\n\t    {\n\t      sd1p[ki*kdim+kh] = spos[kj*knmb+kdim+kh]*sd1par[kj]\n\t\t+ sd1x1[ki]*sder[kj*knmb+kh] \n\t\t  + sx1[ki]*sder[kj*knmb+kdim+kh]*sd1par[kj]\n\t\t    + spos[kk*knmb+kdim+kh]*sd1par[kk]\n\t\t      + sd1x2[ki]*sder[kk*knmb+kh]\n\t\t\t+ sx2[ki]*sder[kk*knmb+kdim+kh]*sd1par[kk]\n\t\t\t  - sd1x1[ki]*scornder1[ki*kdim+kh]\n\t\t\t    - sd1x2[ki]*scornder2[ki*kdim+kh]\n\t\t\t      - (sd1x1[ki]*sx2[ki] \n\t\t\t\t + sx1[ki]*sd1x2[ki])*etwist[ki*kdim+kh];\n\n\t      sd2p[ki*kdim+kh] = spos[kj*knmb+kdim+kh]*sd2par[kj]\n\t\t+ sd2x1[ki]*sder[kj*knmb+kh] \n\t\t  + sx1[ki]*sder[kj*knmb+kdim+kh]*sd2par[kj]\n\t\t    + spos[kk*knmb+kdim+kh]*sd2par[kk]\n\t\t      + sd2x2[ki]*sder[kk*knmb+kh]\n\t\t\t+ sx2[ki]*sder[kk*knmb+kdim+kh]*sd2par[kk]\n\t\t\t  - sd2x1[ki]*scornder1[ki*kdim+kh]\n\t\t\t    - sd2x2[ki]*scornder2[ki*kdim+kh]\n\t\t\t      - (sd2x1[ki]*sx2[ki] \n\t\t\t\t + sx1[ki]*sd2x2[ki])*etwist[ki*kdim+kh];\n\n\t      /* Add the contribution from this blending surface to the first \n\t\t derivative of the Gregory Charrot function. */\n\n\t      eval[kdim+kh] += sd1alpha[ki]*sp[ki*kdim+kh]\n\t\t+ salpha[ki]*sd1p[ki*kdim+kh]; \n\n\t      eval[2*kdim+kh] += sd2alpha[ki]*sp[ki*kdim+kh]\n\t\t+ salpha[ki]*sd2p[ki*kdim+kh]; \n\t    }\n\t}\n      \n      if (ider >= 2)\n\t{\n\t  double sd11alpha[5],sd12alpha[5],sd22alpha[5];  /* 2. derivatives of\n\t\t\t\t\t\t\t     weight function.  */\n\t  double sd11p[15],sd12p[15],sd22p[15];  /* 2. derivatives of blending\n\t\t\t\t\t\t    surfaces.                  */\n\t  double sd11x1[5],sd12x1[5],sd22x1[5];  /* 2. derivatives of local\n\t\t\t\t\t\t    coordinates.               */\n\t  double sd11x2[5],sd12x2[5],sd22x2[5];  /* 2. derivatives of local\n\t\t\t\t\t\t    coordinates.               */\n\t  double sd11par[5],sd12par[5],sd22par[5];  /* 2. derivatives of\n\t\t\t\t\t\t       parameter value at edge. */\n\t  double tdum11,tdum12,tdum22;  /* Factor in expression for 2.\n\t\t\t\t\t   derivative of weight function.*/\n\t  double tnom11,tnom12,tnom22;  /* Factor in expression for 2.\n\t\t\t\t\t   derivative of weight function.*/\n\t  \n\t  /* Compute second derivatives of the Gregory Charrot function. */\n\n\t  for (ki=0; ki<5; ki++)\n\t    {\n\t      /* Differentiate local coordinates.  */      \n\n\t      kj = (ki + 2) % 5;\n\t      kk = (ki > 0) ? ki-1 : 4;\n\t      tdum = ebar[kk] + ebar[kj];\n\t      tdum1 = sd1bar[kk] + sd1bar[kj];\n\t      tdum2 = sd2bar[kk] + sd2bar[kj];\n\t  \n\t      sd11x1[ki] = (double)2.0*(ebar[kj]*tdum1*tdum1/tdum\n\t\t\t\t\t- sd1bar[kj]*tdum1)/(tdum*tdum);\n\t      sd12x1[ki] = ((double)2.0*ebar[kj]*tdum1*tdum2/tdum\n\t\t\t    - sd1bar[kj]*tdum2 - sd2bar[kj]*tdum1)/(tdum*tdum);\n\t      sd22x1[ki] = (double)2.0*(ebar[kj]*tdum2*tdum2/tdum\n\t\t\t\t\t- sd2bar[kj]*tdum2)/(tdum*tdum);\n\n\t      kj = (ki > 1) ? ki-2 : 3+ki;\n\t      kk = (ki + 1) % 5;\n\t      tdum = ebar[kk] + ebar[kj];\n\t      tdum1 = sd1bar[kk] + sd1bar[kj];\n\t      tdum2 = sd2bar[kk] + sd2bar[kj];\n\t  \n\t      sd11x2[ki] = (double)2.0*(ebar[kj]*tdum1*tdum1/tdum\n\t\t\t\t\t- sd1bar[kj]*tdum1)/(tdum*tdum);\n\t      sd12x2[ki] = ((double)2.0*ebar[kj]*tdum1*tdum2/tdum\n\t\t\t    - sd1bar[kj]*tdum2 - sd2bar[kj]*tdum1)/(tdum*tdum);\n\t      sd22x2[ki] = (double)2.0*(ebar[kj]*tdum2*tdum2/tdum\n\t\t\t\t\t- sd2bar[kj]*tdum2)/(tdum*tdum);\n\n\t      /* Compute derivative of parameter value corresponding to\n\t\t the current edge.  */\n\n\t      sd11par[kj] = sint[ki]*sd11x1[ki];\n\t      sd12par[kj] = sint[ki]*sd12x1[ki];\n\t      sd22par[kj] = sint[ki]*sd22x1[ki];\n\t    }\n\n      /* Compute factors used in the expression for the 2. derivatives of\n\t the weight function.  */\n\n\t  tnom11 = tnom12 = tnom22 = (double)0.0;\n\t  for (kh=0; kh<5; kh++)\n\t    {\n\t      kj = (kh + 1) % 5;\n\t      kk = (kh > 0) ? kh-1 : 4;\t  \n\t      \n              sh1467_s9fac2(ebar,sd1bar,sd2bar,kk,kh,kj,&tdum,&tdum1,&tdum2,\n\t\t     &tdum11,&tdum12,&tdum22);\n\t      \n\t      tnom11 += (double)2.0*(tdum1*tdum1 + tdum*tdum11);\n\t      tnom12 += (double)2.0*(tdum1*tdum2 + tdum*tdum12);\n\t      tnom22 += (double)2.0*(tdum2*tdum2 + tdum*tdum22);\n\n\t    }\n\n\t  for (ki=0; ki<5; ki++)\n\t    {\n\t      \n\t      /* Compute the 2. derivatives of the weight functions.  */\n\n\t      kj = (ki + 1) % 5;\n\t      kk = (ki > 0) ? ki-1 : 4;\t  \n\t      \n\t      sh1467_s9fac2(ebar,sd1bar,sd2bar,kk,ki,kj,&tdum,&tdum1,&tdum2,\n\t\t     &tdum11,&tdum12,&tdum22);\n\t      \n\t      sd11alpha[ki] = (double)2.0*(tdum1*tdum1 + tdum*tdum11)/tdenom\n\t\t- (double)4.0*tdum*tdum1*tnom1/(tdenom*tdenom)\n\t\t  - tdum*tdum*tnom11/(tdenom*tdenom) \n                     + (double)2.0*tdum*tdum*tnom1*tnom1/(tdenom*tdenom*tdenom);\n\n\t      sd12alpha[ki] = (double)2.0*(tdum1*tdum2 + tdum*tdum12)/tdenom\n\t\t- (double)2.0*tdum*(tdum1*tnom2 + tdum2*tnom1)/(tdenom*tdenom)\n\t\t  - tdum*tdum*tnom12/(tdenom*tdenom)\n\t\t    + (double)2.0*tdum*tdum*tnom1*tnom2/(tdenom*tdenom*tdenom);\n\n\t      sd22alpha[ki] = (double)2.0*(tdum2*tdum2 + tdum*tdum22)/tdenom\n\t\t- (double)4.0*tdum*tdum2*tnom2/(tdenom*tdenom)\n\t\t  - tdum*tdum*tnom22/(tdenom*tdenom)\n\t\t    + (double)2.0*tdum*tdum*tnom2*tnom2/(tdenom*tdenom*tdenom);\n\t      \n\t      /* Compute 2. derivatives of the functions which blends two sides\n\t\t of the region.  */\n\n\t      kj = (ki + 2) % 5;\n\t      kk = (ki > 1) ? ki - 2 : 3 + ki;\n\t      \n\t      for (kh=0; kh<kdim; kh++)\n\t\t{\n\t\t  sd11p[ki*kdim+kh] = spos[kj*knmb+2*kdim+kh]*sd1par[kj]*sd1par[kj]\n\t\t    + spos[kj*knmb+kdim+kh]*sd11par[kj]\n\t\t      + sd11x1[ki]*sder[kj*knmb+kh]\n\t\t\t+ (double)2.0*sd1x1[ki]*sder[kj*knmb+kdim+kh]*sd1par[kj]\n\t\t\t  + sx1[ki]*sder[kj*knmb+2*kdim+kh]*sd1par[kj]*sd1par[kj]\n\t\t\t    + sx1[ki]*sder[kj*knmb+kdim+kh]*sd11par[kj]\n\t\t\t      + (double)2.0*sd1x2[ki]*sder[kk*knmb+kdim+kh]*sd1par[kk]\n\t\t\t\t+ sx2[ki]*sder[kk*knmb+2*kdim+kh]*sd1par[kk]*sd1par[kk]\n\t\t\t\t  + spos[kk*knmb+2*kdim+kh]*sd1par[kk]*sd1par[kk]\n\t\t\t\t    + spos[kk*knmb+kdim+kh]*sd11par[kk]\n\t\t\t\t      + sd11x2[ki]*sder[kk*knmb+kh]\n\t\t\t\t\t+ sx2[ki]*sder[kk*knmb+kdim+kh]*sd11par[kk]\n\t\t\t\t\t  - sd11x1[ki]*scornder1[ki*kdim+kh]\n\t\t\t\t\t    - sd11x2[ki]*scornder2[ki*kdim+kh]\n\t\t\t\t\t      - (sd11x1[ki]*sx2[ki] \n\t\t\t\t\t\t + (double)2.0*sd1x1[ki]*sd1x2[ki]\n\t\t\t\t\t\t + sx1[ki]*sd11x2[ki])\n\t\t\t\t\t\t*etwist[ki*kdim+kh];\n\t      \n\t\t  sd12p[ki*kdim+kh] = spos[kj*knmb+2*kdim+kh]*sd1par[kj]*sd2par[kj]\n\t\t    + spos[kj*knmb+kdim+kh]*sd12par[kj]\n\t\t      + sd12x1[ki]*sder[kj*knmb+kh]\n\t\t\t+ sd1x1[ki]*sder[kj*knmb+kdim+kh]*sd2par[kj]\n\t\t\t  + sd2x1[ki]*sder[kj*knmb+kdim+kh]*sd1par[kj]\n\t\t\t    + sx1[ki]*sder[kj*knmb+2*kdim+kh]*sd1par[kj]*sd2par[kj]\n\t\t\t      + sx1[ki]*sder[kj*knmb+kdim+kh]*sd12par[kj]\n\t\t\t\t+ sx2[ki]*sder[kk*knmb+2*kdim+kh]*sd1par[kk]*sd2par[kk]\n\t\t\t\t  + spos[kk*knmb+2*kdim+kh]*sd1par[kk]*sd2par[kk]\n\t\t\t\t    + spos[kk*knmb+kdim+kh]*sd12par[kk]\n\t\t\t\t      + sd12x2[ki]*sder[kk*knmb+kh]\n\t\t\t\t\t+ sd1x2[ki]*sder[kk*knmb+kdim+kh]*sd2par[kk]\n\t\t\t\t\t  + sd2x2[ki]*sder[kk*knmb+kdim+kh]*sd1par[kk]\n\t\t\t\t\t    + sx2[ki]*sder[kk*knmb+kdim+kh]*sd12par[kk]\n\t\t\t\t\t      - sd12x1[ki]*scornder1[ki*kdim+kh]\n\t\t\t\t\t\t- sd12x2[ki]*scornder2[ki*kdim+kh]\n\t\t\t\t\t\t  - (sd12x1[ki]*sx2[ki] \n\t\t\t\t\t\t     + sd1x1[ki]*sd2x2[ki]\n\t\t\t\t\t\t     + sd2x1[ki]*sd1x2[ki]\n\t\t\t\t\t\t     + sx1[ki]*sd12x2[ki])\n\t\t\t\t\t\t    *etwist[ki*kdim+kh];\n\n\t\t  sd22p[ki*kdim+kh] = spos[kj*knmb+2*kdim+kh]*sd2par[kj]*sd2par[kj]\n\t\t    + spos[kj*knmb+kdim+kh]*sd22par[kj]\n\t\t      + sd22x1[ki]*sder[kj*knmb+kh]\n\t\t\t+ (double)2.0*sd2x1[ki]*sder[kj*knmb+kdim+kh]*sd2par[kj]\n\t\t\t  + sx1[ki]*sder[kj*knmb+2*kdim+kh]*sd2par[kj]*sd2par[kj]\n\t\t\t    + sx1[ki]*sder[kj*knmb+kdim+kh]*sd22par[kj]\n\t\t\t      + (double)2.0*sd2x2[ki]*sder[kk*knmb+kdim+kh]*sd2par[kk]\n\t\t\t\t+ sx2[ki]*sder[kk*knmb+2*kdim+kh]*sd2par[kk]*sd2par[kk]\n\t\t\t\t  + spos[kk*knmb+2*kdim+kh]*sd2par[kk]*sd2par[kk]\n\t\t\t\t    + spos[kk*knmb+kdim+kh]*sd22par[kk]\n\t\t\t\t      + sd22x2[ki]*sder[kk*knmb+kh]\n\t\t\t\t\t+ sx2[ki]*sder[kk*knmb+kdim+kh]*sd22par[kk]\n\t\t\t\t\t  - sd22x1[ki]*scornder1[ki*kdim+kh]\n\t\t\t\t\t    - sd22x2[ki]*scornder2[ki*kdim+kh]\n\t\t\t\t\t      - (sd22x1[ki]*sx2[ki] \n\t\t\t\t\t\t + (double)2.0*sd2x1[ki]*sd2x2[ki]\n\t\t\t\t\t\t + sx1[ki]*sd22x2[ki])\n\t\t\t\t\t\t*etwist[ki*kdim+kh];\n\t      \n\n\t\t  /* Add the current contribution to the 2. derivative of the Gregory \n\t\t     Charrot function. */\n\n\t\t  eval[3*kdim+kh] += sd11alpha[ki]*sp[ki*kdim+kh]\n\t\t    + (double)2.0*sd1alpha[ki]*sd1p[ki*kdim+kh]\n\t\t      + salpha[ki]*sd11p[ki*kdim+kh];\n\t\t  \n\t\t  eval[4*kdim+kh] += sd12alpha[ki]*sp[ki*kdim+kh]\n\t\t    + sd1alpha[ki]*sd2p[ki*kdim+kh] \n\t\t      + sd2alpha[ki]*sd1p[ki*kdim+kh]\n\t\t\t+ salpha[ki]*sd12p[ki*kdim+kh];\n\t\t  \n\t\t  eval[5*kdim+kh] += sd22alpha[ki]*sp[ki*kdim+kh]\n\t\t    + (double)2.0*sd2alpha[ki]*sd2p[ki*kdim+kh]\n\t\t      + salpha[ki]*sd22p[ki*kdim+kh];\n\t\t}\n\t    }\n\t}\n    }\n  \n  /* Ideal surface evaluated.  */\n\n  *jstat = kwarn;\n  goto out;\n\n\n  /* Error in lower level function.  */\n\n  error :\n    *jstat = kstat;\n  goto out;\n\n  out :\n    return;\n}\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  sh1467_s9fac1(double ebar[],double ed1bar[],double ed2bar[],\n\t\tint i1,int i2,int i3,double *cfac,double *cfac1,\n\t\tdouble *cfac2)\n#else\t       \nstatic void sh1467_s9fac1(ebar,ed1bar,ed2bar,i1,i2,i3,cfac,cfac1,cfac2)\n     int i1,i2,i3;\n     double ebar[],ed1bar[],ed2bar[],*cfac,*cfac1,*cfac2;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Compute value and 1. derivative of product of barycentric\n*              coordinates.\n*\n*\n*\n* INPUT      : ebar   - Array containing value of barycentric coordinates.\n*              ed1bar - Array containing derivative in first parameter \n*                       direction of barycentric coordinates.\n*              ed2bar - Array containing derivative in second parameter \n*                       direction of barycentric coordinates.\n*              i1     - Index of first barycentric coordinate in product.\n*              i2     - Index of second barycentric coordinate in product.\n*              i3     - Index of third barycentric coordinate in product.\n*                       \n*\n* OUTPUT     : cfac   - Product of barycentric coordinates.\n*              cfac1  - Derivative in first parameter direction of product.\n*              cfac2  - Derivative in second parameter direction of product.\n*\n*\n* WRITTEN BY : Vibeke Skytt, SI, 04.90.\n*\n*********************************************************************\n*/\n{\n  *cfac = ebar[i1]*ebar[i2]*ebar[i3];\n  *cfac1 = ed1bar[i1]*ebar[i2]*ebar[i3] + ebar[i1]*ed1bar[i2]*ebar[i3]\n    + ebar[i1]*ebar[i2]*ed1bar[i3];\n  *cfac2 = ed2bar[i1]*ebar[i2]*ebar[i3] + ebar[i1]*ed2bar[i2]*ebar[i3]\n    + ebar[i1]*ebar[i2]*ed2bar[i3];\n\n  return;\n}\n\n  \n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  sh1467_s9fac2(double ebar[],double ed1bar[],double ed2bar[],\n\t\tint i1,int i2,int i3,double *cfac,double *cfac1,\n\t\tdouble *cfac2,double *cfac11,double *cfac12,\n\t\tdouble *cfac22)\n#else\t       \nstatic void sh1467_s9fac2(ebar,ed1bar,ed2bar,i1,i2,i3,cfac,cfac1,cfac2,\n\t\t\t  cfac11,cfac12,cfac22)\n     int i1,i2,i3;\n     double ebar[],ed1bar[],ed2bar[],*cfac,*cfac1,*cfac2,*cfac11;\n     double *cfac12,*cfac22;\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Compute value and 1. and 2. derivatives of product of \n*              barycentric coordinates.\n*\n*\n*\n* INPUT      : ebar   - Array containing value of barycentric coordinates.\n*              ed1bar - Array containing derivative in first parameter \n*                       direction of barycentric coordinates.\n*              ed2bar - Array containing derivative in second parameter \n*                       direction of barycentric coordinates.\n*              i1     - Index of first barycentric coordinate in product.\n*              i2     - Index of second barycentric coordinate in product.\n*              i3     - Index of third barycentric coordinate in product.\n*                       \n*\n* OUTPUT     : cfac   - Product of barycentric coordinates.\n*              cfac1  - Derivative in first parameter direction of product.\n*              cfac2  - Derivative in second parameter direction of product.\n*              cfac11 - 2. derivative in first parameter direction of product.\n*              cfac11 - Mixed derivative of product.\n*              cfac22 - 2. derivative in second parameter direction of product.\n*\n*\n* WRITTEN BY : Vibeke Skytt, SI, 04.90.\n*\n*********************************************************************\n*/\n{\n  \n  *cfac = ebar[i1]*ebar[i2]*ebar[i3];\n  *cfac1 = ed1bar[i1]*ebar[i2]*ebar[i3] + ebar[i1]*ed1bar[i2]*ebar[i3]\n    + ebar[i1]*ebar[i2]*ed1bar[i3];\n  *cfac2 = ed2bar[i1]*ebar[i2]*ebar[i3] + ebar[i1]*ed2bar[i2]*ebar[i3]\n    + ebar[i1]*ebar[i2]*ed2bar[i3];\n  *cfac11 = ed1bar[i1]*(ed1bar[i2]*ebar[i3] + ebar[i2]*ed1bar[i3])\n    + ed1bar[i2]*(ed1bar[i1]*ebar[i3] + ebar[i1]*ed1bar[i3])\n      + ed1bar[i3]*(ed1bar[i1]*ebar[i2] + ebar[i1]*ed1bar[i2]);\n  *cfac12 = ed1bar[i1]*(ed2bar[i2]*ebar[i3] + ebar[i2]*ed2bar[i3])\n    + ed1bar[i2]*(ed2bar[i1]*ebar[i3] + ebar[i1]*ed2bar[i3])\n      + ed1bar[i3]*(ed2bar[i1]*ebar[i2] + ebar[i1]*ed2bar[i2]);\n  *cfac22 = ed2bar[i1]*(ed2bar[i2]*ebar[i3] + ebar[i2]*ed2bar[i3])\n    + ed2bar[i2]*(ed2bar[i1]*ebar[i3] + ebar[i1]*ed2bar[i3])\n      + ed2bar[i3]*(ed2bar[i1]*ebar[i2] + ebar[i1]*ed2bar[i2]);\n}\n\n\n\n"
  },
  {
    "path": "src/sh1502.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1502.c,v 1.2 2001-03-19 15:59:04 afr Exp $\n *\n */\n\n\n#define SH1502\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \nsh1502(SISLCurve *pc1,double base[],double norm[],double axisA[],double alpha,double ratio,int idim,\n\t   double aepsco,double aepsge,\n\tint trackflag,int *jtrack,SISLTrack ***wtrack,\n\tint *jpt,double **gpar,int **pretop,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid sh1502(pc1,base,norm,axisA,alpha,ratio,idim,aepsco,aepsge,\n\ttrackflag,jtrack,wtrack,jpt,gpar,pretop,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     double   base[];\n     double   norm[];\n     double   axisA[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a curve and an elliptic cone.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve.\n*              base   - Base point of cone\n*              norm   - Direction of cone axis\n*              axisA  - One of the two ellipse axis vectors\n*              alpha  - The opening angle of the cone at axisA\n*              ratio  - The ratio of axisA to axisB\n*              idim   - Dimension of the space in which the plane/line\n*                       lies. idim should be equal to two or three.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the curve is put into the equation of the\n*              cone achieving a curve in the one-dimentional space.\n*              The zeroes of this curve is found.\n*\n*\n* REFERENCES :\n*\n*- \n* CALLS      : sh1761 - Find point/curve intersections.\n*              hp_s1880 - Put intersections into output format.\n*              s1500 - Make description of cone as matrix\n*              s1370 - Put curve into implicit equation\n*              make_cv_kreg - Ensure k-regularity of input curve.\n*              newCurve   - Create new curve.\n*              newPoint   - Create new point.                        \n*              newObject  - Create new object.\n*              freeObject - Free the space occupied by a given object.\n*              freeIntdat - Free the space occupied by intersection result.\n*\n* WRITTEN BY : Mike Floater, SI, 18/10/90.\n*\n*********************************************************************\n*/                                                               \n{                                                                     \n  double *nullp = SISL_NULL;\n  int kstat = 0;             /* Local status variable.                       */\n  int kpos = 0;              /* Position of error.                           */\n  int kdim=1;                /* Dimension of curve in curve/point intersection.*/\n  double sarray[16];         /* Array for represetnation of implicit surface */\n  double spoint[1];          /* SISLPoint in curve/point intersection.           */\n  double *spar = SISL_NULL;       /* Values of intersections in the parameter \n\t\t\t\tarea of the second object. Empty in this case. */\n  SISLCurve *qc = SISL_NULL;          /* Pointer to curve in \n\t\t\t\tcurve/point intersection.  */\n  SISLPoint *qp = SISL_NULL;          /* Pointer to point in \n\t\t\t\tcurve/point intersection.  */ \n  SISLObject *qo1 = SISL_NULL;        /* Pointer to object in \n\t\t\t\tobject/point intersection.*/\n  SISLObject *qo2 = SISL_NULL;        /* Pointer to object in \n\t\t\t\tobject/point intersection.*/\n  SISLIntdat *qintdat = SISL_NULL;   /* Pointer to intersection data */\n  int      ksurf=0;         /* Dummy number of Intsurfs. */\n  SISLIntsurf **wsurf=SISL_NULL;    /* Dummy array of Intsurfs. */\n  int      kdeg=2000;       /* input to int_join_per. */\n  SISLObject *track_obj=SISL_NULL;\n  SISLCurve *qkreg=SISL_NULL; /* Input surface ensured k-regularity. */\n\n  /* -------------------------------------------------------- */  \n\n  if (pc1->cuopen == SISL_CRV_PERIODIC)\n  {\n     /* Cyclic curve. */\n\n     make_cv_kreg(pc1,&qkreg,&kstat);\n     if (kstat < 0) goto error;\n   }\n  else\n    qkreg = pc1;\n\n  /*\n  * Create new object and connect curve to object.\n  * ------------------------------------------------\n  */\n  \n  if (!(track_obj = newObject (SISLCURVE)))\n    goto err101;\n  track_obj->c1 = pc1;\n\n  /* \n   * Check dimension.  \n   * ----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if ( idim != 3) goto err104;\n  if (qkreg -> idim != idim) goto err103;\n\n  /* \n   * Make a matrix of dimension (idim+1)(idim+1) to describe the cone\n   * -------------------------------------------------------------------------\n   */\n\n  s1500(base,norm,axisA,alpha,ratio,idim,kdim,sarray,&kstat);\n  if (kstat<0) goto error;\n\n  /* \n   * Put curve into cone equation \n   * -------------------------------------------\n   */ \n\n  s1370(qkreg,sarray,idim,kdim,0,&qc,&kstat);\n  if (kstat<0) goto error;\n\n  /* \n   * Create new object and connect curve to object.  \n   * ----------------------------------------------\n   */\n\n  if (!(qo1 = newObject(SISLCURVE))) goto err101;\n  qo1 -> c1 = qc;\n  qo1 -> o1 = qo1;\n\n  /*\n   * Create new object and connect point to object.\n   * ----------------------------------------------\n   */\n\n  if (!(qo2 = newObject(SISLPOINT))) goto err101;\n  spoint[0] = DZERO;\n  if (!(qp = newPoint(spoint,kdim,1))) goto err101;\n  qo2 -> p1 = qp;\n\n  /* \n   * Find intersections.  \n   * -------------------\n   */\n\n  sh1761(qo1,qo2,aepsge,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj,track_obj,nullp,kdeg,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n      make_tracks (qo1, qo2, 0, nullp,\n\t\t   qintdat->ilist, qintdat->vlist, \n\t\t   jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* \n   * Express intersections on output format.  \n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(track_obj, track_obj, kdeg,\n\t       1,0,qintdat,jpt,gpar,&spar,pretop,jcrv,wcurve,&ksurf,&wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;                                                   \n        s6err(\"sh1502\",*jstat,kpos);\n        goto out;\n\n  /* Dimensions conflicting.  */\n\n err103: *jstat = -103;\n        s6err(\"sh1502\",*jstat,kpos);\n        goto out;\n\n  /* Dimension not equal to two or three.  */\n\n err104: *jstat = -104;                          \n        s6err(\"sh1502\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n        s6err(\"sh1502\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if (spar)    freearray(spar);\n  if (qo1)     freeObject(qo1);\n  if (qo2)     freeObject(qo2);\n  if (qintdat) freeIntdat(qintdat);\n  if (track_obj)\n    {\n       track_obj->c1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n\n  /* Free local curve.  */\n\n  if (qkreg != SISL_NULL && qkreg != pc1) freeCurve(qkreg);\nreturn;\n}                                               \n                                           \n                       \n\n"
  },
  {
    "path": "src/sh1503.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1503.c,v 1.3 2001-03-19 15:59:04 afr Exp $\n *\n */\n\n\n#define SH1503\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh1503(SISLSurf *ps1,double base[],double norm[],double axisA[],double alpha,\n       double ratio,int idim,double aepsco,double aepsge,\n       int trackflag,int *jtrack,SISLTrack ***wtrack,\n       int *jpt,double **gpar,int **pretop,int *jcrv,SISLIntcurve ***wcurve,\n       int *jsurf,SISLIntsurf ***wsurf,int *jstat)\n#else\nvoid sh1503(ps1,base,norm,axisA,alpha,ratio,idim,aepsco,aepsge,trackflag,\n\t    jtrack,wtrack,jpt,gpar,pretop,jcrv,wcurve,jsurf,wsurf,jstat)\n     SISLSurf     *ps1;\n     double   base[];\n     double   norm[];\n     double   axisA[];\n     double   alpha;\n     double   ratio;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jsurf;\n     SISLIntsurf ***wsurf;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find all intersections between a tensor-product surface\n*              and a cone.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve.\n*              base   - Base point of cone\n*              norm   - Direction of cone axis\n*              axisA  - One of the two ellipse axis vectors\n*              alpha  - The opening angle of the cone at axisA\n*              ratio  - The ratio of axisA to axisB\n*              idim     - Dimension of the space in which the cone lies.\n*              aepsco   - Computational resolution.\n*              aepsge   - Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       plane of the surface. The points lie continuous.\n*                       Intersection curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the surface are put into the equation of\n*              the cone resulting in a surface in one-dimensional space.\n*              Then the zeroes of this surface are found.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1761       - Perform point object-intersection.\n*              s1320       - Put equation of surface into equation of implicit\n*                            surface.\n*              s1500       - Represent cone as implicit function.\n*              hp_s1880       - Put intersections on output format.\n*              make_sf_kreg   - Ensure k-regularity of surface.\n*              newObject   - Create new object.\n*              newPoint    - Create new point.\n*              freeObject  - Free space occupied by an object.\n*              freeIntdat  - Free space occupied by an intersection data.\n*\n* WRITTEN BY : Mike Floater, SI, 90-10.\n* Changed by : Per OEyvind Hvidsten, SINTEF, 1194.\n*              jcrv and jsurf set to zero when no intersection are found.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;           /* Local status varible.                        */\n  int kpos = 0;            /* Position of error.                           */\n  int kdim = 1;            /* Dimension of space in which the point in the\n\t\t\t      intersect point/surface problem lies.        */\n  double *spar = SISL_NULL;     /* Dummy array containing parameter values of\n\t\t\t      second object of single intersection points. */\n  double spoint[1];        /* SISLPoint to intersect with object.              */\n  double *scone = SISL_NULL;    /* Description of a cone as implicit surface. */\n  SISLSurf *qs = SISL_NULL;         /* Pointer to surface in\n\t\t\t      surface/point intersection.*/\n  SISLPoint *qp = SISL_NULL;        /* Pointer to point in\n\t\t\t      surface/point intersection.  */\n  SISLObject *qo1 = SISL_NULL;      /* Pointer to surface in\n\t\t\t      object/point intersection. */\n  SISLObject *qo2 = SISL_NULL;      /* Pointer to point in\n\t\t\t      object/point intersection    */\n  SISLIntdat *qintdat = SISL_NULL;  /* Intersection result */\n  int kdeg=2;         /* The degree of the implicit equation   */\n  SISLObject *track_obj=SISL_NULL;\n  SISLSurf *qkreg=SISL_NULL; /* Input surface ensured k-regularity. */\n\n  /* -------------------------------------------------------- */\n\n  if (ps1->cuopen_1 == SISL_SURF_PERIODIC ||\n      ps1->cuopen_2 == SISL_SURF_PERIODIC)\n  {\n     /* Cyclic surface. */\n\n     make_sf_kreg(ps1,&qkreg,&kstat);\n     if (kstat < 0) goto error;\n   }\n  else\n    qkreg = ps1;\n\n  /*\n  * Create new object and connect surface to object.\n  * ------------------------------------------------\n  */\n\n  if (!(track_obj = newObject (SISLSURFACE)))\n    goto err101;\n  track_obj->s1 = ps1;\n\n  /*\n   * Check dimension.\n   * ----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if (idim != qkreg -> idim) goto err106;\n\n  /*\n   * Allocate space for matrix describing a cone.\n   * --------------------------------------------\n   */\n\n  if ((scone = newarray((idim+1)*(idim+1),double)) == SISL_NULL) goto err101;\n\n  /*\n   * Make a matrix of dimension (idim+1)x(idim+1) describing a\n   * cone as an implicit function.\n   * ---------------------------------------------------------\n   */\n\n  s1500(base,norm,axisA,alpha,ratio,idim,1,scone,&kstat);\n  if (kstat < 0) goto error;\n\n  /*\n   * Put the description of the input surface into the implicit\n   * equation for the cone.\n   * ----------------------------------------------------------\n   */\n\n  s1320(qkreg,scone,1,0,&qs,&kstat);\n  if (kstat < 0) goto error;\n\n  /*\n   * Create new object and connect surface to object.\n   * ------------------------------------------------\n   */\n\n  if(!(qo1 = newObject(SISLSURFACE))) goto err101;\n  qo1 -> s1 = qs;\n  qo1 -> o1 = qo1;\n\n  /*\n   * Create new object and connect point to object.\n   * ----------------------------------------------\n   */\n\n  if (!(qo2 = newObject(SISLPOINT))) goto err101;\n  spoint[0] = DZERO;\n  if (!(qp = newPoint(spoint,kdim,1))) goto err101;\n  qo2 -> p1 = qp;\n\n  /*\n   * Find intersections.\n   * -------------------\n   */\n\n  sh1761(qo1,qo2,aepsge,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Represent degenerated intersection curves as one point.  */\n\n  sh6degen(track_obj,track_obj,&qintdat,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n\n      refine_all (&qintdat, track_obj, track_obj, scone, kdeg, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n\n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj,track_obj,scone,kdeg,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  if (trackflag && qintdat)\n    {\n       make_tracks (track_obj, track_obj, kdeg, scone,\n\t\t    qintdat->ilist, qintdat->vlist,\n\t\t    jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n    }\n\n  /*\n   * Express intersections on output format.\n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(track_obj, track_obj, kdeg,\n\t       2,0,qintdat,jpt,gpar,&spar,pretop,jcrv,wcurve,jsurf,wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  else\n  {\n    *jcrv = 0;\n    *jsurf = 0;\n  }\n\n  /*\n   * Intersections found.\n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;\n        s6err(\"sh1503\",*jstat,kpos);\n        goto out;\n\n  /* Dimensions conflicting.  */\n\n err106: *jstat = -106;\n        s6err(\"sh1503\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n        s6err(\"sh1503\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if (spar)    freearray(spar);\n  if (scone)   freearray(scone);\n  if (qo1)     freeObject(qo1);\n  if (qo2)     freeObject(qo2);\n  if (qintdat) freeIntdat(qintdat);\n  if (track_obj)\n    {\n       track_obj->s1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n\n  /* Free local surface.  */\n    if (qkreg != SISL_NULL && qkreg != ps1) freeSurf(qkreg);\n\nreturn;\n}\n"
  },
  {
    "path": "src/sh1510.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1510.c,v 1.3 2001-03-19 15:59:04 afr Exp $\n *\n */\n\n\n#define SH1510\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh1510(SISLSurf * ps,double eyepoint[],int idim,double aepsco,\n\t    double aepsge,int trackflag,int *jtrack,SISLTrack ***wtrack,\n\t    int *jpt,double **gpar,int **pretop,int *jcrv,\n\t    SISLIntcurve ***wcurve,int *jsurf,SISLIntsurf ***wsurf,int *jstat)\n#else\nvoid sh1510(ps, eyepoint, idim, aepsco, aepsge,\ttrackflag,jtrack,wtrack,\n\t    jpt,gpar,pretop,jcrv,wcurve,jsurf,wsurf,jstat)\n     SISLSurf *ps;\n     double eyepoint[];\n     int idim;\n     double aepsco;\n     double aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int *jpt;\n     double **gpar;\n     int      **pretop;\n     int *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jsurf;\n     SISLIntsurf ***wsurf;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find the silhouette curves and points of a surface when\n*              the surface is viewed perspectively from a specific eye point. In\n*              addition to the points and curves found by this routine,\n*              break curves and edge-curves might be silhouette curves.\n*\n*\n*\n* INPUT      : ps  -       Pointer to the surface.\n*              eyepoint -  The eye point vector.\n*              idim   -    Dimension of the space in which eyepoint lies.\n*              aepsco -    Computational resolution.\n*              aepsge -    Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single silhouette points in the parameter\n*                       plane of the surface. The points lie continuous.\n*                       Silhouette curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              jcrv   - Number of silhouette curves.\n*              wcurve - Array containing descriptions of the silhouette\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1761       - Perform point object-intersection.\n*              s1512       - Make a function whose zeroes describe the\n*                            silhouette lines of a surface.\n*              hp_s1880       - Put intersections on output format.\n*              make_sf_kreg   - Ensure k-regularity of surface.\n*              newObject   - Create new object.\n*              newPoint    - Create new point.\n*              freeObject  - Free space occupied by an object.\n*              freeIntdat  - Free space occupied by an intersection data.\n*\n* WRITTEN BY : Mike Floater, SI, 90-11.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov. 1994. Added\n*              initialization of 'jsurf'.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Local status varible.                        */\n  int kpos = 0;\t\t\t/* Position of error.                           */\n  int kdim = 1;\t\t\t/* Dimension of space in which the point in the\n\t\t\t\t   intersect point and surface problem lies.    */\n  double *spar = SISL_NULL;\t\t/* Dummy array containing parameter values of\n\t\t\t\t   second object of single intersection points. */\n  double spoint[1];\t\t/* SISLPoint to intersect with object.              */\n  SISLSurf *qs = SISL_NULL;\t\t/* Surface whose zeroes are the silhouette\n\t\t\t       curves/points of the original surface.     */\n  SISLPoint *qp = SISL_NULL;\t\t/* Pointer to point in\n\t\t\t       surface/point intersection.  */\n  SISLObject *qo1 = SISL_NULL;\t/* Pointer to surface in\n\t\t\t       object/point intersection. */\n  SISLObject *qo2 = SISL_NULL;\t/* Pointer to point in\n\t\t\t       object/point intersection    */\n  SISLIntdat *qintdat = SISL_NULL;\t/* Intersection result */\n  int kdeg = 1004;              /* The degree of the implicit equation */\n  double simpli[16];             /* Array containing the implicit description */\n\n  SISLObject *track_obj=SISL_NULL;\n  SISLSurf *qkreg=SISL_NULL; /* Input surface ensured k-regularity. */\n\n  /* -------------------------------------------------------- */\n\n  if (ps->cuopen_1 == SISL_SURF_PERIODIC ||\n      ps->cuopen_2 == SISL_SURF_PERIODIC)\n  {\n     /* Cyclic surface. */\n\n     make_sf_kreg(ps,&qkreg,&kstat);\n     if (kstat < 0) goto error;\n   }\n  else\n    qkreg = ps;\n\n  /*\n  * Create new object and connect surface to object.\n  * ------------------------------------------------\n  */\n\n  if (!(track_obj = newObject (SISLSURFACE)))\n    goto err101;\n  track_obj->s1 = ps;\n\n  simpli[0] = eyepoint[0];\n  simpli[1] = eyepoint[1];\n  simpli[2] = eyepoint[2];\n\n\n\n\n\n\n  /*\n   * Check dimension.\n   * ----------------\n   */\n\n  *jpt = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n  *jsurf = 0;\n\n  if (idim != qkreg->idim)\n    goto err106;\n\n  /*\n   * Make surface whose zeroes describe silhouette lines.\n   * ----------------------------------------------------\n   */\n\n  s1512 (qkreg, eyepoint, idim, &qs, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /*\n   * Create new object and connect surface to object.\n   * ------------------------------------------------\n   */\n\n  if (!(qo1 = newObject (SISLSURFACE)))\n    goto err101;\n  qo1->s1 = qs;\n  qo1->o1 = qo1;\n\n  /*\n   * Create new object and connect point to object.\n   * ----------------------------------------------\n   */\n\n  if (!(qo2 = newObject (SISLPOINT)))\n    goto err101;\n  spoint[0] = DZERO;\n  if (!(qp = newPoint (spoint, kdim, 1)))\n    goto err101;\n  qo2->p1 = qp;\n\n  /*\n   * Find intersections.\n   * -------------------\n   */\n\n  sh1761 (qo1, qo2, aepsge, &qintdat, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Represent degenerated intersection curves as one point.  */\n\n  sh6degen(track_obj,track_obj,&qintdat,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Split curves at knots where the surface is only C1. */\n\n  spli_silh(&qintdat,track_obj,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n\n      refine_all (&qintdat, track_obj, track_obj, simpli, kdeg, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj,track_obj,simpli,kdeg,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  if (trackflag && qintdat)\n    {\n      make_tracks (track_obj, track_obj, kdeg, simpli,\n\t\t   qintdat->ilist, qintdat->vlist,\n\t\t   jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n    }\n\n  /*\n   * Express silhouette curves and points on output format.\n   * -----------------------------------------------------\n   */\n\n  if (qintdat)\t\t\t/* Only if there were intersections found */\n    {\n      hp_s1880(track_obj, track_obj, kdeg,\n\t       2,0,qintdat,jpt,gpar,&spar,pretop,jcrv,wcurve,jsurf,wsurf,&kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n\n  /*\n   * Silhouette curves and points found.\n   * ----------------------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\nerr101:*jstat = -101;\n  s6err (\"sh1510\", *jstat, kpos);\n  goto out;\n\n  /* Dimensions conflicting.  */\n\nerr106:*jstat = -106;\n  s6err (\"sh1510\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\nerror:*jstat = kstat;\n  s6err (\"sh1510\", *jstat, kpos);\n  goto out;\n\nout:\n\n  /* Free allocated space.  */\n\n  if (spar)\n    freearray (spar);\n  if (qo1)\n    freeObject (qo1);\n  if (qo2)\n    freeObject (qo2);\n  if (qintdat)\n    freeIntdat (qintdat);\n  if (track_obj)\n    {\n       track_obj->s1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n\n  /* Free local surface.  */\n    if (qkreg != SISL_NULL && qkreg != ps) freeSurf(qkreg);\n\n  return;\n}\n"
  },
  {
    "path": "src/sh1511.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1511.c,v 1.2 2001-03-19 15:59:04 afr Exp $\n *\n */\n\n\n#define SH1511\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh1511(SISLSurf *ps,double qpoint[],double bvec[],int idim,double aepsco,\n\t    double aepsge,int trackflag,int *jtrack,SISLTrack ***wtrack,\n\t    int *jpt,double **gpar,int **pretop,int *jcrv,\n\t    SISLIntcurve ***wcurve,int *jsurf,SISLIntsurf ***wsurf,int *jstat)\n#else\nvoid sh1511(ps, qpoint, bvec, idim, aepsco, aepsge,trackflag,jtrack,\n\t    wtrack,jpt,gpar,pretop,jcrv,wcurve,jsurf,wsurf,jstat)\n     SISLSurf *ps;\n     double qpoint[];\n     double bvec[];\n     int idim;\n     double aepsco;\n     double aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int *jpt;\n     double **gpar;\n     int      **pretop;\n     int *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jsurf;\n     SISLIntsurf ***wsurf;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find the circular silhouette curves and points of a surface when\n*              the surface is viewed from a specific eye point. In\n*              addition to the points and curves found by this routine,\n*              break curves and edge-curves might be silhouette curves.\n*\n*\n*\n* INPUT      : ps  -      Pointer to the surface.\n*              qpoint -   A point on the spin axis.\n*              bvec  -    The circular silhouette axis direction.\n*              idim   -   Dimension of the space in which axis lies.\n*              aepsco -   Computational resolution.\n*              aepsge -   Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single silhouette points in the parameter\n*                       plane of the surface. The points lie continuous.\n*                       Silhouette curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              jcrv   - Number of silhouette curves.\n*              wcurve - Array containing descriptions of the silhouette\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1761       - Perform point object-intersection.\n*              s1513       - Make a function whose zeroes describe the\n*                            circular silhouette curves of a surface.\n*              hp_s1880       - Put intersections on output format.\n*              make_sf_kreg   - Ensure k-regularity of surface.\n*              newObject   - Create new object.\n*              newPoint    - Create new point.\n*              freeObject  - Free space occupied by an object.\n*              freeIntdat  - Free space occupied by an intersection data.\n*\n* WRITTEN BY : Mike Floater, SI, 90-11.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Local status varible.                        */\n  int kpos = 0;\t\t\t/* Position of error.                           */\n  int kdim = 1;\t\t\t/* Dimension of space in which the point in the\n\t\t\t\t   intersect point and surface problem lies.    */\n  double *spar = SISL_NULL;\t\t/* Dummy array containing parameter values of\n\t\t\t\t   second object of single intersection points. */\n  double spoint[1];\t\t/* SISLPoint to intersect with object.              */\n  SISLSurf *qs = SISL_NULL;\t\t/* Surface whose zeroes are the silhouette\n\t\t\t       curves/points of the original surface.     */\n  SISLPoint *qp = SISL_NULL;\t\t/* Pointer to point in\n\t\t\t       surface/point intersection.  */\n  SISLObject *qo1 = SISL_NULL;\t/* Pointer to surface in\n\t\t\t       object/point intersection. */\n  SISLObject *qo2 = SISL_NULL;\t/* Pointer to point in\n\t\t\t       object/point intersection    */\n  SISLIntdat *qintdat = SISL_NULL;\t/* Intersection result */\n  int kdeg = 1005;\n  double simpli[16];\n  double snorm[3];\n  SISLObject *track_obj=SISL_NULL;\n  SISLSurf *qkreg=SISL_NULL; /* Input surface ensured k-regularity. */\n\n  /* -------------------------------------------------------- */  \n\n  if (ps->cuopen_1 == SISL_SURF_PERIODIC ||\n      ps->cuopen_2 == SISL_SURF_PERIODIC)\n  {\n     /* Cyclic surface. */\n\n     make_sf_kreg(ps,&qkreg,&kstat);\n     if (kstat < 0) goto error;\n   }\n  else\n    qkreg = ps;\n  \n  /*\n  * Create new object and connect surface to object.\n  * ------------------------------------------------\n  */\n  \n  if (!(track_obj = newObject (SISLSURFACE)))\n    goto err101;\n  track_obj->s1 = ps;\n  \n  /* Normalize bvec direction vector */\n  \n  (void) s6norm (bvec, idim, snorm, &kstat);\n  \n  \n  simpli[0] = qpoint[0];\n  simpli[1] = qpoint[1];\n  simpli[2] = qpoint[2];\n  \n  simpli[3] = snorm[0];\n  simpli[4] = snorm[1];\n  simpli[5] = snorm[2];\n  \n  /*\n   * Check dimension.\n   * ----------------\n   */\n\n  *jpt = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if (idim != qkreg->idim)\n    goto err106;\n\n  /*\n   * Make surface whose zeroes describe silhouette lines.\n   * ----------------------------------------------------\n   */\n\n  s1513 (qkreg, qpoint, bvec, idim, &qs, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /*\n   * Create new object and connect surface to object.\n   * ------------------------------------------------\n   */\n\n  if (!(qo1 = newObject (SISLSURFACE)))\n    goto err101;\n  qo1->s1 = qs;\n  qo1->o1 = qo1;\n\n  /*\n   * Create new object and connect point to object.\n   * ----------------------------------------------\n   */\n\n  if (!(qo2 = newObject (SISLPOINT)))\n    goto err101;\n  spoint[0] = DZERO;\n  if (!(qp = newPoint (spoint, kdim, 1)))\n    goto err101;\n  qo2->p1 = qp;\n\n  /*\n   * Find intersections.\n   * -------------------\n   */\n\n  sh1761 (qo1, qo2, aepsge, &qintdat, &kstat);\n  if (kstat < 0)\n    goto error;\n  \n  /* Represent degenerated intersection curves as one point.  */\n  \n  sh6degen(track_obj,track_obj,&qintdat,aepsge,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Split curves at knots where the surface is only C1. */\n  \n  spli_silh(&qintdat,track_obj,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n \n      refine_all (&qintdat, track_obj, track_obj, simpli, kdeg, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n    }\n  \n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj,track_obj,simpli,kdeg,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  \n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n      make_tracks (track_obj, track_obj, kdeg, simpli,\n\t\t   qintdat->ilist, qintdat->vlist, \n\t\t   jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /*\n   * Express silhouette curves and points on output format.\n   * -----------------------------------------------------\n   */\n\n  if (qintdat)\t\t\t/* Only if there were intersections found */\n    {\n      hp_s1880(track_obj, track_obj, kdeg,\n\t       2,0,qintdat,jpt,gpar,&spar,pretop,jcrv,wcurve,jsurf,wsurf,&kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n\n  /*\n   * Silhouette curves and points found.\n   * ----------------------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\nerr101:*jstat = -101;\n  s6err (\"sh1511\", *jstat, kpos);\n  goto out;\n\n  /* Dimensions conflicting.  */\n\nerr106:*jstat = -106;\n  s6err (\"sh1511\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\nerror:*jstat = kstat;\n  s6err (\"sh1511\", *jstat, kpos);\n  goto out;\n\nout:\n\n  /* Free allocated space.  */\n\n  if (spar)\n    freearray (spar);\n  if (qo1)\n    freeObject (qo1);\n  if (qo2)\n    freeObject (qo2);\n  if (qintdat)\n    freeIntdat (qintdat);\n  if (track_obj)\n    {\n       track_obj->s1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n\n  /* Free local surface.  */\n    if (qkreg != SISL_NULL && qkreg != ps) freeSurf(qkreg);\n\n  return;\n}\n\n"
  },
  {
    "path": "src/sh1761.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1761.c,v 1.7 2001-03-19 15:59:04 afr Exp $\n *\n */\n\n\n#define SH1761\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh1761 (SISLObject * po1, SISLObject * po2, double aepsge, SISLIntdat ** pintdat, int *jstat)\n#else\nvoid\nsh1761 (po1, po2, aepsge, pintdat, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     SISLIntdat **pintdat;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*          NOTE : Comments for further developments/tasks starts\n*                 with <comment-sign> UPDATE :\n*\n*\n* PURPOSE    : Find all intersections between two objects (of type\n*              point, curve or surface). In this rouine the outer\n*              edges/endpoints of the objects are treated.\n*\n*\n*\n* INPUT      : po1    - First object in the intersection.\n*              po2    - Second object in the intersection.\n*              aepsge - Geometry resolution.\n*              *jstat    - Flag\n*                          = 202 : Complicated point-surface intersection\n*                                  in 3D. Perform extra interception test.\n*\n*\n*\n*\n*\n*\n* OUTPUT     : intdat - Intersection dates found beetween the two\n*                       objects.\n*              jstat  - status messages\n*                                       = 1      : Intersection found\n*                                       = 0      : no intersection\n*                                       < 0      : error\n*\n*\n* METHOD     : This function is computing point/point intersection\n*              otherwise it is computing edge/endpoint intersections\n*              by recurson on one end object and the other object,\n*              and futher calling a rutine for computing intersections\n*              in the inner of an object.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err      - Gives error message.\n*              s6dist     - Compute the distance beetween two point.\n*              s1435      - Pick edge curve from a surface.\n*              s1438      - Pick endpoint from a curve.\n*              sh1762      - Find the intersections in the inner of the objects.\n*              sh1790      - Perform BOX test.\n*              sh6idnpt    - Put a new intpt to given intdat.\n*              sh6idput    - Put contence of one intdat in an other intdat.\n*              sh6idlis    - Compute list elements from given intdat.\n*              sh6idalledg - Uppdate edges from given intdat.\n*              freeEdge   - Free space occupied by given edge.\n*              freePoint  - Free space occupied by given point.\n*              freeCurve  - Free space occupied by given curve.\n*              freeObject - Free space occupied by given object.\n*              freeIntdat - Free space occupied by given intdat.\n*              newEdge    - Create new edge-structure.\n*              hp_newIntpt   - Create new intersection point-structure.\n*              newObject  - Create new object.\n*\n* WRITTEN BY : Arne Laksaa, 05.89.\n*              UJK, 06.91 newi\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov.1994. Fixed memory\n*              leaks from 'qt', 'qedge', and 'qintdat' - occured on error exits.\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Local status variable.                 */\n  int kpos = 0;\t\t\t/* Position of error.                     */\n  int ktotal = 1;\t\t/* Make totally expanded box.             */\n  int kxintercept = (*jstat == 202);  /* Extra interception               */\n  double tpar;\t\t\t/* Help variable used for parameter value\n\t\t\t\t   and geometric distance.                */\n  SISLObject *po1_kreg=SISL_NULL;    /* Pointer to first object converted to\n\t\t\t\t   k-regular basis.                       */\n  SISLObject *po2_kreg=SISL_NULL;    /* Pointer to second object converted to\n\t\t\t\t   k-regular basis.                       */\n  SISLIntpt *qt = SISL_NULL;         /* Temporary intersection point. */\n  SISLEdge *qedge[2];\t        /* Edges for use in s1862().      */\n  SISLIntdat *qintdat = SISL_NULL;\t/* Intdat for use in recurson.    */\n\n  double *nullp = SISL_NULL;\n  int idummy;\n\n  qedge[0] = qedge[1] = SISL_NULL;  /* PFU - to fix memory leak */\n\n\n  /* Ensure K-regularity on B-spline basis ________________*/\n  if (po1->iobj == SISLCURVE)\n    {\n       if (po1->c1->cuopen == SISL_CRV_PERIODIC)\n\t {\n\t    if ((po1_kreg = newObject (SISLCURVE)) == SISL_NULL)\n\t      goto err101;\n\t    make_cv_kreg(po1->c1, &po1_kreg->c1, &kstat);\n\t    if (kstat < 0) goto error;\n\t }\n       else po1_kreg = po1;\n\n    }\n  else if (po1->iobj == SISLSURFACE)\n    {\n       if (po1->s1->cuopen_1 == SISL_CRV_PERIODIC ||\n\t   po1->s1->cuopen_2 == SISL_CRV_PERIODIC)\n\t {\n\t    if ((po1_kreg = newObject (SISLSURFACE)) == SISL_NULL)\n\t      goto err101;\n\t    make_sf_kreg(po1->s1, &po1_kreg->s1, &kstat);\n\t    if (kstat < 0) goto error;\n\t }\n       else po1_kreg = po1;\n    }\n  else po1_kreg = po1;\n\n\n\n  if (po2->iobj == SISLCURVE)\n    {\n       if (po2->c1->cuopen == SISL_CRV_PERIODIC)\n\t {\n\t    if ((po2_kreg = newObject (SISLCURVE)) == SISL_NULL)\n\t      goto err101;\n\t    make_cv_kreg(po2->c1, &po2_kreg->c1, &kstat);\n\t    if (kstat < 0) goto error;\n\t }\n       else po2_kreg = po2;\n    }\n  else if (po2->iobj == SISLSURFACE)\n    {\n       if (po2->s1->cuopen_1 == SISL_CRV_PERIODIC ||\n\t   po2->s1->cuopen_2 == SISL_CRV_PERIODIC)\n\t {\n\t    if ((po2_kreg = newObject (SISLSURFACE)) == SISL_NULL)\n\t      goto err101;\n\t    make_sf_kreg(po2->s1, &po2_kreg->s1, &kstat);\n\t    if (kstat < 0) goto error;\n\t }\n       else po2_kreg = po2;\n    }\n\n  else po2_kreg = po2;\n\n  /* End of ensure K-regularity on B-spline basis ________________*/\n\n\n  if (po1_kreg->iobj == SISLPOINT && po2_kreg->iobj == SISLPOINT)\n    {\n      /* Control the dimension of the two points. */\n\n      if (po1_kreg->p1->idim != po2_kreg->p1->idim)\n\tgoto err106;\n\n      /* Computing the distanse beetween the points. */\n\n      tpar = s6dist (po1_kreg->p1->ecoef, po2_kreg->p1->ecoef, po1_kreg->p1->idim);\n\n      if (tpar <= aepsge)\n\t{\n\t  /* PFU, moved to top to fix memory leak: SISLIntpt *qt = SISL_NULL; */\n\n\t  *jstat = 1;\t\t/* Mark intersection found. */\n\t  /* UJK , newi */\n\t  /* Making intersection point. */\n\n\t  qt = hp_newIntpt (0, &tpar, DZERO, SI_ORD,\n\t\t\t    SI_UNDEF, SI_UNDEF, SI_UNDEF, SI_UNDEF,\n\t\t\t    0, 0, nullp, nullp);\n\t  if (qt == SISL_NULL)\n\t    goto err101;\n\n\t  /* Uppdating pintdat. */\n\n\t  sh6idnpt (pintdat, &qt, 1, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  qt = SISL_NULL;      /* PFU - to fix memory leak */\n\t}\n      else\n\t*jstat = 0;\n    }\n  else\n    {\n      /* Test if intersection is possible (perform box-test).  */\n\n      sh1790 (po1_kreg, po2_kreg, ktotal, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /* We may have four different values on kstat.\n\t kstat = 0 : Intersection not possible.\n\t kstat = 1 : The two boxes overlap.\n\t kstat = 2 : The two \"bezier\" boxes is just touching.\n\t kstat = 3 : The two boxes is both inside a microbox of aepsge. */\n\n\n      if (kstat)\n\t{\n\t  int ki, kj;\t\t/* Counters.                      */\n\t  int kedg = 0;\t\t/* Number of parameter direction. */\n\t  SISLObject *qo1 = SISL_NULL;  /* Help pointer.                  */\n\t  SISLObject *qo2 = SISL_NULL;  /* Help pointer.                  */\n\n\t  /* PFU, moved to top to fix memory leak:\n\t   *  SISLEdge *qedge[2];\n\t   *  SISLIntdat *qintdat = SISL_NULL;\n\t   */\n\n\t  qintdat = SISL_NULL; /* PFU to fix memory leak. */\n\t  qedge[0] = qedge[1] = SISL_NULL;\n\t  *jstat = 0;\n\n\t  for (kj = 0, qo1 = po1_kreg, qo2 = po2_kreg; kj < 2; kj++, qo1 = po2_kreg, qo2 = po1_kreg)\n\t    if (qo1->iobj == SISLPOINT)\n\t      qedge[kj] = SISL_NULL;\t/* Not necessary to compute edge intersection.*/\n\t    else if (qo1->iobj == SISLCURVE)\n\t      {\n\t\tif ((qedge[kj] = newEdge (2)) == SISL_NULL)\n\t\t  goto err101;\n\n\t\tfor (ki = 0; ki < 2; ki++)\n\t\t  {\n\t\t    if (qo1->edg[ki] == SISL_NULL)\n\t\t      {\n\t\t\tif ((qo1->edg[ki] = newObject (SISLPOINT)) == SISL_NULL)\n\t\t\t  goto err101;\n\n\t\t\t/* Pick out end point from a curve. */\n\n\t\t\ts1438 (qo1->c1, ki, &(qo1->edg[ki]->p1), &tpar, &kstat);\n\t\t\tif (kstat < 0)\n\t\t\t  goto error;\n\t\t      }\n\t\t    else\n\t\t      tpar = (ki == 0 ? qo1->c1->et[qo1->c1->ik - 1] :\n\t\t\t      qo1->c1->et[qo1->c1->in]);\n\n\t\t    /* Recursiv computing of end intersection. */\n\n\t\t    sh1761 (kj == 0 ? qo1->edg[ki] : qo2, kj == 0 ? qo2 : qo1->edg[ki],\n\t\t\t    aepsge, &qintdat, &kstat);\n\t\t    if (kstat < 0)\n\t\t      goto error;\n\n\n\t\t    if (kstat)\n\t\t      {\n\t\t\t*jstat = 1;\t/* Mark intersection found. */\n\n\t\t\t/* Put intersection found on edges into pintdat. */\n\n\n\t\t\t/* Get parameter border values of qo2. */\n\n\t\t\t/* UJK , newi */\n\t\t\tsh1782 (po1_kreg, po2_kreg, aepsge, qintdat, kedg, tpar,\n\t\t\t\tpintdat, &idummy, &kstat);\n\t\t\tif (kstat < 0)\n\t\t\t  goto error;\n\n\n\t\t\t/* Uppdate edge structure. */\n\t\t\ts6idedg (po1_kreg, po2_kreg, kj + 1, 1, tpar, *pintdat,\n\t\t\t  &qedge[kj]->prpt[ki], &qedge[kj]->ipoint, &kstat);\n\t\t\tif (kstat < 0)\n\t\t\t  goto error;\n\t\t      }\n\n\t\t    if (qintdat != SISL_NULL)\n\t\t      freeIntdat (qintdat);\n\t\t    qintdat = SISL_NULL;\n\t\t  }\n\t\tkedg++;\n\t      }\n\n\t    else if (qo1->iobj == SISLSURFACE)\n\t      {\n\t\tint kpar;\t/* Parameter direction.            */\n\n\t\tif ((qedge[kj] = newEdge (4)) == SISL_NULL)\n\t\t  goto err101;\n\n\t\tfor (ki = 0; ki < 4; ki++)\n\t\t  {\n\t\t    if (qo1->edg[ki] == SISL_NULL)\n\t\t      {\n\t\t\tif ((qo1->edg[ki] = newObject (SISLCURVE)) == SISL_NULL)\n\t\t\t  goto err101;\n\n\t\t\t/* Pick out edge curve from a surface. */\n\n\t\t\ts1435 (qo1->s1, ki, &(qo1->edg[ki]->c1), &tpar, &kstat);\n\t\t\tif (kstat < 0)\n\t\t\t  goto error;\n\t\t      }\n\t\t    else\n\t\t      tpar = (ki == 0 ? qo1->s1->et2[qo1->s1->ik2 - 1] :\n\t\t\t      (ki == 1 ? qo1->s1->et1[qo1->s1->in1] :\n\t\t\t       (ki == 2 ? qo1->s1->et2[qo1->s1->in2] :\n\t\t\t\tqo1->s1->et1[qo1->s1->ik1 - 1])));\n\n\t\t    /* Recursiv computing of edge intersection. */\n\n\t\t    if (kj == 0)\n\t\t      sh1761 (qo1->edg[ki], qo2, aepsge, &qintdat, &kstat);\n\t\t    else\n\t\t      sh1761 (qo2, qo1->edg[ki], aepsge, &qintdat, &kstat);\n\t\t    if (kstat < 0)\n\t\t      goto error;\n\n\n\t\t    if (kstat)\n\t\t      {\n\t\t\t*jstat = 1;\t/* Mark intersection found. */\n\n\t\t\t/* Compute Parameter direction of edge. */\n\n\t\t\tkpar = ((ki == 0 || ki == 2) ? 2 : 1);\n\n\n\t\t\t/* Put intersection found on edges into pintdat. */\n\n\t\t\t/* UJK , newi */\n\t\t\tsh1782 (po1_kreg, po2_kreg, aepsge, qintdat, kpar + kedg - 1, tpar,\n\t\t\t\tpintdat, &idummy, &kstat);\n\t\t\tif (kstat < 0)\n\t\t\t  goto error;\n\n\n\t\t\t/* Uppdate edge structure. */\n\t\t\ts6idedg (po1_kreg, po2_kreg, kj + 1, kpar, tpar, *pintdat,\n\t\t\t  &qedge[kj]->prpt[ki], &qedge[kj]->ipoint, &kstat);\n\t\t\tif (kstat < 0)\n\t\t\t  goto error;\n\t\t      }\n\n\t\t    if (qintdat != SISL_NULL)\n\t\t      freeIntdat (qintdat);\n\t\t    qintdat = SISL_NULL;\n\t\t  }\n\t\tkedg += 2;\n\t      }\n\n\t    else\n\t      goto err121;\n\n\t  /* Before we enter internal intersection and subdivision we\n\t     initiate pointers to top level objects. */\n\n\t  if (po1_kreg->o1 == SISL_NULL)\n\t    po1_kreg->o1 = po1_kreg;\n\t  if (po2_kreg->o1 == SISL_NULL)\n\t    po2_kreg->o1 = po2_kreg;\n\n\t  /* Find the intersections in the inner of the object.  */\n\n\t  /* NEWI (ujk) Must treat helppoint on edges */\n\t  if (qedge[0] != SISL_NULL)\n\t    freeEdge (qedge[0]);\n\t  qedge[0] = SISL_NULL;\n\t  if (qedge[1] != SISL_NULL)\n\t    freeEdge (qedge[1]);\n\t  qedge[1] = SISL_NULL;\n\n\t  if (po1_kreg->iobj == SISLPOINT)\n\t    qedge[0] = SISL_NULL;\n\t  else if ((qedge[0] = newEdge (2 * po1_kreg->iobj)) == SISL_NULL)\n\t    goto err101;\n\n\t  if (po2_kreg->iobj == SISLPOINT)\n\t    qedge[1] = SISL_NULL;\n\t  else if ((qedge[1] = newEdge (2 * po2_kreg->iobj)) == SISL_NULL)\n\t    goto err101;\n\n\t  sh6idalledg (po1_kreg, po2_kreg, *pintdat, qedge, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  kstat = (kxintercept) ? 202 : 0;\n\t  sh1762 (po1_kreg, po2_kreg, aepsge, pintdat, qedge, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  else if (kstat)\n\t    *jstat = 1;\n\n\n\t  /* Free the edges used in s1762. */\n\n\t  if (qedge[0] != SISL_NULL)\n\t    freeEdge (qedge[0]);\n\t  qedge[0] = SISL_NULL;\n\t  if (qedge[1] != SISL_NULL)\n\t    freeEdge (qedge[1]);\n\t  qedge[1] = SISL_NULL;\n\n\n\t  /* UJK, edge reduction rules */\n\t     sh6edgred (po1_kreg, po2_kreg, (*pintdat), &kstat);\n\n\t  /* Organize the list in pintdat. */\n\t    sh6idlis (po1_kreg, po2_kreg, pintdat, aepsge, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n          /* Convert any degenerate intersection curves (Intlists)\n\t     to intersection points (Intpts).\n\t     This may be necessary when\n\t     either of the intersection objects po1_kreg and po2_kreg\n\t     are parametrically degenerate. */\n/*\n\t  sh6degen(po1_kreg,po2_kreg,pintdat,aepsge,&kstat);\n\t  if (kstat < 0) goto error;\n*/\n\t  if (qintdat)  freeIntdat(qintdat);  /* PFU                  */\n\t  qintdat = SISL_NULL;                     /* - to fix memory leak */\n\t}\n      else\n\t*jstat = 0;\n    }\n\n  goto out;\n\n  /* Error in space allocation.  */\n\nerr101:*jstat = -101;\n  s6err (\"sh1761\", *jstat, kpos);\n  goto out;\n\n  /* Error. Dimensions conflicting.  */\n\nerr106:*jstat = -106;\n  s6err (\"sh1761\", *jstat, kpos);\n  goto out;\n\n  /* Error. Kind of object does not exist.  */\n\nerr121:*jstat = -121;\n  s6err (\"sh1761\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower order routine.  */\n\nerror:*jstat = kstat;\n  s6err (\"sh1761\", *jstat, kpos);\n  goto out;\n\n  out:\n     /* Kill kreg temporary geometry */\n     if (po1_kreg && po1_kreg != po1)\n       {\n\t  freeObject(po1_kreg);\n\t  po1_kreg = SISL_NULL;\n       }\n\n     if (po2_kreg && po2_kreg != po2)\n       {\n\t  freeObject(po2_kreg);\n\t  po2_kreg = SISL_NULL;\n\n       }\n\n     if (qt)  freeIntpt(qt);             /* PFU                   */\n     if (qintdat)  freeIntdat(qintdat);  /* - to fix memory leak. */\n     if (qedge[0])  freeEdge(qedge[0]);\n     if (qedge[1])  freeEdge(qedge[1]);\n\n}\n"
  },
  {
    "path": "src/sh1762.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1762.c,v 1.18 2007-08-06 13:09:12 vsk Exp $\n *\n */\n\n\n#define SH1762\n\n#include \"sislP.h\"\n\n/*\nextern int nmbcall;\nextern int nmb0;\nextern int nmb1;\nextern int nmb2;\nextern int nmbsuccess;\n*/\n\n/*\n* Level counter.\n* --------------\n*/\n\nstatic int xc = 0;\nstatic int xmax = 0;\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void sh1762_s9mic (SISLObject *, SISLObject *, SISLIntdat **, SISLEdge **[], int *);\nstatic void sh1762_s9num (SISLObject *, SISLObject *, int *, int *);\nstatic void sh1762_s9num2 (SISLObject *, SISLObject *, int, SISLEdge *[], int *, int *);\nstatic void sh1762_s9div (SISLObject *, SISLObject *, double, int, int, SISLObject *[], SISLEdge *[], SISLIntdat **, int *);\nstatic int sh1762_s9subdivpt (SISLObject *, SISLObject *, double, int, int, SISLEdge *[], SISLIntdat **, int *, SISLIntpt **, double[], int *);\nstatic void sh1762_s9update (SISLObject *, SISLObject *, double, SISLIntdat **, SISLEdge **[], int *);\nstatic void sh1762_s9con (SISLObject *, SISLObject *, double, SISLIntdat **, SISLEdge *[], int *);\nstatic void sh1762_s9intercept (SISLObject *, SISLObject *, double, int, SISLIntpt *[], int *);\nstatic void sh1762_s9coincide (SISLObject *, SISLObject *, double, int, SISLIntpt *[], int *);\nstatic void sh1762_s9toucharea (SISLObject *, SISLObject *, double, int, SISLIntpt *[], int *);\n/*static void sh1762_s9edgpoint (SISLEdge *[], SISLIntpt ***, int *, int *); */\nstatic void\ns9edgsscon_eval(SISLSurf *ps1, SISLSurf *ps2, SISLIntpt **uipt, unsigned char *edg,\n\t\tint kn1, int isimple, double *eval, double *edist, double *dirval,\n\t\tint* ndir, int *jstat);\nstatic void s9edgsscon_simplify(SISLIntdat *rintdat, SISLIntpt **uipt,\n\t\t\t\tunsigned char *edg, int *kn1,\n\t\t\t\tdouble *eval, double *edist, double *dirval,\n\t\t\t\tint *ndir, double aepsge, int *jstat);\nstatic int s9edgsscon_connected(SISLIntpt **uipt, int *ndir, int kn1);\nstatic int s9edgsscon_con(SISLIntpt *pt1, SISLIntpt *pt2);\nstatic SISLIntpt* s9edgsscon_samecon(SISLIntpt *pt1, SISLIntpt *pt2);\nstatic void\ns9edgsscon_directed(SISLIntdat * rintdat, SISLIntpt **uipt, int kn1, double *eval, \n\t\t    double *dirval, int *ndir, double aepsge, int *jstat);\nstatic void\ns9edgsscon_singsearch(SISLSurf *ps1, SISLSurf *ps2, SISLIntdat *rintdat, \n\t\t      SISLIntpt **uipt, int *ndir, int kn1, double aepsge,\n\t\t      int *jstat);\nstatic void sh1762_s9edgsscon (SISLEdge *[], SISLSurf *, SISLSurf *, SISLIntdat *, int, double, int *);\nstatic void sh1762_s9edgpscon (SISLEdge *, double, SISLSurf *, int, SISLIntdat *, double, int *);\nstatic void sh1762_s9checkpscon (SISLIntpt *uipt[], int perm[], int ndir[], int npoints, \n\t\t\t\t int numb_type[], int *mcon[], int *jstat);\n/* static void sh1762_s9simple (SISLObject *, SISLObject *, SISLEdge *[], int *); */\n/* static void sh1762_s9reex (SISLObject *, SISLObject *, SISLEdge *[], double, SISLIntdat *, int *); */\nstatic void sh1762_s9ptiter (SISLObject *, SISLObject *, double, SISLIntdat **, SISLEdge *[], int *);\nstatic int sh1762_is_taboo(SISLSurf *, SISLSurf *, SISLIntpt *, int, int *);\nstatic int sh1762_is_taboo2(SISLObject *, SISLObject *, SISLIntpt *, int, SISLIntdat*, int);\nstatic double sh1762_sflength(SISLSurf *, int, int *);\nstatic double sh1762_cvlength(SISLCurve *, int *);\n#else\nstatic void sh1762_s9mic ();\nstatic void sh1762_s9num ();\nstatic void sh1762_s9num2 ();\nstatic void sh1762_s9div ();\nstatic int sh1762_s9subdivpt ();\nstatic void sh1762_s9update ();\nstatic void sh1762_s9con ();\nstatic void sh1762_s9intercept ();\nstatic void sh1762_s9coincide ();\nstatic void sh1762_s9toucharea ();\n/*static void sh1762_s9edgpoint ();*/\nstatic void s9edgsscon_eval();\nstatic void s9edgsscon_simplify();\nstatic int s9edgsscon_con();\nstatic SISLIntpt* s9edgsscon_samecon();\nstatic int s9edgsscon_connected();\nstatic void s9edgsscon_directed();\nstatic void s9edgsscon_singsearch();\nstatic void sh1762_s9edgsscon ();\nstatic void sh1762_s9edgpscon ();\nstatic void sh1762_s9checkpscon ();\n/* static void sh1762_s9simple (); */\n/* static void sh1762_s9reex (); */\nstatic void sh1762_s9ptiter ();\nstatic int sh1762_is_taboo();\nstatic int sh1762_is_taboo2();\nstatic double sh1762_sflength();\nstatic double sh1762_cvlength();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh1762 (SISLObject * po1, SISLObject * po2, double aepsge,\n\tSISLIntdat ** pintdat, SISLEdge * vedge[], int *jstat)\n#else\nvoid\nsh1762 (po1, po2, aepsge, pintdat, vedge, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     SISLIntdat **pintdat;\n     SISLEdge *vedge[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*          NOTE : Comments for further developments/tasks starts\n*                 with UPDATE :\n*\n*\n* PURPOSE    : SISLObject - object intersection. Treat the inner of the\n*              object.\n*\n*\n*\n* INPUT      : po1       - Pointer to first object\n*              po2       - Pointer to second object\n*              aepsge    - Geometry resolution.\n*              vedge[2]  - Pointers to structure of edge-intersections.\n*              *jstat    - Flag\n*                          = 202 : Complicated point-surface intersection\n*                                  in 3D. Perform extra interception test.\n*\n*\n* INPUT/OUTPUT : pintdat - Pointer to intersection data.\n*\n*\n*\n* OUTPUT     : jstat     - status messages\n*                                         = 1      : intersection found\n*                                         = 0      : no intersection\n*                                         < 0      : error\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err      - Treating error situation.\n*              s1741      - Simple Case test for intersections.\n*              sh1790     - Box test.\n*              s1791      - Test if possible to subdivide\n*              s1792      - Computing midpoint of parameter intervall.\n*              s1770      - Curve/curve iteration.\n*              s1771      - Point/curve iteration.\n*              s1772      - Curve/surface iteration.\n*              s1773      - Point/surface iteration.\n*              s1231      - Subdivide curve.\n*              s1711      - Subdivide surface.\n*              sh1761     - Object/object intersection.\n*              s1435      - Pick an edge curve from a surface.\n*              s1438      - Pick an end point from a curve.\n*              sh6idnpt    - New intpoint in intdat.\n*              s6idkpt    - Kill intpoint in intdat.\n*              s6idcpt    - Copy intpoint in intdat.\n*              sh6idcon    - Connect intpoint in intdat.\n*              s6idput    - put intpoint from one intdat to another\n*                           intdat with one paramete more.\n*              s6idput    - get intpoint from one intdat to another\n*                           intdat with one paramete less.\n*              s6idedg    - Get intpoint on edges from intdat.\n*              s6idint    - Get internal intpoint from intdat.\n*              newPoint   - Create new point structure.\n*              newObject  - Create new object structure.\n*              hp_newIntpt   - Create new intpt structure.\n*              newEdge    - Create new edge structure.\n*              freeObject - Free space occupied by a given object.\n*              freeCurve  - Free space occupied by a given curve.\n*              freeEdge   - Free space occupied by a given edge.\n*              freeIntdat - Free space occupied by a given intdat.\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-04.\n*              UJK        , SI, 89-04.\n*              Arne Laksaa, SI, 89-06.\n*              UJK newi         91-06.\n*********************************************************************\n*/\n{\n  int kpos = 0;\t\t\t/* Position of error.                 */\n  int kstat = 0;\t\t/* Local error status.                */\n  int kdiv1 = 0;\t\t/* Parameter direction of subdivsion. */\n  int kdiv2 = 0;\t\t/* Parameter direction of subdivsion. */\n  int ki, ki1, ki2;\t\t/* Counters.                          */\n  int at_bottom=TRUE;           /* Flag, true on bottom level of recur*/\n  int knewpt=0;                 /* No of points made in prtop part    */\n  int kexpand = 2;\t\t/* Expand box in the inner of object. */\n  int kxintercept = (*jstat == 202);  /* Extra interception           */\n  int knum;                   /* Number of intersection points at edges. */\n  SISLObject *uob1[4];\t\t/* Pointers to subdivided object.     */\n  SISLObject *uob2[4];\t\t/* Pointer to object to subdivide.    */\n  int knedge1, knedge2;\n\n  FILE *fp;\n  int debug_flag=0;\n\n  /*  FOR DEBUGGING define debug_flag as an extern variable, i.e.:\n   *\n   *                    extern int debug_flag;\n   */\n\n    if (debug_flag)\n    {\n       if ((po1->iobj == SISLSURFACE && po1->s1->idim == 1) ||\n           (po1->iobj == SISLSURFACE  && po2->iobj == SISLSURFACE))\n\t   {\n    \t           /*\tif (po1->s1->et1[0] >= 3.3 &&\n\t\t        po1->s1->et1[po1->s1->in1] <= 3.6 &&\n\t\t        po1->s1->et2[0] >= 0.7 &&\n\t\t        po1->s1->et2[po1->s1->in2] <= 0.9)\n\t\t        {\n\t\t   */\n\t     /*int knum; */\n\t   int ipar = 2;\n\t   int kj, ki, kr;\n\t   SISLIntpt **up = SISL_NULL;  /* Array of poiners to intersection point.*/\n\n\t   sh6edgpoint (vedge, &up, &knum, &kstat);\n\t   if (kstat < 0)\n\t      goto error;\n\t   if (debug_flag >= 1)\n\t   {\n\t      printf(\"\\n___________________________________________________\");\n\n\t      printf(\"\\n par val(1) :%#10.10g %#10.10g %#10.10g %#10.10g \",\n\t\t     po1->s1->et1[0],\n\t\t     po1->s1->et1[po1->s1->in1],\n\t\t     po1->s1->et2[0],\n\t\t     po1->s1->et2[po1->s1->in2]);\n\t      if (po2->iobj == SISLSURFACE)\n\t      {\n\t\t ipar = 4;\n\t\t printf(\"\\n par val(2) :%#10.10g %#10.10g %#10.10g %#10.10g \",\n\t\t\tpo2->s1->et1[0],\n\t\t\tpo2->s1->et1[po2->s1->in1],\n\t\t\tpo2->s1->et2[0],\n\t\t\tpo2->s1->et2[po2->s1->in2]);\n\t      }\n\t      printf(\"\\n No of pts: %d\",knum);\n\t      for (ki = 0; ki < knum; ki++)\n\t      {\n\t\t printf(\"\\n point %d :\",ki);\n\t\t for (kj = 0; kj < ipar; kj++)\n\t\t    printf(\" %#10.10g\", up[ki]->epar[kj]);\n\t      }\n\t      printf(\"\\n\");\n\t   }\n\t   if (debug_flag == 2 && (*pintdat) != NULL) \n\t   {\n\t     fp = fopen(\"curr_int.g2\",\"w\");\n\t     for (ki = 0; ki < (*pintdat)->ipoint; ki++)\n\t      {\n\t\tif ((*pintdat)->vpoint[ki]->iinter > 0)\n\t\t  fprintf(fp,\"400 1 0 4 255 0 0 255 \\n\");\n\t\telse\n\t\t  fprintf(fp,\"400 1 0 4 0 255 0 255 \\n\");\n\t\tfprintf(fp, \"1 \\n\");\n\t\tfor (kj = 0; kj < 2; kj++)\n\t\t  fprintf(fp,\" %#10.10g \", (*pintdat)->vpoint[ki]->epar[kj]);\n\t\tfprintf(fp, \" 0.0 \\n\");\n\t      }\n\n\t      for (ki = 0; ki < (*pintdat)->ipoint; ki++)\n\t      {\n\t\tfor (kj=0; kj<(*pintdat)->vpoint[ki]->no_of_curves; ++kj)\n\t\t  {\n\t\t    fprintf(fp, \"410 1 0 4 0 0 255 255 \\n\");\n\t\t    fprintf(fp, \"1 \\n\");\n\t\t    for (kr = 0; kr < 2; kr++)\n\t\t      fprintf(fp,\" %#10.10g \", (*pintdat)->vpoint[ki]->epar[kr]);\n\t\t    fprintf(fp, \" 0.0 \\n\");\n\t\t    for (kr = 0; kr < 2; kr++)\n\t\t      fprintf(fp,\" %#10.10g \", (*pintdat)->vpoint[ki]->pnext[kj]->epar[kr]);\n\t\t    fprintf(fp, \" 0.0 \\n\");\n\t\t  }\n\t      }\n\t\t    \n\t     fprintf(fp, \"410 1 0 4 0 0 0 255 \\n\");\n\t     fprintf(fp, \"4 \\n\");\n\t     fprintf(fp, \"%#10.10g %#10.10g %#10.10g \",\n\t\t     po1->s1->et1[0],\n\t\t     po1->s1->et2[0], 0.0);\n\n\t     fprintf(fp, \"%#10.10g %#10.10g %#10.10g \\n\",\n\t\t     po1->s1->et1[0],\n\t\t     po1->s1->et2[po1->s1->in2], 0.0);\n\n\t     fprintf(fp, \"%#10.10g %#10.10g %#10.10g \",\n\t\t     po1->s1->et1[0],\n\t\t     po1->s1->et2[po1->s1->in2], 0.0);\n\n\t     fprintf(fp, \"%#10.10g %#10.10g %#10.10g \\n\",\n\t\t     po1->s1->et1[po1->s1->in1],\n\t\t     po1->s1->et2[po1->s1->in2], 0.0);\n\n\t     fprintf(fp, \"%#10.10g %#10.10g %#10.10g \",\n\t\t     po1->s1->et1[po1->s1->in1],\n\t\t     po1->s1->et2[po1->s1->in2], 0.0);\n\n\t     fprintf(fp, \"%#10.10g %#10.10g %#10.10g \\n\",\n\t\t     po1->s1->et1[po1->s1->in1],\n\t\t     po1->s1->et2[0], 0.0);\n\n\t     fprintf(fp, \"%#10.10g %#10.10g %#10.10g \",\n\t\t     po1->s1->et1[po1->s1->in1],\n\t\t     po1->s1->et2[0], 0.0);\n\n\t     fprintf(fp, \"%#10.10g %#10.10g  %#10.10g \\n\",\n\t\t     po1->s1->et1[0],\n\t\t     po1->s1->et2[0], 0.0);\n\n\t     fclose(fp);\n\n\t   }\n\n\t   if (up) freearray(up);\n\n\t                     /*\t   }  */\n     }\n  }\n\n  xc++;\n  xmax = MAX (xmax, xc);\n  /*  printf(\"Max : %d \\n\",xc); */\n\n\n  for (ki = 0; ki < 4; ki++)\n    uob1[ki] = uob2[ki] = SISL_NULL;\n\n  /* Initiate to no intersection. */\n\n  *jstat = 0;\n\n  /* Test if intersection is possible (perform box-test).  */\n\n  /*  box_nmb++;\n  time_before = clock();  */\n\n  sh1790 (po1, po2, kexpand, aepsge, &kstat);\n\n  /*  time_used = clock() - time_before;\n  box_time += time_used; */\n  if (kstat < 0)\n    goto error;\n\n  /*  printf(\"Box test. Status = %d \\n\",kstat); */\n\n  /* We may have tree different values on kstat.\n     kstat = 1 : The two boxes overlapp.\n     kstat = 2 : The two \"bezier\" boxes is just touching.\n     kstat = 3 : The two boxes is both inside a microbox of aepsge.\n     kstat = 4 : One of the objects is degenerated to one 3D point.\n     kstat = 5 : Danger of shadow area in point object intersection,\n                 dimension > 1.   */\n\n  if (kstat == 5)\n  {\n     /* VSK, 92-10.\n\tEither make sure that there is no overlap, or find the intersection.\n\tThe situation that there is an intersection point in point-object\n\tintersection when dim > 1 where the usual box test fails to\n\trecognize the possibility may arise near the endpoints/edges of\n\tthe other object. */\n\n     sh1762_s9ptiter(po1, po2, aepsge, pintdat, vedge, &kstat);\n     if (kstat < 0) goto error;\n\n     /* kstat = 0 : No overlap.\n\tkstat = 1 : The boxes overlap, and the intersection is found. */\n\n     if (kstat == 1) *jstat = 1;\n  }\n\n  else if (kstat == 4)\n\n    goto out;\n\n  else if (kstat == 3)\n    {\n      /* Microbox found.*/\n\n      sh1762_s9mic (po1, po2, pintdat, &vedge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      else\n\t*jstat = kstat;\t\t/* Possible uppdating intersection found. */\n    }\n  else if (kstat == 1)\n    {\n      /* Simple Case test (more than one intersection possible?)  */\n\n      /* UJK, div until bezier, due to problems in silhouettes */\n       /* Must be opened again for silhouettes NO/YES?/NO!/...\n\t  ???????????????????????????????????\n\t  !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n\n\n       if ((po1->iobj == SISLSURFACE && po1->s1->idim == 1 &&\n\t    (po1->s1->ik1 != po1->s1->in1 || po1->s1->ik2 != po1->s1->in2)) ||\n\t   (po2->iobj == SISLSURFACE && po2->s1->idim == 1 &&\n\t    (po2->s1->ik1 != po2->s1->in1 || po2->s1->ik2 != po2->s1->in2)))\n\t  kstat = 0;\n       else\n       { */\n\n\t  s1741 (po1, po2, aepsge, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  //else if (po1->iobj == SISLSURFACE && po2->iobj == SISLSURFACE &&\n\t  //\t   vedge[0]->ipoint + vedge[1]->ipoint > 0 && !kstat)\n\t  //  sh1762_s9simple (po1, po2, vedge, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  /* } */\n\n\t  /* Check for tangential belt configuration */\n\t  if (po1->iobj == SISLSURFACE && po2->iobj == SISLSURFACE &&\n\t      (po1->s1->sf_type == TANGENTIAL_BELT ||\n\t       po2->s1->sf_type == TANGENTIAL_BELT ||\n\t       po1->s1->sf_type == SINGULARITY_BOUND ||\n\t       po2->s1->sf_type == SINGULARITY_BOUND))\n\t    kstat = 1;\n\n      /* We may have two different values on kstat.\n\t kstat = 0 : No simple case.\n\t kstat = 1 : Simple case (surfaces possible simple case). */\n\n      /* UJK,20.01.93, Don't skip s9con when not success in s9update.\n\t removed else.*/\n      if (kstat == 0)\n      {\n\t /* UJK, 17.12.92, for a 1D surface of bezier type\n\t    there may be a posibility of dividing out edge\n\t    curve intersections */\n\t if (po1->iobj == SISLSURFACE && po1->s1->idim ==1)\n\t {\n\t    sh_1d_div(po1, po2, aepsge, pintdat, vedge, &kstat);\n\t    if (kstat < 0)\n\t       goto error;\n\t    if (kstat == 1)\n\t       *jstat = 1;\t\t/*Updating found intersection. */\n\t }\n\t else if (po2->iobj == SISLSURFACE && po2->s1->idim == 1)\n\t {\n\t    sh_1d_div(po2, po1, aepsge, pintdat, vedge, &kstat);\n\t    if (kstat < 0)\n\t       goto error;\n\t    if (kstat == 1)\n\t       *jstat = 1;\t\t/*Updating found intersection. */\n\t }\n\n\t else\n\t {\n\n\t    /* Check for interval intersection. */\n\n\t   kstat = (kxintercept) ? 202 : 0;\n\t    sh1762_s9con (po1, po2, aepsge, pintdat, vedge, &kstat);\n\t    if (kstat < 0)\n\t       goto error;\n\n\t    /*  printf(\"sh1762_s9con. Status = %d \\n\",kstat); */\n\n\t    /* We may have two different values on kstat.\n\t       kstat = 0 : No intervall intersection.\n\t       kstat = 1 : Intervall intersection found.\n\t       kstat = 2 : Intersection not possible \n\t       kstat = 3 : Simple case encountered */\n\n\t    if (kstat == 1)\n\t       *jstat = 1;\t\t/*Updating found intersection. */\n\t    else if (kstat == 3)\n\t      kstat = 1;\n\t }\n      }\n\n\n      if (kstat == 1 && (*jstat) != 1)\n      {\n\t /* Possible simple Case, update intersection list. */\n\n\t sh1762_s9update (po1, po2, aepsge, pintdat, &vedge, &kstat);\n\t if (kstat < 0)\n\t    goto error;\n\n\t /* We may have two different values on kstat.\n\t    kstat = 0 : No simple case, more than two edge intersection.\n\t    kstat = 1 : Intersection found. */\n\n\t if (kstat == 1)\n\t    *jstat = 1;\t\t/*Updating found intersection. */\n      }\n\n      if (kstat == 0)\n\t{\n\t  /* Find number of possible subdivision directions.\n\t     kdiv1 and kdiv2 may have 4 difference values :\n\t     kdiv = 0 : Subdivision not possible.\n\t     kdiv = 1 : Subdivision in first parameter direction.\n\t     kdiv = 2 : Subdivision in second parameter direction.\n\t     kdiv = 3 : Subdivision in both parameter directions. */\n\n\t  sh1762_s9num (po1, po2, &kdiv1, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  /* Check with help point configuration */\n\t  if (kdiv1 > 0)\n\t    sh1762_s9num2 (po1, po2, 1, vedge, &kdiv1, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t    \n\t  sh1762_s9num (po2, po1, &kdiv2, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  \n\t  if (kdiv2 > 0)\n\t    sh1762_s9num2 (po1, po2, 2, vedge, &kdiv2, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t    \n\n\t  if (kdiv1 + kdiv2 == 0)\n\t    {\n\t      /* There is two almost plane parallel objects, and\n\t\t there is nothing at the edges (otherwise the\n\t\t intersections should be found by s9con). Then the\n\t\t only possibility is that there is no intersection. */\n\t       /* VSK, 11-92. Since partial coincidence is not\n\t\t  implemented, there might be intersections on the\n\t\t  edges. Check this.   This should not be necessary\n\t\t  any more. */\n\n\t      /* Check if there are intersection points on edges.*/\n\n\t       if (vedge[0] == SISL_NULL)\n\t\t  knum = 0;\n\t       else\n\t\t  knum = vedge[0]->ipoint;\n\n\t       if (vedge[1] != SISL_NULL)\n\t\t  knum += vedge[1]->ipoint;\n\n\n\n\t       /*if (knum > 0)\n\t       {\n\t\t   Do something that makes the routine terminate\n\t\t     until partial coincidence is implemented.\n\n\t\t  sh1762_s9mic(po1, po2, pintdat, &vedge, &kstat);\n\t\t  if (kstat < 0) goto error;\n\n\t\t  *jstat = kstat;\n\t       }\n\t       else\n\t       {\n\t\t  *jstat = 0;\n\t\t  goto out;\n\t       } */\n\n\t       if ((po1->iobj + po2->iobj < 2*SISLSURFACE && knum == 0) ||\n\t\t   (po1->iobj + po2->iobj == 2*SISLSURFACE && knum > 0))\n\t\t{\n\t\t  /* Check for an internal intersection */\n\t\t  kstat = 100; /* Indicates that no further subdivision will \n\t\t\t\t  be performed */\n\t\t  sh1762_s9update (po1, po2, aepsge, pintdat, &vedge, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t  if (po1->iobj + po2->iobj == 2*SISLSURFACE && kstat == 2)\n\t\t    kstat = 1;\n\t\t  *jstat = (kstat == 1) ? 1 : 0;\n\t\t}\n\t      else\n\t\t{\n\t\t  *jstat = 0;\n\t\t  /* goto out; */\n\t\t}\n\t    }\n\t  else\n\t    {\n\t      SISLEdge *uedge[2];\t/* Array of pointers to edges\n\t\t\t\t\t      to use in subproblems.    */\n\n\n\t      /* We do not have simple case and it is possible to\n\t\t subdivide. We therefor subdivide and update the\n\t\t edge intersection and then do a recurcive call\n\t\t to treat the sub problems. Curves are subdivided\n\t\t into two, surfaces into four. We can therefor get\n\t\t up to sexteen recurcive calls.*/\n\n\n\n\t      /***** Treating objects on sub problems. *****/\n\n\t      if (kdiv1 > 0)\t/* New objects for subdivision of po1. */\n\t\t{\n\t\t  for (ki = 0; ki < (kdiv1 < 3 ? 2 : 4); ki++)\n\t\t    {\n\t\t      if ((uob1[ki] = newObject (po1->iobj)) == SISL_NULL)\n\t\t\tgoto err101;\n\n\t\t      /* Initiate o1 pointer to point to top level object. */\n\n\t\t      uob1[ki]->o1 = po1->o1;\n\t\t    }\n\n\t\t  /* Subdivide the po1 object. */\n\n\t\t  sh1762_s9div (po1, po2, aepsge, 1, kdiv1, uob1, vedge, pintdat, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t  else if (kstat == 1)\n\t\t    *jstat = 1;\n\t\t}\n\n\t      /* sh6div may remove points, update edge intersections */\n\t      if (vedge[0] != SISL_NULL)\n\t\t{\n\t\t  knedge1 = vedge[0]->iedge;\n\t\t  freeEdge (vedge[0]);\n\t\t  if ((vedge[0] = newEdge (knedge1)) == SISL_NULL)\n\t\t    goto err101;\n\t\t}\n\t      if (vedge[1] != SISL_NULL)\n\t\t{\n\t\t  knedge2 = vedge[1]->iedge;\n\t\t  freeEdge (vedge[1]);\n\t\t  if ((vedge[1] = newEdge (knedge2)) == SISL_NULL)\n\t\t    goto err101;\n\t\t}\n\n\t      /* Making new edge object */\n\n\n\t      sh6idalledg (po1, po2, *pintdat, vedge, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\n\t      if (kdiv2 > 0)\t/* New objects for subdivision of po2. */\n\t\t{\n\t\t  for (ki = 0; ki < (kdiv2 < 3 ? 2 : 4); ki++)\n\t\t    {\n\t\t      if ((uob2[ki] = newObject (po2->iobj)) == SISL_NULL)\n\t\t\tgoto err101;\n\n\t\t      /* Initiate o1 pointer to point to top level object. */\n\n\t\t      uob2[ki]->o1 = po2->o1;\n\t\t    }\n\n\t\t  /* Subdivide the po2 object. */\n\n\t\t  sh1762_s9div (po1, po2, aepsge, 2, kdiv2, uob2, vedge, pintdat, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t  else if (kstat == 1)\n\t\t    *jstat = 1;\n\t\t}\n\n\t      /* sh6div may remove points, update edge intersections */\n\t      if (vedge[0] != SISL_NULL)\n\t\t{\n\t\t  knedge1 = vedge[0]->iedge;\n\t\t  freeEdge (vedge[0]);\n\t\t  if ((vedge[0] = newEdge (knedge1)) == SISL_NULL)\n\t\t    goto err101;\n\t\t}\n\t      if (vedge[1] != SISL_NULL)\n\t\t{\n\t\t  knedge2 = vedge[1]->iedge;\n\t\t  freeEdge (vedge[1]);\n\t\t  if ((vedge[1] = newEdge (knedge2)) == SISL_NULL)\n\t\t    goto err101;\n\t\t}\n\n\t      /* Making new edge object */\n\n\n\t      sh6idalledg (po1, po2, *pintdat, vedge, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\n\n\t      /***** Recursion. *****/\n\n\t      if (kdiv1 == 0)\t/* Only second object subdivided. */\n\t\tfor (ki = 0; ki < (kdiv2 < 3 ? 2 : 4); ki++)\n\t\t  {\n\t\t    /***** Treating edges on sub problems. *****/\n\n\t\t    /* Making new edge object to sub problems. */\n\n\t\t    if (po1->iobj == SISLPOINT)\n\t\t      uedge[0] = SISL_NULL;\n\t\t    else if ((uedge[0] = newEdge (vedge[0]->iedge)) == SISL_NULL)\n\t\t      goto err101;\n\t\t    if ((uedge[1] = newEdge (vedge[1]->iedge)) == SISL_NULL)\n\t\t      goto err101;\n\n\t\t    /* Update edge intersection on sub problems. */\n\n\t\t    sh6idalledg (po1, uob2[ki], *pintdat, uedge, &kstat);\n\t\t    if (kstat < 0)\n\t\t      goto error;\n\n\t\t    at_bottom = FALSE;\n\t\t    kstat = (kxintercept) ? 202 : 0;\n\t\t    sh1762 (po1, uob2[ki], aepsge, pintdat, uedge, &kstat);\n\t\t    if (kstat < 0)\n\t\t      goto error;\n\t\t    else\n\t\t      *jstat = *jstat || kstat;\n\n\t\t    if (uedge[0] != SISL_NULL)\n\t\t      freeEdge (uedge[0]);\n\t\t    if (uedge[1] != SISL_NULL)\n\t\t      freeEdge (uedge[1]);\n\t\t  }\n\t      else if (kdiv2 == 0)\t/* Only first object subdivided.   */\n\t\tfor (ki = 0; ki < (kdiv1 < 3 ? 2 : 4); ki++)\n\t\t  {\n\t\t    /***** Treating edges on sub problems. *****/\n\n\t\t    /* Making new edge object to sub problems. */\n\n\t\t    if ((uedge[0] = newEdge (vedge[0]->iedge)) == SISL_NULL)\n\t\t      goto err101;\n\t\t    if (po2->iobj == SISLPOINT)\n\t\t      uedge[1] = SISL_NULL;\n\t\t    else if ((uedge[1] = newEdge (vedge[1]->iedge)) == SISL_NULL)\n\t\t      goto err101;\n\n\t\t    /* Update edge intersection on sub problems. */\n\n\t\t    sh6idalledg (uob1[ki], po2, *pintdat, uedge, &kstat);\n\t\t    if (kstat < 0)\n\t\t      goto error;\n\n\t\t    at_bottom = FALSE;\n\t\t    kstat = (kxintercept) ? 202 : 0;\n\t\t    sh1762 (uob1[ki], po2, aepsge, pintdat, uedge, &kstat);\n\t\t    if (kstat < 0)\n\t\t      goto error;\n\t\t    else\n\t\t      *jstat = *jstat || kstat;\n\n\t\t    if (uedge[0] != SISL_NULL)\n\t\t      freeEdge (uedge[0]);\n\t\t    if (uedge[1] != SISL_NULL)\n\t\t      freeEdge (uedge[1]);\n\t\t  }\n\t      else\t\t/* Both objects subdivided.        */\n\t\tfor (ki1 = 0; ki1 < (kdiv1 < 3 ? 2 : 4); ki1++)\n\t\t  for (ki2 = 0; ki2 < (kdiv2 < 3 ? 2 : 4); ki2++)\n\t\t    {\n\t\t      /***** Treating edges on sub problems. *****/\n\n\t\t      /* Making new edge object to sub problems. */\n\n\t\t      if ((uedge[0] = newEdge (vedge[0]->iedge)) == SISL_NULL)\n\t\t\tgoto err101;\n\t\t      if ((uedge[1] = newEdge (vedge[1]->iedge)) == SISL_NULL)\n\t\t\tgoto err101;\n\n\t\t      /* Update edge intersection on sub problems. */\n\n\t\t      sh6idalledg (uob1[ki1], uob2[ki2], *pintdat, uedge, &kstat);\n\t\t      if (kstat < 0)\n\t\t\tgoto error;\n\n\n\t\t      at_bottom = FALSE;\n\t\t      kstat = (kxintercept) ? 202 : 0;\n\t\t      sh1762 (uob1[ki1], uob2[ki2], aepsge, pintdat, uedge, &kstat);\n\t\t      if (kstat < 0)\n\t\t\tgoto error;\n\t\t      else\n\t\t\t*jstat = *jstat || kstat;\n\n\t\t      if (uedge[0] != SISL_NULL)\n\t\t\tfreeEdge (uedge[0]);\n\t\t      if (uedge[1] != SISL_NULL)\n\t\t\tfreeEdge (uedge[1]);\n\t\t    }\n\t    }\n\t}\n    }\n\n\n  /* Must update vedge before going into reex */\n  /* if (vedge[0] != SISL_NULL)\n  {\n     knedge1 = vedge[0]->iedge;\n     freeEdge (vedge[0]);\n     if ((vedge[0] = newEdge (knedge1)) == SISL_NULL)\n        goto err101;\n  }\n  if (vedge[1] != SISL_NULL)\n  {\n     knedge2 = vedge[1]->iedge;\n     freeEdge (vedge[1]);\n     if ((vedge[1] = newEdge (knedge2)) == SISL_NULL)\n\tgoto err101;\n  }*/\n\n  /* Making new edge object to sub problems. */\n\n\n  /* sh6idalledg (po1, po2, *pintdat, vedge, &kstat);\n  if (kstat < 0)\n     goto error; */\n\n\n  /* UPDATE (ujk): s9reex must be changed, interface = ?\n     Now it connects points on edge when they are\n     connected to an internal point ?*/\n  /* Now changed! ALA and MSF.  */\n\n  /* UJK, VSK, ALA, 09.02.93, don't need it any longer !? */\n  /* sh1762_s9reex (po1, po2, vedge, aepsge, *pintdat, &kstat);\n     if (kstat < 0)\n     goto error; */\n\n  /* VSK, 10.92. Set status if reex takes action.  */\n\n  /* *jstat = MAX(*jstat,kstat);\n\n  if (debug_flag && kstat)\n     printf(\"\\n Output reex: %d \\n\",kstat); */\n\n  /* Reduction rules */\n\n  sh6red (po1, po2, (*pintdat), &kstat);\n\n  /* sh6red may remove points, update edge intersections */\n  if (vedge[0] != SISL_NULL)\n  {\n     knedge1 = vedge[0]->iedge;\n     freeEdge (vedge[0]);\n     if ((vedge[0] = newEdge (knedge1)) == SISL_NULL)\n        goto err101;\n  }\n  if (vedge[1] != SISL_NULL)\n  {\n     knedge2 = vedge[1]->iedge;\n     freeEdge (vedge[1]);\n     if ((vedge[1] = newEdge (knedge2)) == SISL_NULL)\n\tgoto err101;\n  }\n\n  /* Making new edge object to sub problems. */\n\n\n  sh6idalledg (po1, po2, *pintdat, vedge, &kstat);\n  if (kstat < 0)\n     goto error;\n\n\n  /* Make help points and pretopology at bottom */\n\n  if (at_bottom)\n    shmkhlppts (po1, po2, aepsge, pintdat, vedge, &knewpt, &kstat);\n\n  /* UJK, aug.92, If we make help points, status must be set !,\n     are there other updating statuses that we've missed ? */\n  if (knewpt) *jstat = 1;\n\n  /* Intersections in the inner found.  */\n\n  goto out;\n\n  /* Error in space allocation.         */\n\nerr101:*jstat = -101;\n  s6err (\"sh1762\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine.      */\n\nerror:*jstat = kstat;\n  s6err (\"sh1762\", *jstat, kpos);\n  goto out;\n\n  /* Free the space that is  allocated. */\n\nout:\n  for (ki = 0; ki < 4; ki++)\n    {\n      if (uob1[ki] != SISL_NULL)\n\tfreeObject (uob1[ki]);\n      if (uob2[ki] != SISL_NULL)\n\tfreeObject (uob2[ki]);\n    }\n  xc--;\n\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1762_s9mic (SISLObject * po1, SISLObject * po2, SISLIntdat ** rintdat,\n\t      SISLEdge ** vedge[], int *jstat)\n#else\nstatic void\nsh1762_s9mic (po1, po2, rintdat, vedge, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntdat **rintdat;\n     SISLEdge **vedge[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE     : Treat intersection when it is not possible to\n*               subdivide any futher, and it is not simple case.\n*\n*\n*\n* INPUT      : (*vedge)[2] - SISLEdge intersection objects to the two\n*                         objects in intersection problem.\n*\n*\n*\n* OUTPUT     : rintdat - intersection data.\n*              jstat   - status messages\n*                               = 1     : Intersection found.\n*                               = 0     : Intersection not found.\n*                               < 0     : error.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-04.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\t\t\t/* Position of error.                      */\n  int kstat = 0;\t\t/* Local error status.                     */\n  int knum = 0;\t\t\t/* Number of intpt on edges.               */\n  /*int klist1, klist2;\t*/\t/* List index in iintpt.                   */\n  int ind1, ind2;\t\t/* Help index in up array.                 */\n  double *spar = SISL_NULL;\t\t/* Array to store parameter values.        */\n  SISLIntpt **up = SISL_NULL;\t/* Array of poiners to intersection point. */\n  double *nullp = SISL_NULL;\n  double tepsge = 0.0000001;    /* Tolerance used in merging of points.    */\n\n  /* Initiate to no new intersection point. */\n\n  *jstat = 0;\n\n  /* Compute number of intersection points on edges. */\n\n  if ((*vedge)[0] == SISL_NULL)\n    knum = 0;\n  else\n    knum = (*vedge)[0]->ipoint;\n\n  if ((*vedge)[1] != SISL_NULL)\n    knum += (*vedge)[1]->ipoint;\n\n\n  if (knum > 0)\n    {\n      /* sh1762_s9edgpoint ((*vedge), &up, &knum, &kstat); */\n      sh6edgpoint ((*vedge), &up, &knum, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n\n  if (knum > 1)\n    {\n      int kturn, ki;\n\n      /* We have more than one intersection point on the edges,\n\t we therefore have to treat these problem. */\n\n      if ((po1->iobj == SISLPOINT && po1->p1->idim <= 2) ||\n\t  (po2->iobj == SISLPOINT && po2->p1->idim <= 2) ||\n\t  (po1->iobj == SISLCURVE && po2->iobj == SISLPOINT && knum == 2) ||\n\t  (po1->iobj == SISLPOINT && po2->iobj == SISLCURVE && knum == 2))\n\t{\n\t  SISLObject *qo1, *qo2;\n\n\t  /* In dimension one and two this function is not\n\t     a degenenerate treatment function, it is a coincidence\n\t     function. */\n\n\t  if (po1->iobj == SISLPOINT)\n\t    {\n\t      qo1 = po1;\n\t      qo2 = po2;\n\t      kturn = 0;\n\t    }\n\t  else\n\t    {\n\t      qo2 = po1;\n\t      qo1 = po2;\n\t      kturn = 1;\n\t    }\n\n\t  if (qo2->iobj == SISLSURFACE)\n\t    {\n\n\t       /* Trim area found */\n\t       for (ki=0; ki<(*rintdat)->ipoint; ki++)\n\t       {\n\t\t  sh6isinside(po1,po2,(*rintdat)->vpoint[ki],&kstat);\n\t\t  if (kstat < 0) goto error;\n\t\t  if (kstat)\n\t\t  {\n\t\t     sh6tomain((*rintdat)->vpoint[ki], &kstat);\n\t\t     if (kstat < 0) goto error;\n\t\t     (*rintdat)->vpoint[ki]->iinter = SI_TRIM;\n\t\t  }\n\t       }\n\n\t       /* UJK 18.09.90 Must set intersection found status */\n\t       *jstat = 1;\n\t       goto out;\n\n\t    }\n\t  else if (qo2->iobj == SISLCURVE && knum == 2)\n\t    {\n\t      double tres;\n\n\t      tres = (qo2->c1->et[qo2->c1->in] -\n\t\t      qo2->c1->et[qo2->c1->ik - 1]) /\n\t\t(qo2->o1->c1->et[qo2->o1->c1->in] -\n\t\t qo2->o1->c1->et[qo2->o1->c1->ik - 1]);\n\n\t      if (tres > REL_PAR_RES)\n\t\t{\n\t\t  /* UJK newi :Main points, curve point 1+2D, connect */\n\t\t  sh6idcon (rintdat, up, up + 1, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t  /* Sort points */\n\t\t  ind1 = 0;\n\t\t  ind2 = 1;\n\t\t  if (up[0]->epar[0] > up[1]->epar[0])\n\t\t    {\n\t\t      ind1 = 1;\n\t\t      ind2 = 0;\n\t\t    }\n\t\t  sh6setdir (up[ind1], up[ind2], &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\n\n\n\t\t  /* Set pretopology */\n\t\t  /* No, it's there already */\n\n\t\t  /*\t\t  ind1 = 1;\n\t          ind2 = 0;\n\t          if (up[0]->epar[0] < up[1]->epar[0])\n\t        {\n\t          ind1 = 0;\n\t          ind2 = 1;\n\t          }\n\n\t          sh6getlist (up[ind1], up[ind2], &klist1, &klist2, &kstat);\n\t          if (kstat != 0)\n\t        {\n\t          kstat = -1;\n\t          goto error;\n\t          }\n\t          if (kturn)\n\t        {\n\t          sh6settop (up[ind1], -1,\n\t          SI_AT, SI_ON, SI_UNDEF, SI_ON, &kstat);\n\t          if (kstat < 0)\n\t          goto error;\n\t          sh6settop (up[ind2], -1,\n\t          SI_ON, SI_AT, SI_ON, SI_UNDEF, &kstat);\n\t          if (kstat < 0)\n\t          goto error;\n\t          }\n\t          else\n\t        {\n\t          sh6settop (up[ind1], -1,\n\t          SI_UNDEF, SI_ON, SI_AT, SI_ON, &kstat);\n\t          if (kstat < 0)\n\t          goto error;\n\t          sh6settop (up[ind2], -1,\n\t          SI_ON, SI_UNDEF, SI_ON, SI_AT, &kstat);\n\t          if (kstat < 0)\n\t          goto error;\n\t          }\n\n\t          */\n\n\t\t  /* UJK 18.09.90 Must set intersection found status */\n\t\t  *jstat = 1;\n\t\t  goto out;\n\t\t}\n\t    }\n\t}\n\n\n\t/* VSK to treat degenerated curves.  */\n\n\tif (po1->iobj == SISLCURVE && po2->iobj == SISLCURVE && knum >= 2)\n\t{\n\t   /* The two curves is within a microbox. The intersection will\n\t      be represented with two points that are connectd. Merge\n\t      the rest of the points into one of the two remaining.   */\n\n\t   for (ki=1; ki<knum-1; ki++)\n\t     {\n\t\tsh6idnewunite(po1,po2,rintdat,&up[0],&up[ki],DZERO,\n\t\t\t      tepsge,&kstat);\n\t\tif (kstat < 0) goto error;\n             }\n\n\t   sh6connect(up[0],up[knum-1],&kstat);\n\t   if (kstat < 0) goto error;\n\n\t   /* Update edge structure.  */\n\n      if ((*vedge)[0] != SISL_NULL)\n\t{\n\t  ki = (*vedge)[0]->iedge;\n\t  freeEdge ((*vedge)[0]);\n\t  (*vedge)[0] = SISL_NULL;\n\t  if (((*vedge)[0] = newEdge (ki)) == SISL_NULL)\n\t    goto err101;\n\t}\n      if ((*vedge)[1] != SISL_NULL)\n\t{\n\t  ki = (*vedge)[1]->iedge;\n\t  freeEdge ((*vedge)[1]);\n\t  (*vedge)[1] = SISL_NULL;\n\t  if (((*vedge)[1] = newEdge (ki)) == SISL_NULL)\n\t    goto err101;\n\t}\n\n          sh6idalledg (po1, po2, *rintdat, *vedge, &kstat);\n          if (kstat < 0)\n            goto error;\n\n           *jstat = 1;\n\t   goto out;\n\t}\n\n      /* We have more than one intersection point on the edges.\n\t We therefore kill these points and\n\t try to find a new intersection point. */\n\n\n\n      for (ki = 1; ki < knum; ki++)\n\t{\n\t  /* UJK newi, unite the points : */\n\t   sh6idnewunite (po1, po2, rintdat, &up[0], &up[ki], (double) 0.5,\n\t\t\t  tepsge, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n\n      if ((*vedge)[0] != SISL_NULL)\n\t{\n\t  ki = (*vedge)[0]->iedge;\n\t  freeEdge ((*vedge)[0]);\n\t  if (((*vedge)[0] = newEdge (ki)) == SISL_NULL)\n\t    goto err101;\n\t}\n      if ((*vedge)[1] != SISL_NULL)\n\t{\n\t  ki = (*vedge)[1]->iedge;\n\t  freeEdge ((*vedge)[1]);\n\t  if (((*vedge)[1] = newEdge (ki)) == SISL_NULL)\n\t    goto err101;\n\t}\n      /* UJK newi, one point kept : */\n      knum = 1;\n    }\n\n\n\n  if (knum == 0)\n    {\n      int kpar = 0;\n      SISLIntpt *qt;\n\n\n      /* There is no intersection points on the edges.\n\t We therfore make one new intersection point with parameter\n\t values in senter of each object. */\n\n\n      /* Number of parameter values of object 1. */\n\n      if (po1->iobj == SISLCURVE)\n\tkpar = 1;\n      else if (po1->iobj == SISLSURFACE)\n\tkpar = 2;\n      else\n\tkpar = 0;\n\n      /* Number of parameter values of object 2. */\n\n      if (po2->iobj == SISLCURVE)\n\tkpar++;\n      else if (po2->iobj == SISLSURFACE)\n\tkpar += 2;\n\n\n      /* Allocate array to store midpoint parameter values. */\n\n      if ((spar = newarray (kpar, double)) == SISL_NULL)\n\tgoto err101;\n\n\n      /* Compute midpoint parameter values. */\n\n      if (po1->iobj == SISLCURVE)\n\t{\n\t  spar[0] = (po1->c1->et[po1->c1->ik - 1] +\n\t\t     po1->c1->et[po1->c1->in]) * (double) 0.5;\n\t  kpar = 1;\n\t}\n      else if (po1->iobj == SISLSURFACE)\n\t{\n\t  spar[0] = (po1->s1->et1[po1->s1->ik1 - 1] +\n\t\t     po1->s1->et1[po1->s1->in1]) * (double) 0.5;\n\t  spar[1] = (po1->s1->et2[po1->s1->ik2 - 1] +\n\t\t     po1->s1->et2[po1->s1->in2]) * (double) 0.5;\n\t  kpar = 2;\n\t}\n      else\n\tkpar = 0;\n\n      if (po2->iobj == SISLCURVE)\n\t{\n\t  spar[kpar] = (po2->c1->et[po2->c1->ik - 1] +\n\t\t\tpo2->c1->et[po2->c1->in]) * (double) 0.5;\n\t  kpar++;\n\t}\n      else if (po2->iobj == SISLSURFACE)\n\t{\n\t  spar[kpar] = (po2->s1->et1[po2->s1->ik1 - 1] +\n\t\t\tpo2->s1->et1[po2->s1->in1]) * (double) 0.5;\n\t  spar[kpar + 1] = (po2->s1->et2[po2->s1->ik2 - 1] +\n\t\t\t    po2->s1->et2[po2->s1->in2]) * (double) 0.5;\n\t  kpar += 2;\n\t}\n\n      *jstat = 1;\t\t/* Mark intersection found. */\n\n\n      /* Making intersection point. */\n      /* UJK newi */\n      /* UPDATE: ? Be aware of this situation, can it occur ? */\n\n      qt = hp_newIntpt (kpar, spar, DZERO, SI_ORD,\n\t\t\tSI_UNDEF, SI_UNDEF, SI_UNDEF, SI_UNDEF,\n\t\t\t0, 0, nullp, nullp);\n      if (qt == SISL_NULL)\n\tgoto err101;\n\n      /* Uppdating pintdat. */\n\n      sh6idnpt (rintdat, &qt, 1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  goto out;\n\n/* Error in space allocation.         */\n\nerr101:*jstat = -101;\n  s6err (\"sh1762_s9mic\", *jstat, kpos);\n  goto out;\n\n/* Error in lower level routine.      */\n\nerror:*jstat = kstat;\n  s6err (\"sh1762_s9mic\", *jstat, kpos);\n  goto out;\n\nout:if (spar != SISL_NULL)\n    freearray (spar);\n  if (up != SISL_NULL)\n    freearray (up);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic double sh1762_sflength(SISLSurf *psurf, int idir, int *jstat)\n#else\nstatic double sh1762_sflength(psurf, idir, jstat)\n    SISLSurf *psurf;\n    int idir;\n    int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Estimate the surface length in a given parameter direction.\n*\n*\n*\n* INPUT      : psurf  - The surface.\n*              idir   - The parameter direction.\n*\n*\n* OUTPUT     : return value - Estimated surface length.\n*              jstat  - status messages\n*                         = 0     : no error.\n*                         < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 99-05.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\n  int kleft1 = 0, kleft2 = 0;\n  int ki;\n  int kdim = psurf->idim;\n  double spar[2];  /* Parameter value in which to evaluate. */\n  double sint[2];  /* Interval between parameter values.    */\n  double sder[12]; /* Points on the surface.                */\n  int kneval;      /* Number of points to evaluate.         */\n  double tlength = 0.0;  /* Estimated length of surface.    */\n\n  kneval = (idir == 1) ? psurf->ik1 : psurf->ik2;\n  kneval = max(2, min(kneval, 4));\n\n  /* Set first parameter in which to evaluate. */\n  if (idir == 1)\n    {\n      spar[0] = psurf->et1[psurf->ik1-1];\n      spar[1] = (double)0.5*(psurf->et2[psurf->ik2-1]+psurf->et2[psurf->in2]);\n\n      sint[0] = (psurf->et1[psurf->in1] - spar[0])/(double)(kneval-1);\n      sint[1] = 0.0;\n    }\n  else\n    {\n      spar[0] = (double)0.5*(psurf->et1[psurf->ik1-1]+psurf->et1[psurf->in1]);\n      spar[1] = psurf->et2[psurf->ik2-1];\n\n      sint[0] = 0.0;\n      sint[1] = (psurf->et2[psurf->in2] - spar[1])/(double)(kneval-1);\n    }\n\n  /* Evaluate points. */\n\n  for (ki=0; ki<kneval; ki++, spar[0]+=sint[0], spar[1]+=sint[1])\n    {\n      s1424(psurf, 0, 0, spar, &kleft1, &kleft2, sder+ki*kdim, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /*  Compute the distance between the points. */\n\n  for (tlength=0.0, ki=1; ki<kneval; ki++)\n    tlength += s6dist(sder+(ki-1)*kdim, sder+ki*kdim, kdim);\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n  error:\n  *jstat = kstat;\n  s6err (\"sh1762_sflength\", *jstat, 0);\n  goto out;\n\n  out:\n  return tlength;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic double sh1762_cvlength(SISLCurve *pcrv, int *jstat)\n#else\nstatic double sh1762_cvlength(pcrv, jstat)\n    SISLCurve *pcrv;\n    int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Estimate the curve length \n*\n*\n*\n* INPUT      : pcrv  - The curve\n*\n*\n* OUTPUT     : return value - Estimated surface length.\n*              jstat  - status messages\n*                         = 0     : no error.\n*                         < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 2018-08.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\n  int kleft = 0;\n  int ki;\n  int kdim = pcrv->idim;\n  double tpar;  /* Parameter value in which to evaluate. */\n  double tdel;  /* Interval between parameter values.    */\n  double sder[12]; /* Points on the surface.                */\n  int kneval;      /* Number of points to evaluate.         */\n  double tlength = 0.0;  /* Estimated length of surface.    */\n\n  kneval = pcrv->ik;\n  kneval = max(2, min(kneval, 4));\n\n  /* Set first parameter in which to evaluate. */\n  tpar = pcrv->et[pcrv->ik-1];\n  tdel = (pcrv->et[pcrv->in] - tpar)/(double)(kneval-1);\n\n  /* Evaluate points. */\n  for (ki=0; ki<kneval; ki++, tpar += tdel)\n    {\n      s1221(pcrv, 0, tpar, &kleft, sder+ki*kdim, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /*  Compute the distance between the points. */\n\n  for (tlength=0.0, ki=1; ki<kneval; ki++)\n    tlength += s6dist(sder+(ki-1)*kdim, sder+ki*kdim, kdim);\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n  error:\n  *jstat = kstat;\n  s6err (\"sh1762_cvength\", *jstat, 0);\n  goto out;\n\n  out:\n  return tlength;\n}\n  \f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1762_s9num (SISLObject * po, SISLObject * poref, int *jdiv, int *jstat)\n#else\nstatic void\nsh1762_s9num (po, poref, jdiv, jstat)\n     SISLObject *po;\n     SISLObject *poref;\n     int *jdiv;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find number of possible subdivisions of an object.\n*\n*\n*\n* INPUT      : po     - SISLObject to subdevide.\n*              poref  - The other object in intersection.\n*\n*\n* OUTPUT     : jdiv   - Possible subdivisions of object.\n*                         = 0     : No subdivision.\n*                         = 1     : Subdivision in first parameter direction.\n*                         = 2     : Subdivision in second parameter direction.\n*                         = 3     : Subdivision in both parameter direction.\n*              jstat  - status messages\n*                         = 0     : no error.\n*                         < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-04.\n* REVISED BY : Vibeke Skytt, SINTEF, 2018-02. Introduced segmentation\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\n  int kgtpi1=0, kgtpi2=0;\n  double tang1=DZERO, tang2=DZERO;\n  int not_case_2d = 1;\n  int kbez1=1, kbez2=1;\n  int hasseg1 = 0, hasseg2 = 0;\n  /*double tcvp1 = 0.0, tcvp2 = 0.0; */\n  double tsfp1=0.0, tsfp2=0.0, t2p1=0.0, t2p2=0.0;\n  double tsize1 = 0.0, tsize2 = 0.0;\n  double tref = 5.0;\n  double lenfac = 0.01;\n  int closed1=0, closed2=0;\n\n  /* Init. */\n\n  *jdiv = 0;\n\n  if (po->iobj < SISLPOINT || po->iobj > SISLSURFACE)\n    goto err121;\n  if (poref->iobj < SISLPOINT || poref->iobj > SISLSURFACE)\n    goto err121;\n\n  if (po->iobj == SISLPOINT)\n    goto out;\n\n  kgtpi1 = 10;\n  tang1 = HUGE;\n\n  kgtpi2 = 0;\n  tang2 = (double) 0.0;  /* VSK. 030394. Changed tang1 into tang2. */\n\n  /* Get attributes from object to divide. */\n  if (po->iobj == SISLCURVE)\n    {\n      if (po->c1->pdir != SISL_NULL)\n\t{\n\t  kgtpi1 = po->c1->pdir->igtpi;\n\t  tang1 = po->c1->pdir->aang;\n\t}\n      kbez1 = (po->c1->ik == po->c1->in);\n      closed1 = (po->c1->cuopen == SISL_CRV_CLOSED);\n      tsize1 = tsfp1 = sh1762_cvlength(po->c1, &kstat);\n      tsfp2 = 1.0;\n      if (kstat < 0)\n\tgoto error;\n    }\n  else \n    {\n      if (po->s1->pdir != SISL_NULL)\n\t{\n\t  kgtpi1 = po->s1->pdir->igtpi;\n\t  tang1 = po->s1->pdir->aang;\n\t}\n      kbez1 = (po->s1->ik1 == po->s1->in1 && po->s1->ik2 == po->s1->in2);\n      closed1 = (po->s1->cuopen_1 == SISL_SURF_CLOSED || \n\t\t po->s1->cuopen_2 == SISL_SURF_CLOSED);\n      if (po->s1->seg1 && po->s1->seg1->num_seg > 0)\n\thasseg1 += 1;\n      if (po->s1->seg2 && po->s1->seg2->num_seg > 0)\n\thasseg1 += 2;\n\n      tsfp1 = sh1762_sflength(po->s1, 1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      tsfp2 = sh1762_sflength(po->s1, 2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      tsize1 = max(tsfp1, tsfp2);\n    }\n\n  /* Get attributes from referance object. */\n  if (poref->iobj == SISLCURVE)\n    {\n      if (poref->c1->pdir != SISL_NULL)\n\t{\n\t  kgtpi2 = poref->c1->pdir->igtpi;\n\t  tang2 = poref->c1->pdir->aang;\n\t}\n      kbez2 = (poref->c1->ik == poref->c1->in);\n      closed2 = (poref->c1->cuopen == SISL_CRV_CLOSED);\n      tsize2 = t2p1 = sh1762_cvlength(poref->c1, &kstat);\n      t2p2 = 1.0;\n      if (kstat < 0)\n\tgoto error;\n    }\n  else if (poref->iobj == SISLSURFACE)\n    {\n      if (poref->s1->pdir != SISL_NULL)\n\t{\n\t  kgtpi2 = poref->s1->pdir->igtpi;\n\t  tang2 = poref->s1->pdir->aang;\n\t}\n      kbez2 = (poref->s1->ik1 == poref->s1->in1 &&\n\t       poref->s1->ik2 == poref->s1->in2);\n      closed2 = (poref->s1->cuopen_1 == SISL_SURF_CLOSED || \n\t\t poref->s1->cuopen_2 == SISL_SURF_CLOSED);\n      if (poref->s1->seg1 && poref->s1->seg1->num_seg > 0)\n\thasseg2 += 1;\n      if (poref->s1->seg2 && poref->s1->seg2->num_seg > 0)\n\thasseg2 += 2;\n\n      t2p1 = sh1762_sflength(poref->s1, 1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      t2p2 = sh1762_sflength(poref->s1, 2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      tsize2 = max(t2p1, t2p2);\n    }\n  else \n    tsize2 = 0.0;\n\n  if (poref->iobj == SISLPOINT && poref->p1->idim == 2)\n    not_case_2d = 0; //FALSE;\n  else\n    not_case_2d = 1; //TRUE;\n\n\n    /* Test for number of division directions.     */\n  /*---------------------------------------------*/\n  /* If linear, we do not subdivide.             */\n  if (kgtpi1 == 0 && tang1 <= ANGULAR_TOLERANCE/10.0 && \n    not_case_2d && !(tsize1 > 10.0*tsize2))\n    /*if (kgtpi1 == 0 && tang1 <= ANGULAR_TOLERANCE/20.0 && \n      not_case_2d && !(tsize1 > 10.0*tsize2))*/\n    *jdiv = 0;\n\n  /* If the other surface has segments and this one not, we do\n     not subdivide  */\n  else if (hasseg2 > 0 && hasseg1 == 0)\n    *jdiv = 0;\n\n  /* If the other object is closed and this not, we do not subdivide */\n  else if (closed1 == 0 && closed2 == 1)\n    *jdiv = 0;\n\n  else if (po->iobj == SISLCURVE && poref->iobj == SISLSURFACE)\n    /* Subdivide curve. */\n    {\n      if (s1791 (po->c1->et, po->c1->ik, po->c1->in))\n\t*jdiv = 1;\n\n      else\n\t*jdiv = 0;\n\n    }\n\n  else if (kgtpi1 == 0 && tang1 < SIMPLECASE /*/ (double) 2.0 */ && \n\t   (kbez1 == 1 || tang1 < 10.0*ANGULAR_TOLERANCE || \n\t    tsfp1*tsfp2 < 0.1*t2p1*t2p2) &&\n\t   (kgtpi2 != 0 || tang2 > tang1 * (double) 2.0) &&\n\t   tsize2 > 100.0*tsize1)\n    *jdiv = 0; \n\n  else if (po->iobj == SISLCURVE)\n    {\n      if (s1791 (po->c1->et, po->c1->ik, po->c1->in))\n\t*jdiv = 1;\n\n      else\n\t*jdiv = 0;\n    }\n  else if (po->iobj == SISLSURFACE)\n    {\n\n\t\n      /* The segmentation logic is too simple as it does not\n\t take into account that segmentation in theory can be given in \n\t more than one direction and attached to more than one surface.\n\t However, this should not be the case currently.  */\n      if (hasseg1 == 1)\n\t*jdiv = 1;\n      else if (po->s1->cuopen_1 == 0 && po->s1->cuopen_2 == 1)\n\t*jdiv = 1;\n      else if (po->s1->cuopen_1 == 1 && po->s1->cuopen_2 == 0)\n\t*jdiv = 0;\t\n      else if ((kgtpi1 == 2 || kgtpi1 == 20) && \n\t       po->s1->in1 < po->s1->in2 && tsfp1 < tsfp2)\n\t*jdiv = 0;\n      else if (s1791 (po->s1->et1, po->s1->ik1, po->s1->in1)  &&\n\t       !((po->s1->ik1 == 2 && tsfp1 < tref*tsfp2) ||\n\t\t tsfp1 < lenfac*tsfp2))\n\t*jdiv = 1;\n      else\n\t*jdiv = 0;\n\n      if (hasseg1 == 2)\n\t*jdiv = 2;\n      else if (po->s1->cuopen_1 == 1 && po->s1->cuopen_2 == 0)\n\t*jdiv += 2;\n      else if (po->s1->cuopen_1 == 0 && po->s1->cuopen_2 == 1)\n\t;\t\n      else if ((kgtpi1 == 1 || kgtpi1 == 10) && \n\t       po->s1->in2 < po->s1->in1 && tsfp2 < tsfp1)\n\t;\n      else if (hasseg1 != 1 &&\n\t       s1791 (po->s1->et2, po->s1->ik2, po->s1->in2)  &&\n\t       !((po->s1->ik2 == 2 && tsfp2 < tref*tsfp1) ||\n\t\t tsfp2 < lenfac*tsfp1))\n\t*jdiv += 2;\n    }\n  goto out;\n\n\n  /* Error in lower level routine. */\n  error:\n  *jstat = kstat;\n  s6err (\"sh1762_s9num\", *jstat, 0);\n  goto out;\n\n  /* Error. Kind of object does not exist.  */\nerr121:\n  *jstat = -121;\n  s6err (\"sh1762_s9num\", *jstat, 0);\n\nout:;\n}\n  \f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1762_s9num2 (SISLObject *po1, SISLObject *po2, int obj,\n\t       SISLEdge *vedge[], int *jdiv, int *jstat)\n#else\nstatic void\n  sh1762_s9num2 (po1, po2, obj, vedge, jdiv, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     int obj;\n     SISLEdge *vedge[];\n     int *jdiv;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Update number of parameter directions in which to\n*              subdivide based on configuration of edge intersections\n*\n*\n*\n* INPUT      : po1     - First object in intersection\n*              po2     - Second other object in intersection\n*              obj     - Object to subdivide (1 = first, 2 = second)\n*              vedge[2] - intersection on edges\n*\n* INPUT/OUTPUT jdiv   - Possible subdivisions of object.\n*                         = 0     : No subdivision.\n*                         = 1     : Subdivision in first parameter direction.\n*                         = 2     : Subdivision in second parameter direction.\n*                         = 3     : Subdivision in both parameter direction.\n*\n*\n* OUTPUT     : jstat  - status messages\n*                         = 0     : no error.\n*                         < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 2023-05\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\n  int ki, kj;\n  SISLObject *qo;\n  SISLIntpt **up = SISL_NULL;\n  int knum = 0;\n  double range[4];\n  double tdel;\n  int ix = (obj == 1) ? 0 : po1->iobj;\n  double frac = 0.6;\n\n  qo = (obj == 1) ? po1 : po2;\n  if (qo->iobj != SISLSURFACE || *jdiv == 0)\n    goto out;  /* Nothing to do */\n\n  range[0] = qo->s1->et1[qo->s1->ik1-1];\n  range[1] = qo->s1->et1[qo->s1->in1];\n  range[2] = qo->s1->et2[qo->s1->ik2-1];\n  range[3] = qo->s1->et2[qo->s1->in2];\n\n  /* Fetch main intersections on edges */\n  sh6edgpoint (vedge, &up, &knum, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* For each intersection point, fetch associated help points and\n     compute the parameter distance between the main point and the help\n     point internal to the current object */\n  for (ki=0; ki<knum; ++ki)\n    {\n      for (kj=0; kj<up[ki]->no_of_curves; ++kj)\n\t{\n\t  if (!sh6ishelp(up[ki]->pnext[kj]))\n\t    continue;\n\n\t  sh6isinside(po1, po2, up[ki]->pnext[kj], &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  if (kstat == 0)\n\t    continue;   /* The point is outside both objects */\n\n\t  if (*jdiv == 1 || *jdiv == 3)\n\t    {\n\t      /* Check extent of help point interval in first parameter direction */\n\t      tdel = fabs(up[ki]->pnext[kj]->epar[ix] - up[ki]->epar[ix]);\n\t      if (tdel > frac*(range[1] - range[0]))\n\t\t*jdiv -= 1;\n\t    }\n\t      \n\t  if (*jdiv == 2 || *jdiv == 3)\n\t    {\n\t      /* Check extent of help point interval in second parameter direction */\n\t      tdel = fabs(up[ki]->pnext[kj]->epar[ix+1] - up[ki]->epar[ix+1]);\n\t      if (tdel > frac*(range[3] - range[2]))\n\t\t*jdiv -= 2;\n\t    }\n\t      \n\t}\n    }\n  goto out;\n  \n/* Error in lower level routine.  */\nerror:*jstat = kstat;\n  s6err (\"sh1762_s9num2\", *jstat, 0);\n  goto out;\n\nout:\n  if (up != SISL_NULL)\n    freearray (up);\n\n  return;\n}\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic int \nsh1762_is_taboo(SISLSurf *psurf1, SISLSurf *psurf2, SISLIntpt *pintpt, \n\t\tint idir, int *jstat)\n#else\nstatic int\nsh1762_is_taboo(psurf1, psurf2 ,pintpt, idir, jstat)\n    SISLSurf *psurf1;\n    SISLSurf *psurf2;\n    SISLIntpt *pintpt;\n    int idir;\n    int *jstat;\n#endif\n\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Check if the intersection curve passing through\n*\t       the point is always parallel to an iso-curve. \n*\n*\n*\n* INPUT      : psurf1   - 1. surface in intersection problem.\n*              psurf2   - 2. surface in intersection problem or SISL_NULL.\n*              pintpt   - Intersection point.\n*              idir     - Parameter direction in surface.\n*\n*\n* OUTPUT     : return value : 1 = is taboo point, 0 = no taboo point\n*              jstat    - Status messages\n*                          = 0     : OK\n*                          < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 99-05.\n*\n*********************************************************************\n*/\n{\n   static double parallel    = 0.01;\n   static double fuzzy_angle = 1e-4;\n   static double tol = (double) 1000000.0 * REL_COMP_RES;\n\n   int kstat = 0;\n   int is_taboo = 0;\n   double derivs1[9], derivs2[9], norm[3], nor1[3], nor2[3], angle;\n   double vec[3], ang1, ang2, ang3, ang4;\n   double abs_tang1[2], abs_tang2[2];\n   double tmax;\n   int ilfs = 0, ilft = 0;\n\n   if (psurf1->idim == 2)\n     return 0;\n\n   /* Test input. */\n\n   if (psurf2 && (psurf1->idim != psurf2->idim || psurf1->idim != 3))\n     goto err104;\n\n   if (!psurf2 && psurf1->idim != 1)\n     goto err105;\n\n   if (psurf2)\n     {\n       /* Evaluate the intersection point in both surfaces. */\n\n       s1421(psurf1, 1, &pintpt->epar[0], &ilfs, &ilft, derivs1, norm, &kstat);\n       if (kstat < 0)\n\t goto error;\n\n       s1421(psurf2, 1, &pintpt->epar[2], &ilfs, &ilft, derivs2, norm, jstat);\n       if (kstat < 0)\n\t goto error;\n\n       s6crss(derivs2+3, derivs2+6, nor2);\n       s6crss(derivs1+3, derivs1+6, nor1);\n\n       /* If we have a singularity, we don't declare it as taboo. */\n\n       angle = s6ang(nor1, nor2, 3);\n\n       s6crss(nor1, nor2, vec);\n       ang1 = s6ang(derivs1+3, vec, 3);\n       ang2 = s6ang(derivs1+6, vec, 3);\n       ang3 = s6ang(derivs2+3, vec, 3);\n       ang4 = s6ang(derivs2+6, vec, 3);\n\n       abs_tang1[0] = fabs(s6scpr(derivs1+6, nor2, 3));\n       abs_tang1[1] = fabs(s6scpr(derivs1+3, nor2, 3));\n\n       abs_tang2[0] = fabs(s6scpr(nor1, derivs2+6, 3));\n       abs_tang2[1] = fabs(s6scpr(nor1, derivs2+3, 3));\n\n       if (angle < fuzzy_angle)\n\t is_taboo = 0;\n       else if (idir == 1 && abs_tang1[0] < parallel*abs_tang1[1])\n\t is_taboo = 1;\n       else if (idir == 2 && abs_tang1[1] < parallel*abs_tang1[0])\n\t is_taboo = 1;\n       else \n\t is_taboo = 0;\n     }\n   else \n     {\n       /* Evaluate the intersection point. */\n\n       s1421(psurf1, 1, &pintpt->epar[0], &ilfs, &ilft, derivs1, norm, &kstat);\n       if (kstat < 0)\n\t goto error;\n\n       /* If we have a singularity, we don't declare it as taboo. */\n\n       tmax = sqrt(derivs1[1]*derivs1[1] + derivs1[2]*derivs1[2]);\n       if (tmax < tol)\n\t  /* The length of the surface normal is less than the \n\t     given tolerance*/\n\tis_taboo = 0;\n\n       else if (idir == 1 && fabs(derivs1[2]) < parallel*tmax)\n\t is_taboo = 1;\n       else if (idir == 2 && fabs(derivs1[1]) < parallel*tmax)\n\t is_taboo = 1;\n       else \n\t is_taboo = 0;\n     }\n\n   *jstat = 0;\n   goto out;\n\n   /* Error in lower order routine. */\n  error:\n  *jstat = kstat;\n  s6err (\"sh1762_is_taboo\", *jstat, 0);\n   goto out;\n\n  /* Error. Dimension not equal to 3.  */\nerr104:\n  *jstat = -104;\n  s6err (\"sh1762_is_taboo\", *jstat, 0);\n   goto out;\n\n  /* Error. Conflicting dimensions.  */\nerr105:\n  *jstat = -105;\n  s6err (\"sh1762_is_taboo\", *jstat, 0);\n   goto out;\n\nout:\n   return is_taboo;\n}\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic int \nsh1762_is_taboo2(SISLObject *po1, SISLObject *po2, SISLIntpt *pintpt, \n\t\t int idir, SISLIntdat *pintdat, int ipar)\n#else\nstatic int\n  sh1762_is_taboo2(po1, po2, pintpt, idir, pintdat, ipar)\n    SISLObject *po1;\n    SISLObject *po2;\n    SISLIntpt *pintpt;\n    int idir;\n    SISLIntdat *pintdat;\n    int ipar;\n#endif\n\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Check if the intersection curve passing through\n*\t       the point is close to intersection points in the other\n*              surface\n*\n*\n*\n* INPUT      : po1   - 1. surface in intersection problem.\n*              po2   - 2. surface in intersection problem or SISL_NULL.\n*              pintpt   - Intersection point.\n*              idir     - Parameter direction in surface.\n*              pintdat  - Pool of intersection points\n*              ipar     - First index of parameter in other surface\n*\n*\n* OUTPUT     : return value : 1 = is taboo point, 0 = no taboo point\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 2018-05.\n*\n*********************************************************************\n*/\n{\n  int status;\n  int kj;\n  double sstart[2], send[2];    /* Parameter domain of psurf2 */\n  double sbelt1[2], sbelt2[2];  /* Belt containing intersection points,\n\t\t\t\t   psurf2 */\n  double tdel1, tdel2;          /* Threshholds for \"close\"   */\n  int nmb_inter = 0;            /* Number of intersection points found */\n  SISLIntpt *pcurr;             /* Current intersection point */\n  double belt_fac = 0.05;\n\n  sbelt1[0] = sstart[0] = po2->s1->et1[po2->s1->ik1 - 1];\n  sbelt2[0] = sstart[1] = po2->s1->et2[po2->s1->ik2 - 1];\n\n  sbelt1[1] = send[0] = po2->s1->et1[po2->s1->in1];\n  sbelt2[1] = send[1] = po2->s1->et2[po2->s1->in2];\n  \n  tdel1 = (double) 0.01 *(send[0] - sstart[0]);\n  tdel2 = (double) 0.01 *(send[1] - sstart[1]);\n\n  /* Find extent of area with intersections */\n  if (pintdat && pintdat->ipoint > 0)\n    {\n      nmb_inter = 0;\n      sbelt1[1] = sstart[0];\n      sbelt2[1] = sstart[1];\n      sbelt1[0] = send[0];\n      sbelt2[0] = send[1];\n      for (kj=0; kj<pintdat->ipoint; kj++)\n\t{\n\t  pcurr = pintdat->vpoint[kj];\n\t  sh6isinside((ipar == 0) ? po2 : po1, (ipar == 0) ? po1 : po2,\n\t\t      pcurr, &status);\n\t  \n\t  if (status > 0)\n\t    {\n\t      /* Inside */\n\t      nmb_inter++;\n\t      sbelt1[0] = min(sbelt1[0], pcurr->epar[ipar]);\n\t      sbelt1[1] = max(sbelt1[1], pcurr->epar[ipar]);\n\t      sbelt2[0] = min(sbelt2[0], pcurr->epar[ipar+1]);\n\t      sbelt2[1] = max(sbelt2[1], pcurr->epar[ipar+1]);\n\t    }\n\t}\n    }\n  \n  if (nmb_inter > 1 && \n      ((sbelt1[1]-sbelt1[0])/(send[0]-sstart[0]) < belt_fac ||\n       (sbelt2[1]-sbelt2[0])/(send[1]-sstart[1]) < belt_fac))\n    return 1;\n  else\n    return 0;\n}\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic int\nsh1762_s9subdivpt (SISLObject * po1, SISLObject * po2, double aepsge,\n\t\t   int iobj, int idiv, SISLEdge * vedge[], SISLIntdat ** pintdat,\n\t\t   int *fixflag, SISLIntpt ** rpt, double epar[], int *jstat)\n#else\nstatic int\nsh1762_s9subdivpt (po1, po2, aepsge, iobj, idiv, vedge, pintdat, fixflag, rpt, epar, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     int iobj;\n     int idiv;\n     SISLEdge *vedge[];\n     SISLIntdat **pintdat;\n     int *fixflag;\n     SISLIntpt **rpt;\n     double epar[];\n     int *jstat;\n#endif\n /* UPDATE ujk: Set up strategy for finding subdiv. point.\n    Use of shsing(singular iteration) pluss segmentation. */\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find an appropriate subdivision point of an object when\n*              the other object in the subdivision and eventual\n*              intersections found on the edges, are known.\n*\n*\n*\n* INPUT      : po1      - First object in intersection.\n*              po2      - Second object in intersection.\n*              aepsge   - Geometry resolution.\n*              iobj     - Number of object to divide.\n*              vedge[]  - Intersection on edges.\n*              pintdat  - Intersection data.\n*\n*\n* OUTPUT     : fixflag  - Indicates if the subdivision point is fixed.\n*              rpt      - An existing internal intersection point used as\n*                         subdividing point. If no such point is found,\n*                         *rpt == SISL_NULL.\n*              epar     - Parameter values of subdivision point. The number of\n*                         elements used is equal to the number of parameter\n*                         directions of the object to be subdivide. The \n*                         dimension is equal to 2.\n*              jstat    - Status messages\n*                          = 1     : Intersection found\n*                          = 0     : no intersection found.\n*                          < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-04.\n* REVISED BY : Vibeke Skytt, SI, 90-10.\n* REWRITTEN BY : Vibeke Skytt, SINTEF, 94-02.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;\n   int kpos = 0;\n   int kpar;            /* First index of subdivision point in the\n\t\t\t   parameter value of in intersection point.        */\n   int kfound = 0;      /* Indicates if in intersection point / extremal\n\t\t\t   point is to be used.                             */\n   int kf1=0, kf2=0;    /* Indicates if an internal intersection point is\n\t\t\t   legal in the parameter directions of a surface.  */\n   double tdel;\t\t/* Parameter used to measure closeness to an edge.  */\n   double tdel1, tdel2;\t/* Parameters used to measure closeness to an edge. */\n   double tstart, tend; /* Endparameters of curve.                          */\n   double tstart2, tend2; /* Endparameters of second curve.                 */\n   double tpar;         /* Parameter value of subdivision point. */\n   double tpar2;        /* Parameter value of point from iteration. */\n   double sstart[2], send[2];  /* Endparameters of surface.      */\n   double spar[2];      /* Parameter value of subdivision point. */\n   double spar2[2];     /* Parameter value of subdivision point. */\n   double sparsave[2];  /* Parameter value of subdivision point. */\n   SISLObject *qo1;\t/* Pointer to the object that is to be subdivided. */\n   SISLObject *qo2;\t/* Pointer to the other object.          */\n   SISLIntpt *qpt = SISL_NULL;  /* An internal intersection point.    */\n   int subdiv_flag = 0;\n   double sbelt1[2], sbelt2[2]; /* Domain containing intersections points */\n   int nmb_inter = 0;\n   double belt_fac = 0.05; \n   SISLIntpt *pcurr;          /* Current intersection point.          */\n   SISLIntpt *pcurr2;          /* Current intersection point.          */\n   int ki, kj;                /* Counter.                             */\n   double fac = 0.2;\n   int npt = (*pintdat) ? (*pintdat)->ipoint : 0;\n   int kpar2;\n\n   /* Set pointer to subdivision object. */\n\n   qo1 = (iobj == 1) ? po1 : po2;\n   qo2 = (iobj == 1) ? po2 : po1;\n   kpar = (iobj == 1) ? 0 : po1->iobj;\n   kpar2 = (iobj == 1) ? po1->iobj : 0;\n\n  *jstat = 0;\n\n  /* Branch on subdivision object. */\n\n  if (qo1->iobj == SISLCURVE)\n  {\n     /* Find a proper subdivision value of the curve.  First set when a point\n\tis to close to an edge to be used as a subdivision point. */\n\n     tdel = (double) 0.01 *(qo1->c1->et[qo1->c1->in] -\n\t\t\t    qo1->c1->et[qo1->c1->ik - 1]);\n\n     /* Try to find an internal intersection point. */\n\n     s6idint (po1, po2, *pintdat, &qpt, iobj);\n     if (!(3*qo1->c1->ik > qo1->c1->in) &&\n\t /* if (qo1->c1->ik != qo1->c1->in && */\n\t (sh6ismain (qpt)) && sh6nmbhelp (qpt,&kstat) == 0)\n\tqpt = SISL_NULL;\n\n      if (qpt != SISL_NULL)\n\t{\n\t  /* Internal intersection point found. */\n\n\t  tpar = qpt->epar[kpar];\n\n\t  if (tpar < (qo1->c1->et[qo1->c1->ik - 1] + tdel) ||\n\t      tpar > (qo1->c1->et[qo1->c1->in] -tdel))\n\t       qpt = SISL_NULL;  /* Do not use the point as a subdivision point. */\n\t}\n\n      if (qpt == SISL_NULL &&\n\t  /*vedge[iobj - 1]->ipoint == 0 &&*/ qo1->c1->ik == qo1->c1->in)\n      {\n\t /* No internal intersection is found. The curve is of Bezier type,\n\t    and there is no intersection on the endpoints of the curve.\n\t    Then we try to iterate in order to find an intersection or\n\t    closest point to use as a subdivision point. Branch on the\n\t    various kind of other objects involved in the intersection. */\n\n\t tstart = qo1->c1->et[qo1->c1->ik - 1];\n\t tend = qo1->c1->et[qo1->c1->in];\n\t tpar = (tstart + tend) * (double) 0.5;\n\t kfound = 1;\n\n\t if (qo2->iobj == SISLPOINT)\n\t {\n\t    /* ALA & UJK start 31/10/90. */\n\t    if (qo2->p1->idim == 1)\n\t       s1172 (qo1->o1->c1, tstart, tend,\n\t\t      tpar, &tpar, &kstat);\n\t    else\n\t    {\n\t       kstat = 1;   /* Use quick iteration. */\n\t       s1771 (qo2->o1->p1, qo1->o1->c1, aepsge, tstart, tend,\n\t\t      tpar, &tpar, &kstat);\n\t    }\n\t    if (kstat < 0)\n\t       goto error;\n\t }\n\n\t else if (qo2->iobj == SISLCURVE)\n\t {\n\t    tstart2 = qo2->c1->et[qo2->c1->ik - 1];\n\t    tend2 = qo2->c1->et[qo2->c1->in];\n\t    tpar2 = (tstart + tend) * (double) 0.5;\n\t    tdel2 = (double)0.01*(tend - tstart);\n\n\t    s1770 (qo1->o1->c1, qo2->o1->c1, aepsge, tstart, tstart2, tend,\n\t\t   tend2, tpar, tpar2, &tpar, &tpar2, &kstat);\n\t    if (kstat < 0)\n\t       goto error;\n\n\t    /* Test the subdivision point towards the endpoint of the\n\t       second curve. */\n\n\t    if (tpar2 < tstart2+tdel2 || tpar2 > tend2-tdel2)\n\t       kfound = 0;\n\t    \n\t    if (kfound && vedge[iobj - 1]->ipoint > 0)\n\t      {\n\t\t/* Check distance to existing intersection points */\n\t\tfor (kj=0; kj<(*pintdat)->ipoint; kj++)\n\t\t  {\n\t\t    pcurr = (*pintdat)->vpoint[kj];\n\t\t    if (sh6ishelp(pcurr))\n\t\t      continue;\n\t\t    sh6isinside(po1, po2, pcurr, &kstat);\n\t\t    if (kstat < 0)\n\t\t      goto error;\n\t\t    if (kstat == 0)\n\t\t      continue;\n\t\t    if (fabs(tpar2 - pcurr->epar[kpar2]) < tdel2 &&\n\t\t\tDNEQUAL(tpar2, pcurr->epar[kpar2]))\n\t\t      {\n\t\t\tkfound = 0;\n\t\t\tbreak;\n\t\t      }\n\t\t  }\n\t      }\n\t }\n\n\t else if (qo2->iobj == SISLSURFACE)\n\t {\n\t    sstart[0] = qo2->s1->et1[qo2->s1->ik1 - 1];\n\t    sstart[1] = qo2->s1->et2[qo2->s1->ik2 - 1];\n\n\t    send[0] = qo2->s1->et1[qo2->s1->in1];\n\t    send[1] = qo2->s1->et2[qo2->s1->in2];\n\n\t    spar[0] = (sstart[0] + send[0]) * (double) 0.5;\n\t    spar[1] = (sstart[1] + send[1]) * (double) 0.5;\n\n\t    tdel1 = (double)0.01* (send[0] - sstart[0]);\n\t    tdel2 = (double)0.01* (send[1] - sstart[1]);\n\n\t    kstat = 1;    /* Use quick iteration. */\n\t    s1772 (qo1->o1->c1, qo2->o1->s1, aepsge, tstart, sstart, tend,\n\t\t   send, tpar, spar, &tpar, spar, &kstat);\n\t    if (kstat < 0)\n\t       goto error;\n\t    /* if (kstat == 2) */\n\t    /*   { */\n\t    /* \tsh6closevert(qo1->c1, qo2->s1, &tpar2, &spar2[0]); */\n\t    /* \ttpar2 = min(tend-10.0*tdel, max(tpar2, tstart+1.0*tdel)); */\n\t    /* \tspar2[0] = min(send[0]-10.0*tdel1, max(spar2[0], sstart[0]+10.0*tdel1)); */\n\t    /* \tspar2[1] = min(send[1]-10.0*tdel2, max(spar2[1], sstart[1]+10.0*tdel2)); */\n\t    /* \ts1772 (qo1->o1->c1, qo2->o1->s1, aepsge, tstart, sstart, tend, */\n\t    /* \t       send, tpar2, spar2, &tpar2, spar2, &kstat); */\n\t    /* \tif (kstat < 0) */\n\t    /* \t  goto error; */\n\t    /* \tif (kstat == 1) */\n\t    /* \t  { */\n\t    /* \t    tpar = tpar2; */\n\t    /* \t    spar[0] = spar2[0]; */\n\t    /* \t    spar[1] = spar2[1]; */\n\t    /* \t  } */\n\t    /*   } */\n\n\t    /* Test the subdivision point towards the edges of the surface. */\n\n\t    if (spar[0] < sstart[0]+tdel1 || spar[0] > send[0]-tdel1 ||\n\t\tspar[1] < sstart[1]+tdel2 || spar[1] > send[1]-tdel2)\n\t       kfound = 0;\n\t    /* else if (kstat == 2) */\n\t    /*   kfound = 0; */\n\t    \n\t    if (kfound && vedge[iobj - 1]->ipoint > 0)\n\t      {\n\t\t/* Check distance to existing intersection points */\n\t\tfor (kj=0; kj<(*pintdat)->ipoint; kj++)\n\t\t  {\n\t\t    pcurr = (*pintdat)->vpoint[kj];\n\t\t    if (sh6ishelp(pcurr))\n\t\t      continue;\n\t\t    sh6isinside(po1, po2, pcurr, &kstat);\n\t\t    if (kstat < 0)\n\t\t      goto error;\n\t\t    if (kstat == 0)\n\t\t      continue;\n\t\t    if ((fabs(spar[0] - pcurr->epar[kpar2]) < tdel1 &&\n\t\t\t DNEQUAL(spar[0],pcurr->epar[kpar2]))  ||\n\t\t\t(fabs(spar[1] - pcurr->epar[kpar2+1]) < tdel2 &&\n\t\t\t DNEQUAL(spar[1], pcurr->epar[kpar2+1])))\n\t\t      {\n\t\t\tkfound = 0;\n\t\t\tbreak;\n\t\t      }\n\t\t  }\n\t      }\n\t }\n\n\t if (kfound && vedge[iobj - 1]->ipoint > 0)\n\t   {\n\t     /* Check distance to existing intersection points */\n\t     for (kj=0; kj<(*pintdat)->ipoint; kj++)\n\t       {\n\t\t pcurr = (*pintdat)->vpoint[kj];\n\t\t if (sh6ishelp(pcurr))\n\t\t   continue;\n\t\t sh6isinside(po1, po2, pcurr, &kstat);\n\t\t if (kstat < 0)\n\t\t   goto error;\n\t\t if (kstat == 0)\n\t\t   continue;\n\t\t if (fabs(tpar - pcurr->epar[kpar]) < tdel)\n\t\t   {\n\t\t     kfound = 0;\n\t\t     break;\n\t\t   }\n\t       }\n\t   }\n\t \n\t /* Test the subdivision point towards the edges of the subdivision\n\t    curve. */\n\n\t if (!kfound ||\n\t     tpar < tstart+tdel || tpar > tend-tdel)\n\n\t    /* Use the midpoint of the curve as subdivision point. */\n\n\t    tpar = s1792 (qo1->c1->et, qo1->c1->ik, qo1->c1->in);\n      }\n      else if (qpt == SISL_NULL)\n\t /* Use the midpoint as a subdivision point. */\n\n\t tpar = s1792 (qo1->c1->et, qo1->c1->ik, qo1->c1->in);\n\n      /* Set output variables  */\n\n      epar[0] = tpar;\n      *rpt = qpt;\n  }\n  else if (qo1->iobj == SISLSURFACE)\n  {\n     /* Find a subdivision point of the surface. Branch on the other\n\tobject involved in the intersection. First set the endparameters\n\tof the surface and when a point is to close to an edge\n\tto be used as a subdivision point. */\n\n     sbelt1[0] = sstart[0] = qo1->s1->et1[qo1->s1->ik1 - 1];\n     sbelt2[0] = sstart[1] = qo1->s1->et2[qo1->s1->ik2 - 1];\n\n     sbelt1[1] = send[0] = qo1->s1->et1[qo1->s1->in1];\n     sbelt2[1] = send[1] = qo1->s1->et2[qo1->s1->in2];\n\n     tdel1 = (double) 0.01 *(send[0] - sstart[0]);\n     tdel2 = (double) 0.01 *(send[1] - sstart[1]);\n     spar[0] = 0.5*(sstart[0] + send[0]);\n     spar[1] = 0.5*(sstart[1] + send[1]);\n\n     /* Find extent of area with intersections */\n     if ((*pintdat) && (*pintdat)->ipoint > 0)\n       {\n\t nmb_inter = 0;\n\t sbelt1[1] = sstart[0];\n\t sbelt2[1] = sstart[1];\n\t sbelt1[0] = send[0];\n\t sbelt2[0] = send[1];\n\t for (kj=0; kj<(*pintdat)->ipoint; kj++)\n\t   {\n\t     pcurr = (*pintdat)->vpoint[kj];\n\t     if (sh6ishelp(pcurr))\n\t\t continue;\n\t     \n\t     if (pcurr->epar[kpar] >= sstart[0] && \n\t\t pcurr->epar[kpar] <= send[0] &&\n\t\t pcurr->epar[kpar+1] >= sstart[1] && \n\t\t pcurr->epar[kpar+1] <= send[1])\n\t       {\n\t\t /* Inside */\n\t\t nmb_inter++;\n\t\t sbelt1[0] = min(sbelt1[0], pcurr->epar[kpar]);\n\t\t sbelt1[1] = max(sbelt1[1], pcurr->epar[kpar]);\n\t\t sbelt2[0] = min(sbelt2[0], pcurr->epar[kpar+1]);\n\t\t sbelt2[1] = max(sbelt2[1], pcurr->epar[kpar+1]);\n\t       }\n\t   }\n\t }\n\n     /* First check if a surface segmentation defines the\n\tsubdivision parameter                                          */\n     kfound = 0;\n     if (po1->psimple == po2)\n       kfound = sh6getsegdiv(qo1->s1, idiv, spar, &subdiv_flag);\n     if (kfound > 0)\n       {\n\t /* printf(\"Segment subdivision \\n\");  %7.13f, %d \\n\",spar[idiv-1], subdiv_flag);*/\n\t *fixflag = kfound;\n       }\n\n     /* In the Bezier case, search for an internal intersection point. */\n     \n\n     if (kfound != idiv &&\n\t qo1->s1->ik1 == qo1->s1->in1 && qo1->s1->ik2 == qo1->s1->in2)\n\ts6idint (po1, po2, *pintdat, &qpt, iobj);\n     if (qpt != SISL_NULL)\n     {\n\t/* Internal intersection point found. */\n\tsparsave[0] = spar[0] = qpt->epar[kpar];\n\tsparsave[1] = spar[1] = qpt->epar[kpar + 1];\n\tkf1 = kf2 = 1;\n\n\t/* Test the point towards the edges of the surface. */\n\n\tif (spar[0] < sstart[0] + tdel1 || spar[0] > send[0] - tdel1 ||\n\t    (nmb_inter > 1 && \n\t     (sbelt1[1]-sbelt1[0])/(send[0]-sstart[0]) < belt_fac))\n\t{\n\t   kf1--;\n\t}\n\tif (spar[1] < sstart[1] + tdel2 || spar[1] > send[1] - tdel2 ||\n\t    (nmb_inter > 1 && \n\t     (sbelt2[1]-sbelt2[0])/(send[1]-sstart[1]) < belt_fac))\n\t{\n\t   kf2--;\n\t}\n\n\t/* Check if the intersection curve passing through\n\t   the point is always parallel to an iso-curve. */\n\t\t    \n\tif ((*pintdat)->ipoint > 1 && kf1 > 0 && qo2->iobj == SISLSURFACE)\n\t  {\n\t    if (sh1762_is_taboo(qo1->s1, qo2->s1,\n\t\t\t\tqpt, 1, &kstat))\n\t      {\n\t\tkf1--;\n\t      }\n\t  }\n\n\tif ((*pintdat)->ipoint > 1 && kf2 > 0 && qo2->iobj == SISLSURFACE)\n\t  {\n\t    if (sh1762_is_taboo(qo1->s1, qo2->s1,\n\t\t\t    qpt, 2, &kstat))\n\t      {\n\t\tkf2--;\n\t      }\n\t  }\n\tif (kf1 == 0 || kf2 == 0)\n\t  qpt = SISL_NULL;\n     }\n\n     /* If no iteration is tried, use the midpoint. */\n     if ((!qpt) && kfound != idiv && qo2->iobj != SISLSURFACE &&\n\t !(qo2->iobj == SISLPOINT && qo2->p1->idim == 1) &&\n\t qo1->s1->ik1 == qo1->s1->in1 && qo1->s1->ik2 == qo1->s1->in2)\n     {\n\t/* No internal intersection is found. The second object is not a\n\t   surface, and the subdivision surface is of Bezier type.\n\t   Prepare for iteration. */\n\n\tspar[0] = (sstart[0] + send[0]) * (double) 0.5;\n\tspar[1] = (sstart[1] + send[1]) * (double) 0.5;\n\tkfound = 3;\n\n\tif (qo2->iobj == SISLPOINT)\n\t{\n\t   s1773 (qo2->o1->p1, qo1->o1->s1, aepsge, sstart, send, spar,\n\t\t  spar, &kstat);\n\t   if (kstat < 0)\n\t      goto error;\n\t}\n\n\telse if (qo2->iobj == SISLCURVE)\n\t{\n\t   tstart = qo2->c1->et[qo2->c1->ik - 1];\n\t   tend = qo2->c1->et[qo2->c1->in];\n\t   tpar = (tstart + tend) * (double) 0.5;\n\t   tdel = (double)0.01*(tend - tstart);\n\n\t   kstat = 1;\n\t   s1772 (qo2->o1->c1, qo1->o1->s1, aepsge, tstart, sstart,\n\t\t  tend, send, tpar, spar, &tpar, spar, &kstat);\n\t   if (kstat < 0)\n\t      goto error;\n\n\t   /* Control the edges of the curve. */\n\n\t   if (tpar < tstart+tdel || tpar > tend-tdel)\n\t      kfound = 0;\n\t}\n\n\t/* Test the edges of the surface to be subdivided. */\n\n\t   if (spar[0] < sstart[0]+tdel1 || spar[0] > send[0]-tdel1)\n\t      kfound--;\n\t   if (spar[1] < sstart[1]+tdel2 || spar[1] > send[1]-tdel2)\n\t      kfound -= 2;\n\t}\n\n     if ((!qpt) && (!(kfound==idiv) && qo2->iobj != SISLSURFACE &&\n\t\t    !(qo2->iobj == SISLPOINT && qo2->p1->idim == 1)))\n\t {\n\t    /* Use the midpoint of the surface as a subdivision point. */\n\n\t    if (kfound != 1)\n\t       spar[0] = s1792 (qo1->s1->et1, qo1->s1->ik1, qo1->s1->in1);\n\t    if (kfound != 2)\n\t       spar[1] = s1792 (qo1->s1->et2, qo1->s1->ik2, qo1->s1->in2);\n\n\t    /* Test if this subdivision point is too close to an existing\n\t       inner intersection point. */\n\n\t    if (kf1 && fabs(spar[0]-sparsave[0]) < tdel1)\n\t      {\n\t\tspar[0] = sparsave[0];\n\t\tif (*fixflag != 1 && *fixflag != 3)\n\t\t  *fixflag += 1;\n\t      }\n\t    if (kf2 && fabs(spar[1]-sparsave[1]) < tdel2)\n\t      {\n\t\tspar[1] = sparsave[1];\n\t\tif (*fixflag != 2 && *fixflag != 3)\n\t\t  *fixflag += 2;\n\t      }\n\t }\n\n     if ((!qpt) && kfound != idiv && \n\t (qo2->iobj == SISLSURFACE ||\n\t  (qo2->iobj == SISLPOINT && \n\t   (qo2->p1->idim == 1 || qo2->p1->idim == 2))))\n     {\n\tSISLPtedge *qptedg;\t/* Pointer used to traverse int. points on edges. */\n\tSISLIntpt *pt1 = SISL_NULL;  /* Intersection point on edge. */\n\tSISLIntpt *pt2 = SISL_NULL;  /* Intersection point on edge. */\n\tSISLIntpt *ptsing1 = SISL_NULL; /* Singular intersection point on edge. */\n\tSISLIntpt *ptsing2 = SISL_NULL; /* Singular intersection point on edge. */\n\tdouble tmean[2];           /* Middle parameter of the surface.     */\n\t/*double tpar1=HUGE, tpar2=HUGE;   Used for comparisement with\n\t\t\t\t\t   intersection point.             */\n\t/*int ktype1=-10, ktype2=-10;     As previous.                    */\n\n\t/* There is a surface-surface intersection or an intersection\n\t   between a surface and a point in 1D. In both cases intersection\n\t   curves are the expected output. Start by logging the intersection\n\t   points at the edges. */\n\t/* If the surface is almost a Bezier surface, make it Bezier. */\n\n\ts9simple_knot(qo1->s1, idiv, spar, fixflag, &kstat);\n\tif ( kstat < 0 ) \n\t  goto error;\n\n\t/* Control for edges */\n\tif (spar[0] < sstart[0]+0.1*tdel1 || spar[0] > send[0]-0.1*tdel1)\n\t  {\n\t    spar[0] = 0.5*(sstart[0] + send[0]);\n\t    if ((*fixflag) == 1 || (*fixflag) == 3)\n\t      (*fixflag) -= 1;\n\t  }\n\tif (spar[1] < sstart[1]+0.1*tdel2 || spar[1] > send[1]-0.1*tdel2)\n\t  {\n\t    spar[1] = 0.5*(sstart[1] + send[1]);\n\t    if ((*fixflag) == 2 || (*fixflag) == 3)\n\t      (*fixflag) -= 2;\n\t  }\n\n\tif (kf1 == 1)\n\t  spar[0] = sparsave[0];\n\tif (kf2 == 1)\n\t  spar[1] = sparsave[1];\n\n\tmemcopy(sparsave, spar, 2, DOUBLE);\n\tif (((*fixflag) == 1 || (*fixflag) == 3) &&\n\t    (spar[0] < sstart[0]+tdel1 || spar[0] > send[0]-tdel1))\n\t   *fixflag -= 1;\n\tif (((*fixflag) == 2 || (*fixflag) == 3) &&\n\t    (spar[1] < sstart[1]+tdel2 || spar[1] > send[1]-tdel2))\n\t   *fixflag -= 2;\n\n\tif ( *fixflag < 3 )\n\t{\n\t   /* In at least one parameter direction there is a freedom\n\t      of the subdivision point.                               */\n\n\t   /* Set the middle parameter.  */\n\n\t   tmean[0] = s1792 (qo1->s1->et1, qo1->s1->ik1, qo1->s1->in1);\n\t   tmean[1] = s1792 (qo1->s1->et2, qo1->s1->ik2, qo1->s1->in2);\n\n\t   /* Control for edges */\n\t   if (tmean[0] < sstart[0]+0.1*tdel1 || tmean[0] > send[0]-0.1*tdel1)\n\t     tmean[0] = 0.5*(sstart[0] + send[0]);\n\t   if (tmean[1] < sstart[1]+0.1*tdel2 || tmean[1] > send[1]-0.1*tdel2)\n\t     tmean[1] = 0.5*(sstart[1] + send[1]);\n\n\t   if (!(*fixflag == 1) && vedge[iobj - 1]->ipoint > 0 &&\n\t       !(nmb_inter > 1 && \n\t\t (sbelt1[1]-sbelt1[0])/(send[0]-sstart[0]) < belt_fac))\n\t   {\n\t      /* Search for intersection points on the edges in the\n\t\t first paramter direction, i.e. edge 1 and 3. Find the\n\t\t intersection point closest to the middle parameter value\n\t\t and distinguish between ordinary intersection points and\n\t\t singular or almost singular (touchy) points. */\n\n\t      /* Loop for edges no 1 and 3*/\n\t      for (kj = 0; kj < 3; kj += 2)\n\t\t /* Loop for all points on edge*/\n\t\t for (qptedg = vedge[iobj - 1]->prpt[kj]; qptedg != SISL_NULL;\n\t       qptedg = qptedg->pnext)\n\t\t {\n\t\t    pcurr = qptedg->ppt;\n\n\t\t    /* Test if the point is too close to an edge. */\n\n\t\t    if (pcurr->epar[kpar] < sstart[0]+tdel1 ||\n\t\t\tpcurr->epar[kpar] > send[0]-tdel1) \n\t\t      continue;\n\n\t\t    /* Check if the intersection point is too close to\n\t\t       another intersection point */\n\t\t    for (ki=0; ki<(*pintdat)->ipoint; ki++)\n\t\t      {\n\t\t    \tpcurr2 = (*pintdat)->vpoint[ki];\n\t\t    \tif (pcurr2 == pcurr)\n\t\t    \t  continue;\n\n\t\t    \tif (pcurr2->epar[kpar] < sstart[0] ||\n\t\t    \t    pcurr2->epar[kpar] > send[0] ||\n\t\t    \t    pcurr2->epar[kpar+1] < sstart[1] ||\n\t\t    \t    pcurr2->epar[kpar+1] > send[1])\n\t\t    \t  continue;\n\n\t\t    \tif (fabs(pcurr2->epar[kpar] - pcurr->epar[kpar]) <\n\t\t    \t    fac*(sbelt1[1]-sbelt1[0]))\n\t\t    \t  break;\n\t\t      }\n\t\t\t\n\t\t    if (ki < (*pintdat)->ipoint)\n\t\t      continue;  // Not a suitable subdivision point\n\t\t    \n\t\t    /* Check if the intersection curve passing through\n\t\t       the point is always parallel to an iso-curve. */\n\t\t    \n\t\t    if (sh1762_is_taboo(qo1->s1, \n\t\t\t\t\t(qo2->iobj == SISLSURFACE) ? \n\t\t\t\t\tqo2->s1 : SISL_NULL, \n\t\t\t\t\tpcurr, 1, &kstat))\n\t\t      continue;\n\n\t\t    if (kstat < 0)\n\t\t      goto error;\n\n\t\t    if (qo2->iobj == SISLSURFACE)\n\t\t      {\n\t\t\tif (sh1762_is_taboo2(qo1, qo2, pcurr, 1,\n\t\t\t\t\t     *pintdat, (iobj==1) ? 2 : 0))\n\t\t\t  continue;\n\t\t      }\n\n\t\t    if (pcurr->iinter == SI_SING)\n\t\t    {\n\t\t       /* Test if the singular/near singular point is the one\n\t\t\t  closest to the middle point.  */\n\n\t\t       if (!ptsing1 || fabs(pcurr->epar[kpar]-tmean[0]) <\n\t\t\t   fabs(ptsing1->epar[kpar]-tmean[0]))\n\t\t\t  ptsing1 = pcurr;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t       /* Test if the intersection point is the one closest\n\t\t\t  to the middle. */\n\n\t\t       if (!pt1 || fabs(pcurr->epar[kpar]-tmean[0]) <\n\t\t\t   fabs(pt1->epar[kpar]-tmean[0]))\n\t\t\t  pt1 = pcurr;\n\t\t    }\n\t\t }\n\t   }\n\n\t   if (!(*fixflag == 2) && vedge[iobj - 1]->ipoint > 0 &&\n\t       !(nmb_inter > 1 && \n\t\t (sbelt2[1]-sbelt2[0])/(send[1]-sstart[1]) < belt_fac))\n\t   {\n\t      /* Search for intersection points on the edges in the\n\t\t second paramter direction, i.e. edge 2 and 4. Find the\n\t\t intersection point closest to the middle parameter value\n\t\t and distinguish between ordinary intersection points and\n\t\t singular or almost singular (touchy) points. */\n\n\t      /* Loop for edges no 2 and 4*/\n\t      for (kj = 1; kj < 4; kj += 2)\n\t\t /* Loop for all points on edge*/\n\t\t for (qptedg = vedge[iobj - 1]->prpt[kj]; qptedg != SISL_NULL;\n\t       qptedg = qptedg->pnext)\n\t\t {\n\t\t    pcurr = qptedg->ppt;\n\n\t\t    /* Test if the point is too close to an edge. */\n\n\t\t    if (pcurr->epar[kpar+1] < sstart[1]+tdel2 ||\n\t\t\tpcurr->epar[kpar+1] > send[1]-tdel2) \n\t\t      continue;\n\n\t\t    /* Check if the intersection point is too close to\n\t\t       another intersection point */\n\t\t    for (ki=0; ki<(*pintdat)->ipoint; ki++)\n\t\t      {\n\t\t    \tpcurr2 = (*pintdat)->vpoint[ki];\n\t\t    \tif (pcurr2 == pcurr)\n\t\t    \t  continue;\n\n\t\t    \tif (pcurr2->epar[kpar] < sstart[0] ||\n\t\t    \t    pcurr2->epar[kpar] > send[0] ||\n\t\t    \t    pcurr2->epar[kpar+1] < sstart[1] ||\n\t\t    \t    pcurr2->epar[kpar+1] > send[1])\n\t\t    \t  continue;\n\n\t\t    \tif (fabs(pcurr2->epar[kpar+1] - pcurr->epar[kpar+1]) <\n\t\t    \t    fac*(sbelt2[1]-sbelt2[0]))\n\t\t    \t  break;\n\t\t      }\n\t\t\t\n\t\t    if (ki < (*pintdat)->ipoint)\n\t\t      continue;  // Not a suitable subdivision point\n\t\t    \n\t\t    /* Check if the intersection curve passing through\n\t\t       the point is always parallel to an iso-curve. */\n\t\t    if (sh1762_is_taboo(qo1->s1,  \n\t\t\t\t\t(qo2->iobj == SISLSURFACE) ? \n\t\t\t\t\tqo2->s1 : SISL_NULL, \n\t\t\t\t\tpcurr, 2, &kstat))\n\t\t      continue;\n\n\t\t    if (kstat < 0)\n\t\t      goto error;\n\n\t\t    if (qo2->iobj == SISLSURFACE)\n\t\t      {\n\t\t\tif (sh1762_is_taboo2(qo1, qo2, pcurr, 2,\n\t\t\t\t\t     *pintdat, (iobj==1) ? 2 : 0))\n\t\t\t  continue;\n\t\t      }\n\n\t\t    /* Check if the intersection point is too close to \n\t\t       another intersection point */\n\t\t    \n\t\t    if (pcurr->iinter == SI_SING)\n\t\t    {\n\t\t       /* Test if the singular/near singular point is the one\n\t\t\t  closest to the middle point.  */\n\n\t\t       if (!ptsing2 || fabs(pcurr->epar[kpar+1]-tmean[1]) <\n\t\t\t   fabs(ptsing2->epar[kpar+1]-tmean[1]))\n\t\t\t  ptsing2 = pcurr;\n\t\t    }\n\t\t    else\n\t\t    {\n\t\t       /* Test if the intersection point is the one closest\n\t\t\t  to the middle. */\n\n\t\t       if (!pt2 || fabs(pcurr->epar[kpar+1]-tmean[1]) <\n\t\t\t   fabs(pt2->epar[kpar+1]-tmean[1]))\n\t\t\t  pt2 = pcurr;\n\t\t    }\n\t\t }\n\t   }\n\n\t   if (qo1->s1->idim == 1)\n\t   {\n\t      /* One-dimensional case. Iterate to find an extremal point. */\n\n\t      if (!(*fixflag == 1) && ptsing1)\n\t      {\n\t\t /* Set startpoint to iteration. */\n\n\t\t spar[0] = ptsing1->epar[kpar];\n\t\t spar[1] = ptsing1->epar[kpar+1];\n\t      }\n\t      else if (!(*fixflag == 2) && ptsing2)\n\t      {\n\t\t spar[0] = ptsing2->epar[kpar];\n\t\t spar[1] = ptsing2->epar[kpar+1];\n\t      }\n\t      else\n\t      {\n\t\t /* No (almost) singular intersection point is found\n\t\t    at the edge. */\n\n\t\t spar[0] = (double)0.5*(sstart[0] + send[0]);\n\t\t spar[1] = (double)0.5*(sstart[1] + send[1]);\n\t      }\n\n\t      /* Perform iteration. */\n\n\t      kfound = 0;\n\t      s1174 (qo1->o1->s1, sstart, send, spar, spar, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t      if (kstat == 1)\n\t\t{\n\t\t   /* An extremal point is found. Test if it is too close\n\t\t      to an edge. */\n\n\t\t   kfound = 3;\n\t\t   if (spar[0] < sstart[0]+tdel1 || spar[0] > send[0]-tdel1)\n\t\t      kfound--;\n\t\t   if (spar[1] < sstart[1]+tdel2 || spar[1] > send[1]-tdel2)\n\t\t      kfound -= 2;\n\t\t}\n\n\t      if (*fixflag == 0 && ptsing2 && ptsing1)\n\t      {\n\t\t /* Try a second iteration for an extremal point\n\t\t    in order to find a subdivision parameter in the\n\t\t    second parameter direction.  */\n\n\t\t spar2[0] = ptsing2->epar[kpar];\n\t\t spar2[1] = ptsing2->epar[kpar+1];\n\n\t\t s1174(qo1->o1->s1, sstart, send, spar2, spar2, &kstat);\n\t\t if (kstat < 0)\n\t\t    goto error;\n\t\t if (kstat == 1)\n\t\t {\n\t\t    /* An extremal point is found. Test it against the edges. */\n\n\t\t    if (!(spar2[1] < sstart[1]+tdel2 || spar2[1] > send[1]-tdel2))\n\t\t    {\n\t\t       spar[1] = spar2[1];\n\t\t       if (kfound < 2) kfound += 2;\n\t\t    }\n\t\t }\n\t      }\n\n\t      /* Set intermediate subdivision point. */\n\n\t      if (*fixflag == 1)\n\t\t spar[0] = sparsave[0];\n\t      else if (kfound == 1 || kfound == 3)\n\t\t (*fixflag)++;\n\t      else if (ptsing1)\n\t      {\n\t\t spar[0] = ptsing1->epar[kpar];\n\t\t (*fixflag)++;\n\t      }\n\t      else if (pt1)\n\t      {\n\t\t spar[0] = pt1->epar[kpar];\n\t\t (*fixflag)++;\n\t      }\n\t      else if (kf1 == 0)\n\t\t spar[0] = tmean[0];\n\n\t      if (*fixflag == 2)\n\t\t spar[1] = sparsave[1];\n\t      else if (kfound == 2 || kfound == 3)\n\t\t (*fixflag) += 2;\n\t      else if (ptsing2)\n\t      {\n\t\t spar[1] = ptsing2->epar[kpar+1];\n\t\t (*fixflag) += 2;\n\t      }\n\t      else if (pt2)\n\t      {\n\t\t spar[1] = pt2->epar[kpar+1];\n\t\t (*fixflag) += 2;\n\t      }\n\t      else if (kf2 == 0)\n\t\t spar[1] = tmean[1];\n\t   }\n\t   else\n\t   {\n\t      /* Surface-surface intersection. Set intermediate\n\t\t subdivision point. */\n\n\t      if (*fixflag == 1)\n\t\t spar[0] = sparsave[0];\n\t      else if (ptsing1 && pt1)\n\t      {\n\t\t if (fabs(ptsing1->epar[kpar]-tmean[0]) <=\n\t\t     fabs(pt1->epar[kpar]-tmean[0]))\n\t\t    spar[0] = ptsing1->epar[kpar];\n\t\t else\n\t\t    spar[0] = pt1->epar[kpar];\n\t\t (*fixflag)++;\n\t      }\n\t      else if (ptsing1)\n\t      {\n\t\t spar[0] = ptsing1->epar[kpar];\n\t\t (*fixflag)++;\n\t      }\n\t      else if (pt1)\n\t      {\n\t\t spar[0] = pt1->epar[kpar];\n\t\t (*fixflag)++;\n\t      }\n\t      else spar[0] = tmean[0];\n\n\t      if (*fixflag == 2)\n\t\t spar[1] = sparsave[1];\n\t      else if (ptsing2 && pt2)\n\t      {\n\t\t if (fabs(ptsing2->epar[kpar+1]-tmean[1]) <=\n\t\t     fabs(pt2->epar[kpar+1]-tmean[1]))\n\t\t    spar[1] = ptsing2->epar[kpar+1];\n\t\t else\n\t\t    spar[1] = pt2->epar[kpar+1];\n\t\t (*fixflag) += 2;\n\t      }\n\t      else if (ptsing2)\n\t      {\n\t\t spar[1] = ptsing2->epar[kpar+1];\n\t\t (*fixflag) += 2;\n\t      }\n\t      else if (pt2)\n\t      {\n\t\t spar[1] = pt2->epar[kpar+1];\n\t\t (*fixflag) += 2;\n\t      }\n\t      else spar[1] = tmean[1];\n\n\t   }\n\t}\n     }\n\n     if (qo1->iobj == SISLSURFACE)\n       {\n\tdouble tpar1=HUGE, tpar2=HUGE;  /* Used for comparisement with\n\t\t\t\t\t   intersection point.             */\n\tint ktype1=-10, ktype2=-10;     /* As previous.                    */\n\n\t/* Test if the found subdivision value lies very close to an\n\t   existing intersection point. In that case move the subdivision\n\t   point to the intersection point. The two parameter directions\n\t   are treated separately.  */\n\n\tif ((*pintdat) && (*pintdat)->ipoint > 0)\n\t   for (kj=0; kj<(*pintdat)->ipoint; kj++)\n\t   {\n\t      pcurr = (*pintdat)->vpoint[kj];\n\t      if (!(nmb_inter > 1 && \n\t\t    (sbelt1[1]-sbelt1[0])/(send[0]-sstart[0]) < belt_fac))\n\t\t{\n\t\t  if ((*fixflag)==1 || (*fixflag)==3)\n\t\t    {\n\t\t      if (fabs(spar[0]-pcurr->epar[kpar]) < (double)0.001*tdel1 )\n\t\t\t{\n\t\t\t  if (fabs(spar[0]-pcurr->epar[kpar]) < fabs(tpar1-spar[0]) &&\n\t\t\t      ktype1 <= pcurr->iinter)\n\t\t\t    {\n\t\t\t      tpar1 = pcurr->epar[kpar];\n\t\t\t      ktype1 = pcurr->iinter;\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t  else\n\t\t    {\n\t\t      if (fabs(spar[0]-pcurr->epar[kpar]) < (double)0.1*tdel1 &&\n\t\t\t  pcurr->epar[kpar] >= sstart[0]+tdel1 &&\n\t\t\t  pcurr->epar[kpar] <= send[0]-tdel1 )\n\t\t\t{\n\t\t\t  if (fabs(spar[0]-pcurr->epar[kpar]) < fabs(tpar1-spar[0]) &&\n\t\t\t      ktype1 <= pcurr->iinter)\n\t\t\t    {\n\t\t\t      tpar1 = pcurr->epar[kpar];\n\t\t\t      ktype1 = pcurr->iinter;\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t}\n\t      else if (sbelt1[0]-0.1*tdel1 < spar[0] && \n\t\t       sbelt1[1]+0.1*tdel1 > spar[0])\n\t\t{\n\t\t  if (sbelt1[0] - sstart[0] > send[0] - sbelt1[1])\n\t\t    {\n\t\t      spar[0] = max(0.5*(sstart[0]+sbelt1[0]),\n\t\t\t\t    sbelt1[0] - tdel1);\n\t\t    }\n\t\t  else\n\t\t    {\n\t\t      spar[0] = min(0.5*(send[0]+sbelt1[1]),\n\t\t\t\t    sbelt1[1] + tdel1);\n\t\t    }\n\t\t}\n\n\t      if (!(nmb_inter > 1 && \n\t\t    (sbelt2[1]-sbelt2[0])/(send[1]-sstart[1]) < belt_fac))\n\t\t{\n\t\t  if ((*fixflag)==2 || (*fixflag)==3)\n\t\t    {\n\t\t      if (fabs(spar[1]-pcurr->epar[kpar+1]) < (double)0.001*tdel2 )\n\t\t\t{\n\t\t\t  if (fabs(spar[1]-pcurr->epar[kpar+1]) < fabs(tpar2-spar[1]) &&\n\t\t\t      ktype2 <= pcurr->iinter)\n\t\t\t    {\n\t\t\t      tpar2 = pcurr->epar[kpar+1];\n\t\t\t      ktype2 = pcurr->iinter;\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t  else\n\t\t    {\n\t\t      if (fabs(spar[1]-pcurr->epar[kpar+1]) < (double)0.1*tdel2 &&\n\t\t\t  pcurr->epar[kpar+1] >= sstart[1]+tdel2 &&\n\t\t\t  pcurr->epar[kpar+1] <= send[1]-tdel2 )\n\t\t\t{\n\t\t\t  if (fabs(spar[1]-pcurr->epar[kpar+1]) < fabs(tpar2-spar[1]) &&\n\t\t\t      ktype2 <= pcurr->iinter)\n\t\t\t    {\n\t\t\t      tpar2 = pcurr->epar[kpar+1];\n\t\t\t      ktype2 = pcurr->iinter;\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t}\n\t      else if (sbelt2[0]-0.1*tdel2 < spar[1] &&\n\t\t       sbelt2[1]+0.1*tdel2 > spar[1])\n\t\t{\n\t\t  if (sbelt2[0] - sstart[1] > send[1] - sbelt2[1])\n\t\t    {\n\t\t      spar[1] = max(0.5*(sstart[1]+sbelt2[0]),\n\t\t\t\t    sbelt2[0] - tdel2);\n\t\t    }\n\t\t  else\n\t\t    {\n\t\t      spar[1] = min(0.5*(send[1]+sbelt2[1]),\n\t\t\t\t    sbelt2[1] + tdel2);\n\t\t    }\n\t\t}\n\t   }\n\n\tif (ktype1 > -10 && tpar1 > sstart[0]+tdel1 \n\t    && tpar1 < send[0]-tdel1)\n\t{\n\t   if (!((*fixflag == 1 || *fixflag == 3) && ktype1 < 0))\n\t      spar[0] = tpar1;\n\t}\n\tif (ktype2 > -10 && tpar2 > sstart[1]+tdel2 && \n\t    tpar2 < send[1]-tdel2)\n\t{\n\t   if (!((*fixflag == 2 || *fixflag == 3) && ktype2 < 0))\n\t      spar[1] = tpar2;\n\t}\n       }\n\n     if (qo2->iobj == SISLSURFACE && *fixflag != 3 && qpt == NULL)\n       {\n\t double limit[8];\n\t double singpar[4];\n\t double guess[4];\n\t \n\t /* Search for a singularity */\n\t limit[0] = sstart[0];\n\t limit[1] = send[0];\n\t limit[2] = sstart[1];\n\t limit[3] = send[1];\n\t limit[4] = qo2->s1->et1[qo2->s1->ik1-1];\n\t limit[5] = qo2->s1->et1[qo2->s1->in1];\n\t limit[6] = qo2->s1->et2[qo2->s1->ik2-1];\n\t limit[7] = qo2->s1->et2[qo2->s1->in2];\n\n\t guess[0] = spar[0];\n\t guess[1] = spar[1];\n\t guess[2] = 0.5*(limit[4] + limit[5]);\n\t guess[3] = 0.5*(limit[6] + limit[7]);\n\n\t shsing(qo1->s1, qo2->s1, limit, guess, singpar, &kstat);\n\t if (kstat < 0)\n\t   goto error;\n\t if (kstat == 1)\n\t   {\n\t     /* An extremum is found. Check for validity */\n\t     if (*fixflag != 1 && singpar[0] >= sstart[0]+tdel1 &&\n\t\t singpar[0] <= send[0]-tdel1)\n\t       {\n\t\t /* Avoid dividing close to an existing intersection point */\n\t\t for (kj=0; kj<npt; kj++)\n\t\t   {\n\t\t     pcurr = (*pintdat)->vpoint[kj];\n\t\t     if (sh6ishelp(pcurr))\n\t\t       continue;\n\t\t     sh6isinside(po1, po2, pcurr, &kstat);\n\t\t     if (kstat < 0)\n\t\t       goto error;\n\t\t     if (kstat == 0)\n\t\t       continue;  /* Outside of current sub intersection */\n\t\t     if (fabs(singpar[0]-pcurr->epar[kpar]) < tdel2 &&\n\t\t\t DNEQUAL(singpar[0], pcurr->epar[kpar]))\n\t\t       break;\n\t\t   }\n\t\t if (kj == npt)\n\t\t   {\n\t\t     *fixflag += 1;\n\t\t     spar[0] = singpar[0];\n\t\t   }\n\t       }\n\t     if (*fixflag != 2 && *fixflag != 3 &&\n\t\t singpar[1] >= sstart[1]+tdel2 &&\n\t\t singpar[1] <= send[1]-tdel2)\n\t       {\n\t\t /* Avoid dividing close to an existing intersection point */\n\t\t for (kj=0; kj<npt; kj++)\n\t\t   {\n\t\t     pcurr = (*pintdat)->vpoint[kj];\n\t\t     if (sh6ishelp(pcurr))\n\t\t       continue;\n\t\t     sh6isinside(po1, po2, pcurr, &kstat);\n\t\t     if (kstat < 0)\n\t\t       goto error;\n\t\t     if (kstat == 0)\n\t\t       continue;  /* Outside of current sub intersection */\n\t\t     if (fabs(singpar[1]-pcurr->epar[kpar+1]) < tdel2 &&\n\t\t\t DNEQUAL(singpar[1], pcurr->epar[kpar+1]))\n\t\t       break;\n\t\t   }\n\t\t if (kj == npt)\n\t\t   {\n\t\t     *fixflag += 2;\n\t\t     spar[1] = singpar[1];\n\t\t   }\n\t       }\n\t   }\n       }\n     \n      /* Set output variables.  */\n\n     epar[0] = spar[0];\n     epar[1] = spar[1];\n     *rpt = qpt;\n     *fixflag = ((*fixflag) >=2) ? 1 : 0;\n  }\n  else goto err122;  /* Unexpected kind of object. */\n\n  goto out;\n\n/* Error. Unexpected kind of object.  */\n\nerr122:*jstat = -122;\n  s6err (\"sh1762_s9subdivpt\", *jstat, kpos);\n  goto out;\n\n/* Error in lower level routine.  */\n\nerror:*jstat = kstat;\n  s6err (\"sh1762_s9subdivpt\", *jstat, kpos);\n  goto out;\n\nout:\n   return subdiv_flag;\n\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1762_s9div (SISLObject * po1, SISLObject * po2, double aepsge,\n\t      int iobj, int idiv, SISLObject * wob[], SISLEdge * vedge[],\n\t      SISLIntdat ** pintdat, int *jstat)\n\n#else\nstatic void\nsh1762_s9div (po1, po2, aepsge, iobj, idiv, wob, vedge, pintdat, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     int iobj;\n     int idiv;\n     SISLObject *wob[];\n     SISLEdge *vedge[];\n     SISLIntdat **pintdat;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Uppdating intersection data if possible.\n*\n*\n*\n* INPUT      : po1      - First object in intersection.\n*              po2      - Second object in intersection.\n*              aepsge   - Geometry resolution.\n*              iobj     - Number of object to divide.\n*              idiv     - Subdivision direction.\n*                          = 0     : No subdivision.\n*\t\t           = 1     : Subdivision in first parameter\n*                                                          direction.\n*\t\t           = 2     : Subdivision in second parameter\n*                                                          direction.\n*\t\t           = 3     : Subdivision in first and second\n*                                                parameter direction.\n*              vedge[]  - Intersection on edges.\n*\n*\n* OUTPUT     : pintdat  - Intersection data.\n*              wob[]    - Pointers to the subdivided objects.\n*              jstat    - Status messages\n*                          = 1     : Intersection found\n*                          = 0     : no intersection found.\n*                          < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-04.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;\t\t\t/* Position of error.      */\n  int kstat = 0;\t\t/* Local status variable.           */\n  int ki, kn, kj;\t\t/* Counters.                        */\n  int kpar;\t\t\t/* First parameter direction corresponding the the object\n\t\t\t           that is to be subdivided.        */\n  double tpar;\n  int knum;\t\t\t/* Total number of points in the data structures of the\n\t\t\t           original problem, and the problem of reduced dimension. */\n  double tdel;\t\t\t/* Parameter used to measure closeness between an\n\t\t\t           intersection point and the subdivision point.    */\n  double spar[2];\t\t/* Parameter values of subdividing point. If a curve is to\n\t\t\t           be subdivided, only the first element is used.           */\n  SISLCurve *qcrv = SISL_NULL;       /* Mother curve of subdivision curve.               */\n  SISLObject *qso = SISL_NULL;\t/* Subdivision object, it is a point if a curve is subdivided\n\t\t\t           and a curve if a surface is subdivided.          */\n  SISLObject *qmotherobj = SISL_NULL; /* Mother object of subdivision object.            */\n  SISLObject *qo1 = SISL_NULL;\t/* Pointer to the object that is to be subdivided.  */\n  SISLObject *qo2 = SISL_NULL;\t/* Pointer to the other object.                     */\n  SISLObject *qs1 = SISL_NULL, *qs2 = SISL_NULL;\t/* Subobjects to be used in the case where a surface\n\t\t\t\t       is to be subdivided in both parameter direction to\n\t\t\t\t       store intermediate subsurfaces.               */\n  SISLIntpt *qpt = SISL_NULL;\t/* An eventual found inner intersection used as subdivision\n\t\t\t           point. If the subdivision point is found in another way,\n\t\t\t           qpt = SISL_NULL.                                      */\n  SISLIntdat *qintdat = SISL_NULL;\t/* Data structure of intersection problem with lower dim. */\n  SISLIntpt *qp;\t\t/* Closest intersection point to the subdiv point */\n  SISLEdge *uedge[2];\t\t/* Edge intersections of subproblem.                 */\n  int fixflag = 0;\t\t/* UJK 31.10.90 */\n  int idummy;\n  int subdiv_flag;\n  double sstart[4], send[4];\n\n  /* Fetch subdivision point of object.  */\n\n  subdiv_flag = sh1762_s9subdivpt (po1, po2, aepsge, iobj, idiv, vedge, \n\t\t\t\t  pintdat, &fixflag, &qpt, spar, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  qo1 = (iobj == 1 ? po1 : po2);\n  qo2 = (iobj == 1 ? po2 : po1);\n  kpar = (iobj == 1 ? 0 : po1->iobj);\n\n  *jstat = 0;\n\n  kj = 0;\n  if (po1->iobj == SISLCURVE)\n    {\n      sstart[kj] = po1->c1->et[po1->c1->ik-1];\n      send[kj++] = po1->c1->et[po1->c1->in];\n    }\n  else if (po1->iobj == SISLSURFACE)\n    {\n      sstart[kj] = po1->s1->et1[po1->s1->ik1-1];\n      send[kj++] = po1->s1->et1[po1->s1->in1];\n      sstart[kj] = po1->s1->et2[po1->s1->ik2-1];\n      send[kj++] = po1->s1->et2[po1->s1->in2];\n    }\n  if (po2->iobj == SISLCURVE)\n    {\n      sstart[kj] = po2->c1->et[po2->c1->ik-1];\n      send[kj++] = po2->c1->et[po2->c1->in];\n    }\n  else if (po2->iobj == SISLSURFACE)\n    {\n      sstart[kj] = po2->s1->et1[po2->s1->ik1-1];\n      send[kj++] = po2->s1->et1[po2->s1->in1];\n      sstart[kj] = po2->s1->et2[po2->s1->ik2-1];\n      send[kj++] = po2->s1->et2[po2->s1->in2];\n    }\n  \n  if (qo1->iobj == SISLCURVE)\n    {\n      /* Subdivide the curve at the found subdivision parameter value.  */\n\n      /* printf(\"Subdivide curve. Parameter value = %10.6f \\n\",spar[0]); */\n\n      s1231 (qo1->c1, spar[0], &(wob[0]->c1), &(wob[1]->c1), &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n\n      if (wob[0]->edg[1] == SISL_NULL)\n\t{\n\t  if ((qso = wob[0]->edg[1] = newObject (SISLPOINT)) == SISL_NULL)\n\t    goto err101;\n\n\t  /* Pick out end point from a curve. */\n\n\t  s1438 (wob[0]->c1, 1, &(qso->p1), &spar[0], &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n      else\n\tqso = wob[0]->edg[1];\n\n      if (po1->iobj + po2->iobj > SISLCURVE)\n\t{\n\t  /***** Treating edges on sub problems. *****/\n\n\t  /* We first have to transform intersection points to the the new\n\t     intersection format qintdat. */\n\n\t  /* UJK, newi */\n\t  sh6idget (po1, po2, kpar, spar[0], *pintdat, &qintdat, aepsge, &kstat);\n\n\n\t  /* Making new edge object to sub problems. */\n\n\t  if ((iobj == 1 ? qso : po1)->iobj == SISLPOINT)\n\t    uedge[0] = SISL_NULL;\n\t  else if ((uedge[0] = newEdge (vedge[0]->iedge - (iobj == 1 ? 2 : 0))) == SISL_NULL)\n\t    goto err101;\n\t  if ((iobj == 2 ? qso : po2)->iobj == SISLPOINT)\n\t    uedge[1] = SISL_NULL;\n\t  else if ((uedge[1] = newEdge (vedge[1]->iedge - (iobj == 2 ? 2 : 0))) == SISL_NULL)\n\t    goto err101;\n\n\t  /* Update edge intersection on sub problems. */\n\n\t  sh6idalledg ((iobj == 1 ? qso : po1), (iobj == 1 ? po2 : qso), qintdat, uedge, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  /* Examine if the subdividing point intersect the second object. */\n\n\t  qso->o1 = qso;\n\n\t  sh1762 ((iobj == 1 ? qso : po1), (iobj == 1 ? po2 : qso), aepsge,\n\t\t  &qintdat, uedge, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  if (uedge[0] != SISL_NULL)\n\t    freeEdge (uedge[0]);\n\t  if (uedge[1] != SISL_NULL)\n\t    freeEdge (uedge[1]);\n\t}\n      else\n\t{\n\t  sh1761 ((iobj == 1 ? qso : po1), (iobj == 1 ? po2 : qso), aepsge,\n\t\t  &qintdat, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n\n      if (kstat)\n\t{\n\t  /* Total number of points. */\n\n\t  knum = (*pintdat == SISL_NULL ? 0 : (*pintdat)->ipoint) + qintdat->ipoint;\n\n\t  *jstat = 1;\t\t/* Mark intersection found. */\n\n\t  /* Intersection found and we have to register the intersection\n\t     points. */\n\n\t  /* UJK newi */\n\t  sh1782 (po1, po2, aepsge, qintdat, kpar, spar[0], pintdat, &idummy, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  /* UJK newi divide curve */\n\t  /* UPDATE: ? what about help points from s1782 knum?? */\n\t  if (qpt != SISL_NULL && (*pintdat)->ipoint == knum)\n\t    {\n\t      /* Find the closest poin to qpt. */\n\n\t      s6idcpt (*pintdat, qpt, &qp);\n\n\t      /* UJK newi, unite the points : */\n\t      sh6idnewunite (po1, po2, pintdat, &qpt, &qp, (double) 0.5,\n\t\t\t     aepsge, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t    }\n\t}\n\n      if (qintdat != SISL_NULL)\n\t{\n\t  freeIntdat (qintdat);\n\t  qintdat = SISL_NULL;\n\t}\n    }\n  else if (qo1->iobj == SISLSURFACE)\n    {\n\n      /* Subdivide surface and treat subdivision curves.  */\n\n      for (ki = 0; ki < (idiv < 3 ? 1 : 3); ki++)\n\t{\n\t  if (idiv == 1)\n\t    {\n\t      /* printf(\"Subdivide surface. 1. par dir. par = %10.6f \\n\",spar[0]); */\n\n\t      s1711 (qo1->s1, 1, spar[0], &(wob[0]->s1), &(wob[1]->s1), &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      /* Check if any surface is flagged due to the applied\n\t\t subdivision strategy  */\n\t      if (subdiv_flag == TANGENTIAL_BELT_LEFT)\n\t\twob[0]->s1->sf_type =  TANGENTIAL_BELT;\n\t      else if (subdiv_flag == TANGENTIAL_BELT_RIGHT)\n\t\twob[1]->s1->sf_type =  TANGENTIAL_BELT;\n\n\t      if (wob[0]->edg[1] == SISL_NULL)\n\t\t{\n\t\t  if ((qso = wob[0]->edg[1] = newObject (SISLCURVE)) == SISL_NULL)\n\t\t    goto err101;\n\n\t\t  /* Pick out edge curve from a surface. */\n\n\t\t  s1435 (wob[0]->s1, 1, &(qso->c1), spar, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t}\n\t      else\n\t\tqso = wob[0]->edg[1];\n\n\t      /* Pick curve from mother object of surface, and make\n\t\t motherobject of curve.                             */\n\n\t      s1437(qo1->o1->s1,spar[0],&qcrv,&kstat);\n\t      if (kstat < 0) goto error;\n\n\t      if ((qmotherobj = newObject(SISLCURVE)) == SISL_NULL) goto err101;\n\t      qmotherobj->c1 = qcrv;\n\t      qso->o1 = qmotherobj;\n\t    }\n\t  else if (idiv == 2)\n\t    {\n\t      /* printf(\"Subdivide surface. 2. par dir. par = %10.6f \\n\",spar[1]); */\n\n\t      s1711 (qo1->s1, 2, spar[1], &(wob[0]->s1), &(wob[1]->s1), &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      /* Check if any surface is flagged due to the applied\n\t\t subdivision strategy  */\n\t      if (subdiv_flag == TANGENTIAL_BELT_LEFT)\n\t\twob[0]->s1->sf_type =  TANGENTIAL_BELT;\n\t      else if (subdiv_flag == TANGENTIAL_BELT_RIGHT)\n\t\twob[1]->s1->sf_type =  TANGENTIAL_BELT;\n\n\t      if (wob[0]->edg[2] == SISL_NULL)\n\t\t{\n\t\t  if ((qso = wob[0]->edg[2] = newObject (SISLCURVE)) == SISL_NULL)\n\t\t    goto err101;\n\n\t\t  /* Pick out edge curve from a surface. */\n\n\t\t  s1435 (wob[0]->s1, 2, &(qso->c1), spar + 1, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t}\n\t      else\n\t\tqso = wob[0]->edg[2];\n\n\t      /* Pick curve from mother object of surface, and make\n\t\t motherobject of curve.                             */\n\n\t      s1436(qo1->o1->s1,spar[1],&qcrv,&kstat);\n\t      if (kstat < 0) goto error;\n\n\t      if ((qmotherobj = newObject(SISLCURVE)) == SISL_NULL) goto err101;\n\t      qmotherobj->c1 = qcrv;\n\t      qso->o1 = qmotherobj;\n\t    }\n\t  else if (ki == 0)\n\t    {\n\t      if ((qs1 = newObject (SISLSURFACE)) == SISL_NULL)\n\t\tgoto err101;\n\t      if ((qs2 = newObject (SISLSURFACE)) == SISL_NULL)\n\t\tgoto err101;\n\n\t      /* printf(\"Subdivide surface. 1. par dir. par = %10.6f \\n\",spar[0]); */\n\n\t      s1711 (qo1->s1, 1, spar[0], &(qs1->s1), &(qs2->s1), &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      if (qs1->edg[1] == SISL_NULL)\n\t\t{\n\t\t  if ((qso = qs1->edg[1] = newObject (SISLCURVE)) == SISL_NULL)\n\t\t    goto err101;\n\n\t\t  /* Pick out edge curve from a surface. */\n\n\t\t  s1435 (qs1->s1, 1, &(qso->c1), spar, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t}\n\t      else\n\t\tqso = qs1->edg[1];\n\n\t      /* Pick curve from mother object of surface, and make\n\t\t motherobject of curve.                             */\n\n\t      s1437(qo1->o1->s1,spar[0],&qcrv,&kstat);\n\t      if (kstat < 0) goto error;\n\n\t      if ((qmotherobj = newObject(SISLCURVE)) == SISL_NULL) goto err101;\n\t      qmotherobj->c1 = qcrv;\n\t      qso->o1 = qmotherobj;\n\t    }\n\t  else if (ki == 1)\n\t    {\n\t      /* printf(\"Subdivide surface. 2. par dir. par = %10.6f \\n\",spar[1]); */\n\n\t      s1711 (qs1->s1, 2, spar[1], &(wob[0]->s1), &(wob[1]->s1), &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      /* Check if any surface is flagged due to the applied\n\t\t subdivision strategy  */\n\t      if (subdiv_flag == ISOLATED_SING_LEFT_LEFT)\n\t\twob[0]->s1->sf_type =  SINGULARITY_BOUND;\n\t      else if (subdiv_flag == ISOLATED_SING_LEFT_RIGHT)\n\t\twob[1]->s1->sf_type =  SINGULARITY_BOUND;\n\t\t\n\t      if (wob[0]->edg[2] == SISL_NULL)\n\t\t{\n\t\t  if ((qso = wob[0]->edg[2] = newObject (SISLCURVE)) == SISL_NULL)\n\t\t    goto err101;\n\n\t\t  /* Pick out edge curve from a surface. */\n\n\t\t  s1435 (wob[0]->s1, 2, &(qso->c1), spar + 1, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t}\n\t      else\n\t\tqso = wob[0]->edg[2];\n\n\t      /* Pick curve from mother object of surface, and make\n\t\t motherobject of curve.                             */\n\n\t      s1436(qo1->o1->s1,spar[1],&qcrv,&kstat);\n\t      if (kstat < 0) goto error;\n\n\t      if ((qmotherobj = newObject(SISLCURVE)) == SISL_NULL) goto err101;\n\t      qmotherobj->c1 = qcrv;\n\t      qso->o1 = qmotherobj;\n\t    }\n\t  else\n\t    /* if (ki == 2) */\n\t    {\n\t      /* printf(\"Subdivide surface. 2. par dir. par = %10.6f \\n\",spar[1]); */\n\n\t      s1711 (qs2->s1, 2, spar[1], &(wob[2]->s1), &(wob[3]->s1), &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      /* Check if any surface is flagged due to the applied\n\t\t subdivision strategy  */\n\t      if (subdiv_flag == ISOLATED_SING_RIGHT_LEFT)\n\t\twob[2]->s1->sf_type =  SINGULARITY_BOUND;\n\t      else if (subdiv_flag == ISOLATED_SING_RIGHT_RIGHT)\n\t\twob[3]->s1->sf_type =  SINGULARITY_BOUND;\n\t\t\n\t      if (wob[2]->edg[2] == SISL_NULL)\n\t\t{\n\t\t  if ((qso = wob[2]->edg[2] = newObject (SISLCURVE)) == SISL_NULL)\n\t\t    goto err101;\n\n\t\t  /* Pick out edge curve from a surface. */\n\n\t\t  s1435 (wob[2]->s1, 2, &(qso->c1), spar + 1, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t}\n\t      else\n\t\tqso = wob[2]->edg[2];\n\n\t      /* Pick curve from mother object of surface, and make\n\t\t motherobject of curve.                             */\n\n\t      s1436(qo1->o1->s1,spar[1],&qcrv,&kstat);\n\t      if (kstat < 0) goto error;\n\n\t      if ((qmotherobj = newObject(SISLCURVE)) == SISL_NULL) goto err101;\n\t      qmotherobj->c1 = qcrv;\n\t      qso->o1 = qmotherobj;\n\t    }\n\n\t  /***** Treating edges on sub problems. *****/\n\n\t  /* We first have to transform intersection points to the the new\n\t     intersection format qintdat. */\n\n\t  /* UJK, newi */\n\t  sh6idget ((iobj == 1 ? (ki == 0 ? po1 : (ki == 1 ? qs1 : qs2)) : po1),\n\t\t(iobj == 2 ? (ki == 0 ? po2 : (ki == 1 ? qs1 : qs2)) : po2),\n\t\t(ki == 0   ? (idiv == 2 ? 1 : 0) : 1) + kpar,\n\t\t(ki == 0   ? (idiv == 2 ? spar[1] : spar[0]) : spar[1]),\n\t\t    *pintdat, &qintdat, aepsge, &kstat);\n\n\t  /* Making new edge object to sub problems. */\n\n\t  if ((iobj == 1 ? qso : po1)->iobj == SISLPOINT)\n\t    uedge[0] = SISL_NULL;\n\t  else if ((uedge[0] = newEdge (vedge[0]->iedge - (iobj == 1 ? 2 : 0))) == SISL_NULL)\n\t    goto err101;\n\t  if ((iobj == 2 ? qso : po2)->iobj == SISLPOINT)\n\t    uedge[1] = SISL_NULL;\n\t  else if ((uedge[1] = newEdge (vedge[1]->iedge - (iobj == 2 ? 2 : 0))) == SISL_NULL)\n\t    goto err101;\n\n\t  /* Update edge intersection on sub problems. */\n\n\t  sh6idalledg ((iobj == 1 ? qso : po1), (iobj == 1 ? po2 : qso), qintdat, uedge, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  /* START of update, UJK,jan.93.__________________________ */\n\t  /* UJK, jan 1993, 1D: test if end pt of curve is intersection pt\n\t     and not registred on edge.\n\t     This will very seldom ocurr, boarder line case. */\n\t  if (qso->c1->idim == 1)\n\t  {\n\t     int changes = FALSE;\n\t     int loop;\n\t     double endpar;\n\t     double qt_par[2];\n\t     SISLPoint  *end_point=SISL_NULL;\n\t     SISLObject *pt_obj=SISL_NULL;\n\t     SISLCurve  *pcrv=SISL_NULL;\n\t     int knum;\n\t     int ind_missing, ind_kept;\n\t     SISLIntpt *qt  = SISL_NULL;\n\t     SISLIntpt *pcl = SISL_NULL;\n\t     SISLIntpt **up = SISL_NULL;\t /* Array of poiners to intersection point. */\n\n\t     /* Get edge points to SUB-problem. */\n\t     sh6edgpoint (uedge, &up, &knum, &kstat);\n\t     if (kstat < 0)\n\t\tgoto error;\n\n\t     /* Set up case navigators. */\n\t     pcrv   = qso->c1;\n\t     pt_obj = (iobj == 1 ? po2 :po1);\n\t     ind_missing = (ki == 0 ? (idiv == 2 ? 1 : 0) : 1);\n\t     ind_kept    = (ki == 0 ? (idiv == 2 ? 0 : 1) : 0);\n\n\t     if (knum < 2)\n\t\tfor (loop = 0; loop < 2; loop++)\n\t\t{\n\n\t\t   /* Pick out end point from a curve. */\n\t\t   s1438 (pcrv, loop, &end_point, &endpar, &kstat);\n\t\t   if (kstat < 0)\n\t\t      goto error;\n\t\t   if (fabs(end_point->ecoef[0] - pt_obj->p1->ecoef[0]) < aepsge &&\n\t\t       (knum == 0 || DNEQUAL(up[0]->epar[0], endpar)))\n\t\t   {\n\t\t      /* Making intersection point. */\n\t\t      double *nullp = SISL_NULL;\n\n\t\t      changes = TRUE;\n\t\t      qt_par[ind_kept]    = endpar;\n\t\t      qt_par[ind_missing] = spar[ind_missing];\n\t\t      qt = hp_newIntpt (2, qt_par, DZERO, SI_ORD,\n\t\t\t\t\tSI_UNDEF, SI_UNDEF, SI_UNDEF, SI_UNDEF,\n\t\t\t\t\t0, 0, nullp, nullp);\n\n\t\t      if (qt == SISL_NULL)\n\t\t\t goto err101;\n\n\t\t      sh6tohelp (qt,&kstat);\n\t\t      if (kstat < 0) goto error;\n\n\t\t      /* get closest point pcl to qt in pintdat. */\n\t\t      sh6idnpt(pintdat,&qt,TRUE,&kstat);\n\t\t      if (kstat < 0) goto error;\n\t\t      kpos=1;\n\t\t      if (kstat) goto errinconsis;\n\n\t\t      kpos=2;\n\t\t      s6idcpt(*pintdat,qt,&pcl);\n\t\t      if (!pcl) goto errinconsis;\n\n\t\t      if (DEQUAL(pcl->epar[ind_kept],qt_par[ind_kept]) &&\n\t\t\t  fabs(pcl->epar[ind_missing] - qt_par[ind_missing])\n\t\t\t  < 0.000001)\n\t\t      {\n\t\t\t qt->epar[ind_missing] = pcl->epar[ind_missing];\n\t\t\t pcl->epar[ind_missing] = qt_par[ind_missing];\n\t\t\t sh6tomain (pcl,&kstat);\n\t\t\t if (kstat < 0) goto error;\n\t\t\t sh6idcon (pintdat,&qt,&pcl,&kstat);\n\t\t\t if (kstat < 0) goto error;\n\t\t      }\n\t\t   }\n\t\t   if (end_point)\n\t\t      freePoint(end_point);\n\t\t   end_point = SISL_NULL;\n\n\t\t}\n\n\t     if (changes)\n\t     {\n\t\t/* Clean up and regenerate uedge and qintdat. */\n\t\tif (uedge[0] != SISL_NULL)\n\t\t   freeEdge (uedge[0]);\n\t\tif (uedge[1] != SISL_NULL)\n\t\t   freeEdge (uedge[1]);\n\n\t\tif (qintdat != SISL_NULL)\n\t\t{\n\t\t   freeIntdat (qintdat);\n\t\t   qintdat = SISL_NULL;\n\t\t}\n\n\t\tsh6idget ((iobj == 1 ? (ki == 0 ? po1 : (ki == 1 ? qs1 : qs2)) : po1),\n\t\t\t  (iobj == 2 ? (ki == 0 ? po2 : (ki == 1 ? qs1 : qs2)) : po2),\n\t\t\t  (ki == 0   ? (idiv == 2 ? 1 : 0) : 1) + kpar,\n\t\t\t  (ki == 0   ? (idiv == 2 ? spar[1] : spar[0]) : spar[1]),\n\t\t\t  *pintdat, &qintdat, aepsge, &kstat);\n\n\t\t/* Making new edge object to sub problems. */\n\n\t\tif ((iobj == 1 ? qso : po1)->iobj == SISLPOINT)\n\t\t   uedge[0] = SISL_NULL;\n\t\telse if ((uedge[0] = newEdge (vedge[0]->iedge - (iobj == 1 ? 2 : 0))) == SISL_NULL)\n\t\t   goto err101;\n\t\tif ((iobj == 2 ? qso : po2)->iobj == SISLPOINT)\n\t\t   uedge[1] = SISL_NULL;\n\t\telse if ((uedge[1] = newEdge (vedge[1]->iedge - (iobj == 2 ? 2 : 0))) == SISL_NULL)\n\t\t   goto err101;\n\n\t\t/* Update edge intersection on sub problems. */\n\n\t\tsh6idalledg ((iobj == 1 ? qso : po1), (iobj == 1 ? po2 : qso), qintdat, uedge, &kstat);\n\t\tif (kstat < 0)\n\t\t   goto error;\n\n\n\t     }\n\t     if (up) freearray(up);\n\t  }\n\t  /* END of update, UJK,jan.93.__________________________ */\n\n\n\t  /* Examine if the subdividing curve intersect the second object. */\n\n\t  sh1762 ((iobj == 1 ? qso : po1), (iobj == 1 ? po2 : qso), aepsge,\n\t\t  &qintdat, uedge, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  if (uedge[0] != SISL_NULL)\n\t    freeEdge (uedge[0]);\n\t  if (uedge[1] != SISL_NULL)\n\t    freeEdge (uedge[1]);\n\n\n\t  /* Free mother object of the subdividing curve.  */\n\n\t  if (qmotherobj != SISL_NULL) freeObject(qmotherobj);\n\t  qmotherobj = SISL_NULL;\n\t  qcrv = SISL_NULL;\n\t  qso->o1 = qso;\n\n\t  /* Examine if there is an intersection point close to the\n\t     subdivision point. If there is, correct the subdivision point. */\n\n\t  /* ALA and UJK 31.10.90 don't change divide point\n\t     when fixflag is set */\n\t  /* if ((fixflag == 0) && idiv == 3 && ki == 0 && qintdat != SISL_NULL) */\n\t  if ((fixflag <= 1) && idiv == 3 && ki == 0 && qintdat != SISL_NULL)\n\t    /*  if (idiv == 3 && ki == 0 && qintdat != SISL_NULL) */\n\t    {\n\t      double sparsave = spar[1];\n\t      int changed = 0;\n\t      tdel = (qso->c1->et[qso->c1->in] -\n\t\t      qso->c1->et[qso->c1->ik - 1]) * (double) 0.1;\n\n\t      for (kn = 0; kn < qintdat->ipoint; kn++)\n\t\t{\n\t\t  /* UJK, aug.92 Do NOT subdiv in a help point */\n\t\t  if (sh6ismain(qintdat->vpoint[kn]))\n\t\t    if ((fabs (qintdat->vpoint[kn]->epar[kpar]\n\t\t\t       - spar[1]) < fabs (tdel)) &&\n\t\t\tDNEQUAL (qintdat->vpoint[kn]->epar[kpar],\n\t\t\t\t qso->c1->et[qso->c1->in]) &&\n\t\t\tDNEQUAL (qintdat->vpoint[kn]->epar[kpar],\n\t\t\t\t qso->c1->et[qso->c1->ik - 1]))\n\t\t      {\n\t\t\ttdel = fabs(spar[1]-qintdat->vpoint[kn]->epar[kpar]);\n\t\t\tspar[1] = qintdat->vpoint[kn]->epar[kpar];\n\t\t\tchanged = 1;\n\t\t      }\n\t\t}\n\t      if (changed && (*pintdat) != NULL)\n\t\t{\n\t\t  // Check if the new intersection point is very close\n\t\t  // to an existing one\n\t\t  for (kn=0; kn<(*pintdat)->ipoint; ++kn)\n\t\t    {\n\t\t      for (kj=0; kj<(*pintdat)->vpoint[kn]->ipar; ++kj)\n\t\t\t{\n\t\t\t  tpar = (*pintdat)->vpoint[kn]->epar[kj];\n\t\t\t  if ((tpar < sstart[kj] && DNEQUAL(tpar, sstart[kj])) ||\n\t\t\t      (tpar > send[kj] && DNEQUAL(tpar, send[kj])))\n\t\t\t    break;\n\t\t\t}\n\t\t      \n\t\t      double del = \n\t\t\tfabs ((*pintdat)->vpoint[kn]->epar[kpar+1] - spar[1]);\n\t\t      if (kj >= (*pintdat)->vpoint[kn]->ipar &&\n\t\t\t  del < tdel && fabs(spar[1]-sparsave) > del) \n\t\t      {\n\t\t\tspar[1] = sparsave;\n\t\t\tchanged = 0;\n\t\t\tbreak;\n\t\t      }\n\t\t      else if (kj >= (*pintdat)->vpoint[kn]->ipar &&\n\t\t\t       del < 2.0*tdel)\n\t\t\t{\n\t\t\t  /* Using midpoint. This is not a perfect solution,\n\t\t\t     the midpoint can also be dangerous */\n\t\t\t  spar[1] = s1792 (qo1->s1->et2, qo1->s1->ik2, \n\t\t\t\t\t   qo1->s1->in2);\n\t\t\t  changed = 0;\n\t\t\t  fixflag = 0;\n\t\t\t}\n\t\t    }\n\t\t}\n\n\t    }\n\n\t  /*ujk, ala 921218, dont't split very close to a\n\t     new intersection point */\n\t  else if ((fixflag) && idiv == 3 && ki == 0 && qintdat != SISL_NULL)\n\t  {\n\t     /* tdel = (qso->c1->et[qso->c1->in] - */\n\t     /* \t     qso->c1->et[qso->c1->ik - 1]) * (double) 0.000001; */\n\t     tdel = (qso->c1->et[qso->c1->in] -\n\t     \t     qso->c1->et[qso->c1->ik - 1]) * (double) 0.0001;\n\n\t     for (kn = 0; kn < qintdat->ipoint; kn++)\n\t\tif (DNEQUAL(qintdat->vpoint[kn]->epar[kpar],spar[1])\n\t\t    && (fabs (qintdat->vpoint[kn]->epar[kpar]\n\t\t\t      - spar[1]) < fabs (tdel))) break;\n\n\t     if (kn <  qintdat->ipoint)\n\t\t/* Using midpoint */\n\t     {\n\t\tspar[1] = s1792 (qo1->s1->et2, qo1->s1->ik2, qo1->s1->in2);\n\t\tfixflag = 0;\n\t     }\n\t  }\n\n\t  /* TDO,UJK 02.08.89 */\n\t  /* A possible better strategy for\n\t     subdividing is to divide in the\n\t     middle value of the first and last\n\t     intersection on the subdividing curve.*/\n/*\n\t  if (idiv == 3 && ki == 0 && qintdat != SISL_NULL)\n\t    {\n\t      int kn;\n\t      double tdel,tdiv,tmin,tmax;\n\n\t      if(qintdat->ipoint > 0)\n\t      {\n\t\t  tmin = qintdat->vpoint[0]->epar[kpar];\n\t\t  tmax = qintdat->vpoint[0]->epar[kpar];\n\n\t\t  for (kn=1;kn<qintdat->ipoint;kn++)\n\t\t    {\n\t\t      if (tmin < qintdat->vpoint[kn]->epar[kpar])\n\t\t\ttmin = qintdat->vpoint[kn]->epar[kpar];\n\n\t\t      if (tmax > qintdat->vpoint[kn]->epar[kpar])\n\t\t\ttmax = qintdat->vpoint[kn]->epar[kpar];\n\n\t\t    }\n\n\t\t  tdiv = (tmax + tmin)/(double)2.0;\n\n\t\t  if (DNEQUAL(tdiv,qso->c1->et[qso->c1->in]) &&\n\t\t      DNEQUAL(tdiv,qso->c1->et[qso->c1->ik-1]))\n\t\t    spar[1]=tdiv;\n\n\t\t}\n\t    }\n*/\n\n\n\t  if (kstat == 1)\n\t    {\n\t      /* Total number of points. */\n\n\t      knum = (*pintdat == SISL_NULL ? 0 : (*pintdat)->ipoint) +\n\t\tqintdat->ipoint;\n\n\t      *jstat = 1;\t/* Mark intersection found. */\n\n\t      /* Intersection found and we have to register the intersection\n\t\t points. */\n\n\t      /* UJK newi */\n\t      sh1782 (po1, po2, aepsge, qintdat,\n\t\t      (ki == 0 ? (idiv == 2 ? 1 : 0) : 1) + kpar,\n\t\t      (ki == 0 ? (idiv == 2 ? spar[1] : spar[0]) : spar[1]),\n\t\t      pintdat, &idummy, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      /* UJK newi divide surface */\n\t      /* UPDATE: ? what about help points from s1782 knum?? */\n\t      if (qpt != SISL_NULL && (*pintdat)->ipoint == knum)\n\t\t{\n\t\t  /* Find the closest poin to qpt. */\n\n\t\t  s6idcpt (*pintdat, qpt, &qp);\n\n\t\t  /* UJK newi, unite the points : */\n\t\t  sh6idnewunite (po1, po2, pintdat, &qpt, &qp, (double) 0.5,\n\t\t\t\t aepsge, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t}\n\n\t    }\n\n\t  if (qintdat != SISL_NULL)\n\t    {\n\t      freeIntdat (qintdat);\n\t      qintdat = SISL_NULL;\n\t    }\n\t}\n      if (qs1 != SISL_NULL)\n\tfreeObject (qs1);\n      if (qs2 != SISL_NULL)\n\tfreeObject (qs2);\n    }\n  else\n    goto err121;\n\n\n  goto out;\n\n/* Error. Inconsistency.  */\n\nerrinconsis:*jstat = -231;\n  s6err (\"sh1762_s9div\", *jstat, kpos);\n  goto out;\n\n/* Error. Kind of object does not exist.  */\n\nerr121:*jstat = -121;\n  s6err (\"sh1762_s9div\", *jstat, kpos);\n  goto out;\n\n/* Error in space allocation.  */\n\nerr101:*jstat = -101;\n  s6err (\"sh1762_s9div\", *jstat, kpos);\n  goto out;\n\n/* Error in lower level routine.  */\n\nerror:*jstat = kstat;\n  s6err (\"sh1762_s9div\", *jstat, kpos);\n  goto out;\n\nout:;\n}\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1762_s9update (SISLObject * po1, SISLObject * po2, double aepsge,\n\t\t SISLIntdat ** pintdat, SISLEdge ** vedge[], int *jstat)\n#else\nstatic void\nsh1762_s9update (po1, po2, aepsge, pintdat, vedge, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     SISLIntdat **pintdat;\n     SISLEdge **vedge[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Uppdating intersection data if possible.\n*\n*\n*\n* INPUT      : po1      - First object in intersection.\n*              po2      - Second object in intersection.\n*              aepsge    - Geometry resolution.\n*              jstat    - = 100: A close to planar conficuration\n*\n*\n* OUTPUT     : pintdat  - intersection data.\n*              vedge[2] - intersection on edges.\n*              jstat    - status messages\n*                          = 2     : no intersection found\n*                          = 1     : Intersection found.\n*                          = 0     : not a simple case.\n*                          < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-04.\n*\n*********************************************************************\n*/\n{\n  /* UJK newi */\n  int ki, no_new;\n  SISLIntpt *qt = SISL_NULL;\n\n  int kpos = 0;\n  int kstat = 0;\n  int kdim;\n  SISLObject *qo;\n  SISLIntpt **up = SISL_NULL;\n  int planar = (*jstat == 100);\n\n  /* Test input.  */\n\n  kdim = (po1->iobj == SISLPOINT ? po1->p1->idim :\n\t  (po1->iobj == SISLCURVE ? po1->c1->idim : po1->s1->idim));\n\n  if (kdim != (po2->iobj == SISLPOINT ? po2->p1->idim :\n\t       (po2->iobj == SISLCURVE ? po2->c1->idim : po2->s1->idim)))\n    goto err106;\n\n  /* Initiate to no intersection. */\n\n  *jstat = 2;\n\n  if (po1->iobj == SISLPOINT || po2->iobj == SISLPOINT)\n    {\n      int kturn = 0;\n      int knum = 0;\n\n      if (po1->iobj != SISLPOINT)\n\t{\n\t  qo = po1;\n\t  po1 = po2;\n\t  po2 = qo;\n\t  kturn = 1;\n\t}\n\n      knum = (*vedge)[1 - kturn]->ipoint;\n\n\n      /* UPDATE ALA 010993. Start */\n      if (knum == 0 && (*pintdat) != SISL_NULL)\n      {\n\tfor (ki = 0; ki < (*pintdat)->ipoint; ki++)\n\t  if (po2->iobj == SISLCURVE)\n\t  {\n\t    if ((*pintdat)->vpoint[ki]->epar[0] > po2->c1->et[po2->c1->ik-1] &&\n\t\t(*pintdat)->vpoint[ki]->epar[0] < po2->c1->et[po2->c1->in])\n\t    {\n\t      knum = 1;\n\t    }\n\t  }\n\t  else\n\t  {\n\t    if ((*pintdat)->vpoint[ki]->epar[0] > po2->s1->et1[po2->s1->ik1-1] &&\n\t\t(*pintdat)->vpoint[ki]->epar[0] < po2->s1->et1[po2->s1->in1]   &&\n\t\t(*pintdat)->vpoint[ki]->epar[1] > po2->s1->et2[po2->s1->ik2-1] &&\n\t\t(*pintdat)->vpoint[ki]->epar[1] < po2->s1->et2[po2->s1->in2])\n\t    {\n\t      knum = 1;\n\t    }\n\t  }\n      }\n      /* UPDATE ALA 010993.  End */\n\n\n      if (knum > 1)\n\t{\n\t  /* sh1762_s9edgpoint ((*vedge), &up, &knum, &kstat); */\n\t  sh6edgpoint ((*vedge), &up, &knum, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n\n\n      /* We have more than one intersection point on the edges.\n\t If the dimension is one and the second object is a point\n\t we just connect the point else we kill these points and\n\t try to find a new intersection point. */\n\n      if (knum > 1)\n\t{\n\t  if (po2->iobj == SISLSURFACE && kdim == 1)\n\t    {\n\t      int ksimple;\n\t      if (po2->o1 == po2)\n\t\tksimple = 0;\n\t      else\n\t\tksimple = 1;\n\n\t      /* UPDATE: UJK, new parameter turn ?? */\n\t      sh1762_s9edgpscon ((*vedge)[1 - kturn], po1->p1->ecoef[0],\n\t\t\t\t po2->s1, ksimple, *pintdat, aepsge, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t      else if (kstat)\n\t\t*jstat = 0;\t/* Not a simple case. */\n\t    }\n\n\t    else  if (po2->iobj == SISLSURFACE && kdim == 2 && knum == 2)\n\t       {\n\t\t  /* 2D point surf, connect */\n\t\t  sh6idcon (pintdat, up, up + 1, &kstat);\n\t\t  if (kstat < 0)\n\t\t     goto error;\n\t        }\n\n\t    else\n\t    {\n\t      /* UJK newi */\n\t      for (ki = 1; ki < knum; ki++)\n\t\t{\n\t\t   sh6idnewunite (po1, po2, pintdat, &up[0], &up[ki],\n\t\t\t\t(double) 0.5, aepsge, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\n\t\t}\n\t      qt = up[0];\n\n\t      ki = (*vedge)[1 - kturn]->iedge;\n\t      freeEdge ((*vedge)[1 - kturn]);\n\t      if (((*vedge)[1 - kturn] = newEdge (ki)) == SISL_NULL)\n\t\tgoto err101;\n\t      knum = 0;\n\t    }\n\t}\n\n      if (knum == 0)\n\t{\n\t  double spar[2];\n\n\t  if (po2->iobj == SISLCURVE)\n\t    {\n\t      double tstart, tend;\n\n\t      tstart = po2->c1->et[po2->c1->ik - 1];\n\t      tend = po2->c1->et[po2->c1->in];\n\t      spar[0] = (tstart + tend) * (double) 0.5;\n\n\n\t      s1771 (po1->p1, po2->o1->c1, aepsge,\n\t\t     tstart, tend, spar[0], spar, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      if (kstat == 1)\n\t\t/*Intersection point found. Control edges. */\n\t\tif (DEQUAL (spar[0], tstart) || DEQUAL (spar[0], tend))\n\t\t  kstat = 0;\n\t    }\n\t  else if (po2->iobj == SISLSURFACE)\n\t    {\n\t      double sstart[2], send[2];\n\n\t      sstart[0] = po2->s1->et1[po2->s1->ik1 - 1];\n\t      sstart[1] = po2->s1->et2[po2->s1->ik2 - 1];\n\n\t      send[0] = po2->s1->et1[po2->s1->in1];\n\t      send[1] = po2->s1->et2[po2->s1->in2];\n\n\t      spar[0] = (sstart[0] + send[0]) * (double) 0.5;\n\t      spar[1] = (sstart[1] + send[1]) * (double) 0.5;\n\n\t      s1773 (po1->p1, po2->o1->s1, aepsge, sstart, send, spar, spar, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      if (kstat == 1)\n\t\t/*Intersection point found. Control edges. */\n\t\tif (DEQUAL (spar[0], sstart[0]) || DEQUAL (spar[0], send[0])\n\t\t|| DEQUAL (spar[1], sstart[1]) || DEQUAL (spar[1], send[1]))\n\t\t  kstat = 0;\n\t    }\n\n\n\n\t  /* UJK, October 91, 2D crv and surf's may be degenerate,\n\t     continue when iteration fails */\n\t  if (po1->p1->idim == 2)\n\t  {\n\t     if ((po2->iobj == SISLSURFACE && kstat == 9)||\n\t\t (po2->iobj == SISLCURVE   && kstat != 1))\n\t     {\n\t\t*jstat = 0;\n\t\tgoto out;\n\t     }\n\t  }\n\n\n\t  /* TESTING UJK !!!!!!!!!!!!!!!!!!!!! */\n\t    /* UJK, August 92, 1D crvs may be \"degenerate\",\n\t       continue when iteration fails */\n\t    if (kstat != 1 && po1->p1->idim == 1)\n\t    {\n\t       *jstat = 0;\n\t       goto out;\n\t    }\n\n\n\t    if (kstat == 1)\t/* Intersection point found. */\n\t    {\n\t      *jstat = 1;\t/* Mark intersection found.  */\n\n\t      /* UJK newi */\n\t      if (qt)\n\t\t{\n\t\t  /* We have an instance of a point, use it */\n\t\t  for (ki = 0; ki < qt->ipar; ki++)\n\t\t    qt->epar[ki] = spar[ki];\n\t\t}\n\t      else\n\t\t{\n\t\t  /* Making intersection point. */\n\t\t  double *nullp = SISL_NULL;\n\t\t  qt = hp_newIntpt (po2->iobj, spar, DZERO, SI_ORD,\n\t\t\t\t    SI_UNDEF, SI_UNDEF, SI_UNDEF, SI_UNDEF,\n\t\t\t\t    0, 0, nullp, nullp);\n\n\t\t  if (qt == SISL_NULL)\n\t\t    goto err101;\n\n\t\t  /* Uppdating pintdat. */\n\t\t  sh6idnpt (pintdat, &qt, 1, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\n\t\t  /* Set pretopology */\n\t\t  if (po2->iobj == SISLCURVE)\n\t\t    {\n\t\t      /* Case point, curve */\n\t\t      if (po1->p1->idim == 1)\n\t\t\t{\n\t\t\t  /* 1D point curve treated,\n\t\t\t     2D, 3D is set to undef */\n\n\t\t\t  sh1781 ((kturn ? po2 : po1),\n\t\t\t\t  (kturn ? po1 : po2),\n\t\t\t\t  aepsge, pintdat, qt, &no_new, &kstat);\n\t\t\t  if (kstat < 0)\n\t\t\t    goto error;\n\t\t\t}\n\t\t      else\n\t\t\t{\n\t\t\t  /* UPDATE (ujk) 1D touch well defined ? */\n\t\t\t  /* Case point, surface */\n\t\t\t  if (po1->p1->idim == 2)\n\t\t\t    {\n\t\t\t      /* 2D point surface is treated,\n\t\t\t         1D, 3D is set to undef */\n\t\t\t      sh1786 ((kturn ? po2 : po1),\n\t\t\t\t      (kturn ? po1 : po2),\n\t\t\t\t      aepsge, pintdat, qt, &no_new, &kstat);\n\n\t\t\t      if (kstat < 0)\n\t\t\t\tgoto error;\n\t\t\t    }\n\t\t\t}\n\n\t\t    }\n\t\t}\n\t    }\n\t}\n    }\n  else if (po1->iobj == SISLCURVE || po2->iobj == SISLCURVE)\n    {\n      int kturn1 = 1, kturn2 = 0;\n\n      if (po1->iobj != SISLCURVE)\n\t{\n\t  qo = po1;\n\t  po1 = po2;\n\t  po2 = qo;\n\t  kturn1 = 0;\n\t  kturn2 = 2;\n\t}\n\n      if ((*vedge)[0]->ipoint + (*vedge)[1]->ipoint > 1)\n\t{\n\t  int knum;\n\n\t  /* sh1762_s9edgpoint ((*vedge), &up, &knum, &kstat); */\n\t  sh6edgpoint ((*vedge), &up, &knum, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  if (knum > 1)\n\t    {\n\t      int ki;\n\n\t      /* We have more than one intersection point on the edges.\n\t         We therefor kill these points and\n\t         try to find a new intersection point. */\n\n\t      /* UJK newi CONNECT */\n\t      for (ki = 1; ki < knum; ki++)\n\t\t{\n\t\t   /* sh6idnewunite (po1, po2, pintdat, &up[0], &up[ki],\n\t\t      (double) 0.5, aepsge, &kstat); */\n\t\t   sh6idcon(pintdat, &up[0], &up[ki], &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\n\t\t}\n\n\t      *jstat = 1;\n\t      goto out;\n\n\t      /* qt = up[0];\n\n\t\t ki = (*vedge)[0]->iedge;\n\t\t freeEdge ((*vedge)[0]);\n\t\t if (((*vedge)[0] = newEdge (ki)) == SISL_NULL)\n\t\t goto err101;\n\t\t ki = (*vedge)[1]->iedge;\n\t\t freeEdge ((*vedge)[1]);\n\t\t if (((*vedge)[1] = newEdge (ki)) == SISL_NULL)\n\t\t goto err101;\n\t\t knum = 0; */\n\t    }\n\t}\n\n      if ((*vedge)[0]->ipoint + (*vedge)[1]->ipoint == 0)\n\t{\n\t  double spar[3];\n\n          /* UPDATE ALA 010993. Start */\n          if ((*pintdat) != SISL_NULL)\n          {\n\t  for (ki = 0; ki < (*pintdat)->ipoint; ki++)\n\t     if (po2->iobj == SISLCURVE)\n\t     {\n\t       if ((*pintdat)->vpoint[ki]->epar[0] > po1->c1->et[po1->c1->ik-1] &&\n\t\t   (*pintdat)->vpoint[ki]->epar[0] < po1->c1->et[po1->c1->in] &&\n\t           (*pintdat)->vpoint[ki]->epar[1] > po2->c1->et[po2->c1->ik-1] &&\n\t\t   (*pintdat)->vpoint[ki]->epar[1] < po2->c1->et[po2->c1->in])\n\t         goto out;\n\t     }\n\t     else\n\t     {\n\t       if ((*pintdat)->vpoint[ki]->epar[kturn2] > po1->c1->et[po1->c1->ik-1] &&\n\t\t   (*pintdat)->vpoint[ki]->epar[kturn2] < po1->c1->et[po1->c1->in] &&\n\t           (*pintdat)->vpoint[ki]->epar[kturn1] > po2->s1->et1[po2->s1->ik1-1] &&\n\t\t   (*pintdat)->vpoint[ki]->epar[kturn1] < po2->s1->et1[po2->s1->in1]   &&\n\t\t   (*pintdat)->vpoint[ki]->epar[kturn1+1] > po2->s1->et2[po2->s1->ik2-1] &&\n\t\t   (*pintdat)->vpoint[ki]->epar[kturn1+1] < po2->s1->et2[po2->s1->in2])\n\t         goto out;\n\t     }\n         }\n         /* UPDATE ALA 010993.  End */\n\n\t if (po2->iobj == SISLCURVE)\n\t    {\n\t      double tstart1, tend1;\n\t      double tstart2, tend2;\n\n\t      tstart1 = po1->c1->et[po1->c1->ik - 1];\n\t      tend1 = po1->c1->et[po1->c1->in];\n\t      spar[0] = (tstart1 + tend1) * (double) 0.5;\n\n\t      tstart2 = po2->c1->et[po2->c1->ik - 1];\n\t      tend2 = po2->c1->et[po2->c1->in];\n\t      spar[1] = (tstart2 + tend2) * (double) 0.5;\n\n\n\t      s1770 (po1->o1->c1, po2->o1->c1, aepsge, tstart1,\n\t\t     tstart2, tend1, tend2, spar[0], spar[1], spar, spar + 1, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      if (kstat >= 2)\n\t\t{\n\t\t  /* Search for a better start point for the\n\t\t     iteration. */\n\t\t  sh6cvvert(po1->c1, po2->c1, spar, spar+1);\n\n\t\t  /* Iterate. */\n\t\t  kstat = 0;\n\t\t  s1770 (po1->o1->c1, po2->o1->c1, aepsge, tstart1,\n\t\t\t tstart2, tend1, tend2, spar[0], spar[1],  \n\t\t\t spar, spar + 1, &kstat);\n\t\t  if (kstat < 0)\n\t\t    { kpos=__LINE__; goto error; }\n\t\t}\n\n\t      if (kstat == 1)\n\t\t/*Intersection point found. Control edges. */\n\t\tif (DEQUAL (spar[0], tstart1) || DEQUAL (spar[0], tend1)\n\t\t    || DEQUAL (spar[1], tstart2) || DEQUAL (spar[1], tend2))\n\t\t  kstat = 0;\n\t    }\n\t  else if (po2->iobj == SISLSURFACE)\n\t    {\n\t      double tstart, tend;\n\t      double sstart[2], send[2];\n\n\t      tstart = po1->c1->et[po1->c1->ik - 1];\n\t      tend = po1->c1->et[po1->c1->in];\n\t      spar[kturn2] = (tstart + tend) * (double) 0.5;\n\n\n\t      sstart[0] = po2->s1->et1[po2->s1->ik1 - 1];\n\t      sstart[1] = po2->s1->et2[po2->s1->ik2 - 1];\n\n\t      send[0] = po2->s1->et1[po2->s1->in1];\n\t      send[1] = po2->s1->et2[po2->s1->in2];\n\n\t      spar[kturn1] = (sstart[0] + send[0]) * (double) 0.5;\n\t      spar[kturn1 + 1] = (sstart[1] + send[1]) * (double) 0.5;\n\n\t      kstat = 0;\n\t      s1772 (po1->o1->c1, po2->o1->s1, aepsge, tstart, sstart, tend, send,\n\t\t     spar[kturn2], &spar[kturn1],\n\t\t     &spar[kturn2], &spar[kturn1], &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      if (kstat == 3)\n\t\t{\n\t\t  /* FLAT */\n\t\t  *jstat = 0;\n\t\t  goto out;\n\t\t}\n\n\t      /* UJIK, Retry, with better startpoint */\n\t      if (kstat == 2)\n\t      {\n\t\t/* No intersection point is found. Try again with a new\n\t\t   start point to the iteration.  */\n\n\t\tsh6closevert(po1->c1,po2->s1,&spar[kturn2],&spar[kturn1]);\n\t\tkstat = 0;\n\t\ts1772 (po1->o1->c1, po2->o1->s1, aepsge, tstart, sstart, tend, send,\n\t\t       spar[kturn2], &spar[kturn1],\n\t\t       &spar[kturn2], &spar[kturn1], &kstat);\n\t\tif (kstat < 0)\n\t\t  goto error;\n\t      }\n\n\t      if (kstat == 1)\n\t\t/*Intersection point found. Control edges. */\n\t\tif (DEQUAL (spar[kturn2], tstart) ||\n\t\t    DEQUAL (spar[kturn2], tend) ||\n\t\t    DEQUAL (spar[kturn1], sstart[0]) ||\n\t\t    DEQUAL (spar[kturn1], send[0]) ||\n\t\t    DEQUAL (spar[kturn1 + 1], sstart[1]) ||\n\t\t    DEQUAL (spar[kturn1 + 1], send[1]))\n\t\t  kstat = 0;\n\t    }\n\n\t  if (kstat == 1)\t/* Intersection point found. */\n\t    {\n\n\t      *jstat = 1;\t/* Mark intersection found.  */\n\n\t      /* UJK newi */\n\t      if (qt)\n\t\t{\n\t\t  /* We have an instance of a point, use it */\n\t\t  for (ki = 0; ki < qt->ipar; ki++)\n\t\t    qt->epar[ki] = spar[ki];\n\t\t}\n\t      else\n\t\t{\n\t\t  /* Making intersection point. */\n\t\t  double *nullp = SISL_NULL;\n\t\t  qt = hp_newIntpt (po1->iobj + po2->iobj, spar, DZERO, SI_ORD,\n\t\t\t\t    SI_UNDEF, SI_UNDEF, SI_UNDEF, SI_UNDEF,\n\t\t\t\t    0, 0, nullp, nullp);\n\n\t\t  if (qt == SISL_NULL)\n\t\t    goto err101;\n\n\t\t  /* Uppdating pintdat. */\n\t\t  sh6idnpt (pintdat, &qt, 1, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\n\t\t  /* Set pretopology */\n\t\t  if (po2->iobj == SISLCURVE)\n\t\t    {\n\t\t      /* Case curve, curve */\n\t\t      if (po1->c1->idim == 2)\n\t\t\t{\n\t\t\t  /* Only 2D is treated */\n\t\t\t  sh1780 (po1, po2,\n\t\t\t\t  aepsge, pintdat, qt, &no_new, &kstat);\n\t\t\t  if (kstat < 0)\n\t\t\t    goto error;\n\t\t\t}\n\t\t    }\n\t\t  else if (po2->iobj == SISLSURFACE)\n\t\t    {\n\t\t      /* Case curve, surface */\n\t\t      if (po1->c1->idim == 3)\n\t\t\t{\n\t\t\t  /* Only 3D  */\n\t\t\t  sh1779 ((kturn1 ? po1 : po2),\n\t\t\t\t  (kturn1 ? po2 : po1),\n\t\t\t\t  aepsge, pintdat, qt, &no_new, &kstat);\n\t\t\t  if (kstat < 0)\n\t\t\t    goto error;\n\t\t\t}\n\t\t    }\n\n\t\t}\n\t    }\n\t}\n    }\n  else if (po1->iobj == SISLSURFACE && po2->iobj == SISLSURFACE)\n    {\n      if ((*vedge)[0]->ipoint + (*vedge)[1]->ipoint > 1)\n\t{\n\t  /* We have more than one intersection point on the edges,\n             we therefor connect these points to each other. */\n\t  int ksimple;\n\t  if (planar)\n\t    ksimple = 2;\n\t  else if (po1->psimple == po2)\n\t    ksimple = 1;\n\t  else\n\t    ksimple = 0;\n\n\t  sh1762_s9edgsscon ((*vedge), po1->s1, po2->s1, *pintdat, ksimple,\n\t\t\t     aepsge, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  else if (kstat)\n\t    *jstat = 0;\t\t/* Not a simple case. */\n\t}\n    }\n  else\n    goto err121;\n\n  goto out;\n\n/* Error. Kind of object does not exist.  */\n\nerr121:*jstat = -121;\n  s6err (\"sh1762_s9update\", *jstat, kpos);\n  goto out;\n\n/* Error in input. Conflicting dimensions.  */\n\nerr106:*jstat = -106;\n  s6err (\"s1770\", *jstat, kpos);\n  goto out;\n\n/* Error in space allocation.  */\n\nerr101:*jstat = -101;\n  s6err (\"sh1762_s9update\", *jstat, kpos);\n  goto out;\n\n/* Error in lower level routine.  */\n\nerror:*jstat = kstat;\n  s6err (\"sh1762_s9update\", *jstat, kpos);\n  goto out;\n\nout:if (up != SISL_NULL)\n    freearray (up);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1762_s9con (SISLObject * po1, SISLObject * po2, double aepsge,\n\t      SISLIntdat ** pintdat, SISLEdge * vedge[], int *jstat)\n#else\nstatic void\nsh1762_s9con (po1, po2, aepsge, pintdat, vedge, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     SISLIntdat **pintdat;\n     SISLEdge *vedge[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Check if one part of an object coincide in one part\n*              of an other object. Both object must intersect in at least two\n*              ends/edges. This rutine also use a rotated SISLbox tests\n*              to test if intersection is possible.\n*\n*\n*\n* INPUT      : po1      - The first SISLObject to check.\n*              po2      - The second SISLObject to check.\n*              aepsge   - Geometrical resolution.\n*              vedge[]  - SISLEdge intersection.\n*              *jstat    - Flag\n*                          = 202 : Complicated point-surface intersection\n*                                  in 3D. Perform extra interception test.\n*\n*\n* INPUT/OUTPUT:pintdat  - Intersection data.\n*\n*\n* OUTPUT     :\n*              jstat    - status messages\n*                           = 3     : Simple case encountered\n*                           = 2     : No intersection..\n*                           = 1     : Coinside found.\n*                           = 0     : no coinside.\n*                           < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* CALLS      : sh1762_s9intercept - Perform improved box tests and implicitizaion to\n*                            intercept recursion.\n*              sh1762_s9coincide  - Test coincidence between crv/crv and surf/crv objects.\n*              sh1762_s9toucharea - Test coincidence between surf/surf objects.\n*              sh6edgpoint        - Fetch intersection points on edges.\n*\n*\n* WRITTEN BY : Arne Laksaa,  SI, 89-05.\n* REWISED BY : Vibeke Skytt, SI, 91-01.\n*              UJK,          SI, 91-06\n* REVISED BY : Michael Floater SI, 91-09\n\t\t- check for existence of touching areas.\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                        */\n  int ki,kj;\t\t\t/* Counter.                                */\n  int knum = 0;\t\t\t/* Number of intersection points on edges. */\n  SISLIntpt **up = SISL_NULL;\t/* Intersection points on edges.           */\n  SISLdir *qd1, *qd2;\t\t/* Direction cones of objects.             */\n  SISLIntpt *qpt;               /* Evt 3. intersection point.              */\n  int knpar=po1->iobj+po2->iobj; /* Number of parameter directions.        */\n  int kcrv1;                    /* Indicates if 1. object is a curve.      */\n  int kcrv2;                    /* Indicates if 2. object is a curve.      */\n  int pretop[2][4];\n  SISLObject *qobj;\n  int ind1, ind2, perm[2], obj, ipar;\n  int klist1, klist2;\n  int linear = FALSE;\n  int kpt,kpt2;                 /* Number of elements in int. list.        */\n  int kstat2 = 0, kstat3 = 0;   /* Remember status from s9toucharea.       */\n  double mintang1;\n  double mintang2;\n  double tboxsize1;\n  double tboxsize2;\n  int kxintercept = (*jstat == 202);  /* Extra interception       */\n\n  /*int loopcount;*/\t\t/* Count up num intpts in a list. */\n  int one_edge = 0;             /* Indicates if all intersection points\n\t\t\t\t   lies on one edge in each surface.     */\n  SISLPtedge *qpt1, *qpt2;      /* Pointers used to traverse edge intersections. */\n  /*int kdir, kdir2;               Constant parameter directions */\n  int kgtpi1, kgtpi2;\n\n  /* Set kcrv parameters.  */\n\n  kcrv1 = (po1->iobj == SISLCURVE) ? 1 : 0;\n  kcrv2 = (po2->iobj == SISLCURVE) ? 1 : 0;\n\n  if ((po1->iobj == SISLPOINT && po1->p1->idim == 1) ||\n      (po2->iobj == SISLPOINT && po2->p1->idim == 1))\n    *jstat = 0;\n  else\n    {\n\n       if (po1->iobj == SISLPOINT) qd1 = SISL_NULL;\n       else\n\t  qd1 = (po1->iobj == SISLCURVE ? po1->c1->pdir : po1->s1->pdir);\n\n       if (po2->iobj == SISLPOINT) qd2 = SISL_NULL;\n       else\n\t  qd2 = (po2->iobj == SISLCURVE ? po2->c1->pdir : po2->s1->pdir);\n\n       knum = 0;\n       if (vedge[0] != SISL_NULL) knum += vedge[0]->ipoint;\n       if (vedge[1] != SISL_NULL) knum += vedge[1]->ipoint;\n\n      if (knum > 0)\n\t{\n\t  /* Organize intersection points on an array. */\n\n\t  /* sh1762_s9edgpoint (vedge, &up, &knum, &kstat); */\n\t  sh6edgpoint (vedge, &up, &knum, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n\n      /* We test coincide by linearity. If the two object is liniar\n         and have end/edge intersection we just connect these\n         intersection points, else we have no internal intersections. */\n\n      if (po1->iobj == SISLCURVE)\n      {\n\t tboxsize1 = po1->c1->pbox->e2max[2][0] - po1->c1->pbox->e2min[2][0];\n\t if (po1->c1->idim > 1)\n\t    tboxsize1 = MAX(tboxsize1,\n\t\t\t   po1->c1->pbox->e2max[2][1] - po1->c1->pbox->e2min[2][1]);\n\t if (po1->c1->idim > 2)\n\t    tboxsize1 = MAX(tboxsize1,\n\t\t\t   po1->c1->pbox->e2max[2][2] - po1->c1->pbox->e2min[2][2]);\n\t mintang1 = aepsge/((double)2*tboxsize1);\n      }\n      else  if (po1->iobj == SISLSURFACE)\n\t mintang1 = ANGULAR_TOLERANCE/(double)10;\n\n      if (po2->iobj == SISLCURVE)\n      {\n\t tboxsize2 = po2->c1->pbox->e2max[2][0] - po2->c1->pbox->e2min[2][0];\n\t if (po2->c1->idim > 1)\n\t    tboxsize2 = MAX(tboxsize2,\n\t\t\t   po2->c1->pbox->e2max[2][1] - po2->c1->pbox->e2min[2][1]);\n\t if (po2->c1->idim > 2)\n\t    tboxsize2 = MAX(tboxsize2,\n\t\t\t   po2->c1->pbox->e2max[2][2] - po2->c1->pbox->e2min[2][2]);\n\t mintang2 = aepsge/((double)2*tboxsize2);\n      }\n      else if (po2->iobj == SISLSURFACE)\n\t mintang2 = ANGULAR_TOLERANCE/(double)10;\n\n      /* if (qd1->igtpi || qd2->igtpi || qd1->aang > ANGULAR_TOLERANCE ||\n\t  qd2->aang > ANGULAR_TOLERANCE) */\n      if (qd1 == SISL_NULL || qd2 == SISL_NULL)\n\t *jstat = 0;\n      else if (qd1->igtpi || qd2->igtpi || qd1->aang > mintang1 ||\n\t  qd2->aang > mintang2)\n\t*jstat = 0;\n      else if (knum == 2)\n\t/* Newi (ujk) When linear and 2 points, we know how to set\n           the pretopology for curves, this is done a bit further down */\n\tlinear = TRUE;\n      else if (po1->iobj + po2->iobj < 2*SISLSURFACE)\n\t{\n\t  if (knum > 1)\n\t    {\n\t      /* We have more than one intersection point on the edges.\n                 We therefore connect these points. */\n\t      /* UPDATE (ujk) don't like this connection */\n\n\t      for (ki = 0; ki < knum; ki++)\n\t\tsh6tomain (up[ki], &kstat);\n\n\t      for (ki = 1; ki < knum; ki++)\n\t\t{\n\t\t  sh6idcon (pintdat, &up[ki - 1], &up[ki], &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t}\n\t      *jstat = 1;\n\t    }\n\t  else\n\t    *jstat = 2;\n\n\t  goto out;\t\t/* Test performed.  */\n\t}\n\n      if (knum == 1 &&\n\t  po1->iobj == SISLSURFACE && po2->iobj == SISLSURFACE &&\n\t  po1->s1->idim == 3)\n      {\n\t/* Check if the intersection point lies in the corner of at \n\t   least one surface */\n\tsh6isinside(po1, po2, up[0], &kstat);\n\tif (kstat < 0)\n\t  goto error;\n\tif (kstat == 3 || kstat == 4)\n\t  {\n\t    double sval1[9];\n\t    double snorm1[3];\n\t    double sval2[9];\n\t    double snorm2[3];\n\t    double tang;\n\t    int left1 = 0, left2=0, left3 = 0, left4 = 0;\n\t    \n\t    /* Check if the intersection point is singular */\n\t    s1421(po1->s1, 1, up[0]->epar, &left1, &left2, sval1, snorm1, &kstat);\n\t    if (kstat < 0)\n\t      goto error;\n\t    s1421(po2->s1, 1, up[0]->epar+2, &left3, &left4, sval2, snorm2, &kstat);\n\t    if (kstat < 0)\n\t      goto error;\n\t    tang = s6ang(snorm1, snorm2, 3);\n\t    if (tang <= ANGULAR_TOLERANCE || M_PI-tang <= ANGULAR_TOLERANCE)\n\t      {\n\t\t/* A singular intersection point. Check if it is isolated.\n\t\t   In that case, define a segmentation to avoid too close\n\t\t   subdivisions */\n\t\t/* printf(\"Singular corner intersection found \\n\"); */\n\t\tsh1795(po1, po2, up[0], aepsge, &kstat);\n\t\tif (kstat < 0)\n\t\t  goto error;\n\t      }\n\t  }\n      }\n      \n      if (knum >= 2 &&\n\t  po1->iobj == SISLSURFACE &&\n\t  po2->iobj == SISLSURFACE)\n      {\n\t /* VSK. Change test on possibility of coincidence.\n\t    More than two intersection points on the edges.\n\t    Check if there is\n\t    coincidence between the (surface) objects.\n\t    Fetch all closed loops. Then call s9toucharea to\n\t    see if the surfaces coincide everywhere inside the loop. */\n\n\t for (kstat2=0, kpt=0; kpt<knum; kpt+=kpt2)\n\t {\n\t    sh6floop(up+kpt,knum-kpt,&kpt2,&kstat);\n\t    kstat3 = kstat;\n\n\t    if (kstat == 1)\n\t    {\n\t       sh1762_s9toucharea (po1, po2, aepsge, kpt2, up+kpt, &kstat);\n\t       /*fprintf (stdout, \"\\n s9_toucharea, kstat=%d\", kstat); */\n\t       if (kstat < 0)\n\t\t  goto error;\n\t       kstat2 = MAX(kstat2,kstat);\n\t       /* if (false /\\*kstat == 1*\\/) */\n\t       /* \t { */\n\t       /* \t   /\\* VSK 1117. Locally this makes sense, but since the */\n\t       /* \t      intersection surface is not brought forward to the */\n\t       /* \t      application of the intersection function, it might */\n\t       /* \t      be better to stop the computations and keep the */\n\t       /* \t      boundary curves. *\\/ */\n\t       /* \t   for (kr=0,kj=kpt; kr<kpt2; ++kr, ++kj) */\n\t       /* \t     up[kj]->iinter = SI_TRIM; */\n\t       /* \t } */\n\t    }\n\t    else if (kpt == 0 && kpt2 == knum)\n\t    {\n\t       /* Only one open edge curve. Test if the entire\n\t\t  curve lies on one edge in each surface.  */\n\n\t       for (one_edge=1, ki=1; ki<knum; ki++)\n\t       {\n\t\t  sh6comedg(po1, po2, up[ki-1], up[ki], &kstat);\n\t\t  if (kstat < 0) goto error;\n\n\t\t  if (kstat != 3) \n\t\t    one_edge = 0;  /* Not a common edge. */\n\t       }\n\t    }\n\n\t    if (kstat3 != 1 && kpt2 >= knum-1)\n\t      {\n\t\tkgtpi1 = (po1->s1->pdir != SISL_NULL) ?\n\t\t  po1->s1->pdir->igtpi : 0;\n\t\tkgtpi2 = (po2->s1->pdir != SISL_NULL) ?\n\t\t  po2->s1->pdir->igtpi : 0;\n\t\tif (kpt2 == knum || (kgtpi1 == 0 && kgtpi2 == 0))\n\t\t  {\n\n\t\t    /* Check if the curve follows one constant parameter\n\t\t       curve in one surface and select the most significant\n\t\t       candidate. Check if this intersection curve is\n\t\t       tangential and, in that case, set appropriate\n\t\t       surface segmentation information. */\n\n\t\t    if (po1->s1->seg1 || po1->s1->seg2 || po2->s1->seg1 ||\n\t\t\tpo2->s1->seg2)\n\t\t      kstat = 1;\n\t\t    else\n\t\t      {\n\t\t\tsh1794(po1, po2, up, knum, aepsge, &kstat);\n\t\t\tif (kstat < 0)\n\t\t\t  goto error;\n\t\t\tif (kstat == 1)\n\t\t\t  {\n\t\t\t    /* A tangential intersection curve is found */\n\t\t\t    /*printf(\"Tangential \\n\");*/\n\t\t\t  }\n\t\t\telse if (kstat == 2)\n\t\t\t  kstat2 = 2;\n\t\t      }\n\t\t  }\n\t    }\n\t }\n\n\t *jstat = kstat2;\n\n\t if (kstat2 == 1)\n\t {\n\t    /* Do something with the pretopology. */\n\t    /* fprintf (stdout, \"\\n Coincidence, kstat=%d\", kstat); */\n\t }\n      }\n\n      if (knum < 2 || (po1->iobj == SISLSURFACE &&\n\t\t       po2->iobj == SISLSURFACE && (one_edge || knum == 2)))\n\t{\n\t  /* Number of intersection points on the edges is less than\n             two. Try to intercept further subdivision by performing\n             improved box tests.  */\n\n\t  kstat = (kxintercept) ? 202 : 0;\n\t  sh1762_s9intercept (po1, po2, aepsge, knum, up, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  *jstat = kstat;\n\t}\n      else if (knum == 2 && !(po1->iobj == SISLSURFACE &&\n\t\t\t      po2->iobj == SISLSURFACE))\n\t{\n\t  /* Two intersection points on the edges. Check if there is\n             coincidence between the objects.  */\n\n\t  if (linear)\n\t    kstat = 1;\n\t  else\n\t    {\n\t      sh1762_s9coincide (po1, po2, aepsge, knum, up, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t    }\n\n\t  *jstat = kstat;\n\n\t  if (kstat == 1)\n\t    {\n\t      int kstat1 = 0;\n\n\t      for (ki = 0; ki < knum; ki++)\n\t\tsh6tomain (up[ki], &kstat);\n\n\t      sh6idcon (pintdat, &up[0], &up[1], &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t      /* Newi (ujk) */\n\t      /*\t      for (ind1 = 0; ind1 < 2; ind1++)\n\t\tfor (ind2 = 0; ind2 < 4; ind2++)\n\t\tpretop[ind1][ind2] = SI_UNDEF; */\n\n\t      /* Fetch existing pretopology. */\n\t      sh6gettop (up[0], -1, &pretop[0][0], &pretop[0][1],\n\t\t\t &pretop[0][2], &pretop[0][3], &kstat1);\n\n\t      sh6gettop (up[1],  -1, &pretop[1][0], &pretop[1][1],\n\t\t\t &pretop[1][2], &pretop[1][3], &kstat1);\n\n\t      for (qobj = po1, obj = 0, ipar = 0; obj < 2;\n\t       qobj = po2, obj++, ipar = ((po1->iobj == SISLCURVE) ? 1 : 2))\n\t\t/* Pretopology for curves */\n\t\tif (qobj->iobj == SISLCURVE)\n\t\t  {\n\t\t    if (up[0]->epar[ipar] < up[1]->epar[ipar])\n\t\t      {\n\t\t\tperm[0] = 0;\n\t\t\tperm[1] = 1;\n\t\t\tind1 = 0;\n\t\t\tind2 = 1;\n\t\t      }\n\t\t    else\n\t\t      {\n\t\t\tperm[0] = 1;\n\t\t\tperm[1] = 0;\n\t\t\tind1 = 1;\n\t\t\tind2 = 0;\n\t\t      }\n\n\t\t    /* Left point on curve */\n\t\t    pretop[ind1][1 + 2 * obj] = SI_ON;\n\t\t    /* Point at edge */\n\t\t    if (pretop[ind1][2 * obj] != SI_IN &&\n\t\t\tpretop[ind1][2 * obj] != SI_OUT &&\n\t\t\tDEQUAL (up[perm[0]]->epar[ipar],\n\t\t\t\tqobj->c1->et[qobj->c1->ik - 1]))\n\t\t      {\n\t\t\t/* Point at edge */\n\t\t\tpretop[ind1][2 * obj] = SI_AT;\n\t\t      }\n\n\t\t    /* Right point of curve */\n\t\t    pretop[ind2][2 * obj] = SI_ON;\n\t\t    if (pretop[ind2][1 + 2 * obj] != SI_IN &&\n\t\t\tpretop[ind2][1 + 2 * obj] != SI_OUT &&\n\t\t\tDEQUAL (up[perm[1]]->epar[ipar],\n\t\t\t\tqobj->c1->et[qobj->c1->in]))\n\t\t      {\n\t\t\t/* Point at edge */\n\t\t\tpretop[ind2][1 + 2 * obj] = SI_AT;\n\t\t      }\n\n\t\t    /*    / Left point on curve /\n\t\t    if (DEQUAL (up[perm[0]]->epar[ipar],\n\t\t\t\tqobj->c1->et[qobj->c1->ik - 1]))\n\t\t      {\n\t\t\t* Point at edge *\n\t\t\tpretop[ind1][2 * obj] = SI_AT;\n\t\t\tpretop[ind1][1 + 2 * obj] = SI_ON;\n\t\t      }\n\t\t    else\n\t\t      {\n\t\t\tpretop[ind1][1 + 2 * obj] = SI_ON;\n\t\t      }\n\n\t\t    * Right point of curve *\n\t\t    if (DEQUAL (up[perm[1]]->epar[ipar],\n\t\t\t\tqobj->c1->et[qobj->c1->in]))\n\t\t      {\n\t\t\t* Point at edge *\n\t\t\tpretop[ind2][2 * obj] = SI_ON;\n\t\t\tpretop[ind2][1 + 2 * obj] = SI_AT;\n\t\t      }\n\t\t    else\n\t\t      {\n\t\t\tpretop[ind2][2 * obj] = SI_ON;\n\t\t\t} */\n\n\t\t  }\n\t      sh6getlist (up[0], up[1], &klist1, &klist2, &kstat);\n\t      if (kstat != 0)\n\t\t{\n\t\t  kstat = -1;\n\t\t  goto error;\n\t\t}\n\n\t      sh6settop (up[0], -1, pretop[0][0], pretop[0][1],\n\t\t\t pretop[0][2], pretop[0][3], &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      sh6settop (up[1], -1, pretop[1][0], pretop[1][1],\n\t\t\t pretop[1][2], pretop[1][3], &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\n\t      if (knpar<4 && (*pintdat)->ipoint == 3)\n\t\t {\n\t\t    /* There is 3 intersection points. Test if the 3. point\n\t\t       lies between the endpoints of the coincidence curve.\n\t\t       First fetch 3. point.         */\n\n\t\t    for (kj=0; kj<3; kj++)\n\t\t      {\n\t\t\t qpt = (*pintdat)->vpoint[kj];\n\t\t\t if (qpt!=up[0] && qpt!=up[1]) break;\n\t\t      }\n\n\t\t    /* Check if the point lies inside the current\n\t\t       intersection area.  */\n\n\t\t    sh6isinside(po1,po2,qpt,&kstat);\n\t\t    if (kstat < 0) goto error;\n\n\t\t    if (kstat == 1)\n\t\t    {\n\t\t       /* Check parameter value of evt curves. */\n\n\t\t       if ((kcrv1 &&\n\t\t\t   (up[0]->epar[0] < qpt->epar[0] &&\n\t\t\t    qpt->epar[0] < up[1]->epar[0])) ||\n\t\t\t   (up[1]->epar[0] < qpt->epar[0] &&\n\t\t\t    qpt->epar[0] < up[0]->epar[0])) kcrv1 = -1;\n\n\t\t       if ((kcrv2 &&\n\t\t\t   (up[0]->epar[po1->iobj] < qpt->epar[po1->iobj] &&\n\t\t\t    qpt->epar[po1->iobj] < up[1]->epar[po1->iobj])) ||\n\t\t\t   (up[1]->epar[po1->iobj] < qpt->epar[po1->iobj] &&\n\t\t\t     qpt->epar[po1->iobj] < up[0]->epar[po1->iobj]))\n\t\t\t  kcrv2 = -1;\n\n\t\t       if (kcrv1 < 1 && kcrv2 < 1)\n\t\t       {\n\n\t\t\t  /* The point lies inside the coincidence curve.\n\t\t\t     Place it between the endpoints of the curve. */\n\n\t\t\t  sh6tomain(qpt,&kstat);\n\t\t\t  sh6insertpt(up[0],up[1],qpt,&kstat);\n\t\t\t  if (kstat < 0) goto error;\n\t\t\t}\n\t\t     }\n\t\t }\n\n\t    }\n\t}\n      else if (knum > 2 && !(po1->iobj == SISLSURFACE &&\n\t\t\t     po2->iobj == SISLSURFACE))\n      {\n\t /* There is more than two edge intersection and it is no\n\t    surface - surface intersection. Check if the edge\n\t    intersections are already connected. */\n\n\t sh6floop(up, knum, &kpt2, &kstat);\n\t if (kpt2 == knum)\n\t    /* All edge intersections lie in one loop.  */\n\n\t    *jstat = 1;\n\t else\n\t {\n\t    /* Check if (one of) the curve(s) lies entirely in an\n\t       intersection curve found at an edge.  */\n\n\t    if (po1->iobj == SISLCURVE)\n\t    {\n\t       for (qpt1=vedge[0]->prpt[0]; qpt1!=SISL_NULL; qpt1=qpt1->pnext)\n\t       {\n\t\t  for (qpt2=vedge[0]->prpt[1]; qpt2!=SISL_NULL; qpt2=qpt2->pnext)\n\t\t  {\n\t\t     /* UJK, aug 93, oo-loop in sh6isconn, BEOrd20786. */\n\t\t     int is_conn,kcount;\n\t\t     is_conn = sh6isconnect(SISL_NULL, qpt1->ppt, qpt2->ppt);\n\t\t     for (kcount = 0;kcount<(*pintdat)->ipoint;kcount++)\n\t\t\t(*pintdat)->vpoint[kcount]->marker = 0;\n\n\t\t     if (is_conn) break;\n\t\t  }\n\t\t  if (qpt2 != SISL_NULL) break;\n\t       }\n\n\t       if (qpt1 != SISL_NULL && qpt2 != SISL_NULL) *jstat = 1;\n\t       else *jstat = 0;\n\t    }\n\t    if (*jstat != 1 && po2->iobj == SISLCURVE)\n\t    {\n\t       for (qpt1=vedge[1]->prpt[0]; qpt1!=SISL_NULL; qpt1=qpt1->pnext)\n\t       {\n\t\t  for (qpt2=vedge[1]->prpt[1]; qpt2!=SISL_NULL; qpt2=qpt2->pnext)\n\t\t  {\n\t\t     /* UJK, aug 93, oo-loop in sh6isconn, BEOrd20786. */\n\t\t     int is_conn,kcount;\n\t\t     is_conn = sh6isconnect(SISL_NULL, qpt1->ppt, qpt2->ppt);\n\t\t     for (kcount = 0;kcount<(*pintdat)->ipoint;kcount++)\n\t\t\t(*pintdat)->vpoint[kcount]->marker = 0;\n\n\t\t     if (is_conn) break;\n\t\t  }\n\n\t\t  if (qpt2 != SISL_NULL) break;\n\t       }\n\n\t       if (qpt1 != SISL_NULL && qpt2 != SISL_NULL) *jstat = 1;\n\t       else *jstat = 0;\n\t    }\n\t }\n      }\n    }\n\n  goto out;\n\n  /* Error in subroutines      */\n\nerror:*jstat = kstat;\n  s6err (\"sh1762_s9con\", *jstat, 0);\n  goto out;\n\nout:\n  if (up != SISL_NULL)\n    freearray (up);\n\n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1762_s9intercept (SISLObject * po1, SISLObject * po2, double aepsge,\n\t\t    int inmbpt, SISLIntpt * vintpt[], int *jstat)\n#else\nstatic void\nsh1762_s9intercept (po1, po2, aepsge, inmbpt, vintpt, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     int inmbpt;\n     SISLIntpt *vintpt[];\n     int *jstat;\n#endif\n /*\n *********************************************************************\n *\n *********************************************************************\n *\n * PURPOSE    : If there is less than two intersections between two\n *              objects, use rotated box tests to check if more\n *              intersections are possible.\n *\n *\n *\n * INPUT      : po1      - The first object to check.\n *              po2      - The second object to check.\n *              aepsge   - Geometrical resolution.\n *              inmbpt   - Number of intersections found on the edges.\n *              vintpt   - The intersections at the edges.\n *                         Dimension of pointer array is inmbpt.\n *              *jstat    - Flag\n*                          = 202 : Complicated point-surface intersection\n*                                  in 3D. Perform extra interception test.\n*\n *\n *\n * OUTPUT     :\n *              jstat    - status messages\n *                           = 3     : Simple case encountered\n *                           = 2     : No intersection..\n *                           = 1     : Coinside found.\n *                           = 0     : no coinside.\n *                           < 0     : error\n *\n *\n * METHOD     :\n *\n *\n * REFERENCES :\n *\n * CALLS      : s1221  - Evaluation of B-spline curve.\n *              sh1830  - Improved box test between curve and surface.\n *              sh1834  - Rotated box test.\n *              sh1839  - Improved box test between surface and object.\n *              s6testimpl - Implicitization with box test and simple case test\n *\n * WRITTEN BY : Arne Laksaa, SI, 89-05.\n * REWRITTEN BY : Vibeke Skytt, SI, 91-01.\n *\n *********************************************************************\n */\n{\n  int kstat = 0;\t\t/* Status variable.               */\n  int kdim;\t\t\t/* Dimension of geometry space.   */\n  int kleft = 0;\t\t/* Parameter to curve evaluation. */\n  int kleft2 = 0;               /* Parameter to evaluator.        */\n  int incr, ind;\t\t/* indexes and loop control       */\n  int ratflag = 0;              /* Indicates if rational object.  */\n  int kxintercept = (*jstat == 202);  /* Extra interception       */\n  double tepsge;                /* Local tolerance in 1D box test. */\n  double testpar[2];\t\t/* Par val when treating help p.  */\n  double trad;                  /* Radius of geometry object.     */\n  double spar[2];               /* Parameter pair of surface.     */\n  double scentre[3];            /* Centre of sphere of cylinder.  */\n  double sder1[9];\t\t/* Value and derivative of object.  */\n  double sder2[9];\t\t/* Pointer to value of second object.*/\n  double snorm1[3];             /* Normal to first surface.       */\n  double snorm2[3];             /* Normal to second surface.      */\n  double splitgeom[16];         /* Matrix description of a sphere\n\t\t\t\t   or cylinder.                   */\n  SISLSurf *qs1=SISL_NULL;           /* B-spline surface put into sphere\n\t\t\t\t   or cylinder equation.          */\n  SISLSurf *qs2=SISL_NULL;           /* B-spline surface put into sphere\n\t\t\t\t   or cylinder equation.          */\n  SISLCurve *qc=SISL_NULL;           /* B-spline curve put into sphere\n\t\t\t\t   equation.                      */\n  SISLCurve *qc2=SISL_NULL;           /* B-spline curve put into sphere\n\t\t\t\t   equation.                      */\n  SISLPoint *pp1=SISL_NULL;\n  SISLObject *qobjs;\t\t/* Pointer to surface object.     */\n  SISLObject *qobjc;\t\t/* Pointer to curve object.       */\n  int isbez1 = 0, isbez2 = 2;\n\n  /*   long time_before;\n  long time_used = 0;  */\n\n  /* Test number of found intersection points.  */\n\n  /* VSK, 01/93. if (inmbpt > 1 || inmbpt < 0)\n    goto err128; */\n\n  *jstat = 0;\n\n  if (po1->iobj == SISLSURFACE && po2->iobj == SISLSURFACE)\n    {\n       kdim = po1->s1->idim;\n\n      /*      rotate_nmb++;\n      time_before = clock(); */\n\n       if (inmbpt == 0)\n       {\n\t  /* No intersections at the edges.  */\n\n\t  if (xc % 2 == 0)\n\t  {\n\t     sh1839 (po1, po2, aepsge, &kstat);\n\t     if (kstat < 0)\n\t\tgoto error;\n\t  }\n\t  else\n\t  {\n\t     sh1839 (po2, po1, aepsge, &kstat);\n\t     if (kstat < 0)\n\t\tgoto error;\n\t  }\n\t  /*   time_used = clock() - time_before; */\n\n\t  if (kstat == 1)\n\t  {\n\t     if (xc % 2 == 0)\n\t     {\n\t\tsh6findsplit(po1->s1, po2->s1, aepsge, &kstat);\n\t\tif (kstat < 0) goto error;\n\t     }\n\t     else\n\t     {\n\t\tsh6findsplit(po2->s1, po1->s1, aepsge, &kstat);\n\t\tif (kstat < 0) goto error;\n\t     }\n\t  }\n\n\t  if (kstat == 0 || kstat == 2)\n\t  {\n\t     *jstat = 2;\n\t     goto out;\n\t  }\n\n       }\n       \n       if (inmbpt == 1 && kdim == 3)\n\t {\n\t   double tang, len;\n\t   double spos[3], snorm[3];\n\t   int sgn = 1;\n\t   int ki;\n\t   \n\t   /* Check if the intersection point is singular */\n\t  s1421(po1->s1,1,vintpt[0]->epar,&kleft,&kleft2,sder1,snorm1,&kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  s1421(po2->s1,1,vintpt[0]->epar+2,&kleft,&kleft2,sder2,snorm2,&kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  tang = s6ang(snorm1, snorm2, kdim);\n\t  tang = min(tang, M_PI-tang);\n\t  if (tang < ANGULAR_TOLERANCE)\n\t    {\n\t      /* Try to intercept with a plane */\n\t      if (s6scpr(snorm1, snorm2, kdim) < 0.0)\n\t\tsgn = -1;\n\t      for (ki=0; ki<3; ++ki)\n\t\t{\n\t\t  spos[ki] = 0.5*(sder1[ki] + sder2[ki]);\n\t\t  snorm[ki] = 0.5*(snorm1[ki] + sgn*snorm2[ki]);\n\t\t}\n\t      len = s6norm(snorm, kdim, snorm, &kstat);\n\t      if (kstat == 1)\n\t\t{\n\t\t  s1329(po1->s1, spos, snorm, kdim, &qs1, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t  s1329(po2->s1, spos, snorm, kdim, &qs2, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\n\t\t  /* Make 1D boxes */\n\t\t  sh1992su(qs1,0,aepsge,&kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n      \n\t\t  sh1992su(qs2,0,aepsge,&kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\n\t\t  /*if (qs1) freeSurf(qs1);\n\t\t  qs1 = NULL;\n\t\t  if (qs2) freeSurf(qs2);\n\t\t  qs2 = NULL;*/\n\t\t    \n\t\t  /* Check if the boxes overlap.  */\n      \n\t\t  if (qs1->pbox->e2min[0][0] > qs2->pbox->e2max[0][0] ||\n\t\t      qs1->pbox->e2max[0][0] < qs2->pbox->e2min[0][0])\n\t\t    {\n\t\t      /* No intersection is possible.  */\n\t\t      *jstat = 2;\n\t\t      goto out;\n\t\t    }\n\t\t}\n\n\t      \n\t    }\n\t }\n       \n       if (inmbpt >= 1)\n       {\n\t  /* Evaluate the surfaces in the first intersection point, and\n\t     use the partial derivatives in this point as rotation axises. */\n\n\t  s1421(po1->s1,1,vintpt[0]->epar,&kleft,&kleft2,sder1,snorm1,&kstat);\n\t  if (kstat < 0) goto error;\n\n\t  s1421(po2->s1,1,vintpt[0]->epar+2,&kleft,&kleft2,sder2,snorm2,&kstat);\n\t  if (kstat < 0) goto error;\n\n\t  sh1834(po1,po2,aepsge,kdim,sder1+kdim,sder1+2*kdim,&kstat);\n\t  if (kstat < 0) goto error;\n\n\t  if (kstat == 1 &&\n\t      fabs(s6ang(sder1+kdim,sder1+2*kdim,kdim) - PIHALF) > ANGULAR_TOLERANCE)\n\t  {\n\t     sh1834(po1,po2,aepsge,kdim,sder1+2*kdim,sder1+kdim,&kstat);\n\t     if (kstat < 0) goto error;\n\t  }\n\n\t  if (kstat == 1 &&\n\t      s6ang(sder1+kdim,sder2+kdim,kdim) > ANGULAR_TOLERANCE &&\n\t      s6ang(sder1+2*kdim,sder2+kdim,kdim) > ANGULAR_TOLERANCE)\n\t  {\n\t     sh1834(po1,po2,aepsge,kdim,sder2+kdim,sder2+2*kdim,&kstat);\n\t     if (kstat < 0) goto error;\n\t  }\n\n\t  if (kstat == 1 &&\n\t      fabs(s6ang(sder2+kdim,sder2+2*kdim,kdim) - PIHALF) > ANGULAR_TOLERANCE &&\n\t      s6ang(sder1+kdim,sder2+2*kdim,kdim) > ANGULAR_TOLERANCE &&\n\t      s6ang(sder1+2*kdim,sder2+2*kdim,kdim) > ANGULAR_TOLERANCE)\n\n\t  {\n\t     sh1834(po1,po2,aepsge,kdim,sder2+2*kdim,sder2+kdim,&kstat);\n\t     if (kstat < 0) goto error;\n\t  }\n\n\t  if (kstat == 0 || kstat == 2)\n\t  {\n\t     *jstat = 2;\n\t     goto out;\n\t  }\n\n       }\n\n      /* If we got here, additional intersections are still possible.\n\t Try implicitization. */\n       isbez1 = (po1->s1->ik1 == po1->s1->in1 && po1->s1->ik2 == po1->s1->in2);\n       isbez2 = (po2->s1->ik1 == po2->s1->in1 && po2->s1->ik2 == po2->s1->in2);\n       if (isbez1 && isbez2)\n\t {\n\t   s6testimpl(po1->s1, po2->s1, (xc%2==0), \n\t\t      vintpt, inmbpt, aepsge, &kstat);\n\t   if (kstat < 0)\n\t     goto error;\n      \n\t   if (kstat == 0)\n\t     {\n\t       *jstat = 2;\n\t       goto out;\n\t     }\n\t   else if (kstat == 3)\n\t     {\n\t       *jstat = 3;\n\t       goto out;\n\t     }\n\t }\n    }\n  else if ((po1->iobj == SISLSURFACE && po2->iobj == SISLCURVE) ||\n\t   (po1->iobj == SISLCURVE && po2->iobj == SISLSURFACE))\n    {\n      /*We test if intersection is possible using\n\t rotated box tests. */\n\n      if (po1->iobj == SISLSURFACE)\n\t{\n\t  qobjs = po1;\n\t  qobjc = po2;\n\t}\n      else\n\t{\n\t  qobjs = po2;\n\t  qobjc = po1;\n\t}\n\n      /* Perform improved box-test.  */\n\n      /*   rotate_nmb++;\n      time_before = clock(); */\n\n      /* Improved box-test based on main tangent of curve and\n\t main normal of surface.     */\n\n      sh1830 (qobjs, qobjc, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      if (kstat == 1)\n\t{\n\t  sh1839 (qobjs, qobjc, aepsge, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n      /*\ttime_used = clock() - time_before; */\n      /*\n      if (kstat == 1)\n      {\n\t Try to separate the objects by a sphere.\n\n\t sh6sepgeom(qobjs->s1, qobjc->c1, aepsge, scentre, &trad, &kstat);\n\t if (kstat < 0) goto error;\n\n\t  If kstat = 0 is returned, no splitting geometry is found,\n\t    and no further interception is to be tried.\n\n\t if (kstat > 0)\n\t {\n\t    The splitting geometry object is a sphere.\n\t       Make a matrix of dimension (idim+1)x(idim+1) describing a hyper\n\t       sphere as an implicit function.\n\n\t    s1321(scentre,trad,qobjc->c1->idim,1,splitgeom,&kstat);\n\t    if (kstat < 0) goto error;\n\n\n\n\t    * Put the description of the surface and the curve into the\n\t    * implicit equation for the sphere.\n\t    * ----------------------------------------------------------\n\n\t    ratflag = (qobjs->s1->ikind == 2 || qobjs->s1->ikind == 4) ? 1 : 0;\n\t    s1320(qobjs->s1,splitgeom,1,ratflag,&qs1,&kstat);\n\t    if (kstat < 0) goto error;\n\n\t    ratflag = (qobjc->c1->ikind == 2 || qobjc->c1->ikind == 4) ? 1 : 0;\n\t    s1370(qobjc->c1,splitgeom,qobjc->c1->idim,1,ratflag,&qc,&kstat);\n\t    if (kstat < 0) goto error;\n\n\t     Set up local tolerance.\n\n\t    tepsge = (double)2.0*trad*aepsge;\n\n\t     Make box of 1D surface.\n\n\t    sh1992su(qs1,2,tepsge,&kstat);\n\t    if (kstat < 0) goto error;\n\n\t     Make box of 1D curve.\n\n\t    sh1992cu(qc,2,tepsge,&kstat);\n\t    if (kstat < 0) goto error;\n\n\t     Check if the boxes overlap.\n\n\t    if (qs1->pbox->e2min[2][0] > qc->pbox->e2max[2][0] ||\n\t\tqs1->pbox->e2max[2][0] < qc->pbox->e2min[2][0])\n\t    {\n\n\t       No intersection is possible.\n\n\t       *jstat = 2;\n\t       goto out;\n\t    }\n\t    else kstat = 1;   Mark possibility of intersection.\n\t }\n\t else kstat = 1;   Mark possibility of intersection.\n      } */\n\n      if (kstat == 0 || kstat == 2)\n\t{\n\t  *jstat = 2;\n\t  goto out;\n\t}\n    }\n  else if (po1->iobj == SISLCURVE && po2->iobj == SISLCURVE &&\n\t   2*po1->c1->ik >= po1->c1->in && 2*po2->c1->ik >= po2->c1->in)\n  {\n     double spoint[3];  /* Point in splitting plane. */\n     double snorm[3];   /* Normal to splitting plane. */\n     double sn1[3], sn2[3];\n     int ki;\n     double t1, t2;\n     int ksign;\n\n     /* Find dimension of geometry space. */\n\n     kdim = po1->c1->idim;\n     if (kdim != po2->c1->idim)\n\tgoto err106;\n\n     if (inmbpt == 1)\n     {\n\t/* One intersection point between two curves found. Find splitting\n\t   plane. */\n\t/* First allocate space for local arrays.  */\n\t/* NEWI, (ujk), Lets try to find a help point */\n\n\tincr = 0;\n\tif (DEQUAL (vintpt[0]->epar[0], po1->c1->et[po1->c1->ik - 1]))\n\t{\n\t   incr++;\n\t   testpar[0] = po1->c1->et[po1->c1->in];\n\t}\n\telse if (DEQUAL (vintpt[0]->epar[0], po1->c1->et[po1->c1->in]))\n\t{\n\t   incr++;\n\t   testpar[0] = po1->c1->et[po1->c1->ik - 1];\n\t}\n\n\tif (DEQUAL (vintpt[0]->epar[1], po2->c1->et[po2->c1->ik - 1]))\n\t{\n\t   incr++;\n\t   testpar[1] = po2->c1->et[po2->c1->in];\n\t}\n\telse if (DEQUAL (vintpt[0]->epar[1], po2->c1->et[po2->c1->in]))\n\t{\n\t   incr++;\n\t   testpar[1] = po2->c1->et[po2->c1->ik - 1];\n\t}\n\n\tif (incr == 2)\n\t   for (ind = 0; ind < vintpt[0]->no_of_curves; ind++)\n\t      if (sh6ishelp (vintpt[0]->pnext[ind]) &&\n\t\t  DEQUAL (vintpt[0]->pnext[ind]->epar[0], testpar[0]) &&\n\t\t  DEQUAL (vintpt[0]->pnext[ind]->epar[1], testpar[1]))\n\t      {\n\t\t *jstat = 2;\n\t\t goto out;\n\t      }\n\n\t/* Evaluate the curves in the intersection point.  */\n\n\ts1221 (po1->c1, 1, vintpt[0]->epar[0], &kleft, sder1, &kstat);\n\tif (kstat < 0)\n\t   goto error;\n\n\ts1221 (po2->c1, 1, vintpt[0]->epar[1], &kleft, sder2, &kstat);\n\tif (kstat < 0)\n\t   goto error;\n\n\t/* Normalize derivatives. */\n\n\tt1 = s6norm(sder1+kdim, kdim, sder1+kdim, &kstat);\n\tt2 = s6norm(sder2+kdim, kdim, sder2+kdim, &kstat);\n\tksign = (s6scpr(sder1+kdim, sder2+kdim, kdim) >\n\t\t DZERO) ? 1 : -1;\n\tfor (ki=0; ki<kdim; ki++)\n\t{\n\t   /* sder1[kdim+ki] *= t2;\n\t   sder2[kdim+ki] *= t1; */\n\t   spoint[ki] = (double)0.5*(sder1[ki] + sder2[ki]);\n\t   sn1[ki] = (double)0.5*(sder1[kdim+ki]+sder2[kdim+ki]);\n\t}\n\tif (kdim == 2)\n\t{\n\t   snorm[0] = sn1[1];   /* KYS 5/7-94: normal corrected */\n\t   snorm[1] = -sn1[0];\n\t}\n\telse if (kdim == 3)\n\t{\n\t   s6crss(sder1+kdim, sder2+kdim, sn2);\n\t   s6crss(sn1, sn2, snorm);\n\t}\n\t(void)s6norm(snorm, kdim, snorm, &kstat);\n\tif (!kstat) kstat = 1;\n\telse kstat = 0;\n     }\n     else if (inmbpt == 0 && po1->c1->pdir->aang < ANGULAR_TOLERANCE &&\n\t      po2->c1->pdir->aang < ANGULAR_TOLERANCE  &&\n\t      s6ang(po1->c1->pdir->ecoef,po1->c1->pdir->ecoef,kdim) <\n\t      (double)10*ANGULAR_TOLERANCE)\n     {\n\tdouble tpar2;\n\tSISLPoint *pt = SISL_NULL;\n\tdouble *s1, *s2, *s3, *s4;\n\n\ts1 = po1->c1->ecoef;\n\ts2 = po1->c1->ecoef+kdim*(po1->c1->in-1);\n\ts3 = po2->c1->ecoef;\n\ts4 = po2->c1->ecoef+kdim*(po2->c1->in-1);\n\n\t/* Evaluate midpoint of first curve. */\n\n\t/* tpar1 = (double)0.5*(po1->c1->et[po1->c1->ik-1] +\n\t   po1->c1->et[po1->c1->in]);\n\t   s1221 (po1->c1, 0, tpar1, &kleft, sder1, &kstat);\n\t   if (kstat < 0)\n\t   goto error; */\n\tif (MIN(s6dist(s1,s3,kdim),s6dist(s1,s4,kdim)) <\n\t    MIN(s6dist(s2,s3,kdim),s6dist(s2,s4,kdim)))\n\t   memcopy(sder1,s1,kdim,DOUBLE);\n\telse\n\t   memcopy(sder1,s2,kdim,DOUBLE);\n\n\t/* Find closest point on the other curve. */\n\n\tif ((pt = newPoint(sder1, kdim, 0)) == SISL_NULL) goto err101;\n\n\t/* tpar2 = (double)0.5*(po2->c1->et[po2->c1->ik-1] +\n\t   po2->c1->et[po2->c1->in]); */\n\tif (s6dist(s3,sder1,kdim) < s6dist(s4,sder1,kdim))\n\t   tpar2 = po2->c1->et[po2->c1->ik-1];\n\telse\n\t   tpar2 = po2->c1->et[po2->c1->in];\n\ts1771(pt, po2->c1, aepsge, po2->c1->et[po2->c1->ik-1],\n\t      po2->c1->et[po2->c1->in], tpar2, &tpar2, &kstat);\n\n\tif (pt) freePoint(pt);\n\tif (kstat < 0)\n\t   goto error;\n\n\ts1221 (po1->c1, 1, tpar2, &kleft, sder1, &kstat);\n\tif (kstat < 0)\n\t   goto error;\n\ts1221 (po2->c1, 1, tpar2, &kleft, sder2, &kstat);\n\tif (kstat < 0)\n\t   goto error;\n\n\t/* Let the splitting plane pass through the midpoint of the\n\t   points on the two curves and let the medium of the\n\t   axises of the direction cones of the curves lie in the\n\t   plane. */\n\n\t/* Normalize the tangents. */\n\n\tt1 = s6norm(sder1+kdim, kdim, sder1+kdim, &kstat);\n\tt2 = s6norm(sder2+kdim, kdim, sder2+kdim, &kstat);\n\tksign = (s6scpr(sder1+kdim, sder2+kdim, kdim) >\n\t\t DZERO) ? 1 : -1;\n\tfor (ki=0; ki<kdim; ki++)\n\t{\n\t   /* sder1[kdim+ki] *= t2;\n\t   sder2[kdim+ki] *= t1; */\n\t   spoint[ki] = (double)0.5*(sder1[ki] + sder2[ki]);\n\t   sn1[ki] = (double)0.5*(sder1[kdim+ki] +\n\t\t\t\t  (double)ksign*sder2[kdim+ki]);\n\t}\n\n\tif (kdim == 3)\n\t{\n\t   s6crss(sder1+kdim, sder2+kdim, sn2);\n\t   s6crss(sn1, sn2, snorm);\n\t}\n\telse\n\t{\n\t   snorm[0] = sn1[1]; /* KYS 5/7-94: normal corrected */\n\t   snorm[1] = -sn1[0];\n\t}\n\n\t(void)s6norm(snorm, kdim, snorm, &kstat);\n\tif (!kstat) kstat = 1;\n\telse kstat = 0;\n     }\n     else kstat = 1;\n\n\n     /* Try to intercept with the found plane. */\n\n     if (kstat == 0)\n     {\n\t/* nmb_rotated++; */\n       sh1831(po1->c1, po2->c1, 1, spoint, snorm, aepsge, &kstat);\n\tif (kstat < 0) goto error;\n     }\n\n     if (kstat == 0)\n     {\n\t/* nmb_succ_rotated++; */\n\t*jstat = 2;\n\tgoto out;\n     }\n\n\n     if (kstat == 1 && inmbpt == 0 && po1->c1->idim > 2)\n     {\n\t/* kstat = 1; */\t\t\t/* Make sure to subdivide further if there\n\t\t\t\t\t\t   is two curves and no intersection point. */\n\t/* Try to separate the objects by a sphere. */\n\n\t   if (xc % 2 == 0)\n\t   {\n\t      /* nmb_sep++; */\n\t      sh6sepcrv(po1->c1, po2->c1, aepsge, scentre, &trad, &kstat);\n\t      if (kstat < 0) goto error;\n\t   }\n\t   else\n\t   {\n\t      /* nmb_sep++; */\n\t      sh6sepcrv(po2->c1, po1->c1, aepsge, scentre, &trad, &kstat);\n\t      if (kstat < 0) goto error;\n\t   }\n\n\t/* If kstat = 0 is returned, no splitting geometry is found,\n\t   and no further interception is to be tried.  */\n\n\tif (kstat)\n\t{\n\t   /* The splitting geometry object is a sphere.\n\t      Make a matrix of dimension (idim+1)x(idim+1) describing a hyper\n\t      sphere as an implicit function.      \t      */\n\n\t   /* nmb_try_sep++; */\n\t   s1321(scentre,trad,po1->c1->idim,1,splitgeom,&kstat);\n\t   if (kstat < 0) goto error;\n\n\n\t   /*\n\t   * Put the description of the surface and the curve into the\n\t   * implicit equation for the sphere.\n\t   * ----------------------------------------------------------\n\t   */\n\n\t   ratflag = (po1->c1->ikind == 2 || po1->c1->ikind == 4) ? 1 : 0;\n\t   s1370(po1->c1,splitgeom,po1->c1->idim,1,ratflag,&qc,&kstat);\n\t   if (kstat < 0) goto error;\n\n\t   ratflag = (po2->c1->ikind == 2 || po2->c1->ikind == 4) ? 1 : 0;\n\t   s1370(po2->c1,splitgeom,po2->c1->idim,1,ratflag,&qc2,&kstat);\n\t   if (kstat < 0) goto error;\n\n\t   /* Set up local tolerance. */\n\n\t   tepsge = (double)2.0*trad*aepsge;\n\n\t   /* Make box of 1D surface. */\n\n\t   sh1992cu(qc,2,tepsge,&kstat);\n\t   if (kstat < 0) goto error;\n\n\t   /* Make box of 1D curve. */\n\n\t   sh1992cu(qc2,2,tepsge,&kstat);\n\t   if (kstat < 0) goto error;\n\n\t   /* Check if the boxes overlap.  */\n\n\t   if (qc2->pbox->e2min[2][0] > qc->pbox->e2max[2][0] ||\n\t       qc2->pbox->e2max[2][0] < qc->pbox->e2min[2][0])\n\t   {\n\n\t      /* No intersection is possible.  */\n\n\t      /* numb_succ_sep++; */\n\t      *jstat = 2;\n\t      goto out;\n\t   }\n\t   else kstat = 1;  /* Mark possibility of intersection.  */\n\t}\n\telse kstat = 1;\n     }\n     else kstat = 1;\n  }\n  else if ((po1->iobj == SISLSURFACE && po2->iobj == SISLPOINT &&\n\t   po2->p1->idim == 2) ||\n\t   (po2->iobj == SISLSURFACE && po1->iobj == SISLPOINT &&\n\t   po1->p1->idim == 2))\n  {\n     /* Compute the mid-parameter value of the surface. First set\n\tpointer to the surface.  */\n\n     if (po1->iobj == SISLSURFACE) qs1 = po1->s1;\n     else qs1 = po2->s1;\n\n     spar[0] = (double)0.5*(qs1->et1[qs1->ik1-1] + qs1->et1[qs1->in1]);\n     spar[1] = (double)0.5*(qs1->et2[qs1->ik2-1] + qs1->et2[qs1->in2]);\n\n     /* Evaluate the surface in the midpoint. */\n\n     s1421(qs1, 1, spar, &kleft, &kleft2, sder1, snorm1, &kstat);\n     if (kstat < 0) goto error;\n\n     if (s6ang(sder1+2, sder1+4, 2) < ANGULAR_TOLERANCE)\n     {\n\tspar[0] = (double)0.5*(sder1[2]+sder1[4]);\n\tspar[1] = (double)0.5*(sder1[3]+sder1[5]);\n\tsh1834(po1, po2, aepsge, 2, spar, sder1+4, &kstat);\n\tif (kstat < 0) goto error;\n\tif (kstat == 5) kstat = 0;   /* No 45 degree testing for rotated\n\t\t\t\t\tbox test meens no danger of\n\t\t\t\t\tintersection point near corner that\n\t\t\t\t\tis not caught by the box test. */\n     }\n     else kstat = 1;\n\n     qs1 = SISL_NULL;     /* Make sure that the input surface is not freed. */\n  }\n  else if (((po1->iobj == SISLSURFACE && po2->iobj == SISLPOINT &&\n\t   po2->p1->idim == 3) ||\n\t   (po2->iobj == SISLSURFACE && po1->iobj == SISLPOINT &&\n\t   po1->p1->idim == 3)) && kxintercept && xc > 7 && xc % 2 == 0)\n  {\n    if (po1->iobj == SISLSURFACE) \n      {\n\tqs1 = po1->s1;\n\tpp1 = po2->p1;\n      }\n    else \n      {\n\tqs1 = po2->s1;\n\tpp1 = po1->p1;\n      }\n    kdim = qs1->idim;\n\n    if (qs1->in1 > qs1->ik1 || qs1->in2 > qs1->ik2)\n      kstat = 1;\n    else\n      {\n\tint ind1, ind2, ind3;\n\tint kpt = 0;\n\tint kcrv = 0;\n\tdouble *spar = SISL_NULL;\n\tSISLIntcurve **ucurve = SISL_NULL;\n\tdouble eps = 0.001*aepsge;\n\n\t/* Find the closest points between the surface and the point */\n\ts1954(qs1, pp1->ecoef, qs1->idim, 0.0, eps, &kpt, &spar,\n\t      &kcrv, &ucurve, &kstat);\n\tif (kstat < 0)\n\t  goto error;\n\n\n\t/* Test distance between the closest points on the surface and\n\t   the point  */\n\tfor (ind1=0; ind1<kpt; ind1++)\n\t  {\n\t    s1421(qs1, 0, spar+2*ind1, &kleft, &kleft2, sder1, \n\t\t  snorm1, &kstat);\n\t    if (s6dist(pp1->ecoef, sder1, kdim) <= aepsge)\n\t      break;\n\t  }\n\n\tfor (ind2=0; ind2<kcrv; ind2++)\n\t  {\n\t    for (ind3=0; ind3<ucurve[ind2]->ipoint; ind3++)\n\t      {\n\t\ts1421(qs1, 0, ucurve[ind2]->epar1+2*ind3, &kleft, &kleft2, \n\t\t      sder1, snorm1, &kstat);\n\t\tif (s6dist(pp1->ecoef, sder1, kdim) <= aepsge)\n\t\t  break;\n\t      }\n\t    if (ind3 < ucurve[ind2]->ipoint)\n\t      break;\n\t  }\n\n\tif (ind1 < kpt || ind2 < kcrv)\n\t  kstat = 1;\n\telse kstat = 0;\n\n\t/* fprintf(stdout,\"%7.13f %7.13f %7.13f %7.13f \\n\",qs1->et1[0],\n\t\tqs1->et1[qs1->in1],qs1->et2[0],qs1->et2[qs1->in2]);\n\tfprintf(stdout,\"Point-srf : kstat = %d\\n\",kstat); */\n\n\tif (spar)\n\t  freearray(spar);\n\tif (ucurve)\n\t  freeIntcrvlist(ucurve, kcrv);\n      }\n    qs1 = SISL_NULL;\n  }  \n  else kstat = 1;\n\n\n  *jstat = (kstat == 0 || kstat == 2) ? 2 : ((kstat == 3) ? 3 : 0);\n  goto out;\n\n  /* Error in scratch allocation.  */\n\n  err101: *jstat = -101;\n  goto out;\n\n  /* Error in input. Confliciting dimensions.  */\n\nerr106:*jstat = -106;\n  goto out;\n\n  /* Wrong number of intersection points on edge.  */\n\n  /* err128:*jstat = -128;\n  goto out; */\n\n  /* Error in lower level routine.  */\n\nerror:*jstat = kstat;\n  goto out;\n\nout:\n   /* Free scratch used by 1D surfaces. */\n\n   if (qs1 != SISL_NULL) freeSurf(qs1);\n   if (qs2 != SISL_NULL) freeSurf(qs2);\n   if (qc != SISL_NULL) freeCurve(qc);\n   if (qc2 != SISL_NULL) freeCurve(qc2);\n\n  /*\trotate_box_time += time_used;\t */\n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1762_s9coincide (SISLObject * po1, SISLObject * po2, double aepsge,\n\t\t   int inmbpt, SISLIntpt * vintpt[], int *jstat)\n#else\nstatic void\nsh1762_s9coincide (po1, po2, aepsge, inmbpt, vintpt, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     int inmbpt;\n     SISLIntpt *vintpt[];\n     int *jstat;\n#endif\n /*\n *********************************************************************\n *\n *********************************************************************\n *\n * PURPOSE    : Check if one part of an object coincide in one part\n *              of an other object. Both object must intersect in two\n *              ends/edges.\n *\n *\n * INPUT      : po1      - The first SISLObject to check.\n *              po2      - The second SISLObject to check.\n *              aepsge   - Geometrical resolution.\n *              inmbpt   - Number of intersection points on edges (=2).\n *              vintpt   - Intersection points found on edges.\n *                         Dimension of pointer array is inmbpt.\n *              vedge[]  - SISLEdge intersection.\n *\n *\n * INPUT/OUTPUT:pintdat  - Intersection data.\n *\n *\n * OUTPUT     :\n *              jstat    - status messages\n *                           = 2     : No intersection..\n *                           = 1     : Coinside found.\n *                           = 0     : no coinside.\n *                           < 0     : error\n *\n *\n * METHOD     :\n *\n *\n * REFERENCES :\n *\n * CALLS      : s1221  - Evaluation of curve.\n *              s1421  - Evaluation of surface.\n *              s1785  - Test coincidence between curve and surface.\n *              s1786  - Test coincidence between two curves.\n *              sh6getlist - Check if two intersection points are already\n *                           connected.\n *\n *\n * WRITTEN BY : Arne Laksaa, SI, 89-05.\n * REVISED BY : Vibeke Skytt, SI, 91-01.\n * REVISED BY : Michael Floater, SI, 91-08.\n *                   Removed angle test.\n * REVISED BY : Vibeke Skytt, SINTEF Oslo, 94-11. Coincidence marching\n *                                                for 2D point - surface.\n *\n *********************************************************************\n */\n{\n  int kstat = 0;\t\t/* Status variable.                           */\n  int kdim;\t\t\t/* Dimension of geometry space.               */\n  int kcur;\t\t\t/* Indicates the curve in curve-surface\n\t\t\t\t   intersection.                              */\n  int kn;\t\t\t/* Counter.                                   */\n  int kleft1 = 0, kleft2 = 0;\t/* Parameters used in evaluation.           */\n  int kind1,kind2;              /* Dummy parameters to sh6getlist.            */\n  double tang;\t\t\t/* Angle between vectors.                     */\n  double *snorm;\t\t/* Pointer to surface normal.                 */\n  double *sder1 = SISL_NULL;\t\t/* Array containing position etc. of objects. */\n  double *sder2;\t\t/* Pointer to position of second object.      */\n  SISLSurf *qs;\t\t\t/* Pointer to surface.                        */\n  SISLCurve *qc;\t\t/* Pointer to curve.                          */\n  SISLPoint *qp;\n\n  if (inmbpt != 2)\n    goto err128;\n\n  if ((po1->iobj == SISLSURFACE && po2->iobj == SISLCURVE) ||\n      (po1->iobj == SISLCURVE && po2->iobj == SISLSURFACE))\n    {\n      /* We test coincidence for curve-surface. */\n\n       /* VSK, 10.92. First check if the points are already connected.     */\n\n       sh6getlist(vintpt[0],vintpt[1],&kind1,&kind2,&kstat);\n       if (kstat < 0) goto error;\n\n       if (kstat == 0)\n       {\n\t  /* The points are already connected.  */\n\n\t  *jstat = 1;\n\t  goto out;\n       }\n\n      if (po1->iobj == SISLSURFACE)\n\t{\n\t  qs = po1->s1;\n\t  qc = po2->c1;\n\t  kcur = 0;\n\t}\n      else\n\t{\n\t  qs = po2->s1;\n\t  qc = po1->c1;\n\t  kcur = 1;\n\t}\n\n      /* Allocate space for local arrays.  */\n\n      if ((sder1 = newarray (6 * qc->idim, double)) == SISL_NULL)\n\tgoto err101;\n      sder2 = sder1 + 2 * qc->idim;\n      snorm = sder2 + 3 * qc->idim;\n\n      for (kn = 0; kn < 2; kn++)\n\t{\n\t  /* We have to test if the curve and the surface\n\t     have coinciding derivatives in intersection ponts. */\n\n\t  s1221 (qc, 1, vintpt[kn]->epar[(kcur ? 0 : 2)], &kleft1, sder1, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  s1421 (qs, 1, vintpt[kn]->epar + kcur, &kleft1, &kleft2, sder2, snorm, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  else if (kstat > 0)\n\t    {\n\t      /* Singular point.  */\n\n\t      *jstat = 0;\n\t      goto out;\n\t    }\n/*\n\t  tang = s6ang (sder1 + qc->idim, snorm, qc->idim);\n\n\t  if (PIHALF - tang > ANGULAR_TOLERANCE)\n\t    {\n\t      *jstat = 0;\n\t      goto out;\n\t    }\n*/\n\t}\n      /* Removed the angle test. M.F. 30/8/91.  */\n      /* If the first derivatives are equal we call a routine\n\t to test further for coincidence.  */\n\n      s1785 (qc, qs, aepsge, vintpt[0]->epar, vintpt[1]->epar, kcur, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n    }\n  else if (po1->iobj == SISLCURVE && po2->iobj == SISLCURVE)\n    {\n      kdim = po1->c1->idim;\n      if (kdim != po2->c1->idim)\n\tgoto err106;\n\n      /* Test coincidence between two curves. First allocate\n\t space for local arrays.  */\n\n      if ((sder1 = newarray (8 * kdim, double)) == SISL_NULL)\n\tgoto err101;\n      sder2 = sder1 + 4 * kdim;\n\n      /* Evaluate the curves in the first intersection point.  */\n\n      s1221 (po1->c1, 1, vintpt[0]->epar[0], &kleft1, sder1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      s1221 (po2->c1, 1, vintpt[0]->epar[1], &kleft1, sder2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /* Evaluate the curves in the second intersection point.  */\n\n      s1221 (po1->c1, 1, vintpt[1]->epar[0], &kleft1, sder1 + (2 * kdim), &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      s1221 (po2->c1, 1, vintpt[1]->epar[1], &kleft2, sder2 + (2 * kdim), &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /* Test if the curves are parallel in the endpoints. */\n\n      tang = s6ang (sder1 + kdim, sder2 + kdim, kdim);\n\n      if (tang > ANGULAR_TOLERANCE)\n\t{\n\t  *jstat = 0;\n\t  goto out;\n\t}\n\n      tang = s6ang (sder1 + (3 * kdim), sder2 + (3 * kdim), kdim);\n\n      if (tang > ANGULAR_TOLERANCE)\n\t{\n\t  *jstat = 0;\n\t  goto out;\n\t}\n\n      s1786 (po1->c1, po2->c1, aepsge, vintpt[0]->epar, vintpt[1]->epar, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n    }\n  else if ((po1->iobj == SISLSURFACE && po2->iobj == SISLPOINT &&\n\t    po2->p1->idim >= 2) ||\n\t   (po2->iobj == SISLSURFACE && po1->iobj == SISLPOINT &&\n\t    po1->p1->idim >= 2))\n  {\n     if (po1->iobj == SISLSURFACE)\n     {\n\tqs = po1->s1;\n\tqp = po2->p1;\n     }\n     else\n     {\n\tqs = po2->s1;\n\tqp = po1->p1;\n     }\n\n     /* Allocate space for local arrays.  */\n\n     if ((sder1 = newarray (7 * qs->idim, double)) == SISL_NULL)\n\tgoto err101;\n     sder2 = sder1 + 3 * qs->idim;\n     snorm = sder2 + 3 * qs->idim;\n\n     /* Evaluate the surface in the intersection points at the edges. */\n\n     s1421 (qs, 1, vintpt[0]->epar, &kleft1, &kleft2, sder1, snorm, &kstat);\n     if (kstat < 0)\n\tgoto error;\n\n     s1421 (qs, 1, vintpt[1]->epar, &kleft1, &kleft2, sder2, snorm, &kstat);\n     if (kstat < 0)\n\tgoto error;\n\n     /* Test if this is a singular situation. */\n\n     if (s6ang(sder1+qs->idim, sder1+2*qs->idim, qs->idim) <= \n\t ANGULAR_TOLERANCE &&\n\t s6ang(sder2+qs->idim, sder2+2*qs->idim, qs->idim) <= \n\t ANGULAR_TOLERANCE)\n     {\n\t/* Perform marching to check if there is coincidence between\n\t   the intersection points. */\n\n\t /* fprintf(stdout,\"Try coincidence marching \\n\"); \n\t fprintf(stdout,\"%7.13f %7.13f %7.13f %7.13f \\n\",qs->et1[0],\n\t\t qs->et1[qs->in1],qs->et2[0],qs->et2[qs->in2]); */\n\n\ts1789(qp, qs, aepsge, vintpt[0]->epar, vintpt[1]->epar, &kstat);\n\tif (kstat < 0) goto error;\n\t /* fprintf(stdout,\"kstat = %d \\n\",kstat); */\n     }\n     else\n\tkstat = 0;   /* No coincidence. */\n  }\n\n  *jstat = kstat;\n  goto out;\n\n  /* Error in scratc allocation.  */\n\nerr101:*jstat = -101;\n  goto out;\n\n  /* Error in input. Conflicting dimensions.  */\n\nerr106:*jstat = -106;\n  goto out;\n\n  /* Wrong number of edge intersections found.  */\n\nerr128:*jstat = -128;\n  goto out;\n\n  /* Error in lower level routine.  */\n\nerror:*jstat = kstat;\n  goto out;\n\nout:\n\n  /* Free scratch occupied by local array.  */\n\n  if (sder1 != SISL_NULL)\n    freearray (sder1);\n\n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1762_s9toucharea (SISLObject * po1, SISLObject * po2, double aepsge,\n\t\t    int inmbpt, SISLIntpt * vintpt[], int *jstat)\n#else\nstatic void\nsh1762_s9toucharea (po1, po2, aepsge, inmbpt, vintpt, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     int inmbpt;\n     SISLIntpt *vintpt[];\n     int *jstat;\n#endif\n /*\n *********************************************************************\n *\n *********************************************************************\n *\n * PURPOSE    : Check if the intersection of two surfaces\n *              is a surface (a \"touch area\").\n *              Both objects must intersect in at least\n *              three ends or edges and all the intersection\n *              points must be linked in one closed list.\n *\n *\n * INPUT      : po1      - The first SISLObject to check.\n *              po2      - The second SISLObject to check.\n *              aepsge   - Geometrical resolution.\n *              inmbpt   - Number of intersection points on edges (>=3).\n *              vintpt   - Intersection points found on edges.\n *                         Dimension of pointer array is inmbpt.\n *                         VSK. The array is sorted.\n *              vedge[]  - SISLEdge intersection.\n *\n *\n * INPUT/OUTPUT:pintdat  - Intersection data.\n *\n *\n * OUTPUT     :\n *              jstat    - status messages\n *                           = 2     : No intersection..\n *                           = 1     : Coinside found.\n *                           = 0     : no coinside.\n *                           < 0     : error\n *\n *\n * METHOD     :\n *\n *\n * REFERENCES :\n *\n * CALLS      : s1421  - Evaluation of surface.\n *              s1773  - Closest point to a surface.\n *              s1436  - Pick a const. v curve from surface.\n *              s1437  - Pick a const. u curve from surface.\n *              sh1784 - Test coincidence between curve and surface.\n *\n *\n * WRITTEN BY : Vibeke Skytt, 9403.\n *              Note that this verions of coincidence testing between\n *              surfaces are a prelimenary one, not a final version.\n * Changed by : Per OEyvind Hvidsten, SINTEF, 11-94\n *              Added a goto out; at end (thus skipping err101).\n *\n *********************************************************************\n */\n{\n   int kstat = 0;         /* Local status variable. */\n   int kntest1, kntest2;  /* Number of locations to test coincidence in\n\t\t\t     both parameter directions.                 */\n   double tint1, tint2;   /* Parameter interval between testing spots.  */\n   int ki,kj;             /* Counters.                                  */\n   int kdim = po1->s1->idim; /* Dimension of geometry space.            */\n   double spar[2];        /* Parameter of testing spot.                 */\n   double sder1[3];       /* Position of first surface.                 */\n   double sder2[3];       /* Position of second surface.                */\n   double snorm1[3], snorm2[3];  /* Dummy normals of surface.           */\n   int kleft11 = 0, kleft12 = 0; /* Pointers into knot arrays of surface. */\n   int kleft21 = 0, kleft22 = 0; /* Pointers into knot arrays of surface. */\n   int kn11 = po1->s1->in1;\n   int kn12 = po1->s1->in2;\n   int kk11 = po1->s1->ik1;\n   int kk12 = po1->s1->ik2;\n   double *st11 = po1->s1->et1;\n   double *st12 = po1->s1->et2;\n   int kn21 = po2->s1->in1;\n   int kn22 = po2->s1->in2;\n   int kk21 = po2->s1->ik1;\n   int kk22 = po2->s1->ik2;\n   double *st21 = po2->s1->et1;\n   double *st22 = po2->s1->et2;\n   SISLPoint *pt = SISL_NULL;       /* Point in point surface iteration.       */\n   double sstart[2], send[2];  /* Parameter boundaries of second surface. */\n   double spar2[2];            /* Parameter value of second surface.      */\n   int at_boundary = 0;\n   /* int nmb_inner = 0; */\n\n   /* Set number of locations to test coincidence. */\n\n   kntest1 = 30*(kn11 - kk11 + 1);\n   kntest2 = 30*(kn12 - kk12 + 1);\n   tint1 = (st11[kn11] - st11[kk11-1])/(double)(kntest1+1);\n   tint2 = (st12[kn12] - st12[kk12-1])/(double)(kntest2+1);\n\n   /* Set parameter boundaries and midpoint of second surface. */\n\n   sstart[0] = st21[kk21-1];\n   sstart[1] = st22[kk22-1];\n   send[0] = st21[kn21];\n   send[1] = st22[kn22];\n   spar2[0] = (double)0.5*(sstart[0] + send[0]);\n   spar2[1] = (double)0.5*(sstart[1] + send[1]);\n\n   for (spar[0]=st11[kk11-1]+tint1, ki=0; ki<kntest1; ki++, spar[0]+=tint1)\n   {\n      for (spar[1]=st12[kk12-1]+tint2, kj=0; kj<kntest2; kj++, spar[1]+=tint2)\n      {\n\tat_boundary = 0;\n\t\n\t /* Evaluate first surface. */\n\n\t s1421(po1->s1, 0, spar, &kleft11, &kleft12, sder1, snorm1, &kstat);\n\t if (kstat < 0) goto error;\n\n\t /* Find closest point on the other surface. */\n\n\t if ((pt =  newPoint(sder1, kdim, 0)) == SISL_NULL) goto err101;\n\n\t s1773(pt, po2->s1, aepsge, sstart, send, spar2, spar2, &kstat);\n\t if (kstat < 0) goto error;\n\n\t /* Check if the closest point is found on a surface boundary. */\n\t if (DEQUAL(spar2[0], po2->s1->et1[po2->s1->ik1-1]) ||\n\t     DEQUAL(spar2[0], po2->s1->et1[po2->s1->in1]) ||\n\t     DEQUAL(spar2[1], po2->s1->et2[po2->s1->ik2-1]) ||\n\t     DEQUAL(spar2[1], po2->s1->et2[po2->s1->in2]))\n\t   at_boundary = 1;\n\t /* else\n\t    nmb_inner++; */\n\n\t /* Evalutate second surface. */\n\n\t s1421(po2->s1, 0, spar2, &kleft21, &kleft22, sder2, snorm2, &kstat);\n\t if (kstat < 0) goto error;\n\n\t if (pt != SISL_NULL) freePoint(pt);\n\t pt = SISL_NULL;\n\n\t /* Check distance between the closest points. */\n\n\t if (s6dist(sder1, sder2, kdim) > aepsge && (!at_boundary)) \n\t   break;  /* Not a coincidence.*/\n      }\n      if (kj < kntest2) break;  /* Not a coincidence. */\n   }\n\n   *jstat = (ki==kntest1 && kj==kntest2 /* && nmb_inner>0 */) ? 1 : 0;\n   goto out;\n\n   err101 : *jstat = -101;    /* Error in scratch allocation. */\n   goto out;\n\n   error : *jstat = kstat;    /* Error in lower level function. */\n   goto out;\n\n   out:\n      if (pt != SISL_NULL) freePoint(pt);\n\n      return;\n}\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns9edgsscon_eval(SISLSurf *ps1, SISLSurf *ps2, SISLIntpt **uipt, unsigned char *edg,\n\t\tint kn1, int isimple, double *eval, double *edist, double *dirval,\n\t\tint* ndir, int *jstat)\n#else\nstatic void\n  s9edgsscon_eval(ps1, ps2, uipt, edg, kn1, isimple, eval, edist, dirval, ndir, jstat)\n     SISLSurf *ps1;\n     SISLSurf *ps2;\n     SISLIntpt **uipt;\n     unsigned char *edg;\n     int kn1;\n     int isimple;\n     double *eval;\n     double *edist;\n     double *dirval;\n     int* ndir;\n     int *jstat;  \n#endif\n /*\n *********************************************************************\n *\n *********************************************************************\n *\n * PURPOSE    : Evaluate intersection point properties for use in\n *              connecting intersection points into curves\n *\n *\n *\n * INPUT      : ps1      - First surface in intersection.\n *              ps2      - Second surface in intersection.\n *              uipt     - Array of intersection points\n *              edg      - The edge associated with the intersection points\n *              kn1      - Number of intersection points\n *              isimple  - = 1: The direction of the intersection curve can\n *                              be deduced\n *\n * OUTPUT     : eval     - Points and tangents in intersection points\n *              edist    - Distance between surfaces at intersection points\n *              dirval   - Sorting parameter for intersection points if a\n *                         direction is available\n *              ndir     - Status value for the intersection points\n *                         0 - The intersect.curve is parallel to one par. dir.\n *\t\t\t   1 - The intersect.curve has direction into the domain.\n *\t\t\t   -1 - The intersect.curve has direction out of the domain.\n *\t\t\t    2 - The point is singulear.\n *\t\t\t    10 - The intersect.curve touch one corner of the domain.\n *              jstat    - status messages\n *                           = 0     : OK.\n *                           < 0     : error\n *\n *\n * METHOD     :\n *\n *\n * REFERENCES :\n *\n *\n * WRITTEN BY : Arne Laksaa, SI, 89-06.\n * ADAPTED BY: Vibeke Skytt, SINTEF, 2023-06.\n *\n *********************************************************************\n */\n{\n  int kstat = 0;\n  int ki, kj, kpar;\n  int klfs = 0, klft = 0;\n  double sval1[30];\n  double *snorm1 = sval1 + 9;\n  double *sdec1 = snorm1 + 3;\n  double *sval2 = sval1 + 12;\n  double *snorm2 = sval2 + 9;\n  double *sdec2 = snorm2 + 3;\n  double *stang;\n  double svec[3];\n  double tang;\n  int kdir;\n  double tolpar = (double)0.001;\n  \n  if (isimple == 1 && ps1->pdir && ps2->pdir)\n    {\n      s6crss(ps1->pdir->ecoef, ps2->pdir->ecoef, svec);\n      s6norm(svec, 3, svec, &kstat);\n    }\n  else\n    svec[0] = svec[1] = svec[2] = 0.0;\n\n  for (ki = 0; ki < kn1; ki++)\n    {\n      klfs = klft = 0;\n      s1421 (ps1, 1, uipt[ki]->epar, &klfs, &klft, sval1, snorm1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      else if (kstat > 0)\n\t{\n\t  ndir[ki] = 2;\n\t  continue;\n\t}\n\n      klfs = klft = 0;\n      s1421 (ps2, 1, uipt[ki]->epar + 2, &klfs, &klft, sval2, snorm2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      else if (kstat > 0)\n\t{\n\t  ndir[ki] = 2;\n\t  continue;\n\t}\n\n      for (kj=0; kj<3; ++kj)\n\teval[6*ki+kj] = 0.5*(sval1[kj] + sval2[kj]);\n      dirval[ki] = eval[6*ki]*svec[0] + eval[6*ki+1]*svec[1] + eval[6*ki+2]*svec[2];\n      edist[ki] = s6dist(sval1, sval2, 3);\n      tang = s6ang (snorm1, snorm2, 3);\n      if (tang < REL_PAR_RES)\n\t{\n\t  ndir[ki] = 2;\n\t  continue;\n\t}\n\n      stang = &eval[6*ki+3];\n      s6crss (snorm1, snorm2, stang);\n\n      s6decomp (stang, sdec1, sval1+3, sval1+6, snorm1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      else if (kstat > 0)\n\t{\n\t  ndir[ki] = 2;\n\t  continue;\n\t}\n\n\n      s6decomp (stang, sdec2, sval2+3, sval2+6, snorm2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      else if (kstat > 0)\n\t{\n\t  ndir[ki] = 2;\n\t  continue;\n\t}\n\n      for (kpar = 1, kj = 0; kj < 8; kj++)\n\tif ((edg[ki] & 1 << kj) == 1 << kj)\n\t  {\n\t    switch (kj)\n\t      {\n\t      case 0:\n\t\ttang = s6ang (stang, sval1+3, 3);\n\t\tkdir = (sdec1[1] > DZERO ? 1 : -1);\n\t\tbreak;\n\t      case 4:\n\t\ttang = s6ang (stang, sval2+3, 3);\n\t\tkdir = (sdec2[1] > DZERO ? 1 : -1);\n\t\tbreak;\n\t      case 1:\n\t\ttang = s6ang (stang, sval1+6, 3);\n\t\tkdir = (sdec1[0] > DZERO ? -1 : 1);\n\t\tbreak;\n\t      case 5:\n\t\ttang = s6ang (stang, sval2+6, 3);\n\t\tkdir = (sdec2[0] > DZERO ? -1 : 1);\n\t\tbreak;\n\t      case 2:\n\t\ttang = s6ang (stang, sval1+3, 3);\n\t\tkdir = (sdec1[1] > DZERO ? -1 : 1);\n\t\tbreak;\n\t      case 6:\n\t\ttang = s6ang (stang, sval2+3, 3);\n\t\tkdir = (sdec2[1] > DZERO ? -1 : 1);\n\t\tbreak;\n\t      case 3:\n\t\ttang = s6ang (stang, sval1+6, 3);\n\t\tkdir = (sdec1[0] > DZERO ? 1 : -1);\n\t\tbreak;\n\t      case 7:\n\t\ttang = s6ang (stang, sval2+6, 3);\n\t\tkdir = (sdec2[0] > DZERO ? 1 : -1);\n\t      }\n\n\t    if (tang < tolpar)\n\t      kdir = 0;\n\t    /* if (tang < REL_PAR_RES)\n\t       kdir = 0; */\n\t    /*  if (tang < ANGULAR_TOLERANCE) kdir = 0;*/\n\t    if (kdir == 0)\n\t      kpar = 0;\n\t    else if (ndir[ki] != kdir)\n\t      {\n\t\tif (ndir[ki] == 0)\n\t\t  ndir[ki] = kdir;\n\t\telse\n\t\t  {\n\t\t    ndir[ki] = 10;\n\t\t    break;\n\t\t  }\n\t      }\n\t  }\n      if (kpar == 0 && ndir[ki] != 10)\n\tndir[ki] = 0;\n    }\n  goto out;\n\n error : *jstat = kstat;    /* Error in lower level function. */\n  goto out;\n\n out:\n  return;\n}\n\n\f\n\n \n#if defined(SISLNEEDPROTOTYPES)\nstatic void s9edgsscon_simplify(SISLIntdat *rintdat, SISLIntpt **uipt,\n\t\t\t\tunsigned char *edg, int *kn1,\n\t\t\t\tdouble *eval, double *edist, double *dirval,\n\t\t\t\tint *ndir, double aepsge, int *jstat)\n#else\n  static void s9edgsscon_simplify(rintdat, uipt, edg, kn1, eval, edist, dirval, ndir, \n\t\t\t\t  aepsge, jstat)\n     SISLIntdat *rintdat;\n     SISLIntpt **uipt;\n     unsigned char *edg;\n     int *kn1;\n     double *eval;\n     double *edist;\n     double *dirval;\n     int *ndir;\n     double aepsge;\n     int *jstat;\n#endif\n /*\n *********************************************************************\n *\n *********************************************************************\n *\n * PURPOSE    : Simplify intersection point configuration in an unclear\n *              situation\n *\n * INPUT      : uipt     - Array of intersection points\n *              kn1      - Number of intersection points\n *\n * OUTPUT     :  jstat    - status messages\n *                           = 0     : Simplified\n *                           = 1     : Not changed\n *                           < 0     : error\n *\n * WRITTEN BY: Vibeke Skytt, SINTEF, 2023-06.\n *\n *********************************************************************\n */\n{\n  int kstat = 0;\n  int kr, ki, kj, kh;\n  int kv;\n  int code[3];\n  int knn, khelp;\n  int kcon1, kcon2;\n  SISLIntpt *qother = SISL_NULL;\n  code[0] = -1;\n  code[1] = 1;\n  code[2] = 0;\n  \n  /* Count occurances of classified points */\n  for (kr=0; kr<2; ++kr)\n    {\n      knn = khelp = 0;\n      for (ki=0, kv=0; ki < (*kn1); ki++)\n\t{\n\t  if (ndir[ki] < 10)\n\t    kv++;\n\t  if (ndir[ki] == code[kr])\n\t    {\n\t      knn++;\n\t      if (uipt[ki]->fromhelp)\n\t\tkhelp++;\n\t    }\n\t}\n      if (knn > 1 && khelp > 0)\n\t{\n\t  /* Check if one point has more than one representation */\n\t  for (ki=0; ki<(*kn1); ++ki)\n\t    {\n\t      int ix = -1;\n\t      if (ndir[ki] != code[kr])\n\t\tcontinue;\n\t      for (kj=ki+1; kj<(*kn1); ++kj)\n\t\t{\n\t\t  if (ndir[kj] != code[kr])\n\t\t    continue;\n\t\t  kcon1 = s9edgsscon_con(uipt[ki], uipt[kj]);\n\t\t  qother = s9edgsscon_samecon(uipt[ki], uipt[kj]);\n\t\t  kcon2 = (qother != SISL_NULL);\n\t\t  if ((kcon1 || kcon2) && (edg[ki] & edg[kj]))\n\t\t    {\n\t\t      /* Possible dual representation */\n\t\t      /* Check if a point lies in the corner */\n\t\t      int kc1 = 0, kc2 = 0, kc3 = 0, kc4 = 0;\n\t\t      int nmain1, nmain2;\n\t\t      int kdum;\n\t\t      double tdum;\n\t\t      SISLIntpt *qdum;\n\t\t      unsigned int kdum2;\n\t\t      for (kh=0; kh<4; ++kh)\n\t\t\t{\n\t\t\t  if (edg[ki] & (1 << kh))\n\t\t\t    kc1++;\n\t\t\t  if (edg[kj] & (1 << kh))\n\t\t\t    kc2++;\n\t\t\t}\n\t\t      for (kh=4; kh<8; ++kh)\n\t\t\t{\n\t\t\t  if (edg[ki] & (1 << kh))\n\t\t\t    kc3++;\n\t\t\t  if (edg[kj] & (1 << kh))\n\t\t\t    kc4++;\n\t\t\t}\n\t\t      kc1 = max(kc1, kc3);\n\t\t      kc2 = max(kc2, kc4);\n\t\t      nmain1 = sh6nmbmain(uipt[ki], &kstat);\n\t\t      nmain2 = sh6nmbmain(uipt[kj], &kstat);\n\t\t      nmain1 -= (kcon1+kcon2);\n\t\t      nmain2 -= (kcon1+kcon2);\n\t\t      if (kc1 < 2 && kc2 >= 2 && nmain1 <= 1 && uipt[ki]->fromhelp)\n\t\t\tix = ki;\n\t\t      else if (kc2 < 2 && kc1 >= 2 && nmain2 <= 1 && uipt[kj]->fromhelp)\n\t\t\tix = kj;\n\t\t      else if (edist[ki] > edist[kj] && nmain1 <= 1 && uipt[ki]->fromhelp)\n\t\t\tix = ki;\n\t\t      else if (edist[kj] >= edist[ki] && nmain2 <= 1 && uipt[kj]->fromhelp)\n\t\t\tix = kj;\n\n\t\t      if (ix >= 0)\n\t\t\t{\n\t\t\t  /* Kill dual point */\n\t\t\t  sh6idkpt (&rintdat, &uipt[ix], 1, &kstat);\n\t\t\t  if (kstat < 0)\n\t\t\t    goto error;\n\n\t\t\t  /* Remove point info from arrays */\n\t\t\t  if (ix < *kn1-1)\n\t\t\t    {\n\t\t\t      qdum = uipt[ix];\n\t\t\t      uipt[ix] = uipt[*kn1-1];\n\t\t\t      uipt[*kn1-1] = qdum;\n\t\t\t      kdum = ndir[ix];\n\t\t\t      ndir[ix] = ndir[*kn1-1];\n\t\t\t      ndir[*kn1-1] = ndir[ix];\n\t\t\t      kdum2 = edg[ix];\n\t\t\t      edg[ix] = edg[*kn1-1];\n\t\t\t      edg[*kn1-1] = kdum2;\n\t\t\t      tdum = edist[ix];\n\t\t\t      edist[ix] = edist[*kn1-1];\n\t\t\t      edist[*kn1-1] = tdum;\n\t\t\t      tdum = dirval[ix];\n\t\t\t      dirval[ix] = dirval[*kn1-1];\n\t\t\t      dirval[*kn1-1] = tdum;\n\t\t\t      for (kh=0; kh<6; ++kh)\n\t\t\t\t{\n\t\t\t\t  tdum = eval[6*ix+kh];\n\t\t\t\t  eval[6*ix+kh] = eval[6*(*kn1-1)+kh];\n\t\t\t\t  eval[6*(*kn1-1)+kh] = tdum;\n\t\t\t\t}\n\t\t\t    }\n\t\t\t  (*kn1)--;\n\t\t\t  break;\n\t\t\t}\n\t\t    }\n\t\t}\n\t      if (ix >= 0)\n\t      \tki = -1;  /* Start from the beginning */\n\t    }\n\t}\n    }\n\n  goto out;\n\n error:\n  *jstat = kstat;\n  goto out;\n  \n out:\n  return;\n}\n\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic int s9edgsscon_con(SISLIntpt *pt1, SISLIntpt *pt2)\n#else\n  static int s9edgsscon_con(pt1, pt2)\n     SISLIntpt *pt1;\n     SISLIntpt *pt2;  \n#endif\n{\n  int kstat = 0;\n  int klist1=-1, klist2=-1;\n  sh6getlist (pt1, pt2, &klist1, &klist2, &kstat);\n  return (kstat == 0);\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic SISLIntpt* s9edgsscon_samecon(SISLIntpt *pt1, SISLIntpt *pt2)\n#else\n  static SISLIntpt* s9edgsscon_samecon(pt1, pt2)\n     SISLIntpt *pt1;\n     SISLIntpt *pt2;  \n#endif\n{\n  SISLIntpt *dummy = SISL_NULL;\n  int ki, kj;\n  for (ki=0; ki<pt1->no_of_curves; ++ki)\n    for (kj=0; kj<pt2->no_of_curves; ++kj)\n      if (pt1->pnext[ki] == pt2->pnext[kj])\n\treturn pt1->pnext[ki];\n  return dummy;\n}\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic int s9edgsscon_connected(SISLIntpt **uipt, int *ndir, int kn1)\n#else\n  static int s9edgsscon_connected(uipt, ndir, kn1)\n     SISLIntpt **uipt;\n     int *ndir;\n     int kn1;\n#endif\n /*\n *********************************************************************\n *\n *********************************************************************\n *\n * PURPOSE    : Check if a numbar of intersection points are connected into\n *              a chain, excluding corner touches\n *\n * INPUT      : uipt     - Array of intersection points\n *              ndir     - Point classification\n *              kn1      - Number of intersection points\n *\n * OUTPUT     : retur value - status messages\n *                           = 0     : Connected\n *                           = 1     : Not a chain\n *                           < 0     : error\n *\n * WRITTEN BY: Vibeke Skytt, SINTEF, 2023-06.\n *\n *********************************************************************\n */\n{\n  int kstat = 0;\n  int ki, kj;\n  int klist1, klist2;\n  int nmb_one = 0;\n  int *count = SISL_NULL;\n\n  if ((count = new0array (kn1, int)) == SISL_NULL)\n    goto err101;\n\n  for (ki=0; ki<kn1; ++ki)\n    {\n      for (kj=0; kj<kn1; ++kj)\n\t{\n\t  if (ki == kj)\n\t    continue;\n\t  if (ndir[ki] == 10)\n\t    continue;  /* Corner touch */\n\n\t  /* Check if the points are connected */\n\t  sh6getlist (uipt[ki], uipt[kj], &klist1, &klist2, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  if (kstat == 0)\n\t    count[ki]++;\n\t}\n    }\n\n  /* Check if the list has two endpoints and no branches */\n  kstat = 0;\n  for (ki=0; ki<kn1; ++ki)\n    {\n      if (count[ki] == 1)\n\tnmb_one++;\n      if ((count[ki] < 1 && ndir[ki] != 10) || count[ki] > 2)\n\t{\n\t  kstat = 1;  /* Not a chain including all points */\n\t  goto out;\n\t}\n    }\n  if (nmb_one != 2)\n    kstat = 1;\n\n  goto out;\n\n err101:\n  kstat = -101;\n  goto out;\n\n error:\n  goto out;\n\n out:\n  if (count)\n    freearray(count);\n  return kstat;\n}\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns9edgsscon_directed(SISLIntdat *rintdat, SISLIntpt **uipt, int kn1, double *eval, \n\t\t    double *dirval, int *ndir, double aepsge, int *jstat)\n#else\n  static void s9edgsscon_directed(rintdat, uipt, kn1, eval, dirval, ndir, aepsge, jstat)\n     SISLIntdat *rintdat;\n     SISLIntpt **uipt;\n     int kn1;\n     double *eval;\n     double *dirval;\n     int *ndir;\n     double aepsge;\n     int *jstat;\n#endif\n /*\n *********************************************************************\n *\n *********************************************************************\n *\n * PURPOSE    : Connect a directed curve\n *\n * INPUT      : uipt     - Array of intersection points\n *              kn1      - Number of intersection points\n *\n * OUTPUT     :  jstat    - status messages\n *                           = 0     : Connected\n *                           = 1     : Not connected\n *                           < 0     : error\n *\n * WRITTEN BY: Vibeke Skytt, SINTEF, 2023-06.\n *\n *********************************************************************\n */\n{\n  int kstat = 0;\n  int ki, kj;\n  int klist1, klist2;\n  int kdum;\n  int *lperm = SISL_NULL;\n  int *lconn;\n  int nconn = 0;\n  \n  /* Sort intersection points */\n  if ((lperm = newarray(3*kn1,  int)) == SISL_NULL)\n    goto err101;\n  lconn = lperm + kn1;\n  for (ki=0; ki<kn1; ++ki)\n    lperm[ki] = ki;\n\n  for (ki=0; ki<kn1; ++ki)\n    for (kj=ki+1; kj<kn1; ++kj)\n      if (dirval[lperm[kj]] < dirval[lperm[ki]])\n\t{\n\t  kdum = lperm[ki];\n\t  lperm[ki] = lperm[kj];\n\t  lperm[kj] = kdum;\n\t}\n\n  /* Check if a connection is possible */\n  *jstat = 0;  /* Suppose that it is possible to connect */\n  for (ki=1; ki<kn1; ++ki)\n    {\n      sh6getlist (uipt[lperm[ki-1]], uipt[lperm[ki]], &klist1, &klist2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      if (kstat == 0)\n\tcontinue;  /* Already connected */\n      else if ((ndir[lperm[ki-1]] == -1 || ndir[lperm[ki-1]] == 1) &&\n\t  ndir[lperm[ki]] == 1)\n\t{\n\t  *jstat = 1;  /* Not possible to connect */\n\t  goto out;\n\t}\n      else if ((ndir[lperm[ki-1]] == 1 || ndir[lperm[ki-1]] == 0 ) &&\n\t       ndir[lperm[ki]] == -1)\n\t{\n\t  /* Going out of the domain. Continue to next pair of points */\n\t  lconn[nconn++] = lperm[ki-1];\n\t  lconn[nconn++] = lperm[ki];\n\t  ++ki;\n\t  continue;\n\t}\n      else if (ndir[lperm[ki-1]] == 1 && ndir[lperm[ki]] == 0)\n\t{\n\t  /* From in to touching. */\n\t  lconn[nconn++] = lperm[ki-1];\n\t  lconn[nconn++] = lperm[ki];\n\t  continue;\n\t}\n      else if (ndir[lperm[ki-1]] == 1 && ndir[lperm[ki]] == 2)\n\t{\n\t  /* From in to singular */\n\t  lconn[nconn++] = lperm[ki-1];\n\t  lconn[nconn++] = lperm[ki];\n\t  continue;\n\t}\n      else if (ndir[lperm[ki-1]] == 2 && ndir[lperm[ki]] == -1)\n\t{\n\t  /* From singular to out */\n\t  lconn[nconn++] = lperm[ki-1];\n\t  lconn[nconn++] = lperm[ki];\n\t  ++ki;\n\t  continue;\n\t}\n      else if (ndir[lperm[ki-1]] == 0 && ndir[lperm[ki]] == 0)\n\t{\n\t  /* Two parallel points that are not connected. Check if there is a \n\t     connection within the surface domains */\n\t  /* For the time being */\n\t  *jstat = 1;\n\t  goto out;\n\t}\n      else if (s6dist(&eval[lperm[ki-1]*6], &eval[lperm[ki]*6], 3) < aepsge)\n\t{\n\t  /* Two instances of the same point. Connect */\n\t  lconn[nconn++] = lperm[ki-1];\n\t  lconn[nconn++] = lperm[ki];\n\t  continue;\n\t}\n      else\n\t{\n\t  /* Not a known configuration */\n\t  *jstat = 1;\n\t  goto out;\n\t}\n    }\n\n  /* Connect */\n  for (ki=0; ki<nconn; ki+=2)\n    {\n      sh6condir(rintdat, uipt[lconn[ki]], uipt[lconn[ki+1]], &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  *jstat = 0;\n  goto out;\n\n err101:\n  *jstat = -101;\n  goto out;\n\n error:\n  *jstat = kstat;\n  goto out;\n\n out:\n  if (lperm) freearray(lperm);\n}\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\ns9edgsscon_singsearch(SISLSurf *ps1, SISLSurf *ps2, SISLIntdat *rintdat, \n\t\t      SISLIntpt **uipt, int *ndir, int kn1, double aepsge,\n\t\t      int *jstat)\n#else\n  static void s9edgsscon_singsearch(ps1, ps2, rintdat, uipt, ndir, kn1, aepsge, jstat)\n     SISLSurf *ps1;\n     SISLSurf *ps2; \n     SISLIntdat *rintdat;\n     SISLIntpt **uipt;\n     int *ndir;\n     int kn1;\n     double aepsge;\n     int *jstat;\n#endif\n /*\n *********************************************************************\n *\n *********************************************************************\n *\n * PURPOSE    : Search for a singular intersection to which in/out points \n *              should be connected\n *\n * INPUT      : ps1      - First surface in intersection.\n *              ps2      - Second surface in intersection.\n *              uipt     - Array of intersection points\n *              ndir     - Classification of intersection points\n *              kn1      - Number of intersection points\n *              aepsge   - Geometry tolerance\n *\n * OUTPUT     : rintdat  - Intersection dates to be updated.\n *              jstat    - status messages\n *                           = 1     : Not a simple case.\n *                           = 0     : OK.\n *                           < 0     : error\n *\n * WRITTEN BY: Vibeke Skytt, SINTEF, 2023-06.\n *\n *********************************************************************\n */\n{\n  int kstat = 0;\n  int ki, kj;\n  int kv;\n  int klist1, klist2;\t\t/* List index in iintpt.   */\n  double *nullp = SISL_NULL;\n  double tdist;                 /* Distance between surfaces in point.   */\n  double tref;                  /* Reference value.                      */\n  double spos[4];               /* Parameter value of singular point.    */\n  double spnt1[3], spnt2[3];    /* Value of singularity in the two surfaces */\n  double start[4];              /* Start parameter to iteration.         */\n  double slimit[8];             /* Limits to the parameter areas.        */\n  SISLIntpt *qsing=SISL_NULL;   /* Singular intersection point.          */\n  int klfs = 0, klft = 0; \n  int kinn = 0, kout = 0, ksing = 0, kpar = 0;\n  int ki1=-1, ki2=-1, ko1=-1, ko2=-1, kx1 = -1, kx2 = -1;\n\n  /* Count occurances of classified points */\n  for (ki=0, kv=0; ki < kn1; ki++)\n    {\n      if (ndir[ki] < 10)\n\tkv++;\n      if (ndir[ki] == 1)\n\t{\n\t  if (kinn == 0)\n\t    ki1 = ki;\n\t  else\n\t    ki2 = ki;\n\t  kinn++;\n\t}\n      else if (ndir[ki] == -1)\n\t{\n\t  if (kout == 0)\n\t    ko1 = ki;\n\t  else\n\t    ko2 = ki;\n\t  kout++;\n\t}\n      else if (ndir[ki] == 0)\n\t{\n\t  if (kx1 < 0)\n\t    kx1 = ki;\n\t  else\n\t    kx2 = ki;\n\t  kpar++;\n\t}\n      else if (ndir[ki] == 2)\n\tksing++;\n    }\n\n  /* Configuration is assumed to be checked prior to calling this function. */\n  \n  /* If two parallel points check if they are connected */\n  if (kpar == 2)\n    {\n      if (kx1 < 0 || kx2 < 0)\n\tgoto warn1;\n      sh6getlist (uipt[kx1], uipt[kx2], &klist1, &klist2, &kstat);\n      if (kstat != 0)\n\tgoto warn1;   /* Not a suitable configuration */\n    }\n\n  /* A configuration that might include a singularity.\n     Prepare for a search. */\n      \n  slimit[0] = *(ps1->et1 + ps1->ik1 - 1);\n  slimit[1] = *(ps1->et1 + ps1->in1);\n  slimit[2] = *(ps1->et2 + ps1->ik2 - 1);\n  slimit[3] = *(ps1->et2 + ps1->in2);\n  slimit[4] = *(ps2->et1 + ps2->ik1 - 1);\n  slimit[5] = *(ps2->et1 + ps2->in1);\n  slimit[6] = *(ps2->et2 + ps2->ik2 - 1);\n  slimit[7] = *(ps2->et2 + ps2->in2);\n  tref = MAX(MAX(slimit[1]-slimit[0],slimit[3]-slimit[2]),\n\t     MAX(slimit[5]-slimit[4],slimit[7]-slimit[6]));\n      \n  for (kj=0; kj<4; kj++)\n    {\n      start[kj] = DZERO;\n      for (ki=0; ki<kn1; ki++)\n\t{\n\t  if (ndir[ki] == 10)\n\t    continue;\n\t  start[kj] += uipt[ki]->epar[kj];\n\t}\n      start[kj] /= (double)kv;\n    }\n      \n  /* Search for singularity.  */\n      \n  shsing(ps1, ps2, slimit, start, spos, &kstat);\n  if (kstat < 0)\n    goto error;\n      \n  if (kstat == 1)\n    {\n      /* A singularity is found. Check if it is an\n\t intersection point. */\n\t  \n      s1424(ps1, 0, 0, spos, &klfs, &klft, spnt1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\t  \n      s1424(ps2, 0, 0, spos+2, &klfs, &klft, spnt2, &kstat);\n      if (kstat < 0) \n\tgoto error;\n\t  \n      tdist = s6dist(spnt1, spnt2, 3);\n      if (tdist < aepsge)\n\t{\n\t  /* A singular intersection point is found. Check if\n\t     it is identical to any of the existing. */\n\t      \n\t  for (ki=0; ki<kn1; ki++)\n\t    {\n\t      if (ndir[ki] == 10)\n\t\tcontinue;\n\t      for (kj=0; kj<4; kj++)\n\t\tif (DNEQUAL(spos[kj]+tref,uipt[ki]->epar[kj]+tref))\n\t\t  break;\n\t      if (kj == 4)\n\t\tbreak;\n\t    }\n\n\t  if (ki < kn1)\n\t    {\n\t      /* An existing interesction points is found to be\n\t\t singular. Connect in/out points to the singular point\n\t\t and mark it as singular */\n\t      for (kj=0; kj<kn1; ++kj)\n\t\t{\n\t\t  if (kj == ki)\n\t\t    continue;\n\t\t  if (ndir[kj] == 1)\n\t\t    sh6condir(rintdat, uipt[kj], uipt[ki], &kstat);\n\t\t  else if (ndir[kj] == -1)\n\t\t    sh6condir(rintdat, uipt[ki], uipt[kj], &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t}\n\n\t      uipt[ki]->iinter = SI_SING;\n\t    }\n\t  else\n\t    {\n\t      /* The singular intersection point does not exist already.\n\t\t Create intersection point.  */\n\t\t      \n\t      qsing = hp_newIntpt (4, spos, DZERO,\n\t\t\t\t   SI_ORD, SI_UNDEF, SI_UNDEF,\n\t\t\t\t   SI_UNDEF, SI_UNDEF,\n\t\t\t\t   0, 0, nullp, nullp);\n\t      if (qsing == SISL_NULL)\n\t\tgoto err101;\n\t      /* Mark point as singular.  */\n\t      qsing -> iinter = SI_SING;\n\t\t      \n\t      /*  Check if it lies on an edge.       */\n\t\t      \n\t      for (kj=0; kj<4; kj++)\n\t\tif (DEQUAL(spos[kj]+tref,slimit[2*kj]+tref) ||\n\t\t    DEQUAL(spos[kj]+tref,slimit[2*kj+1]+tref))\n\t\t  break;\n\t\t      \n\t      if (kj < 4 && kpar == 2)\n\t\t{\n\t\t  /* Singular intersection point at an edge.\n\t\t     Insert between the two parallel points.  */\n\n\t\t  sh6insert(&rintdat,uipt[kx1], uipt[kx2], &qsing, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\n\t\t  /* Connect to in/out point.  */\n\t\t  if (kinn == 1)\n\t\t    sh6condir(rintdat, uipt[ki1], qsing, &kstat);\n\t\t  else\n\t\t    sh6condir(rintdat, qsing, uipt[ko1], &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\n\t\t}\n\t      else if (kj == 4)\n\t\t{\n\t\t  /* Singular point in the inner. Connect to\n\t\t     all edge points. First put into data structure. */\n\t\t  sh6idnpt (&rintdat, &qsing, 1, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\n\t\t  for (ki=0; ki<kn1; ++ki)\n\t\t    {\n\t\t      if (ndir[ki] == 1)\n\t\t\tsh6condir(rintdat, uipt[ki], qsing, &kstat);\n\t\t      else if (ndir[ki] == -1)\n\t\t\tsh6condir(rintdat, qsing, uipt[ki], &kstat);\n\t\t      if (kstat < 0)\n\t\t\tgoto error;\n\t\t    }\n\t\t}\n\t      else\n\t\tgoto warn1;\n\t    }\n\t}\n      else\n\tgoto warn1;\n    }\n  else\n    goto warn1;\n\n  *jstat = 0;\n  goto out;\n\n warn1:\n  *jstat = 1;\n  goto out;\n\n err101:\n  *jstat = -101;\n  goto out;\n  \n error:\n  *jstat = kstat;\n  goto out;\n  \n out:\n  return;\n}\n\n\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1762_s9edgsscon (SISLEdge * vedge[], SISLSurf * ps1, SISLSurf * ps2,\n\t\t   SISLIntdat * rintdat, int isimple, double aepsge,\n\t\t   int *jstat)\n#else\nstatic void\nsh1762_s9edgsscon (vedge, ps1, ps2, rintdat, isimple, aepsge, jstat)\n     SISLEdge *vedge[];\n     SISLSurf *ps1;\n     SISLSurf *ps2;\n     SISLIntdat *rintdat;\n     int isimple;\n     double aepsge;\n     int *jstat;\n#endif\n /*\n *********************************************************************\n *\n *********************************************************************\n *\n * PURPOSE    : To connect intersection points on edges on two surfaces\n *              into curves.\n *\n *\n *\n * INPUT      : vedge[]  - SISLEdge intersection.\n *              ps1      - First surface in intersection.\n *              ps2      - Second surface in intersection.\n *              isimple  - If value 1, we use a special connecting\n *                         strategy for 4 points.\n *                         = 2: No further subdivision will be performed\n *                              Special connections\n *              aepsge   - Geometry tolerance.\n *\n * OUTPUT     : rintdat  - Intersection dates to be updated.\n *              jstat    - status messages\n *                           = 1     : Not a simple case.\n *                           = 0     : OK.\n *                           < 0     : error\n *\n *\n * METHOD     :\n *\n *\n * REFERENCES :\n *\n *\n * WRITTEN BY : Arne Laksaa, SI, 89-06.\n *\n *********************************************************************\n */\n{\n  int kstat = 0;\n  int *ldir = SISL_NULL;\t\t/* Local array containing one of the statusvalues for\n\t\t\t\t * each point:\n\t\t\t\t *  0 - The intersect.curve is parallel to one\n\t\t\t\t *      parameter direction.\n\t\t\t\t *  1 - The intersect.curve has direction into the\n\t\t\t\t *      domain.\n\t\t\t\t * -1 - The intersect.curve has direction out of the\n\t\t\t\t *      domain.\n\t\t\t\t *  2 - The point is singulear.\n\t\t\t\t * 10 - The intersect.curve touch one corner of the\n\t\t\t\t *      domain.\n\t\t\t\t * --------------------------------------------------\n\t\t\t\t */\n\n  int lant[2];\n  unsigned char *edg = SISL_NULL;\n  double *sval = SISL_NULL;      /* Position and tangen of intersection point */\n  double *sdist;\n  double *sdval;\n  SISLIntpt **uipt = SISL_NULL;\n  SISLPtedge *qpt;\n  int klist1, klist2;\t\t/* List index in iintpt.   */\n\n  int kpt2 = 0;                 /* Number of connected intersection points */\n  int kn1, ki, kj, kn, kr, kv, kant;\n  double distfac = 10.0;\n  int kinn = 0, kout = 0, ksing = 0, kpar = 0;\n  int ki1=-1, ki2=-1, ko1=-1, ko2=-1, kx1 = -1, kx2 = -1;\n\n\n  if (ps1->idim != 3 || ps2->idim != 3)\n    goto err200;\n\n  *jstat = 0;\n\n  if (vedge[0] == SISL_NULL)\n    lant[0] = 0;\n  else\n    lant[0] = vedge[0]->ipoint;\n\n  if (vedge[1] == SISL_NULL)\n    lant[1] = 0;\n  else\n    lant[1] = vedge[1]->ipoint;\n\n\n  kant = lant[0] + lant[1];\n  if (kant == 0)\n    {\n      /* No point at the edges. Stop recursion */\n      *jstat = 0;\n      goto out;\n    }\n  \n  /* Allocate array of pointers to the points. */\n  if ((uipt = newarray (kant, SISLIntpt *)) == SISL_NULL)\n    goto err101;\n  if ((edg = new0array (kant, unsigned char)) == SISL_NULL)\n    goto err101;\n\n  /* Collect points and identify corresponding edges */\n  for (kn1 = 0, kn = 0; kn < 2; kn++)\n    if (lant[kn] > 0)\n      for (kj = 0; kj < vedge[kn]->iedge; kj++)\n\tfor (qpt = vedge[kn]->prpt[kj]; qpt != SISL_NULL; qpt = qpt->pnext)\n\t  {\n\t    for (ki = 0; ki < kn1; ki++)\n\t      {\n\t\tif (qpt->ppt == uipt[ki])\n\t\t  break;\n\t      }\n\t    if (ki == kn1)\n\t      uipt[kn1++] = qpt->ppt;\n\n\t    edg[ki] |= 1 << (vedge[kn]->iedge * kn + kj);\n\t  }\n\n  if (kn1 <= 1)\n    {\n      /* One point only. No connection possible. Stop recursion */\n      *jstat = 0;\n      goto out;\n    }\n\n  /* Allocate arrays for intersection point properties */\n  if ((ldir = new0array (kn1, int)) == SISL_NULL)\n    goto err101;\n  if ((sval = newarray (8*kn1, double)) == SISL_NULL)\n    goto err101;\n  sdval = sval + 6*kn1;\n  sdist = sdval + kn1;\n  \n  /* Evaluate intersection point properties */\n  s9edgsscon_eval(ps1, ps2, uipt, edg, kn1, isimple, sval, sdist, sdval,\n\t\t  ldir, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Check if the configuration can be simplified */\n  s9edgsscon_simplify(rintdat, uipt, edg, &kn1, sval, sdist, sdval, ldir,\n  \t\t      aepsge, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Count occurances of in-points, out-points and non-corner points */\n  for (ki=0, kv=0; ki < kn1; ki++)\n    {\n      if (ldir[ki] < 10)\n\tkv++;\n      if (ldir[ki] == 1)\n\t{\n\t  if (kinn == 0)\n\t    ki1 = ki;\n\t  else\n\t    ki2 = ki;\n\t  kinn++;\n\t}\n      else if (ldir[ki] == -1)\n\t{\n\t  if (kout == 0)\n\t    ko1 = ki;\n\t  else\n\t    ko2 = ki;\n\t  kout++;\n\t}\n      else if (ldir[ki] == 0)\n\t{\n\t  if (kx1 < 0)\n\t    kx1 = ki;\n\t  else\n\t    kx2 = ki;\n\t  kpar++;\n\t}\n      else if (ldir[ki] == 2)\n\tksing++;\n    }\n  \n  if (kv == 0)\n    {\n      /* Only corner points. No connection. Stop recursion */\n      *jstat = 0;\n      goto out;\n    }\n\n  /* Check if the points are connected in a chain */\n  kstat = s9edgsscon_connected(uipt, ldir, kn1);\n  if (kstat < 0)\n    goto error;\n  if (kstat == 0)\n    {\n      /* Already connected */\n      *jstat = 0;\n      goto out;\n    }\n\n  /* Try to connect a directed curve */\n  if (isimple == 1)\n    {\n      s9edgsscon_directed(rintdat, uipt, kn1, sval, sdval, ldir, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      if (kstat == 0)\n\t{\n\t  /* Connection performed */\n\t  *jstat = 0;\n\t  goto out;\n\t}\n    }\n\n  /* Handle non-directed curves and special cases */\n  \n  if (kinn == 1 && kout == 1)\n    {\n      /* One in, one out. Connect */\n      sh6condir(rintdat, uipt[ki1], uipt[ko1], &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      if (kv > 2)\n\t{\n\t  /* There exist non-connected parallel points. Check if they can\n\t     be removed */\n\t  for (ki=0; ki<kv; ++ki)\n\t    {\n\t      if (ki != ki1 && ki != ko1)\n\t\t{\n\t\t  if (uipt[ki]->fromhelp > 0)\n\t\t    {\n\t\t      sh6idkpt (&rintdat, &uipt[ki], 1, &kstat);\n\t\t      if (kstat < 0)\n\t\t\tgoto error;\n\t\t    }\n\t\t}\n\t    }\n\t}\n      *jstat = 0;\n      goto out;\n    }\n\n  if (kinn + kout == 1 && ksing == 1 && kv == 2)\n    {\n      /* Connect in/out point to singular */\n      kx1 = -1;\n      for (ki=0; ki<kn1; ++ki)\n\t{\n\t  if (ldir[ki] == 2)\n\t    {\n\t      kx1 = ki;\n\t      break;\n\t    }\n\t}\n      if (kx1 >= 0)\n\t{\n\t  if (kinn == 1)\n\t    sh6condir(rintdat, uipt[ki1], uipt[kx1], &kstat);\n\t  else\n\t    sh6condir(rintdat, uipt[kx1], uipt[ko1], &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  *jstat = 0;\n\t  goto out;\n\t}\n    }\n\n  if (kv == 2 && kinn + kout == kv)\n    {\n      /* One in-out point. Check if there should be a connection */\n      int kd = (kinn >= 1) ? ki1 : ko1;\n      int kx = -1;\n      for (ki=0; ki<kn1; ++ki)\n\tif (ldir[ki] != 10 && ki != kd)\n\t  kx = ki;\n\n      /* Check if the points are connected to the same main point */\n      for (kr=0; kr<uipt[kd]->no_of_curves; ++kr)\n\t{\n\t  if (sh6ismain(uipt[kd]->pnext[kr]))\n\t    {\n\t      sh6getlist (uipt[kx], uipt[kd]->pnext[kr], \n\t\t\t  &klist1, &klist2, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t      if (kstat == 0)\n\t\t{\n\t\t  /* Connected. */\n\t\t  break;\n\t\t}\n\t    }\n\t}\n      if (kr < uipt[kd]->no_of_curves)\n\t/*printf(\"Connection with one in or out point. Must have a look at this \\n\"); */ ;\n    }\n\n  if (kn1-kv == 1 && kinn+kout == 1)\n    {\n      /* Handle situation with one in or out point and one corner point */\n      /* Check if the points should be connected */\n      int kic, kid;\n\n      kid =  (ldir[0] == 10) ? 1 : 0;\n      kic =  (ldir[0] == 10) ? 0 : 1;\n\n      /* Check if it is a part of a help point configuration */\n      kr = uipt[kid]->no_of_curves;  /* Initially assume not a resolved \n\t\t\t\t      configuration */\n      if (max(sdist[kic],sdist[kid]) > distfac*min(sdist[kic],sdist[kid]) ||\n\t  uipt[kid]->fromhelp > 0)\n\t{\n\t  /* Check if the points are already connected trough one\n\t     common main point */\n\t  for (kr=0; kr<uipt[kid]->no_of_curves; ++kr)\n\t    {\n\t      if (sh6ismain(uipt[kid]->pnext[kr]))\n\t\t{\n\t\t  sh6getlist (uipt[kic], uipt[kid]->pnext[kr], &klist1,\n\t\t\t      &klist2, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t  if (kstat == 0)\n\t\t    {\n\t\t      /* Connected. Assume configuration to be resolved */\n\t\t      break;\n\t\t    }\n\t\t}\n\t    }\n\t}\n\n      if (kr == uipt[kid]->no_of_curves)\n\t{\n\t  /* Check if it is a real corner touch */\n\t  if (!((sdist[kid] > distfac*sdist[kic] ||\n\t\t (uipt[kid]->fromhelp > 0 && uipt[kic]->fromhelp == 0)) &&\n\t\tsh6nmbmain(uipt[kid],&kstat) == 1))\n\t    {\n\t      /* The in/out point is stronger than the corner. Do connect */\n\t      if (kinn == 1)\n\t\tsh6condir(rintdat, uipt[kid], uipt[kic], &kstat);\n\t      else\n\t\tsh6condir(rintdat, uipt[kic], uipt[kid], &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t    }\n\t}\n      *jstat = 0;\n      goto out;\n    }\n\n  if ((kv == 3 &&  ((kpar == 2 && kinn+kout == 1) || kinn+kout == kv)) ||\n       (kv == 4 && isimple == 2 && kinn == 2 && kout == 2))\n    {\n      s9edgsscon_singsearch(ps1, ps2, rintdat, uipt, ldir, kn1, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      if (kstat == 0)\n\t{\n\t  *jstat = 0;\n\t  goto out;\n\t}\n    }\n\n  if (ps1->sf_type == TANGENTIAL_BELT || \n      ps2->sf_type == TANGENTIAL_BELT)\n    {\n      /* One surface represents a fuzzy zone close to a tangential\n\t intersection curve. Unconnected points pointing in or out\n\t should be connected to this curve. To start with, stop\n\t processing if all intersection points are connected */\n      int ix1 = -1, ix2 = -1;\n      sh6floop(uipt, kn1, &kpt2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      if (kpt2 == kn1)\n\t{\n\t  *jstat = 0;\n\t  goto out;\n\t}\n\n      /* There is at least one loose point. Due to the configuration there\n\t must be two points connected along an edge */\n      for (ki=0; ki<kn1; ++ki)\n\t{\n\t  for (kj=ki+1; kj<kn1; ++kj)\n\t    {\n\t      if (edg[ki] & edg[kj])\n\t\t{\n\t\t  ix1 = ki;\n\t\t  ix2 = kj;\n\t\t  break;\n\t\t}\n\t      if (kj < kn1)\n\t\tbreak;\n\t    }\n\t  }\n\n      if (ix1 >= 0 && ix2 >= 0)\n\t{\n\t  for (ki=0; ki<kn1; ++ki)\n\t    {\n\t      if (ki==ix1 || ki==ix2)\n\t\tcontinue;\n\t      if (sdist[ki] < distfac*max(sdist[ix1],sdist[ix2]))\n\t\tbreak;\n\t    }\n\t  if (ki == kn1)\n\t    {\n\t      /* Extra points are noise. Stop recursion */\n\t      /* Could possibly check and connect */\n\t      *jstat = 0;\n\t      goto out;\n\t    }\n\t}\n    }\n\t\t\n\n  if (kv == 3 && kinn == 1 && kout == 1 && kpar == 1)\n    {\n      int kc = 0;\n      \n      /* Three points, one in, one out, one parallel, connect in-out,\n\t delete parallel.. */\n      sh6condir(rintdat, uipt[ki1], uipt[ko1], &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /* Can't delete the parallel point if it's in a corner. */\n      /* Should check the configuration with the parallel point further */\n\n      /* Corner first surface ? */\n      for (kc = kj = 0; kj < 4; kj++)\n\tif (edg[kx1] & (1<<kj))\n\t  kc++;\n\n      /* Corner second surface ? */\n      if (kc < 2)\n\tfor (kc = 0, kj = 4; kj < 8; kj++)\n\t  if (edg[kx1] & (1<<kj))\n\t    kc++;\n\n      if (kc < 2)\n\t{\n\t  sh6idkpt (&rintdat, &uipt[kx1], 1, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n\n      *jstat = 0;\n      goto out;\n    }\n\n  if (kinn+kout == 1 && kpar > 1)\n    {\n      /* One in or out point */\n      /* More than one parallel point. Check if they are connected */\n      for (ki=0; ki<kn1; ++ki)\n\t{\n\t  if (ldir[ki] != 0)\n\t    continue;\n\t  for (kj=0; kj<kn1; ++kj)\n\t    {\n\t      if (kj == ki)\n\t\tcontinue;\n\t      if (ldir[kj] != 0)\n\t\tcontinue;\n\t      sh6getlist (uipt[ki], uipt[kj], &klist1, &klist2, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t      if (kstat == 0)\n\t\tbreak;\n\t    }\n\t  if (kj == kn1)\n\t    break;   /* Point not connected to another parallel point */\n\t}\n\n      if (ki == kn1)\n\t{\n\t  /* Connect in/out point to closest parallel point */\n\t  double mindist = HUGE;\n\t  int minix = -1;\n\t  double tdist;\n\t  int ix = (kinn == 1) ? ki1 : ko1;\n\t  for (kj=0; kj<kn1; ++kj)\n\t    {\n\t      if (ldir[kj] != 0)\n\t\tcontinue;\n\t      tdist = s6dist(sval+ix*6, sval+kj*6, 3);\n\t      if (tdist < mindist)\n\t\t{\n\t\t  mindist = tdist;\n\t\t  minix = kj;\n\t\t}\n\t    }\n\t  if (minix >= 0)\n\t    {\n\t      if (kinn == 1)\n\t\tsh6condir(rintdat, uipt[ix], uipt[minix], &kstat);\n\t      else\n\t\tsh6condir(rintdat, uipt[minix], uipt[ix], &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t      *jstat = 0;\n\t      goto out;\n\t    }\n\t}\n    }\n      \n  if (kv > 2 && isimple == 2 && kinn + kout == kn1 && (kinn == 1 || kout == 1))\n    {\n      /* An extra effort to connect at the bottom of the\n\t recursion */\n      int kcode = (kinn == 1) ? 1 : -1;\n      int num_single = 0;\n      int num_fromhelp = 0;\n      int ix_main1 = -1, ix_main2 = -1;\n      int ixin = ki1;\n      int ixout = ko1;\n      for (ki=0; ki<kn1; ++ki)\n\t{\n\t  if (ldir[ki] == kcode)\n\t    continue;\n\t  if (sh6nmbmain(uipt[ki], &kstat) == 1)\n\t    num_single++;\n\t  else\n\t    ix_main1 = ki;\n\t  if (uipt[ki]->fromhelp > 0)\n\t    num_fromhelp++;\n\t  else\n\t    ix_main2 = ki;\n\t}\n\n      if (ix_main1 < 0)\n\tix_main1 = ix_main2;\n      if (ix_main1 >= 0)\n\t{\n\t  /* Change loose points to help points. Connect to\n\t     remaining main point */\n\t  for (ki=0; ki<kn1; ++ki)\n\t    {\n\t      if (ki == ix_main1)\n\t\tcontinue;\n\t      if (ldir[ki] == kcode)\n\t\tcontinue;\n\t      sh6tohelp(uipt[ki], &kstat);\n\t    }\n\t  if (kinn == 1)\n\t    ixout = ix_main1;\n\t  else\n\t    ixin = ix_main1;\n\n\t  sh6condir(rintdat, uipt[ixin], uipt[ixout], &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  *jstat = 0;\n\t  goto out;\n\t}\n    }\n\n  if (kinn == kout && ksing == 0 && kpar == 0)\n    {\n      /* This is a situation where connection could be possible. Leaving\n\t it to later */\n      /* printf(\"Should try to connect \\n\"); */ ;\n    }\n\n\n  *jstat = 1;   /* No conclution is reached */\n  goto out;\n\n\n\n/* Error in sub rutines.      */\n\nerror:*jstat = kstat;\n  s6err (\"sh1762_s9edgsscon\", *jstat, 0);\n  goto out;\n\n/* Error in memory allocation.      */\n\nerr101:*jstat = -101;\n  s6err (\"sh1762_s9edgsscon\", *jstat, 0);\n  goto out;\n\n/* Error dimension.      */\n\nerr200:*jstat = -200;\n  s6err (\"sh1762_s9edgsscon\", *jstat, 0);\n  goto out;\n\nout:\n  if (uipt != SISL_NULL)\n    freearray (uipt);\n  if (edg != SISL_NULL)\n    freearray (edg);\n  if (ldir != SISL_NULL)\n    freearray (ldir);\n  if (sval != SISL_NULL)\n    freearray (sval);\n}\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1762_s9edgpscon (SISLEdge * pedge, double alevel, SISLSurf * ps,\n\t\t   int isimple, SISLIntdat * rintdat, double aepsge, int *jstat)\n#else\nstatic void\nsh1762_s9edgpscon (pedge, alevel, ps, isimple, rintdat, aepsge, jstat)\n     SISLEdge *pedge;\n     double alevel;\n     SISLSurf *ps;\n     int isimple;\n     SISLIntdat *rintdat;\n     double aepsge;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To connect intersection points on edges on a surface\n*              into curves. The problem must be of type point-surface\n*              intersection in one dimension.\n*\n*\n*\n* INPUT      : pedge    - SISLEdge intersection.\n*              alevel   - The point value in intersection.\n*              ps       - Surface in intersection.\n*              isimple  - Flag telling if we are to try marching in troublesom cases.\n*              aepsge   - Geometry tolerance\n*\n* OUTPUT     : rintdat  - Intersection dates to be updated.\n*              jstat    - status messages\n*                           = 1     : Not a simple case.\n*                           = 0     : OK.\n*                           < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-07.\n*\n*********************************************************************\n*/\n{\n  int kstat,kstat1,kstat2;\n  int *ldir = SISL_NULL;\t\t/* Local array containing one of the statusvalues for\n\t\t\t         * each point:\n\t                         *  0 - The intersect.curve is parallel to one\n\t\t\t         *      parameter direction.\n\t                         *  1 - The intersect.curve has direction into the\n\t\t\t         *      domain.\n\t                         * -1 - The intersect.curve has direction out of the\n\t\t\t         *      domain.\n\t                         *  2 - The point is singulear.\n\t                         * 10 - The intersect.curve touch one corner of the\n\t\t\t         *      domain.\n\t\t\t         * ---------------------------------------------------\n\t\t\t         */\n\n  unsigned char *edg = SISL_NULL;\n  double *sval = SISL_NULL;\n  SISLPtedge *qpt = SISL_NULL;\n  SISLIntpt **uipt = SISL_NULL;\n  SISLIntpt **uinewpt = SISL_NULL;\n\n  double *spar = SISL_NULL;\t\t/* Local array with parameter values used as\n\t\t\t\t   input to s9conmarch. */\n  int *lperm = SISL_NULL;\t\t/* Local permutation array after sorting\n\t\t\t\t   input points to s9conmarch.*/\n  int *lpermdir = SISL_NULL;\t\t/* Local array with status values used as\n\t\t\t\t   input to s9conmarch. */\n  int lstatus[4];\t\t/* Local array containing the possible status\n\t\t\t\t   constants -1,1,0,2. */\n  int lnumb[4];\t\t\t/* Local array containing the number of points\n\t\t\t\t   with status lstatus. */\n\n  double *sparout = SISL_NULL;\t/* Local array with parameter values used as\n\t\t\t\t   output from s9conmarch.*/\n  int *lpar = SISL_NULL;\t\t/* Local array containing the connection information\n\t\t\t\t   from s9conmarch.*/\n  int kpoints;\t\t\t/* Local integer containing number of points returned\n\t\t\t\t   from s9conmarch.*/\n  int klist1, klist2;\t\t/* Indices for Intpoints. */\n\n  if (ps->idim != 1)\n    goto err200;\n\n  *jstat = 1;\n\n  if (pedge->ipoint > 1)\n    {\n      int kn1, kn, ki, kj, kv, kant, klfs, klft, kdir, kpar;\n      /* UJK 18.09.90  multiplying; treating near singularities as singularities.*/\n      double ttol = (double) 1000000.0 * REL_COMP_RES;\n      double tolpar = (double) 0.00001;\n\n      double *snorm;\n      double tmax, tmax2;\n      double *nullp = SISL_NULL;\n      kant = pedge->ipoint;\n\n      /* Allocate array of pointers to the points. */\n\n      if ((uipt = newarray (kant, SISLIntpt *)) == SISL_NULL)\n\tgoto err101;\n      if ((edg = new0array (kant, unsigned char)) == SISL_NULL)\n\tgoto err101;\n      if ((ldir = new0array (kant, int)) == SISL_NULL)\n\tgoto err101;\n      if ((sval = newarray (4 * kant, double)) == SISL_NULL)\n\tgoto err101;\n      snorm = sval + 3 * kant;\n\n\n      /* Update the arrays. */\n\n      for (kn1 = kj = 0; kj < pedge->iedge; kj++)\n\tfor (qpt = pedge->prpt[kj]; qpt != SISL_NULL; qpt = qpt->pnext)\n\t  {\n\t    for (ki = 0; ki < kn1; ki++)\n\t      {\n\t\tif (qpt->ppt == uipt[ki])\n\t\t  break;\n\t      }\n\t    if (ki == kn1)\n\t      uipt[kn1++] = qpt->ppt;\n\n\t    edg[ki] |= 1 << kj;\n\t  }\n\n      /* NEWI (ujk) some tuning ?! */\n      if (kn1 == 2)\n\ttolpar = ttol;\n\n\n      if (kn1 > 1)\n\tfor (ki = 0; ki < kn1; ki++)\n\t  {\n\t    kn = 3 * ki;\n\n\t    klfs = klft = 0;\n\t    s1421 (ps, 1, uipt[ki]->epar, &klfs, &klft, sval + kn, snorm + ki, &kstat);\n\t    if (kstat < 0)\n\t      goto error;\n\t    else if (kstat > 0)\n\t      {\n\t\tldir[ki] = 2;\n\t\tcontinue;\n\t      }\n\n\t    tmax = sqrt (sval[kn + 1] * sval[kn + 1] + sval[kn + 2] * sval[kn + 2]);\n\t    if (tmax < ttol)\n\t      {\n\t\tldir[ki] = 2;\n\t\tcontinue;\n\t      }\n\n\t    for (kpar = 1, kj = 0; kj < 4; kj++)\n\t      if ((edg[ki] & 1 << kj) == 1 << kj)\n\t\t{\n\t\t  switch (kj)\n\t\t    {\n\t\t    case 0:\n\t\t      if (fabs (sval[kn + 1] / tmax) < tolpar)\n\t\t\tkdir = 0;\n\t\t      else\n\t\t\tkdir = (sval[kn + 1] > DZERO ? 1 : -1);\n\t\t      break;\n\t\t    case 1:\n\t\t      if (fabs (sval[kn + 2] / tmax) < tolpar)\n\t\t\tkdir = 0;\n\t\t      else\n\t\t\tkdir = (sval[kn + 2] > DZERO ? 1 : -1);\n\t\t      break;\n\t\t    case 2:\n\t\t      if (fabs (sval[kn + 1] / tmax) < tolpar)\n\t\t\tkdir = 0;\n\t\t      else\n\t\t\tkdir = (sval[kn + 1] > DZERO ? -1 : 1);\n\t\t      break;\n\t\t    case 3:\n\t\t      if (fabs (sval[kn + 2] / tmax) < tolpar)\n\t\t\tkdir = 0;\n\t\t      else\n\t\t\tkdir = (sval[kn + 2] > DZERO ? -1 : 1);\n\t\t    }\n\n\t\t  if (kdir == 0)\n\t\t    kpar = 0;\n\t\t  else if (ldir[ki] != kdir)\n\t\t    {\n\t\t      if (ldir[ki] == 0)\n\t\t\tldir[ki] = kdir;\n\t\t      else\n\t\t\t{\n\t\t\t  ldir[ki] = 10;\n\t\t\t  break;\n\t\t\t}\n\t\t    }\n\t\t}\n\t    if (kpar == 0 && ldir[ki] != 10)\n\t      ldir[ki] = 0;\n\t  }\n      /* End of for ki=0 ..... */\n\n\n     /* When only two points, check if they are connected. */\n      if (kn1 == 2)\n\t{\n\t  sh6getlist (uipt[0], uipt[1], &klist1, &klist2, &kstat);\n\t  if (kstat == 0)\n\t    kn1 = 0;\n\t}\n\n      /* Count all the points that are candidates for connection. */\n      for (kv = ki = 0; ki < kn1; ki++)\n\tif (ldir[ki] < 10)\n\t  kv++;\n\n\n      if (kv == 1 && kn1 > 1 )\n      {\n\t int i=-1, j=-1;\n\n\t if (kn1 > 2)\n\t {\n\t    *jstat = 0;\n\t    for (i=0;i<kn1;i++)\n\t       if (ldir[i] == 1 || ldir[i] == -1)\n\t\t  *jstat = 1;\n\t    goto out;\n\t }\n\n\n\t if (ldir[0] == 1 || ldir[0] == -1)\n\t {\n\t    i =  0;\n\t    j =  1;\n\t }\n\t else if (ldir[1] == 1 || ldir[1] == -1)\n\t {\n\t    i =  1;\n\t    j =  0;\n\t }\n\t else\t\t\t\t\t\ti = -1;\n\n\t if (i >=0)\n\t {\n\t    /* We have one point, and the direction is in/out.\n\t       The other point is touching a corner it is probably\n\t       an error and the point must be close to tangential.*/\n\t   /* VSK 0619. However, it might also be that the touch\n\t      point is correct while the in/out point is close to\n\t      tangential. Test strength of classification */\n\n\t    s1421 (ps, 1, uipt[i]->epar, &klfs, &klft, sval + 3*i, snorm + i, \n\t\t   &kstat);\n\t    if (kstat < 0)\n\t      goto error;\n\t    s1421 (ps, 1, uipt[j]->epar, &klfs, &klft, sval + 3*j, snorm + j, \n\t\t   &kstat);\n\t    if (kstat < 0)\n\t      goto error;\n\t    tmax = sqrt (sval[3*i+1]*sval[3*i+1] + sval[3*i+2]*sval[3*i+2]);\n\t    tmax2 = sqrt (sval[3*j+1]*sval[3*j+1] + sval[3*j+2]*sval[3*j+2]);\n\t    if (min(fabs(sval[3*i+1]/tmax), fabs(sval[3*i+2]/tmax)) <\n\t\tmin(fabs(sval[3*j+1]/tmax), fabs(sval[3*j+2]/tmax)))\n\t      {\n\t\t/* Assume corner cut and no connection inside the current\n\t\t   patch */\n\t\t*jstat = 1;\n\t      }\n\t    else\n\t      {\n\t\t/* In/out point stronger. Connect. */\n\t\tif (ldir[i] == -1)\n\t\t  {\n\t\t    int k=j;\n\t\t    j  =  i;\n\t\t    i  =  k;\n\t\t  }\n\n\t\tsh6tomain (uipt[i], &kstat);\n\t\tsh6tomain (uipt[j], &kstat);\n\n\t\tsh6idcon (&rintdat, &uipt[i], &uipt[j], &kstat);\n\t\tif (kstat < 0)\n\t\t  goto error;\n\t\tsh6setdir (uipt[i], uipt[j], &kstat);\n\t\tif (kstat < 0)\n\t\t  goto error;\n\t\t*jstat = 0;\n\t      }\n\t }\n      }\n      else if (kv < 2)\n\t/* Less than two points, it's a simple case. */\n\t*jstat = 0;\n\n      else if (kv > 8)\n\t/* More than eight points, it's not a simple case. */\n\t*jstat = 1;\n      else\n\t/* We have two, three or four points, prepare a marching strategy\n           for connection.*/\n\t{\n\t  lstatus[0] = 1;\n\t  lstatus[1] = -1;\n\t  lstatus[2] = 0;\n\t  lstatus[3] = 2;\n\n\t  lnumb[0] = 0;\n\t  lnumb[1] = 0;\n\t  lnumb[2] = 0;\n\t  lnumb[3] = 0;\n\n\t  if ((lperm = new0array (kv, int)) == SISL_NULL)\n\t    goto err101;\n\t  if ((lpermdir = new0array (kv, int)) == SISL_NULL)\n\t    goto err101;\n\t  if ((spar = newarray (2 * kv, double)) == SISL_NULL)\n\t    goto err101;\n\n\t  for (kn = 0, kj = 0; kn < 4 && kj < kv; kn++)\n\t    {\n\t      /* We pass through the points four times, one for each\n                 possible statusvalue.*/\n\t      /* In this way they will be sorted : 111..-1-1-1..000..222.. */\n\n\t      for (ki = 0; ki < kn1 && kj < kv; ki++)\n\t\t{\n\n\t\t  if (ldir[ki] == lstatus[kn])\n\t\t    {\n\t\t      lnumb[kn] += 1;\n\t\t      spar[2 * kj] = uipt[ki]->epar[0];\n\t\t      spar[2 * kj + 1] = uipt[ki]->epar[1];\n\t\t      lperm[kj] = ki;\n\t\t      lpermdir[kj] = ldir[ki];\n\t\t      kj++;\n\t\t    }\n\t\t}\n\t    }\n\n\t  /* If the first point is a parallel point, change status. */\n\t  if (lpermdir[0] == 0)\n\t    lpermdir[0] = 11;\n\n\t  /* UJK, aug. 92 */\n\t  if (kv == 3)\n\t    {\n\t       /* When three points, check if they are connected. */\n\n\t       sh6getlist (uipt[lperm[0]], uipt[lperm[1]],\n\t\t\t   &klist1, &klist2, &kstat);\n\t       if (kstat < 0) goto error;\n\t       sh6getlist (uipt[lperm[0]], uipt[lperm[2]],\n\t\t\t   &klist1, &klist2, &kstat1);\n\t       if (kstat1 < 0) goto error;\n\t       sh6getlist (uipt[lperm[1]], uipt[lperm[2]],\n\t\t\t   &klist1, &klist2, &kstat2);\n\t       if (kstat2 < 0) goto error;\n\n\t       if (kstat + kstat1 + kstat2 <= 1)\n\t\t {\n\t\t    *jstat=0;\n\t\t    goto out;\n\t\t }\n\t    }\n\n\t  if (kv == 3 &&  lpermdir[2] == 2)\n\t     {\n\t\t/* When three points, one singular, check if they are connected. */\n\n\t\tsh6getlist (uipt[lperm[0]], uipt[lperm[2]],\n\t\t\t    &klist1, &klist2, &kstat);\n\t\tsh6getlist (uipt[lperm[1]], uipt[lperm[2]],\n\t\t\t    &klist1, &klist2, &kstat1);\n\n\t\tif (kstat == 0 && kstat1 == 0)\n\t\t{\n\t\t   *jstat=0;\n\t\t   goto out;\n\t\t}\n\t\telse if (kstat1 == 0 &&\n\t\t\t abs(lpermdir[0]) == 1 &&\n\t\t\t     lpermdir[1] == 0  &&\n\t\t\t     lpermdir[2] == 2)\n\t\t   {\n\t\t      /* Sing point is connected to parallell,\n\t\t\t connect singular point to in(out) point. */\n\t\t      sh6tomain (uipt[lperm[0]], &kstat);\n\t\t      sh6tomain (uipt[lperm[2]], &kstat);\n\n\t\t      sh6idcon (&rintdat, &uipt[lperm[0]],\n\t\t\t\t&uipt[lperm[2]], &kstat);\n\t\t      if (kstat < 0)\n\t\t\tgoto error;\n\n\t\t      /* Set in/out direction */\n\t\t      if (lpermdir[0] == 1)\n\t\t\tsh6setdir (uipt[lperm[0]],\n\t\t\t\t   uipt[lperm[2]], &kstat);\n\t\t      else\n\t\t\tsh6setdir (uipt[lperm[2]],\n\t\t\t\t   uipt[lperm[0]], &kstat);\n\n\t\t      if (kstat < 0)\n\t\t\tgoto error;\n\n\t\t      /* Set status JUNCTION point. */\n\t\t      uipt[lperm[2]]->iinter = SI_SING;\n\n\n\t\t      *jstat=0;\n\t\t      goto out;\n\t\t   }\n\n\n\t     }\n\n\n\t  /* UJK 18.09.90 Connecting whenever we have two points and\n             at least one of them is moving in or out. */\n\t  if (kv == 2 && (abs (lpermdir[0]) == 1))\n/*\t  if (kv==2 &&\n\t      ((lpermdir[0]*lpermdir[1] == -1) ||\n\t       (abs(lpermdir[0])==1 && lpermdir[1] == 0))) */\n\t    {\n\t      /* We have only two points and there has to be a curve,\n                 connect. */\n\t      sh6tomain (uipt[lperm[0]], &kstat);\n\t      sh6tomain (uipt[lperm[1]], &kstat);\n\n\t      sh6idcon (&rintdat, &uipt[lperm[0]], &uipt[lperm[1]], &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      /* Newi (ujk) Set in/out direction */\n\t      if (lpermdir[0] == 1)\n\t\tsh6setdir (uipt[lperm[0]],\n\t\t\t   uipt[lperm[1]], &kstat);\n\t      else\n\t\tsh6setdir (uipt[lperm[1]],\n\t\t\t   uipt[lperm[0]], &kstat);\n\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      /* ALA && UJK 19.09.90 Set status JUNCTION point. */\n\t      if (lpermdir[1] == 2)\n\t\tuipt[lperm[1]]->iinter = SI_SING;\n\n\t      /* UJK,aug 93, Problems in sh1d_div, simple case may result\n\t\t in connecting to edge pts that is singular in the original\n\t\t problem, create one extra, internal pt if possible. */\n\t      if (DEQUAL(uipt[lperm[0]]->epar[0],uipt[lperm[1]]->epar[0]) ||\n\t\t  DEQUAL(uipt[lperm[0]]->epar[1],uipt[lperm[1]]->epar[1]))\n\t      {\n\t\t SISLObject *obj=SISL_NULL;\n\t\t SISLIntpt *pint=SISL_NULL;\n\t\t double start;\n\t\t double *result;\n\t\t double coor[2];\n\t\t if ((obj = newObject(SISLCURVE))== SISL_NULL) goto err101;\n\t\t if (fabs(uipt[lperm[0]]->epar[0]-uipt[lperm[1]]->epar[0]) >\n\t\t     fabs(uipt[lperm[0]]->epar[1]-uipt[lperm[1]]->epar[1]))\n\t\t {\n\t\t    coor[0] = (uipt[lperm[0]]->epar[0]+uipt[lperm[1]]->epar[0])/(double)2.0;\n\t\t    result = coor+1;\n\t\t    s1437(ps,coor[0],&(obj->c1),&kstat);\n\t\t    if (kstat < 0) goto error;\n\t\t }\n\t\t else\n\t\t {\n\t\t    coor[1] = (uipt[lperm[0]]->epar[1]+uipt[lperm[1]]->epar[1])/(double)2.0;\n\t\t    result = coor;\n\t\t    s1436(ps,coor[1],&(obj->c1),&kstat);\n\t\t    if (kstat < 0) goto error;\n\t\t }\n\t\t start = s1792(obj->c1->et,obj->c1->ik,obj->c1->in);\n\n\t\t sh6ptobj(&alevel, obj, aepsge, &start, result, &kstat);\n\t\t if (kstat < 0) goto error;\n\t\t if (kstat == 1)\n\t\t {\n\t\t    pint = hp_newIntpt (2, coor, DZERO,\n\t\t\t\t\tSI_ORD, SI_UNDEF, SI_UNDEF,\n\t\t\t\t\tSI_UNDEF, SI_UNDEF,\n\t\t\t\t\t0, 0, SISL_NULL, SISL_NULL);\n\n\n\t\t    if (pint == SISL_NULL)\n\t\t       goto err101;\n\n\t\t    sh6insert (&rintdat, uipt[lperm[0]], uipt[lperm[1]],\n\t\t\t       &pint,&kstat);\n\t\t    if (kstat < 0)\n\t\t       goto error;\n\n\n\t\t }\n\t\t if (obj) freeObject(obj);\n\n\t      }\n\t      /* ______E N D aug.93________ */\n\n\t      *jstat = 0;\n\t    }\n\n\t  else if (kv > 4 && lpermdir[kv - 1] != -1)\n\t    /* More than four points, some with status /= +-1;\n               , it's not a simple case. */\n\t    *jstat = 1;\n\n\t  else if (kv == 3 &&\n\t\t   lpermdir[0] == 1 &&\n\t\t   lpermdir[1] == -1 &&\n\t\t   lpermdir[2] == 0)\n\t    /* Three points, one in, one out, one parallel, connect in-out,\n               delete parallel.. */\n\t    {\n\n\t      sh6tomain (uipt[lperm[0]], &kstat);\n\t      sh6tomain (uipt[lperm[1]], &kstat);\n\n\t      sh6idcon (&rintdat, &uipt[lperm[0]], &uipt[lperm[1]], &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t      sh6setdir (uipt[lperm[0]],\n\t\t\t uipt[lperm[1]], &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      /* UJK, Aug.92, can't delete the parallel point\n\t\t if it's in the corner. */\n\n\t      for (kn1 = kj = 0; kj < pedge->iedge; kj++)\n\t\tif (edg[lperm[2]] & (1<<kj)) kn1++;\n\n\t       if (kn1 < 2)\n\t\t {\n\t\t    sh6idkpt (&rintdat, &uipt[lperm[2]], 1, &kstat);\n\t\t    if (kstat < 0)\n\t\t      goto error;\n\t\t }\n\n\t      *jstat = 0;\n\t    }\n\t  /* ALA UJK 31.10.90 Some special analysis when simple case\n             and two nondirectional points. */\n\t  else if (kv == 2 && isimple > 0)\n\t    {\n\t      if (edg[lperm[0]] & edg[lperm[1]])\n\t\t{\n\t\t  /* The two points are on the same edge. */\n\t\t  sh6getlist (uipt[lperm[0]], uipt[lperm[1]], &klist1, &klist2, &kstat);\n\t\t  if (kstat == 0)\n\t\t    /* The points are connected, ok. */\n\t\t    *jstat = 0;\n\t\t  else\n\t\t    /* We must subdivide further. */\n\t\t    *jstat = 1;\n\t\t}\n\t      else\n\t\t{\n\t\t  /* The points are not on the same edge, connect. */\n\n\t\t  sh6tomain (uipt[lperm[0]], &kstat);\n\t\t  sh6tomain (uipt[lperm[1]], &kstat);\n\n\t\t  sh6idcon (&rintdat, &uipt[lperm[0]], &uipt[lperm[1]], &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t  /* Set status JUNCTION point. */\n\t\t  if (lpermdir[0] == 2)\n\t\t    uipt[lperm[0]]->iinter = SI_SING;\n\t\t  if (lpermdir[1] == 2)\n\t\t    uipt[lperm[1]]->iinter = SI_SING;\n\n\t\t  *jstat = 0;\n\t\t}\n\t    }\n\n\n\t  /* end 31.10.90 */\n\n\t  /* UJK 18.09.90 Marching singular cases is VERY expensiv and leads\n             to nothing.  (Number of points is here more than 2)*/\n\t  else if (lnumb[3] >= 2)\n\t    *jstat = 1;\n\t  /*end 18.09.90 */\n\n\t  else if (kv == 2 || (isimple > 0 && (lnumb[2] < 2)))\n\t    {\n\t      /* If we got two points, we always try marching as the second\n                 strategy. */\n\t      /* If we got more than two points, we march only when the\n                 input parameter isimple is set and the no more than one\n                 parallel point is given.*/\n\t      /* First check if the points can be sorted along one\n\t\t parameter direction and connected based on in/out information.\n\t\t Only for points where the tangent points in or out of\n\t\t the domain. */\n\t      kstat = 0;\n\t      if (kv%2 == 0 && lnumb[0] == kv/2 && lnumb[1] == kv/2)\n\t\t{\n\t\t  kpoints = kv;\n\t\t  sh1762_s9checkpscon(uipt, lperm, ldir, kv, lnumb,\n\t\t\t\t      &lpar, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\n\t\t  if (kstat != 1)\n\t\t    {\n\t\t      /* Prepare for reuse of array */\n\t\t      if (lpar != SISL_NULL)\n\t\t\tfreearray(lpar);\n\t\t      lpar = SISL_NULL;\n\t\t    }\n\t\t}\n\n\t      if (kstat != 1)\n\t\t{\n\t\t  /* No connection conclusion is made. Try marching */\n\t\t  s9conmarch (ps, alevel, spar, lpermdir, kv, &sparout,\n\t\t\t      &lpar, &kpoints, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t}\n\n\t      /* Branch on the given result from s9conmarch. */\n\t      if (kstat == 0)\n\t\t/* The points are not connected, continue subdividing. */\n\t\t*jstat = 1;\n\n\t      else if (kstat == 2)\n\t\t/* Only singulear points, set status ok. */\n\t\t*jstat = 0;\n\n\t      else\n\t\t{\n\t\t  /* A solution is found. Check if it is consistent with\n\t\t     the classification of the intersection points */\n\t\t  *jstat = 0;\n\t\t  for (kj=0; kj<kv; ++kj)\n\t\t    {\n\t\t      /* Count number of connections to this point */\n\t\t      int kncon = 1;\n\t\t      for (ki=kj+1; ki<kv; ++ki)\n\t\t\t{\n\t\t\t  if (lpar[ki] == lpar[kj])\n\t\t\t    ++kncon;\n\t\t\t}\n\t\t      if (kncon > 1 && ldir[lperm[lpar[kj]]] != 2)\n\t\t\t{\n\t\t\t  /* More than one connection to a non-singular\n\t\t\t     point. Dismiss. */\n\t\t\t  *jstat = 1;\n\t\t\t  break;\n\t\t\t}\n\t\t    }\n\t\t}\n\n\t      if (*jstat == 0 && kstat != 2)\n\t\t{\n\t\t  if (kpoints > kv)\n\t\t    {\n\t\t      if ((uinewpt = newarray (kpoints - kv, SISLIntpt *))\n\t\t\t  == SISL_NULL)\n\t\t\tgoto err101;\n\t\t      for (kj = kv, ki = 0; kj < kpoints; kj++, ki++)\n\t\t\t{\n\t\t\t  /* For each new point returned from s9conmarch,\n                             we create an intersection point. */\n\t\t\t  SISLIntpt *qt;\n\t\t\t  double sintpar[2];\n\n\t\t\t  sintpar[0] = sparout[2 * kj];\n\t\t\t  sintpar[1] = sparout[2 * kj + 1];\n\n\t\t\t  uinewpt[ki] = qt = hp_newIntpt (2, sintpar, DZERO,\n\t\t\t\t\t\t SI_ORD, SI_UNDEF, SI_UNDEF,\n\t\t\t\t\t\t\t  SI_UNDEF, SI_UNDEF,\n\t\t\t\t\t\t\t0, 0, nullp, nullp);\n\n\n\t\t\t  if (qt == SISL_NULL)\n\t\t\t    goto err101;\n\n\t\t\t  sh6idnpt (&rintdat, &qt, 1, &kstat);\n\t\t\t  if (kstat < 0)\n\t\t\t    goto error;\n\n\t\t\t}\n\t\t    }\n\n\t\t  /* Now we connect the points. */\n\t\t  *jstat = 0;\n\n\t\t  for (kj = 0; kj < kv; kj++)\n\t\t    {\n\t\t      ki = lpar[kj] - 1;\n\n\t\t      if (lpar[kj] > 0)\n\t\t\t{\n\t\t\t  if (lpar[kj] > kv)\n\t\t\t    {\n\t\t\t      /* SISLPoint is to be connected to a new point */\n\t\t\t      sh6tomain (uipt[lperm[kj]], &kstat);\n\t\t\t      sh6tomain (uinewpt[ki - kv], &kstat);\n\n\t\t\t      sh6idcon (&rintdat, &uipt[lperm[kj]],\n\t\t\t\t\t&uinewpt[ki - kv], &kstat);\n\t\t\t      if (kstat < 0)\n\t\t\t\tgoto error;\n\n\t\t\t      /* Newi (ujk) Set in/out direction */\n\t\t\t      if (lpermdir[kj] == 1)\n\t\t\t\tsh6setdir (uipt[lperm[kj]],\n\t\t\t\t\t   uinewpt[ki - kv], &kstat);\n\t\t\t      else if (lpermdir[kj] == -1)\n\t\t\t\tsh6setdir (uinewpt[ki - kv],\n\t\t\t\t\t   uipt[lperm[kj]], &kstat);\n\n\t\t\t      if (kstat < 0)\n\t\t\t\tgoto error;\n\t\t\t    }\n\t\t\t  else\n\t\t\t    {\n\t\t\t      /* SISLPoint is to be connected to an old point */\n\t\t\t      sh6tomain (uipt[lperm[kj]], &kstat);\n\t\t\t      sh6tomain (uipt[lperm[ki]], &kstat);\n\t\t\t      sh6idcon (&rintdat, &uipt[lperm[kj]],\n\t\t\t\t\t&uipt[lperm[ki]], &kstat);\n\t\t\t      if (kstat < 0)\n\t\t\t\tgoto error;\n\n\n\t\t\t      /* Newi (ujk) Set in/out direction */\n\t\t\t      if (lpermdir[kj] == 1 || lpermdir[ki] == -1)\n\t\t\t\tsh6setdir (uipt[lperm[kj]],\n\t\t\t\t\t   uipt[lperm[ki]], &kstat);\n\t\t\t      else if (lpermdir[kj] == -1 ||\n\t\t\t\t       lpermdir[ki] == 1)\n\t\t\t\tsh6setdir (uipt[lperm[ki]],\n\t\t\t\t\t   uipt[lperm[kj]], &kstat);\n\t\t\t      if (kstat < 0)\n\t\t\t\tgoto error;\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n\t  else\n\t    /* The input parameter isimple is not set, no marching\n               is to be done. */\n\t    *jstat = 1;\n\t}\n    }\n\n\n  goto out;\n\n/* Error in sub rutines.      */\n\nerror:*jstat = kstat;\n  s6err (\"sh1762_s9edgpscon\", *jstat, 0);\n  goto out;\n\n/* Error in memory allocation.      */\n\nerr101:*jstat = -101;\n  s6err (\"sh1762_s9edgpscon\", *jstat, 0);\n  goto out;\n\n/* Error dimension.      */\n\nerr200:*jstat = -200;\n  s6err (\"sh1762_s9edgpscon\", *jstat, 0);\n  goto out;\n\nout:\n  if (uipt != SISL_NULL)\n    freearray (uipt);\n  if (edg != SISL_NULL)\n    freearray (edg);\n  if (ldir != SISL_NULL)\n    freearray (ldir);\n  if (sval != SISL_NULL)\n    freearray (sval);\n\n  if (uinewpt != SISL_NULL)\n    freearray (uinewpt);\n  if (spar != SISL_NULL)\n    freearray (spar);\n  if (sparout != SISL_NULL)\n    freearray (sparout);\n  if (lpar != SISL_NULL)\n    freearray (lpar);\n  if (lperm != SISL_NULL)\n    freearray (lperm);\n  if (lpermdir != SISL_NULL)\n    freearray (lpermdir);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1762_s9checkpscon (SISLIntpt *uipt[], int perm[], int ndir[], int npoints, \n\t\t     int numb_type[], int *mcon[], int *jstat)\n#else\nstatic void\n  sh1762_s9checkpscon (uipt, perm, ndir, npoints, numb_type, mcon, jstat)\n     SISLIntpt *uipt[];\n     int perm[];\n     int ndir[];\n     int npoints;\n     int numb_type[];\n     int *mcon[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Check if a set of points can be sorted along one\n*              parameter direction and connected based on in/out information.\n*              Only for points where the tangent points in or out of\n*\t       the domain.\n*\n*\n* INPUT      : uipt     - Array of intersection point at surface boundaries\n*              perm     - Permutation array representing sequence in s9edgpscon\n*              ndir     - Configuration of intersection curve at points\n*                         =  0 : Parallel to surface boundary\n*                         =  1 : Pointing into surface\n*                         = -1 : Pointing out\n*                         =  2 : Singular point\n*                         = 10 : Touching corner of surface domain\n*              numb_type - Number of intersection points according to each\n*                          type specified in ndir\n*\n*\n* OUTPUT     : mcon     - Connection between points\n*                       - 0 : No connection\n*                       - k : Can connect to point number k (k > 0, points\n*                             counted from 1)\n*              jstat    - status messages\n*                           = 1     : Connections defined\n*                           = 0     : No connections found\n*                           < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 2019-03\n*\n*********************************************************************\n*/\n{\n  int ki, kj, ka, kb, ok_pts;\n  int ind;\n  int *perm2 = SISL_NULL;  /* Permutation array for sorting of points */\n\n   *jstat = 0;\n  if (!(npoints%2 == 0 && numb_type[0]==npoints/2 && numb_type[1]==npoints/2))\n    goto out;   /* Input requirements not satisfied */\n\n\n  if ((*mcon = new0array (npoints, int)) == SISL_NULL)    \n    goto err101;\n  if ((perm2 = new0array (npoints, int)) == SISL_NULL)    \n    goto err101;\n\n  for (ki=0; ki<npoints; ++ki)\n    perm2[ki] = ki;\n\n  for (ok_pts=FALSE, ind = 0; ind<2 && (!ok_pts); ind++)\n    {\n      ok_pts = TRUE;\n      \n      for (ki=0; ki<npoints; ki++)\n\t{\n\t  for (kj=ki+1, kb=ki; kj<npoints; kj++)\n\t    if (uipt[perm[perm2[kj]]]->epar[ind] < \n\t\tuipt[perm[perm2[kb]]]->epar[ind])\n\t      kb = kj;\n\t    else if (uipt[perm[perm2[kj]]]->epar[ind] == \n\t\t     uipt[perm[perm2[kb]]]->epar[ind])\n\t      {\n\t\tok_pts=FALSE;\n\t\tbreak;\n\t      }\n\t  \n\t  ka = perm2[ki];\n\t  perm2[ki] = perm2[kb];\n\t  perm2[kb] = ka;\n\n\t  if (ki > 0 && ndir[perm[perm2[ki]]]*ndir[perm[perm2[ki-1]]] >= 0)\n\t    ok_pts=FALSE;\n\t  if (!ok_pts) \n\t    break;\n\t}\n    }\n\n  /* Define connections */\n  if (ok_pts)\n    {\n      for (ki=0; ki<npoints; ki+=2)\n\t{\n\t  (*mcon)[perm2[ki]] = perm2[ki+1] + 1;  /* To match output from s9conmarch */\n\t  (*mcon)[perm2[ki+1]] = perm2[ki] + 1;\n\t}\n    }\n\n  *jstat = (ok_pts) ? 1 : 0;\n  goto out;\n\n/* Error in memory allocation.      */\n\nerr101:*jstat = -101;\n  s6err (\"sh1762_s9checkpscon\", *jstat, 0);\n  goto out;\n\n out:\n  if (perm2 != SISL_NULL)\n    freearray(perm2);\n}\n\n\f\n#if 0\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1762_s9simple (SISLObject * po1, SISLObject * po2, SISLEdge * vedge[],\n\t\t int *jstat)\n#else\nstatic void\nsh1762_s9simple (po1, po2, vedge, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLEdge *vedge[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : A simle case test were we have edge intersections.\n*              In this case we just test if every B-spline bases\n*              from the orginal object is divided.\n*\n*\n* INPUT      : po1      - First  object in intersection.\n*              po2      - Second object in intersection.\n*\n*\n* OUTPUT     : jstat    - status messages\n*                           = 1     : A simple case.\n*                           = 0     : No simple case.\n*                           < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-06.\n*\n*********************************************************************\n*/\n{\n  int kstat;\n  int kk1, kk2;\n  int kn1, kn2;\n  int kdim, knum;\n  int klin1 = 0, klin2 = 0;\n  double *et1, *et2;\n  double tstart1, tstart2, tend1, tend2;\n  double tvolorg, tvol, tvolfac;\n  SISLIntpt **up = SISL_NULL;\n\n  kdim = po1->s1->idim;\n  if (kdim != po2->s1->idim)\n    goto err106;\n\n\n  /* Init to no simpel case. */\n  *jstat = 0;\n\n  /* Count number of different edge-intersection points. */\n  /* sh1762_s9edgpoint (vedge, &up, &knum, &kstat); */\n  sh6edgpoint (vedge, &up, &knum, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* No point on edge, continue subdividing. */\n  if (knum == 0)\n    goto out;\n\n  /* We test if one of the two objects is liniar. */\n  if (po1->s1->pdir != SISL_NULL)\n    if (po1->s1->pdir->igtpi == 0 && po1->s1->pdir->aang <= ANGULAR_TOLERANCE)\n      klin1 = 1;\n\n  if (po2->s1->pdir != SISL_NULL)\n    if (po2->s1->pdir->igtpi == 0 && po2->s1->pdir->aang <= ANGULAR_TOLERANCE)\n      klin2 = 1;\n  /* UJK, This is a coincidence or simple case test ? */\n  /* Both objects are linear, stop subdividing. */\n  /*  if (klin1 == 1 && klin2 == 1)\n     {\n     *jstat = 1;\n     goto out;\n     } */\n\n  /* Set different percent factor depending on number of edge points. */\n  if (knum == 1)\n    tvolfac = (double) 0.0001;\n  else\n    tvolfac = (double) 0.00390625;\n\n  /* Get attributes from surface no 1. */\n  tstart1 = po1->s1->et1[po1->s1->ik1 - 1];\n  tend1 = po1->s1->et1[po1->s1->in1];\n  tstart2 = po1->s1->et2[po1->s1->ik2 - 1];\n  tend2 = po1->s1->et2[po1->s1->in2];\n\n  et1 = po1->o1->s1->et1;\n  et2 = po1->o1->s1->et2;\n  kk1 = po1->o1->s1->ik1;\n  kk2 = po1->o1->s1->ik2;\n  kn1 = po1->o1->s1->in1;\n  kn2 = po1->o1->s1->in2;\n\n  tvolorg = (et1[kn1] - et1[kk1 - 1]) * (et2[kn2] - et2[kk2 - 1]);\n  tvol = (tend1 - tstart1) * (tend2 - tstart2);\n\n  /* Get attributes from surface no 1. */\n  tstart1 = po2->s1->et1[po2->s1->ik1 - 1];\n  tend1 = po2->s1->et1[po2->s1->in1];\n  tstart2 = po2->s1->et2[po2->s1->ik2 - 1];\n  tend2 = po2->s1->et2[po2->s1->in2];\n\n  et1 = po2->o1->s1->et1;\n  et2 = po2->o1->s1->et2;\n  kk1 = po2->o1->s1->ik1;\n  kk2 = po2->o1->s1->ik2;\n  kn1 = po2->o1->s1->in1;\n  kn2 = po2->o1->s1->in2;\n\n  tvolorg = tvolorg * (et1[kn1] - et1[kk1 - 1]) * (et2[kn2] - et2[kk2 - 1]);\n  tvol = tvol * (tend1 - tstart1) * (tend2 - tstart2);\n\n  if (tvol <= tvolorg * tvolfac)\n    *jstat = 1;\n\n  goto out;\n\n  /* Error in input. Dimensions of curves conflicting. */\n\nerr106:*jstat = -106;\n  s6err (\"sh1762_s9simple\", *jstat, 0);\n  goto out;\n\n  /* Error in sub rutines.      */\n\nerror:*jstat = kstat;\n  s6err (\"sh1762_s9simple\", *jstat, 0);\n  goto out;\n\nout:if (up != SISL_NULL)\n    freearray (up);\n}\n#endif\n\f\n#if 0\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1762_s9reex (SISLObject * po1, SISLObject * po2, SISLEdge * vedge[],\n\t       double aepsge, SISLIntdat * pintdat, int *jstat)\n#else\nstatic void\nsh1762_s9reex (po1, po2, vedge, aepsge, pintdat, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLEdge *vedge[];\n     double aepsge;\n     SISLIntdat *pintdat;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Aa extra last test whether the rest of the rutine\n*              have done theire jobb. If no edge points is\n*              connected to an internal or another edge point.\n*              we just connecet.\n*\n*\n* INPUT      : po1      - First  object in intersection.\n*              po2      - Second object in intersection.\n*              vedge[2] - SISLEdge intersections.\n*              aepsge   - Geometry tolerance.\n*\n*\n* INPUT/OUTPUT: pintdat - Intersections dates.\n*\n*\n* OUTPUT     : jstat    - status messages\n*                           = 0     : OK!.\n*                           = 1     : Updating is performed.\n*                           < 0     : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-07.\n* REWISED BY : Vibeke Skytt, SI, 92-10. Set status if updating performed.\n*\n*********************************************************************\n*/\n{\n  int kstat;\n  SISLIntpt **up = SISL_NULL;\n\n  *jstat = 0;\n\n  if (po1->iobj == SISLSURFACE && po2->iobj == SISLSURFACE)\n    {\n      int knum = 0;\n\n      if (vedge[0]->ipoint + vedge[1]->ipoint > 1)\n\t{\n\t  /* The edges might be corrupt caused by killpoint,\n             check existance of edgepoints. */\n\n\t  int kn1, kn, ki, kj;\n\t  SISLPtedge *qpt;\n\n\t  kn1 = pintdat->ipoint;\n\n\t  /* Loop for both objects*/\n\t  for (kn = 0; kn < 2; kn++)\n\t    if (vedge[kn] != SISL_NULL)\n\t      /* Loop for objects edges*/\n\t      for (kj = 0; kj < vedge[kn]->iedge; kj++)\n\t\t/* Loop for all points on edge*/\n\t\tfor (qpt = vedge[kn]->prpt[kj]; qpt != SISL_NULL; qpt = qpt->pnext)\n\t\t  {\n\t\t    /* Loop for all points in intersection data*/\n\t\t    for (ki = 0; ki < kn1; ki++)\n\t\t      if (qpt->ppt == pintdat->vpoint[ki])\n\t\t\tbreak;\n\n\t\t    /* SISLPoint not found, quit! */\n\t\t    if (ki == kn1)\n\t\t      goto out;\n\n\t\t  }\n\n\t  /* sh1762_s9edgpoint (vedge, &up, &knum, &kstat); */\n\t  sh6edgpoint (vedge, &up, &knum, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n\n      if (knum > 1)\n\t{\n\t  int ki, kj;\n\t  int klist1, klist2;\n\t  double *spar;\n\n\t  /* We have to examine if any intersection points\n             point to an internal or an other edge point. */\n\n\t  for (ki = 0; ki < knum; ki++)\n\t    if (sh6nmbmain (up[ki], &kstat) > 0)\n\t      {\n\t\tfor (kj = 0; kj < knum; kj++)\n\t\t  {\n\t\t    sh6getlist (up[ki], up[kj], &klist1, &klist2, &kstat);\n\t\t    if (kstat == 0)\n\t\t      goto out;\n\t\t  }\n\n\t\tfor (kj = 0; kj < up[ki]->no_of_curves; kj++)\n\t\t  {\n\t\t    spar = up[ki]->pnext[kj]->epar;\n\n\t\t    if (spar[0] > po1->s1->et1[po1->s1->ik1 - 1] &&\n\t\t\tspar[0] < po1->s1->et1[po1->s1->in1] &&\n\t\t\tspar[1] > po1->s1->et2[po1->s1->ik2 - 1] &&\n\t\t\tspar[1] < po1->s1->et2[po1->s1->in2] &&\n\t\t\tspar[2] > po2->s1->et1[po2->s1->ik1 - 1] &&\n\t\t\tspar[2] < po2->s1->et1[po2->s1->in1] &&\n\t\t\tspar[3] > po2->s1->et2[po2->s1->ik2 - 1] &&\n\t\t\tspar[3] < po2->s1->et2[po2->s1->in2])\n\t\t      goto out;\n\t\t  }\n\n\t      }\n\n\n\t  sh1762_s9edgsscon (vedge, po1->s1, po2->s1, pintdat, 0,\n\t\t\t     aepsge, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  /* Test if any connections is done in sh1762_s9edgsscon. */\n\n\t  if (kstat == 0) *jstat = 1;\n\t}\n    }\n  else if ((po1->iobj == SISLPOINT &&\n\t    po2->iobj == SISLSURFACE &&\n\t    po1->p1->idim == 1) ||\n\t   (po1->iobj == SISLSURFACE &&\n\t    po2->iobj == SISLPOINT &&\n\t    po2->p1->idim == 1))\n    {\n      int knum = 0;\n\n      if (vedge[0] != SISL_NULL)\n\tknum = vedge[0]->ipoint;\n      if (vedge[1] != SISL_NULL)\n\tknum += vedge[1]->ipoint;\n\n      if (knum > 1)\n\t{\n\t  /* The edges might be corrupt caused by killpoint,\n             check existance of edgepoints. */\n\n\t  int kn1, kn, ki, kj;\n\t  SISLPtedge *qpt;\n\n\t  kn1 = pintdat->ipoint;\n\n\t  /* Loop for both objects*/\n\t  for (kn = 0; kn < 2; kn++)\n\t    if (vedge[kn] != SISL_NULL)\n\t      /* Loop for objects edges*/\n\t      for (kj = 0; kj < vedge[kn]->iedge; kj++)\n\t\t/* Loop for all points on edge*/\n\t\tfor (qpt = vedge[kn]->prpt[kj]; qpt != SISL_NULL; qpt = qpt->pnext)\n\t\t  {\n\t\t    /* Loop for all points in intersection data*/\n\t\t    for (ki = 0; ki < kn1; ki++)\n\t\t      if (qpt->ppt == pintdat->vpoint[ki])\n\t\t\tbreak;\n\n\t\t    /* SISLPoint not found, quit! */\n\t\t    if (ki == kn1)\n\t\t      goto out;\n\n\t\t  }\n\n\t  /* sh1762_s9edgpoint (vedge, &up, &knum, &kstat); */\n\t  sh6edgpoint (vedge, &up, &knum, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n\n      if (knum > 1)\n\t{\n\t  int ki, kj;\n\t  int klist1, klist2;\n\t  double *spar;\n\t  SISLSurf *qs1;\n\n\t  /* We have to examine if any intersection points\n             point to an internal or an other edge point. */\n\n\t  if (po1->iobj == SISLSURFACE)\n\t    qs1 = po1->s1;\n\t  else\n\t    qs1 = po2->s1;\n\n\t  for (ki = 0; ki < knum; ki++)\n\t    if (sh6nmbmain (up[ki], &kstat) > 0)\n\t      {\n\t\tfor (kj = 0; kj < knum; kj++)\n\t\t  {\n\t\t    sh6getlist (up[ki], up[kj], &klist1, &klist2, &kstat);\n\t\t    if (kstat == 0)\n\t\t      goto out;\n\t\t  }\n\n\t\tfor (kj = 0; kj < up[ki]->no_of_curves; kj++)\n\t\t  {\n\t\t    spar = up[ki]->pnext[kj]->epar;\n\n\t\t    /* ALA and UJK 19.09.90, To treat the problem of\n                       junction points, we have introduced equality\n                       in this test. */\n\t\t    if (spar[0] >= qs1->et1[qs1->ik1 - 1] &&\n\t\t\tspar[0] <= qs1->et1[qs1->in1] &&\n\t\t\tspar[1] >= qs1->et2[qs1->ik2 - 1] &&\n\t\t\tspar[1] <= qs1->et2[qs1->in2])\n\t\t      goto out;\n\t\t  }\n\n\t      }\n\n\n\t  sh1762_s9edgpscon (vedge[(po1->iobj == SISLSURFACE ? 0 : 1)],\n\t\t       (po1->iobj == SISLSURFACE ? po2 : po1)->p1->ecoef[0],\n\t\t\t     qs1, 1, pintdat, aepsge, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  /* Test if any connections is done in sh1762_s9edgpscon. */\n\n\t  if (kstat == 0) *jstat = 1;\n\t}\n    }\n\n  goto out;\n\n/* Error in subroutines.      */\n\nerror:*jstat = kstat;\n  s6err (\"sh1762_s9reex\", *jstat, 0);\n  goto out;\n\nout:if (up != SISL_NULL)\n    freearray (up);\n}\n\f\n#endif /* if 0 */\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1762_s9ptiter (SISLObject * po1, SISLObject * po2, double aepsge,\n\t       SISLIntdat ** pintdat, SISLEdge *vedge[], int *jstat)\n#else\nstatic void\nsh1762_s9ptiter (po1, po2, aepsge, pintdat, vedge, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double     aepsge;\n     SISLIntdat **pintdat;\n     SISLEdge   *vedge[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : In point-object intersection, there is no overlap, but\n*              the objects might intersect anyway. Test if an intersection\n*              is possible, and in that case, iterate to find it. The\n*              dimension of the geometry space is greater than one.\n*\n*\n* INPUT      : po1      - First  object in intersection.\n*              po2      - Second object in intersection.\n*              aepsge   - Geometry tolerance.\n*              vedge    - Intersections found at the ends of the objects.\n*\n*\n* INPUT/OUTPUT: pintdat - Intersections data.\n*\n*\n* OUTPUT     : jstat    - status messages\n*                           = 0     : OK!.\n*                           = 1     : Updating is performed.\n*                           < 0     : error\n*\n*\n* METHOD     : First try to intercept by checking how close the point is\n*              to the endpoints/corner points of the other object, and that\n*              it is at the same side of the endpoints as the object. If this\n*              is not possible, iteration is performed starting from the\n*              closest endpoint. If the iteration produced an intersection\n*              this is stored, otherwise no intersection is possible.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Vibeke Skytt, SI, 92-10.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;\n   int kturn;      /* Indicates if the order of the objects is changed.      */\n   int kdim;         /* Dimension of geometry space.                         */\n   int kcrv;         /* Index of curve in array of edge intersections.       */\n   double tptdist1;  /* Distance between point and first endpoint of curve.  */\n   double tptdist2;  /* Distance between point and second endpoint of curve. */\n   double tcoefd1,tcoefd2;   /* Distance between vertices of curve.          */\n   double tstart,tend; /* Endparameters of curve used in iteration.          */\n   double tref;        /* Referance value in equality test.                  */\n   double tpar,tres;   /* Start- and endparameter of intersection point.     */\n   double *sc1;      /* Pointer to coefficient of curve.                     */\n   double *sc2;      /* Pointer to coefficient of curve.                     */\n   double sdiff1[3]; /* Vector between point and endpoint of object.         */\n   double sdiff2[3]; /* Vector between endpoint of object and closest inner\n\t\t\tvertex.                                              */\n   double *nullp = SISL_NULL;\n   SISLPoint *qpt;   /* Pointer to the point in the intersection.            */\n   SISLObject *qobj2; /* Pointer to the other object in the intersection.    */\n   SISLCurve *qcrv;  /* Pointer to the curve in the intersection.            */\n   SISLIntpt *qt = SISL_NULL; /* Pointer to intersection point.                   */\n\n   /* Find the order of the objects. */\n\n   if (po1->iobj == SISLPOINT)\n   {\n      qpt = po1->p1;\n      qobj2 = po2;\n      kturn = 0;\n   }\n   else if (po2->iobj == SISLPOINT)\n   {\n      qpt = po2->p1;\n      qobj2 = po1;\n      kturn = 1;\n   }\n   else\n      goto err122;\n\n   /* Find dimension of geometry space. */\n\n   kdim = qpt->idim;\n\n   if (qobj2->iobj == SISLCURVE)\n   {\n      /* Curve object intersection. Compute distances between point and\n\t endpoints of curve, and between endpoints of curve and closest\n\t vertex.        */\n\n      kcrv = 1 - kturn;\n      qcrv = qobj2->c1;\n      sc1 = qcrv->ecoef;\n      sc2 = qcrv->ecoef + kdim*(qcrv->in - 1);\n\n      if (qcrv->in == 2)\n      {\n\t /* No intersection is possible.  */\n\n\t *jstat = 0;\n\t goto out;\n      }\n\n      tptdist1 = s6dist(qpt->ecoef,sc1,kdim);\n      tptdist2 = s6dist(qpt->ecoef,sc2,kdim);\n      tcoefd1 = s6dist(sc1,sc1+kdim,kdim);\n      tcoefd2 = s6dist(sc2,sc2-kdim,kdim);\n\n      if (tptdist1 > (double)1.5*tcoefd1 && tptdist2 > (double)1.5*tcoefd2)\n      {\n\t /* The point is not close to an endpoint of the curve.\n\t    No intersection. NB! It may be necessary to make this\n\t    test less strict when we have gained some experience\n\t    with this routine. */\n\n\t *jstat = 0;\n\t goto out;\n      }\n\n      if (tptdist1 < tptdist2 && tptdist1 <= (double)1.5*tcoefd1)\n      {\n\t s6diff(qpt->ecoef,sc1,kdim,sdiff1);\n\t s6diff(sc1+kdim,sc1,kdim,sdiff2);\n      }\n      else\n      {\n\t s6diff(qpt->ecoef,sc2,kdim,sdiff1);\n\t s6diff(sc2-kdim,sc2,kdim,sdiff2);\n      }\n\n      /* Check if the point lies on the same side of the closest endpoint\n\t of the curve as the curve itself.                                */\n\n      if (s6scpr(sdiff1,sdiff2,kdim) < DZERO)\n      {\n\t /* No intersection.  */\n\n\t *jstat = 0;\n\t goto out;\n      }\n\n      /* Iterate to find the intersection point. */\n\n      tstart = qcrv->et[qcrv->ik - 1];\n      tend = qcrv->et[qcrv->in];\n      tref = tend - tstart;\n\n      if (tptdist1 < tptdist2 && tptdist1 <= (double)1.5*tcoefd1)\n      {\n\t tpar = tstart;\n\n\t /* Check if there exists an intersection in the start of the\n\t    curve.  */\n\n\t if (vedge[kcrv]->prpt[0] != SISL_NULL)\n\t {\n\t    /* No iteration is to be performed. */\n\n\t    *jstat = 0;\n\t    goto out;\n\t }\n      }\n      else\n      {\n\t tpar = tend;\n\n\t /* Check if there exists an intersection in the end of the\n\t    curve.  */\n\n\t if (vedge[kcrv]->prpt[1] != SISL_NULL)\n\t {\n\t    /* No iteration is to be performed. */\n\n\t    *jstat = 0;\n\t    goto out;\n\t }\n      }\n\n      s1771 (qpt, qcrv, aepsge,\n\t     tstart, tend, tpar, &tres, &kstat);\n      if (kstat < 0)\n\t goto error;\n\n      if (kstat == 1)\n\t /*Intersection point found. Control edges. */\n\t if (DEQUAL (tres+tref, tstart+tref) || DEQUAL (tres+tref, tend+tref))\n\t    kstat = 0;\n\n      if (kstat == 1)\t/* Intersection point found. */\n      {\n\t *jstat = 1;\t/* Mark intersection found.  */\n\n\t /* Making intersection point. */\n\t qt = hp_newIntpt (SISLCURVE, &tres, DZERO, SI_ORD,\n\t\t\t   SI_UNDEF, SI_UNDEF, SI_UNDEF, SI_UNDEF,\n\t\t\t   0, 0, nullp, nullp);\n\n\t if (qt == SISL_NULL)\n\t    goto err101;\n\n\t /* Uppdating pintdat. */\n\t sh6idnpt (pintdat, &qt, 1, &kstat);\n\t if (kstat < 0)\n\t    goto error;\n      }\n   }\n   else\n   {\n      /* The other object is a surface. For the time being, set no\n\t intersection. This part of the routine will be implemented\n\t later. */\n\n      *jstat = 0;\n      goto out;\n   }\n\n   goto out;\n\n   /* Error in space allocation.  */\n\n   err101 : *jstat = -101;\n   goto out;\n\n   /* None of the objects is a point. */\n\n   err122 : *jstat = -122;\n   goto out;\n\n   /* Error in lower level routine.  */\n\n   error : *jstat = kstat;\n   goto out;\n\n\n   out:\n      return;\n}\n"
  },
  {
    "path": "src/sh1779.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1779.c,v 1.2 2001-03-19 15:59:05 afr Exp $\n *\n */\n\n\n#define SH1779\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh1779 (SISLObject * po1, SISLObject * po2, double aepsge,\n\tSISLIntdat ** rintdat, SISLIntpt * pintpt,\n\tint *jnewpt, int *jstat)\n#else\nvoid\nsh1779 (po1, po2, aepsge, rintdat, pintpt, jnewpt, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     SISLIntdat **rintdat;\n     SISLIntpt *pintpt;\n     int *jnewpt;\n     int *jstat;\n#endif\n\n /* UPDATE: (ujk) : Must tune the test on when to use local\n    info (=subtask no ?),\n    As in sh1780 it is necessary to determine when a helppoint\n    is close enough to a mainpoint to be neglected.\n    sh1784 does not tell if it march outside the surface,\n    this might be a problem. */\n\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Set pre-topology data in 3-dimensional curve-surface\n*              intersection. Also find help points if necessary.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              aepsge   - Geometry resolution.\n*              rintdat  - Intersection data structure.\n*              pintpt   - Current intersection point.\n*\n*\n* OUTPUT     : pintpt   - Intersection point after updating pre-topology.\n*              jnewpt   - Number of new int.pt. created.\n*              jstat    - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      : shevalc    -  ? (s1221 used )Evaluate curve using filtered coefficients.\n*              s1421      -  Evaluate surface using filtered coefficients.\n*              sh1784     -  March along curve as long as it coincide\n*                            with a surface.\n*              s6ang      -  Angle between two vectors.\n*              s6length   -  Length of vector.\n*              s6dist     -  Distance between two points.\n*              sh6idcon   -  Connect intersection points.\n*              sh6genhbrs -  Get neighbours.\n*              sh6getgeo  -  Get geometric info from intersection point.\n*              sh6settop  -  Set topology of intersection point.\n*              hp_newIntpt   -  Create new intersection point.\n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SI, Oslo, Norway. 04.91.\n*              Ulf J. Krystad, SI, 06.91.\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                        */\n  int ki;\t\t\t/* Counters.                               */\n  int kleft1 = 0, kleft2 = 0;\t/* Parameters to the evaluator.            */\n  int kdim;\t\t\t/* Dimension of geometry space.            */\n  int kpos = 0;\t\t\t/* Current position in int.pt. array.      */\n  int kpar1, kpar2;\t\t/* Index of parameter value of object.     */\n  int kn;\t\t\t/* Number of vertices of curve.            */\n  int kk;\t\t\t/* Order of curve.                         */\n  int kmarch = 0;\t\t/* Indicates if marching is necessary.     */\n  int lleft[2];\t\t\t/* Array storing pre-topology information. */\n  int lright[2];\t\t/* Array storing pre-topology information. */\n  int *ll1, *ll2, *lr1, *lr2;\t/* Pointers into pre-topology arrays.   */\n  double tref;\t\t\t/* Referance value in equality test.       */\n  double *st;\t\t\t/* Knot vector of curve.                   */\n  double sder[9];\t\t/* Result of curve evaluation.             */\n  double stang[3];\t\t/* Tangent vector of curve.                */\n  double snorm[3];\t\t/* Normal vector of surface.               */\n  double slast[3];\t\t/* Last parameter value of coincidence.    */\n  double snext[3];\t\t/* First parameter value outside interval\n\t\t\t           of coincidence.                         */\n  double *ret_val;\t\t/* Pointer to geo data from sh6getgeom     */\n  double *ret_norm;\t\t/* Pointer to geo data from sh6getgeom     */\n  double *sptpar = pintpt->epar;/* Pointer to parameter values of int.pt.  */\n  SISLCurve *qc;\t\t/* Pointer to the curve.                   */\n  SISLSurf *qs;\t\t\t/* Pointer to the surface.                 */\n  SISLIntpt *uintpt[2];\t\t/* Array containing new intersection points. */\n  SISLIntpt *qpt1, *qpt2;\t/* Intersection points in list.            */\n  double *nullp = SISL_NULL;\n  double sf_low_lim[2];\n  double sf_high_lim[2];\n  SISLIntpt *qprev = SISL_NULL;\n  SISLIntpt *qnext = SISL_NULL;\n\n  /* Don't make pretop for help points ! */\n  if (sh6ishelp (pintpt))\n    {\n      *jstat = 0;\n      goto out;\n    }\n\n  /* Set pointers into the arrays storing pre-topology information. */\n\n  if (po1->iobj == SISLCURVE)\n    {\n      qc = po1->c1;\n      qs = po2->s1;\n\n      kpar1 = 0;\n      kpar2 = 1;\n      ll1 = lleft;\n      lr1 = lright;\n      ll2 = lleft + 1;\n      lr2 = lright + 1;\n    }\n  else\n    {\n      qc = po2->c1;\n      qs = po1->s1;\n\n      kpar1 = 2;\n      kpar2 = 0;\n      ll1 = lleft + 1;\n      lr1 = lright + 1;\n      ll2 = lleft;\n      lr2 = lright;\n    }\n\n  /* Look for existing help points */\n  for (ki=0; ki<pintpt->no_of_curves; ++ki)\n    {\n      if (sh6ismain(pintpt->pnext[ki]) || pintpt->pnext[ki]->no_of_curves > 1)\n\tcontinue;\n      if (pintpt->pnext[ki]->epar[kpar1] < pintpt->epar[kpar1])\n\tqprev = pintpt->pnext[ki];\n      else if (pintpt->pnext[ki]->epar[kpar1] > pintpt->epar[kpar1])\n\tqnext = pintpt->pnext[ki];\n    }\n  \n  /* Get pre-topology of intersection point.  */\n  sh6gettop (pintpt, -1, lleft, lright, lleft + 1, lright + 1, &kstat);\n\n  /* Describe curve partly by local parameters. */\n\n  kdim = qc->idim;\n  kk = qc->ik;\n  kn = qc->in;\n  st = qc->et;\n  tref = st[kn] - st[kk - 1];\n\n  sf_low_lim[0] = qs->et1[qs->ik1 - 1] + REL_COMP_RES;\n  sf_low_lim[1] = qs->et2[qs->ik2 - 1] + REL_COMP_RES;\n  sf_high_lim[0] = qs->et1[qs->in1] - REL_COMP_RES;\n  sf_high_lim[1] = qs->et2[qs->in2] - REL_COMP_RES;\n\n  /* Fetch geometry information, curve.  */\n  sh6getgeom ((po1->iobj == SISLCURVE) ? po1 : po2,\n\t      (po1->iobj == SISLCURVE) ? 1 : 2,\n\t      pintpt, &ret_val, &ret_norm, aepsge, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Local copy of curve tangent */\n  memcopy (stang, ret_val + kdim, kdim, DOUBLE);\n\n  /* Fetch geometry information, surface.  */\n  sh6getgeom ((po1->iobj == SISLSURFACE) ? po1 : po2,\n\t      (po1->iobj == SISLSURFACE) ? 1 : 2,\n\t      pintpt, &ret_val, &ret_norm, aepsge, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Local copy of surface normal */\n  memcopy (snorm, ret_norm, kdim, DOUBLE);\n\n\n  /* (ALA) Test if local information may be used to compute pre-topology. */\n  s6length (snorm, kdim, &kstat);\n  s6length (stang, kdim, &ki);\n\n  if (!kstat || !ki || fabs (PIHALF - s6ang (snorm, stang, kdim)) < 0.05)\n    {\n      /* Check if the intersection point lies at the start point of\n         the curve. */\n\n      if (DEQUAL (sptpar[kpar1] + tref, st[kn] + tref))\n\t;\n      else\n\t{\n\t  /* Check if the intersection point is member of a list\n             in this parameter direction of the curve. */\n\n\t  qpt1 = qpt2 = SISL_NULL;\n\t  kmarch = 1;\n\n\t  /* UPDATE (ujk) : only one list ? */\n\t  sh6getnhbrs (pintpt, &qpt1, &qpt2, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  kmarch = 0;\n\t  if (qpt1 != SISL_NULL && qpt1->epar[kpar1] > sptpar[kpar1])\n\t    *lr1 = SI_ON;\n\t  else if (qpt2 != SISL_NULL && qpt2->epar[kpar1] > sptpar[kpar1])\n\t    *lr1 = SI_ON;\n\t  else\n\t    kmarch = 1;\n\t}\n\n      if (kmarch)\n\t{\n\t  /* Perform marching to compute pre-topology. March first in the\n             positive direction of the curve.  */\n\n\t  sh1784 (qc, qs, aepsge, sptpar, (kpar1 == 0), 1, slast, snext, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  if (kstat == 1)\n\t    {\n\t      /* The endpoint of the curve is reached. */\n\t      ;\n\t    }\n\t  else if (kstat == 2)\n\t    ;\n\t  else\n\t    {\n\n\t      if (slast[kpar2] > sf_high_lim[0] ||\n\t\t  slast[kpar2 + 1] > sf_high_lim[1] ||\n\t\t  slast[kpar2] < sf_low_lim[0] ||\n\t\t  slast[kpar2 + 1] < sf_low_lim[1])\n\t\t;\n\t      else\n\t\t{\n\n\n\t\t  /* Create help point. First fetch geometry information. */\n\n\t\t  s1221 (qc, 0, slast[kpar1], &kleft1, sder, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\n\t\t  s1221 (qc, 0, snext[kpar1], &kleft1, sder + kdim, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t  s6diff (sder + kdim, sder, kdim, stang);\n\n\t\t  s1421 (qs, 1, slast + kpar2, &kleft1, &kleft2, sder, snorm, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\n\t\t  /* Discuss tangent- and normal vector, and set up pre-topology\n\t             in one direction of the curve. \t\t   */\n\n\t\t  if (s6scpr (snorm, stang, kdim) > DZERO)\n\t\t    *lr1 = SI_OUT;\n\t\t  else\n\t\t    *lr1 = SI_IN;\n\n\t\t  /* UPDATE (ujk) : Tuning on distance */\n\t\t  if (s6dist (sptpar, slast, 3) > (double) 0.05 * tref)\n\t\t    {\n\t\t      /* Create help point. Set pre-topology data as undefined. */\n\t\t      /* UPDATE (ujk) : If calculated values is stored, kder must\n\t\t         be 1 for curve and 2 for surface (sh6getgeom). Should\n\t\t         shevalc be used in stead of s1221 ? */\n\n\t\t      uintpt[kpos] = SISL_NULL;\n\t\t      if ((uintpt[kpos] = hp_newIntpt (3, slast, DZERO, -SI_ORD,\n\t\t\t\t\t      lleft[0], lright[0], lleft[1],\n\t\t\t\t    lright[1], 0, 0, nullp, nullp)) == SISL_NULL)\n\t\t\tgoto err101;\n\n\t\t      kpos++;\n\t\t    }\n\t\t}\n\t    }\n\t}\n\n      /* Check if the intersection point lies at the end point of\n         the curve. */\n\n      kmarch = 0;\n      if (DEQUAL (sptpar[kpar1] + tref, st[kk - 1] + tref))\n\t;\n      else\n\t{\n\t  /* Check if the intersection point is member of a list\n             in this parameter direction of the curve. */\n\n\t  qpt1 = qpt2 = SISL_NULL;\n\t  kmarch = 1;\n\n\t  /* UPDATE (ujk) : only one list ? */\n\t  /* UPDATE (ujk) : only one list ? */\n\t  sh6getnhbrs (pintpt, &qpt1, &qpt2, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  kmarch = 0;\n\t  if (qpt1 != SISL_NULL && qpt1->epar[kpar1] < sptpar[kpar1])\n\t    *ll1 = SI_ON;\n\t  else if (qpt2 != SISL_NULL && qpt2->epar[kpar1] < sptpar[kpar1])\n\t    *ll1 = SI_ON;\n\t  else\n\t    kmarch = 1;\n\n\t}\n\n      if (kmarch)\n\t{\n\t  /* March in the negative direction of the curve. */\n\n\t  sh1784 (qc, qs, aepsge, sptpar, (kpar1 == 0), -1, slast, snext, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  if (kstat == 1)\n\t    {\n\t      /* The endpoint of the curve is reached. */\n\t      ;\n\t    }\n\t  else if (kstat == 2)\n\t    ;\n\t  else\n\t    {\n\t      if (slast[kpar2] > sf_high_lim[0] ||\n\t\t  slast[kpar2 + 1] > sf_high_lim[1] ||\n\t\t  slast[kpar2] < sf_low_lim[0] ||\n\t\t  slast[kpar2 + 1] < sf_low_lim[1])\n\t\t;\n\t      else\n\t\t{\n\n\t\t  /* Create help point. First fetch geometry information. */\n\n\t\t  s1221 (qc, 0, slast[kpar1], &kleft1, sder, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\n\t\t  s1221 (qc, 0, snext[kpar1], &kleft1, sder + kdim, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t  s6diff (sder + kdim, sder, kdim, stang);\n\n\t\t  s1421 (qs, 1, slast + kpar2, &kleft1, &kleft2, sder, snorm, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\n\t\t  /* Discuss tangent- and normal vector, and set up pre-topology\n\t             in one direction of the curve. \t\t   */\n\n\t\t  if (s6scpr (snorm, stang, kdim) > DZERO)\n\t\t    *ll1 = SI_OUT;\n\t\t  else\n\t\t    *ll1 = SI_IN;\n\n\t\t  /* UPDATE (ujk) : Tuning on distance */\n\t\t  if (s6dist (sptpar, slast, 3) > (double) 0.05 * tref)\n\t\t    {\n\t\t      /* Create help point. Set pre-topology data as undefined. */\n\t\t      /* UPDATE (ujk) : If calculated values is stored, kder must\n\t\t         be 1 for curve and 2 for surface (sh6getgeom). Should\n\t\t         shevalc be used in stead of s1221 ? */\n\n\t\t      uintpt[kpos] = SISL_NULL;\n\t\t      if ((uintpt[kpos] = hp_newIntpt (3, slast, DZERO, -SI_ORD,\n\t\t\t\t\t      lleft[0], lright[0], lleft[1],\n\t\t\t\t    lright[1], 0, 0, nullp, nullp)) == SISL_NULL)\n\t\t\tgoto err101;\n\n\t\t      kpos++;\n\t\t    }\n\t\t}\n\t    }\n\t}\n    }\n  else\n    {\n      /* Pre-topology data of the curve may be computed from\n         local information. */\n\n      if (s6scpr (snorm, stang, kdim) > DZERO)\n\t{\n\t  *ll1 = SI_IN;\n\t  *lr1 = SI_OUT;\n\t}\n      else\n\t{\n\t  *ll1 = SI_OUT;\n\t  *lr1 = SI_IN;\n\t}\n\n    }\n\n  /* Update pre-topology of intersection point.  */\n  /* UPDATE (ujk), index = -1 ?? */\n  sh6settop (pintpt, -1, lleft[0], lright[0], lleft[1], lright[1], &kstat);\n\n  /* Join intersection points, and set pretopology of help points.  */\n\n  for (ki = 0; ki < kpos; ki++)\n    {\n      /* Help point ? */\n      if (sh6ishelp (uintpt[ki]))\n\tsh6settop (uintpt[ki], -1, *(pintpt->left_obj_1), *(pintpt->right_obj_1),\n\t\t   *(pintpt->left_obj_2), *(pintpt->right_obj_2), &kstat);\n\n      /* if (qprev && ki==0) */\n      /* \tsh6idkpt(rintdat, &qprev, 0, &kstat); */\n      /* else if (qnext && ki==1) */\n      /* \tsh6idkpt(rintdat, &qnext, 0, &kstat); */\n\t\n      sh6idcon (rintdat, &uintpt[ki], &pintpt, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* Pre-topology information computed. */\n\n  *jnewpt = kpos;\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation.  */\n\nerr101:*jstat = -101;\n  goto out;\n\n\n  /* Error lower level routine.  */\n\nerror:*jstat = kstat;\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/sh1779_at.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1779_at.c,v 1.2 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n#define SH1779_AT\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh1779_at (SISLObject * po1, SISLObject * po2, SISLIntpt * pintpt,\n\t   int *jstat)\n#else\nvoid\nsh1779_at (po1, po2, pintpt, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntpt *pintpt;\n     int *jstat;\n#endif\n\n\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Set pre-topology AT in 3-dimensional curve-surface\n*              intersection.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              pintpt   - Current intersection point.\n*\n*\n* OUTPUT     : pintpt   - Intersection point after updating pre-topology.\n*              jstat    - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      : sh6gettop  -  Get topology of intersection point.\n*              sh6settop  -  Set topology of intersection point.\n*\n* REFERENCES :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 06.91.\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                        */\n  int kpar1, kpar2;\t\t/* Index of parameter value of object.     */\n  int kn;\t\t\t/* Number of vertices of curve.            */\n  int kk;\t\t\t/* Order of curve.                         */\n  int lleft[2];\t\t\t/* Array storing pre-topology information. */\n  int lright[2];\t\t/* Array storing pre-topology information. */\n  int *ll1, *ll2, *lr1, *lr2;\t/* Pointers into pre-topology arrays.   */\n  double tref;\t\t\t/* Referance value in equality test.       */\n  double *st;\t\t\t/* Knot vector of curve.                   */\n  double *sptpar = pintpt->epar;/* Pointer to parameter values of int.pt.  */\n  SISLCurve *qc;\t\t/* Pointer to the curve.                   */\n  SISLSurf *qs;\t\t\t/* Pointer to the surface.                 */\n  double sf_low_lim[2];\n  double sf_high_lim[2];\n  /* ---------------------------------------------------------------------- */\n  /* Don't make pretop for help points ! */\n  if (sh6ishelp (pintpt))\n    {\n      *jstat = 0;\n      goto out;\n    }\n\n  /* Set pointers into the arrays storing pre-topology information. */\n  if (po1->iobj == SISLCURVE)\n    {\n      qc = po1->c1;\n      qs = po2->s1;\n      kpar1 = 0;\n      kpar2 = 1;\n      ll1 = lleft;\n      lr1 = lright;\n      ll2 = lleft + 1;\n      lr2 = lright + 1;\n    }\n  else\n    {\n      qc = po2->c1;\n      qs = po1->s1;\n\n      kpar1 = 2;\n      kpar2 = 0;\n      ll1 = lleft + 1;\n      lr1 = lright + 1;\n      ll2 = lleft;\n      lr2 = lright;\n    }\n\n  kk = qc->ik;\n  kn = qc->in;\n  st = qc->et;\n  tref = st[kn] - st[kk - 1];\n\n  sf_low_lim[0] = qs->et1[qs->ik1 - 1] + REL_COMP_RES;\n  sf_low_lim[1] = qs->et2[qs->ik2 - 1] + REL_COMP_RES;\n  sf_high_lim[0] = qs->et1[qs->in1] - REL_COMP_RES;\n  sf_high_lim[1] = qs->et2[qs->in2] - REL_COMP_RES;\n\n  sh6gettop (pintpt, -1, lleft, lright, lleft + 1, lright + 1, &kstat);\n  if (kstat < 0)\n    goto error;\n  /* Check endpoint of curve. */\n\n  if (DEQUAL (sptpar[kpar1] + tref, st[kk - 1] + tref))\n    *ll1 = SI_AT;\n  if (DEQUAL (sptpar[kpar1] + tref, st[kn] + tref))\n    *lr1 = SI_AT;\n\n  /* Update pre-topology of intersection point.  */\n  sh6settop (pintpt, -1, lleft[0], lright[0], lleft[1], lright[1], &kstat);\n  if (kstat < 0)\n    goto error;\n\n  *jstat = 0;\n  goto out;\n\n  /* Error lower level routine.  */\nerror:*jstat = kstat;\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/sh1780.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1780.c,v 1.3 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n#define SH1780\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh1780 (SISLObject * po1, SISLObject * po2, double aepsge,\n\tSISLIntdat ** rintdat, SISLIntpt * pintpt, int *jnewpt, int *jstat)\n#else\nvoid\nsh1780 (po1, po2, aepsge, rintdat, pintpt, jnewpt, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     SISLIntdat **rintdat;\n     SISLIntpt *pintpt;\n     int *jnewpt;\n     int *jstat;\n#endif\n\n /* UPDATE: (ujk) : Must tune the test on when to use local\n  info (=subtask no ?),\n  As in sh1779 it is necessary to determine when a helppoint\n  is close enough to a mainpoint to be neglected. */\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Generate help points and set pre-topology data in\n*              curve-curve intersection.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              aepsge   - Geometry resolution.\n*              rintdat  - Intersection data structure.\n*              pintpt   - Current intersection point.\n*\n*\n* OUTPUT     : pintpt   - Intersection point with updated pre-topology info.\n*              jnewpt   - Number of new int.pt. created.\n*              jstat    - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      : shevalc    -  ? (s1221 used )Evaluate curve using filtered coefficients.\n*              s1421      -  Evaluate surface using filtered coefficients.\n*              sh1783     -  March along two curves as long as they coincide.\n*              s6ang      -  Angle between two vectors.\n*              s6length   -  Length of vector.\n*              s6dist     -  Distance between two points.\n*              sh6idcon   -  Connect intersection points.\n*              sh6genhbrs -  Get neighbours.\n*              sh6getgeo  -  Get geometric info from intersection point.\n*              sh6settop  -  Set topology of intersection point.\n*              hp_newIntpt   -  Create new intersection point.\n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SI, Oslo, Norway. 04.91.\n*              Ulf J. Krystad, SI, 06.91\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                        */\n  int ki;\t\t\t/* Counters.                               */\n  int kleft1 = 0;               /* Parameters to the evaluator.            */\n  int kdim;\t\t\t/* Dimension of geometry space.            */\n  int kpos = 0;\t\t\t/* Current position in output array.       */\n  int kdir1, kdir2;\t\t/* Directions in which to march the curves.*/\n  int kk1, kk2;\t\t\t/* Orders of the two curves.               */\n  int kn1, kn2;\t\t\t/* Number of vertices in the curves.       */\n  int lleft[2];\t\t\t/* Array storing pre-topology information. */\n  int lright[2];\t\t/* Array storing pre-topology information. */\n  double tref;\t\t\t/* Reference value in equality test.       */\n  double *st1, *st2;\t\t/* Pointers to knot vectors of curves.     */\n  double sder[6];\t\t/* Result of curve evaluation.             */\n  double stang1[3];\t\t/* Tangent vector of curve.                */\n  double stang2[3];\t\t/* Tangent vector of level value.          */\n  double slast[3];\t\t/* Last parameter value of coincidence.    */\n  double snext[3];\t\t/* First parameter value outside interval\n\t\t\t           of coincidence.                         */\n  double *ret_val;\t\t/* Pointer to geo data from sh6getgeom     */\n  double *ret_norm;\t\t/* Pointer to geo data from sh6getgeom     */\n  double *sptpar = pintpt->epar;/* Parameter array of int.pt.        */\n  SISLIntpt *uintpt[2];\t\t/* Pointer to new intersection points.     */\n  double *nullp = SISL_NULL;\n\n  /* Don't make pretop for help points ! */\n  if (sh6ishelp (pintpt))\n    {\n      *jstat = 0;\n      goto out;\n    }\n\n  /* Test dimension of geometry space.  */\n\n  kdim = po1->c1->idim;\n  if (kdim > 3)\n    goto err108;\n  if (kdim != po2->c1->idim)\n    goto err106;\n\n  /* Express the curve by local parameters.  */\n\n  kn1 = po1->c1->in;\n  kk1 = po1->c1->ik;\n  st1 = po1->c1->et;\n  kn2 = po2->c1->in;\n  kk2 = po2->c1->ik;\n  st2 = po2->c1->et;\n  tref = MAX (st1[kn1] - st1[kk1 - 1], st2[kn2] - st2[kk2 - 1]);\n\n  /* Fetch already existing topology. */\n  sh6gettop (pintpt, -1, lleft, lright, lleft + 1, lright + 1, &kstat);\n\n  /* Fetch geometry information, first curve.  */\n  sh6getgeom (po1, 1, pintpt, &ret_val, &ret_norm, aepsge, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Local copy of curve tangent */\n  memcopy (stang1, ret_val + kdim, kdim, DOUBLE);\n\n  /* Fetch geometry information,second curve.  */\n  sh6getgeom (po2, 2, pintpt, &ret_val, &ret_norm, aepsge, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Local copy of curve tangent */\n  memcopy (stang2, ret_val + kdim, kdim, DOUBLE);\n\n  /* Compute the angle between the tangent vectors of the curves\n     in the current intersection point, and check if marching is\n     necessary to compute the pre-topology information.  */\n\n  /* UPDATE (ujk) : tune */\n  if (s6ang (stang1, stang2, kdim) <= ANGULAR_TOLERANCE)\n    {\n      /* Perform marching in positive direction of the first curve.  */\n\n      kdir1 = 1;\n      kdir2 = (s6scpr (stang1, stang2, kdim) >= DZERO) ? 1 : -1;\n\n      /* Check if the intersection point is situated at the endpoint\n\t of a curve.             */\n\n      if (DEQUAL (sptpar[0] + tref, st1[kn1] + tref) ||\n\t  (kdir2 == 1 && DEQUAL (sptpar[1] + tref, st2[kn2] + tref)) ||\n\t  (kdir2 == -1 && DEQUAL (sptpar[1] + tref, st2[kk2 - 1] + tref)))\n\t{\n\t}\n      else\n\t{\n\t  /* Perform marching.  */\n\n\t  sh1783 (po1->c1, po2->c1, aepsge, sptpar, kdir1, kdir2, slast,\n\t\t  snext, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  if (kstat > 0)\n\t    {\n\t      /* An intersection interval is found. */\n\t      /* Set pre-topology */\n\n\t      lright[0] = SI_ON;\n\t      if (kdir2 == 1)\n\t\tlright[1] = SI_ON;\n\t      else\n\t\tlleft[1] = SI_ON;\n\t    }\n\t  else\n\t    {\n\t      /* Create help point. First fetch geometry information. */\n\n\t      s1221 (po1->c1, 0, slast[0], &kleft1, sder, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      s1221 (po1->c1, 0, snext[0], &kleft1, sder + kdim, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t      s6diff (sder + kdim, sder, kdim, stang1);\n\n\t      s1221 (po2->c1, 0, slast[1], &kleft1, sder, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      s1221 (po2->c1, 0, snext[1], &kleft1, sder + kdim, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t      s6diff (sder + kdim, sder, kdim, stang2);\n\n\t      /* Discuss directions of vectors and set up pre-topology\n\t         information in one direction of the curves.             */\n\n\t      if ((stang1[0] * stang2[1] - stang1[1] * stang2[0]) * (double) kdir2\n\t\t  < DZERO)\n\t\tlright[0] = SI_OUT;\n\t      else\n\t\tlright[0] = SI_IN;\n\n\t      if (kdir2 == 1)\n\t\tlright[1] = (lright[0] == SI_IN) ? SI_OUT : SI_IN;\n\t      else\n\t\tlleft[1] = (lright[0] == SI_OUT) ? SI_OUT : SI_IN;\n\n\t      /* UPDATE (ujk) : tune */\n\t      if (s6dist (sptpar, slast, 2) > (double) 0.05 * tref)\n\t\t{\n\t\t  /* Create help point. Set pre-topology data as SI_UNDEF. */\n\n\t\t  uintpt[kpos] = SISL_NULL;\n\t\t  if ((uintpt[kpos] = hp_newIntpt (2, slast, DZERO, -SI_ORD,\n\t\t\t\t     SI_UNDEF, SI_UNDEF, SI_UNDEF, SI_UNDEF,\n\t\t\t\t\t       0, 0, nullp, nullp)) == SISL_NULL)\n\t\t    goto err101;\n\n\t\t  kpos++;\n\t\t}\n\t    }\n\t}\n\n      /* Perform marching in negative direction of the first curve.  */\n\n      kdir1 = -1;\n      kdir2 = -kdir2;\n\n      /* Check if the intersection point is situated at the endpoint\n\t of a curve.             */\n\n      if (DEQUAL (sptpar[0] + tref, st1[kk1 - 1] + tref) ||\n\t  (kdir2 == 1 && DEQUAL (sptpar[1] + tref, st2[kn2] + tref)) ||\n\t  (kdir2 == -1 && DEQUAL (sptpar[1] + tref, st2[kk2 - 1] + tref)))\n\t{\n\t}\n      else\n\t{\n\t  /* Perform marching.  */\n\n\t  sh1783 (po1->c1, po2->c1, aepsge, sptpar, kdir1, kdir2, slast,\n\t\t  snext, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  if (kstat > 0)\n\t    {\n\t      /* An intersection interval is found. Set pre-topology. */\n\n\t      lleft[0] = SI_ON;\n\t      if (kdir2 == 1)\n\t\tlright[1] = SI_ON;\n\t      else\n\t\tlleft[1] = SI_ON;\n\t    }\n\t  else\n\t    {\n\t      /* Create help point. First fetch geometry information. */\n\n\t      s1221 (po1->c1, 0, slast[0], &kleft1, sder, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      s1221 (po1->c1, 0, snext[0], &kleft1, sder + kdim, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t      s6diff (sder + kdim, sder, kdim, stang1);\n\n\t      s1221 (po2->c1, 0, slast[1], &kleft1, sder, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      s1221 (po2->c1, 0, snext[1], &kleft1, sder + kdim, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t      s6diff (sder + kdim, sder, kdim, stang2);\n\n\t      /* Discuss directions of vectors and set up pre-topology\n\t         information in one direction of the curves.             */\n\n\t      if ((stang1[0] * stang2[1] - stang1[1] * stang2[0]) * (double) kdir2\n\t\t  < DZERO)\n\t\tlleft[0] = SI_OUT;\n\t      else\n\t\tlleft[0] = SI_IN;\n\n\t      if (kdir2 == -1)\n\t\tlleft[1] = (lleft[0] == SI_IN) ? SI_OUT : SI_IN;\n\t      else\n\t\tlright[1] = (lleft[0] == SI_OUT) ? SI_OUT : SI_IN;\n\n\t      /* UPDATE (ujk) : tune */\n\t      if (s6dist (sptpar, slast, 2) > (double) 0.05 * tref)\n\t\t{\n\t\t  /* Create help point. Set pre-topology data as SI_UNDEF. */\n\n\t\t  uintpt[kpos] = SISL_NULL;\n\t\t  if ((uintpt[kpos] = hp_newIntpt (2, slast, DZERO, -SI_ORD,\n\t\t\t\t     SI_UNDEF, SI_UNDEF, SI_UNDEF, SI_UNDEF,\n\t\t\t\t\t       0, 0, nullp, nullp)) == SISL_NULL)\n\t\t    goto err101;\n\n\t\t  kpos++;\n\t\t}\n\t    }\n\t}\n    }\n  else\n    {\n      /* The pretopology may be computed using local information. */\n\n      if (stang1[0] * stang2[1] - stang1[1] * stang2[0] < DZERO)\n\t{\n\t  lleft[0] = SI_IN;\n\t  lright[0] = SI_OUT;\n\t  lleft[1] = SI_OUT;\n\t  lright[1] = SI_IN;\n\t}\n      else\n\t{\n\t  lleft[0] = SI_OUT;\n\t  lright[0] = SI_IN;\n\t  lleft[1] = SI_IN;\n\t  lright[1] = SI_OUT;\n\t}\n\n\n    }\n\n  /* Update pre-topology of intersection point.  */\n  /* UPDATE (ujk), index = -1 ?? */\n  sh6settop (pintpt, -1, lleft[0], lright[0], lleft[1], lright[1], &kstat);\n\n  /* Join intersection points, and set pretopology of help points.  */\n\n  for (ki = 0; ki < kpos; ki++)\n    {\n      sh6idnpt (rintdat, &uintpt[ki], 1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      if (sh6ishelp (uintpt[ki]) && uintpt[ki]->no_of_curves == 0)\n\t{\n\t  sh6settop (uintpt[ki], -1, *(pintpt->left_obj_1), *(pintpt->right_obj_1),\n\t\t     *(pintpt->left_obj_2), *(pintpt->right_obj_2), &kstat);\n\n\t  /* UPDATE (ujk) : Transfer pintpt to main point ?? */\n\t  /* Mark that an intersection interval is found.  */\n\t  sh6idcon (rintdat, &uintpt[ki], &pintpt, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n    }\n\n  /* Pre-topology information computed. */\n\n  *jnewpt = kpos;\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation.  */\n\nerr101:*jstat = -101;\n  goto out;\n\n  /* Error in input. Conflicting dimensions.  */\n\nerr106:*jstat = -106;\n  goto out;\n\n  /* Error in input. Dimension not equal to 2. */\n\nerr108:*jstat = -108;\n  goto out;\n\n  /* Error lower level routine.  */\n\nerror:*jstat = kstat;\n  goto out;\n\nout:\n  return;\n}\n\n"
  },
  {
    "path": "src/sh1780_at.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1780_at.c,v 1.2 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n#define SH1780_AT\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh1780_at (SISLObject * po1, SISLObject * po2,\n\t   SISLIntpt * pintpt, int *jstat)\n#else\nvoid\nsh1780_at (po1, po2, pintpt, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntpt *pintpt;\n     int *jstat;\n#endif\n\n\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Set pre-topology data AT in curve-curve\n*              intersection.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              pintpt   - Current intersection point.\n*\n*\n* OUTPUT     : pintpt   - Intersection point with updated pre-topology info.\n*              jstat    - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      : sh6gettop  -  Set topology of intersection point.\n*              sh6settop  -  Set topology of intersection point.\n*\n* REFERENCES :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 09.91\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                        */\n  int kk1, kk2;\t\t\t/* Orders of the two curves.               */\n  int kn1, kn2;\t\t\t/* Number of vertices in the curves.       */\n  int lleft[2];\t\t\t/* Array storing pre-topology information. */\n  int lright[2];\t\t/* Array storing pre-topology information. */\n  double tref;\t\t\t/* Reference value in equality test.       */\n  double *st1, *st2;\t\t/* Pointers to knot vectors of curves.     */\n  double *sptpar = pintpt->epar;/* Parameter array of int.pt.              */\n  /* --------------------------------------------------------------------- */\n\n  /* Don't make pretop for help points ! */\n  if (sh6ishelp (pintpt))\n    {\n      *jstat = 0;\n      goto out;\n    }\n\n\n  /* Express the curve by local parameters.  */\n\n  kn1 = po1->c1->in;\n  kk1 = po1->c1->ik;\n  st1 = po1->c1->et;\n  kn2 = po2->c1->in;\n  kk2 = po2->c1->ik;\n  st2 = po2->c1->et;\n  tref = MAX (st1[kn1] - st1[kk1 - 1], st2[kn2] - st2[kk2 - 1]);\n\n  /* Update pre-topology of intersection point.  */\n  sh6gettop (pintpt, -1, lleft, lright, lleft + 1, lright + 1, &kstat);\n\n  /* Change the pre-topology information if the intersection point\n\t lies at an endpoint of the curves.    */\n  if (DEQUAL (sptpar[0] + tref, st1[kn1] + tref))\n    {\n      lright[0] = SI_AT;\n    }\n  if (DEQUAL (sptpar[0] + tref, st1[kk1 - 1] + tref))\n    {\n      lleft[0] = SI_AT;\n    }\n  if (DEQUAL (sptpar[1] + tref, st2[kn2] + tref))\n    {\n      lright[1] = SI_AT;\n    }\n  if (DEQUAL (sptpar[1] + tref, st2[kk2 - 1] + tref))\n    {\n      lleft[1] = SI_AT;\n    }\n\n  /* Update pre-topology of intersection point.  */\n  sh6settop (pintpt, -1, lleft[0], lright[0], lleft[1], lright[1], &kstat);\n  if (kstat < 0)\n    goto error;\n\n\n  *jstat = 0;\n  goto out;\n\n\n  /* Error lower level routine.  */\nerror:*jstat = kstat;\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/sh1781.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1781.c,v 1.2 2001-03-19 15:59:05 afr Exp $\n *\n */\n\n\n#define SH1781\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh1781 (SISLObject * po1, SISLObject * po2, double aepsge,\n\tSISLIntdat ** rintdat, SISLIntpt * pintpt, int *jnewpt,\n\tint *jstat)\n#else\nvoid\nsh1781 (po1, po2, aepsge, rintdat, pintpt, jnewpt, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     SISLIntdat **rintdat;\n     SISLIntpt *pintpt;\n     int *jnewpt;\n     int *jstat;\n#endif\n /* UPDATE: (ujk) : Must tune the test on when to use local\n    info (=subtask no ?) */\n/*\n******************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Set pre-topology data in 1-dimensional curve-point\n*              intersection. Also find help points if necessary.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              aepsge   - Geometry resolution.\n*              rintdat  - Intersection data structure.\n*              pintpt   - Current intersection point.\n*\n*\n* OUTPUT     : pintpt   - Intersection point after updating pre-topology.\n*              jnewpt   - Number of new int.pt. created.\n*              jstat    - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      : shevalc  -  Evaluate curve using filtered coefficients.\n*              s6ang    -  Angle between two vectors.\n*              s6idcon  -  Connect two intersection points.\n*              hp_newIntpt -  Create new intersection point.\n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SI, Oslo, Norway. 04.91.\n*              Ulf J. Krystad, SI, 06.91.\n* REWISED BY : VSK, 11-92.  Make sure that a help point always is an\n*                           intersection point.\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                        */\n  int ki, kj;\t\t\t/* Counters.                               */\n  int kleft = 0;\t\t/* Parameter to evaluator.                 */\n  int korgleft = 0;\t\t/* Knot index.                 \t\t   */\n  int kdim;\t\t\t/* Dimension of geometry space.            */\n  int kn;\t\t\t/* Number of vertices of curve.            */\n  int kk;\t\t\t/* Order of curve.                         */\n  int kpos = 0;\t\t\t/* Current position in int.pt. array.      */\n  int lleft[2];\t\t\t/* Array storing pre-topology information. */\n  int lright[2];\t\t/* Array storing pre-topology information. */\n  int *ll1, *ll2, *lr1, *lr2;\t/* Pointers into pre-topology arrays.   */\n  double tpoint;\t\t/* Level value.                            */\n  double tpar0,tpar;    \t/* Parameter value of point on curve.      */\n  double spar[1];\t\t/* Parameter value of endpoint of curve.   */\n  double sder[2];\t\t/* Result of curve evaluation.             */\n  double stang1[2];\t\t/* Tangent vector of curve.                */\n  double stang2[2];\t\t/* Tangent vector of level value.          */\n  double *st;\t\t\t/* Pointer to knot vector of curve.        */\n  double *sptpar = pintpt->epar;/* Pointer to parameter array of int.pt. */\n  double tref;\t\t\t/* Referance value in equality test.       */\n  SISLCurve *qc;\t\t/* Pointer to current curve.               */\n  SISLIntpt *uintpt[2];\t\t/* Array storing new intersection points.  */\n  double *ret_val;\t\t/* Pointer to geo data from sh6getgeom     */\n  double *ret_norm;\t\t/* Pointer to geo data from sh6getgeom     */\n  double *nullp = SISL_NULL;\n  int make_hp;                  /* Flag, make/not make help pt.            */\n\n  /* Don't make pretop for help points ! */\n  if (sh6ishelp (pintpt))\n    {\n      *jstat = 0;\n      goto out;\n    }\n\n  /* Set pointers into the arrays storing pre-topology information. */\n\n  if (po1->iobj == SISLCURVE)\n    {\n      ll1 = lleft;\n      lr1 = lright;\n      ll2 = lleft + 1;\n      lr2 = lright + 1;\n    }\n  else\n    {\n      ll1 = lleft + 1;\n      lr1 = lright + 1;\n      ll2 = lleft;\n      lr2 = lright;\n    }\n\n  /* Get pre-topology information. */\n  sh6gettop (pintpt, -1, lleft, lright, lleft + 1, lright + 1, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Test dimension of geometry space. */\n  if (po1->iobj == SISLCURVE)\n    {\n      qc = po1->c1;\n    }\n  else\n    {\n      qc = po2->c1;\n    }\n\n  kdim = qc->idim;\n  if (kdim != 1)\n    goto err106;\n\n  /* Store curve information in local parameters. */\n\n  kn = qc->in;\n  kk = qc->ik;\n  st = qc->et;\n  tref = st[kn] - st[kk - 1];\n\n  /* Fetch geometry information, point.  */\n  sh6getgeom ((po1->iobj == SISLPOINT) ? po1 : po2,\n\t      (po1->iobj == SISLPOINT) ? 1 : 2,\n\t      pintpt, &ret_val, &ret_norm, aepsge, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  tpoint = ret_val[0];\n\n  /* Fetch geometry information, curve.  */\n  sh6getgeom ((po1->iobj == SISLCURVE) ? po1 : po2,\n\t      (po1->iobj == SISLCURVE) ? 1 : 2,\n\t      pintpt, &ret_val, &ret_norm, aepsge, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  s1219(st,kk,kn,&korgleft,sptpar[0],&kstat);\n  if (kstat < 0) goto error;\n  \n  sder[0] = ret_val[0];\n  sder[1] = ret_val[1];\n\n/* Set tangent vectors. */\n\n  stang1[0] = (double) 1.0;\n  stang1[1] = ret_val[1];\n  stang2[0] = (double) 1.0;\n  stang2[1] = DZERO;\n\n  /* UPDATE (ujk) : tune */\n  if (s6ang (stang1, stang2, 2) > 0.001*ANGULAR_TOLERANCE)\n    {\n      /* Compute pre-topology using local information.  */\n\n      if (sder[1] > 0)\n\t{\n\t  *ll1 = SI_IN;\n\t  *lr1 = SI_OUT;\n\t  *ll2 = SI_OUT;\n\t  *lr2 = SI_IN;\n\t}\n      else\n\t{\n\t  *ll1 = SI_OUT;\n\t  *lr1 = SI_IN;\n\t  *ll2 = SI_IN;\n\t  *lr2 = SI_OUT;\n\t}\n\n    }\n  else\n    {\n      /* Test if the intersection point lies at the endpoint of\n         the curve. */\n\n      if (DEQUAL (sptpar[0] + tref, st[kn] + tref))\n\t{\n\n\t}\n      else\n\t{\n\t  /* Find endpoint of coincidence interval in the positive\n             direction of the curve. */\n\t   \n\t  ki = 0;\n\t  tpar = sptpar[0] + (double) 2.0 *sqrt (aepsge);\n\t  tpar = min (tpar, st[kn]);\n\t  tpar0 = tpar = min (tpar, st[korgleft+1]);\n\t  shevalc (qc, 0, tpar, aepsge, &kleft, sder, &kstat);\n\t  if (fabs (sder[0] - tpoint) <= aepsge)\n\t    {\n\t      make_hp = TRUE;\n\t      for (ki = kleft - kk + 1; ki < kn; ki++)\n\t\t{\n\t\t  for (tpar = DZERO, kj = ki + 1; kj < ki + kk; kj++)\n\t\t    tpar += st[kj];\n\t\t  tpar /= (double) (kk - 1);\n\n\t\t  if (tpar > sptpar[0] && DNEQUAL(tpar,sptpar[0]))\n\t\t    {\n\t\t      shevalc (qc, 0, tpar, aepsge, &kleft, sder, &kstat);\n\t\t      if (fabs (sder[0] - tpoint) >= aepsge)\n\t\t\tbreak;\n\t\t      \n\t\t      tpar0 = tpar; /* Remember parameter value. */\n\t\t    }\n\t\t}\n\t    }\n\t  /*UJK, sept 92, don't make help pt close to main */\n\t  else make_hp = FALSE;\n\t  \n\t  /* Test if there is coincidence along the entire curve part. */\n\n\t  if (ki == kn)\n\t    {\n\t      /* Set right values of original point.  */\n\t      *lr1 = *lr2 = SI_ON;\n\t    }\n\t  else\n\t    {\n\t      /* Compute right values of intersection point. */\n\t      *lr1 = (sder[0] > tpoint) ? SI_OUT : SI_IN;\n\t      *lr2 = (*lr1 == SI_IN) ? SI_OUT : SI_IN;\n\t      \n\t      /*UJK, sept 92, don't make help pt close to main */\n\t      if (make_hp)\n\t      {\n\t\t /* Create help point.  */\n\t\t if (sptpar[0] < st[kleft]) \n\t\t    spar[0] = MIN(tpar0,st[kleft]);\n\t\t else\n\t\t    spar[0] = tpar0;\n\t\t \n\t\t uintpt[kpos] = SISL_NULL;\n\t\t if ((uintpt[kpos] = hp_newIntpt (1, spar, DZERO, -SI_ORD,\n\t\t\t\t\t\t  SI_ON, lright[0], SI_ON,\n\t\t\t\t\t\t  lright[1], 0, 0, nullp, nullp)) == SISL_NULL)\n\t\t    goto err101;\n\t\t \n\t\t /* Insert the point into the data structure.  */\n\t\t \n\t\t sh6idnpt (rintdat, &uintpt[kpos], 1, &kstat);\n\t\t if (kstat < 0)\n\t\t    goto error;\n\t\t \n\t\t kpos++;\n\t      }\n\t    }\n\t}\n\n      /* Test if the intersection point lies at the startpoint\n         of the curve. */\n\n      if (DEQUAL (sptpar[0] + tref, st[kk - 1] + tref))\n\t{\n\t}\n      else\n\t{\n\t  /* Find endpoint of coincidence interval in the negative\n             direction of the curve. */\n\n\t  ki = kn;\n\t  while (sptpar[0] == st[korgleft]) korgleft--;\n\t  tpar = sptpar[0] - (double) 2.0 *sqrt (aepsge);\n\t  tpar = max (tpar, st[kk - 1]);\n\t  tpar0 = tpar = max (tpar, st[korgleft]);\t  \n\t  shevalc (qc, 0, tpar, aepsge, &kleft, sder, &kstat);\n\t  if (fabs (sder[0] - tpoint) <= aepsge)\n\t    {\n\t      make_hp = TRUE;\n\t      for (ki = kleft; ki >= 0; ki--)\n\t\t{\n\t\t  for (tpar = DZERO, kj = ki + 1; kj < ki + kk; kj++)\n\t\t    tpar += st[kj];\n\t\t  tpar /= (double) (kk - 1);\n\n\t\t  if (tpar < sptpar[0] && DNEQUAL(tpar,sptpar[0]))\n\t\t  {\n\t\t     shevalc (qc, 0, tpar, aepsge, &kleft, sder, &kstat);\n\t\t     if (fabs (sder[0] - tpoint) >= aepsge)\n\t\t\tbreak;\n\t\t     \n\t\t     tpar0 = tpar;\n\t\t  }\n\t\t}\n\t    }\n\t  /*UJK, sept 92, don't make help pt close to main */\n\t  else make_hp = FALSE;\n\t  \n\t  /* Test if there is coincidence along the entire curve part. */\n\t  if (ki < 0)\n\t    {\n\t      /* Set left values of original point.  */\n\t      *ll1 = *ll2 = SI_ON;\n\t    }\n\t  else\n\t    {\n\t      /* Compute left values of intersection point. */\n\n\t      *ll1 = (sder[0] > tpoint) ? SI_OUT : SI_IN;\n\t      *ll2 = (*ll1 == SI_IN) ? SI_OUT : SI_IN;\n\n\t      /*UJK, sept 92, don't make help pt close to main */\n\t      if (make_hp)\n\t      {\n\t\t /* Create intersection point.  */\n\t\t if (sptpar[0] > st[kleft+1]) \n\t\t    spar[0] = MAX(tpar0,st[kleft+1]);\n\t\t else\n\t\t    spar[0] = tpar0;\n\t\t \n\t\t uintpt[kpos] = SISL_NULL;\n\t\t if ((uintpt[kpos] = hp_newIntpt (1, spar, DZERO, -SI_ORD,\n\t\t\t\t\t\t  lleft[0], SI_ON, lleft[1],\n\t\t\t\t\t\t  SI_ON, 0, 0, nullp, nullp)) == SISL_NULL)\n\t\t    goto err101;\n\t\t \n\t\t /* Insert the point into the data structure.  */\n\t\t \n\t\t sh6idnpt (rintdat, &uintpt[kpos], 1, &kstat);\n\t\t if (kstat < 0)\n\t\t    goto error;\n\t\t \n\t\t \n\t\t kpos++;\n\t      }\n\n\t    }\n\n\t}\n    }\n\n  /* Update pretopology of intersection point.  */\n\n  sh6settop (pintpt, -1, lleft[0], lright[0], lleft[1], lright[1], &kstat);\n  if (kstat < 0)\n    goto error;\n  /* Change, if necessary, pintpt to mainpoint */\n  sh6tomain (pintpt, &kstat);\n\n  /* Join intersection points.  (kpos=0,1,2)*/\n  for (ki = 0; ki < kpos; ki++)\n    {\n      sh6idnpt (rintdat, &uintpt[ki], 1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      /* Mark that an intersection interval is found.  */\n      if (sh6ishelp (uintpt[ki]) && uintpt[ki]->no_of_curves == 0)\n\t{\n\t  sh6idcon (rintdat, &uintpt[ki], &pintpt, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n    }\n\n  /* Pre-topology information computed. */\n\n  *jnewpt = kpos;\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation.  */\n\nerr101:*jstat = -101;\n  goto out;\n\n  /* Error in input. Incorrect dimension.  */\n\nerr106:*jstat = -106;\n  goto out;\n\n  /* Error lower level routine.  */\n\nerror:*jstat = kstat;\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/sh1781_at.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1781_at.c,v 1.2 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n#define SH1781_AT\n\n#include \"sislP.h\"\n\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh1781_at (SISLObject * po1, SISLObject * po2,\n\t   SISLIntpt * pintpt,\n\t   int *jstat)\n#else\nvoid\nsh1781_at (po1, po2, pintpt, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntpt *pintpt;\n     int *jstat;\n#endif\n/*\n******************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Set pre-topology data AT in 1-dimensional curve-point\n*              intersection.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              pintpt   - Current intersection point.\n*\n*\n* OUTPUT     : pintpt   - Intersection point after updating pre-topology.\n*              jstat    - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      : sh6gettop - Get topological info\n*              sh6settop - Set topological info\n* REFERENCES :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 06.91.\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                        */\n  int kn;\t\t\t/* Number of vertices of curve.            */\n  int kk;\t\t\t/* Order of curve.                         */\n  int lleft[2];\t\t\t/* Array storing pre-topology information. */\n  int lright[2];\t\t/* Array storing pre-topology information. */\n  int *ll1, *ll2, *lr1, *lr2;\t/* Pointers into pre-topology arrays.      */\n  double *st;\t\t\t/* Pointer to knot vector of curve.        */\n  double *sptpar = pintpt->epar;/* Pointer to parameter array of int.pt.   */\n  double tref;\t\t\t/* Referance value in equality test.       */\n  SISLCurve *qc;\t\t/* Pointer to current curve.               */\n  /* --------------------------------------------------------------------- */\n\n\n  /* Don't make pretop for help points ! */\n  if (sh6ishelp (pintpt))\n    {\n      *jstat = 0;\n      goto out;\n    }\n\n  /* Set pointers into the arrays storing pre-topology information. */\n\n  if (po1->iobj == SISLCURVE)\n    {\n      ll1 = lleft;\n      lr1 = lright;\n      ll2 = lleft + 1;\n      lr2 = lright + 1;\n    }\n  else\n    {\n      ll1 = lleft + 1;\n      lr1 = lright + 1;\n      ll2 = lleft;\n      lr2 = lright;\n    }\n\n  /* Get pre-topology information. */\n  sh6gettop (pintpt, -1, lleft, lright, lleft + 1, lright + 1, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Test dimension of geometry space. */\n  if (po1->iobj == SISLCURVE)\n    qc = po1->c1;\n  else\n    qc = po2->c1;\n\n  /* Store curve information in local parameters. */\n  kn = qc->in;\n  kk = qc->ik;\n  st = qc->et;\n  tref = st[kn] - st[kk - 1];\n\n  /* Test if the intersection point lies at an endpoint of\n     the curve. */\n\n  if (DEQUAL (sptpar[0] + tref, st[kn] + tref))\n    *lr1 = SI_AT;\n  if (DEQUAL (sptpar[0] + tref, st[kk - 1] + tref))\n    *ll1 = SI_AT;\n\n  /* Update pretopology of intersection point.  */\n\n  sh6settop (pintpt, -1, lleft[0], lright[0], lleft[1], lright[1], &kstat);\n  if (kstat < 0)\n    goto error;\n\n  *jstat = 0;\n  goto out;\n\n\n  /* Error lower level routine.  */\nerror:*jstat = kstat;\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/sh1782.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1782.c,v 1.3 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n#define SH1782\n\n#include \"sislP.h\"\n\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1782_s9sf_pt (SISLObject *, SISLObject *, double, SISLIntdat **,\n\t\tSISLIntpt **, int, int, int *);\nstatic void\nsh1782_s9sf_cu (SISLObject *, SISLObject *, double, SISLIntdat **,\n\t\tSISLIntpt **, int, int, int *);\nstatic void\nsh1782_s9sf_sf (SISLObject *, SISLObject *, double, SISLIntdat **,\n\t\tSISLIntpt **, int, int, int *);\n#else\nstatic void sh1782_s9sf_pt ();\nstatic void sh1782_s9sf_cu ();\nstatic void sh1782_s9sf_sf ();\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh1782 (SISLObject * po1, SISLObject * po2, double aepsge,\n\tSISLIntdat * pintdat, int ipar, double apar,\n\tSISLIntdat ** rintdat, int *jnewpt, int *jstat)\n#else\nvoid\nsh1782 (po1, po2, aepsge, pintdat, ipar, apar, rintdat, jnewpt, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     SISLIntdat *pintdat;\n     int ipar;\n     double apar;\n     SISLIntdat **rintdat;\n     int *jnewpt;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Insert all points in one intersection data structure\n*              into another intersection data structure with one more\n*              parameter direction.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              aepsge   - Geometry resolution.\n*              pintdat  - Intersection data structure of a problem in a\n*                         reduced parameter space.\n*              ipar     - Missing parameter direction in the reduced space.\n*              apar     - Value of the missing parameter for all intersection\n*                         points.\n*\n*\n* OUTPUT     : rintdat  - Intersection data of object-object intersection.\n*              jnewpt   - Number of new intersection points.\n*              jstat    - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      : sh1782_s9sf_pt  - Set edge info 1D and 2D surface-point.\n*              sh1782_s9sf_cu  - Set edge info 3D surface-curve.\n*              sh1782_s9sf_sf  - Set edge info 3D surface-surface.\n*              sh6idput        - Put point into higher dimensional parameter\n*                                space.\n*\n* REFERENCES :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 06.91\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                     */\n  int kdim;\t\t\t/* Dimension of geometry space.         */\n  int knpoint;\t\t\t/* Number of int.pt. in array.          */\n  SISLIntpt **uintpt = SISL_NULL;\t/* Array storing intersection points.   */\n\n  *jnewpt = 0;\n\n  /* Test if an intersection data structure exist.  */\n\n  if (pintdat == SISL_NULL)\n    {\n      *jstat = 0;\n      goto out;\n    }\n\n  /* Fetch dimension of geometry space. */\n\n  if (po1->iobj == SISLPOINT)\n    kdim = po1->p1->idim;\n  else if (po1->iobj == SISLCURVE)\n    kdim = po1->c1->idim;\n  else\n    kdim = po1->s1->idim;\n\n  /* Insert the intersection points from pintdat into the structure\n     *rintdat belonging to the current problem.  */\n\n  sh6idput (po1, po2, rintdat, pintdat, ipar, apar, &uintpt, &knpoint, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  if (knpoint == 0)\n    {\n      *jstat = 0;\n      goto out;\n    }\n\n\n  /* Browse on the dimension of geometry space and the type of\n     the input objects.     */\n\n  if (kdim <= 2 && ((po1->iobj == SISLSURFACE && po2->iobj == SISLPOINT)\n\t\t    || (po2->iobj == SISLSURFACE && po1->iobj == SISLPOINT)))\n    {\n      /* Compute pre-topology in one-dimensional surface-level value\n         intersection.           */\n\n      sh1782_s9sf_pt (po1, po2, aepsge, rintdat, uintpt, knpoint,\n\t\t      ipar, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n    }\n\n  else if (kdim == 3 && \n\t ((po1->iobj == SISLSURFACE && po2->iobj == SISLCURVE) ||\n\t  (po1->iobj == SISLCURVE && po2->iobj == SISLSURFACE )))\n    {\n      /* Surface-surface intersection in 3-dimensional geometry space. */\n\n      sh1782_s9sf_cu (po1, po2, aepsge, rintdat, uintpt, knpoint,\n\t\t      ipar, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  else if (kdim == 3 && po1->iobj == SISLSURFACE\n\t   && po2->iobj == SISLSURFACE)\n    {\n      /* Surface-surface intersection in 3-dimensional geometry space. */\n\n      sh1782_s9sf_sf (po1, po2, aepsge, rintdat, uintpt, knpoint,\n\t\t      ipar, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* Task performed.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\nerror:*jstat = kstat;\n  goto out;\n\nout:if (uintpt != SISL_NULL)\n    freearray (uintpt);\n}\n\n\n\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1782_s9sf_pt (SISLObject * po1, SISLObject * po2, double aepsge,\n\t\tSISLIntdat ** rintdat, SISLIntpt ** uintpt, int kpoint,\n\t\tint ipar, int *jstat)\n#else\nstatic void\nsh1782_s9sf_pt (po1, po2, aepsge, rintdat, uintpt, kpoint, ipar, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     SISLIntdat **rintdat;\n     SISLIntpt **uintpt;\n     int kpoint;\n     int ipar;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Set pre-topology data in 1-dimensional surface-point\n*              intersection.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              aepsge   - Geometry resolution.\n*              rintdat  - Intersection data structure.\n*              uintpt   - Intersection points.\n*              knpoint  - No of int points\n*              ipar     - Parameter direction of missing parameter in the\n*                         lower dimensional parameter space.\n*\n* OUTPUT     : uintpt   - Updated intersection point.\n*              jstat    - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n*\n* METHOD     :\n*\n* CALLS      : sh6getgeom -  Get geometry of intersection point.\n*              sh6gettop  -  Get topology of intersection point.\n*              sh6settop  -  Set topology of intersection point.\n* REFERENCES :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, Oslo, Norway. 07.91.\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                        */\n  int kdim;\t\t\t/* Dimension of geometry space.            */\n  double tdum, tsign;\t\t/* Parameters used to browse between cases.*/\n  double *sder;\t\t\t/* Surface geometry values.                */\n  double *sdum;\t\t\t/* Normal of surface(dummy)                */\n  int ind;\t\t\t/* Index for curve's par val.              */\n  int ki, kj, klow, khigh;\t/* Help indexes into uintpt                */\n  int index1, index2;\t\t/* Dummy in this context                   */\n  int kant;\t\t\t/* Edge indicator                          */\n  int *edge_f, *edge_l;\t\t/* Pointers to atribute edge in intpt      */\n  SISLSurf *ps;\t\t\t/* The 1D Surface                          */\n  /* --------------------------------------------------------------------- */\n\n  /* Test input */\n  kdim = (po1->iobj == SISLSURFACE) ? po1->s1->idim : po2->s1->idim;\n  if (kdim != 1 && kdim !=2)\n    goto err106;\n\n  if (ipar == 0)\n    ind = 1;\n  else\n    ind = 0;\n\n  if (po1->iobj == SISLSURFACE)\n    tsign = (double) 1.0;\n  else\n    tsign = -(double) 1.0;\n\n  /* Loop for all points */\n  for (ki = 0; ki < kpoint; ki++)\n    for (kj = ki + 1; kj < kpoint; kj++)\n      /* Connected ? */\n      {\n\tsh6getlist (uintpt[ki], uintpt[kj], &index1, &index2, &kstat);\n\tif (kstat < 0)\n\t  goto error;\n\tif (!kstat)\n\t  {\n\t    /* They are connected, sort on edge par val*/\n\t    if (uintpt[ki]->epar[ind] <\n\t\tuintpt[kj]->epar[ind])\n\t      {\n\t\tklow = ki;\n\t\tkhigh = kj;\n\t      }\n\t    else\n\t      {\n\t\tklow = kj;\n\t\tkhigh = ki;\n\t      }\n\n\t    /* Fetch geometry of surface */\n\t    sh6getgeom ((po1->iobj == SISLSURFACE) ? po1 : po2,\n\t\t\t(po1->iobj == SISLSURFACE) ? 1 : 2,\n\t\t\tuintpt[klow], &sder, &sdum, aepsge, &kstat);\n\n\t    if (kstat < 0)\n\t      goto error;\n\n\t    if (ipar == 0)\n\t      tdum = tsign * sder[1];\n\t    else\n\t      tdum = -tsign * sder[2];\n\n\t    if (tdum > DZERO)\n\t      sh6setdir (uintpt[klow], uintpt[khigh], &kstat);\n\t    else if (tdum < 0)\n\t      sh6setdir (uintpt[khigh], uintpt[klow], &kstat);\n\n\t      sh6setcnsdir (uintpt[klow], uintpt[khigh], ipar, &kstat);\n\n\t    /* Mark edge intersection curve */\n\t    if (sh6ismain (uintpt[ki]) && sh6ismain (uintpt[kj]) &&\n\t\tpo1->o1 == po1 &&\n\t\tpo2->o1 == po2)\n\t      {\n\n\t\tps = po1->s1;\n\t\tedge_f = &(uintpt[ki]->edge_1);\n\t\tedge_l = &(uintpt[kj]->edge_1);\n\n\t\tif (po2->iobj == SISLSURFACE)\n\t\t  {\n\t\t    edge_f = &(uintpt[ki]->edge_2);\n\t\t    edge_l = &(uintpt[kj]->edge_2);\n\t\t    ps = po2->s1;\n\t\t  }\n\n\t\tkant = 0;\n\t\tif (ipar == 0)\n\t\t  {\n\t\t    if (DEQUAL (uintpt[ki]->epar[ipar],\n\t\t\t\tps->et1[ps->ik1 - 1]))\n\t\t      kant = -1;\n\t\t    else if (DEQUAL (uintpt[ki]->epar[ipar],\n\t\t\t\t     ps->et1[ps->in1]))\n\t\t      kant = 1;\n\t\t  }\n\t\telse\n\t\t  {\n\t\t    if (DEQUAL (uintpt[ki]->epar[ipar], ps->et2[ps->ik2 - 1]))\n\t\t      kant = 1;\n\t\t    else if (DEQUAL (uintpt[ki]->epar[ipar],\n\t\t\t\t     ps->et2[ps->in2]))\n\t\t      kant = -1;\n\t\t  }\n\n\t\tif (kant)\n\t\t  {\n\t\t    if ((double) kant * tdum > DZERO)\n\t\t      *edge_f = *edge_l = SI_RIGHT;\n\t\t    else if ((double) kant * tdum < DZERO)\n\t\t      *edge_f = *edge_l = SI_LEFT;\n\n\t\t  }\n\n\t      }\n\n\t  }\n      }\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in input. Incorrect dimension.  */\n\nerr106:*jstat = -106;\n  goto out;\n\n  /* Error lower level routine.  */\n\nerror:*jstat = kstat;\n  goto out;\n\nout:\n  return;\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1782_s9sf_cu (SISLObject * po1, SISLObject * po2, double aepsge,\n\t\tSISLIntdat ** rintdat, SISLIntpt ** uintpt, int kpoint,\n\t\tint ipar, int *jstat)\n#else\nstatic void\nsh1782_s9sf_cu (po1, po2, aepsge, rintdat, uintpt, kpoint, ipar, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     SISLIntdat **rintdat;\n     SISLIntpt **uintpt;\n     int kpoint;\n     int ipar;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Set pre-topology data in 3-dimensional surface-curve\n*              intersection.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              aepsge   - Geometry resolution.\n*              rintdat  - Intersection data structure.\n*              uintpt   - Intersection points.\n*              kpoint   - No of int points\n*              ipar     - Parameter direction of missing parameter in the\n*                         lower dimensional parameter space.\n*\n* OUTPUT     : uintpt   - Updated intersection point.\n*              jstat    - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      : s6crss    -  Cross product between two vectors.\n*              s6scpr    -  Scalar product between two vectors.\n*              sh6getgeo -  Fetch geometry information of intersection point.\n*\n* REFERENCES :\n*\n* WRITTEN BY : ALA & VSK okt. 1992.\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                        */\n  int kdim;\t\t\t/* Dimension of geometry space.            */\n  double tdum;\t\t\t/* Parameter used to browse on the cases.  */\n  double *val_s1;\t\t/* Surface geometry                        */\n  double *val_s2;\t\t/* Surface geometry                        */\n  double *snorm1;\t\t/* Normal vector of surface.               */\n  double *snorm2;\t\t/* Normal vector of surface.               */\n  double *sdir;\t        \t/* Direction vector of intersection curve. */\n  double *stang;\t\t/* Tangent vector of edge curve.           */\n  int ind;\t\t\t/* Index for curve's par val.              */\n  int ki, kj, klow, khigh;\t/* Help indexes into uintpt                */\n  int index1, index2;\t\t/* Dummy in this context                   */\n  int kcurve;\t\t\t/* Which object is the curve?\t\t   */\n  /* --------------------------------------------------------------------- */\n  \n  *jstat = 0;\n\n  /* Test input */\n  \n  if (po1->iobj == SISLCURVE && po2->iobj == SISLSURFACE)\n  {\n     kcurve = 1;\n     kdim = po1->c1->idim;\n     if (kdim != 3)\n\tgoto err104;\n     if (kdim != po2->s1->idim)\n\tgoto err106;\n  }\n  else if (po1->iobj == SISLSURFACE && po2->iobj == SISLCURVE)\n  {\n     kcurve = 2;\n     kdim = po1->s1->idim;\n     if (kdim != 3)\n\tgoto err104;\n     if (kdim != po2->c1->idim)\n\tgoto err106;\n  }\n  else\n    goto err104;\n  \n  /* Get index for curve par val  */\n  if (kcurve == 1 && ipar == 1)\n    ind = 2;\n  else  if ((kcurve == 1 && ipar == 2) ||\n\t    (kcurve == 2 && ipar == 0))\n    ind = 1;\n  else  if (kcurve == 2 && ipar == 1)\n    ind = 0;\n  else\n     goto out;\n  \n  /* Loop for all points */\n  for (ki = 0; ki < kpoint; ki++)\n    for (kj = ki + 1; kj < kpoint; kj++)\n      /* Connected ? */\n      {\n\tsh6getlist (uintpt[ki], uintpt[kj], &index1, &index2, &kstat);\n\tif (kstat < 0)\n\t  goto error;\n\tif (!kstat)\n\t  {\n\t    /* They are connected, sort on edge par val*/\n\t    if (uintpt[ki]->epar[ind] <\n\t\tuintpt[kj]->epar[ind])\n\t      {\n\t\tklow = ki;\n\t\tkhigh = kj;\n\t      }\n\t    else\n\t      {\n\t\tklow = kj;\n\t\tkhigh = ki;\n\t      }\n\n\t    /* Get geometry first object */\n\t    sh6getgeom (po1, 1, uintpt[klow], &val_s1, &snorm1, aepsge, &kstat);\n\t    if (kstat < 0)\n\t      goto error;\n\n\t    /* Get geometry second object */\n\t    sh6getgeom (po2, 2, uintpt[klow], &val_s2, &snorm2, aepsge, &kstat);\n\t    if (kstat < 0)\n\t      goto error;\n\n\t    /* Fetch tangent of edge curve.  */\n\t    if (ipar == 0)\n\t      stang = val_s1 + 6;\n\t    else if (ipar == 1 && kcurve == 2)\n\t      stang = val_s1 + 3;\n\t    else if (ipar == 1 && kcurve == 1)\n\t      stang = val_s2 + 6;\n\t    else\n\t      stang = val_s2 + 3;\n\n\t    /* The direction of the intersection curve is set along\n\t       the direction of the curve in the intersection.  */\n\t    if (kcurve == 1)\n\t       sdir = val_s1 + 3;\n\t    else\n\t       sdir = val_s2 + 3;\n\n\t    tdum = s6scpr (sdir, stang, kdim);\n\n\t    if (tdum > 0)\n\t      sh6setdir (uintpt[klow], uintpt[khigh], &kstat);\n\t    else if (tdum < 0)\n\t      sh6setdir (uintpt[khigh], uintpt[klow], &kstat);\n\n\t      sh6setcnsdir (uintpt[klow], uintpt[khigh], ipar, &kstat);\n\t  }\n      }\n  *jstat = 0;\n  goto out;\n\n\n  /* Error in input. Dimension not equal to 3. */\n\nerr104:*jstat = -104;\n  goto out;\n\n  /* Error in input. Conflicting dimensions.  */\n\nerr106:*jstat = -106;\n  goto out;\n\n  /* Error lower level routine.  */\n\nerror:*jstat = kstat;\n  goto out;\n\nout:\n  return;\n}\n\n\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\nsh1782_s9sf_sf (SISLObject * po1, SISLObject * po2, double aepsge,\n\t\tSISLIntdat ** rintdat, SISLIntpt ** uintpt, int kpoint,\n\t\tint ipar, int *jstat)\n#else\nstatic void\nsh1782_s9sf_sf (po1, po2, aepsge, rintdat, uintpt, kpoint, ipar, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     SISLIntdat **rintdat;\n     SISLIntpt **uintpt;\n     int kpoint;\n     int ipar;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Set pre-topology data in 3-dimensional surface-surface\n*              intersection.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              aepsge   - Geometry resolution.\n*              rintdat  - Intersection data structure.\n*              uintpt   - Intersection points.\n*              knpoint  - No of int points\n*              ipar     - Parameter direction of missing parameter in the\n*                         lower dimensional parameter space.\n*\n* OUTPUT     : uintpt   - Updated intersection point.\n*              jstat    - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      : s6crss    -  Cross product between two vectors.\n*              s6scpr    -  Scalar product between two vectors.\n*              sh6getgeo -  Fetch geometry information of intersection point.\n*\n* REFERENCES :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, Oslo, Norway. 07.91.\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                        */\n  int kdim;\t\t\t/* Dimension of geometry space.            */\n  double tdum;\t\t\t/* Parameter used to browse on the cases.  */\n  double *val_s1;\t\t/* Surface geometry                        */\n  double *val_s2;\t\t/* Surface geometry                        */\n  double *snorm1;\t\t/* Normal vector of surface.               */\n  double *snorm2;\t\t/* Normal vector of surface.               */\n  double sdir[3];\t\t/* Direction vector of intersection curve. */\n  double *stang;\t\t/* Tangent vector of edge curve.           */\n  int ind;\t\t\t/* Index for curve's par val.              */\n  int ki, kj, klow, khigh;\t/* Help indexes into uintpt                */\n  int index1, index2;\t\t/* Dummy in this context                   */\n  int *edge_f, *edge_l;\t\t/* Pointers to atribute edge in intpt      */\n  int kant;\t\t\t/* Edge indicator                          */\n  SISLSurf *ps;\t\t\t/* The 3D Surface enhanced                 */\n  /* --------------------------------------------------------------------- */\n\n  /* Test input */\n  kdim = po1->s1->idim;\n  if (kdim != 3)\n    goto err104;\n  if (kdim != po2->s1->idim)\n    goto err106;\n\n  /* Get index for curve par val  */\n  if (ipar == 0)\n    ind = 1;\n  else if (ipar == 1)\n    ind = 0;\n  else if (ipar == 2)\n    ind = 3;\n  else\n    ind = 2;\n\n  /* Loop for all points */\n  for (ki = 0; ki < kpoint; ki++)\n    for (kj = ki + 1; kj < kpoint; kj++)\n      /* Connected ? */\n      {\n\tsh6getlist (uintpt[ki], uintpt[kj], &index1, &index2, &kstat);\n\tif (kstat < 0)\n\t  goto error;\n\tif (!kstat)\n\t  {\n\t    /* They are connected, sort on edge par val*/\n\t    if (uintpt[ki]->epar[ind] <\n\t\tuintpt[kj]->epar[ind])\n\t      {\n\t\tklow = ki;\n\t\tkhigh = kj;\n\t      }\n\t    else\n\t      {\n\t\tklow = kj;\n\t\tkhigh = ki;\n\t      }\n\n\n\n\n\t    /* Get geometry first object */\n\t    sh6getgeom (po1, 1, uintpt[klow], &val_s1, &snorm1, aepsge, &kstat);\n\t    if (kstat < 0)\n\t      goto error;\n\n\t    /* Get geometry second object */\n\t    sh6getgeom (po2, 2, uintpt[klow], &val_s2, &snorm2, aepsge, &kstat);\n\t    if (kstat < 0)\n\t      goto error;\n\n\t    /* Get geometry lower level object */\n\t    /* Fetch tangent of edge curve.  */\n\t    if (ipar == 0)\n\t      stang = val_s1 + 6;\n\t    else if (ipar == 1)\n\t      stang = val_s1 + 3;\n\t    else if (ipar == 2)\n\t      stang = val_s2 + 6;\n\t    else\n\t      stang = val_s2 + 3;\n\n\t    /* Compute direction of intersection curve.  */\n\t    s6crss (snorm1, snorm2, sdir);\n\n\t    tdum = s6scpr (sdir, stang, kdim);\n\n\t    if (tdum > 0)\n\t      sh6setdir (uintpt[klow], uintpt[khigh], &kstat);\n\t    else if (tdum < 0)\n\t      sh6setdir (uintpt[khigh], uintpt[klow], &kstat);\n\n\t      sh6setcnsdir (uintpt[klow], uintpt[khigh], ipar, &kstat);\n\t    /* Mark edge intersection curve */\n\t    if (sh6ismain (uintpt[ki]) && sh6ismain (uintpt[kj]) &&\n\t\tpo1->o1 == po1 &&\n\t\tpo2->o1 == po2)\n\t      {\n\n\t\tif (ipar < 2)\n\t\t  /* First surf */\n\t\t  {\n\t\t    edge_f = &(uintpt[ki]->edge_1);\n\t\t    edge_l = &(uintpt[kj]->edge_1);\n\t\t    ps = po1->s1;\n\t\t  }\n\t\telse\n\t\t  {\n\t\t    edge_f = &(uintpt[ki]->edge_2);\n\t\t    edge_l = &(uintpt[kj]->edge_2);\n\t\t    ps = po2->s1;\n\t\t  }\n\n\t\tkant = 0;\n\t\tif (ipar == 0 || ipar == 2)\n\t\t  {\n\t\t    if (DEQUAL (uintpt[ki]->epar[ipar],\n\t\t\t\tps->et1[ps->ik1 - 1]))\n\t\t      kant = -1;\n\t\t    else if (DEQUAL (uintpt[ki]->epar[ipar],\n\t\t\t\t     ps->et1[ps->in1]))\n\t\t      kant = 1;\n\t\t  }\n\t\telse\n\t\t  {\n\t\t    if (DEQUAL (uintpt[ki]->epar[ipar], ps->et2[ps->ik2 - 1]))\n\t\t      kant = 1;\n\t\t    else if (DEQUAL (uintpt[ki]->epar[ipar],\n\t\t\t\t     ps->et2[ps->in2]))\n\t\t      kant = -1;\n\t\t  }\n\n\t\tif (kant)\n\t\t  {\n\t\t    if ((double) kant * tdum > DZERO)\n\t\t      *edge_f = *edge_l = SI_RIGHT;\n\t\t    else if ((double) kant * tdum < DZERO)\n\t\t      *edge_f = *edge_l = SI_LEFT;\n\n\t\t  }\n\n\n\n\n\n\t      }\n\t  }\n      }\n  *jstat = 0;\n  goto out;\n\n\n  /* Error in input. Dimension not equal to 3. */\n\nerr104:*jstat = -104;\n  goto out;\n\n  /* Error in input. Conflicting dimensions.  */\n\nerr106:*jstat = -106;\n  goto out;\n\n  /* Error lower level routine.  */\n\nerror:*jstat = kstat;\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/sh1783.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1783.c,v 1.2 2001-03-19 15:59:05 afr Exp $\n *\n */\n\n\n#define SH1783\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\ntypedef void (*fevalProc)(SISLCurve *,int,double,int *,double[],int *);\n#else\ntypedef void (*fevalProc)();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void sh1783_s9relax (fevalProc fevalc1,fevalProc fevalc2,\n\t\t\t    SISLCurve *,SISLCurve *,int,double,double,int *,\n\t\t\t    double [],double,double *,int *,double [],int *);\n#else\nstatic void sh1783_s9relax ();\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh1783 (SISLCurve * pc1, SISLCurve * pc2, double aepsge, double epar[],\n\tint idir1, int idir2, double elast[], double enext[], int *jstat)\n#else\nvoid \nsh1783 (pc1, pc2, aepsge, epar, idir1, idir2, elast, enext, jstat)\n     SISLCurve *pc1;\n     SISLCurve *pc2;\n     double aepsge;\n     double epar[];\n     int idir1;\n     int idir2;\n     double elast[];\n     double enext[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : March along two curves as long as the coincide. Then return\n*              the last points found that are closer to each other than\n*              the tolerance, and the first points that are more distant.\n*              Start the marching in a given intersection point.\n*\n*\n* INPUT      : pc1      - Pointer to the first curve.\n*              pc2      - Pointer to the second curve..\n*              aepsge   - Geometry resolution.\n*              epar[2]  - Parameter values for the intersection point.\n*              idir1    - Direction to march first curve.\n*                         = 1  : March in the direction of the parametrization.\n*                         = -1 : March in the opposite direction.\n*              idir2    - Direction to march second curve.\n*\n*\n* OUTPUT     : elast[2] - Parameter values of the last point within the\n*                         interval of coincidence.\n*              enext[2] - Parameter values of the first point found outside\n*                         this interval.\n*              jstat    - status messages\n*                             = 3   : Coincidence along both curves.\n*                             = 2   : Coincidence along the entire second curve.\n*                             = 1   : Coincidence along the entire first curve.\n*                             = 0   : Ok. End of interval found.\n*                             < 0   : Error.\n*\n*\n* METHOD     : March along one curve, and for each step iterate to\n*              the closest point of the other curve at the midpoint and\n*              the endpoint of the step. The geometry and knot vectors of\n*              both curves are considered when making the step, and we\n*              march along the curve that has set the step.\n*\n* CALLS      : s1221  - Evaluate B-spline curve.\n*              s1227  - Evaluate B-spline curve.\n*              s1307  - Compute unit tangent and radius of curvature.\n*              s1311  - Find current step length.\n*              sh1992  - Find box-size of object.\n*              s6lenght - Length of vector.\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SI, Oslo, Norway. 04.91.\n*\n*********************************************************************\n*/\n{\n  int kstat;\t\t\t/* Status variable                                 */\n  int ki;\t\t\t/* Counter.                                        */\n  int kleftc1 = 0;\t\t/* Left indicator for point calculation of curve 1.*/\n  int kleftc2 = 0;\t\t/* Left indicator for point calculation of curve 2.*/\n  int kk1, kk2, kn1, kn2;\t/* Orders and number of vertices of curves         */\n  int kdim;\t\t\t/* The dimension of the space in which the curves lie. */\n  int kpos = 0;\t\t\t/* Position of error                               */\n  int kderc = 2;\t\t/* Number of derivatives to be claculated on the curves */\n  int kdum;\t\t\t/* Temporary variable                              */\n  int kchange;\t\t\t/* Indicates which curve that is marched along.\n\t\t\t\t   = 0 : First curve.\n\t\t\t\t   = 1 : Second curve.                             */\n  double s3dinf1[20];\t\t/* Pointer to storage for point info of curve 1\n\t\t\t\t    (10 dobules pr point when idim=3, 7 when idim=3) */\n  double s3dinf2[20];\t\t/* Pointer to storage for point info of curve 2\n\t\t\t\t    (10 dobules pr point when idim=3, 7 when idim=3) */\n  double *st1;\t\t\t/* Knot vector of first curve                      */\n  double *st2;\t\t\t/* Knot vector of second curve                     */\n  double tfirst1, tfirst2;\t/* First parameter value on curves              */\n  double tend1, tend2;\t\t/* Last parameter on curves                        */\n  double sderc1[20];\t\t/* Position, first and second derivatives on curve 1 */\n  double sderc2[20];\t\t/* Position, first and second derivatives on curve 2 */\n  double tx, tx1, tx2;\t\t/* Parameter values of first curve.  */\n  double ty, ty1, ty2;\t\t/* Parameter value of second curve.  */\n  double tstep;\t\t\t/* Final step length     */\n  double txstep, tystep;\t/* Step length     */\n  double txmaxinc, tymaxinc;\t/* Maximal increment in parameter value along curve*/\n  double txlengthend, tylengthend;\t/* Length of 1st derivative at start of segment */\n  double txincre, tyincre;\t/* Parameter value increment */\n  double txmax, tymax;\t\t/* Local maximal step length                       */\n  double tdist = DZERO;\t\t/* Distance */\n  double tpos;\t\t\t/* New iteration  point on curve pc2     */\n\n  /* Pointer to curve evaluator routines */\n\n  fevalProc fevalc1;\n  fevalProc fevalc2;\n\n  /* Make maximal step length based on box-size of curve 1 */\n\n  sh1992cu (pc1, 0, aepsge, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  txmax = MAX (pc1->pbox->e2max[0][0] - pc1->pbox->e2min[0][0],\n\t       pc1->pbox->e2max[0][1] - pc1->pbox->e2min[0][1]);\n  txmax = MAX (txmax, pc1->pbox->e2max[0][2] - pc1->pbox->e2min[0][2]);\n\n  /* Make maximal step length based on box-size of curve 2 */\n\n  sh1992cu (pc2, 0, aepsge, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  tymax = MAX (pc2->pbox->e2max[0][0] - pc2->pbox->e2min[0][0],\n\t       pc2->pbox->e2max[0][1] - pc2->pbox->e2min[0][1]);\n  tymax = MAX (tymax, pc2->pbox->e2max[0][2] - pc2->pbox->e2min[0][2]);\n\n  /* Copy curve pc1 attributes to local parameters.  */\n\n  kdim = pc1->idim;\n  kk1 = pc1->ik;\n  kn1 = pc1->in;\n  st1 = pc1->et;\n\n  /* Copy curve pc2 attributes to local parameters.  */\n\n  kk2 = pc2->ik;\n  kn2 = pc2->in;\n  st2 = pc2->et;\n\n  /* Check that dimensions are equal */\n\n  if (kdim != pc2->idim || kdim > 3)\n    goto err105;\n\n  /* Copy interval description into local variables */\n\n  tfirst1 = epar[0];\n  tfirst2 = epar[1];\n  tend1 = (idir1 == 1) ? st1[kn1] : st1[kk1 - 1];\n  tend2 = (idir2 == 1) ? st2[kn2] : st2[kk2 - 1];\n\n  /* To make sure we do not start outside or end outside the curve we\n     truncate tfirst1 to the knot interval of the curve */\n\n  tfirst1 = (idir1 == 1) ? MAX (tfirst1, st1[kk1 - 1]) : MIN (tfirst1, st1[kn1]);\n\n  /* To make sure we do not start outside or end outside the curve we\n     truncate tstart2 and tend2 to the knot interval of the curve */\n\n  tfirst2 = (idir2 == 1) ? MAX (tfirst2, st2[kk2 - 1]) : MIN (tfirst2, st2[kn2]);\n\n  /* Set curve evaluator of 1. curve.  */\n\n  fevalc1 = (idir1 == 1) ? s1221 : s1227;\n\n  /* Set curve evaluator of 2. curve.  */\n\n  fevalc2 = (idir2 == 1) ? s1221 : s1227;\n\n  /* Store knot values at start of curve */\n\n  tx1 = tfirst1;\n  kdum = MAX (kk1, kk2);\n  txmaxinc = fabs (tend1 - tfirst1) / (kdum * kdum);\n\n  /* Make start point and intital step length based on first curve  */\n\n  fevalc1 (pc1, kderc, tx1, &kleftc1, sderc1, &kstat);\n  if (kstat < 0) goto error;\n\n  ty1 = tfirst2;\n  tymaxinc = fabs (tend2 - tfirst2) / (kdum * kdum);\n\n  /* Make start point and intital step length based on second curve  */\n\n  fevalc2 (pc2, kderc, ty1, &kleftc2, sderc2, &kstat);\n  if (kstat < 0) goto error;\n\n  /* While end not reached */\n\n  while (idir1 * tx1 < idir1 * tend1 && idir2 * ty1 < idir2 * tend2)\n    {\n\n      /* Calculate unit tangent and radius of curvature of first curve. */\n\n      s1307 (sderc1, kdim, s3dinf1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /* Calculate step length based on curvature of first curve. */\n\n      txstep = s1311 (s3dinf1[3 * kdim], aepsge, tymax, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /* Remember length of start tangent, end of zero segment */\n\n      txlengthend = s6length (sderc1 + kdim, kdim, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /* Calculate unit tangent and radius of curvature of second curve. */\n\n      s1307 (sderc2, kdim, s3dinf2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /* Calculate step length based on curvature */\n\n      tystep = s1311 (s3dinf2[3 * kdim], aepsge, txmax, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /* Remember length of start tangent, end of zero segment */\n\n      tylengthend = s6length (sderc2 + kdim, kdim, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /*  Find minimum step length.  */\n\n      tstep = MIN (txstep, tystep);\n      kchange = (txstep <= tystep) ? 0 : 1;\n\n      /*  Find candidate end point, make sure that no breaks in tangent or\n\t  curvature exists between start and endpoints of the segment      */\n      /* Compute increment in the parameter values.  Use REL_PAR_RES if the\n         tangent has zero length.  */\n\n      if (DEQUAL (txlengthend, DZERO))\n\ttxincre = REL_PAR_RES;\n      else\n\ttxincre = MIN (tstep / txlengthend, txmaxinc);\n\n      if (DEQUAL (tylengthend, DZERO))\n\ttyincre = REL_PAR_RES;\n      else\n\ttyincre = MIN (tstep / tylengthend, tymaxinc);\n\n      /*  Make sure that we don't pass any knots of curve 1. */\n\n      /* VSK. 01-93. Is it possible that several knots might be passed. */\n      \n      if (idir1 > 0 && (tx1 + txincre) > (st1[kleftc1 + 1] + REL_PAR_RES) &&\n\t  !(tx1 > (st1[kleftc1 + 1] - REL_PAR_RES)))\n\t{\n\t  txincre = st1[kleftc1 + 1] - tx1;\n\t  tstep = txincre * txlengthend;\n\t  tyincre = (tylengthend > DZERO) ? tstep / tylengthend : REL_PAR_RES;\n\t  kchange = 0;\n\t}\n\n/*\n  guen      if (idir1 < 0 && (tx1 - txincre < st1[kleftc1] - REL_PAR_RES))\n  guen fixed to:\n*/\n      /* VSK. 01-93. Is it possible that several knots might be passed. */\n      \n      if (idir1 < 0 && (tx1 - txincre) < (st1[kleftc1] - REL_PAR_RES) &&\n\t  !(tx1 < (st1[kleftc1] + REL_PAR_RES)))\n\t{\n\t  txincre = idir1 * (st1[kleftc1] - tx1);\n\t  tstep = txincre * txlengthend;\n\t  tyincre = (tylengthend > DZERO) ? tstep / tylengthend : REL_PAR_RES;\n\t  kchange = 0;\n\t}\n\n      /* Avoid passing next knot of curve 2. */\n      \n      /* VSK. 01-93. Is it possible that several knots might be passed. */\n\n      if (idir2 > 0 && (ty1 + tyincre) > (st2[kleftc2 + 1] + REL_PAR_RES) &&\n\t  !(ty1 > (st2[kleftc2 + 1] - REL_PAR_RES)))\n\t{\n\t  tyincre = st2[kleftc2 + 1] - ty1;\n\t  tstep = tyincre * tylengthend;\n\t  txincre = (txlengthend > DZERO) ? tstep / txlengthend : REL_PAR_RES;\n\t  kchange = 1;\n\t}\n\n      /* Avoid passing previous knot of curve 2. */\n\n/*\n  guen      if (idir2 < 0 && (ty1 - tyincre < st2[kleftc2] - REL_PAR_RES))\n  guen fixed to:\n*/\n      /* VSK. 01-93. Is it possible that several knots might be passed. */\n\n      if (idir2 < 0 && (ty1 - tyincre) < (st2[kleftc2] - REL_PAR_RES) &&\n\t  !(ty1 > (st2[kleftc2] + REL_PAR_RES)))\n\t{\n\t  tyincre = idir2 * (st2[kleftc2] - ty1);\n\t  tstep = tyincre * tylengthend;\n\t  txincre = (txlengthend > DZERO) ? tstep / txlengthend : REL_PAR_RES;\n\t  kchange = 1;\n\t}\n\n\n      /* Set endpoints of step.  */\n\n      tx2 = tx1 + idir1 * txincre;\n      ty2 = ty1 + idir2 * tyincre;\n\n      for (tx = (tx1 + tx2) / (double) 2.0, ty = (ty1 + ty2) / (double) 2.0, ki = 0;\n\t   ki < 2; ki++, tx = tx2, ty = ty2)\n\t{\n\t  if (kchange == 0)\n\t    {\n\t      if (idir1 * tx >= idir1 * tend1)\n\t\tbreak;\n\n\t      /* March along first curve. Iterate down to the second.  */\n\n\t      sh1783_s9relax (fevalc1, fevalc2, pc1, pc2, kderc, aepsge, tx, &kleftc1, sderc1, ty,\n\t\t\t      &tpos, &kleftc2, sderc2, jstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t    }\n\t  else\n\t    {\n\t      if (idir2 * ty >= idir2 * tend2)\n\t\tbreak;\n\n\t      /* March along second curve. Iterate down to the first.  */\n\n\t      sh1783_s9relax (fevalc2, fevalc1, pc2, pc1, kderc, aepsge, ty, &kleftc2, sderc2, tx,\n\t\t\t      &tpos, &kleftc1, sderc1, jstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t    }\n\n\t  /*  Check if point on curve and surface are within positional and\n\t      angular tolerances */\n\n\t  tdist = s6dist (sderc1, sderc2, kdim);\n\n\t  if (tdist > aepsge)\n\t    break;\t\t/*   Points not within tolerances */\n\t}\n\n      if (tdist > aepsge)\n\tbreak;\t\t\t/*   Points not within tolerances */\n\n      /*   Update start parameter value of segment.  */\n\n      if (kchange == 0)\n\t{\n\t  tx1 = tx2;\n\t  ty1 = (idir2 > 0) ? MAX(ty1,tpos) : MIN(ty1,tpos);\n\t}\n      else\n\t{\n\t  tx1 = (idir1 > 0) ? MAX(tx1,tpos) : MIN(tx1,tpos);\n\t  ty1 = ty2;\n\t}\n    }\n\n  elast[0] = tx1;\n  elast[1] = ty1;\n  if (tdist > aepsge)\n    {\n      enext[0] = (kchange == 0) ? tx : tpos;\n      enext[1] = (kchange == 1) ? ty : tpos;\n      *jstat = 0;\n    }\n  else if (idir1 * tx1 >= idir1 * tend1 && idir2 * ty1 >= idir2 * tend2)\n    *jstat = 3;\n  else if (idir2 * ty1 >= idir2 * tend2)\n    *jstat = 2;\n  else\n    *jstat = 1;\n\n  goto out;\n\n/* Error in input, dimension not equal to 2 or 3 */\n\nerr105:*jstat = -105;\n  s6err (\"sh1783\", *jstat, kpos);\n  goto out;\n\n/* Error in lower level function */\n\nerror:*jstat = kstat;\n  s6err (\"sh1783\", *jstat, kpos);\n  goto out;\n\nout:\n  return;\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  sh1783_s9relax(fevalProc fevalc1,fevalProc fevalc2,\n\t\t SISLCurve * pc1, SISLCurve * pc2,int ider, double aepsge, \n\t\t double ax1, int *jleft1, double eder1[],double anext,\n\t\t double *cx2, int *jleft2, double eder2[], int *jstat)\n#else\nstatic void \nsh1783_s9relax (fevalc1, fevalc2, pc1, pc2, ider, aepsge, ax1, jleft1, eder1, \n\t\tanext,cx2, jleft2, eder2, jstat)\n     fevalProc  fevalc1;\n     fevalProc  fevalc2;\n     SISLCurve  *pc1;\n     SISLCurve  *pc2;\n     int        ider;\n     double     aepsge;\n     double     ax1;\n     int        *jleft1;\n     double     eder1[];\n     double     anext;\n     double     *cx2;\n     int        *jleft2;\n     double     eder2[];\n     int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Evaluate the first curve in a given parameter value and\n*              iterate down to the closest point on the second curve\n*              to the position on the first curve.\n*\n*\n* INPUT      : fevalc1 - Curve evaluator corresponding to first curve.\n*              fevalc1 - Curve evaluator corresponding to second curve.\n*              pc1     - Pointer to the first curve.\n*              pc2     - Pointer to the second curve.\n*              ider    - Number of derivatives to compute. 0 <= ider <= 2.\n*              aepsge  - Geometry resolution.\n*              ax1     - Parameter value at which to evaluate curve 1.\n*              anext   - Start parameter to the iteration on curve 2.\n*\n*\n* INPUT/OUTPUT : jleft1  - Parameter used to set knot interval of curve1.\n*                          Used in s1221.\n*                jleft2  - Parameter used to set knot interval of curve2.\n*\n*\n* OUTPUT     : eder1   - 0-ider'th derivative of curve 1 evaluated in ax1.\n*                        Dimension is (ider+1)*pc1->idim.\n*              cx2     - Parameter value of the point on curve 2 closest\n*                        to the point given by eder1.\n*              eder2   - 0-ider'th derivative of curve 2 evaluated in *cx2.\n*                        Dimension is (ider+1)*pc2->idim.\n*              jstat   - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n*\n* CALLS      :  s1221     - Evaluate curve.\n*               s1771     - Closest point between a curve and a point.\n*               newPoint  - Create new point object.\n*               freePoint - Free point object.\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SI, Oslo, Norway. Oct. 1990\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.  */\n  double tstart;\t\t/* Start parameter value of curve 2.  */\n  double tend;\t\t\t/* End parameter value of curve 2.    */\n  SISLPoint *qpoint = SISL_NULL;\t/* SISLPoint instance used to represent point on curve 1. */\n\n  /* Find endpoints of the parameter interval of curve 2.  */\n\n  tstart = *(pc2->et + pc2->ik - 1);\n  tend = *(pc2->et + pc2->in);\n\n  /*  Make point sderc at curve at ax1 */\n\n  fevalc1 (pc1, ider, ax1, jleft1, eder1, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Find closest point on curve 2 to eder1 */\n\n  qpoint = newPoint (eder1, pc1->idim, 0);\n  if (qpoint == SISL_NULL) goto err101;\n\n  s1771 (qpoint, pc2, aepsge, tstart, tend, anext, cx2, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Calculate point and derivatives in second curve */\n\n  fevalc2 (pc2, ider, *cx2, jleft2, eder2, &kstat);\n  if (kstat < 0) goto error;\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\nerr101:\n  *jstat = -101;\n  goto out;\n\n  /* Error in lower level routine.  */\n\nerror:\n  *jstat = kstat;\n  goto out;\n\nout:\n  if (qpoint != SISL_NULL)\n    freePoint (qpoint);\n\n  return;\n}\n\n"
  },
  {
    "path": "src/sh1784.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1784.c,v 1.4 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n#define SH1784\n\n#include \"sislP.h\"\n\n\ntypedef  void (*fevalcProc)(\n#if defined(SISLNEEDPROTOTYPES)\n                        SISLCurve *,\n                        int,\n                        double ,\n                        int *,\n                        double [],\n                        int *\n#endif\n);\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh1784 (SISLCurve * pcurve, SISLSurf * psurf, double aepsge,\n\tdouble epar[], int icur, int idirc, double elast[],\n\tdouble enext[], int *jstat)\n#else\nvoid\nsh1784 (pcurve, psurf, aepsge, epar, icur, idirc, elast, enext, jstat)\n     SISLCurve *pcurve;\n     SISLSurf *psurf;\n     double aepsge;\n     double epar[];\n     int icur;\n     int idirc;\n     double elast[];\n     double enext[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : March along a curve as long as it coincides with a given\n*              surface. Start marching in an intersection point. Return\n*              the last found point of coincidence, and the first found\n*              point outside the coincidence interval.\n*\n*\n* INPUT      : pcurve   - Pointer to the curve.\n*              psurf    - Pointer to the surface.\n*              aepsge   - Geometry resolution.\n*              epar[3]  - Parameter values for the given intersection point.\n*              icur     -         = 1 , epar[0] is the parameter value\n*                                       for the curve and epar[1],epar[2] is\n*                                       the parameter values for the surface.\n*                                 = 0 , epar[2] is the parameter value\n*                                       for the curve and epar[0],epar[1] is\n*                                       the parameter values for the surface.\n*              idirc    - Direction to march the curve.\n*                         =  1 : March in the parameter direction.\n*                         = -1 : March in the opposite direction.\n*\n*\n*\n* OUTPUT     : elast[3] - Parameter values of the last point within the\n*                         interval of coincidence.\n*              enext[3] - Parameter values of the first point found outside\n*                         this interval.\n*              jstat   -  status messages\n*                                = 2   : Coincidence until an edge of the surface.\n*                                = 1   : Coincidence of complete curve.\n*                                = 0   : Ok. End of interval found.\n*                                < 0   : Error.\n*\n*\n* METHOD     : March along the curve and iterate down to the surface for\n*              each midpoint and endpoint of each step. The steplenght\n*              is computed from the curvature and the knot vector\n*              of the curve. If any knot lines of the surface are crossed,\n*              the marching are drawn back to the knot line, and a new\n*              step is initiated.\n*              If the closest point on the surface is at an edge of\n*              the surface then we stop with jstat=2.\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SI, Oslo, Norway. 04.91.\n* REVISED BY : Michael Floater,  SI, Oslo, Norway.  08.91.\n*                 Stopping condition at edge of surface.\n* CORRECTED BY: UJK,  SI, Oslo, Norway. Oct. 91\n* REVISED BY : Vibeke Skytt, SI, 02.93. Reduce step length if curve\n*                                       tangent changes direction.\n*********************************************************************\n*/\n{\n  int kstat;\t\t\t/* Status variable                                 */\n  int ki;\t\t\t/* Counter.                                        */\n  int kleftc = 0;\t\t/* Left indicator for point calculation            */\n  int kleft1 = 0;\t\t/* Left indicator for point calculation in 1. par.\n\t\t\t           direction of surface.                           */\n  int kleft2 = 0;\t\t/* Left indicator for point calculation in 2. par dir.*/\n  int kleft1prev, kleft2prev;\t/* Previous left indicators of surface.    */\n  int kn;\t\t\t/* The number of B-splines, i.e., the dimension of\n\t\t\t           the spline space associated with the knot\n\t\t\t           vector.                                         */\n  int kk;\t\t\t/* The polynomial order of the curve.              */\n  int kk1, kk2, kn1, kn2;\t/* Orders and nu,ber of vertices of surface        */\n  int kdimc;\t\t\t/* The dimension of the space in which the curve\n\t\t\t           lies. Equivalently, the number of components\n\t\t\t           of each B-spline coefficient.                   */\n  int kdims;\t\t\t/* Dimension of space where the surface lies       */\n  int kpos = 0;\t\t\t/* Position of error                               */\n  int kderc = 2;\t\t/* Number of derivatives to be claculated on curve */\n  int kders = 1;\t\t/* Number of derivatives to be calculated on surface\n\t\t\t           If step lenght is to be generated from surface,\n\t\t\t           kders must be equal to 2.                       */\n  int kdum;\t\t\t/* Temporary variable                              */\n  int kpar;\t\t\t/* Parameter value of constant parameter curve.    */\n  int kiterate;                 /* Indicates if further iteration is necessary\n\t\t\t\t   after curve-curve iteration.                    */\n  double tref;                  /* Referance value in equality test.               */\n  double tclose1, tclose2;\t/* Parameter values of closest point between curves. */\n  double tangdot;               /* Scalar product between curve tangents.          */\n  double snorm[3];\t\t/* Normal vector of surface                        */\n  double s3dinf1[10];\t\t/* Pointer to storage for point info of curve\n\t\t\t           (10 dobules prpoint when idim=3, 7 when idim=3) */\n  double *st;\t\t\t/* Pointer to the first element of the knot vector\n\t\t\t           of the curve. The knot vector has [kn+kk]\n\t\t\t           elements.                                       */\n  double *st1;\t\t\t/* First knot direction of surface                 */\n  double *st2;\t\t\t/* Second knot direction of surface                */\n  double sfirst[2];\t\t/* Start parameter par in surface                  */\n  double tfirst;\t\t/* Fist parameter on curve                         */\n  double tend;\t\t\t/* Last parameter on curve                         */\n  double sderc[9];\t\t/* Position, first and second derivative of curve  */\n  double stangprev[3];          /* Previous tangent of curve.                      */\n  double sders[18];\t\t/* Position, first and second derivatives of surface */\n  double tx, tx1, tx2;\t\t/* Parameter value */\n  double tstep;\t\t\t/* Final step length     */\n  double tmaxinc;\t\t/* Maximal increment in parameter value along curve*/\n  double tlengthend;\t\t/* Length of 1st derivative at end of segment */\n  double tincre;\t\t/* Parameter value increment */\n  double tsmax, tcmax;\t\t/* Local maximal step length based of boxsizes of objects */\n  double tdist = DZERO;\t\t/* Distance */\n  double sstart[2];\t\t/* Lower boundary of parameter intervals */\n  double send[2];\t\t/* Upper bounadry of parameter intervals */\n  double snext[3];\t\t/* Existing iteration point on  surface            */\n  double spos[3];\t\t/* New iteration  point on surface                 */\n  double snext2[2];\t\t/* Help parameter values.                          */\n  SISLPoint *qpoint = SISL_NULL;\n  SISLCurve *qc = SISL_NULL;\t\t/* Constant parameter curve.                       */\n\n  /* Pointer to curve evaluator routine of the curve.  */\n\n  fevalcProc fevalc;\n/*\n #if defined(SISLNEEDPROTOTYPES)\n   void (*fevalc) (SISLCurve *, int, double, int *, double[], int *);\n #else\n   void (*fevalc) ();\n #endif\n */\n  /* Make maximal step length based on box-size of surface */\n\n  sh1992su (psurf, 0, aepsge, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  tsmax = MAX (psurf->pbox->e2max[0][0] - psurf->pbox->e2min[0][0],\n\t       psurf->pbox->e2max[0][1] - psurf->pbox->e2min[0][1]);\n  tsmax = MAX (tsmax, psurf->pbox->e2max[0][2] - psurf->pbox->e2min[0][2]);\n\n  /* Make maximal step length based on box-size of curve */\n\n  sh1992cu (pcurve, 0, aepsge, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  tcmax = MAX (pcurve->pbox->e2max[0][0] - pcurve->pbox->e2min[0][0],\n\t       pcurve->pbox->e2max[0][1] - pcurve->pbox->e2min[0][1]);\n  tcmax = MAX (tcmax, pcurve->pbox->e2max[0][2] - pcurve->pbox->e2min[0][2]);\n\n  /* Copy curve attributes to local parameters.  */\n\n  kdimc = pcurve->idim;\n  kk = pcurve->ik;\n  kn = pcurve->in;\n  st = pcurve->et;\n\n  /* Copy surface attributes to local parameters.  */\n\n  kdims = psurf->idim;\n  kk1 = psurf->ik1;\n  kk2 = psurf->ik2;\n  kn1 = psurf->in1;\n  kn2 = psurf->in2;\n  st1 = psurf->et1;\n  st2 = psurf->et2;\n\n  /* Set reference value.  */\n\n  tref = MAX(st[kn]-st[kk-1],MAX(st1[kn1]-st1[kk1-1],st2[kn2]-st2[kk2-1]));\n\n  /* Check that dimensions are 3 */\n\n  if (kdimc != 3 || kdims != 3)\n    goto err105;\n\n  sstart[0] = st1[kk1 - 1];\n  sstart[1] = st2[kk2 - 1];\n  send[0] = st1[kn1];\n  send[1] = st2[kn2];\n\n  /* Copy interval description into local variables */\n\n  if (icur == 1)\n    {\n      sfirst[0] = epar[1];\n      sfirst[1] = epar[2];\n      tfirst = epar[0];\n      tend = (idirc == 1) ? st[kn] : st[kk - 1];\n    }\n  else\n    {\n      sfirst[0] = epar[0];\n      sfirst[1] = epar[1];\n      tfirst = epar[2];\n      tend = (idirc == 1) ? st[kn] : st[kk - 1];\n    }\n\n  /* To make sure we do not start outside or end outside the curve we\n     truncate tfirst to the knot interval of the curve */\n\n  tfirst = (idirc == 1) ? MAX (tfirst, st[kk - 1]) : MIN (tfirst, st[kn]);\n\n  /* Set start point of iteration on surface */\n\n  spos[0] = sfirst[0];\n  spos[1] = sfirst[1];\n\n  /* Set curve evaluator of the curve.  */\n\n  fevalc = (idirc == 1) ? s1221 : s1227;\n\n  /* Store knot values at start of curve */\n\n  tx2 = tfirst;\n  kdum = MAX (kk1, kk2);\n  kdum = MAX (kdum, kk);\n  tmaxinc = fabs (tend - tfirst) / (kdum * kdum);\n\n  /* Make start point of curve  */\n\n  fevalc (pcurve, kderc, tx2, &kleftc, sderc, &kstat);\n  if (kstat < 0) goto error;\n\n  /* Make start point of surface.  */\n\n  s1421 (psurf, kders, spos, &kleft1, &kleft2, sders, snorm, &kstat);\n  if (kstat < 0) goto error;\n\n  /* While end not reached */\n\n  while (idirc * tx2 < idirc * tend)\n    {\n      /* Save parameters of previous step.   */\n\n      tx1 = tx2;\n      snext[0] = spos[0];\n      snext[1] = spos[1];\n      kleft1prev = kleft1;\n      kleft2prev = kleft2;\n\n      /* Calculate unit tangent and radius of curvature of curve. */\n\n      s1307 (sderc, kdimc, s3dinf1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /* Calculate step length based on curvature */\n\n      tstep = s1311 (s3dinf1[3 * kdimc], aepsge, tsmax, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /* Remember length of start tangent, end of zero segment */\n\n      tlengthend = s6length (sderc + kdimc, kdimc, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n\n      /* Find candidate end point, make sure that no breaks in tangent or\n         curvature exists between start and endpoints of the segment     */\n      /* Make step length equal to resolution if the length is zero */\n\n      if (DEQUAL (tlengthend, DZERO))\n\ttincre = REL_PAR_RES;\n      else\n\ttincre = tstep / tlengthend;\n\n      tincre = MIN (tincre, tmaxinc);\n\n      /*  Make sure that we don't pass any knots of the curve. */\n\n      if (idirc * (tx1 + tincre) > idirc * (st[kleftc + idirc] + REL_PAR_RES))\n\ttincre = idirc * (st[kleftc + idirc] - tx1);\n\n      if (idirc < 0 && (tx1 - tincre < st[kleftc] - REL_PAR_RES))\n\ttincre = idirc * (st[kleftc] - tx1);\n\n      /* Find parameter value of candidate end point of segment */\n\n      tx2 = tx1 + idirc * tincre;\n\n      for (ki = 0, tx = (tx1 + tx2) / (double) 2.0; ki < 2; ki++, tx = tx2)\n\t{\n\t  if (idirc * tx >= idirc * tend)\n\t    break;\n\n\t  /* Make point sderc at curve at tx */\n\n\t  fevalc (pcurve, kderc, tx, &kleftc, sderc, &kstat);\n\t  if (kstat < 0) goto error;\n\n\t  /* Test if the step is legal.  */\n\n\t  if (DNEQUAL(tx1,tfirst) || ki>0)\n\t  {\n\t     tangdot = s6scpr(stangprev, sderc+kdimc, kdimc);\n\t     while (tangdot < DZERO)\n\t     {\n\t\t/* The step is not legal. Reduce step length. */\n\n\t\tif (ki == 0)\n\t\t{\n\t\t   tx2 = tx;\n\t\t   tx = (tx1 + tx2)/(double)2.0;\n\t\t}\n\t\telse\n\t\t{\n\t\t   tx2 = tx1 + (double)0.75*(tx2-tx1);\n\t\t   tx = tx2;\n\t\t}\n\n\t\t/* Make point sderc at curve at tx */\n\n\t\tfevalc (pcurve, kderc, tx, &kleftc, sderc, &kstat);\n\t\tif (kstat < 0) goto error;\n\n\t\ttangdot = s6scpr(stangprev, sderc+kdimc, kdimc);\n\t     }\n\t  }\n\t  /* Find closest point on surface to sderc */\n\n\t  qpoint = newPoint (sderc, kdimc, 0);\n\t  if (qpoint == SISL_NULL)\n\t    goto err101;\n\n\t  snext2[0] = snext[0];\n\t  snext2[1] = snext[1];\n\t  s1773 (qpoint, psurf, aepsge, sstart, send, snext2, spos, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  freePoint (qpoint);\n\t  qpoint = SISL_NULL;\n\n\t  /* Check to see if we have crossed an edge of the\n\t     surface, i.e. we have gone outside the parameter\n\t     area for psurf. */\n\n          if(spos[0] <= st1[kk1-1] || spos[0] >= st1[kn1] ||\n             spos[1] <= st2[kk2-1] || spos[1] >= st2[kn2])\n          {\n\t      /* Coincidence! Finish with a message. */\n\t      goto edge_of_surf;\n\t  }\n\n\t  /* Calculate point and derivatives in surface */\n\n\t  s1421 (psurf, kders, spos, &kleft1, &kleft2, sders, snorm, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  /* Check if point on curve and surface are within positional and\n             angular tolerances */\n\n\t  tdist = s6dist (sderc, sders, kdimc);\n\n\t  if (tdist > aepsge)\n\t    {\n\t      /* Points not within tolerances, curve and surface do not\n\t         coincide */\n\t      goto no_coin;\n\t    }\n\n\t  /* Check if any parameter lines of the surface is crossed in the 1.\n             parameter direction.  */\n\n\t  if (kleft1 != kleft1prev &&\n\t      ((DNEQUAL(spos[0]+tref,st1[kleft1]+tref) &&\n\t\tDNEQUAL(snext[0]+tref,st1[kleft1]+tref)) ||\n\t       kleft1 != kleft1prev+1) &&\n\t      ((DNEQUAL(snext[0]+tref,st1[kleft1prev]+tref) &&\n\t\tDNEQUAL(spos[0]+tref,st1[kleft1prev]+tref)) ||\n\t       kleft1 != kleft1prev - 1))\n\t    {\n\t      /* At least one parameter line is crossed. Fetch the constant parameter\n\t         curve at the closest parameter line in the direction of the marching. */\n\n\t      if (kleft1 > kleft1prev)\n\t\tkpar = kleft1prev + 1;\n\t      else if (snext[0] != st1[kleft1prev])\n\t\tkpar = kleft1prev;\n\t      else\n\t\tkpar = kleft1prev - 1;\n\n\t      /* Pick constant parameter curve.   */\n\n\t      s1437 (psurf, st1[kpar], &qc, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      /* Find the closest point between the input curve and the constant\n\t         parameter curve.    */\n\n\t\t/* UJK Oct 91, Nice trap ! tx1 > tx */\n\t\t/*  s1770 (pcurve, qc, aepsge, tx1, st2[kk2 - 1], tx, st2[kn2], (tx1 + tx) / (double) 2.0,\n\t\t     st2[kleft2], &tclose1, &tclose2, &kstat); */\n\t       s1770 (pcurve, qc, aepsge, min(tx1,tx), st2[kk2 - 1], max(tx1,tx),\n\t\t      st2[kn2], (tx1 + tx) / (double) 2.0,\n\t\t     (double)0.5*(st2[kleft2]+st2[kleft2+1]),\n\t\t     &tclose1, &tclose2, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      if (kstat == 2 || fabs(tclose1-tx1) < REL_PAR_RES)\n\t\t /* No intersection point is found. Mark that surface-point\n\t\t    iteration is necessary.  */\n\n\t\t kiterate = 1;\n\t      else kiterate = 0;\n\n\t      /* Set new parameter values to the iteration.  */\n\n\t      spos[0] = st1[kpar];\n\t      spos[1] = tclose2;\n\t      if (fabs(tclose1-tx1) > REL_PAR_RES) tx2 = tclose1;\n\n\t      /* Test midpoint of reduced step. First evaluate curve in midpoint. */\n\n\t      tx = (tx1 + tx2) / (double) 2.0;\n\n\t      fevalc (pcurve, kderc, tx, &kleftc, sderc, &kstat);\n\t      if (kstat < 0) goto error;\n\n\t      /* Find closest point on surface to sderc */\n\n\t      qpoint = newPoint (sderc, kdimc, 0);\n\t      if (qpoint == SISL_NULL)\n\t\tgoto err101;\n\n\t      snext2[0] = snext[0];\n\t      snext2[1] = snext[1];\n\t      s1773 (qpoint, psurf, aepsge, sstart, send, snext2, snext2, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      freePoint (qpoint);\n\t      qpoint = SISL_NULL;\n\n\t      /* Calculate point and derivatives in surface */\n\n\t      s1421 (psurf, kders, snext2, &kleft1, &kleft2, sders, snorm, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      /* Check if point on curve and surface are within positional and\n\t         angular tolerances */\n\n\t      tdist = s6dist (sderc, sders, kdimc);\n\n\t      if (tdist > aepsge)\n\t\t{\n\t\t  /* Points not within tolerances, curve and surface do not\n\t\t     coincide */\n\t\t  goto no_coin;\n\t\t}\n\n\t      /* Calculate point and derivatives in the curve in the endpoint of the step. */\n\n\t      fevalc (pcurve, kderc, tx2, &kleftc, sderc, &kstat);\n\t      if (kstat < 0) goto error;\n\n\t      if (kiterate)\n\t      {\n\t\t /* Relax the point on the curve down to the surface. */\n\n\t\t qpoint = newPoint (sderc, kdimc, 0);\n\t\t if (qpoint == SISL_NULL)\n\t\t    goto err101;\n\n\t\t spos[0] = snext2[0];\n\t\t spos[1] = snext2[1];\n\t\t s1773 (qpoint, psurf, aepsge, sstart, send, spos, spos, &kstat);\n\t\t if (kstat < 0)\n\t\t    goto error;\n\n\t\t freePoint (qpoint);\n\t\t qpoint = SISL_NULL;\n\t      }\n\n\t      /* Calculate point and derivatives in the surface.  */\n\n\t      s1421 (psurf, kders, spos, &kleft1, &kleft2, sders, snorm, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      /* Check if point on curve and surface are within positional and\n\t         angular tolerances */\n\n\t      tdist = s6dist (sderc, sders, kdimc);\n\n\t      if (tdist > aepsge)\n\t\t{\n\t\t  /* Points not within tolerances, curve and surface do not\n\t\t     coincide */\n\t\t  goto no_coin;\n\t\t}\n\n\t      /* Mark that a new step is to be initiated.  */\n\n\t      ki = 2;\n\n\t      /* Free constant parameter curve.  */\n\n\t      if (qc != SISL_NULL)\n\t\tfreeCurve (qc);\n\t      qc = SISL_NULL;\n\t    }\n\n\t  /* Check if any parameter lines of the surface is crossed in the 2.\n             parameter direction.  */\n\n\t  if (kleft2 != kleft2prev &&\n\t      ((DNEQUAL(spos[1]+tref,st2[kleft2]+tref) &&\n\t\tDNEQUAL(snext[1]+tref,st2[kleft2]+tref)) ||\n\t       kleft2 != kleft2prev+1) &&\n\t      ((DNEQUAL(snext[1]+tref,st2[kleft2prev]+tref) &&\n\t\tDNEQUAL(spos[1]+tref,st2[kleft2prev]+tref)) ||\n\t       kleft2 != kleft2prev - 1))\n\t    {\n\t      /* At least one parameter line is crossed. Fetch the constant parameter\n\t         curve at the closest parameter line in the direction of the marching. */\n\n\t      if (kleft2 > kleft2prev)\n\t\tkpar = kleft2prev + 1;\n\t      else if (snext[1] != st2[kleft2prev])\n\t\tkpar = kleft2prev;\n\t      else\n\t\tkpar = kleft2prev - 1;\n\n\t      /* Pick constant parameter curve.   */\n\n\t      s1436 (psurf, st2[kpar], &qc, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      /* Find the closest point between the input curve and the constant\n\t         parameter curve.    */\n\n\t\t/* UJK Oct 91, Nice trap ! tx1 > tx */\n\t\ts1770 (pcurve, qc, aepsge, min(tx1,tx), st1[kk1 - 1], max(tx,tx1),\n\t\t       st1[kn1], (tx1 + tx) / (double) 2.0,\n\t\t       (double)0.5*(st1[kleft1]+st1[kleft1+1]),\n\t\t       &tclose1, &tclose2, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      if (kstat == 2 || fabs(tclose1-tx1) < REL_PAR_RES)\n\t\t /* No intersection point is found. Mark that surface-point\n\t\t    iteration is necessary.  */\n\n\t\t kiterate = 1;\n\t      else kiterate = 0;\n\n\t      /* Set new parameter values to the iteration.  */\n\n\t      spos[0] = tclose2;\n\t      spos[1] = st2[kpar];\n\t      if (fabs(tclose1-tx1) > REL_PAR_RES) tx2 = tclose1;\n\n\t      /* Test midpoint of reduced step. First evaluate curve in midpoint. */\n\n\t      tx = (tx1 + tx2) / (double) 2.0;\n\n\t      fevalc (pcurve, kderc, tx, &kleftc, sderc, &kstat);\n\t      if (kstat < 0) goto error;\n\n\t      /* Find closest point on surface to sderc */\n\n\t      qpoint = newPoint (sderc, kdimc, 0);\n\t      if (qpoint == SISL_NULL)\n\t\tgoto err101;\n\n\t      snext2[0] = snext[0];\n\t      snext2[1] = snext[1];\n\t      s1773 (qpoint, psurf, aepsge, sstart, send, snext2, snext2, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      freePoint (qpoint);\n\t      qpoint = SISL_NULL;\n\n\t      /* Calculate point and derivatives in surface */\n\n\t      s1421 (psurf, kders, snext2, &kleft1, &kleft2, sders, snorm, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      /* Check if point on curve and surface are within positional and\n\t         angular tolerances */\n\n\t      tdist = s6dist (sderc, sders, kdimc);\n\n\t      if (tdist > aepsge)\n\t\t{\n\t\t  /* Points not within tolerances, curve and surface do not\n\t\t     coincide */\n\t\t  goto no_coin;\n\t\t}\n\n\t      /* Calculate point and derivatives in the curve.    */\n\n\t      fevalc (pcurve, kderc, tx2, &kleftc, sderc, &kstat);\n\t      if (kstat < 0) goto error;\n\n\t      if (kiterate)\n\t      {\n\t\t /* Relax the point on the curve down to the surface. */\n\n\t\t qpoint = newPoint (sderc, kdimc, 0);\n\t\t if (qpoint == SISL_NULL)\n\t\t    goto err101;\n\n\t\t spos[0] = snext2[0];\n\t\t spos[1] = snext2[1];\n\t\t s1773 (qpoint, psurf, aepsge, sstart, send, spos, spos, &kstat);\n\t\t if (kstat < 0)\n\t\t    goto error;\n\n\t\t freePoint (qpoint);\n\t\t qpoint = SISL_NULL;\n\t      }\n\n\n\t      /* Calculate point and derivatives in the surface.  */\n\n\t      s1421 (psurf, kders, spos, &kleft1, &kleft2, sders, snorm, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      /* Check if point on curve and surface are within positional and\n\t         angular tolerances */\n\n\t      tdist = s6dist (sderc, sders, kdimc);\n\n\t      if (tdist > aepsge)\n\t\t{\n\t\t  /* Points not within tolerances, curve and surface do not\n\t\t     coincide */\n\t\t  goto no_coin;\n\t\t}\n\n\t      /* Mark that a new step is to be initiated.  */\n\n\t      ki = 2;\n\n\t      /* Free constant parameter curve.  */\n\n\t      if (qc != SISL_NULL)\n\t\tfreeCurve (qc);\n\t      qc = SISL_NULL;\n\t    }\n\n\t  /* Save tangent of curve.  */\n\n\t  memcopy(stangprev, sderc+kdimc, kdimc, DOUBLE);\n\t}\n    }\n\n  /* Coincidence interval along complete curve. */\n\n  *jstat = 1;\n  if (icur == 1)\n    {\n      elast[0] = tx1;\n      elast[1] = snext[0];\n      elast[2] = snext[1];\n    }\n  else\n    {\n      elast[0] = snext[0];\n      elast[1] = snext[1];\n      elast[2] = tx1;\n    }\n  goto out;\n\n  /* Curve and surface not within tolerance */\nno_coin:*jstat = 0;\n  if (icur == 1)\n    {\n      elast[0] = tx1;\n      elast[1] = snext[0];\n      elast[2] = snext[1];\n      enext[0] = tx2;\n      enext[1] = spos[0];\n      enext[2] = spos[1];\n    }\n  else\n    {\n      elast[0] = snext[0];\n      elast[1] = snext[1];\n      elast[2] = tx1;\n      enext[0] = spos[0];\n      enext[1] = spos[1];\n      enext[2] = tx2;\n    }\n  goto out;\n\n  /* Curve and surface are within tolerance up to an edge\n     of the surface. */\nedge_of_surf:\n  *jstat = 2;\n  if (icur == 1)\n    {\n      elast[0] = tx1;\n      elast[1] = snext[0];\n      elast[2] = snext[1];\n      enext[0] = tx2;\n      enext[1] = spos[0];\n      enext[2] = spos[1];\n    }\n  else\n    {\n      elast[0] = snext[0];\n      elast[1] = snext[1];\n      elast[2] = tx1;\n      enext[0] = spos[0];\n      enext[1] = spos[1];\n      enext[2] = tx2;\n    }\n  goto out;\n\n  /* Error in memory allocation */\n\nerr101:*jstat = -101;\n  s6err (\"sh1784\", *jstat, kpos);\n  goto out;\n\n  /* Error in input, dimension not equal to 2 or 3 */\n\nerr105:*jstat = -105;\n  s6err (\"sh1784\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level function */\n\nerror:*jstat = kstat;\n  s6err (\"sh1784\", *jstat, kpos);\n  goto out;\n\n\nout:\n\n  return;\n}\n"
  },
  {
    "path": "src/sh1786.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1786.c,v 1.2 2001-03-19 15:59:05 afr Exp $\n *\n */\n\n\n#define SH1786\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh1786 (SISLObject * po1, SISLObject * po2, double aepsge,\n\tSISLIntdat ** rintdat, SISLIntpt * pintpt, int *jnewpt,\n\tint *jstat)\n#else\nvoid\nsh1786 (po1, po2, aepsge, rintdat, pintpt, jnewpt, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     SISLIntdat **rintdat;\n     SISLIntpt *pintpt;\n     int *jnewpt;\n     int *jstat;\n#endif\n/*\n******************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Set pre-topology data in n-dimensional curve-point\n*              intersection. Also find help points if necessary.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              aepsge   - Geometry resolution.\n*              rintdat  - Intersection data structure.\n*              pintpt   - Current intersection point.\n*\n*\n* OUTPUT     : pintpt   - Intersection point after updating pre-topology.\n*              jnewpt   - Number of new int.pt. created.\n*              jstat    - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      : shevalc  -  Evaluate curve using filtered coefficients.\n*              s6ang    -  Angle between two vectors.\n*              s6idcon  -  Connect two intersection points.\n*              hp_newIntpt -  Create new intersection point.\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. 09.91.\n* CHANGED BY : UJK, ALA, SI, 10.10.91:\n*              Purpose of function is only to generate helppoints in 2D\n* REWISED BY : VSK, 11-92.  Make sure that a help point always is an\n*                           intersection point.\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                        */\n  int ki, kj;\t\t\t/* Counters.                               */\n  int kleft = 0;\t\t/* Parameter to evaluator.                 */\n  int korgleft = 0;\t\t/* Knot index.                 \t\t   */\n  int kdim;\t\t\t/* Dimension of geometry space.            */\n  int kn;\t\t\t/* Number of vertices of curve.            */\n  int kk;\t\t\t/* Order of curve.                         */\n  int kpos = 0;\t\t\t/* Current position in int.pt. array.      */\n  double tpoint[3];\t\t/* Value of point to intersect.            */\n  double tpar0, tpar;\t\t/* Parameter value of point on curve.      */\n  double spar[1];\t\t/* Parameter value of endpoint of curve.   */\n  double sder[6];\t\t/* Result of curve evaluation.             */\n  double stang1[2];\t\t/* Tangent vector of curve.                */\n  double stang2[2];\t\t/* Tangent vector of level value.          */\n  double *st;\t\t\t/* Pointer to knot vector of curve.        */\n  double *sptpar = pintpt->epar;/* Pointer to parameter array of int.pt.   */\n  double tref;\t\t\t/* Referance value in equality test.       */\n  SISLCurve *qc;\t\t/* Pointer to current curve.               */\n  SISLIntpt *uintpt[2];\t\t/* Array storing new intersection points.  */\n  double *ret_val;\t\t/* Pointer to geo data from sh6getgeom     */\n  double *ret_norm;\t\t/* Pointer to geo data from sh6getgeom     */\n  double *nullp = SISL_NULL;\n  double dist;                  /* Distance from curve to point.           */\n  double tot_ang;               /* Sum of angles between curve deriv. and 1*/\n  int i;                        /* Loop variable.                          */\n  int make_hp;                  /* Flag, make/not make help pt.            */\n  /* --------------------------------------------------------------------- */\n\n  /* Don't make help point for help points ! */\n  if (sh6ishelp (pintpt))\n    {\n      *jstat = 0;\n      goto out;\n    }\n\n\n  /* Test dimension of geometry space. */\n  if (po1->iobj == SISLCURVE)\n    {\n      qc = po1->c1;\n    }\n  else\n    {\n      qc = po2->c1;\n    }\n\n  kdim = qc->idim;\n  if (kdim != 2) goto err106;\n\t       \n  /* Store curve information in local parameters. */\n\n  kn = qc->in;\n  kk = qc->ik;\n  st = qc->et;\n  tref = st[kn] - st[kk - 1];\n\n  /* Fetch geometry information, point.  */\n  sh6getgeom ((po1->iobj == SISLPOINT) ? po1 : po2,\n\t      (po1->iobj == SISLPOINT) ? 1 : 2,\n\t      pintpt, &ret_val, &ret_norm, aepsge, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  for(i=0; i<kdim; i++)\n      tpoint[i] = ret_val[i];\n\n  /* Fetch geometry information, curve.  */\n  sh6getgeom ((po1->iobj == SISLCURVE) ? po1 : po2,\n\t      (po1->iobj == SISLCURVE) ? 1 : 2,\n\t      pintpt, &ret_val, &ret_norm, aepsge, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  s1219(st,kk,kn,&korgleft,sptpar[0],&kstat);\n  if (kstat < 0) goto error;\n  \n  for(i=0; i<kdim*2; i++)\n      sder[i] = ret_val[i];\n\n/* Set tangent vectors. */\n\n  stang1[0] = (double)1.0;\n  stang2[0] = (double)1.0;\n  stang2[1] = DZERO;\n  tot_ang = (double)0.0;\n\n  for(i=0; i<kdim; i++)\n  {\n      stang1[1] = sder[kdim+i];\n      tot_ang += s6ang(stang1,stang2,2);\n  }\n\n  /*  tune */\n  if (fabs(tot_ang) <= ANGULAR_TOLERANCE)\n    {\n      /* Test if the intersection point lies at the endpoint of\n         the curve. */\n\n      if (DEQUAL (sptpar[0] + tref, st[kn] + tref))\n\t{\n\n\t}\n      else\n\t{\n\t  /* Find endpoint of coincidence interval in the positive\n             direction of the curve. */\n\t  ki = 0;\n\t  tpar = sptpar[0] + (double) 2.0 *sqrt (aepsge);\n\t  tpar = min (tpar, st[kn]);\n\t  tpar0 = tpar = min (tpar, st[korgleft+1]);\n\t  shevalc (qc, 0, tpar, aepsge, &kleft, sder, &kstat);\n          dist=s6dist(sder,tpoint,kdim);\n          if (dist <= aepsge)\n\t    {\n\t       make_hp = TRUE;\n\t      for (ki = kleft - kk + 1; ki < kn; ki++)\n\t\t{\n\t\t  for (tpar = DZERO, kj = ki + 1; kj < ki + kk; kj++)\n\t\t    tpar += st[kj];\n\t\t  tpar /= (double) (kk - 1);\n\n\t\t  if (tpar > sptpar[0])\n\t\t    {\n\t\t      shevalc (qc, 0, tpar, aepsge, &kleft, sder, &kstat);\n\t\t      dist=s6dist(sder,tpoint,kdim);\n\t\t      if (dist > aepsge) break;\n\t\t      \n\t\t      tpar0 = tpar;  /* Store parameter value of \n\t\t\t\t\tintersection point.          */\n\t\t    }\n\t\t}\n\t    }\n\t  else make_hp = FALSE;\n\n\t  /* Test if there is coincidence along the entire curve part. */\n\n\t  if (ki != kn && make_hp)\n\t    {\n\t      /* Create help point.  */\n\t       \n\t      spar[0] = tpar0;\n\t      uintpt[kpos] = SISL_NULL;\n\t      if ((uintpt[kpos] = hp_newIntpt (1, spar, DZERO, -SI_ORD,\n\t\t\t\t\t       SI_UNDEF, SI_UNDEF, SI_UNDEF,\n\t\t\t\t    SI_UNDEF, 0, 0, nullp, nullp)) == SISL_NULL)\n\t\tgoto err101;\n\n\t      /* Insert the point into the data structure.  */\n\n\t      sh6idnpt (rintdat, &uintpt[kpos], 1, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      kpos++;\n\t    }\n\t}\n\n      /* Test if the intersection point lies at the startpoint\n         of the curve. */\n\n      if (DEQUAL (sptpar[0] + tref, st[kk - 1] + tref))\n\t{\n\t}\n      else\n\t{\n\t  /* Find endpoint of coincidence interval in the negative\n             direction of the curve. */\n\n\t  ki = kn;\n\t  while (sptpar[0] == st[korgleft]) korgleft--;\n\t  tpar = sptpar[0] - (double) 2.0 *sqrt (aepsge);\n\t  tpar = max (tpar, st[kk - 1]);\n\t  tpar0 = tpar = max (tpar, st[korgleft]);\t  \n\t  shevalc (qc, 0, tpar, aepsge, &kleft, sder, &kstat);\n          dist=s6dist(sder,tpoint,kdim);\n          if (dist <= aepsge)\n\t    {\n\t       make_hp = TRUE;\n\t       \n\t      for (ki = kleft; ki >= 0; ki--)\n\t\t{\n\t\t  for (tpar = DZERO, kj = ki + 1; kj < ki + kk; kj++)\n\t\t    tpar += st[kj];\n\t\t  tpar /= (double) (kk - 1);\n\n\t\t  if (tpar < sptpar[0])\n\t\t    {\n\t\t      shevalc (qc, 0, tpar, aepsge, &kleft, sder, &kstat);\n\t\t      dist=s6dist(sder,tpoint,kdim);\n\t\t      if (dist > aepsge) break;\n\t\t      \n\t\t      tpar0 = tpar;  /* Store parameter value of last\n\t\t\t\t\tfound intersection point.  */\n\t\t    }\n\t\t}\n\t    }\n\t  else make_hp = FALSE;\n\t  \n\t  /* Test if there is coincidence along the entire curve part. */\n\t  if (ki >= 0 && make_hp)\n\t    {\n\n\t      /* Create intersection point.  */\n\t      spar[0] = tpar0;\n\t      uintpt[kpos] = SISL_NULL;\n\t      if ((uintpt[kpos] = hp_newIntpt (1, spar, DZERO, -SI_ORD,\n\t\t\t\t\t       SI_UNDEF,SI_UNDEF,SI_UNDEF,\n\t\t\t\t\tSI_UNDEF, 0, 0, nullp, nullp)) == SISL_NULL)\n\t\tgoto err101;\n\n\t      /* Insert the point into the data structure.  */\n\n\t      sh6idnpt (rintdat, &uintpt[kpos], 1, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\n\t      kpos++;\n\n\t    }\n\n\t}\n    }\n\n  /* Join intersection points.  (kpos=0,1,2)*/\n  for (ki = 0; ki < kpos; ki++)\n    {\n      sh6idnpt (rintdat, &uintpt[ki], 1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      /* Mark that an intersection interval is found.  */\n      if (sh6ishelp (uintpt[ki]) && uintpt[ki]->no_of_curves == 0)\n\t{\n\t  sh6idcon (rintdat, &uintpt[ki], &pintpt, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n    }\n\n  /* Pre-topology information computed. */\n\n  *jnewpt = kpos;\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation.  */\n\nerr101:*jstat = -101;\n  goto out;\n\n  /* Error in input. Incorrect dimension.  */\n\nerr106:*jstat = -106;\n  goto out;\n\n  /* Error lower level routine.  */\n\nerror:*jstat = kstat;\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/sh1787.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1787.c,v 1.4 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n#define SH1787\n\n#include \"sislP.h\"\n\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n    sh1787 (SISLObject * po1, SISLObject * po2, double aepsge,\n\tSISLIntdat ** rintdat, SISLIntpt * pintpt, int *jnewpt,\n\tint *jstat)\n#else\nvoid\n   sh1787 (po1, po2, aepsge, rintdat, pintpt, jnewpt, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     SISLIntdat **rintdat;\n     SISLIntpt *pintpt;\n     int *jnewpt;\n     int *jstat;\n#endif\n/*\n******************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Set pre-topology data in n-dimensional surface-point\n*              intersection.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              aepsge   - Geometry resolution.\n*              rintdat  - Intersection data structure.\n*              pintpt   - Current intersection point.\n*\n*\n* OUTPUT     : pintpt   - Intersection point after updating pre-topology.\n*              jnewpt   - Number of new int.pt. created.\n*              jstat    - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      : shevalc  -  Evaluate surface using filtered coefficients.\n*              s6ang    -  Angle between two vectors.\n*              s6idcon  -  Connect two intersection points.\n*              hp_newIntpt -  Create new intersection point.\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. 09.91.\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                        */\n  int kdim;\t\t\t/* Dimension of geometry space.              */\n  int kn1;\t\t\t/* Nmb vertices of surface in 1st direc.     */\n  int kn2;\t\t\t/* Nmb vertices of surface in 1st direc.     */\n  int kk1;\t\t\t/* Order of surface in 1st direction.        */\n  int kk2;\t\t\t/* Order of surface in 1st direction.        */\n  int kpos = 0;\t\t\t/* Current position in int.pt. array.        */\n  int lleft[2];\t\t\t/* Array storing pre-topology information.   */\n  int lright[2];\t\t/* Array storing pre-topology information.   */\n  int *ll1, *ll2, *lr1, *lr2;\t/* Pointers into pre-topology arrays.        */\n  double tpoint[3];\t\t/* Value of point to intersect.              */\n  double sder[21];\t\t/* Result of surface evaluation.             */\n  double *st1;\t\t\t/* First knot vector of surface.             */\n  double *st2;\t\t\t/* Second knot vector of surface.            */\n  double tref1;\t\t\t/* Referance value in equality test.         */\n  double tref2;\t\t\t/* Referance value in equality test.         */\n  SISLSurf *qs;\t\t        /* Pointer to current surface.               */\n  double *ret_val;\t\t/* Pointer to geo data from sh6getgeom       */\n  double *ret_norm;\t\t/* Pointer to geo data from sh6getgeom       */\n  int i;                        /* Loop variable.                            */\n  double cross;                 /* utang x vtang.                            */\n  double in_out[2];             /* To be used in touchy situations           */\n  /* ----------------------------------------------------------------------  */\n\n  /* Don't make pretop for help points ! */\n  /* Oh, yes ?, 2D is some nice case ! */\n  /* if (sh6ishelp (pintpt))\n     {\n     *jstat = 0;\n     goto out;\n     }\n     */\n\n  /* Set pointers into the arrays storing pre-topology information. */\n  if (po1->iobj == SISLSURFACE)\n    {\n      ll1 = lleft;\n      lr1 = lright;\n      ll2 = lleft + 1;\n      lr2 = lright + 1;\n    }\n  else\n    {\n      ll1 = lleft + 1;\n      lr1 = lright + 1;\n      ll2 = lleft;\n      lr2 = lright;\n    }\n\n  /* Get pre-topology information. */\n  sh6gettop (pintpt, -1, lleft, lright, lleft + 1, lright + 1, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Test dimension of geometry space. */\n  if (po1->iobj == SISLSURFACE)\n      qs = po1->s1;\n  else\n      qs = po2->s1;\n\n  kdim = qs->idim;\n  if (kdim != 2)\n    goto err106;\n\n  /* Store surface information in local parameters. */\n\n  kn1 = qs->in1;\n  kn2 = qs->in2;\n  kk1 = qs->ik1;\n  kk2 = qs->ik2;\n  st1 = qs->et1;\n  st2 = qs->et2;\n  tref1 = st1[kn1] - st1[kk1 - 1];\n  tref2 = st2[kn2] - st2[kk2 - 1];\n\n  /* Fetch geometry information, point.  */\n  sh6getgeom ((po1->iobj == SISLPOINT) ? po1 : po2,\n\t      (po1->iobj == SISLPOINT) ? 1 : 2,\n\t      pintpt, &ret_val, &ret_norm, aepsge, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  for(i=0; i<kdim; i++)\n      tpoint[i]=ret_val[i];\n\n\n  /* Fetch geometry information, surface.  */\n  sh6getgeom ((po1->iobj == SISLSURFACE) ? po1 : po2,\n\t      (po1->iobj == SISLSURFACE) ? 1 : 2,\n\t      pintpt, &ret_val, &ret_norm, aepsge, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  for(i=0; i<kdim*3; i++)\n       sder[i]=ret_val[i];\n\n/* Set normal vector from the 2D tangent vectors. */\n\n  cross = sder[kdim]*sder[2*kdim+1] + sder[kdim+1]*sder[2*kdim];\n\n  /*  Could improve this test. */\n  if (fabs(cross) > ANGULAR_TOLERANCE)\n    {\n      /* Compute pre-topology using local information.  */\n\n      if (cross > 0)\n\t{\n\t  *ll1 = SI_UNDEF;\n\t  *lr1 = SI_UNDEF;\n\t  *ll2 = SI_IN;\n\t  *lr2 = SI_OUT;\n\t}\n      else\n\t{\n\t  *ll1 = SI_UNDEF;\n\t  *lr1 = SI_UNDEF;\n\t  *ll2 = SI_OUT;\n\t  *lr2 = SI_IN;\n\t}\n\n    }\n  else if (qs->pdir && qs->pdir->ecoef &&\n\t   (DNEQUAL(qs->pdir->ecoef[0],DZERO) ||\n\t    DNEQUAL(qs->pdir->ecoef[1],DZERO)))\n    {\n       /* March to find help points.\n\t   Not implemented yet. */\n       /* UJK, I'm not sure, but something like this should work :\n\t  Remeber we are in a simple case situation !\n\t  */\n       in_out[0] =  (double)1.0;\n       in_out[1] = -(double)1.0;\n\n       if (s6scpr(qs->pdir->ecoef,in_out,kdim) > 0)\n\t  {\n\t     *ll1 = SI_UNDEF;\n\t     *lr1 = SI_UNDEF;\n\t     if (*ll2 == SI_UNDEF &&\n\t\t *lr2 == SI_UNDEF)\n\t     {\n\t\t*ll2 = SI_IN;\n\t\t*lr2 = SI_OUT;\n\t     }\n\t     else if (!((*ll2 == SI_IN && *lr2 == SI_IN) ||\n\t\t      (*ll2 == SI_OUT && *lr2 == SI_OUT)))\n\t\t{\n\t\t   if (*ll2 != SI_IN) *ll2 = SI_IN;\n\t\t}\n\t  }\n\t  else\n\t  {\n\t     *ll1 = SI_UNDEF;\n\t     *lr1 = SI_UNDEF;\n\t     if (*ll2 == SI_UNDEF &&\n\t\t *lr2 == SI_UNDEF)\n\t     {\n\t\t*ll2 = SI_OUT;\n\t\t*lr2 = SI_IN;\n\t     }\n\t     else if (!((*ll2 == SI_IN && *lr2 == SI_IN) ||\n\t\t      (*ll2 == SI_OUT && *lr2 == SI_OUT)))\n\t\t{\n\t\t   if (*lr2 != SI_IN) *lr2 = SI_IN;\n\t\t}\n\t  }\n\n    }\n\n  /* Update pretopology of intersection point.  */\n\n  sh6settop (pintpt, -1, lleft[0], lright[0], lleft[1], lright[1], &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Pre-topology information computed. */\n\n  *jnewpt = kpos;\n  *jstat = 0;\n  goto out;\n\n  /* Error in input. Incorrect dimension.  */\n\nerr106:*jstat = -106;\n  goto out;\n\n  /* Error lower level routine.  */\n\nerror:*jstat = kstat;\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/sh1790.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1790.c,v 1.2 2001-03-19 15:59:05 afr Exp $\n *\n */\n\n\n#define SH1790\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh1790(SISLObject *po1,SISLObject *po2,int itype,\n\t    double aepsge,int *jstat)\n#else\nvoid sh1790(po1,po2,itype,aepsge,jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     int    itype;\n     double aepsge;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Perform a box-test on the two object given by\n*              po1 and po2 and check if the boxes overlap.\n*\n*\n*\n* INPUT      : po1    - First object.\n*              po2    - Second object.\n*              itype  - Kind of box to make.\n*                       = 0 : Do not expand box.\n*                       = 1 : Make a totally expanded box.\n*                       = 2 : Make a box expanded in the inner of the\n*                             object, and reduced along the edges/endpoints.\n*                       If itype>=10, it is interpreted as itype-10. This\n*                       code is present to reduce the number of sides in\n*                       the box to be made.\n*\t       aepsge - Geometry resolution.\n*                                                                     \n*\n* OUTPUT     : jstat  - status messages  \n*                            = 5      : Danger of shadow area in point\n*                                       intersection.\n*\t\t\t     = 4      : One box is collapsed into a point.\n*\t\t\t     = 3      : Both boxes inside geometry resolution.\n*                            = 2      : Overlap as closed sets only.\n*                            = 1      : Overlap as open sets.\n*                            = 0      : No overlap.\n*                            < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-03.\n*              Arne Laksaa, SI, 89-07.\n* REWISED BY : Vibeke Skytt, SI, 91-01. Tolerance dependant boxes.\n* CORRECTED BY: UJK and ALA, SI, 91-08. Removed edge test\n* REWISED BY : VSK, SI, 92-10. Transform tolerance to other object when a point\n*                              is included. Special check on \"shadow area\",\n*                              which may arise in point-object intersection\n*                              where the point lies outside the reduced box\n*                              of the other object, but still within a \n*                              distance less than the tolerance from the\n*                              object itself (in particular curve). This\n*                              is possible near the endpoints/edges of the\n*                              other object.\n*********************************************************************\n*/                                     \n{\n  int kstat = 0;        /* Local status error.                        */\n  int kpos = 0;         /* Position of error.                         */\n  int ktype = itype%10; /* Type of box to make.                       */\n  int kant;             /* Number of sides in all boxes.              */\n  int kdim1,kdim2;      /* Dimension of space.\t    \t   \t      */\n  int ki,kj=0;          /* Counters.                                  */\n  int kpttest=0;        /* Indicates wether one object is a point and\n\t\t\t   the geometry has dimension greater than 1.\n\t\t\t   In that case the boundaries of the box is\n\t\t\t   placed further out in the min- and max-arrays. */\n  int kshadow = 0;      /* Indicates if there is a risk of a shadow areas */\n  int kbez = 0;         /* Indicates if any object is a bezier object.    */\n  double tdist;         /* Distance between boxes.                    */\n  double teps1;         /* To be used in 1D.                          */\n  double teps2;         /* Two times aepsge if expanded box.          */\n  double tepsge = aepsge; /* Tolerance to be used locally. In 1D \n\t\t\t     tepsge=2*aepsge since the point is not\n\t\t\t     expended.                                */\n  double t1,t2,t3,t4;   /* Help variables.                            */\n  double t01,t02,t03,t04;   /* Help variables.                        */\n  double *tmin1,*tmax1; /* Smallest and larges value of the vertices of\n\t\t\t   first object in each box in all dimension. */\n  double *tmin2,*tmax2; /* Smallest and larges value of the vertices of\n                           second object in each box in all dimension.*/\n  \n  /* Set local tolerance.  */\n  \n  teps2 = (ktype == 0) ? aepsge : (double)2.0*aepsge;\n  \n  /* Check if one object is a point. */\n  \n  if (po1->iobj == SISLPOINT) kdim1 = po1->p1->idim;\n  else if (po1->iobj == SISLCURVE) kdim1 = po1->c1->idim;\n  else if (po1->iobj == SISLSURFACE) kdim1 = po1->s1->idim;\n  \n  if (kdim1 == 1)\n  {\n     if (ktype != 0) teps2 = (double)3.0*aepsge;\n     teps1 = (ktype == 0) ? aepsge : aepsge+aepsge;\n     \n     if (po1->iobj == SISLPOINT || po2->iobj == SISLPOINT)\n\ttepsge += aepsge;\n  }\n  else\n  {\n     teps1 = DZERO;\n     if (po1->iobj == SISLPOINT || po2->iobj == SISLPOINT)\n\tkpttest = 1;\n  }\n\n\t       \n  /* Compute the box of the first object.  */ \n  \n  sh1992(po1,itype,tepsge,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* VSK. 06.93. Adjust microbox tolerance in bezier case. */\n \n  if (ktype != 0 && kstat == 1) kbez = 1;\n\n  /* Set pointers to box boundaries.  */\n  \n  if (po1->iobj == SISLPOINT)\n  {\n     tmin1 = po1->p1->pbox->e2min[ktype];\n     tmax1 = po1->p1->pbox->e2max[ktype];\n  }\n  else if (po1->iobj == SISLCURVE)\n  {\n     tmin1 = po1->c1->pbox->e2min[ktype];\n     tmax1 = po1->c1->pbox->e2max[ktype];\n  }       \n  else if (po1->iobj == SISLSURFACE)\n  {\n     tmin1 = po1->s1->pbox->e2min[ktype];\n     tmax1 = po1->s1->pbox->e2max[ktype];\n  }         \n  else goto err121;\n  \n  /* Make requested box.  */\n\t\t \n  sh1992(po2,itype,tepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  /* VSK. 06.93. Adjust microbox tolerance in bezier case. */\n\n  if (ktype != 0 && kstat == 1) kbez += 1;\n  if (kdim1 == 1 && kbez > 0) teps2 -= (double)2.0*aepsge;\n  else if (kbez > 0) teps2 -= aepsge;\n  if (kbez) teps1 = aepsge;\n\n  /* Set pointers to box boundaries.  */\n  \n  if (po2->iobj == SISLPOINT)\n  {\n     tmin2 = po2->p1->pbox->e2min[ktype];\n     tmax2 = po2->p1->pbox->e2max[ktype];\n     kdim2 = po2->p1->idim;\n  }  \n  else if (po2->iobj == SISLCURVE)\n  {\n     tmin2 = po2->c1->pbox->e2min[ktype];\n     tmax2 = po2->c1->pbox->e2max[ktype];\n     kdim2 = po2->c1->idim;\n  }       \n  else if (po2->iobj == SISLSURFACE)\n  {\n     tmin2 = po2->s1->pbox->e2min[ktype];\n     tmax2 = po2->s1->pbox->e2max[ktype];\n     kdim2 = po2->s1->idim;\n  }       \n  else goto err121;\n  \n  /* Check dimension. */\n  \n  if (kdim1 != kdim2 ) goto err106;\n  else\n    if (kdim1 < 1 )   goto err105;\n  \n  \n  /* Compute total number of SISLbox edges. */\n  \n  if (itype < 10 && kdim1 == 3) kant = 9;\n  else\n    if (itype < 10 && kdim1 == 2) kant = 4;\n    else           kant = kdim1;\n  \n  \n  /* For each dimension in all boxes perform box-test. First check\n     that we point on the right place in the min- and max-arrays.  */\t\n  \n  if (kpttest)\n  {\n     tmin1 += kant;\n     tmin2 += kant;\n     tmax1 += kant;\n     tmax2 += kant;\n  }\n  \n  for (ki=0; ki<kant; ki++,tmin1++,tmax1++,tmin2++,tmax2++)\n    {\n      /* Sorting: t1-t2 The SISLbox with largest max value.\n\t t3-t4 The other box. */\n      \n      if (*tmax1 > *tmax2)\n\t{\n\t  t1 = *tmax1;   t01 = *(tmax1 - kant*kpttest);\n\t  t2 = *tmin1;   t02 = *(tmin1 - kant*kpttest);\n\t  t3 = *tmax2;   t03 = *(tmax2 - kant*kpttest);\n\t  t4 = *tmin2;   t04 = *(tmin2 - kant*kpttest);\n\t}\n      else\n\t{\n\t  t1 = *tmax2;   t01 = *(tmax2 - kant*kpttest);\n\t  t2 = *tmin2;   t02 = *(tmin2 - kant*kpttest);\n\t  t3 = *tmax1;   t03 = *(tmax1 - kant*kpttest);\n\t  t4 = *tmin1;   t04 = *(tmin1 - kant*kpttest);\n\t}\n      tdist = t2 - t3;\n\n      /* Use non-expanded boxes when testing if minibox is possible. */\n      \n      if (t01 - min(t02,t04) <= teps2)\n\tkj++;                 /* Minibox is possible. */\n      else if (kdim1 == 1 && t01-t04 <= teps1 && t03-t02 <= teps1)\n\tkj++;                 /* Minibox is possible. */\n      else if (t3 < t2 && (tdist > teps2 || !kpttest))\n\t{\n\t  *jstat = 0;           /* No overlap. */\n\t  goto out;\n\t}\n      else if (t3 < t2)\n\t kshadow = 1;           /* Danger of shadow area.  */\n\n      /* UJK and ALA, 91-08: The tolerance is now\n\t incorporated in the box. \n\t else if (kdim1 != 1 && t3 - t2 < tepsge && t3 - t4 > teps2 &&\n\t t1 - t2 > teps2)\n\t {\n\t *jstat = 2;           Only edge touching possible. \n\t goto degenerate;\n\t }\n\t else if ( kdim1 == 1 && (t1 - t4 < tepsge || t3 - t2 < tepsge))\n\t {\n\t *jstat = 2;            Only edge touching possible. \n\t goto out;\n\t } */\n\t\n      /* else possible overlap. */\n    }\n  \n  if (kj == kant)\n    *jstat = 3;                   /* Minibox found. */\n  else if (kshadow)\n     *jstat = 5;                  /* Danger of shadow area.  */\n  else\n    *jstat = 1;                   /* Overlap.  */\n  \n  \n  /* Box-test performed. */\n  \n  /* degenerate: */\n  /* Test if one of the objects has collapsed. Use non-expanded box.  */\n  if (kdim1 != 1 && po1->iobj > SISLPOINT)\n    {\n      if (po1->iobj == SISLCURVE)\n\t{\n\t  tmin1 = po1->c1->pbox->e2min[ktype];\n\t  tmax1 = po1->c1->pbox->e2max[ktype];\n\t}\n      \n      else if (po1->iobj == SISLSURFACE)\n\t{\n\t  tmin1 = po1->s1->pbox->e2min[ktype];\n\t  tmax1 = po1->s1->pbox->e2max[ktype];\n\t}\n      \n      /* Make sure that we are correct place in the min- and max-arrays. */\n      \n      if (kpttest)\n      {\n\t tmin1 += kant;\n\t tmax1 += kant;\n      }\n      \n      for(ki=0;ki<kdim1;ki++,tmin1++,tmax1++)\n\tif (fabs(tmax1[0]-tmin1[0]) > tepsge) break;\n      \n      if (ki == kdim1+1)\n\t{\n\t  *jstat = 4;\n\t  goto out;\n\t}\n    }\n  \n  if (kdim1 != 1 && po2->iobj > SISLPOINT)\n    {\n      if (po2->iobj == SISLCURVE)\n\t{\n\t  tmin1 = po2->c1->pbox->e2min[ktype];\n\t  tmax1 = po2->c1->pbox->e2max[ktype];\n\t}\n      \n      else if (po2->iobj == SISLSURFACE)\n\t{\n\t  tmin1 = po2->s1->pbox->e2min[ktype];\n\t  tmax1 = po2->s1->pbox->e2max[ktype];\n\t}\n      \n      /* Make sure that we are correct place in the min- and max-arrays. */\n      \n      if (kpttest)\n      {\n\t tmin1 += kant;\n\t tmax1 += kant;\n      }\n      \n      for(ki=0;ki<kdim1;ki++,tmin1++,tmax1++)\n\tif (fabs(tmax1[0]-tmin1[0]) > tepsge) break;\n      \n      if (ki == kdim1+1)\n\t{\n\t  *jstat = 4;\n\t  goto out;\n\t}\n    }\n  goto out;\n  \n  /* Dimensions conflicting. */\n  \n err106: *jstat = -106;\n  s6err(\"sh1790\",*jstat,kpos);\n  goto out;\n  \n  /* Dimensions less than one. */\n  \n err105: *jstat = -105;\n  s6err(\"sh1790\",*jstat,kpos);\n  goto out;\n  \n  /* Kind of object does not exist. */\n  \n err121: *jstat = -121;\n  s6err(\"sh1790\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine. */\n  \n error:  *jstat = kstat;\n  s6err(\"sh1790\",*jstat,kpos);\n  goto out;\n  \n out:\treturn;\n}\n\n\n\n\n\n"
  },
  {
    "path": "src/sh1794.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define SH1794\n\n#include \"sislP.h\"\n\f\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic int sh1794_s9findedg(SISLSurf *ps1, SISLSurf *ps2, SISLIntpt **up,\n\t\t\t    int nmb_pt, SISLIntpt* pt1[4], SISLIntpt* pt2[4],\n\t\t\t    int sdir[4], SISLIntpt ** pt3, int *jstat);\n#else\nstatic int sh1794_s9findedg();\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh1794(SISLObject *po1, SISLObject *po2, SISLIntpt **up, int nmb_pt,\n\t    double aepsge, int *jstat)\n#else\n  void sh1794(po1, po2, up, nmb_pt, aepsge, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntpt **up;\n     int nmb_pt; \n     double aepsge; \n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Check if an intersection curve following a constant\n*              parameter direction between two specified intersection\n*              points represent a tangential intersection curve\n*              between two corners in the intersection problem\n*\n*\n*\n* INPUT      : po1    - First surface in intersection.\n*              po2    - Second surface in intersection\n*              pt1    - Intersection point in the start of the curve\n*              pt2    - Intersection point in the end of the curve\n*              idir   - Constant parameter direction (0 and 1 corresponds\n*\t       aepsge - Geometry resolution.\n*                                                                     \n*\n* OUTPUT     : jstat  - status messages  \n*                            = 2      : Entire surface withing tangential zone\n*                            = 1      : Tangential curve found\n*\t\t\t     = 0      : The curve is not tangential or\n*\t\t\t                do not end in corners\n*                            < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 2018-02\n*\n*********************************************************************\n*/                                     \n{\n  int kstat = 0;   /* Local status variable                        */\n  int ki, kj, kr, kh;  /* Counters                                     */\n  int kmax = 7;    /* Maximum number of iterations to find par. val.*/\n  int kdim;        /* Dimension of geometry space                  */ \n  SISLSurf *qs1;   /* Surface with constant parameter intersection */\n  SISLSurf *qs2;   /* The other surface                            */\n  int nsample;     /* Number of sampling points                    */\n  int kleft1=0, kleft2=0, kleft3=0, kleft4=0;  /* Indices in knot vector  */\n  double spar1[2], spar2[2];  /* Parameter value of point on intersection\n\t\t\t\t curve with respect to surface            */\n  double tstart, tend;  /* Endparameters of intersection curve in surface */\n  double tdel0, tdel, tdel2;   /* Step length                                  */\n  int kdir;        /* Parameter direction of constant parameter in surface */\n  int kd;          /* Parameter direction                          */\n  double scratch[60];  /* Storage for results of surface evaluation */\n  double *sder1, *sder2, *snorm1, *snorm2;  /* Pointers to position and \n\t\t\t\t\t       surface normals      */\n  double *cvder1, *cvder2;\n  double tang;    /* Angle between surface normals                  */\n  double sstart[2], send[2];  /* Parameter limits of surface        */\n  int kk, kn;     /* Order and number of coefficients of boundary \n\t\t     intersection curve                             */\n  double *st;     /* Knot vector along boundary intersection curve  */\n  double angtol = 2.0*ANGULAR_TOLERANCE;  /* Needs tuning           */\n  double sdist[2];  /* Specified distances between surfaces         */\n  double dtol = 0.1*aepsge;/* Tolerance in search for zone par. val.*/\n  double *zonepar = NULL;  /* Parameter values corresponding to distances */\n  double *samplepar = NULL;  /* Parameter values at samples         */\n  double *seg = NULL;   /* Segmentation parameters along intersection curve */\n  int nseg = 0;         /* Number of segmentation parameters        */\n  double ptol = 100*REL_PAR_RES;\n  double tpar;    /* Parameter value at the end of the zone         */\n  double tpar2;\n  double tprev;   /* Previous estimate for parameter value          */\n  double tdistprev, tdist0;  /* Distance at previous parameter value        */\n  double initdist;   /* Distance at initial parameter value        */\n  double tdum;    /* Estimate for distance at given parameter value */\n\n  double par1[2], par2[2], pos1[3], pos2[3];\n  double tstart2, tend2, dist2;\n  int sgn;\n  double tmin, tmax;  /* Allowed endparameters of tangential zone   */\n  double td1;         /* Distance between intersection points       */\n  int failure;\n  int idir;\n  int nmb_dir;\n  int sdir[4];\n  SISLIntpt* pt1[4];\n  SISLIntpt* pt2[4];\n  SISLIntpt* pt3 = NULL;\n  SISLCurve *qc = NULL;\n  SISLObject *qoc = NULL;\n  SISLIntdat *qintdat = NULL;\n  int nmbmain = 0;\n  double minfrac = 0.1;\n  double minfrac2 = 0.1;\n  double minfrac3 = 1.0; /*0.5;*/\n  double tp2;\n  double sp2[2];\n\n  sdist[0] = 1.2*aepsge;\n  sdist[1] = 2.0*aepsge;\n\n  /* Test input */\n  if (po1->iobj != SISLSURFACE || po2->iobj != SISLSURFACE)\n    nmb_dir = 0;  /* Not a surface-surface intersection */\n  else\n    {\n      /* Identify edge intersection curve */\n      nmb_dir = sh1794_s9findedg(po1->s1, po2->s1, up, nmb_pt, pt1, pt2,\n\t\t\t\t sdir, &pt3, &kstat);\n      if (kstat < 0) \n\tgoto error;\n    }\n\n  /* Initiate */\n  *jstat = 0;\n\n  for (kh=0; kh<nmb_dir; ++kh)\n    {\n      /* Test for corner configuration */\n      sh6isinside(po1, po2, pt1[kh], &kstat);\n      if (kstat < 0)\n\tgoto error;\n      if (kstat < 3)\n\tcontinue;\n      \n      sh6isinside(po1, po2, pt2[kh], &kstat);\n      if (kstat < 0)\n\tgoto error;\n      if (kstat < 3)\n\tcontinue;\n\n      idir = sdir[kh];\n      \n      /* Evaluate the intersection curve in a number of sampling points\n\t to check whether it is tangential */\n      qs1 = (idir <= 1) ? po1->s1 : po2->s1;\n      qs2 = (idir <= 1) ? po2->s1 : po1->s1;\n      kdim = qs1->idim;\n      if (kdim != 3)\n\tgoto err104;\n\n      /* Prepare for checking */\n      kdir = (idir <= 1) ? idir : idir-2;\n      kd = (idir <= 1) ? 1-idir : 3-kdir;\n      spar1[kdir] = pt1[kh]->epar[idir];\n      tstart = pt1[kh]->epar[kd];\n      tend =  pt2[kh]->epar[kd];\n      if (tstart > tend)\n\t{\n\t  tdum = tstart;\n\t  tstart = tend;\n\t  tend = tdum;\n\t}\n\n      sstart[0] = qs2->et1[qs2->ik1-1];\n      send[0] = qs2->et1[qs2->in1];\n      sstart[1] = qs2->et2[qs2->ik2-1];\n      send[1] = qs2->et2[qs2->in2];\n      spar2[0] = (idir <= 1) ? pt1[kh]->epar[2] : pt1[kh]->epar[0];\n      spar2[1] = (idir <= 1) ? pt1[kh]->epar[3] : pt1[kh]->epar[1];\n\n      if (kdir == 0)\n\t{\n\t  tstart2 = qs1->et1[qs1->ik1-1];\n\t  tend2 = qs1->et1[qs1->in1];\n\t}\n      else\n\t{\n\t  tstart2 = qs1->et2[qs1->ik2-1];\n\t  tend2 = qs1->et2[qs1->in2];\n\t}\n      sgn = (spar1[kdir]-tstart2 < tend2-spar1[kdir]) ? 1 : -1;\n\n      /* Set pointers to evaluation results */\n      sder1 = scratch;\n      snorm1 = sder1 + 18;\n      sder2 = snorm1 + 3;\n      snorm2 = sder2 + 18;\n      cvder1 = snorm2 + 3;\n      cvder2 = cvder1 + 9;\n\n      /* Compute number of sampling points */\n      kn = (kdir == 0) ? qs1->in2 : qs1->in1;\n      kk = (kdir == 0) ? qs1->ik2 : qs1->ik1;\n      st = (kdir == 0) ? qs1->et2 : qs1->et1;\n      if ((tend-tstart)/(st[kn] - st[kk-1]) < minfrac)\n\tcontinue;\n      s1219(st, kk, kn, &kleft1, tstart, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      s1219(st, kk, kn, &kleft2, tend, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      nsample = 3*(kleft2 - kleft1)*kk;\n      nsample = max(3*kk, min(nsample, 20*kk));\n      tdel = (tend - tstart)/(double)(nsample);\n\n      /* Initial check to avoid overemphasising tiny curves */\n      s1421(qs1, 0, pt1[kh]->epar+2*(idir>0), &kleft1, &kleft2, sder1,\n\t    snorm1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      s1421(qs1, 0, pt2[kh]->epar+2*(idir>0), &kleft1, &kleft2, sder2,\n\t    snorm2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      td1 = s6dist(sder1, sder2, kdim);\n      if (td1 < aepsge && (DNEQUAL(tstart,st[kk-1]) || DNEQUAL(tend,st[kn])))\n\tcontinue;\n\n      nsample = max(2, min(nsample, (int)(td1/aepsge)));\n\n      if (zonepar != NULL) freearray(zonepar);\n      zonepar = NULL;\n      if (samplepar != NULL) freearray(samplepar);\n      samplepar = NULL;\n      if (seg != NULL) freearray(seg);\n      seg = NULL;\n\n      zonepar = new0array(2*nsample, DOUBLE);\n      samplepar = newarray(nsample, DOUBLE);\n      seg = newarray(2+nsample, DOUBLE);\n      if (zonepar == NULL || samplepar == NULL || seg == NULL) \n\tgoto err101;\n\n      for (ki=0, spar1[1-kdir]=tstart+0.5*tdel; ki<nsample;\n\t   ++ki, spar1[1-kdir]+=tdel)\n\t{\n\t  spar1[kdir] = pt1[kh]->epar[idir];\n\t  tdel0 = 0.0;\n\t  \n\t  /* Start at the best intersection point */\n\t  if (kdir == 1)\n\t    s1437(qs1, spar1[1-kdir], &qc, &kstat);\n\t  else\n\t    s1436(qs1, spar1[1-kdir], &qc, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  s1772(qc, qs2, aepsge, tstart2, sstart, tend2, send, spar1[kdir],\n\t\tspar2, &tp2, sp2, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  if (kstat == 1)\n\t    {\n\t      tdel0 = fabs(tp2-spar1[kdir]);\n\t      spar1[kdir] = tp2;\n\t      spar2[0] =  sp2[0];\n\t      spar2[1] =  sp2[1];\n\t    }\n\n\t  /* /\\* Compute distance *\\/ */\n\t  /* s1221(qc, 0, tp2, &kleft1, pos1, &kstat); */\n\t  /* if (kstat < 0) goto error; */\n\t  /* s1424(qs2, 0, 0, sp2, &kleft3, &kleft4, pos2, &kstat); */\n\t  /* dist2 = s6dist(pos1, pos2, kdim); */\n\n\t  samplepar[ki] = spar1[1-kdir];\n\n\t  /* Test if the two surfaces intersect tangentially in the\n\t     current sampling point.\n\t     First evaluate the surface in which there is an intersection\n\t     curve along the boundary                                     */\n\t  s1421(qs1, 2, spar1, &kleft1, &kleft2, sder1, snorm1, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  /* Find the closest point in the other surface. */\n\t  s1775(qs2, sder1, kdim, aepsge, sstart, send, spar2, spar2, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  /* Evaluate the second surface. */\n\t  s1421(qs2, 2, spar2, &kleft3, &kleft4, sder2, snorm2, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  // Test if the current point is a touch point\n\t  tang = s6ang(snorm1, snorm2, kdim);\n\t  if (tang > angtol)\n\t    break;\n\n\t  /* Compute 0-2. derivative of corresponding curves in surfaces */\n\t  /* Surface with boundary intersection */\n\t  memmove(cvder1, sder1, kdim*sizeof(double));\n\t  memmove(cvder1+kdim, sder1+(1+kdir)*kdim, kdim*sizeof(double));\n\t  memmove(cvder1+2*kdim, sder1+(3+2*kdir)*kdim, kdim*sizeof(double));\n\n\t  /* The other surface */\n\t  s1291(cvder1, sder2, kdim, cvder2, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  /* Compute the parameter value where two curves have the\n\t     specified distances (approximation) */\n\t  tprev = 0.0;\n\t  initdist = s6dist(cvder1, cvder2, kdim);\n\t  tdum = s6dist(cvder1+2*kdim, cvder2+2*kdim, kdim);\n\n\t  for (kj=0; kj<2; ++kj)\n\t    {\n\t      tdistprev = HUGE;\n\t      if (tdum > REL_PAR_RES)\n\t\t{\n\t\t  tpar = 2*sdist[kj]/tdum;\n\t\t  tpar = sqrt(tpar);\n\t\t  if (tpar > tend2-tstart2)\n\t\t    tpar = tend2 - tstart2;\n\t\t}\n\t      else\n\t\ttpar = tend2 - tstart2;\n\n\t      /* Iterate to a better position */\n\t      /* Could also take the parameter value of the previous\n\t\t sample point as input  */\n\t      failure = 0;\n\t      for (kr=0; kr<kmax; ++kr)\n\t\t{\n\t\t  /* Check accuracy of current estimate */\n\t\t  par1[1-kdir] = spar1[1-kdir];\n\t\t  par1[kdir] = spar1[kdir] + sgn*tpar;\n\t\t  par2[0] = spar2[0];\n\t\t  par2[1] = spar2[1];\n\t\t  s1424(qs1, 0, 0, par1, &kleft1, &kleft2, pos1, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t  s1775(qs2, pos1, kdim, aepsge, sstart, send, par2, par2, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t  s1424(qs2, 0, 0, par2, &kleft3, &kleft4, pos2, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t  dist2 = s6dist(pos1, pos2, kdim);\n\t\t  /*printf(\"Dist: %7.13f, expected: %7.13f \\n\",dist2, sdist[kj]); */\n\t\t  if (fabs(dist2 - sdist[kj]) < dtol ||\n\t\t      dist2 < sdist[kj] && tpar >= tend2 - tstart2 - REL_PAR_RES)\n\t\t    {\n\t\t      tprev = tpar;\n\t\t      break;   /* The estimate for the tangential zone limit\n\t\t\t\t  is close enough                            */\n\t\t    }\n\t\t  if (DEQUAL(dist2, tdistprev) || dist2 < initdist)\n\t\t    {\n\t\t      failure = 1;\n\t\t      break;\n\t\t      /* /\\* The boundary curve may be an inexact representation of  */\n\t\t      /* \t the intersection curve. Start again the iteration from here *\\/ */\n\t\t      /* s1421(qs1, 2, par1, &kleft1, &kleft2, sder1, snorm1, &kstat); */\n\t\t      /* if (kstat < 0) */\n\t\t      /* \tgoto error; */\n\t\t      /* s1421(qs2, 2, par2, &kleft3, &kleft4, sder2, snorm2, &kstat); */\n\t\t      /* if (kstat < 0) */\n\t\t      /* \tgoto error; */\n\t\t      /* memmove(cvder1, sder1, kdim*sizeof(double)); */\n\t\t      /* memmove(cvder1+kdim, sder1+(1+kdir)*kdim, kdim*sizeof(double)); */\n\t\t      /* memmove(cvder1+2*kdim, sder1+(3+2*kdir)*kdim, kdim*sizeof(double)); */\n\t\t      /* s1291(cvder1, sder2, kdim, cvder2, &kstat); */\n\t\t      /* if (kstat < 0) */\n\t\t      /* \tgoto error; */\n\t\t      /* tdum = s6dist(cvder1+2*kdim, cvder2+2*kdim, kdim); */\n\t\t      /* if (tdum > REL_PAR_RES) */\n\t\t      /* \t{ */\n\t\t      /* \t  tpar = 2*sdist[kj]/tdum; */\n\t\t      /* \t  tpar = sqrt(tpar); */\n\t\t      /* \t  if (tpar > tend2-tstart2) */\n\t\t      /* \t    tpar = tend2 - tstart2; */\n\t\t      /* \t} */\n\t\t      /* else */\n\t\t      /* \ttpar = tend2 - tstart2; */\n\t\t      /* tpar = min(tend2 - tstart2, tpar + (par1[kdir]-spar1[kdir])); */\n\t\t      /* continue; */\n\t\t    }\n\t\t  if (fabs(dist2 - sdist[kj]) > fabs(tdistprev - sdist[kj]))\n\t\t    {\n\t\t      tpar = 0.5*(tprev+tpar);  // We are loosing accuracy\n\t\t      continue;\n\t\t    }\n\n\t\t  /* Find new position */\n\t\t  tdist0 = (kr == 0) ? initdist : tdistprev;\n\t\t  tdel2 = (sdist[kj]-dist2)*(tpar-tprev)/(dist2-tdist0);\n\t\t  tprev = tpar;\n\t\t  tdistprev = dist2;\n\t\t  tpar += tdel2;\n\t\t}\n\t      if (failure)\n\t\t{\n\t\t  if (spar1[1-kdir]-tstart < REL_PAR_RES ||\n\t\t      tend-spar1[1-kdir] < REL_PAR_RES)\n\t\t    {\n\t\t      tprev = spar1[kdir];\n\t\t      failure = 0;\n\t\t    }\n\t\t  else\n\t\t    break;\n\t\t}\n\t      zonepar[2*ki+kj] = tprev + tdel0;\n\t    }\n\n\t  if (failure)\n\t    break;\n\n\t  if (zonepar[2*ki] > zonepar[2*ki+1])\n\t    {\n\t      tdum = zonepar[2*ki];\n\t      zonepar[2*ki] = zonepar[2*ki+1];\n\t      zonepar[2*ki+1] = tdum;\n\t    }\n\t  if (qc) freeCurve(qc);\n\t  qc = SISL_NULL;\n\t}\n  \n      if (ki < nsample)\n\t{\n\t  /* Not a tangential intersection curve */\n\t  continue;\n\t}\n\n      /* When we have got here, there is a tangential curve. Check for\n\t a configuration with an additional point */\n      if ((pt3 != NULL && tend-tstart < minfrac3*(tend2-tstart2)) ||\n\t   (nmb_dir > 1 && tend-tstart < minfrac2*(tend2-tstart2)))\n\t{\n\t  /* Define candidate width of tangential zone */\n\t  tmin = zonepar[0];\n\t  tmax = zonepar[1];\n\t  for (ki=1; ki<nsample; ++ki)\n\t    {\n\t      tmin = max(tmin, zonepar[2*ki]);\n\t      tmax = min(tmax, zonepar[2*ki+1]);\n\t    }\n\t  tpar = spar1[kdir] + 0.5*sgn*(tmin + tmax);\n\n\t  /* Check with possible help points */\n\t  for (ki=0; ki<pt1[kh]->no_of_curves; ++ki)\n\t    {\n\t      if (sh6ishelp(pt1[kh]->pnext[ki]))\n\t\t{\n\t\t  sh6isinside(po1, po2, pt1[kh]->pnext[ki], &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t  if (kstat == 0)\n\t\t    continue;\n\t\t  if (fabs(pt1[kh]->pnext[ki]->epar[kdir]-spar1[kdir]) >\n\t\t      fabs(tpar - spar1[kdir]))\n\t\t    tpar = pt1[kh]->pnext[ki]->epar[kdir] + sgn*ptol;\n\t\t}\n\t    }\n\t  \n\t  for (ki=0; ki<pt2[kh]->no_of_curves; ++ki)\n\t    {\n\t      if (sh6ishelp(pt2[kh]->pnext[ki]))\n\t\t{\n\t\t  sh6isinside(po1, po2, pt2[kh]->pnext[ki], &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t  if (kstat == 0)\n\t\t    continue;\n\t\t  if (fabs(pt2[kh]->pnext[ki]->epar[kdir]-spar1[kdir]) >\n\t\t      fabs(tpar - spar1[kdir]))\n\t\t    tpar = pt2[kh]->pnext[ki]->epar[kdir] + sgn*ptol;\n\t\t}\n\t    }\n\n\t  if (pt3 != NULL)\n\t    tpar2 = pt3->epar[kdir];\n\t  else\n\t    tpar2 = (fabs(spar1[kdir]-tstart2) < fabs(tend2-spar1[kdir])) ?\n\t\t     tend2 : tstart2;\n\t  if (fabs(tpar2 - spar1[kdir]) > fabs(tpar - spar1[kdir]))\n\t    {\n\t      /* Check for intersections along the possible tangenial\n\t\t belt limit */\n\t      if (kdir == 0)\n\t\ts1437(qs1, tpar, &qc, &kstat);\n\t      else\n\t\ts1436(qs1, tpar, &qc, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      /* Intersect with the other surface and count intersections */\n\t      if ((qoc = newObject(SISLCURVE)) == NULL)\n\t\tgoto err101;\n\t      qoc->c1 = qc;\n\n\t      sh1761((idir <= 1) ? po2 : po1, qoc, aepsge, &qintdat, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      /* One main point is expected. Check. */\n\t      nmbmain = 0;\n\t      if (qintdat != NULL)\n\t\t{\n\t\t  for (ki=0; ki<qintdat->ipoint; ++ki)\n\t\t    if (sh6ismain(qintdat->vpoint[ki]))\n\t\t      nmbmain++;\n\t\t}\n\n\t      if (qoc != NULL)\n\t\t{\n\t\t  freeObject(qoc);\n\t\t  qc = NULL;\n\t\t}\n\t      qoc = NULL;\n\t      if (qc != NULL)\n\t\tfreeCurve(qc);\n\t      qc = NULL;\n\t      if (qintdat != NULL)\n\t\tfreeIntdat(qintdat);\n\t      qintdat = NULL;\n\t      \n\t      if (nmbmain == 1)\n\t\t{\n\t\t  /* Define tangential belt */\n\t\t  po1->psimple = po2;\n\t\t  seg[nseg++] = tpar;\n\t\t  sh6setseg(qs1, kdir, seg, nseg,\n\t\t\t    (sgn == 1) ? TANGENTIAL_BELT_LEFT :\n\t\t\t    TANGENTIAL_BELT_RIGHT, &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\n\t\t  *jstat = 1;\n\t\t  goto out;\n\t\t}\n\t    }\n\t}\n\n      /* Identify non-overlapping pairs of tangential zone end parameters */\n      /* Check also whether the tangential intersection curve follows the\n\t entire surface boundary  */\n      if (tstart > st[kk-1] + ptol)\n\tseg[nseg++] = tstart;\n\n      for (ki=0; ki<nsample; ki=kj)\n\t{\n\t  if (DEQUAL(zonepar[2*ki], zonepar[2*ki+1]))\n\t    printf(\"Zone equality \\n\");\n\t  for (kj=ki+1; kj<nsample; ++kj)\n\t    {\n\t      if (zonepar[2*ki] > zonepar[2*kj+1]+ptol ||\n\t\t  zonepar[2*ki+1] < zonepar[2*kj]-ptol)\n\t\t{\n\t\t  /* No overlap. Define segmentation parameter */\n\t\t  /* First look for a suitable knot value */\n\t\t  s1219(st, kk, kn, &kleft1, samplepar[ki], &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t  s1219(st, kk, kn, &kleft2, samplepar[kj], &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t  if (samplepar[kj] > st[kleft2]+ptol && kleft2 > kleft1)\n\t\t    {\n\t\t      seg[nseg++] = st[kleft2];\n\t\t      for (kr=kj-1; kr>ki && samplepar[kr]>st[kleft2]; --kr);\n\t\t      kj = max(kr+1, ki+1);\n\t\t    }\n\t\t  else if (kj > ki+1)\n\t\t    {\n\t\t      seg[nseg++] = samplepar[kj-1];\n\t\t      --kj;\n\t\t    }\n\t\t  else\n\t\t    seg[nseg++] = 0.5*(samplepar[ki]+samplepar[kj]);\n\n\t\t  break;\n\t\t}\n\t    }\n\t}\n\n      if (tend < st[kn] - ptol)\n\tseg[nseg++] = tend;\n  \n      if (nseg > 0)\n\t{\n\t  /* Define segmentation parameters along the tangential \n\t     intersection curve   */\n\t  po1->psimple = po2;\n\t  sh6setseg(qs1, 1-kdir, seg, nseg, LIMITING_SEG, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n      else\n\t{\n\t  /* Set width of tangential zone */\n\t  tmin = zonepar[0];\n\t  tmax = zonepar[1];\n\t  for (ki=1; ki<nsample; ++ki)\n\t    {\n\t      tmin = max(tmin, zonepar[2*ki]);\n\t      tmax = min(tmax, zonepar[2*ki+1]);\n\t    }\n\t  tpar = pt1[kh]->epar[idir] + sgn*max(0.5*(tmin + tmax),tmin);\n\n\t  if (tpar < tstart2 || tpar > tend2)\n\t    {\n\t      /* The entire surface is within the tangential intersectin\n\t\t zone. Set output status */\n\t      *jstat = 2;\n\t      goto out;\n\t    }\n\n\t  /* Define segmentation parameter perpendicular to the tangential\n\t     intersection curve */\n\t  po1->psimple = po2;\n\t  seg[nseg++] = tpar;\n\t  sh6setseg(qs1, kdir, seg, nseg, (sgn == 1) ? TANGENTIAL_BELT_LEFT :\n\t\t    TANGENTIAL_BELT_RIGHT, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n      *jstat = 1;\n      break;  /* If we got here a tangential curve is found and handled */\n    }\n  \n  goto out;\n\nerror:\n  /* Error in lower order function */\n  *jstat = kstat;\n  goto out;\n\n err101:\n  /* Error in scratch allocation */\n  *jstat = -101;\n  goto out;\n\n err104:\n  /* Dimension of geometry space not equal to 3 */\n  *jstat = -104;\n  goto out;\n\n out:\n  if (zonepar != NULL) freearray(zonepar);\n  if (samplepar != NULL) freearray(samplepar);\n  if (seg != NULL) freearray(seg);\n  if (qoc != NULL) \n    {\n      freeObject(qoc);\n      qc = NULL;\n    }\n  if (qc != NULL) freeCurve(qc);\n  if (qintdat != NULL) freeIntdat(qintdat);\n  return;\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic int sh1794_s9findedg(SISLSurf *ps1, SISLSurf *ps2, SISLIntpt **up,\n\t\t\t    int nmb_pt, SISLIntpt* pt1[4], SISLIntpt* pt2[4],\n\t\t\t    int sdir[4], SISLIntpt** pt3, int *jstat)\n#else\nstatic int sh1794_s9findedg(ps1, ps2, up, nmb_pt, pt1, pt2,\n\t\t\t    sdir, pt3, jstat)\nSISLSurf *ps1; \nSISLSurf *ps2; \nSISLIntpt **up;\nint nmb_pt; \nSISLIntpt* pt1[4]; \nSISLIntpt* pt2[4];\nint sdir[4];\nSISLIntpt **pt3;\nint *jstat;\n#endif\n\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Check if a chain of linked intersection points\n*              contain an intersection curve along some surface edge\n*              and select the most signicant candidate\n*\n*\n*\n* INPUT      : ps1    - First surface in intersection.\n*              ps2    - Second surface in intersection\n*              up     - Intersection points\n*\t       nmb_pt - Number of intersection points\n*                                                                     \n*\n* OUTPUT     : return value - Number of parameter directions with detected \n*                             edge (both sfs)\n*              pt1    - Intersection points in the start of the curve\n*              pt2    - Intersection points in the end of the curve\n*              sdir   - Detected directions\n*              pt3    - Possible intersection point not coupled to \n*                       other points\n*              jstat  - status messages \n*                            = 1      : Probably degenerate situation. Do not searh\n*                                       for tangential intersection \n*\t\t\t     = 0      : OK\n*                            < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 2018-02\n*\n*********************************************************************\n*/                                     \n{\n  int kstat = 0;  /* Local status variable                             */\n  int kdir;  /* Parameter direction of possible tangential intersection curve */\n  int kdir2;\n  int ix[8];      /* Maximum possible end parameters of constant chain */\n  int ki, kj;     /* Counters                                          */\n  int kidx = 0;   /* Current parameter direction                       */\n  int klist1=0, klist2=0;\n  double parlen;  /* Distance between intersection points in\n\t\t     parameter domain along constant direction */\n  int pd;               /* Parameter direction                      */\n  double del;        /* Edge length of surface in parameter domain */\n  int kfirst = 0, klast = nmb_pt;\n  double sfac[4];\n  int kdum;\n  double tdum;\n  SISLIntpt *qdum;\n\n  sdir[0] = sdir[1] = sdir[2] = sdir[3] = -1;\n  sfac[0] = sfac[1] = sfac[2] = sfac[3] = 0.0;\n  *pt3 = NULL;\n\n  if (nmb_pt < 2)\n    return 0;\n\n  /* One loose point is allowed. It is either first or last */\n  sh6getlist(up[0], up[1], &klist1, &klist2, &kstat);\n  if (kstat == 1)\n    kfirst = 1;\n  sh6getlist(up[nmb_pt-2], up[nmb_pt-1], &klist1, &klist2, &kstat);\n  if (kstat == 1)\n    klast = nmb_pt-1;\n  \n  if (klast - kfirst < nmb_pt - 1)\n    return 0;  /* More than one loose point */\n  if (kfirst > 0)\n    *pt3 = up[0];\n  else if (klast < nmb_pt)\n    *pt3 = up[klast];\n  \n  ix[2*kidx] = 0;\n  for (kj=kfirst; kj<klast; kj=max(kj+1,ki-1))\n    {\n      kdir = -1;\n      for (ki=kj+1; ki<nmb_pt; ++ki)\n\t{\n\t  sh6getlist(up[ki-1], up[ki], &klist1, &klist2, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  if (kstat == 1)\n\t    continue;\n\t\t       \n\t  for (kdir2=0; kdir2<up[ki-1]->ipar; ++kdir2)\n\t    {\n\t      if (up[ki-1]->curve_dir[klist1] & (1 << (kdir2+1)))\n\t\tbreak;\n\t    }\n\t  ix[2*kidx] = kj;\n\t  if (kdir2 == up[ki-1]->ipar)\n\t    {\n\t      if (kdir >= 0)\n\t\t{\n\t\t  sdir[kidx] = kdir;\n\t\t  ix[2*kidx+1] = ki-1;\n\t\t  kidx++;\n\t\t  kdir = 0;\n\t\t}\n\t      kdir2 = -1;\n\t      break;\n\t    }\n\t  else if (kdir >= 0 && kdir2 != kdir)\n\t    {\n\t      sdir[kidx] = kdir;\n\t      ix[2*kidx+1] = ki;\n\t      kidx++;\n\t      kdir = kdir2;\n\t      break;\n\t    }\n\t  else\n\t    {\n\t      kdir = kdir2;\n\t    }\n\t}\n      if (kidx > 3)\n\tgoto warn1;\n    }\n  if (kdir2 >= 0 && (kidx == 0 || kdir2 != sdir[kidx-1]))\n    {\n      sdir[kidx] = kdir2;\n      ix[2*kidx+1] = ki;\n      kidx++;\n    }\n      \n  for (ki=0; ki<kidx; ++ki)\n    {\n      /* Compute significance */\n      kdir = sdir[ki];\n      pd = (kdir <= 1) ? 1 - kdir : 5 - kdir;\n      parlen = fabs(up[ix[2*ki+1]-1]->epar[pd]-up[ix[2*ki]]->epar[pd]);\n      if (kdir <= 0)\n\tdel = (pd == 0) ? ps1->et1[ps1->in1] - ps1->et1[ps1->ik1-1] :\n\t  ps1->et2[ps1->in2] - ps1->et2[ps1->ik2-1];\n      else\n\tdel = (pd == 0) ? ps2->et1[ps2->in1] - ps2->et1[ps2->ik1-1] :\n\t  ps2->et2[ps2->in2] - ps2->et2[ps2->ik2-1];\n      sfac[ki] = parlen/del;\n      pt1[ki] = up[ix[2*ki]];\n      pt2[ki] = up[ix[2*ki+1]-1];\n    }\n\n  /* Sort with respect to length factor */\n  for (ki=0; ki<kidx; ++ki)\n    for (kj=ki+1; kj<kidx; ++kj)\n      {\n\tif (sfac[kj] > sfac[ki])\n\t  {\n\t    kdum = sdir[ki];\n\t    sdir[ki] = sdir[kj];\n\t    sdir[kj] = kdum;\n\t    tdum = sfac[ki];\n\t    sfac[ki] = sfac[kj];\n\t    sfac[kj] = tdum;\n\t    qdum = pt1[ki];\n\t    pt1[ki] = pt1[kj];\n\t    pt1[kj] = qdum;\n\t    qdum = pt2[ki];\n\t    pt2[ki] = pt2[kj];\n\t    pt2[kj] = qdum;\n\t  }\n      }\n      \n\n  *jstat = 0;\n  goto out;\n\n warn1:\n  *jstat = 1;\n  kidx = 0;\n  goto out;\n  \n error:\n  *jstat = kstat;\n  goto out;\n\n out:\n  return kidx;\n}\n\n"
  },
  {
    "path": "src/sh1795.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define SH1795\n\n#include \"sislP.h\"\n\f\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic int sh1795_s9iterate(SISLSurf *ps1, SISLSurf *ps2, double aepsge,\n\t\t\t    double eps, int dir, int sgn, \n\t\t\t    double epar1[2], double epar2[2],\n\t\t\t    double initdist, double der2dist, double lim1,\n\t\t\t    double lim2, double *zonepar, int *jstat);\n#else\n  static int sh1795_s9iterate();\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh1795(SISLObject *po1, SISLObject *po2, SISLIntpt *pt,\n\t    double aepsge, int *jstat)\n#else\n  void sh1795(po1, po2, pt, aepsge, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntpt *pt;\n     double aepsge; \n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Check if a singular intersection point in a corner is \n*              isolated. In that case, define segmentation parameters \n*              bounding the singularity.\n*\n*\n*\n* INPUT      : po1    - First surface in intersection.\n*              po2    - Second surface in intersection\n*              pt     - Intersection point\n*\t       aepsge - Geometry resolution.\n*                                                                     \n*\n* OUTPUT     : jstat  - status messages  \n*                            = 2      : Entire surface withing tangential zone\n*                            = 1      : Tangential zone found\n*\t\t\t     = 0      : Not an isolated singularity or tangential\n*                                       not found\n*                            < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 2023-03\n*\n*********************************************************************\n*/                                     \n{\n  int kstat = 0;   /* Local status variable                        */\n  int kdim;\n  int ki, kj, kr;\n  double sdist[2];  /* Specified distances between surfaces         */\n  double zonepar[12];  /* Parameter values corresponding to distances */\n  double samplepar[6];  /* Parameter values at samples         */\n  double tsize1, tsize2;\n  int iobj;\n  double *st1 = po1->s1->et1;\n  double *st2 = po1->s1->et2;\n  double *st3 = po2->s1->et1;\n  double *st4 = po2->s1->et2;\n  int kn1 = po1->s1->in1;\n  int kn2 = po1->s1->in2;\n  int kn3 = po2->s1->in1;\n  int kn4 = po2->s1->in2;\n  int kk1 = po1->s1->ik1;\n  int kk2 = po1->s1->ik2;\n  int kk3 = po2->s1->ik1;\n  int kk4 = po2->s1->ik2;\n  SISLSurf *qs1;   /* Surface with singular corner intersection */\n  SISLSurf *qs2;   /* The other surface                            */\n  double tlim1[2], tlim2[2];\n  int kleft1=0, kleft2=0, kleft3=0, kleft4=0;  /* Indices in knot vector  */\n  double spar1[2], spar2[2];  /* Parameter value of point on intersection */\n  double scratch[69];  /* Storage for results of surface evaluation */\n  double *sder1, *sder2, *snorm1, *snorm2;  /* Pointers to position and \n\t\t\t\t\t       surface normals      */\n  double *cvder1, *cvder2;\n  double tang;    /* Angle between surface normals                  */\n  int sgn[2];\n  int converged = 0;\n  double initdist;\n  double tdum;\n  double sstart[2], send[2];\n  double ptol = 100*REL_PAR_RES;\n  double tmin, tmax;\n  double tpar;\n  SISLCurve *qc = SISL_NULL;\n  SISLObject *qoc = SISL_NULL;\n  SISLIntdat *qintdat = SISL_NULL;\n  double seg[2];\n \n  sdist[0] = 1.2*aepsge;\n  sdist[1] = 2.0*aepsge;\n\n  /* Test configuration */\n  if (po1->s1->idim != 3)\n    goto err104;\n  kdim = po1->s1->idim;\n  \n  sh6isinside(po1, po2, pt, &kstat);\n  if (kstat < 0)\n    goto error;\n  if (kstat != 3 && kstat != 4)\n    goto out;   /* Not a corner */\n\n  /* Set pointers to evaluation results */\n  sder1 = scratch;\n  snorm1 = sder1 + 18;\n  sder2 = snorm1 + 3;\n  snorm2 = sder2 + 18;\n  cvder1 = snorm2 + 3;\n  cvder2 = cvder1 + 9;\n\n  /* Identify corner and governing surface */\n  tsize1 = (st1[kn1]-st1[kk1-1])*(st2[kn2]-st2[kk2-1]);\n  tsize2 = (st3[kn3]-st3[kk3-1])*(st4[kn4]-st4[kk4-1]);\n  iobj = (tsize1 >= tsize2) ? 0 : 1;\n  if (iobj == 0 &&\n      (!(DEQUAL(pt->epar[0],st1[kk1-1]) || DEQUAL(pt->epar[0],st1[kn1]))) &&\n      (!(DEQUAL(pt->epar[1],st2[kk2-1]) || DEQUAL(pt->epar[1],st2[kn2]))))\n    iobj = 1;\n  if (iobj == 1 &&\n      (!(DEQUAL(pt->epar[2],st3[kk3-1]) || DEQUAL(pt->epar[2],st3[kn3]))) &&\n      (!(DEQUAL(pt->epar[3],st4[kk4-1]) || DEQUAL(pt->epar[3],st4[kn4]))))\n    iobj = 0;\n  qs1 = (iobj == 0) ? po1->s1 : po2->s1;\n  qs2 = (iobj == 0) ? po2->s1 : po1->s1;\n  samplepar[0] = pt->epar[2*iobj];\n  samplepar[3] = pt->epar[2*iobj+1];\n  tlim1[0] = qs1->et2[qs1->ik2-1];\n  tlim2[0] = qs1->et2[qs1->in2];\n  tlim1[1] = qs1->et1[qs1->ik1-1];\n  tlim2[1] = qs1->et1[qs1->in1];\n  sgn[0] = (DEQUAL(samplepar[0], qs1->et1[qs1->ik1-1])) ? 1 : -1;\n  sgn[1] = (DEQUAL(samplepar[3], qs1->et2[qs1->ik2-1])) ? 1 : -1;\n  spar1[0] = pt->epar[2*iobj];\n  spar1[1] = pt->epar[2*iobj+1];\n  spar2[0] = pt->epar[2*(1-iobj)];\n  spar2[1] = pt->epar[2*(1-iobj)+1];\n  sstart[0] = qs2->et1[qs2->ik1-1];\n  sstart[1] = qs2->et2[qs2->ik2-1];\n  send[0] = qs2->et1[qs2->in1];\n  send[1] = qs2->et2[qs2->in2];\n\n \n  s1421(qs1, 2, spar1, &kleft1, &kleft2, sder1, snorm1, &kstat);\n  if (kstat < 0)\n    goto error;\n  s1421(qs2, 2, spar2, &kleft3, &kleft4, sder2, snorm2, &kstat);\n  if (kstat < 0)\n    goto error;\n  tang = s6ang(snorm1, snorm2, 3);\n  if (tang > ANGULAR_TOLERANCE && M_PI-tang > ANGULAR_TOLERANCE)\n    goto out; /* Not a singularity */\n\n  /* Corner */\n  for (ki=0; ki<2; ++ki)\n    {\n      memmove(cvder1, sder1, kdim*sizeof(double));\n      memmove(cvder1+kdim, sder1+(2-ki)*kdim, kdim*sizeof(double));\n      memmove(cvder1+2*kdim, sder1+(5-2*ki)*kdim, kdim*sizeof(double));\n      s1291(cvder1, sder2, kdim, cvder2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      \n      /* Compute the parameter value where two curves have the\n\t specified distances (approximation) */\n      initdist = s6dist(cvder1, cvder2, kdim);\n      tdum = s6dist(cvder1+2*kdim, cvder2+2*kdim, kdim);\n\n      for (kj=0; kj<2; ++kj)\n\t{\n\t  converged = sh1795_s9iterate(qs1, qs2, aepsge, sdist[kj], 1-ki, sgn[1-ki],\n\t\t\t\t       spar1, spar2, initdist, \n\t\t\t\t       tdum, tlim1[1-ki], tlim2[1-ki],\n\t\t\t\t       zonepar+6*ki+kj, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  if (!converged)\n\t    goto out;\n\t}\n\n    }\n\n  /* Additional samples */\n  samplepar[2] = samplepar[0] + 0.9*sgn[0]*zonepar[6];\n  samplepar[1] = 0.5*(samplepar[0] + samplepar[2]);\n  samplepar[5] = samplepar[3] + 0.9*sgn[1]*zonepar[0];\n  samplepar[4] = 0.5*(samplepar[3] + samplepar[5]);\n  for (ki=0; ki<2; ++ki)\n    {\n      spar1[1-ki] = pt->epar[2*iobj+1-ki];\n      spar2[0] = pt->epar[2*(1-iobj)];\n      spar2[1] = pt->epar[2*(1-iobj)+1];\n      for (kr=1; kr<=2; ++kr)\n\t{\n\t  spar1[ki] = samplepar[3*ki+kr];\n\n\t  /* Evaluate first surface in the start point of the search */\n\t  s1421(qs1, 2, spar1, &kleft1, &kleft2, sder1, snorm1, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  \n\t  /* Find the closest point in the other surface. */\n\t  s1775(qs2, sder1, kdim, aepsge, sstart, send, spar2, spar2, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  /* Evaluate the second surface. */\n\t  s1421(qs2, 2, spar2, &kleft3, &kleft4, sder2, snorm2, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  /* Compute 0-2. derivative of corresponding curves in surfaces */\n\t  /* Surface with boundary intersection */\n\t  memmove(cvder1, sder1, kdim*sizeof(double));\n\t  memmove(cvder1+kdim, sder1+(2-ki)*kdim, kdim*sizeof(double));\n\t  memmove(cvder1+2*kdim, sder1+(5-2*ki)*kdim, kdim*sizeof(double));\n\n\t  /* The other surface */\n\t  s1291(cvder1, sder2, kdim, cvder2, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\n\t  /* Compute the parameter value where two curves have the\n\t     specified distances (approximation) */\n\t  initdist = s6dist(cvder1, cvder2, kdim);\n\t  tdum = s6dist(cvder1+2*kdim, cvder2+2*kdim, kdim);\n\n\t  for (kj=0; kj<2; ++kj)\n\t    {\n\t      if (initdist > sdist[kj])\n\t\tzonepar[6*ki+2*kr+kj] = 0.0;\n\t      else\n\t\tconverged = sh1795_s9iterate(qs1, qs2, aepsge, sdist[kj],\n\t\t\t\t\t     1-ki, sgn[1-ki],\n\t\t\t\t\t     spar1, spar2, initdist, \n\t\t\t\t\t     tdum, tlim1[1-ki], tlim2[1-ki],\n\t\t\t\t\t     zonepar+6*ki+2*kr+kj, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t      if (!converged)\n\t\tgoto out;\n\t    }\n\t}\n    }\n\n  for (ki=0; ki<2; ++ki)\n    {\n      /* Define test curve */\n      tmin = zonepar[6*ki];\n      tmax = zonepar[6*ki+1];\n      for (kr=1; kr<3; ++kr)\n\t{\n\t  tmax = min(tmax, zonepar[6*ki+2*kr+1]);\n\t  tmin = max(tmin, zonepar[6*ki+2*kr]);\n\t}\n      tpar = pt->epar[2*iobj+1-ki] + sgn[1-ki]*max(0.5*(tmin+tmax),zonepar[6*ki]);\n      \n      /* Check with possible help points */\n      for (kj=0; kj<pt->no_of_curves; ++kj)\n\t{\n\t  if (sh6ishelp(pt->pnext[kj]))\n\t    {\n\t      sh6isinside(po1, po2, pt->pnext[kj], &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t      if (kstat == 0)\n\t\tcontinue;\n\t      if (fabs(pt->pnext[kj]->epar[2*iobj+1-ki]-pt->epar[2*iobj+1-ki]) >\n\t\t  fabs(tpar - pt->epar[2*iobj+1-ki]))\n\t\ttpar = pt->pnext[kj]->epar[2*iobj+1-ki] + sgn[1-ki]*ptol;\n\t    }\n\t}\n\t  \n      /* Check for intersections along limiting curve */\n      if (ki == 1)\n\ts1437(qs1, tpar, &qc, &kstat);\n      else\n\ts1436(qs1, tpar, &qc, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /* Intersect with the other surface and count intersections */\n      if ((qoc = newObject(SISLCURVE)) == SISL_NULL)\n\tgoto err101;\n      qoc->c1 = qc;\n\n      sh1761((iobj == 0) ? po2 : po1, qoc, aepsge, &qintdat, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      if (qintdat)\n\tgoto out;  /* Not an isolated singularity */\n      seg[ki] = tpar;\n      if (qoc != SISL_NULL) \n\t{\n\t  freeObject(qoc);\n\t  qoc = SISL_NULL;\n\t  qc = SISL_NULL;\n\t}\n    }\n\n  /* Define segmentation parameters */\n  po1->psimple = po2;\n  for (ki=0; ki<2; ++ki)\n    {\n      sh6setseg(qs1, 1-ki, seg+ki, 1, (sgn[1-ki] == 1) ? TANGENTIAL_BELT_LEFT :\n\t\tTANGENTIAL_BELT_RIGHT, &kstat);\n      if (kstat < 0)\n\tgoto error;\n   }\n\n  goto out;\n\nerror:\n  /* Error in lower order function */\n  *jstat = kstat;\n  goto out;\n\n err101:\n  /* Error in scratch allocation */\n  *jstat = -101;\n  goto out;\n\n err104:\n  /* Dimension of geometry space not equal to 3 */\n  *jstat = -104;\n  goto out;\n\n out:\n  if (qoc != SISL_NULL) \n    {\n      freeObject(qoc);\n      qc = SISL_NULL;\n    }\n  if (qc != SISL_NULL) freeCurve(qc);\n  if (qintdat != SISL_NULL) freeIntdat(qintdat);\n  return;\n}\n\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic int sh1795_s9iterate(SISLSurf *ps1, SISLSurf *ps2, double aepsge,\n\t\t\t    double eps, int dir, int sgn, \n\t\t\t    double epar1[2], double epar2[2],\n\t\t\t    double initdist, double der2dist, double lim1,\n\t\t\t    double lim2, double *zonepar, int *jstat)\n#else\n  static int sh1795_s9iterate(ps1, ps2, aepsge, eps, dir, sgn, epar1,\n\t\t\t      epar2, initdist, der2dist, lim1, lim2,\n\t\t\t      zonepar, jstat)\n     SISLSurf *ps1; \n     SISLSurf *ps2; \ndouble aepsge;\ndouble eps;\nint dir;\nint sgn; \ndouble epar1[2];\ndouble epar2[2];\ndouble initdist;\ndouble der2dist;\ndouble lim1;\ndouble lim2;\ndouble *zonepar;\nint *jstat;\n#endif\n\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : \n*\n*\n*\n* INPUT      : ps1    - First surface in intersection.\n*              ps2    - Second surface in intersection\n*              \n*                                                                     \n*\n* OUTPUT     : \n*              jstat  - status messages  \n*\t\t\t     = 0      : OK\n*                            < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 2023-03\n*\n*********************************************************************\n*/                                     \n{\n  int kstat = 0;\n  int kdim = ps1->idim;\n  int kmax = 7;    /* Maximum number of iterations to find par. val.*/\n  double tprev = 0.0;\n  double tdistprev = HUGE;\n  double dist;\n  double tdel;\n  int kr;\n  double par1[2], par2[2], pos1[3], pos2[3];\n  int kleft1 = 0, kleft2 = 0, kleft3 = 0, kleft4 = 0;\n  double sstart[2], send[2];\n  double dtol = 0.1*aepsge;/* Tolerance in search for zone par. val.*/\n  double tdist0;\n  double tdel2;\n  int converge = 0;\n\n  sstart[0] = ps2->et1[ps2->ik1-1];\n  sstart[1] = ps2->et2[ps2->ik2-1];\n  send[0] = ps2->et1[ps2->in1];\n  send[1] = ps2->et2[ps2->in2];\n\n  if (der2dist > REL_PAR_RES)\n    {\n      tdel = 2*eps/der2dist;\n      tdel = sqrt(tdel);\n      if (tdel > lim2 -lim1)\n\ttdel = lim2 - lim1;\n    }\n  else\n    tdel = lim2 - lim1;\n  \n  /* Iterate to a better position */\n  for (kr=0; kr<kmax; ++kr)\n    {\n      /* Check accuracy of current estimate */\n      par1[1-dir] = epar1[1-dir];\n      par1[dir] = epar1[dir] + sgn*tdel;\n      par2[0] = epar2[0];\n      par2[1] = epar2[1];\n      s1424(ps1, 0, 0, par1, &kleft1, &kleft2, pos1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      s1775(ps2, pos1, kdim, aepsge, sstart, send, par2, par2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      s1424(ps2, 0, 0, par2, &kleft3, &kleft4, pos2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      dist = s6dist(pos1, pos2, kdim);\n      if (fabs(dist - eps) < dtol ||\n\t  (dist < eps && tdel >= lim2 - lim1 - REL_PAR_RES))\n\t{\n\t  tprev = tdel;\n\t  break;   /* The estimate for the tangential zone limit\n\t\t      is close enough                            */\n\t}\n\n      if (fabs(dist - eps) > fabs(tdistprev - eps))\n\t{\n\t  tdel = 0.5*(tprev+tdel);  // We are loosing accuracy\n\t  continue;\n\t}\n      \n      /* Find new position */\n      tdist0 = (kr == 0) ? initdist : tdistprev;\n      tdel2 = (eps-dist)*(tdel-tprev)/(dist-tdist0);\n      if (DEQUAL(tdel2, 0.0))\n\tbreak;\n      tprev = tdel;\n      tdistprev = dist;\n      tdel += tdel2;\n    }\n  \n  if (fabs(dist - eps) < dtol ||\n      (dist < eps && tdel >= lim2 - lim1 - REL_PAR_RES))\n    {\n      *zonepar = tprev;\n      converge = 1;\n    }\n  else\n      converge = 0;\n\n  goto out;\n\nerror:\n  /* Error in lower order function */\n  *jstat = kstat;\n  goto out;\n\n out:\n  return converge;\n}\n"
  },
  {
    "path": "src/sh1830.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1830.c,v 1.2 2001-03-19 15:59:05 afr Exp $\n *\n */\n\n\n#define SH1830\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n  sh1830(SISLObject *po1,SISLObject *po2,double aepsge,int *jstat)\n#else\nvoid sh1830(po1,po2,aepsge,jstat)\n     SISLObject  *po1;\n     SISLObject  *po2;\n     double aepsge;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Perform improved box-test in curve/surface intersection.\n*              The test is based on the main tangent of the curve and\n*              the main normal of the surface.\n*\n*\n*\n* INPUT      : po1    - Pointer to object involved in intersection problem.\n*              po2    - Pointer to object involved in intersection problem.\n*\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                              = 2      : Only edge-intersections possible.\n*                              = 1      : Possibility of intersection.\n*                              = 0      : No possibility of intersection.\n*                              < 0      : error\n*\n*\n* METHOD     : Let the main tangent of the curve be the vector from the\n*              first to the last vertex, and let the main normal of the\n*              surface be the cross-product of the main diagonals. Perform\n*              rotated box-tests with respect to this two vectors.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1834  - Perform rotated box-test.\n*              s6diff - Difference vector between two vectors.\n*              s6crss - Cross-product of two vectors.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n* REWISED BY : Vibeke Skytt, SI, 91-01.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;         /* Local status variable.           */\n  int kpos = 0;          /* Position of error.               */\n  int kdim;              /* Dimension of space.              */\n  int knc;               /* Number of vertices of curve.     */\n  int kn1,kn2;           /* Number of vertices of surface.   */\n  double *scurve;        /* Vertices of curve.               */\n  double *ssurf;         /* Vertices of surface.             */\n  double *stan = SISL_NULL;   /* Main tangent of curve.           */\n  double *sdiag1 = SISL_NULL; /* First main diagonal of surface.  */\n  double *sdiag2 = SISL_NULL; /* Second main diagonal of surface. */\n  double *snorm = SISL_NULL;  /* Main normal of surface.          */\n  SISLCurve *qcurve;     /* Pointer to curve.                */\n  SISLSurf *qsurf;       /* Pointer to surface.              */\n  \n  /* Test input.  */\n  \n  if (!((po1->iobj == SISLSURFACE && po2->iobj == SISLCURVE) ||\n\t(po1->iobj == SISLCURVE && po2->iobj == SISLSURFACE))) \n     goto err121;\n  \n  /* Set pointers to objects.  */\n  \n  if (po1->iobj == SISLSURFACE)\n  {\n     qsurf = po1->s1;  qcurve = po2->c1;\n  }\n  else\n  {\n     qsurf = po2->s1;  qcurve = po1->c1;\n  }\n  \n  /* Test dimension.  */\n  \n  kdim = qsurf -> idim;\n  if (kdim != 3) goto err104;\n  if (kdim != qcurve -> idim) goto err106;\n  \n  /* Allocate space for local arrays.  */\n  \n  if ((stan = newarray(kdim,double)) == SISL_NULL) goto err101;\n  if ((sdiag1 = newarray(kdim,double)) == SISL_NULL) goto err101;\n  if ((sdiag2 = newarray(kdim,double)) == SISL_NULL) goto err101;\n  if ((snorm = newarray(kdim,double)) == SISL_NULL) goto err101;\n  \n  /* Describe curve with local parameters.  */\n  \n  knc = qcurve->in;\n  scurve = qcurve->ecoef;\n  \n  /* Describe surface with local parameters.  */\n  \n  kn1 = qsurf->in1;\n  kn2 = qsurf->in2;\n  ssurf = qsurf->ecoef;\n  \n  /* Fetch main tangent of curve.  */\n  \n  s6diff(scurve+(knc-1)*kdim,scurve,kdim,stan);\n  \n  /* Fetch main diagonals of surface.  */\n  \n  s6diff(ssurf+(kn1*kn2-1)*kdim,ssurf,kdim,sdiag1);\n  \n  s6diff(ssurf+kn1*(kn2-1)*kdim,ssurf+(kn1-1)*kdim,kdim,sdiag2);\n  \n  /* Compute main normal of surface.  */\n  \n  s6crss(sdiag1,sdiag2,snorm);\n  \n  /* Perform rotated box-test.  */\n  \n  sh1834(po1,po2,aepsge,kdim,stan,snorm,&kstat);\n  if (kstat < 0) goto error;\n  \n  if (kstat == 1)\n    {\n      kstat = 0;\n      \n      sh1834(po1,po2,aepsge,kdim,snorm,stan,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* Improved box-test performed.  */\n  \n  *jstat = kstat;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"sh1830\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Dimension not equal to 3.  */\n  \n err104: *jstat = -104;\n  s6err(\"sh1830\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Dimensions conflicting.  */\n  \n err106: *jstat = -106;\n  s6err(\"sh1830\",*jstat,kpos);\n  goto out;\n  \n  /* Error in kind of object.  */\n  \n  err121: *jstat = -121;\n  s6err(\"s1930\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"sh1830\",*jstat,kpos);\n  goto out;\n  \n out:\n  \n  /* Free space occupied by local arrays.  */\n  \n  if (stan != SISL_NULL) freearray(stan);\n  if (sdiag1 != SISL_NULL) freearray(sdiag1);\n  if (sdiag2 != SISL_NULL) freearray(sdiag2);\n  if (snorm != SISL_NULL) freearray(snorm);\n  \n  return;\n}\n"
  },
  {
    "path": "src/sh1831.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define SH1831\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     sh1831(SISLCurve *pc1, SISLCurve *pc2, int isign, double epoint[], \n\t    double enorm[], double aepsge, int *jstat)\n#else\nvoid sh1831(pc1, pc2, isign, epoint, enorm, aepsge, jstat)\n     SISLCurve *pc1;\n     SISLCurve *pc2;\n     int isign;\n     double epoint[];\n     double enorm[];\n     double aepsge;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Interception test between two curves. Test if it is\n*              possible to split the curves by a given plane.\n*\n*\n*\n* INPUT      : pc1    - First curve.\n*              pc2    - Second curve.\n*              epoint - Point in plane.\n*              enorm  - Plane normal.\n*              aepsge - Geometric tolerance.\n*\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                              = 1      : Possibility of inner intersections.\n*                              = 0      : No possibility of inner intersections.\n*                              < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6scpr - Scalar product between two vectors.\n*              s6diff - Difference vector between two vectors.\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 94-02.\n*\n*********************************************************************\n*/\n{\n  int kpos = 0;          /* Position of error.               */\n  int ki;\n  int kdim;              /* Dimension of space.              */\n  int kbez1, kbez2;      /* Indicates if the curves are of type Bezier. */\n  int ksignprev = 0;     /* Sign of distance between previous curve and plane.*/\n  int ksign1 = 0;        /* Sign of distance between curve and plane.*/\n  int ksign2 = 0;        /* Sign of distance between curve and plane.*/\n  double tdist;          /* Distance between coefficient and plane.     */\n  double *s1;            /* Pointer to coefficient of curve. */\n  double sdiff[3];       /* Difference vector.               */\n  \n  /* Test dimension of geometry space. */\n  \n  kdim = pc1->idim;\n  if (kdim != 2 && kdim != 3) goto err105;\n  if (kdim != pc2->idim) goto err106;\n  \n  /* Test if the curves are Bezier curves. */\n  \n  kbez1 = (pc1->ik == pc1->in) ? 1 : 0;\n  kbez2 = (pc2->ik == pc2->in) ? 1 : 0;\n  \n  /* For each curve, compute the distance between the coefficients of the\n     curve and the given plane.    */\n  \n  for (s1=pc1->ecoef, ki=0; ki<pc1->in; ki++, s1+=kdim)\n  {\n     s6diff(epoint, s1, kdim, sdiff);\n     tdist = s6scpr(sdiff, enorm, kdim);\n     \n     if (fabs(tdist) <= aepsge && !kbez1 && !(ki==0 || ki==pc1->in-1)) break;\n     ksign2 = (DEQUAL(tdist,DZERO)) ? 0 : ((tdist > 0) ? 1 : -1);\n     if (ksign1*ksign2 < 0) break;\n     ksign1 = ksign2;\n  }\n  if (ki < pc1->in)\n  {\n     *jstat = 1;\n     goto out;\n  }\n\n  ksignprev = isign*ksign1;\n  ksign1 = 0;\n  for (s1=pc2->ecoef, ki=0; ki<pc2->in; ki++, s1+=kdim)\n  {\n     s6diff(epoint, s1, kdim, sdiff);\n     tdist = s6scpr(sdiff, enorm, kdim);\n     \n     if (fabs(tdist) <= aepsge && !kbez2 && !(ki==0 || ki==pc2->in-1)) break;\n     ksign2 = (DEQUAL(tdist,DZERO)) ? 0 : ((tdist > 0) ? 1 : -1);\n     if (ksign1*ksign2 < 0) break;\n     if (ksignprev*ksign1 > 0) break;\n     ksign1 = ksign2;\n  }\n  if (ki < pc2->in)\n  {\n     *jstat = 1;\n     goto out;\n  }\n  \n  goto out;\n  \n  /* Error in input. Dimension not equal to 2 or 3.  */\n  \n err105: *jstat = -105;\n  s6err(\"sh1831\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Dimensions conflicting.  */\n  \n err106: *jstat = -106;\n  s6err(\"sh1831\",*jstat,kpos);\n  goto out;\n  \n out:\n  \n  return;\n}\n"
  },
  {
    "path": "src/sh1834.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1834.c,v 1.5 2001-03-19 15:59:05 afr Exp $\n *\n */\n\n\n#define SH1834\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void sh1834_s9mat2d(double [],double []);\nstatic void sh1834_s9mat3d(double [],double [],double []);\n#else\nstatic void sh1834_s9mat2d();\nstatic void sh1834_s9mat3d();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh1834(SISLObject *po1,SISLObject *po2,double aepsge,int idim,\n\t    double edir1[],double edir2[],int *jstat)\n#else\nvoid sh1834(po1,po2,aepsge,idim,edir1,edir2,jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     int    idim;\n     double edir1[];\n     double edir2[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Perform a box-test to check if two objects overlap in\n*              the rotated coordinate system where edir1 defines the\n*              x-axis and (edir1 x edir2) defines the z-axis if\n*              idim = 3.\n*\n*\n*\n* INPUT      : po1    - Pointer to the first object.\n*              po2    - Pointer to the second object.\n*              aepsge - Geometry resolution.\n*              idim   - The dimension of the space in which the objects\n*                       lie. idim = 2 or idim = 3.\n*              edir1  - First direction vector. Defines x-axis in rotated\n*                       coordinate system.\n*              edir2  - Second direction vector.\n*\n*\n*\n* OUTPUT     : jstat  - status messages\n*                                 = 2      : Boundaries just touch.\n*                                 = 1      : Rotated SISLbox overlaps point.\n*                                 = 0      : No overlap.\n*                                 < 0      : error\n*\n*\n* METHOD     : The coordinate system is rotated such that if idim = 2,\n*              the x-axis of the new coordinate system is parallell to\n*              the vector edir1. If idim = 3, the cross-product of edir1\n*              and edir2 is rotated to be parallell to the z-axis and\n*              edir1 rotated to be parallell to the x-axis. The objects\n*              are moved into this rotated coordinate system and a\n*              box-test is performed.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1790  - Perform box test.\n*              s6scpr - Compute scalar product of two vectors.\n*              sh1834_s9mat2d - Set up rotation matrix for 2 dimensional space.\n*              sh1834_s9mat3d - Set up rotation matrix for 3 dimensional space.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-06.\n* REVISED BY : Vibeke Skytt, SI, 91-01.\n* REVISED BY : Mike Floater, SI, 94-07. Updated for rationals\n*                                        (s1834 didn't need changing).\n* REVISED BY : Vibeke Skytt, SINTEF Oslo, 94-11. Introduced 2D point-surface\n*                                                intersection.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;   /* Local status variable.                     */\n  int kpos = 0;    /* Position of error.                         */\n  int kinnerexp = 12; /* Expand box in the inner. No rotation.   */\n  int kn1=0,kn2=0;     /* Number of coefficients of objects.     */\n  double *sc1,*sc2;/* Pointers to coefficients of objects.       */\n  double *scoef1=SISL_NULL;  /* Rotated coefficients of first object. */\n  double *scoef2=SISL_NULL;  /* Rotated coefficients of second object.*/\n  double *smat=SISL_NULL;    /* Rotation matrix.                      */\n  double *s1,*s2,*s3,*s4,*s5;  /* Pointers used to traverse arrays. */\n  SISLObject *qo1=SISL_NULL; /* First object after rotation.          */\n  SISLObject *qo2=SISL_NULL; /* Second object after rotation.         */\n  /*  long time_before;\n  long time_used=0; */\n\n  double *rc1,*rc2;     /* Pointers to homogeneous coefficients. */\n  double *rcoef1=SISL_NULL;  /* Possibly homogeneous coefficients.    */\n  double *rcoef2=SISL_NULL;  /* Possibly homogeneous coefficients.    */\n  int ikind1=0, ikind2=0;   /* Kinds of objects 1 and 2.         */\n  int i,i1,i2,j,k;      /* Loop variables.                       */\n\n  /* Test input.  */\n\n  if (idim != 2 && idim != 3) goto err105;\n\n  /* Fetch coefficients of the objects. */\n\n  if (po1->iobj == SISLCURVE)\n  {\n     kn1 = po1->c1->in;\n     sc1 = po1->c1->ecoef;\n     rc1 = po1->c1->rcoef;\n     ikind1 = po1->c1->ikind;\n  }\n  else if (po1->iobj == SISLSURFACE)\n  {\n     kn1 = po1->s1->in1*po1->s1->in2;\n     sc1 = po1->s1->ecoef;\n     rc1 = po1->s1->rcoef;\n     ikind1 = po1->s1->ikind;\n  }\n  else\n  {\n     kn1 = 1;\n     sc1 = po1->p1->ecoef;\n     rc1 = SISL_NULL;\n     ikind1 = 1;\n  }\n\n  if (po2->iobj == SISLCURVE)\n  {\n     kn2 = po2->c1->in;\n     sc2 = po2->c1->ecoef;\n     rc2 = po2->c1->rcoef;\n     ikind2 = po2->c1->ikind;\n  }\n  else if (po2->iobj == SISLSURFACE)\n  {\n     kn2 = po2->s1->in1*po2->s1->in2;\n     sc2 = po2->s1->ecoef;\n     rc2 = po2->s1->rcoef;\n     ikind2 = po2->s1->ikind;\n  }\n  else\n  {\n     kn2 = 1;\n     sc2 = po2->p1->ecoef;\n     rc2 = SISL_NULL;\n     ikind2 = 1;\n  }\n\n  /* Allocate space for local parameters.  */\n\n  if ((scoef1 = newarray(idim*kn1,DOUBLE)) == SISL_NULL) goto err101;\n  if ((scoef2 = newarray(idim*kn2,DOUBLE)) == SISL_NULL) goto err101;\n  if ((smat = new0array(idim*idim,DOUBLE)) == SISL_NULL) goto err101;\n\n  /* Find the rotation matrix.  */\n\n  if (idim == 2)\n\n    /* After normalization edir1[0] will contain the cosine of the\n       rotation angle and edir1[1] will contain the sine.           */\n\n     sh1834_s9mat2d(smat,edir1);\n  else\n\n    /* Set up the rotation matrix when idim = 3. (edir1 x edir2) is\n       rotated to be parallell to the z-axis and edir1 to be parallell\n       to the x-axis.                                                   */\n\n  sh1834_s9mat3d(smat,edir1,edir2);\n\n  /* The objects is moved into the new coordinate system by rotating\n     them using the rotation matrix.                                 */\n\n  /* Rotate first object. */\n\n    for (s2=sc1,s4=s2+idim*kn1,s5=scoef1; s2<s4; s2+=idim)\n     for (s1=smat,s3=smat+idim*idim; s1<s3; s1+=idim,s5++)\n\t*s5 = s6scpr(s1,s2,idim);\n\n  /* Rotate second object. */\n\n  for (s2=sc2,s4=s2+idim*kn2,s5=scoef2; s2<s4; s2+=idim)\n     for (s1=smat,s3=smat+idim*idim; s1<s3; s1+=idim,s5++)\n\t*s5 = s6scpr(s1,s2,idim);\n\n  /* Make rotated objects.  */\n\n  if ((qo1 = newObject(po1->iobj)) == SISL_NULL) goto err101;\n  if ((qo2 = newObject(po2->iobj)) == SISL_NULL) goto err101;\n\n  if(ikind1 == 2 || ikind1 == 4)\n  {\n      if ((rcoef1 = newarray((idim+1)*kn1,DOUBLE)) == SISL_NULL) goto err101;\n      for(i=0,i1=0,i2=0; i<kn1; i++)\n      {\n\t  k = i1 + idim;\n\t  for(j=0; j<idim; j++, i1++, i2++)\n\t  {\n\t      rcoef1[i1] = scoef1[i2] * rc1[k];\n\t  }\n\t  rcoef1[i1] = rc1[k];\n\t  i1++;\n      }\n  }\n  else\n  {\n      rcoef1 = scoef1;\n  }\n\n  if(ikind2 == 2 || ikind2 == 4)\n  {\n      if ((rcoef2 = newarray((idim+1)*kn2,DOUBLE)) == SISL_NULL) goto err101;\n      for(i=0,i1=0,i2=0; i<kn2; i++)\n      {\n\t  k = i1 + idim;\n\t  for(j=0; j<idim; j++, i1++, i2++)\n\t  {\n\t      rcoef2[i1] = scoef2[i2] * rc2[k];\n\t  }\n\t  rcoef2[i1] = rc2[k];\n\t  i1++;\n      }\n  }\n  else\n  {\n      rcoef2 = scoef2;\n  }\n\n\n  if (po1->iobj == SISLCURVE)\n  {\n     if ((qo1->c1 = newCurve(po1->c1->in,po1->c1->ik,po1->c1->et,\n\t\t\t     rcoef1,po1->c1->ikind,idim,0)) == SISL_NULL)\n\tgoto err101;\n     /* printf(\"Rotated box test. Curve - \"); */\n  }\n  else if (po1->iobj == SISLSURFACE)\n  {\n     if ((qo1->s1 = newSurf(po1->s1->in1,po1->s1->in2,po1->s1->ik1,\n\t\t\t    po1->s1->ik2,po1->s1->et1,po1->s1->et2,\n\t\t\t     rcoef1,po1->s1->ikind,idim,0)) == SISL_NULL)\n\tgoto err101;\n     /* printf(\"Rotated box test. Surface - \"); */\n\n  }\n  else \n  {\n     if ((qo1->p1 = newPoint(rcoef1,idim,0)) == SISL_NULL) goto err101;\n  }\n\n  if (po2->iobj == SISLCURVE)\n  {\n     if ((qo2->c1 = newCurve(po2->c1->in,po2->c1->ik,po2->c1->et,\n\t\t\t     rcoef2,po2->c1->ikind,idim,0)) == SISL_NULL)\n\tgoto err101;\n     /* printf(\"curve. \"); */\n  }\n  else if (po2->iobj == SISLSURFACE)\n  {\n     if ((qo2->s1 = newSurf(po2->s1->in1,po2->s1->in2,po2->s1->ik1,\n\t\t\t    po2->s1->ik2,po2->s1->et1,po2->s1->et2,\n\t\t\t     rcoef2,po2->s1->ikind,idim,0)) == SISL_NULL)\n\tgoto err101;\n     /* printf(\"surface. \"); */\n  }\n  else \n  {\n     if ((qo2->p1 = newPoint(rcoef2,idim,0)) == SISL_NULL) goto err101;\n  }\n\n  /* Make box test.  */\n\n  /*  time_before = clock();\n  boxrot_nmb++; */\n  sh1790(qo1,qo2,kinnerexp,aepsge,&kstat);\n  /*  time_used = clock() - time_before;\n  boxrot_time += time_used; */\n  if (kstat < 0) goto error;\n\t\t /* printf(\"Status = %d \\n\",kstat); */\n\n  /* Box-test permformed.  */\n\n  *jstat = kstat;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;\n  s6err(\"sh1834\",*jstat,kpos);\n  goto out;\n\n  /* Error in input. Dimension not equal to 2 or 3.  */\n\n err105: *jstat = -105;\n  s6err(\"sh1834\",*jstat,kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n  goto out;\n\n out:\n\n  /* Free space occupied by local arrays and objects.  */\n\n  if (qo1 != SISL_NULL) freeObject(qo1);\n  if (qo2 != SISL_NULL) freeObject(qo2);\n  if (rcoef1 != SISL_NULL && rcoef1 != scoef1) freearray(rcoef1);\n  if (rcoef2 != SISL_NULL && rcoef2 != scoef2) freearray(rcoef2);\n  if (scoef1 != SISL_NULL) freearray(scoef1);\n  if (scoef2 != SISL_NULL) freearray(scoef2);\n  if (smat != SISL_NULL) free0array(smat);\n\n  return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  sh1834_s9mat2d(double emat[],double edir[])\n#else\nstatic void sh1834_s9mat2d(emat,edir)\n     double emat[];\n     double edir[];\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Set up rotation matrix in two dimensions when the x-axis\n*              is supposed to be rotated to be parallell with edir.\n*\n* INPUT      : edir  - Direction of rotated x-axis.\n*\n* OUTPUT     : emat  - Rotation matrix. emat is supposed to be\n*                      initialized to zero before this routine is entered.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;   /* Local status variable.              */\n  double tlength;  /* Length of vector edir.              */\n  double sdir[2];  /* Normalized vertion of vector edir.  */\n\n  tlength = s6norm(edir,2,sdir,&kstat);\n  if (kstat == 0)\n\n    /* Length of edir equal to zero. Let the rotation matrix be\n       the identity matrix.                                      */\n\n    emat[0] = emat[3] = (double)1.0;\n  else\n    {\n\n      /* Make rotation matrix.  */\n\n      emat[0] = sdir[0];\n      emat[1] = sdir[1];\n      emat[2] = sdir[1];\n      emat[3] = -sdir[0];\n    }\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  sh1834_s9mat3d(double emat[],double edir1[],double edir2[])\n#else\nstatic void sh1834_s9mat3d(emat,edir1,edir2)\n     double emat[];\n     double edir1[];\n     double edir2[];\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Set up rotation matrix in three dimensions when edir1\n*              is supposed to be rotated to be parallell with the x-axis\n*              and (edir1 x edir2) to be parallell with the z-axis.\n*\n* INPUT      : edir1 - First direction vector.\n*              edir2 - Second direction vector.\n*\n* OUTPUT     : emat  - Rotation matrix. The matrix is supposed to be\n*                      initialized to zero before this routine is enterd.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;    /* Local status variable.                         */\n  double snorm[3];  /* Cross-product of edir1 and edir2.              */\n  double sdir[3];   /* Normalized vertion of edir1.                   */\n  double *s1;       /* Pointer into emat array.                       */\n  double tleng1,tleng2; /* Length of snorm and edir1 respectively.    */\n  double ta1,ta2,ta3,tb1,tb2,tb3,td1,td2,tl1,tl2,tl3; /* Help variables. */\n\n  /* Calculate cross-product of edir1 and edir2.  */\n\n  s6crss(edir1,edir2,snorm);\n\n  /* Normalize snorm.  */\n\n  tleng1 = s6norm(snorm,3,snorm,&kstat);\n\n  /* Normalize edir1.  */\n\n  tleng2 = s6norm(edir1,3,sdir,&kstat);\n\n  /* Initialize help variables.  */\n\n  ta1 = snorm[0];\n  ta2 = snorm[1];\n  ta3 = snorm[2];\n  tl1 = sqrt(ta2*ta2+ta3*ta3);\n\n  /* Set up rotation matrix.  */\n\n  if ((DEQUAL(tleng1,DZERO) || DEQUAL(tl1,DZERO)) && DEQUAL(tleng2,DZERO))\n\n    /* The rotation matrix is the identity matrix.  */\n\n    emat[0] = emat[4] = emat[8] = (double)1.0;\n  else if (DEQUAL(tleng1,DZERO) || DEQUAL(tl1,DZERO))\n    {\n\n      /* The rotation matrix is supposed to rotate edir1 to be parallell\n\t to the x-axis.                                                   */\n\n      tb1 = sdir[0];\n      tb2 = sdir[1];\n      tb3 = sdir[2];\n      tl3 = sqrt(tb1*tb1+tb2*tb2);\n\n      if (DEQUAL(tl3,DZERO)) emat[0] = emat[4] = emat[8] = (double)1.0;\n      else\n\t{\n\t  s1      = emat;\n\t  *(s1++) = tb1;\n\t  *(s1++) = tb2;\n\t  *(s1++) = tb3;\n\t  *(s1++) = -tb2/tl3;\n\t  *(s1++) = tb1/tl3;\n\t  *(s1++) = DZERO;\n\t  *(s1++) = -tb1*tb3/tl3;\n\t  *(s1++) = -tb2*tb3/tl3;\n\t  *(s1++) = tl3;\n\t}\n    }\n  else\n    {\n      td1 = edir1[0]/tl1;\n      td2 = (ta3*edir1[1] - ta2*edir1[2])/tl1;\n      tl2 = sqrt(td1*td1+td2*td2);\n\n      if (DEQUAL(tl2,DZERO))\n\t{\n\n\t  /* The normal snorm is rotated to be parallell to the z-axis. */\n\n\t  s1      = emat;\n\t  *(s1++) = tl1;\n\t  *(s1++) = -ta1*ta2/tl1;\n\t  *(s1++) = -ta1*ta3/tl1;\n\t  *(s1++) = DZERO;\n\t  *(s1++) = ta3/tl1;\n\t  *(s1++) = -ta2/tl1;\n\t  *(s1++) = ta1;\n\t  *(s1++) = ta2;\n\t  *(s1++) = ta3;\n\t}\n      else\n\t{\n\n\t  /* The normal is rotated to be parallell to the z-axis and edir1\n\t     to be parallell to the x-axis.                                 */\n\n\t  s1      = emat;\n\t  *(s1++) = td1*tl1/tl2;\n\t  *(s1++) = (-ta1*ta2*td1 + ta3*td2)/(tl1*tl2);\n\t  *(s1++) = (-ta1*ta3*td1 - ta2*td2)/(tl1*tl2);\n\t  *(s1++) = -td2*tl1/tl2;\n\t  *(s1++) = (ta1*ta2*td2 + ta3*td1)/(tl1*tl2);\n\t  *(s1++) = (ta1*ta3*td2 - ta2*td1)/(tl1*tl2);\n\t  *(s1++) = ta1;\n\t  *(s1++) = ta2;\n\t  *(s1++) = ta3;\n\t}\n    }\n}\n"
  },
  {
    "path": "src/sh1839.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1839.c,v 1.2 2001-03-19 15:59:06 afr Exp $\n *\n */\n\n\n#define SH1839\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh1839(SISLObject *po1,SISLObject *po2,double aepsge,int *jstat)\n#else\nvoid sh1839(po1,po2,aepsge,jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Perform improved box-test in intersection involving\n*              a surface.\n*\n*\n*\n* INPUT      : po1     - Pointer to the first object in the intersection.\n*                        This object is expected to be a surface.\n*              po2     - Pointer to the second object in the intersection.\n*              aepsge  - Geometry resolution.\n*\n*\n*\n* OUTPUT     : *jstat  - status messages  \n*                            = 2      : Only edge-intersections possible.\n*                            = 1      : Internal intersections possible.\n*                            = 0      : No intersections possible.\n*                            < 0      : error\n*\n*\n* METHOD     : Pick the diagonal of the surface and the tangents in\n*              the corners of the surface if these might be different \n*              from the diagonals. Rotate coordinate system according\n*              to the vectors picked and perform a box-test.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1834 - Perform rotated box-test.\n*\n* WRITTEN BY : Tor Dokken, SI, OSlo, Norway.\n* REWISED BY : Vibeke Skytt, SI, 91-01.\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;           /* Local status variable.                        */\n  int kpos = 0;            /* Position of error.                            */\n  int ki,kj;               /* Counter.                                      */\n  int kdim;                /* Dimension of geometry space.                  */\n  int kn1,kn2;             /* Number of vertices in each parameter\n\t\t\t      direction of surface.                         */\n  int kk1,kk2;             /* Order in each parameter direction of surface. */\n  int kvec;                /* Number of direction vectors to calculate.     */\n  int klap;                /* Indcates whether SISLbox of surface overlap point.*/\n  double tang1,tang2;      /* Angles between direction vectors.             */\n  double *scoef;           /* Vertices of surface.                          */\n  register double *s1,*s2,\n  *s3,*s4;                 /* Pointers used to traverse arrays.             */\n  double *sdir = SISL_NULL;     /* Array containing direction vectors.           */\n  \n  /* Test kind of first object.  */\n  \n  if (po1->iobj != SISLSURFACE) goto err122;\n    \n  /* Copy surface to local parameters.  */\n  \n  kdim = po1 -> s1 -> idim;\n  kn1 = po1 -> s1 -> in1;\n  kn2 = po1 -> s1 -> in2;\n  kk1 = po1 -> s1 -> ik1;\n  kk2 = po1 -> s1 -> ik2;\n  scoef = po1 -> s1 -> ecoef;\n  \n  /* Find number of rotations to make.  */\n  \n  if (kk1 > 2 || kk2 > 2) kvec = 10; else kvec = 2;\n  \n  /* Allocate space for vectors with which the x-axis is to be parallell. */\n  \n  sdir = newarray(kvec*kdim,double);\n  if (sdir == SISL_NULL) goto err101;\n  \n   if (kvec == 2)\n   {\n  /* Make diagonal from lower left to upper right corner of patch.  \n     s1 points to the array which contains the results, s3 points to the\n     lower left corner and s4 to the upper right corner.                 */\n  \n  for (s1=sdir,s2=s1+kdim,s3=scoef,s4=scoef+kdim*(kn1*kn2-1); s1<s2;\n       s1++,s3++,s4++)\n    *s1 = *s4 - *s3;\n  \n  /* Make diagonal from upper left to lower right corner of patch. s1\n     points to the array which contains the results, s3 points to the\n     upper left and s4 to the lower right corner.                       */\n  \n  for (s1=sdir+kdim,s2=s1+kdim,s3=scoef+kdim*kn1*(kn2-1),\n       s4=scoef+kdim*(kn1-1); s1<s2; s1++,s3++,s4++)\n    *s1 = *s4 - *s3;\n   }\n   \n  if (kvec > 2)\n    {\n      \n      /* The surface is not linear in both parameter directions. Make\n\t horizontal and vertical tangent in lower left corner. s1 points\n\t to the array which contain the results and s3 to the corner.    */\n      \n      for (s1=sdir+2*kdim,s2=s1+kdim,s3=scoef; s1<s2; s1++,s3++)\n\t{       \n\t  *s1 = *(s3+kdim) - *s3;\n\t  *(s1+kdim) = *(s3+kdim*kn1) - *s3;\n\t}\n      \n      /* Make the horizontal and vertical tangent in lower right corner. s1\n\t points to the array which contain the results and s3 to the corner.*/\n      \n      for (s1=sdir+4*kdim,s2=s1+kdim,s3=scoef+kdim*(kn1-1); s1<s2; s1++,s3++)\n\t{\n\t  *s1 = *(s3-kdim) - *s3;\n\t  *(s1+kdim) = *(s3+kdim*kn1) - *s3;\n\t}\n      \n      /* Make the horizontal and vertical tangent in upper left corner. s1\n\t points to the result array and s3 to the corner.                  */\n      \n      for (s1=sdir+6*kdim,s2=s1+kdim,s3=scoef+kdim*kn1*(kn2-1);s1<s2;s1++,s3++)\n\t{\n\t  *s1 = *(s3+kdim) - *s3;\n\t  *(s1+kdim) = *(s3-kdim*kn1) - *s3;\n\t}\n      \n      /* Make the horizontal and vertical tangent in upper right corner. \n\t s1 points to the result array and s3 to the corner.             */\n      \n      for (s1=sdir+8*kdim,s2=s1+kdim,s3=scoef+kdim*(kn1*kn2-1);s1<s2;s1++,s3++)\n\t{\n\t  *s1 = *(s3-kdim) - *s3;\n\t  *(s1+kdim) = *(s3-kn1*kdim) - *s3;\n\t}\n    }\n  \n  /* Rotate coordinate system according to the vectors found and perform\n     box-test. First use the diagonal vectors.                           */\n  \n  klap = 1;\n  if (kvec == 2)\n  {\n  sh1834(po1,po2,aepsge,kdim,sdir,sdir+kdim,&kstat);\n  if (kstat < 0) goto error;\n  klap = kstat;\n  \n  if (klap == 1)\n    {\n       sh1834(po1,po2,aepsge,kdim,sdir+kdim,sdir,&kstat);\n      if (kstat < 0) goto error;\n      klap = kstat;\n    }\n  }\n  \n  /* If the box-tests performed till now show overlap and the surface\n     is non-linear in at least one direction rotate the geometry according\n     to the tangent information gathered.                                 */\n  /* First remove superfluous rotation directions.                        */\n  \n  for (ki=4; ki<kvec; )\n  {\n     for (kj=2; kj<4; kj+=2)\n     {\n\t/* Test if the found vectors are aproximately equal.  */\n\t\n\ttang1 = s6ang(sdir+ki*kdim,sdir+kj*kdim,kdim);\n\ttang2 = s6ang(sdir+(ki+1)*kdim,sdir+(kj+1)*kdim,kdim);\n\t\n\tif (tang1 < ANGULAR_TOLERANCE && tang2 < ANGULAR_TOLERANCE) break;\n     }\n     \n     if (kj < 4)\n     {\n\t/* Remove set of rotation vectors.  */\n\t\n\tif (ki+2 < kvec)\n\t  memmove(sdir+ki*kdim, sdir+(ki+2)*kdim, (kvec-ki-2)*kdim*sizeof(double));\n\t/*memcopy(sdir+ki*kdim, sdir+(ki+2)*kdim, (kvec-ki-2)*kdim, DOUBLE); */\n\tkvec -= 2;\n     }\n     else ki+=2;\n  }\n  \n  ki = 2;\n  while (ki<kvec && klap == 1)\n    {\n       sh1834(po1,po2,aepsge,kdim,sdir+ki*kdim,sdir+(ki+1)*kdim,&kstat);\n      if (kstat < 0) goto error;\n      klap = kstat;\n      \n      if (klap && \n\t  fabs(s6ang(sdir+ki*kdim,sdir+(ki+1)*kdim,kdim)-PIHALF) \n\t  > ANGULAR_TOLERANCE)\n      {\n\t /* VSK, 01/93. Use the other partial derivative as x-axis in \n\t    the rotation. */\n\t \n\t sh1834(po1,po2,aepsge,kdim,sdir+(ki+1)*kdim,sdir+ki*kdim,&kstat);\n\t if (kstat < 0) goto error;\n\t klap = kstat;\n      }\n      ki += 2;\n    }\n  \n  /* Improved boxtest performed.  */\n  \n  *jstat = klap;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n err101: *jstat = -101;\n  s6err(\"sh1839\",*jstat,kpos);\n  goto out;\n  \n  /* Error in input. Unexpected object found.  */\n  \n err122: *jstat = -122;\n  s6err(\"sh1839\",*jstat,kpos);\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"sh1839\",*jstat,kpos);\n  goto out;\n  \n out: \n  \n  /* Free allocated space.  */\n  \n  if (sdir != SISL_NULL) freearray(sdir);\n  \n  return;\n}\n"
  },
  {
    "path": "src/sh1850.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1850.c,v 1.2 2001-03-19 15:59:06 afr Exp $\n *\n */\n\n\n#define SH1850\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \nsh1850(SISLCurve *pc1,double epoint[],double enorm[],int idim,double aepsco,\n       double aepsge,int trackflag, int *jtrack, SISLTrack *** wtrack,\n       int *jpt,double **gpar,int **pretop,int *jcrv,\n       SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid sh1850(pc1,epoint,enorm,idim,aepsco,aepsge,\n\t    trackflag,jtrack,wtrack,jpt,gpar,pretop,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     double   epoint[];\n     double   enorm[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a curve and a plane if\n*              the dimension is equal to three and a line if the \n*              dimension is two.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve.\n*              epoint - SISLPoint in the plane/line.\n*              enorm  - Normal to the plane/line.\n*              idim   - Dimension of the space in which the plane/line\n*                       lies. idim should be equal to two or three.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              jcrv   - Number of intersection curves.\n*              wcurve - Array containing descrjptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter interval. The curve-pointers points\n*                       to nothing. (See descrjption of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the curve is put into the equation of the\n*              plane/line achieving a curve in the one-dimentional space.\n*              The zeroes of this curve is found.\n*\n*\n* REFERENCES :\n*\n*- \n* CALLS      : sh1761       - Find point/curve intersections.\n*              hp_s1880       - Put intersections into output format.\n*              s6diff      - Difference between two vectors.\n*              s6scpr      - Scalar product of two vectors.\n*              newCurve    - Create new curve.                        \n*              newPoint    - Create new point.\n*              newObject   - Create new object.\n*              freeObject  - Free the space occupied by a given object.\n*              freeIntdat  - Free space occupied by an intersection data.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-05.\n* REWRITTEN BY : Bjoern Olav Hoset, SI, 89-06.\n* REVISED BY : Mike Floater, SI, 91-04 for rational curves.\n* REVISED BY : UJK, SI, 92-04 periodicity.\n* \n*********************************************************************\n*/                                                               \n{                                                                     \n  double *nullp = SISL_NULL;\n  int ikind;               /* kind of curve pc1 is                     */\n  int kstat = 0;           /* Local status variable.                     */\n  int kpos = 0;            /* Position of error.                         */\n  int kn;                  /* Number of vertices of curve.               */\n  int kk;                  /* Order of curve.                            */\n  int ki;                  /* Counter                                    */\n  int kdim = 1;            /* Dimension of curve in curve/point intersection.*/\n  double *st;              /* Pointer to knotvector of curve.              */\n  double *scoef;           /* Pointer to vertices of curve.                */\n  double *sc = SISL_NULL;       /* Pointer to vertices of curve in curve/point\n\t\t\t      intersection.                                */\n  double spoint[1];        /* SISLPoint in curve/point intersection.           */\n  double *spar = SISL_NULL;     /* Values of intersections in the parameter \n\t\t\t      area of the second object. Empty in this case. */\n  double *sdiff = SISL_NULL;    /* Difference between point and coefficient.    */\n  double *s1,*s2;          /* Pointers used to traverse coefficient arrays.*/\n  SISLCurve *qc = SISL_NULL;        /* Pointer to curve in \n\t\t\t      curve/point intersection.  */\n  SISLPoint *qp = SISL_NULL;        /* Pointer to point in \n\t\t\t      curve/point intersection.  */\n  SISLObject *qo1 = SISL_NULL;      /* Pointer to curve in \n\t\t\t      object/point intersection. */\n  SISLObject *qo2 = SISL_NULL;      /* Pointer to point in \n\t\t\t      object/point intersection    */\n  SISLIntdat *qintdat = SISL_NULL;  /* Intersection result */\n  double *rscoef;          /* Scaled coefficients if pc1 is rational        */\n  double *s3;              /* pointer to weight if curve rational           */\n  double wmin,wmax;        /* min and max values of the weights if rational */\n  double scale;            /* factor for scaling weights if rational        */\n  int i;                   /* loop variable                                 */\n  int idimp1;              /* idim+1                                        */\n  int      ksurf=0;         /* Dummy number of Intsurfs. */\n  SISLIntsurf **wsurf=SISL_NULL;    /* Dummy array of Intsurfs. */\n  int      kdeg=2000;       /* input to int_join_per. */\n  SISLObject *track_obj=SISL_NULL;\n  \n  /*\n  * Create new object and connect curve to object.\n  * ------------------------------------------------\n  */\n  \n  if (!(track_obj = newObject (SISLCURVE)))\n    goto err101;\n  track_obj->c1 = pc1;\n  \n\n  /* \n   * Check dimension.  \n   * ----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if ( !(idim == 2 || idim == 3)) goto err104;\n  if (pc1 -> idim != idim) goto err103;\n\n  /* \n   * Copy curve to local variables.  \n   * ------------------------------\n   */\n\n  kn    = pc1 -> in;\n  kk    = pc1 -> ik;\n  st    = pc1 -> et;\n  ikind = pc1 -> ikind;\n  \n  /* rational curves are a special case */\n  if(ikind == 2 || ikind == 4)\n  {\n      /* scale the coeffs so that min. weight * max. weight = 1  */\n      idimp1=idim+1;\n      rscoef = pc1 -> rcoef;\n      wmin=rscoef[idim];\n      wmax=rscoef[idim];\n      for(i=idim; i< kn*idimp1; i+=idimp1)\n      {\n          if(rscoef[i] < wmin) wmin=rscoef[i];\n          if(rscoef[i] > wmax) wmax=rscoef[i];\n      } \n      scale=1.0/sqrt(wmin*wmax);\n      scoef=newarray(kn*idimp1,DOUBLE);\n      for(i=0; i< kn*idimp1; i++)\n      {\n          scoef[i]=rscoef[i]*scale;\n      } \n  }\n  else\n  {\n      scoef = pc1 -> ecoef;\n  }\n\n\n  /* \n   * Allocate space for coeffecients of new curve and help array. \n   * ------------------------------------------------------------\n   */\n                         \n  if ((sdiff = newarray(idim,double)) == SISL_NULL) goto err101;\n  if ((sc = newarray(kn,double)) == SISL_NULL) goto err101;\n\n  /* \n   * Put vertices into the equation of the plane/line. \n   * Compute new vertices.\n   * -------------------------------------------------\n   */\n\n  for (s1=scoef,s2=sc,ki=0; ki<kn; ki++,s1+=idim,s2++)\n    {\n      if(ikind == 2 || ikind == 4)\n      {\n      /* curve is rational so we're using idim+1 - d homogeneous coords */\n          s3=s1+idim;\n          for(i=0; i<idim; i++)\n          {\n              sdiff[i]=(*(s1+i)) - (*s3) * epoint[i];\n          }\n          *s2 = s6scpr(sdiff,enorm,idim);\n\t  s1++;\n      }\n      else\n      {\n      /* curve is not rational so we're using ordinary idim - d coords */\n          s6diff(s1,epoint,idim,sdiff);\n          *s2 = s6scpr(sdiff,enorm,idim);\n      }\n    }                                 \n\n  if(ikind == 2 || ikind == 4) freearray(scoef);\n\n  /* \n   * Create new curve.  \n   * -----------------\n   */\n\n  if(ikind == 2 || ikind == 4) ikind--;\n  qc = newCurve(kn,kk,st,sc,ikind,kdim,0);\n  if (qc == SISL_NULL) goto err101;\n  qc->cuopen = pc1->cuopen;\t\t  \n      \n  /* \n   * Create new object and connect curve to object.  \n   * ----------------------------------------------\n   */\n\n  if (!(qo1 = newObject(SISLCURVE))) goto err101;\n  qo1 -> c1 = qc;\n  qo1 -> o1 = qo1;\n  \n  /*\n   * Create new object and connect point to object.\n   * ----------------------------------------------\n   */\n\n  if(!(qo2 = newObject(SISLPOINT))) goto err101;\n  spoint[0] = DZERO;\n  if(!(qp = newPoint(spoint,kdim,1))) goto err101;\n  qo2 -> p1 = qp;\n\n  /* \n   * Find intersections.  \n   * -------------------\n   */\n\n  sh1761(qo1,qo2,aepsge,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj,track_obj,nullp,kdeg,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n      make_tracks (qo1, qo2, 0, nullp,\n\t\t   qintdat->ilist, qintdat->vlist, \n\t\t   jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* \n   * Express intersections on output format.  \n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(track_obj, track_obj, kdeg,\n\t       1,0,qintdat,jpt,gpar,&spar,pretop,jcrv,wcurve,&ksurf,&wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;\n        s6err(\"sh1850\",*jstat,kpos);\n        goto out;\n\n  /* Dimensions conflicting.  */\n\n err103: *jstat = -103;\n        s6err(\"sh1850\",*jstat,kpos);\n        goto out;\n\n  /* Dimension not equal to two or three.  */\n\n err104: *jstat = -104;                          \n        s6err(\"sh1850\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n        s6err(\"sh1850\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if (sc)      freearray(sc);\n  if (sdiff)   freearray(sdiff);       \n  if (spar)    freearray(spar);\n  if (qo1)     freeObject(qo1);\n  if (qo2)     freeObject(qo2);\n  if (qintdat) freeIntdat(qintdat);\n  if (track_obj)\n    {\n       track_obj->c1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n\nreturn;\n}                                               \n                                           \n                       \n\n"
  },
  {
    "path": "src/sh1851.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1851.c,v 1.2 2001-03-19 15:59:06 afr Exp $\n *\n */\n\n\n#define SH1851\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh1851(SISLSurf * ps1, double epoint[], double enorm[], int idim, \n\t    double aepsco, double aepsge,int trackflag, int *jtrack, \n\t    SISLTrack *** wtrack,int *jpt, double **gpar, int **pretop, \n\t    int *jcrv, SISLIntcurve *** wcurve, int *jsurf, \n\t    SISLIntsurf ***wsurf, int *jstat)\n#else\nvoid sh1851(ps1, epoint, enorm, idim, aepsco, aepsge,trackflag, jtrack, \n\t    wtrack, jpt, gpar, pretop, jcrv, wcurve,jsurf,wsurf, jstat)\n     SISLSurf *ps1;\n     double epoint[];\n     double enorm[];\n     int idim;\n     double aepsco;\n     double aepsge;\n     int trackflag;\n     int *jtrack;\n     SISLTrack ***wtrack;\n     int *jpt;\n     double **gpar;\n     int **pretop;\n     int *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jsurf;\n     SISLIntsurf ***wsurf;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find all intersections between a tensor-product surface\n*              and a plane.\n*\n*\n*\n* INPUT      : ps1    - Pointer to surface.\n*              epoint - SISLPoint in the plane.\n*              enorm  - Normal to the plane.\n*              idim   - Dimension of the space in which the plane lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       plane of the surface. The points lie continuous.\n*                       Intersection curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the surface are put into the equation of the\n*              plane achieving a surface in the one-dimentional space.\n*              Then the zeroes of this surface is found.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1761       - Perform point object-intersection.\n*              s1329       - Equation of surface into equation of plane.\n*              hp_s1880       - Put intersections on output format.\n*              make_sf_kreg   - Ensure k-regularity of surface.\n*              newObject   - Create new object.\n*              newPoint    - Create new point.\n*              freeObject  - Free space occupied by an object.\n*              freeIntdat  - Free space occupied by an intersection data.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-06.\n* REWRITTEN BY : Bjoern Olav Hoset, SI, 89-06.\n*                UJK, SI, 91-07\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Local status varible.                      */\n  int kpos = 0;\t\t\t/* Position of error.                         */\n  int kdim = 1;\t\t\t/* Dimension of space in which the point in the\n\t\t\t           intersect point and surface problem lies.  */\n  double *spar = SISL_NULL;\t\t/* Dummy array containing parameter values of\n\t\t\t           second object of single intersection points.*/\n  double spoint[1];\t\t/* SISLPoint to intersect with object.            */\n  SISLSurf *qs = SISL_NULL;\t\t/* Pointer to surface in\n\t\t\t       surface/point intersection.*/\n  SISLPoint *qp = SISL_NULL;\t\t/* Pointer to point in\n\t\t\t       surface/point intersection.  */\n  SISLObject *qo1 = SISL_NULL;\t/* Pointer to surface in\n\t\t\t       object/point intersection. */\n  SISLObject *qo2 = SISL_NULL;\t/* Pointer to point in\n\t\t\t       object/point intersection    */\n  SISLIntdat *qintdat = SISL_NULL;\t/* Intersection result */\n  int kdeg = 1;\t\t\t/* Implisit descr. to track  */\n  double simpli[16];\n  double snorm[3];\n  SISLObject *track_obj=SISL_NULL;\n  SISLSurf *qkreg=SISL_NULL; /* Input surface ensured k-regularity. */\n\n  /* -------------------------------------------------------- */  \n\n  if (ps1->cuopen_1 == SISL_SURF_PERIODIC ||\n      ps1->cuopen_2 == SISL_SURF_PERIODIC)\n  {\n     /* Cyclic surface. */\n\n     make_sf_kreg(ps1,&qkreg,&kstat);\n     if (kstat < 0) goto error;\n   }\n  else\n    qkreg = ps1;\n  \n  /*\n  * Create new object and connect surface to object.\n  * ------------------------------------------------\n  */\n  \n  if (!(track_obj = newObject (SISLSURFACE)))\n    goto err101;\n  track_obj->s1 = ps1;\n  \n  /*\n  * Check dimension.\n  * ----------------\n  */\n  \n  *jpt = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if (idim != qkreg->idim)\n    goto err106;\n\n  /*\n   * Put surface into plane-equation.\n   * --------------------------------\n   */\n\n  s1329 (qkreg, epoint, enorm, idim, &qs, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /*\n   * Create new object and connect surface to object.\n   * ------------------------------------------------\n   */\n\n  if (!(qo1 = newObject (SISLSURFACE)))\n    goto err101;\n  qo1->s1 = qs;\n  qo1->o1 = qo1;\n\n  /*\n   * Create new object and connect point to object.\n   * ----------------------------------------------\n   */\n\n  if (!(qo2 = newObject (SISLPOINT)))\n    goto err101;\n  spoint[0] = DZERO;\n  if (!(qp = newPoint (spoint, kdim, 1)))\n    goto err101;\n  qo2->p1 = qp;\n\n  /*\n   * Find intersections.\n   * -------------------\n   */\n\n  sh1761 (qo1, qo2, aepsge, &qintdat, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Represent degenerated intersection curves as one point.  */\n\n  sh6degen(track_obj,track_obj,&qintdat,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  /* BUG BEOrd13026, simpli is now always in use, UJK */\n  /* Normalize plane normal */\n  \n  (void) s6norm (enorm, 3, snorm, &kstat);\n  \n  simpli[0] = snorm[0];\n  simpli[1] = snorm[1];\n  simpli[2] = snorm[2];\n  simpli[3] = -s6scpr (epoint, snorm, 3);\n       \n  \n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n       refine_all (&qintdat, track_obj, track_obj, simpli, kdeg, aepsge, &kstat);\n       if (kstat < 0)\n\t goto error;\n    }\n  \n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj, track_obj, simpli, kdeg,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n  \n  if (trackflag && qintdat)\n    {\n       make_tracks (track_obj, track_obj, kdeg, simpli,\n\t\t    qintdat->ilist, qintdat->vlist, \n\t\t    jtrack, wtrack, aepsge, &kstat);\n       if (kstat < 0)\n\t goto error;\n    }\n\n  /*\n   * Express intersections on output format.\n   * ---------------------------------------\n   */\n\n  if (qintdat)\t\t\t/* Only if there were intersections found */\n    {\n      hp_s1880 (track_obj, track_obj, kdeg,\n\t\t2, 0, qintdat, jpt, gpar, &spar, pretop, jcrv, wcurve, jsurf,wsurf,&kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /*\n   * Intersections found.\n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\nerr101:*jstat = -101;\n  s6err (\"sh1851\", *jstat, kpos);\n  goto out;\n\n  /* Dimensions conflicting.  */\n\nerr106:*jstat = -106;\n  s6err (\"sh1851\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\nerror:*jstat = kstat;\n  s6err (\"sh1851\", *jstat, kpos);\n  goto out;\n\nout:\n\n  /* Free allocated space.  */\n\n  if (spar)\n    freearray (spar);\n  if (qo1)\n    freeObject (qo1);\n  if (qo2)\n    freeObject (qo2);\n  if (qintdat)\n    freeIntdat (qintdat);\n  if (track_obj)\n    {\n       track_obj->s1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n\n  /* Free local surface.  */\n    if (qkreg != SISL_NULL && qkreg != ps1) freeSurf(qkreg);\n  \n  return;\n}\n\n\n"
  },
  {
    "path": "src/sh1852.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1852.c,v 1.2 2001-03-19 15:59:06 afr Exp $\n *\n */\n\n\n#define SH1852\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh1852(SISLSurf *ps1,double ecenter[],double aradius,\n\t    int idim,double aepsco,double aepsge,\n\t    int trackflag, int *jtrack, SISLTrack *** wtrack,\n\t    int *jpt,double **gpar,int **pretop,int *jcrv,\n\t    SISLIntcurve ***wcurve,int *jsurf, \n\t    SISLIntsurf *** wsurf, int *jstat)\n#else\nvoid sh1852(ps1,ecenter,aradius,idim,aepsco,aepsge,trackflag,jtrack,\n\t    wtrack,jpt,gpar,pretop,jcrv,wcurve,jsurf,wsurf,jstat)\n     SISLSurf     *ps1;\n     double   ecenter[];\n     double   aradius;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar; \n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jsurf;\n     SISLIntsurf ***wsurf;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a tensor-product surface\n*              and a sphere.\n*\n*\n*\n* INPUT      : ps1      - Pointer to surface.\n*              ecenter  - Center of the sphere.\n*              aradius  - Radius of the sphere.\n*              idim     - Dimension of the space in which the sphere lies.\n*              aepsco   - Computational resolution.\n*              aepsge   - Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       plane of the surface. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the surface are put into the equation of the\n*              sphere achieving a surface in the one-dimentional space.\n*              Then the zeroes of this surface is found.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1761 - Perform point object-intersection.\n*              s1320 - Put equation of surface into equation of implicit\n*                      surface.\n*              s1321 - Represent sphere as implicit function.\n*              make_sf_kreg   - Ensure k-regularity of surface.\n*              hp_s1880 - Put intersections on output format.\n*              newPoint    - Create new point.\n*              newObject - Create new object.\n*              freeIntdat  - Free space occupied by an intersection data.\n*              freeObject - Free space occupied by an object.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-06.\n* REWRITTEN BY : Bjoern Olav Hoset, SI, 89-06.\n*\n*********************************************************************\n*/\n{            \n  int kstat = 0;           /* Local status varible.                      */\n  int kpos = 0;            /* Position of error.                         */\n  int kdim = 1;            /* Dimension of space in which the point in the\n\t\t\t      intersect point/surface problem lies.      */\n  double *spar = SISL_NULL;     /* Dummy array containing parameter values of\n\t\t\t      second object of single intersection points.*/\n  double spoint[1];        /* SISLPoint to intersect with object.         */\n  double eps_1d;           /* The tolerance converted to 1D               */\n  int kdeg=2;              /* The degree of the implicit equation of the sphere*/\n  double *ssphere = SISL_NULL;  /* Description of sphere as implicit surface.  */\n  SISLSurf *qs = SISL_NULL;         /* Pointer to surface in \n\t\t\t      surface/point intersection.*/\n  SISLPoint *qp = SISL_NULL;        /* Pointer to point in \n\t\t\t      surface/point intersection.  */\n  SISLObject *qo1 = SISL_NULL;      /* Pointer to surface in \n\t\t\t      object/point intersection. */\n  SISLObject *qo2 = SISL_NULL;      /* Pointer to point in \n\t\t\t      object/point intersection    */\n  SISLIntdat *qintdat = SISL_NULL;  /* Intersection result */\n  SISLObject *track_obj=SISL_NULL;\n  SISLSurf *qkreg=SISL_NULL; /* Input surface ensured k-regularity. */\n\n  /* -------------------------------------------------------- */  \n\n  if (ps1->cuopen_1 == SISL_SURF_PERIODIC ||\n      ps1->cuopen_2 == SISL_SURF_PERIODIC)\n  {\n     /* Cyclic surface. */\n\n     make_sf_kreg(ps1,&qkreg,&kstat);\n     if (kstat < 0) goto error;\n   }\n  else\n    qkreg = ps1;\n  \n  /*\n  * Create new object and connect surface to object.\n  * ------------------------------------------------\n  */\n  \n  if (!(track_obj = newObject (SISLSURFACE)))\n    goto err101;\n  track_obj->s1 = ps1;\n  \n  /* \n   * Check dimension.  \n   * ----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if (idim != qkreg -> idim) goto err106;\n\n  /* \n   * Allocate space for matrix describing a hyper sphere.  \n   * ----------------------------------------------------\n   */\n\n  if ((ssphere = newarray((idim+1)*(idim+1),double)) == SISL_NULL) goto err101;\n\n  /* \n   * Make a matrix of dimension (idim+1)x(idim+1) describing a hyper\n   * sphere as an implicit function.                                 \n   * ---------------------------------------------------------------\n   */\n\n  s1321(ecenter,aradius,idim,1,ssphere,&kstat);\n  if (kstat < 0) goto error;\n\n  /* \n   * Put the description of the input surface into the implicit\n   * equation for the sphere.                                    \n   * ----------------------------------------------------------\n   */\n\n  s1320(qkreg,ssphere,1,0,&qs,&kstat);\n  if (kstat < 0) goto error;\n\n  /* \n   * Create new object and connect surface to object.  \n   * ------------------------------------------------\n   */\n\n  if(!(qo1 = newObject(SISLSURFACE))) goto err101;\n  qo1 -> s1 = qs;\n  qo1 -> o1 = qo1;\n\n  /*\n   * Create new object and connect point to object.\n   * ----------------------------------------------\n   */\n\n  if(!(qo2 = newObject(SISLPOINT))) goto err101;\n  spoint[0] = DZERO;\n  if(!(qp = newPoint(spoint,kdim,1))) goto err101;\n  qo2 -> p1 = qp;\n\n  /* \n   * Find intersections.  \n   * -------------------\n   */\n\n  /* UJK, 21.01.93, use another tolerance in 1D. */\n  eps_1d = 2*aradius*aepsge;\n  sh1761(qo1,qo2,eps_1d,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Represent degenerated intersection curves as one point.  */\n\n  sh6degen(track_obj,track_obj,&qintdat,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n \n      refine_all (&qintdat, track_obj, track_obj, ssphere, kdeg, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj, track_obj, ssphere, kdeg,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  if (trackflag && qintdat)\n    {\n      make_tracks (track_obj, track_obj, kdeg, ssphere,\n\t\t   qintdat->ilist, qintdat->vlist, \n\t\t   jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n     }\n\n  /* \n   * Express intersections on output format.  \n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(track_obj, track_obj, kdeg,\n\t       2,0,qintdat,jpt,gpar,&spar,pretop,jcrv,wcurve,jsurf,wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;\n        s6err(\"sh1852\",*jstat,kpos);\n        goto out;\n\n  /* Dimensions conflicting.  */\n\n err106: *jstat = -106;\n        s6err(\"sh1852\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n        s6err(\"sh1852\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if (spar)    freearray(spar);\n  if (ssphere) freearray(ssphere);\n  if (qo1)     freeObject(qo1);\n  if (qo2)     freeObject(qo2);\n  if (qintdat) freeIntdat(qintdat);\n  if (track_obj)\n    {\n       track_obj->s1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n\n  /* Free local surface.  */\n    if (qkreg != SISL_NULL && qkreg != ps1) freeSurf(qkreg);\n\nreturn;\n}                                               \n\n"
  },
  {
    "path": "src/sh1853.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1853.c,v 1.2 2001-03-19 15:59:06 afr Exp $\n *\n */\n\n\n#define SH1853\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh1853(SISLSurf *ps1,double epoint[],double edirec[],double aradius,\n\t    int idim, double aepsco,double aepsge,\n\t    int trackflag, int *jtrack, SISLTrack *** wtrack,\n\t    int *jpt,double **gpar,int **pretop,int *jcrv,\n\t    SISLIntcurve ***wcurve,int *jsurf, \n\t    SISLIntsurf *** wsurf, int *jstat)\n#else\nvoid sh1853(ps1,epoint,edirec,aradius,idim,aepsco,aepsge,trackflag,\n\t    jtrack,wtrack,jpt,gpar,pretop,jcrv,wcurve,jsurf,wsurf,jstat)\n     SISLSurf     *ps1;\n     double   epoint[];\n     double   edirec[];\n     double   aradius;\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jsurf;\n     SISLIntsurf ***wsurf;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a tensor-product surface\n*              and a cylinder.\n*\n*\n*\n* INPUT      : ps1      - Pointer to surface.\n*              epoint   - SISLPoint on the axis of the cylinder.\n*              edirec   - The direction vector of the axis of the cylinder.\n*              aradius  - Radius of the cylinder.\n*              idim     - Dimension of the space in which the cylinder lies.\n*              aepsco   - Computational resolution.\n*              aepsge   - Geometry resolution.\n*              trackflag - If true, create tracks.\n*                                                                        \n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       plane of the surface. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the surface are put into the equation of the\n*              cylinder achieving a surface in the one-dimentional space.\n*              Then the zeroes of this surface is found.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1761       - Perform point object-intersection.\n*              s1320       - Put equation of surface into equation of implicit\n*                            surface.\n*              s1322       - Represent cylinder as implicit function.\n*              hp_s1880       - Put intersections on output format.\n*              make_sf_kreg   - Ensure k-regularity of surface.\n*              newObject   - Create new object.\n*              newPoint    - Create new point.\n*              freeObject  - Free space occupied by an object.\n*              freeIntdat  - Free space occupied by an intersection data.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-06.\n* REWRITTEN BY : Bjoern Olav Hoset, SI, 89-06.\n*\n*********************************************************************\n*/\n{            \n  int kstat = 0;           /* Local status varible.                       */\n  int kpos = 0;            /* Position of error.                          */\n  int kdim = 1;            /* Dimension of space in which the point in the\n\t\t\t      intersect point/surface problem lies.       */\n  double *spar = SISL_NULL;     /* Dummy array containing parameter values of\n\t\t\t      second object of single intersection points.*/\n  double spoint[1];        /* SISLPoint to intersect with object.         */\n  double eps_1d;           /* The tolerance converted to 1D               */\n  int kdeg=2;              /* The degree of the implicit equation of the cyl*/\n  double *scyl = SISL_NULL;     /* Description of cylinder as implicit surface.*/\n  SISLSurf *qs = SISL_NULL;         /* Pointer to surface in \n\t\t\t      surface/point intersection.*/\n  SISLPoint *qp = SISL_NULL;        /* Pointer to point in \n\t\t\t      surface/point intersection.  */\n  SISLObject *qo1 = SISL_NULL;      /* Pointer to surface in \n\t\t\t      object/point intersection. */\n  SISLObject *qo2 = SISL_NULL;      /* Pointer to point in \n\t\t\t      object/point intersection    */\n  SISLIntdat *qintdat = SISL_NULL;  /* Intersection result */\n  SISLObject *track_obj=SISL_NULL;\n  SISLSurf *qkreg=SISL_NULL; /* Input surface ensured k-regularity. */\n\n  int ki;\n  double nmax=(double)1.0;\n  /* -------------------------------------------------------- */  \n\n  if (ps1->cuopen_1 == SISL_SURF_PERIODIC ||\n      ps1->cuopen_2 == SISL_SURF_PERIODIC)\n  {\n     /* Cyclic surface. */\n\n     make_sf_kreg(ps1,&qkreg,&kstat);\n     if (kstat < 0) goto error;\n   }\n  else\n    qkreg = ps1;\n  \n  \n  /*\n  * Create new object and connect surface to object.\n  * ------------------------------------------------\n  */\n  \n  if (!(track_obj = newObject (SISLSURFACE)))\n    goto err101;\n  track_obj->s1 = ps1;\n  \n  /* \n   * Check dimension.  \n   * ----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if (idim != qkreg -> idim) goto err106;\n\n  /* \n   * Allocate space for matrix describing a cylinder. \n   * ------------------------------------------------\n   */\n\n  if ((scyl = newarray((idim+1)*(idim+1),double)) == SISL_NULL) goto err101;\n\n  /* \n   * Make a matrix of dimension (idim+1)x(idim+1) describing a \n   * cylinder as an implicit function.                           \n   * ---------------------------------------------------------\n   */\n\n  s1322(epoint,edirec,aradius,idim,1,scyl,&kstat);\n  if (kstat < 0) goto error;\n\n  /* \n   * Put the description of the input surface into the implicit\n   * equation for the cylinder.                                   \n   * ----------------------------------------------------------\n   */\n\n  s1320(qkreg,scyl,1,0,&qs,&kstat);\n  if (kstat < 0) goto error;\n\n  /* \n   * Create new object and connect surface to object.  \n   * ------------------------------------------------\n   */\n\n  if(!(qo1 = newObject(SISLSURFACE))) goto err101;\n  qo1 -> s1 = qs;\n  qo1 -> o1 = qo1;\n\n  /*\n   * Create new object and connect point to object.\n   * ----------------------------------------------\n   */\n\n  if(!(qo2 = newObject(SISLPOINT))) goto err101;\n  spoint[0] = DZERO;\n  if(!(qp = newPoint(spoint,kdim,1))) goto err101;\n  qo2 -> p1 = qp;\n\n  /* \n   * Find intersections.  \n   * -------------------\n   */\n\n  /* UJK, 21.01.93, use another tolerance in 1D. */\n  eps_1d = 2*aradius*aepsge;\n\n  /* UJK,sept 93, Normalize to get angle tolerances correct */\n  for(ki=0; ki<qs->in1*qs->in2;ki++)\n     nmax = max(fabs(qs->ecoef[ki]),nmax);\n  \n  if (nmax >(double)10.0)\n  {\n     for(ki=0; ki<qs->in1*qs->in2;ki++)\n        qs->ecoef[ki] /= nmax;\n     eps_1d = eps_1d/nmax;\n  }\n  \n  /* UJK,sept 93, End of change */\n  \n  sh1761(qo1,qo2,eps_1d,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Represent degenerated intersection curves as one point.  */\n\n  sh6degen(track_obj,track_obj,&qintdat,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n \n      refine_all (&qintdat, track_obj, track_obj, scyl, kdeg, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n    }\n  \n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj, track_obj, scyl, kdeg,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n      make_tracks (track_obj, track_obj, kdeg, scyl,\n\t\t   qintdat->ilist, qintdat->vlist, \n\t\t   jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* \n   * Express intersections on output format.  \n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(track_obj, track_obj, kdeg,\n\t       2,0,qintdat,jpt,gpar,&spar,pretop,jcrv,wcurve,jsurf,wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;\n        s6err(\"sh1853\",*jstat,kpos);\n        goto out;\n\n  /* Dimensions conflicting.  */\n\n err106: *jstat = -106;\n        s6err(\"sh1853\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n        s6err(\"sh1853\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if (spar)    freearray(spar);\n  if (scyl)    freearray(scyl);\n  if (qo1)     freeObject(qo1);\n  if (qo2)     freeObject(qo2);\n  if (qintdat) freeIntdat(qintdat);\n  if (track_obj)\n    {\n       track_obj->s1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n\n  /* Free local surface.  */\n    if (qkreg != SISL_NULL && qkreg != ps1) freeSurf(qkreg);\n\nreturn;\n}                                               \n\n"
  },
  {
    "path": "src/sh1854.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1854.c,v 1.2 2001-03-19 15:59:06 afr Exp $\n *\n */\n\n\n#define SH1854\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \nsh1854(SISLSurf *ps1,double etop[],double eaxis[],double econe[],int idim,\n       double aepsco,double aepsge,\n       int trackflag, int *jtrack, SISLTrack *** wtrack,\n       int *jpt,double **gpar,int **pretop,int *jcrv,SISLIntcurve ***wcurve,\n       int *jsurf, SISLIntsurf *** wsurf, int *jstat)\n#else\nvoid sh1854(ps1,etop,eaxis,econe,idim,aepsco,aepsge,trackflag,jtrack,\n\t    wtrack,jpt,gpar,pretop,jcrv,wcurve,jsurf,wsurf,jstat)\n     SISLSurf     *ps1;\n     double   etop[];\n     double   eaxis[];\n     double   econe[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jsurf;\n     SISLIntsurf ***wsurf;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a tensor-product surface\n*              and a cone.\n*\n*\n*\n* INPUT      : ps1      - Pointer to surface.\n*              etop     - Top point of the cone.\n*              eaxis    - SISLPoint on the axis of the cone. eaxis is not\n*                         equal to etop.\n*              econe    - SISLPoint on the cone surface. econe is not equal\n*                         to etop.\n*              idim     - Dimension of the space in which the cone lies.\n*              aepsco   - Computational resolution.\n*              aepsge   - Geometry resolution.\n*              trackflag - If true, create tracks.\n*                                                                        \n*                                                                        \n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       plane of the surface. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the surface are put into the equation of \n*              the cone achieving a surface in the one-dimentional space.\n*              Then the zeroes of this surface is found.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1761       - Perform point object-intersection.\n*              s1320       - Put equation of surface into equation of implicit\n*                            surface.\n*              s1323       - Represent cone as implicit function.\n*              make_sf_kreg   - Ensure k-regularity of surface.\n*              hp_s1880       - Put intersections on output format.\n*              newObject   - Create new object.\n*              newPoint    - Create new point.\n*              freeObject  - Free space occupied by an object.\n*              freeIntdat  - Free space occupied by an intersection data.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-06.\n* REWRITTEN BY : Bjoern Olav Hoset, SI, 89-06.\n*\n*********************************************************************\n*/\n{            \n  int kstat = 0;           /* Local status varible.                        */\n  int kpos = 0;            /* Position of error.                           */\n  int kdim = 1;            /* Dimension of space in which the point in the\n\t\t\t      intersect point/surface problem lies.        */\n  double *spar = SISL_NULL;     /* Dummy array containing parameter values of\n\t\t\t      second object of single intersection points. */\n  double spoint[1];        /* SISLPoint to intersect with object.              */\n  int kdeg=2;              /* The degree of the implicit equation of the cone*/\n  double *scone = SISL_NULL;    /* Description of a cone as implicit surface. */\n  SISLSurf *qs = SISL_NULL;         /* Pointer to surface in \n\t\t\t      surface/point intersection.*/\n  SISLPoint *qp = SISL_NULL;        /* Pointer to point in \n\t\t\t      surface/point intersection.  */\n  SISLObject *qo1 = SISL_NULL;      /* Pointer to surface in \n\t\t\t      object/point intersection. */\n  SISLObject *qo2 = SISL_NULL;      /* Pointer to point in \n\t\t\t      object/point intersection    */\n  SISLIntdat *qintdat = SISL_NULL;  /* Intersection result */\n  SISLObject *track_obj=SISL_NULL;\n  SISLSurf *qkreg=SISL_NULL; /* Input surface ensured k-regularity. */\n\n  /* -------------------------------------------------------- */  \n\n  if (ps1->cuopen_1 == SISL_SURF_PERIODIC ||\n      ps1->cuopen_2 == SISL_SURF_PERIODIC)\n  {\n     /* Cyclic surface. */\n\n     make_sf_kreg(ps1,&qkreg,&kstat);\n     if (kstat < 0) goto error;\n   }\n  else\n    qkreg = ps1;\n  \n  /*\n  * Create new object and connect surface to object.\n  * ------------------------------------------------\n  */\n  \n  if (!(track_obj = newObject (SISLSURFACE)))\n    goto err101;\n  track_obj->s1 = ps1;\n\n  /* \n   * Check dimension.  \n   * ----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if (idim != qkreg -> idim) goto err106;\n\n  /* \n   * Allocate space for matrix describing a cone.  \n   * --------------------------------------------\n   */\n\n  if ((scone = newarray((idim+1)*(idim+1),double)) == SISL_NULL) goto err101;\n\n  /* \n   * Make a matrix of dimension (idim+1)x(idim+1) describing a \n   * cone as an implicit function.                             \n   * ---------------------------------------------------------\n   */\n\n  s1323(etop,eaxis,econe,idim,1,scone,&kstat);\n  if (kstat < 0) goto error;\n\n  /* \n   * Put the description of the input surface into the implicit\n   * equation for the cone.                                       \n   * ----------------------------------------------------------\n   */\n\n  s1320(qkreg,scone,1,0,&qs,&kstat);\n  if (kstat < 0) goto error;\n\n  /* \n   * Create new object and connect surface to object.  \n   * ------------------------------------------------\n   */\n\n  if(!(qo1 = newObject(SISLSURFACE))) goto err101;\n  qo1 -> s1 = qs;\n  qo1 -> o1 = qo1;\n  \n  /*\n   * Create new object and connect point to object.\n   * ----------------------------------------------\n   */\n\n  if (!(qo2 = newObject(SISLPOINT))) goto err101;\n  spoint[0] = DZERO;\n  if (!(qp = newPoint(spoint,kdim,1))) goto err101;\n  qo2 -> p1 = qp;\n\n  /* \n   * Find intersections.  \n   * -------------------\n   */\n\n  sh1761(qo1,qo2,aepsge,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Represent degenerated intersection curves as one point.  */\n\n  sh6degen(track_obj,track_obj,&qintdat,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n \n      refine_all (&qintdat, track_obj, track_obj, scone, kdeg, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n    }\n\n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj, track_obj, scone, kdeg,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n  \n  if (trackflag && qintdat)\n    {\n \n      make_tracks (track_obj, track_obj, kdeg, scone,\n\t\t   qintdat->ilist, qintdat->vlist, \n\t\t   jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n    }\n\n  /* \n   * Express intersections on output format.  \n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(track_obj, track_obj, kdeg,\n\t       2,0,qintdat,jpt,gpar,&spar,pretop,jcrv,wcurve,jsurf,wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;\n        s6err(\"sh1854\",*jstat,kpos);\n        goto out;\n\n  /* Dimensions conflicting.  */\n\n err106: *jstat = -106;\n        s6err(\"sh1854\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n        s6err(\"sh1854\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if (spar)    freearray(spar);\n  if (scone)   freearray(scone);\n  if (qo1)     freeObject(qo1);\n  if (qo2)     freeObject(qo2);\n  if (qintdat) freeIntdat(qintdat);\n  if (track_obj)\n    {\n       track_obj->s1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n\n  /* Free local surface.  */\n    if (qkreg != SISL_NULL && qkreg != ps1) freeSurf(qkreg);\n\nreturn;\n}                                               \n\n"
  },
  {
    "path": "src/sh1855.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1855.c,v 1.2 2001-03-19 15:59:06 afr Exp $\n *\n */\n\n\n#define SH1855\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \nsh1855(SISLSurf *ps1,double ecentr[],double aradius,\n\t   double enorm[],int idim,double aepsco,double aepsge,\n\tint trackflag, int *jtrack, SISLTrack *** wtrack,\n\t   int *jpt,double **gpar,int **pretop,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid sh1855(ps1,ecentr,aradius,enorm,idim,aepsco,aepsge,\n\ttrackflag,jtrack,wtrack,jpt,gpar,pretop,jcrv,wcurve,jstat)\n     SISLSurf     *ps1;\n     double   ecentr[];\n     double   aradius;\n     double   enorm[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a tensor-product surface\n*              and a circle.\n*\n*\n*\n* INPUT      : ps1      - Pointer to surface.\n*              ecentr   - Center of the circle.\n*              aradius  - Radius of the circle.\n*              enorm    - Normal vector to the plane in which the circle\n*                         lies.\n*              idim     - Dimension of the space in which the circle lies.\n*              aepsco   - Computational resolution.\n*              aepsge   - Geometry resolution.\n*              trackflag - If true, create tracks.\n*                                                                        \n*                                                                        \n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       plane of the surface. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The vertices of the surface are put into the equation of \n*              the circle achieving a surface in the two-dimentional space.\n*              Then the zeroes of this surface is found.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1761 - Perform point object-intersection.\n*              s1320 - Put equation of surface into equation of implicit\n*                      surface.\n*              s1324 - Represent circel as two implicit functions.\n*              make_sf_kreg   - Ensure k-regularity of surface.\n*              hp_s1880 - Put intersections on output format.\n*              newObject - Create new object.\n*              newPoint    - Create new point.\n*              freeObject - Free space occupied by an object.\n*              freeIntdat  - Free space occupied by an intersection data.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-06.\n*\n*********************************************************************\n*/\n{            \n  double *nullp = SISL_NULL;\n  int kstat = 0;              /* Local status varible.                     */\n  int kpos = 0;               /* Position of error.                        */\n  int kdim = 2;               /* Dimension of space in which the point in the\n\t\t\t\t intersect point/surface problem lies.      */\n  double *spar = SISL_NULL;        /* Dummy array containing parameter values of\n\t\t\t\t second object of single intersection points.*/\n  double spoint[2];           /* SISLPoint to intersect with object.           */\n  double *scirc = SISL_NULL;       /* Description of a circel as two implicit \n\t\t\t\t functions.                                */\n  SISLSurf *qs = SISL_NULL;            /* Pointer to surface in \n\t\t\t\t surface/point intersection.*/\n  SISLPoint *qp = SISL_NULL;           /* Pointer to point in \n\t\t\t\t surface/point intersection.  */\n  SISLObject *qo1 = SISL_NULL;         /* Pointer to surface in \n\t\t\t\t object/point intersection. */\n  SISLObject *qo2 = SISL_NULL;         /* Pointer to point in \n\t\t\t\t object/point intersection    */\n  SISLIntdat *qintdat = SISL_NULL;     /* Intersection result */\n  int      ksurf=0;         /* Dummy number of Intsurfs. */\n  SISLIntsurf **wsurf=SISL_NULL;    /* Dummy array of Intsurfs. */\n  int      kdeg=2000;       /* input to int_join_per. */\n  SISLObject *track_obj=SISL_NULL;\n  SISLSurf *qkreg=SISL_NULL; /* Input surface ensured k-regularity. */\n\n  /* -------------------------------------------------------- */  \n\n  if (ps1->cuopen_1 == SISL_SURF_PERIODIC ||\n      ps1->cuopen_2 == SISL_SURF_PERIODIC)\n  {\n     /* Cyclic surface. */\n\n     make_sf_kreg(ps1,&qkreg,&kstat);\n     if (kstat < 0) goto error;\n   }\n  else\n    qkreg = ps1;\n  \n  /*\n  * Create new object and connect surface to object.\n  * ------------------------------------------------\n  */\n  \n  if (!(track_obj = newObject (SISLSURFACE)))\n    goto err101;\n  track_obj->s1 = ps1;\n  \n\n  /* \n   * Check dimension.  \n   * ----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if (idim != qkreg -> idim) goto err106;\n\n  /* \n   * Allocate space for matrix describing a cone.  \n   * --------------------------------------------\n   */\n\n  if ((scirc = newarray(2*(idim+1)*(idim+1),double)) == SISL_NULL) goto err101;\n\n  /* \n   * Make a matrix of dimension (idim+1)x(idim+1) describing a \n   * cone as an implicit function.                             \n   * ---------------------------------------------------------\n   */\n\n  s1324(ecentr,aradius,enorm,idim,scirc,&kstat);\n  if (kstat < 0) goto error;\n\n  /* \n   * Put the description of the input surface into the implicit\n   * equation for the cone.                                       \n   * ----------------------------------------------------------\n   */\n\n  s1320(qkreg,scirc,2,0,&qs,&kstat);\n  if (kstat < 0) goto error;\n\n  /* \n   * Create new object and connect surface to object.  \n   * ------------------------------------------------\n   */\n\n  if(!(qo1 = newObject(SISLSURFACE))) goto err101;\n  qo1 -> s1 = qs;\n  qo1 -> o1 = qo1;\n  \n  /*\n   * Create new object and connect point to object.\n   * ----------------------------------------------\n   */\n\n  if(!(qo2 = newObject(SISLPOINT))) goto err101;\n  spoint[0] = spoint[1] = DZERO;\n  if(!(qp = newPoint(spoint,kdim,1))) goto err101;\n  qo2 -> p1 = qp;\n\n  /* \n   * Find intersections.  \n   * -------------------\n   */\n\n  sh1761(qo1,qo2,aepsge,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Represent degenerated intersection curves as one point.  */\n\n  sh6degen(track_obj,track_obj,&qintdat,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj,track_obj,nullp,kdeg,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n      make_tracks (qo1, qo2, 0, nullp,\n\t\t   qintdat->ilist, qintdat->vlist,\n\t\t   jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* \n   * Express intersections on output format.  \n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(track_obj, track_obj, kdeg,\n\t       2,0,qintdat,jpt,gpar,&spar,pretop,jcrv,wcurve,&ksurf,&wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;\n        s6err(\"sh1855\",*jstat,kpos);\n        goto out;\n\n  /* Dimensions conflicting.  */\n\n err106: *jstat = -106;\n        s6err(\"sh1855\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n        s6err(\"sh1855\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if (spar)    freearray(spar);\n  if (scirc)   freearray(scirc);\n  if (qo1)     freeObject(qo1);\n  if (qo2)     freeObject(qo2);\n  if (qintdat) freeIntdat(qintdat);\n  if (track_obj)\n    {\n       track_obj->s1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n\n  /* Free local surface.  */\n    if (qkreg != SISL_NULL && qkreg != ps1) freeSurf(qkreg);\n\nreturn;\n}                                               \n\n"
  },
  {
    "path": "src/sh1856.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1856.c,v 1.2 2001-03-19 15:59:06 afr Exp $\n *\n */\n\n\n#define SH1856\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh1856(SISLSurf *ps1,double epoint[],double edir[],int idim,\n\t    double aepsco,double aepsge,\n\t    int trackflag, int *jtrack, SISLTrack *** wtrack,\n\t    int *jpt,double **gpar,int **pretop,int *jcrv,\n\t    SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid sh1856(ps1,epoint,edir,idim,aepsco,aepsge,\n\t    trackflag,jtrack,wtrack,jpt,gpar,pretop,jcrv,wcurve,jstat)\n     SISLSurf     *ps1;\n     double   epoint[];\n     double   edir[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a tensor-product surface\n*              and an infinite straight line.\n*\n*\n*\n* INPUT      : ps1    - Pointer to surface.\n*              epoint - SISLPoint on the line.\n*              edir   - Direction vector of the line.\n*              idim   - Dimension of the space in which the line lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       plane of the surface. The points lie continuous. \n*                       Intersection curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              *jcrv  - Number of intersection curves.\n*              wcurve  - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The line is described as the intersection between two\n*              planes. The vertices of the surface are put into the equation \n*              of this planes achieving a surface in the two-dimentional \n*              space. Then the zeroes of this surface is found.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1761 - Perform point object-intersection.\n*              s1328 - Equation of surface into equations of two planes.\n*              s1329 - Equation of surface into equation of plane.\n*              make_sf_kreg   - Ensure k-regularity of surface.\n*              hp_s1880 - Put intersections on output format.\n*              s6twonorm - Make two vectors of length one that are normal\n*                          to a 3d input vector.\n*              newPoint    - Create new point.\n*              newObject - Create new object.\n*              freeObject - Free space occupied by an object.\n*              freeIntdat  - Free space occupied by an intersection data.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-06.\n* REWRITTEN BY : Bjoern Olav Hoset, SI, 89-06.\n*\n*********************************************************************\n*/\n{            \n  double *nullp = SISL_NULL;\n  int kstat = 0;           /* Local status varible.                        */\n  int kpos = 0;            /* Position of error.                           */\n  int kdim;                /* Dimension of space in which the point in the\n\t\t\t      intersect point and surface problem lies.    */\n  double *spar = SISL_NULL;     /* Dummy array containing parameter values of\n\t\t\t      second object of single intersection points. */\n  double spoint[2];        /* SISLPoint to intersect with object.              */\n  double *snorm1 = SISL_NULL;   /* Normal to direction vector of line.          */\n  double *snorm2 = SISL_NULL;   /* Normal to direction vector of line and snorm1.*/\n  SISLSurf *qs = SISL_NULL;         /* Pointer to surface in \n\t\t\t      surface/point intersection.*/\n  SISLPoint *qp = SISL_NULL;        /* Pointer to point in \n\t\t\t      surface/point intersection.  */\n  SISLObject *qo1 = SISL_NULL;      /* Pointer to surface in \n\t\t\t      object/point intersection. */\n  SISLObject *qo2 = SISL_NULL;      /* Pointer to point in \n\t\t\t      object/point intersection    */\n  SISLIntdat *qintdat = SISL_NULL;  /* Intersection result */\n  int      ksurf=0;         /* Dummy number of Intsurfs. */\n  SISLIntsurf **wsurf=SISL_NULL;    /* Dummy array of Intsurfs. */\n  int      kdeg=2000;       /* input to int_join_per. */\n  SISLObject *track_obj=SISL_NULL;\n  SISLSurf *qkreg=SISL_NULL; /* Input surface ensured k-regularity. */\n\n  /* -------------------------------------------------------- */  \n\n  if (ps1->cuopen_1 == SISL_SURF_PERIODIC ||\n      ps1->cuopen_2 == SISL_SURF_PERIODIC)\n  {\n     /* Cyclic surface. */\n\n     make_sf_kreg(ps1,&qkreg,&kstat);\n     if (kstat < 0) goto error;\n   }\n  else\n    qkreg = ps1;\n  \n  /*\n  * Create new object and connect surface to object.\n  * ------------------------------------------------\n  */\n  \n  if (!(track_obj = newObject (SISLSURFACE)))\n    goto err101;\n  track_obj->s1 = ps1;\n\n  /* \n   * Check dimension.  \n   * ----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if (idim != 2 && idim != 3) goto err105;\n  if (idim != qkreg -> idim) goto err106;\n\n  /* \n   * Allocate space for normal vectors.  \n   * ----------------------------------\n   */\n\n  snorm1 = newarray(idim,double);\n  snorm2 = newarray(idim,double);\n  if (snorm1 == SISL_NULL || snorm2 == SISL_NULL) goto err101;\n\n  if (idim == 3)\n    {\n\n      /* \n       * Find two planes that intersect in the given line.  \n       * -------------------------------------------------\n       */\n\n      s6twonorm(edir,snorm1,snorm2,&kstat);\n      if (kstat < 0) goto error;\n\n      /* \n       * Put the surface into the plane equations.  \n       * -----------------------------------------\n       */\n\n      s1328(qkreg,epoint,snorm1,snorm2,idim,&qs,&kstat);\n      if (kstat < 0) goto error;\n\n      /*\n       * Create new object and connect point to object.\n       * ----------------------------------------------\n       */\n\n      kdim      = 2;\n      spoint[0] = spoint[1] = DZERO;\n      if (!(qo2  = newObject(SISLPOINT))) goto err101;\n      if (!(qp   = newPoint(spoint,kdim,1))) goto err101;\n      qo2 -> p1 = qp;\n    }\n  else if (idim == 2)\n    {\n\n      /* \n       * Find normal vector of line.  \n       * ---------------------------\n       */\n\n      snorm1[0] = edir[1];\n      snorm1[1] = (-1)*edir[0];\n\n      /* \n       * Put surface into line-equation.  \n       * -------------------------------\n       */\n\n      s1329(qkreg,epoint,snorm1,idim,&qs,&kstat);\n      if (kstat < 0) goto error;\n\n      /*\n       * Create new object and connect point to object.\n       * ----------------------------------------------\n       */\n\n      kdim      = 1;\n      spoint[0] = DZERO;\n      if (!(qo2  = newObject(SISLPOINT))) goto err101;\n      if (!(qp   = newPoint(spoint,kdim,1))) goto err101;\n      qo2 -> p1 = qp;\n    }\n\n  /* \n   * Create new object and connect surface to object.  \n   * ------------------------------------------------\n   */\n\n  if(!(qo1 = newObject(SISLSURFACE))) goto err101;\n  qo1 -> s1 = qs;\n  qo1 -> o1 = qo1;\n\n  /* \n   * Find intersections.  \n   * -------------------\n   */\n\n  sh1761(qo1,qo2,aepsge,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Represent degenerated intersection curves as one point.  */\n\n  sh6degen(track_obj,track_obj,&qintdat,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj,track_obj,nullp,kdeg,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n      make_tracks (qo1, qo2, 0, nullp,\n\t\t   qintdat->ilist, qintdat->vlist,\n\t\t   jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* \n   * Express intersections on output format.  \n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(track_obj, track_obj, kdeg,\n\t       2,0,qintdat,jpt,gpar,&spar,pretop,jcrv,wcurve,&ksurf,&wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;\n        s6err(\"sh1856\",*jstat,kpos);\n        goto out;\n\n  /* Error in input. Dimension different from two or three.  */\n\n err105: *jstat = -105;\n        s6err(\"sh1856\",*jstat,kpos);\n        goto out;\n\n  /* Dimensions conflicting.  */\n\n err106: *jstat = -106;\n        s6err(\"sh1856\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n        s6err(\"sh1856\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if (snorm1)  freearray(snorm1);\n  if (snorm2)  freearray(snorm2);\n  if (spar)    freearray(spar);\n  if (qo1)     freeObject(qo1);\n  if (qo2)     freeObject(qo2);\n  if (qintdat) freeIntdat(qintdat);\n  if (track_obj)\n    {\n       track_obj->s1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n\n  /* Free local surface.  */\n    if (qkreg != SISL_NULL && qkreg != ps1) freeSurf(qkreg);\n\nreturn;\n}                                               \n\n"
  },
  {
    "path": "src/sh1857.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1857.c,v 1.2 2001-03-19 15:59:06 afr Exp $\n *\n */\n\n\n#define SH1857\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n     sh1857(SISLCurve *pc1,SISLCurve *pc2,double aepsco,double aepsge,\n\tint trackflag, int *jtrack, SISLTrack *** wtrack,\n\t   int *jpt,double **gpar1,double **gpar2,int **pretop,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid sh1857(pc1,pc2,aepsco,aepsge,\n\ttrackflag,jtrack,wtrack,jpt,gpar1,gpar2,pretop,jcrv,wcurve,jstat)\n     SISLCurve    *pc1;\n     SISLCurve    *pc2;    \n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar1;\n     double   **gpar2;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between two B-spline curves.\n*\n*\n*\n* INPUT      : pc1    - Pointer to first curve.\n*              pc2    - Pointer to second curve.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar1  - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the first curve. The points lie \n*                       continuous. Intersection curves are stored in wcurve.\n*              gpar2  - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the second curve.\n*              pretop - Topology info. for single intersection points.\n*              jcrv   - Number of intersection curves.\n*              wcurve - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*                       If the curves given as input are degnenerate an\n*                       intersection point can be returned as an intersection\n*                       curve. Use s1327 to decide if an intersection curve\n*                       is a point on one of the curves.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The curves are subdivided until we have a simple problem\n*              where the intersection can be found by iteration. Then\n*              Newton iteration is used.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1761      - Perform object/object-intersection.\n*              hp_s1880      - Put intersections on output format.\n*              newObject  - Create new object.\n*              freeObject - Free space occupied by an object.\n*              freeIntdat - Free space occupied by the intdat structure.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-10.\n* REWRITTEN BY : B.O. Hoset, SI, 89-06.\n*\n*********************************************************************\n*/\n{            \n  double *nullp = SISL_NULL;\n  int kstat = 0;                 /* Local status variable.                   */\n  int kpos = 0;                  /* Position of error.                       */\n  SISLObject *qo1 = SISL_NULL;            /* Object containing first curve in \n\t\t\t\t    the intersection.                        */\n  SISLObject *qo2 = SISL_NULL;            /* Object containing second curve in \n\t\t\t\t    the intersection.                        */\n  SISLIntdat *qintdat = SISL_NULL;       /* Structure holding the intersection data. */\n  int      ksurf=0;         /* Dummy number of Intsurfs. */\n  SISLIntsurf **wsurf=SISL_NULL;    /* Dummy array of Intsurfs. */\n  int kdeg=0;\n  \n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  /* \n   * Check dimensions.  \n   * -----------------\n   */\n\n  if (pc1 -> idim != pc2 -> idim) goto err106;\n\n  /* \n   * Create objects and connect curves to the objects.  \n   * -------------------------------------------------\n   */\n\n  if ((qo1 = newObject(SISLCURVE)) == SISL_NULL) goto err101;\n  qo1 -> c1 = pc1;\n  qo1 -> o1 = qo1;\n  \n  if ((qo2 = newObject(SISLCURVE)) == SISL_NULL) goto err101;\n  qo2 -> c1 = pc2;\n  qo2 -> o1 = qo2;\n  \n  /* \n   * Find intersections.  \n   * -------------------\n   */\n\n  sh1761(qo1,qo2,aepsge,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Join periodic curves */\n  int_join_per( &qintdat,qo1,qo2,nullp,kdeg=0,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n      make_tracks (qo1, qo2, 0, nullp,\n\t\t   qintdat->ilist, qintdat->vlist, \n\t\t   jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* \n   * Express intersections on output format.  \n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(qo1, qo2, kdeg,\n\t       1,1,qintdat,jpt,gpar1,gpar2,pretop,jcrv,wcurve,&ksurf,&wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* \n   * Error in space allocation.  \n   * --------------------------\n   */\n\n err101: *jstat = -101;                \n        s6err(\"sh1857\",*jstat,kpos);\n        goto out;\n\n  /* Dimensions conflicting.  */\n\n err106: *jstat = -106;\n        s6err(\"sh1857\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n        s6err(\"sh1857\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* \n   * Free allocated space.  \n   * ---------------------\n   */\n\n  if (qo1) \n    {\n      qo1 -> c1 = SISL_NULL;  freeObject(qo1);\n    }\n  if (qo2) \n    {\n      qo2 -> c1 = SISL_NULL;  freeObject(qo2);\n    }\n  if (qintdat) freeIntdat(qintdat);\n\n  /*\n   * Exit sh1857.\n   * -----------\n   */\n                                        \nreturn;\n}                                               \n\n"
  },
  {
    "path": "src/sh1858.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1858.c,v 1.2 2001-03-19 15:59:06 afr Exp $\n *\n */\n\n\n#define SH1858\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \nsh1858(SISLSurf *ps1,SISLCurve *pc1,double aepsco,double aepsge,\n\tint trackflag, int *jtrack, SISLTrack *** wtrack,\n\t   int *jpt,double **gpar1,double **gpar2,int **pretop,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid sh1858(ps1,pc1,aepsco,aepsge,trackflag,jtrack,wtrack,jpt,\n\t    gpar1,gpar2,pretop,jcrv,wcurve,jstat)\n     SISLSurf     *ps1;\n     SISLCurve    *pc1;    \n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar1;\n     double   **gpar2;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a B-spline surface\n*              and a B-spline curve.\n*\n*\n*\n* INPUT      : ps1    - Pointer to the surface.\n*              pc1    - Pointer to the curve.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar1  - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the first curve. The points lie \n*                       continuous. Intersection curves are stored in wcurve.\n*              gpar2  - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the second curve.\n*              pretop - Topology info. for single intersection points.\n*              jcrv   - Number of intersection curves.\n*              wcurve - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*                       If the curves given as input are degnenerate an\n*                       intersection point can be returned as an intersection\n*                       curve. Use s1327 to decide if an intersection curve\n*                       is a point on one of the curves.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1761      - Perform object/object-intersection.\n*              hp_s1880      - Put intersections on output format.\n*              newObject  - Create new object.\n*              freeObject - Free space occupied by an object.\n*              freeIntdat - Free space occupied by the intdat structure.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-10.\n* REWRITTEN BY : B.O. Hoset, SI, 89-06.\n*\n*********************************************************************\n*/\n{            \n  double *nullp = SISL_NULL;\n  int kstat = 0;                 /* Local status variable.                   */\n  int kpos = 0;                  /* Position of error.                       */\n  SISLObject *qo1 = SISL_NULL;            /* Object containing first curve in \n\t\t\t\t    the intersection.                        */\n  SISLObject *qo2 = SISL_NULL;            /* Object containing second curve in \n\t\t\t\t    the intersection.                        */\n  SISLIntdat *qintdat = SISL_NULL;        /* Structure holding the intersection data. */\n  int      ksurf=0;         /* Dummy number of Intsurfs. */\n  SISLIntsurf **wsurf=SISL_NULL;    /* Dummy array of Intsurfs. */\n  int kdeg=0;\n  \n  /* \n   * Check dimensions.  \n   * -----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if (ps1 -> idim != pc1 -> idim) goto err106;\n\n  /* \n   * Create objects and connect surface/curve to the objects.  \n   * --------------------------------------------------------\n   */\n\n  if ((qo1 = newObject(SISLSURFACE)) == SISL_NULL) goto err101;\n  qo1 -> s1 = ps1;\n  qo1 -> o1 = qo1;\n  \n  if ((qo2 = newObject(SISLCURVE)) == SISL_NULL) goto err101;\n  qo2 -> c1 = pc1;\n  qo2 -> o1 = qo2;\n  \n  /* \n   * Find intersections.  \n   * -------------------\n   */\n\n  sh1761(qo1,qo2,aepsge,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Represent degenerated intersection curves as one point.  */\n\n  sh6degen(qo1,qo2,&qintdat,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Join periodic curves */\n  int_join_per( &qintdat,qo1,qo2,nullp,kdeg=0,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n      make_tracks (qo1, qo2, 0, nullp,\n\t\t   qintdat->ilist, qintdat->vlist, \n\t\t   jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n    }\n\n  /* \n   * Express intersections on output format.  \n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(qo1, qo2, kdeg,\n\t       2,1,qintdat,jpt,gpar1,gpar2,pretop,jcrv,wcurve,&ksurf,&wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* \n   * Error in space allocation.  \n   * --------------------------\n   */\n\n err101: *jstat = -101;                \n        s6err(\"sh1858\",*jstat,kpos);\n        goto out;\n\n  /* Dimensions conflicting.  */\n\n err106: *jstat = -106;\n  s6err(\"sh1858\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n        s6err(\"sh1858\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* \n   * Free allocated space.  \n   * ---------------------\n   */\n\n  if (qo1) \n    {\n      qo1 -> s1 = SISL_NULL;  freeObject(qo1);\n    }\n  if (qo2) \n    {\n      qo2 -> c1 = SISL_NULL;  freeObject(qo2);\n    }\n  if (qintdat) freeIntdat(qintdat);\n\n  /*\n   * Exit sh1858.\n   * -----------\n   */\n                                        \n  return;\n}                                               \n\n"
  },
  {
    "path": "src/sh1859.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1859.c,v 1.4 2003-01-10 12:55:15 vsk Exp $\n *\n */\n\n\n#define SH1859\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh1859 (SISLSurf * ps1, SISLSurf * ps2, double aepsco, double aepsge,\n\tint trackflag, int *jtrack, SISLTrack *** wtrack,\n\tint *jpt, double **gpar1, double **gpar2, int **pretop, int *jcrv, SISLIntcurve *** wcurve, int *jsurf, SISLIntsurf *** wsurf, int *jstat)\n#else\nvoid \nsh1859 (ps1, ps2, aepsco, aepsge,\n\ttrackflag, jtrack, wtrack, jpt, gpar1, gpar2, pretop, jcrv, wcurve,jsurf,wsurf, jstat)\n     SISLSurf *ps1;\n     SISLSurf *ps2;\n     double aepsco;\n     double aepsge;\n     int trackflag;\n     int *jtrack;\n     SISLTrack ***wtrack;\n     int *jpt;\n     double **gpar1;\n     double **gpar2;\n     int **pretop;\n     int *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jsurf;\n     SISLIntsurf ***wsurf;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find all intersections between two B-spline surfaces.\n*\n*\n*\n* INPUT      : ps1    - Pointer to first surface.\n*              ps2    - Pointer to second surface.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar1  - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the first curve. The points lie\n*                       continuous. Intersection curves are stored in wcurve.\n*              gpar2  - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the second curve.\n*              pretop - Topology info. for single intersection points.\n*              jcrv   - Number of intersection curves.\n*              wcurve - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*                       If the curves given as input are degnenerate an\n*                       intersection point can be returned as an intersection\n*                       curve. Use s1327 to decide if an intersection curve\n*                       is a point on one of the curves.\n*              jstat  - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : The curves are subdivided until we have a simple problem\n*              where the intersection can be found by iteration. Then\n*              Newton iteration is used.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1761      - Perform object/object-intersection.\n*              hp_s1880      - Put intersections on output format.\n*              newObject  - Create new object.\n*              freeObject - Free space occupied by an object.\n*              freeIntdat - Free space occupied by the intdat structure.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-10.\n* REWRITTEN BY : B.O. Hoset, SI, 89-06.\n* REWRITTEN BY : Ulf J. Krystad, SI, 91-06.\n*\n*********************************************************************\n*/\n{\n  double *nullp = SISL_NULL;\n  int kstat = 0;\t\t/* Local status variable.                   */\n  int kpos = 0;\t\t\t/* Position of error.                       */\n  SISLObject *qo1 = SISL_NULL;\t/* Object containing first curve in\n\t\t\t       the intersection.                        */\n  SISLObject *qo2 = SISL_NULL;\t/* Object containing second curve in\n\t\t\t       the intersection.                        */\n  SISLIntdat *qintdat = SISL_NULL;\t/* Structure holding the intersection data. */\n  int      kdeg=0;              /* input to int_join_per. */\n\n  /*\n   * Check dimensions.\n   * -----------------\n   */\n\n  *jpt = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n  *jsurf = 0;\n\n  if (ps1->idim != ps2->idim)\n    goto err106;\n\n  /*\n   * Create objects and connect surfaces to the objects.\n   * ---------------------------------------------------\n   */\n\n  if ((qo1 = newObject (SISLSURFACE)) == SISL_NULL)\n    goto err101;\n  qo1->s1 = ps1;\n  qo1->o1 = qo1;\n\n  if ((qo2 = newObject (SISLSURFACE)) == SISL_NULL)\n    goto err101;\n  qo2->s1 = ps2;\n  qo2->o1 = qo2;\n\n  /*\n   * Find intersections.\n   * -------------------\n   */\n\n  sh1761 (qo1, qo2, aepsge, &qintdat, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* Represent degenerated intersection curves as one point.  */\n\n  sh6degen(qo1,qo2,&qintdat,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n      refine_all( &qintdat,qo1,qo2,nullp,kdeg=0,aepsge,&kstat);\n      if (kstat < 0)\n\tgoto error; \n    }\n\n  /* Join periodic curves */\n  int_join_per( &qintdat,qo1,qo2,nullp,kdeg=0,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n  \n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n      make_tracks (qo1, qo2, 0, nullp,\n\t\t   qintdat->ilist, qintdat->vlist, \n\t\t   jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n\n  /*\n* Express intersections on output format.\n* ---------------------------------------\n*/\n\n  if (qintdat)\t\t\t/* Only if there were intersections found */\n    {\n      hp_s1880(qo1, qo2, 0,\n\t       2,2,qintdat,jpt,gpar1,gpar2,pretop,jcrv,wcurve,jsurf,wsurf,&kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n\n  /*\n   * Intersections found.\n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /*\n   * Error in space allocation.\n   * --------------------------\n   */\n\nerr101:*jstat = -101;\n  s6err (\"sh1859\", *jstat, kpos);\n  goto out;\n\n  /* Dimensions conflicting.  */\n\nerr106:*jstat = -106;\n  s6err (\"sh1859\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine.  */\n\nerror:*jstat = kstat;\n  s6err (\"sh1859\", *jstat, kpos);\n  goto out;\n\nout:\n\n  /*\n   * Free allocated space.\n   * ---------------------\n   */\n\n  if (qo1)\n    {\n      qo1->s1 = SISL_NULL;\n      freeObject (qo1);\n    }\n  if (qo2)\n    {\n      qo2->s1 = SISL_NULL;\n      freeObject (qo2);\n    }\n  if (qintdat)\n    freeIntdat (qintdat);\n\n  /*\n   * Exit sh1859.\n   * -----------\n   */\n\n  return;\n}\n\n"
  },
  {
    "path": "src/sh1860.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1860.c,v 1.2 2001-03-19 15:59:06 afr Exp $\n *\n */\n\n\n#define SH1860\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \nsh1860(SISLSurf *ps,double eview[],int idim,double aepsco,double aepsge,\n\tint trackflag, int *jtrack, SISLTrack *** wtrack,\n\t   int *jpt,double **gpar,int **pretop,int *jcrv,SISLIntcurve ***wcurve,int *jsurf,SISLIntsurf ***wsurf,int *jstat)\n#else\nvoid sh1860(ps,eview,idim,aepsco,aepsge,\n\ttrackflag,jtrack,wtrack,jpt,gpar,pretop,jcrv,wcurve,jsurf,wsurf,jstat)\n     SISLSurf     *ps;\n     double   eview[];\n     int      idim;\n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jsurf;\n     SISLIntsurf ***wsurf;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find the silhouette curves and points of a surface when\n*              the surface is viewed from a specific direction. In\n*              addition to the points and curves found by this routine,\n*              break curves and edge-curves might be silhouette curves.\n*\n*\n*\n* INPUT      : ps  - Pointer to the surface.\n*              eview  - The direction vector of the viewing.\n*              idim   - Dimension of the space in which eview lies.\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              trackflag - If true, create tracks.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar   - Array containing the parameter values of the\n*                       single silhouette points in the parameter\n*                       plane of the surface. The points lie continuous. \n*                       Silhouette curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              jcrv   - Number of silhouette curves.\n*              wcurve - Array containing descriptions of the silhouette\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1761       - Perform point object-intersection.\n*              s1382       - Make a function whose zeroes describe the\n*                            silhouette lines of a surface.\n*              hp_s1880       - Put intersections on output format.\n*              make_sf_kreg   - Ensure k-regularity of surface.\n*              newObject   - Create new object.\n*              newPoint    - Create new point.\n*              freeObject  - Free space occupied by an object.\n*              freeIntdat  - Free space occupied by an intersection data.\n*\n* WRITTEN BY : Vibeke Skytt, SI, 88-11.\n* REWRITTEN BY : Bjoern Olav Hoset, SI, 89-06.\n*\n*********************************************************************\n*/\n{            \n  int kstat = 0;             /* Local status varible.                        */\n  int kpos = 0;              /* Position of error.                           */\n  int kdim = 1;              /* Dimension of space in which the point in the\n\t\t\t\tintersect point and surface problem lies.    */\n  int ki;                    /* Loop control. */\n  double nmax=1.0;           /* max absolute value of 1d surface. */\n  double *spar = SISL_NULL;       /* Dummy array containing parameter values of\n\t\t\t\tsecond object of single intersection points. */\n  double spoint[1];          /* SISLPoint to intersect with object.              */\n  SISLSurf *qs = SISL_NULL;           /* Surface whose zeroes are the silhouette\n\t\t\t\tcurves/points of the original surface.     */\n  SISLPoint *qp = SISL_NULL;          /* Pointer to point in \n\t\t\t\tsurface/point intersection.  */\n  SISLObject *qo1 = SISL_NULL;        /* Pointer to surface in \n\t\t\t\tobject/point intersection. */\n  SISLObject *qo2 = SISL_NULL;        /* Pointer to point in \n\t\t\t\tobject/point intersection    */\n  SISLIntdat *qintdat = SISL_NULL;    /* Intersection result */\n  int kdeg=1003;      \n  double simpli[16];  \n  double snorm[3];\n  SISLObject *track_obj=SISL_NULL;\n  SISLSurf *qkreg=SISL_NULL; /* Input surface ensured k-regularity. */\n\n  /* -------------------------------------------------------- */  \n  /* UJK, aug 93, It seems that a tolerance of 10e-11 is make us\n     walk around the noise, accept only tolerance GE 10e-06 */\n  /* testing aepsge = max(aepsge,(double)0.000001);\n  */\n  aepsge = (double)1.0e-09;\n\n  if (ps->cuopen_1 == SISL_SURF_PERIODIC ||\n      ps->cuopen_2 == SISL_SURF_PERIODIC)\n  {\n     /* Cyclic surface. */\n\n     make_sf_kreg(ps,&qkreg,&kstat);\n     if (kstat < 0) goto error;\n   }\n  else\n    qkreg = ps;\n  \n  /*\n  * Create new object and connect surface to object.\n  * ------------------------------------------------\n  */\n  \n  if (!(track_obj = newObject (SISLSURFACE)))\n    goto err101;\n  track_obj->s1 = ps;\n  \n  (void)s6norm(eview,3,snorm,&kstat);\n  \n  simpli[0] = snorm[0];\n  simpli[1] = snorm[1];\n  simpli[2] = snorm[2];\n  \n\n  /* \n   * Check dimension.  \n   * ----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if (idim != qkreg -> idim) goto err106;\n\n  /* \n   * Make surface whose zeroes describe silhouette lines.  \n   * ----------------------------------------------------\n   */\n\n  s1382(qkreg,eview,idim,&qs,&kstat);\n  if (kstat < 0) goto error;\n\n  /* UJK,24.02.93: I'll comment this later, but the scaling of the 1d surface should solve \n     many of the tolerance problems, especially when the surface Normal \n     do not vary too much and the normal cone is more than 45 degrees. \n     It is important to use aepsge as the angular tolerance (10-11?)*/\n\n  /* Start of change 01.02.93 ___________________*/\n  /* UJK,01.03.93: To get a better conversion to 1d, pick the middle of th surface and \n     project it in x,y and z direction. */\n  {\n     double min1,min2,max1,max2;\n     int kleft=0;\n     double qview[3];\n     int kj;\n     SISLSurf *qstmp=SISL_NULL;\n     SISLSurf *qstmp_1d=SISL_NULL;\n     \n     \n     min1 = s1792(qkreg->et1,qkreg->ik1,qkreg->in1);\n     s1219(qkreg->et1,qkreg->ik1,qkreg->in1,&kleft,min1,&kstat);\n     if (kstat < 0) goto error;\n     max1 = qkreg->et1[kleft+1];\n     min2 = s1792(qkreg->et2,qkreg->ik2,qkreg->in2);\n     s1219(qkreg->et2,qkreg->ik2,qkreg->in2,&kleft,min2,&kstat);\n     if (kstat < 0) goto error;\n     max2 = qkreg->et2[kleft+1];\n     \n     s1001 (qkreg, min1, min2, max1, max2, &qstmp, &kstat);\n     if (kstat < 0) goto error;\n     for (ki=0;ki<3;ki++)  qview[ki] = DZERO;\n     \n     nmax = (double)1.0;\n     for (ki=0;ki<3;ki++)\n     {\n\tqview[ki] = (double)1.0;\n\ts1382(qstmp,qview,idim,&qstmp_1d,&kstat);\n\tif (kstat < 0) goto error;\n\tfor(kj=0; kj<qstmp_1d->in1*qstmp_1d->in2;kj++)\n\t   nmax = max(fabs(qstmp_1d->ecoef[kj]),nmax);\n\t\n\tif (qstmp_1d) freeSurf(qstmp_1d);\n\tqstmp_1d  = SISL_NULL;\n\tqview[ki] = DZERO;\n     }\n     if (qstmp) freeSurf(qstmp);\n     qstmp = SISL_NULL;\n  }\n  /* End of change 01.02.93 ___________________*/\n     \n  for(ki=0; ki<qs->in1*qs->in2;ki++)\n     nmax = max(fabs(qs->ecoef[ki]),nmax);\n  \n  for(ki=0; ki<qs->in1*qs->in2;ki++)\n     qs->ecoef[ki] /= nmax;\n  /* \n   * Create new object and connect surface to object.  \n   * ------------------------------------------------\n   */\n\n  if(!(qo1 = newObject(SISLSURFACE))) goto err101;\n  qo1 -> s1 = qs;\n  qo1 -> o1 = qo1;\n  \n  /*\n   * Create new object and connect point to object.\n   * ----------------------------------------------\n   */\n\n  if(!(qo2 = newObject(SISLPOINT))) goto err101;\n  spoint[0] = DZERO;\n  if(!(qp = newPoint(spoint,kdim,1))) goto err101;\n  qo2 -> p1 = qp;\n\n  /* \n   * Find intersections.  \n   * -------------------\n   */\n\n  sh1761(qo1,qo2,aepsge,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Represent degenerated intersection curves as one point.  */\n\n  sh6degen(track_obj,track_obj,&qintdat,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Split curves at knots where the surface is only C1. */\n  \n  spli_silh(&qintdat,track_obj,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n  {\n\n     \n      refine_all (&qintdat, track_obj, track_obj, simpli, kdeg, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n  }\n  \n  /* Join periodic curves */\n  int_join_per( &qintdat,track_obj, track_obj, simpli, kdeg,aepsge,&kstat);\n  if (kstat < 0)\n    goto error;\n\n  \n  /* Create tracks */\n  if (trackflag && qintdat)\n  {\n      make_tracks (track_obj, track_obj, kdeg, simpli,\n\t\t   qintdat->ilist, qintdat->vlist, \n\t\t   jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* \n   * Express silhouette curves and points on output format.  \n   * -----------------------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(track_obj, track_obj, kdeg,\n\t       2,0,qintdat,jpt,gpar,&spar,pretop,jcrv,wcurve,jsurf,wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n\n  /* \n   * Silhouette curves and points found.  \n   * ----------------------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in space allocation.  */\n\n err101: *jstat = -101;                \n        s6err(\"sh1860\",*jstat,kpos);\n        goto out;\n\n  /* Dimensions conflicting.  */\n\n err106: *jstat = -106;\n        s6err(\"sh1860\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n        s6err(\"sh1860\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* Free allocated space.  */\n\n  if (spar)    freearray(spar);\n  if (qo1)     freeObject(qo1);\n  if (qo2)     freeObject(qo2);\n  if (qintdat) freeIntdat(qintdat);\n  if (track_obj)\n    {\n       track_obj->s1 = SISL_NULL;\n       freeObject(track_obj);\n    }\n\n  /* Free local surface.  */\n    if (qkreg != SISL_NULL && qkreg != ps) freeSurf(qkreg);\n                                         \nreturn;\n}                                               \n\n"
  },
  {
    "path": "src/sh1870.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1870.c,v 1.4 2002-05-07 11:46:54 jbt Exp $\n *\n */\n\n\n#define SH1870\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \nsh1870(SISLSurf *ps1, double *pt1, int idim, double aepsco, double aepsge,\n\tint trackflag, int *jtrack, SISLTrack *** wtrack,\n\t   int *jpt,double **gpar1,int **pretop,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid sh1870(ps1,pt1,idim,aepsco,aepsge,\n\ttrackflag,jtrack,wtrack,jpt,gpar1,pretop,jcrv,wcurve,jstat)\n     SISLSurf     *ps1;\n     double    *pt1;\n     int\tidim;\n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar1;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a B-spline surface\n*              and a point.\n*\n*\n*\n* INPUT      : ps1    - Pointer to the surface.\n*              pt1    - coordinates of the point.\n*\t       idim   - number of coordinates in pt1.\t\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              trackflag - For future use. Should now be 0.\n*              *jstat    - Flag\n*                          = 202 : Complicated point-surface intersection\n*                                  in 3D. Perform extra interception test.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar1  - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the surface. The points lie \n*                       continuous. Intersection curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              jcrv   - Number of intersection curves.\n*              wcurve - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*                       If the curves given as input are degnenerate an\n*                       intersection point can be returned as an intersection\n*                       curve. Use s1327 to decide if an intersection curve\n*                       is a point on one of the curves.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1761      - Perform object/object-intersection.\n*              hp_s1880      - Put intersections on output format.\n*              newObject  - Create new object.\n\t       newPoint   - Create new SISLPoint.\n*              freeObject - Free space occupied by an object.\n*              freeIntdat - Free space occupied by the intdat structure.\n*\n* WRITTEN BY : K. Stroem, SI, 92-10.\n*\n*********************************************************************\n*/\n{            \n  double *nullp = SISL_NULL;\n  int kstat = 0;                 /* Local status variable.                   */\n  int kpos = 0;                  /* Position of error.                       */\n  SISLObject *qo1 = SISL_NULL;            /* Object containing first curve in \n\t\t\t\t    the intersection.                        */\n  SISLObject *qo2 = SISL_NULL;            /* Object containing second curve in \n\t\t\t\t    the intersection.*/\n  SISLPoint  *pp1 = SISL_NULL;\t   /* Point object containing the point */\n  SISLIntdat *qintdat = SISL_NULL;        /* Structure holding the intersection data. */\n  int      ksurf=0;         /* Dummy number of Intsurfs. */\n  SISLIntsurf **wsurf=SISL_NULL;    /* Dummy array of Intsurfs. */\n  int kdeg=0;\n  \n  /* \n   * Check dimensions.  \n   * -----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if (ps1 -> idim != idim) goto err106;\n\n  /* \n   * Create objects and connect surface/point to the objects.  \n   * --------------------------------------------------------\n   */\n\n  if ((qo1 = newObject(SISLSURFACE)) == SISL_NULL) goto err101;\n  qo1 -> s1 = ps1;\n  qo1 -> o1 = qo1;\n\n  if ((pp1 = newPoint(pt1,idim, 0)) == SISL_NULL) goto err101;\n  \n  if ((qo2 = newObject(SISLPOINT)) == SISL_NULL) goto err101;\n  qo2 -> p1 = pp1;\n  qo2 -> o1 = qo2;\n  \n  /* \n   * Find intersections.  \n   * -------------------\n   */\n\n  kstat = *jstat;\n  sh1761(qo1,qo2,aepsge,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Represent degenerated intersection curves as one point.  */\n\n  sh6degen(qo1,qo2,&qintdat,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Join periodic curves */\n/*    int_join_per( &qintdat,qo1,qo2,nullp,kdeg=0,aepsge,&kstat); */\n/*    if (kstat < 0) */\n/*      goto error; */\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n      make_tracks (qo1, qo2, kdeg=0, nullp,\n\t\t   qintdat->ilist, qintdat->vlist, \n\t\t   jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n    }\n\n  /* \n   * Express intersections on output format.  \n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(qo1, qo2, 0,\n\t       2,0,qintdat,jpt,gpar1,&nullp,pretop,jcrv,wcurve,&ksurf,&wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* \n   * Error in space allocation.  \n   * --------------------------\n   */\n\n err101: *jstat = -101;                \n        s6err(\"sh1870\",*jstat,kpos);\n        goto out;\n\n  /* Dimensions conflicting.  */\n\n err106: *jstat = -106;\n  s6err(\"sh1870\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n        s6err(\"sh1870\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* \n   * Free allocated space.  \n   * ---------------------\n   */\n\n  if (qo1) \n    {\n      qo1 -> s1 = SISL_NULL;  freeObject(qo1);\n    }\n  if (qo2) \n    {\n      freeObject(qo2);\n    }\n  if (qintdat) freeIntdat(qintdat);\n\n  /*\n   * Exit sh1870.\n   * -----------\n   */\n                                        \n  return;\n}                                               \n\n"
  },
  {
    "path": "src/sh1871.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1871.c,v 1.3 2002-01-28 12:38:50 jbt Exp $\n *\n */\n\n\n#define SH1871\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \nsh1871(SISLCurve *pc1, double *pt1, int idim, double aepsco, double aepsge,\n\tint trackflag, int *jtrack, SISLTrack *** wtrack,\n\t   int *jpt,double **gpar1,int **pretop,int *jcrv,SISLIntcurve ***wcurve,int *jstat)\n#else\nvoid sh1871(pc1,pt1,idim,aepsco,aepsge,\n\ttrackflag,jtrack,wtrack,jpt,gpar1,pretop,jcrv,wcurve,jstat)\n     SISLCurve     *pc1;\n     double    *pt1;\n     int\tidim;\n     double   aepsco;\n     double   aepsge;\n     int       trackflag;\n     int       *jtrack;\n     SISLTrack ***wtrack;\n     int      *jpt;\n     double   **gpar1;\n     int      **pretop;\n     int      *jcrv;\n     SISLIntcurve ***wcurve;\n     int      *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Find all intersections between a B-spline curve\n*              and a point.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve.\n*              pt1    - coordinates of the point.\n*\t       idim   - number of coordinates in pt1.\t\n*              aepsco - Computational resolution.\n*              aepsge - Geometry resolution.\n*              trackflag - For future use. Should now be 0.\n*\n*\n*\n* OUTPUT     : jtrack - Number of tracks created\n*              wtrack - Array of pointers to tracks\n*              jpt    - Number of single intersection points.\n*              gpar1  - Array containing the parameter values of the\n*                       single intersection points in the parameter\n*                       interval of the curve. The points lie \n*                       continuous. Intersection curves are stored in wcurve.\n*              pretop - Topology info. for single intersection points.\n*              jcrv   - Number of intersection curves.\n*              wcurve - Array containing descriptions of the intersection\n*                       curves. The curves are only described by points\n*                       in the parameter plane. The curve-pointers points\n*                       to nothing. (See description of Intcurve\n*                       in intcurve.dcl).\n*                       If the curves given as input are degnenerate an\n*                       intersection point can be returned as an intersection\n*                       curve. Use s1327 to decide if an intersection curve\n*                       is a point on one of the curves.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh1761      - Perform object/object-intersection.\n*              hp_s1880      - Put intersections on output format.\n*              newObject  - Create new object.\n\t       newPoint   - Create new SISLPoint.\n*              freeObject - Free space occupied by an object.\n*              freeIntdat - Free space occupied by the intdat structure.\n*\n* WRITTEN BY : K. Stroem, SI, 92-10.\n*\n*********************************************************************\n*/\n{            \n  double *nullp = SISL_NULL;\n  int kstat = 0;                 /* Local status variable.                   */\n  int kpos = 0;                  /* Position of error.                       */\n  SISLObject *qo1 = SISL_NULL;            /* Object containing the curve in \n\t\t\t\t    the intersection.                        */\n  SISLObject *qo2 = SISL_NULL;            /* Object containing the point in \n\t\t\t\t    the intersection.*/\n  SISLPoint  *pp1 = SISL_NULL;\t   /* Point object containing the point */\n  SISLIntdat *qintdat = SISL_NULL;        /* Structure holding the intersection data. */\n  int      ksurf=0;         /* Dummy number of Intsurfs. */\n  SISLIntsurf **wsurf=SISL_NULL;    /* Dummy array of Intsurfs. */\n  int kdeg=0;\n  \n  /* \n   * Check dimensions.  \n   * -----------------\n   */\n\n  *jpt  = 0;\n  *jcrv = 0;\n  *jtrack = 0;\n\n  if (pc1 -> idim != idim) goto err106;\n\n  /* \n   * Create objects and connect curve/point to the objects.  \n   * --------------------------------------------------------\n   */\n\n  if ((qo1 = newObject(SISLCURVE)) == SISL_NULL) goto err101;\n  qo1 -> c1 = pc1;\n  qo1 -> o1 = qo1;\n\n  if ((pp1 = newPoint(pt1,idim, 0)) == SISL_NULL) goto err101;\n  \n  if ((qo2 = newObject(SISLPOINT)) == SISL_NULL) goto err101;\n  qo2 -> p1 = pp1;\n  qo2 -> o1 = qo2;\n  \n  /* \n   * Find intersections.  \n   * -------------------\n   */\n\n  sh1761(qo1,qo2,aepsge,&qintdat,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Represent degenerated intersection curves as one point.  */\n\n  sh6degen(qo1,qo2,&qintdat,aepsge,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Join periodic curves */\n/*    int_join_per( &qintdat,qo1,qo2,nullp,kdeg=0,aepsge,&kstat); */\n/*    if (kstat < 0) */\n/*      goto error; */\n\n  /* Create tracks */\n  if (trackflag && qintdat)\n    {\n      make_tracks (qo1, qo2, kdeg=0, nullp,\n\t\t   qintdat->ilist, qintdat->vlist, \n\t\t   jtrack, wtrack, aepsge, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n    }\n\n  /* \n   * Express intersections on output format.  \n   * ---------------------------------------\n   */\n\n  if (qintdat)/* Only if there were intersections found */\n    {\n      hp_s1880(qo1, qo2, 0,\n\t       1,0,qintdat,jpt,gpar1,&nullp,pretop,jcrv,wcurve,&ksurf,&wsurf,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* \n   * Intersections found.  \n   * --------------------\n   */\n\n  *jstat = 0;\n  goto out;\n\n  /* \n   * Error in space allocation.  \n   * --------------------------\n   */\n\n err101: *jstat = -101;                \n        s6err(\"sh1871\",*jstat,kpos);\n        goto out;\n\n  /* Dimensions conflicting.  */\n\n err106: *jstat = -106;\n  s6err(\"sh1871\",*jstat,kpos);\n        goto out;\n\n  /* Error in lower level routine.  */\n\n  error : *jstat = kstat;\n        s6err(\"sh1871\",*jstat,kpos);\n        goto out;\n\n out:\n\n  /* \n   * Free allocated space.  \n   * ---------------------\n   */\n\n  if (qo1) \n    {\n      qo1 -> c1 = SISL_NULL;  freeObject(qo1);\n    }\n  if (qo2)  freeObject(qo2);\n\n  if (qintdat) freeIntdat(qintdat);\n\n  /*\n   * Exit sh1871.\n   * -----------\n   */\n                                        \n  return;\n}                                               \n\n"
  },
  {
    "path": "src/sh1922.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1922.c,v 1.2 2001-03-19 15:59:06 afr Exp $\n *\n */\n\n#define SH1922\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      sh1922(double et[],int im,int ik,double etau[],int in,double ea[],\n\t     int nfirst[],int nlast[],int *jstat)\n#else\nvoid sh1922(et,im,ik,etau,in,ea,nfirst,nlast,jstat)\n   double et[];\n   int im;\n   int ik;\n   double etau[];\n   int in;\n   double ea[];\n   int nfirst[];\n   int nlast[];\n   int *jstat;\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : To compute the B-spline refinement transformation matrix\n*              from the spline space generated by the knot vector etau\n*              to the refined spline space generated by the refined knot\n*              vector et.\n* \n* INPUT      : et     - Real array of length (im+ik) containing the refined\n*                       knot vector.\n*              im     - The dimension of the spline space corresponding to et.\n*\t       ik     - The order of the spline space.\n*              etau   - Real array of length (in+ik) containing the original \n*                       knot vector.\n*              in     - The dimension of the spline space corresponding\n*                       to etau.\n*\n* \n* OUTPUT     : ea     - Real array of dimension (im*ik) containing \n*                       the B-spline refinement matrix from the knot vector\n*                       etau to the knot vector et. This matrix has\n*                       dimension im*in but since at most\n*                       ik entries are nonzero in each row, it can\n*                       be stored in a im*ik array together\n*                       with two integer arrays indicating the position\n*                       of the first and last nonzero elements in each\n*                       row.\n*              nfirst - Integer array of dimension (im) containing \n*                       pointers to the first nonzero element of each row \n*                       of the B-spline refinement matrix from etau to et.\n*              nlast  - Integer array of dimension (im) containing \n*                       pointers to the last nonzero element of each row \n*                       of the B-spline refinement matrix from etau to et.\n*              jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*             \n* \n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        :\n*\n*-\n* CALLS      :   \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.92, on the basis of a routine\n*              written by Tom Lyche and Knut Moerken, 12.85.\n*\n*********************************************************************\n*/\n{ \n   int kstat = 0;\n   int kj1,kj2;\n   int kih1,kih2;\n   int ki,kj,kjh,kkj;\n   int kmu;\n   int kmuprm;\n   int knu;\n   double *sah = SISL_NULL;\n   \n   if ((sah = new0array(ik,DOUBLE)) == SISL_NULL) goto err101;\n   \n   /* The first and last few rows of the refinement matrix ea may contain\n      only zeroes. The first task is to find the first and the last\n      nonzero rows (pointed at by kj1 and kj2).  First kj2 are determined. */\n\n   for (kmu=in+ik-1; DEQUAL(etau[kmu-1],etau[kmu]); kmu--);\n   \n   for (kjh=im-1; et[kjh+ik]>etau[kmu]; kjh--);\n   \n   ki = kjh;\n   if (DEQUAL(et[kjh+ik],etau[kmu]))\n      {\n\t for (; DEQUAL(et[ki-1+ik],et[kjh+ik]); ki--);\n      }\n      \n   kj2 = MIN(im-1,ki+in+ik-kmu-1);\n   \n   /* Determine kj1.  */\n       \n   for (kmu=0; DEQUAL(etau[kmu+1],etau[kmu]); kmu++);\n   \n   for (kjh=0; et[kjh]<etau[kmu]; kjh++);\n   \n   ki = kjh;\n   if (DEQUAL(et[kjh],etau[kmu]))\n      {\n\t for (; DEQUAL(et[ki+1],et[kjh]); ki++);\n      }\n   kj1 = MAX(0,ki-kmu);      \n      \n   /*  Set all elements of ea to zero. */\n      \n   memzero(ea,im*ik,DOUBLE);\n   \n   /* Determine the refinement transformation.  */\n   /* Indicate that rows 1,2,..,kj1 of ea are zero by setting nfirst>nlast\n      for these rows.  */\n   \n   for (kj=0; kj<kj1; kj++)\n     {\n\tnfirst[kj] = ik;\n\tnlast[kj] = 0;\n     }\n   \n   /* Similarily for rows kj2+1, ... im-1 of ea.  */\n   \n   for (kj=kj2+1; kj<im; kj++)\n     {\n\tnfirst[kj] = ik;\n\tnlast[kj] = 0;\n     }\n   \n   /* Compute rows kj1 to kj2 of ea. */\n   \n   for (kj=kj1; kj<=kj2; kj++)\n     {\n\tfor (; etau[kmu+1] <= et[kj]; kmu++);\n\tkkj = kj;\n\tsh1929(etau,in,ik,kmu,et,im,kkj,sah,&kmuprm,&knu,&kstat);\n\tif (kstat < 0) goto error;\n\t\t       \n       /* Get the pointers right.  */\n\t\t       \n       nfirst[kj] = MAX(kmuprm-knu,0);\n       nlast[kj] = MIN(kmuprm,in-1);\n       kih1 = nfirst[kj] + ik - kmuprm - 1;\n       kih2 = nlast[kj] + ik - kmuprm - 1;\n       for (ki=kih1; ki<=kih2; ki++)\n\t ea[kj*ik+ki] = sah[ki];\n     }\n\n   /* Refinement transformation matrix computed.  */\n\n   *jstat = 0;\n   goto out;\n   \n   /* Error in space allocation.  */\n   \n   err101: *jstat = -101;\n   goto out;\n   \n   /* Error in lower level routine.  */\n   \n   error: *jstat = kstat;\n   goto out;\n   \n   out:\n      /* Free scratch used for local array.  */\n      \n      if (sah != SISL_NULL) freearray(sah);\n\t  \n      return;\n}\n   \n"
  },
  {
    "path": "src/sh1923.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1923.c,v 1.2 2001-03-19 15:59:06 afr Exp $\n *\n */\n\n#define SH1923\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      sh1923(double *ea,int in,int ik,int *nstart,int *jstat)\n#else\nvoid sh1923(ea,in,ik,nstart,jstat)\n   double *ea;\n   int in;\n   int ik;\n   int *nstart;\n   int *jstat;\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : To caluclate the Cholesky factorization (A=L*L(tr)) of\n*              a (symmetric positive definite) in*in matrix with a\n*              maximum of 2*ik-1 nonzero elements in each row. Because \n*              of the  symmetry it is sufficient to store the nonzero\n*              elements to the left of and including the diagonal, i.e.\n*              at most ik nonzero elements. Hence, the input matrix is\n*              given by the two arrays ea and nstart of dimension (in*ik)\n*              and in, respectively, with nstart indicating the position\n*              of the first nonzero elements of each row of ea. If the\n*              factorization is successfull, it is given as output in ea\n*              a nstart using the same representation as the input.\n* \n* \n* INPUT      : ea     - Real array of dimension (in*ik) containing the \n*                       nonzero elements of the matrix factorized. This\n*                       is possible since it is assumed that the input \n*                       matrix is symmetric with at most 2*ik nonzero\n*                       elements in each row.\n*              in     - The dimension of the input matrix, i.e. the number\n*                       of rows in ea.\n*              ik     - The maximum number of different nonzero elements\n*                       in each row of the input matrix and therefore the\n*                       number of columns of ea.\n*              nstart - Integer array of dimension (in) containing pointers\n*                       to the first nonzero element of each row of ea.\n*              \n*\n* \n* OUTPUT     : ea     - Real array of dimension (in*ik) containing the\n*                       nonzero elements of the Cholesky factorization.\n*                       This is possible because fo the special structure \n*                       of the input matrix and the fact that Cholesky\n*                       factorization preserves this structure.\n*              jstat  - status messages \n*                          > 0 : warning \n*                          = 0 : ok \n*                          < 0 : error \n*             \n* \n* METHOD     : The Cholesky factorization is computed in the form\n*              A = L*L(tr). (L(tr) denotes the transpose of L) one\n*              row at a time.\n*\n*\n* REFERENCES : Any book on general numerical analysis or numerical\n*              linear algebra.\n*              \n*\n* USE        :\n*\n*-\n* CALLS      :   \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.92, on the basis of a routine\n*              written by Tom Lyche and Knut Moerken, 12.85.\n*\n*********************************************************************\n*/\n{\n   int ki,kj,kr;           /* Counters.              */\n   int kjs,kjh,krhs,krh;   /* Pointers into matrix.  */\n   int kik1 = ik-1;        /* Order minus one.       */\n   double tsum;            /* Help variable.         */\n   double thelp;           /* Help variable.         */\n\n   \n   /* Go through the rows of the matrix one by one.  */\n   \n   for (ki=0; ki<in; ki++)\n     {\n\t/* Calculate the off diagonal elemnts of row no ki of the\n\t   Cholesky factorization. The first nonzero element of this\n\t   row is given by nstart[ki]. The integer kjh gives the\n\t   position of this element in the underlying in*in matrix.  */\n\t\n\tfor (kjs=nstart[ki], kjh=ki+kjs-ik+1, krhs=kik1, kj=kjs;\n\t kj<kik1; kjh++, krhs--, kj++)\n\t  {\n\t     tsum = (double)0.0;\n\t     krh = krhs;\n\t     for (kr=kjs; kr<kj; krh++,kr++)\n\t       tsum += ea[ki*ik+kr]*ea[kjh*ik+krh];\n\t     ea[ki*ik+kj] -= tsum;\n\t     ea[ki*ik+kj] /= ea[kjh*ik+kik1];\n\t  }\n\t\n\t/* Finish off row ki by calculating the diagonal element of the\n\t   Cholesky factorization.   */\n\t\n\ttsum = (double)0.0;\n\tfor (kr=kjs; kr<kik1; kr++)\n\t  {\n\t     thelp = ea[ki*ik+kr];\n\t     tsum += thelp*thelp;\n\t  }\n\t\n\t/* Check if nonpositive ea[ki*ik+ik-1], i.e. singular non positive\n\t   definite matrix.  */\n\t\n\ttsum = ea[ki*ik+kik1] - tsum;\n\tif (tsum <= DZERO) goto err106;\n        ea[ki*ik+kik1] = sqrt(tsum);\n     }\n   \n   /* Cholesky factorization computed.  */\n   \n   *jstat = 0;\n   goto out;\n   \n   /* Singular matrix.  */\n   \n   err106: *jstat = -106;\n   goto out;\n   \n   out:\n      return;\n}\n   \n"
  },
  {
    "path": "src/sh1924.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1924.c,v 1.2 2001-03-19 15:59:06 afr Exp $\n *\n */\n\n#define SH1924\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      sh1924(double *ea,double *eb,int in,int ik,int idim,\n\t     int *nstart,int *jstat)\n#else\nvoid sh1924(ea,eb,in,ik,idim,nstart,jstat)\n   double *ea;\n   double *eb;\n   int in;\n   int ik;\n   int idim;\n   int *nstart;\n   int *jstat;\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : To solve idim linear systems of equations A*X=eb, given\n*              the right-hand-side eb and the Cholesky factorization of\n*              the matrix A (i.e. A is assumed to be symmetric and\n*              positive definite). It is also assumed that A has at most\n*              2*ik-1 nonzero elements in each row, and since this\n*              structure is not destroyed by the Cholesky factorization,\n*              it is sufficient to store a maximum of ik elements per\n*              row, see the subroutine sh1923. The right-hand-side eb has\n*              idim components each of length in. The output of the \n*              routine is the solution fo the linear system which \n*              overwrites eb.\n* \n* \n* INPUT      : ea     - Real array of dimension (in*ik) containing the \n*                       nonzero elements of the Cholesky factorization.\n*              eb     - Real array of dimension (in*idim) containing\n*                       the right-hand-side(s) of the linear systems.\n*              in     - The dimension of the linear systems, i.e. the number\n*                       of rows in ea.\n*              ik     - The maximum number of different nonzero elements\n*                       in each row of the Cholesky factorization and \n*                       therefore the number of columns of ea.\n*              idim   - The number of different right-hand-sides.\n*              nstart - Integer array of dimension (in) containing pointers\n*                       to the first nonzero element of each row of ea.\n*\n* \n* OUTPUT     : eb     - The solution of the idim linear systems.\n*              jstat  - status messages \n*                          > 0 : warning \n*                          = 0 : ok \n*                          < 0 : error \n*             \n* \n* METHOD     : The linear system is solved in the usual way, first a \n*              forward substition and the a back substitution.\n*\n*\n* REFERENCES : Any book on general numerical analysis or numerical\n*              linear algebra.\n*              \n*\n* USE        :\n*\n*-\n* CALLS      :   \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.92, on the basis of a routine\n*              written by Tom Lyche and Knut Moerken, 12.85.\n*\n*********************************************************************\n*/\n{\n   int ki,kj,kr;         /* Counters.    */\n   int ki1,kih,kim;      /* Counters.    */\n   int kjs,kjh; /* Pointers into matrix.  */\n   int kik1 = ik-1;      /* Order minus one.       */\n   double thelp;         /* Help variable.         */\n   double *ssum=SISL_NULL;    /* Help array.            */\n\n   /* Allocate scratch for help array.  */\n   \n   if ((ssum = new0array(idim,DOUBLE)) == SISL_NULL) goto err101;\n   \n   /* Forward substitution.  */\n   \n   for (ki=0; ki<in; ki++)\n     {\n\tki1 = ki - 1;\n\tfor (kr=0; kr<idim; kr++) ssum[kr] = (double)0.0;\n\t\n\t/* kjs points to the firs nonzero element of row ki of ea, and\n\t   kjh points to the corresponding element in the underlying\n\t   matrix.       */\n\t\n\tfor (kjs=nstart[ki], kjh=ki+kjs-ik+1, kj=kjs;\n\t kj<kik1; kjh++, kj++)\n\t  {\n\t     thelp = ea[ki*ik+kj];\n\t     for (kr=0; kr<idim; kr++)\n\t       ssum[kr] += thelp*eb[kjh*idim+kr];\n\t  }\n\t\n\t/* Check if the linear system is singular.  */\n\t\n\tif (DEQUAL(ea[ki*ik+kik1],DZERO)) goto err106;\n\t\n\tthelp = (double)1.0/ea[ki*ik+kik1];\n\tfor (kr=0; kr<idim; kr++)\n\t  eb[ki*idim+kr] = (eb[ki*idim+kr] - ssum[kr])*thelp;\n     }\n   \n   /* Back substitution.  */\n   \n   for (ki=in-1, ki1=in-1, kih=0;\n    kih<in; ki--, kih++)\n     {\n\t/* Compute the index of the last nonzero element in row ki of the\n\t   transpose of the Cholesky factorization. The integer ik-ki1+ki\n\t   gives the position of element no (ki1*ik+ki) in row ki1 of ea.\n\t   ki1 is reduced until the first nonzero element or row ki1 is\n\t   ik-ki1+ki.   */\n\t\n\tfor (;;ki1--)\n\t  if (nstart[ki1] < ik-ki1+ki) break;\n\t\n\tfor (kr=0; kr<idim; kr++) ssum[kr] = (double)0.0;\n\t\n\t/* Calculate eb[.*ik+kik1].  */\n\t\n\tfor (kjs=ki+1, kim=ik-kjs+ki-1, kj=kjs;\n\t kj<=ki1; kim--, kj++)\n\t  {\n\t     thelp = ea[kj*ik+kim];\n\t     for (kr=0; kr<idim; kr++)\n\t       ssum[kr] += thelp*eb[kj*idim+kr];\n\t  }\n\t\n\tthelp = (double)1.0/ea[ki*ik+ik-1];\n\tfor (kr=0; kr<idim; kr++)\n\t  eb[ki*idim+kr] = (eb[ki*idim+kr] - ssum[kr])*thelp;\n     }\n   \n   \n   /* The linear system is solved.  */\n   \n   *jstat = 0;\n   goto out;\n   \n   /* Error in space allocation.  */\n   \n   err101: *jstat = -101;\n   goto out;\n   \n   /* Singular matrix.  */\n   \n   err106: *jstat = -106;\n   goto out;\n   \n   out:\n      /* Free scratch used for local array.  */\n      \n      if (ssum != SISL_NULL) freearray(ssum);\n\t  \n      return;\n}\n   \n"
  },
  {
    "path": "src/sh1925.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1925.c,v 1.2 2001-03-19 15:59:06 afr Exp $\n *\n */\n\n#define SH1925\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      sh1925(SISLCurve *pc1,SISLCurve *pc2,int idim,double ea[],int nstart[],\n\t     int nstop[],double emxerr[],double el2err[],int ilend,\n\t     int irend,int *jstat)\n#else\nvoid sh1925(pc1,pc2,idim,ea,nstart,nstop,emxerr,el2err,\n\t    ilend,irend,jstat)\n   SISLCurve *pc1;\n   SISLCurve *pc2;\n   int idim;\n   double ea[];\n   int nstart[];\n   int nstop[];\n   double emxerr[];\n   double el2err[];\n   int ilend;\n   int irend;\n   int *jstat;\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : To finish off the calculation of a discrete least squares\n*              spline approximation to the spline curve pc1, see the \n*              routine sh1926, and to calculate the discrete max-error\n*              and L2-error of the approximation.\n* \n* \n* INPUT      : pc1    - The spline curve to be approximated.\n*              pc2    - The curve approximating pc1 on a subset of the\n*                       knotvector.\n*              idim   - The dimension of the geometry space.\n*              ea     - Real array of dimension (pc1->in*pc1->ik) containing \n*                       the B-spline refinement matrix from the knot vector\n*                       pc2->et to the knot vector pc1->et. This matrix has\n*                       dimension pc1->in*pc2->inm byt subce at most\n*                       pc1->ik entries are nonzero in each row, it can\n*                       be stored in a pc1->in*pc1->ik array together\n*                       with two integer arrays indicating the position\n*                       of the first and last nonzero elements in each\n*                       row.\n*              nstart - Integer array of dimension (pc1->in) containing \n*                       pointers to the first nonzero element of each row \n*                       of the B-spline refinement matrix from pc2->et to\n*                       pc1->et.\n*              nstop  - Integer array of dimension (pc1->in) containing \n*                       pointers to the last nonzero element of each row \n*                       of the B-spline refinement matrix from pc2->et to\n*                       pc1->et.\n*              ilend  - The number of derivatives that have been kept fixed\n*                       at the left end of the spline. This means that the \n*                       first ilend coefficients are not to be multiplied\n*                       by the constants induced from the pc2->et knot\n*                       vector.\n*              irend  - The number of derivatives that have been kept fixed\n*                       at the right end of the spline. This means that the \n*                       last irend coefficients are not to be multiplied\n*                       by the constants induced from the pc2->et knot\n*                       vector.\n*\n* \n* OUTPUT     : emxerr - Real array of dimension (idim) containing the \n*                       absolute value of the largest B-spline coefficient\n*                       of f-g (see method below) in each component when\n*                       f-g is expressed as a spline on the pc1->et knot\n*                       vector.\n*              el2err - Real array of dimension (idim) containing a\n*                       weighted L2-norm of the B-spline coefficients of\n*                       f-g in each component when f-g is expressed as a\n*                       spline on the knot vector pc1->et.\n*              jstat     - status messages \n*                          > 0 : warning \n*                          = 0 : ok \n*                          < 0 : error \n*             \n* \n* METHOD     : First the B-spline coefficients pc2->ecoef of the spline\n*              approximation g are multiplied by the square matrix dtau(-1/2),\n*              i.e., pc2->ecoef[\n*\n*\n* REFERENCES : Any book on general numerical analysis or numerical\n*              linear algebra.\n*              \n*\n* USE        :\n*\n*-\n* CALLS      :   \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.92, on the basis of a routine\n*              written by Tom Lyche and Knut Moerken, 12.85.\n*\n*********************************************************************\n*/\n{\n   int ki,kj,kr;\n   int kjh;\n   int kk = pc1->ik;\n   int km = pc1->in;\n   int kn = pc2->in;\n   int kj1,kj2;\n   int kstop;\n   double tkindv = (double)1.0/(double)kk;\n   double tw;\n   double thelp;\n   double *st = pc1->et;\n   double *sd = pc1->ecoef;\n   double *stau = pc2->et;\n   double *sc = pc2->ecoef;\n   double *stemp = SISL_NULL;\n   \n   /* Allocate scratch for local array.  */\n   \n   if ((stemp = newarray(idim,DOUBLE)) == SISL_NULL) goto err101;\n  \n   /* Multiply the part of ec pointed to by kstart and kstop by the\n      corresponding parts of the square matrix dtau(-1/2).   */\n   \n   for (kstop=kn-irend, ki=ilend; ki<kstop; ki++)\n     {\n\ttw = sqrt((double)kk/(stau[ki+kk] - stau[ki]));\n\tfor (kj=0; kj<idim; kj++)\n\t  sc[ki*idim+kj] *= tw;\n     }\n   \n   /* Initiate arrays to zero.  */\n   \n   memzero(stemp,idim,DOUBLE);\n   memzero(emxerr,idim,DOUBLE);\n   memzero(el2err,idim,DOUBLE);\n\t\t  \n   /* Express the approximating spline as a spline on et by multiplying\n      ec by ea and then calculate the error in the spline approximation. */\n   \n   for (ki=0; ki<km; ki++)\n     {\n\tmemzero(stemp,idim,DOUBLE);\n\t\n\t/* Express the approximation as a spline on et.  */\n\t\n\tkj1 = nstart[ki];\n\tkj2 = nstop[ki];\n\tfor (kjh=kk+kj1-kj2-1, kj=kj1; kj<=kj2; kjh++, kj++)\n\t  {\n\t     thelp = ea[ki*kk+kjh];\n\t     for (kr=0; kr<idim; kr++)\n\t       stemp[kr] += thelp*sc[kj*idim+kr];\n\t  }\n\t\n\t/* Calculate the maxerror and the weighted L2-error of the\n\t   approximation. */\n\t\n\tthelp = (st[ki+kk] - st[ki])*tkindv;\n\tfor (kr=0; kr<idim; kr++)\n\t  {\n\t     stemp[kr] = fabs(stemp[kr] - sd[ki*idim+kr]);\n\t     el2err[kr] += thelp*stemp[kr]*stemp[kr];\n\t     if (stemp[kr] > emxerr[kr]) emxerr[kr] = stemp[kr];\n\t  }\n     }\n   for (kr=0; kr<idim; kr++)\n     el2err[kr] = sqrt(el2err[kr]);\n\t\n   \n   *jstat = 0;\n   goto out;\n   \n   /* Error in space allocation.  */\n   \n   err101: *jstat = -101;\n   goto out;\n   \n   out:\n      /* Free scratch used for local array.  */\n      \n      if (stemp != SISL_NULL) freearray(stemp);\n\t  \n      return;\n}\n   \n"
  },
  {
    "path": "src/sh1926.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1926.c,v 1.2 2001-03-19 15:59:06 afr Exp $\n *\n */\n\n#define SH1926\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      sh1926(double etau[],int ik,int in,int idim,double et[],double ed[],\n\t     int im,double ea[],int nfirst[],int nlast[],double eb[],\n\t     int n2sta[],double ec[],int *jstat)\n#else\nvoid sh1926(etau,ik,in,idim,et,ed,im,ea,nfirst,nlast,eb,n2sta,ec,jstat)\n   double etau[];\n   int ik;\n   int in;\n   int idim;\n   double et[];\n   double ed[];\n   int im;\n   double ea[];\n   int nfirst[];\n   int nlast[];\n   double eb[];\n   int n2sta[];\n   double ec[];\n   int *jstat;\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : To set up the normal equations for solving the linear\n*              system ea*x=ed in a wighted least squares sense. The\n*              least squares problem stems from the problem of approximating\n*              the spline with knot vector et and B-spline coefficients \n*              ed from the subspace generated by the knot vector etau\n*              which is a subsequence of et. The aim is to minimize a\n*              weighted 2-norm of the coefficients of the difference between\n*              a spline from the spline space generated by etau and the\n*              given spline in the spline space gernerated by et expressed\n*              in the latter space.\n* \n* INPUT      : etau   - Real array of length (in+ik) containing the  \n*                       knot vector of the approximatin space.\n*\t       ik     - The order of the spline space.\n*              in     - The dimension of the spline space corresponding\n*                       to etau.\n*              idim   - The dimension of the geometry space.\n*              et     - Real array of length (im+ik) containing the refined\n*                       knot vector.\n*              ed     - Real array of length (im*idim) containing the B-spline\n*                       coefficients of the spline to be approximated.\n*              im     - The dimension of the spline space corresponding to et.\n*              ea     - Real array of dimension (im*ik) containing \n*                       the B-spline refinement matrix from the knot vector\n*                       etau to the knot vector et. This matrix has\n*                       dimension im*in but since at most\n*                       ik entries are nonzero in each row, it can\n*                       be stored in a im*ik array together\n*                       with two integer arrays indicating the position\n*                       of the first and last nonzero elements in each\n*                       row.\n*              nfirst - Integer array of dimension (im) containing \n*                       pointers to the first nonzero element of each row \n*                       of the B-spline refinement matrix from etau to et.\n*              nlast  - Integer array of dimension (im) containing \n*                       pointers to the last nonzero element of each row \n*                       of the B-spline refinement matrix from etau to et.\n*\n* \n* OUTPUT     : eb     - Real array of dimension (in*ik) containing the \n*                       coefficient matrix of the normal equations. This\n*                       is really a in*in matrix but since each row of ea\n*                       only has at most ik nonzero elements and eb\n*                       essentially is of the form eb = ea(tr)*ea, it is\n*                       easy to see that eb is a band matrix of band with\n*                       at most ik. Since eb also is symmetric it is enough\n*                       to store the elements below and on the diagonal.\n*                       This is done by storing the diagonal element of row\n*                       i in eb(i*ik+ik-1), and then letting d2sta[i] indicat\n*                       the position of the first nonzero element in row i of eb.\n*              n2sta  - Integer array of length (in*idim) containing pointers to\n*                       the first nonzero elements of the in rows of eb.\n*              ec     - Real array of lengh (in*idim) containing the right\n*                       hand side of the normal equations (or really the\n*                       idim right hand sides).\n*              jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*             \n* \n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        :\n*\n*-\n* CALLS      :   \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.92, on the basis of a routine\n*              written by Tom Lyche and Knut Moerken, 12.85.\n*\n*********************************************************************\n*/\n{ \n  int ki,kj,kr;\n  int ki1,ki2,kr1,kj1;\n  int kik,kih,krh;\n  double tw;\n  double thelp;\n  double *swa = SISL_NULL;\n  \n  /* Allocate space for a local array of lenth in to be used during\n     multiplication with dtau(-1/2).  */\n  \n  if ((swa = newarray(in,DOUBLE)) == SISL_NULL)goto err101;\n  \n  /* Initiate output arrays to zero.  */\n  \n  for (kj=0; kj<in; kj++) n2sta[kj] = -1;\n  memzero(ec,in*idim,DOUBLE);\n  memzero(eb,in*ik,DOUBLE);\n  \n  /* Determine the normal equations.\n     Compute ea(tr)*dt*ea and ea(tr)*dt*ed and store in eb and ec\n     respectively.  */\n  \n  for (kj=0; kj<im; kj++)\n    {\n       ki1 = nfirst[kj];\n       ki2 = nlast[kj];\n       kr1 = ik - ki2 + ki1 - 1;\n       tw = (et[kj+ik] - et[kj])/(double)ik;\n       kik = ik - 1;\n       for (kr = kr1; kr<ik; ki1++, kik--, kr++)\n\t {\n\t    if (n2sta[ki1] == -1) n2sta[ki1] = kik;\n\t    kih = ik - ki2 + ki1 - 1;\n\t    krh = ik - 1;\n\t    thelp = tw*ea[kj*ik+kr];\n\t    for (ki=ki1; ki<=ki2; kih++, krh--, ki++)\n\t      eb[ki*ik+krh] += ea[kj*ik+kih]*thelp;\n\t    kih = kr - ik + ki2 + 1;\n\t    for (ki=0; ki<idim; ki++)\n\t      ec[kih*idim+ki] += ed[kj*idim+ki]*thelp;\n\t }\n    }\n  \n  /* Multiply eb and ec by dtau(-1/2).  */\n  \n  for (ki=0; ki<in; ki++)\n    swa[ki] = sqrt((double)ik/(etau[ki+ik]-etau[ki]));\n  for (ki=0; ki<in; ki++)\n    {\n       thelp = swa[ki];\n       for (kj=0; kj<idim; kj++)\n\t ec[ki*idim+kj] *= thelp;\n       for (kj1=n2sta[ki], kih=kj1-ik+ki+1, kj=kj1;\n\tkj<ik; kih++, kj++)\n\t eb[ki*ik+kj] *= swa[kih]*thelp;\n    }\n   \n\n  /* Normal equations set.  */\n  \n   *jstat = 0;\n   goto out;\n   \n   /* Error in space allocation.  */\n   \n   err101: *jstat = -101;\n   goto out;\n   \n   out:\n      /* Free scratch used for local array.  */\n      \n      if (swa != SISL_NULL) freearray(swa);\n\t  \n      return;\n}\n   \n"
  },
  {
    "path": "src/sh1927.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1927.c,v 1.3 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n#define SH1927\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      sh1927(double etau[],int ik,int in,int idim,SISLCurve *pcurve,\n\t     int ilend,int irend,double ec[],int *jstat)\n#else\nvoid sh1927(etau,ik,in,idim,pcurve,ilend,irend,ec,jstat)\n   double etau[];\n   int ik;\n   int in;\n   int idim;\n   SISLCurve *pcurve;\n   int ilend;\n   int irend;\n   double ec[];\n   int *jstat;\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : To compute the ilend first and irend last coefficients\n*              of a spline on the knot vector etau with 0 - ilend-1\n*              derivatives at etau[ik-1] equal to the corresponding derivates\n*              of the spline given by et and ed at the point et[ik-1], and\n*              similarily for the 0 - irend-1 derivative at etau[in] and\n*              et[im] respectively. et denotes the knotvector of pcurve and im\n*              is the number of knots.\n* \n* INPUT      : etau   - Real array of length (in+ik) containing the  \n*                       knot vector of the approximating space.\n*\t       ik     - The order of the spline space.\n*              in     - The dimension of the spline space corresponding\n*                       to etau.\n*              idim   - The dimension of the geometry space.\n*              pcurve - The B-spline to be approximated.\n*              ilend  - Parameter giving the number of derivatives to be\n*                       kept fixed at etau[ik-1], ie.e at the left end of the\n*                       curve. This means that the 0 - ilend-1 derivatives at\n*                       etau[ik-1], of the spline given by etau and ec will\n*                       be the same as the corresponding derivatives at \n*                       et[ik-1], of the spline given by et and ed. \n*                       NB! If ilend is negative it will be set to zero, if\n*                       it is greater than ik, it will be set equal to ik.\n*              irend  - Parameter giving the number of derivatives to be\n*                       kept fixed at etau[in], ie.e at the right end of the\n*                       curve. This means that the 0 - irend-1 derivatives at\n*                       etau[in], of the spline given by etau and ec will\n*                       be the same as the corresponding derivatives at \n*                       et[im], of the spline given by et and ed. \n*                       NB! If irend is negative it will be set to zero, if\n*                       it is greater than ik, it will be set equal to ik.\n*\n* \n* OUTPUT     : ec     - Real array of lengh (in*idim) containing B-spline\n*                       coefficients of the new spline with knot vector etau\n*                       with derivatives similar to those of the spline given\n*                       by et and ed at the beginning and end of the curve.\n*                       Only the first ilend and the last irend sets of \n*                       coefficients (each set consists of idim coefficients)\n*                       receive a value in this routine.\n*              jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*             \n* \n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        :\n*\n*-\n* CALLS      :   \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.92, on the basis of a routine\n*              written by Tom Lyche and Knut Moerken, 12.85.\n*\n*********************************************************************\n*/\n{ \n   int kstat;\n   int kn,km;\n   int ki,kj,kr,kp;\n   int krh,kjh,khc,kjhc;\n   int kstart,kstop;\n   int kleft = ik - 1;\n   double tm;\n   double th;\n   double *sder=SISL_NULL;\n   double *sbder=SISL_NULL;\n   double *ssum = SISL_NULL;\n   double *shc = SISL_NULL;\n\n   /* Test input.  */\n\n   if (pcurve->ik != ik) goto err106;\n   if (pcurve->idim != idim) goto err103;\n  \n   /* Allocate scratch for local arrays.  */\n   \n   if ((sder = newarray(idim*MAX(ilend,irend),DOUBLE)) == SISL_NULL)\n      goto err101;\n   if ((sbder=newarray(ik*ik,DOUBLE)) == SISL_NULL) goto err101;\n   if ((ssum = newarray(idim,DOUBLE)) == SISL_NULL) goto err101;\n   if ((shc = newarray(MAX(1,irend)*idim,DOUBLE)) == SISL_NULL) goto err101;\n   \n   /* Check the input and adjust if necessary.  */\n   \n   if (ilend < 0) ilend = 0;\n   if (ilend > ik) ilend = ik;\n   if (irend < 0) irend = 0;\n   if (irend > ik) irend = ik;\n   \n   /* Set output array to zero.  */\n   \n   memzero(ec,in*idim,DOUBLE);\n   \n   /* Treat left end if any coefficients are kept fixed.  */\n   \n   if (ilend > 0)\n   {\n      /* Compute the necessary derivatives. */\n      \n      s1221(pcurve,ilend-1,pcurve->et[ik-1],&kleft,sder,&kstat);\n      if (kstat < 0) goto error;\n      \n      s1220(etau,ik,in,&kleft,etau[ik-1],ilend-1,sbder,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Compute the multiplicity of etau[ik-1] (from the left).  */\n\t\t     \n      for (km=1; ; km++)\n\tif (km == ik || etau[ik-km-1] < etau[ik-km]) break;\n      \n      /* The first diagonal block is known to be of dimension kn=ik-km. */\n      \n      kn = ik - km;\n\t\n      /* Perform LU-factorization of the transpose of this first block\n\t which is a dense, square matrix.   */\n      \n      if (km < ik)\n      {\n\t for (kr=0; kr<kn-1; kr++)\n\t   for (ki=kr+1; ki<kn; ki++)\n\t     {\n\t\ttm = sbder[kr*ilend+ki]/sbder[kr*ilend+kr];\n\t\tfor (kj=kr+1; kj<kn; kj++)\n\t\t  sbder[kj*ilend+ki] -= tm*sbder[kj*ilend+kr];\n\t\tfor (kp=0; kp<idim; kp++)\n\t\t  sder[ki*idim+kp] -= tm*sder[kr*idim+kp];\n\t     }\n\t \n\t /* Find the value of ec[0],...,ec[kn-1] by back substitution.  */\n\t \n\t tm = (double)1.0/sbder[(kn-1)*ilend+kn-1];\n\t for (kp=0; kp<idim; kp++)\n\t   ec[(kn-1)*idim+kp] = sder[(kn-1)*idim+kp]*tm;\n\t for (kr=kn-2; kr>=0; kr--)\n\t   {\n\t      memzero(ssum,idim,DOUBLE);\n\t      for (kj=kr+1; kj<kn; kj++)\n\t\t{\n\t\t   tm = sbder[kj*ilend+kr];\n\t\t   for (kp=0; kp<idim; kp++)\n\t\t     ssum[kp] += ec[kj*idim+kp]*tm;\n\t\t}\n\t      \n\t      tm = (double)1.0/sbder[kr*ilend+kr];\n\t      for (kp=0; kp<idim; kp++)\n\t\tec[kr*idim+kp] = (sder[kr*idim+kp] - ssum[kp])*tm;\n\t   }\n      }\n      \n      /* Determine ec[kn],...ec[ilend-1]. This is simple since the\n\t second block is upper triangular.  */\n      \n      for (kr=kn; kr<ilend; kr++)\n\t{\n\t   memzero(ssum,idim,DOUBLE);\n\t   for (kj=0; kj<kr; kj++)\n\t     {\n\t\ttm = sbder[kj*ilend+kr];\n\t\tfor (kp=0; kp<idim; kp++)\n\t\t  ssum[kp] += ec[kj*idim+kp]*tm;\n\t     }\n\t   \n\t   tm = (double)1.0/sbder[kr*ilend+kr];\n\t   for (kp=0; kp<idim; kp++)\n\t     ec[kr*idim+kp] = (sder[kr*idim+kp] - ssum[kp])*tm;\n\t}\n      \n      /* Finished with the left end.  */\n   }\n      \n   /* Treat right end if any coefficients are kept fixed. */\n   \n   if (irend > 0)\n   {\n      /* Compute the derivatives of the original spline at et[im],\n\t and the derivatives of the last ik B-splines associated with\n\t etau at the point etau[in].  */\n      \n      kleft = pcurve->in;\n      s1221(pcurve,irend-1,pcurve->et[pcurve->in],&kleft,sder,&kstat);\n      if (kstat < 0) goto error;\n\t\t     \n      kleft = in;\t\t     \n      s1220(etau,ik,in,&kleft,etau[in],irend-1,sbder,&kstat);\n      if (kstat < 0) goto error;\n\t\t\t\t    \n      /* Compute the multiplicity of etau[ik-1] (from the right).  */\n\t\t\t\t    \n      for (km=1; ; km++)\n\tif (km == ik || etau[in+km-1] < etau[in+km]) break;\n      \n      /* The coefficient matrix is now block upper triangular (really\n\t lower triangular but we are working with the transpose of the \n\t matrix) along the bi-diagonal, with a square block of dimension \n\t (ik-im)*(ik-im) in the upper right corner, and a upper triangular\n\t matrix of dimensions kn*km in the lower left corner (in case \n\t irend=ik).\n\t The solution of this system is stored in an extra array shc\n\t so that the average of the two solutions (the one at the beginning\n\t and the one at the end) can be easily calculated where the \n\t overlap.       */\n\n      khc = idim*(irend-1);\n\n      /* if pcurve->in = ik, the whole system is triangular.  */\n      \n      if (km < ik)\n      {\n\t /* Perform LU-factorizing of the square matrix in the upper right\n\t    corner and perform the corresponding forward substitution\n\t    on sder.    */\n\t \n\t for (krh=0, kstop=ik-km, kr=km+1; kr<ik-1; kr++)\n\t   for (krh++, ki=krh+1; ki<kstop; ki++)\n\t     {\n\t\ttm = sbder[kr*irend+ki]/sbder[kr*irend+krh];\n\t\tfor (kj=kr+1; kj<ik; kj++)\n\t\t  sbder[kj*irend+ki] -= tm*sbder[kj*irend+krh];\n\t\tfor (kp=0; kp<idim; kp++)\n\t\t  sder[ki*idim+kp] -= tm*sder[krh*idim+kp];\n\t     }\n\t \n\t /* Compute the last ik-km unknowns by back substitution.  */\n\t \n\t krh = ik - km;\n\t tm = (double)1.0/sbder[ik*irend+krh];\n\t for (kp=0; kp<idim; khc++, kp++)\n\t   shc[khc] = sder[krh*idim+kp]*tm;\n\t for (kstop=in-ik+km+1, kr=in-1; kr>=kstop; kr--)\n\t   {\n\t      khc -= 2*idim;\n\t      krh--;\n\t      memzero(ssum,idim,DOUBLE);\n\t      for (kjhc=khc+idim, kjh=km+krh, kj=kr+1; kj<kn; kj++)\n\t\t{\n\t\t   tm = sbder[kjh*irend+krh];\n\t\t   for (kp=0; kp<idim; kjhc++, kp++)\n\t\t     ssum[kp] += shc[kjhc]*tm;\n\t\t}\n\t      \n\t      tm = (double)1.0/sbder[(krh+km)*irend+krh];\n\t      for (kp=0; kp<idim; khc++, kp++)\n\t\tshc[khc] = (sder[krh*idim+kp] - ssum[kp])*tm;\n\t   }\n\t khc -= 2*idim;\n      }\n\n\n   /* Compute the remaining unknowns by straight forward elimination. */\n   \n   for (krh=ik-km, kstart=in-ik+km-1, kstop=in-irend, kr=kstart;\n    kr>=kstop; krh++, kr--)\n     {\n\tmemzero(ssum,idim,DOUBLE);\n\tfor (kjhc=khc+idim, kjh=ik-krh, kj=kr+1; kj<in; kjh++, kj++)\n\t  {\n\t     tm = sbder[kjh*irend+krh];\n\t     for (kp=0; kp<idim; kjhc++, kp++)\n\t       ssum[kp] += shc[kjhc]*tm;\n\t  }\n\t\n\ttm = (double)1.0/sbder[(ik-krh-1)*irend+krh];\n\tfor (kp=0; kp<idim; khc++, kp++)\n\t  shc[khc] = (sder[krh*idim+kp] - ssum[kp])*tm;\n\tkhc -= 2*idim;\n     }\n   \n   /* Put the last irend coefficients into ec, but set ec equal to the\n      average of the two solutions where they overlap.  */\n   \n   for (khc=0, ki=in-irend; ki<in; ki++)\n     for (kp=0; kp<idim; khc++, kp++)\n       {\n\t  if (ki < ilend) th = ec[ki*idim+kp];\n\t  else th = shc[khc];\n\t  ec[ki*idim+kp] = (th + shc[khc])/(double)2.0;\n       }\n   }\n   \n   *jstat = 0;\n   goto out;\n   \n   /* Error in space allocation.  */\n   \n   err101: *jstat = -101;\n   goto out;\n\n   /* Conflicting dimensions. */\n   \n   err103: *jstat = -103;\n   goto out;\n   \n   /* Conflicting orders of curves. */\n   \n   err106: *jstat = -106;\n   goto out;\n   \n   /* Error in lower level routine.  */\n   \n   error: *jstat = kstat;\n   goto out;\n   \n   out:\n      /* Free scratch used for local array.  */\n      \n      if (sder != SISL_NULL) freearray(sder);\n      if (sbder != SISL_NULL) freearray(sbder);\n      if (ssum != SISL_NULL) freearray(ssum);\n      if (shc != SISL_NULL) freearray(shc);\n\n      return;\n}\n   \n"
  },
  {
    "path": "src/sh1928.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1928.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n#define SH1928\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      sh1928(double etau[],int ik,int in,int idim,double et[],\n\t     double ed[],int im,int ilend,int irend,\n\t     double ea[],int inh,int nfirst[],int nlast[],\n\t     double eb[],double ec[],int n2sta[],int *jstat)\n#else\nvoid sh1928(etau,ik,in,idim,et,ed,im,ilend,irend,ea,inh,nfirst,nlast,\n\t    eb,ec,n2sta,jstat)\n   double etau[];\n   int ik;\n   int in;\n   int idim;\n   double et[];\n   double ed[];\n   int im;\n   int ilend;\n   int irend;\n   double ea[];\n   int inh;\n   int nfirst[];\n   int nlast[];\n   double eb[];\n   double ec[];\n   int n2sta[];\n   int *jstat;\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : To set up the normal equations for solving the linear\n*              system ea*x=ed in a wighted least squares sense. The\n*              least squares problem stems from the problem of approximating\n*              the spline with knot vector et and B-spline coefficients \n*              ed from the subspace generated by the knot vector etau\n*              which is a subsequence of et. The aim is to minimize a\n*              weighted 2-norm of the coefficients of the difference between\n*              a spline from the spline space generated by etau and the\n*              given spline in the spline space gernerated by et expressed\n*              in the latter space.\n*              However, there are side constraints which means that the first\n*              ilend and the last irend unknowns have already been computed\n*              and the right-hand-side adjusted correspondingly so columns\n*              0,...,ilend-1 and in-irend,...,in-1 of ea are to be ignored.\n* \n* INPUT      : etau   - Real array of length (in+ik) containing the  \n*                       knot vector of the approximatin space.\n*\t       ik     - The order of the spline space.\n*              in     - The dimension of the spline space corresponding\n*                       to etau.\n*              idim   - The dimension of the geometry space.\n*              et     - Real array of length (im+ik) containing the refined\n*                       knot vector.\n*              ed     - Real array of length (im*idim) containing the B-spline\n*                       coefficients of the spline to be approximated.\n*              im     - The dimension of the spline space corresponding to et.\n*              ilend  - The number of derivatives that are to be kept fixed\n*                       at the left end of the spline.\n*              irend  - The number of derivatives that are to be kept fixed\n*                       at the right end of the spline.\n*              ea     - Real array of dimension (im*ik) containing \n*                       the B-spline refinement matrix from the knot vector\n*                       etau to the knot vector et. This matrix has\n*                       dimension im*in but since at most\n*                       ik entries are nonzero in each row, it can\n*                       be stored in a im*ik array together\n*                       with two integer arrays indicating the position\n*                       of the first and last nonzero elements in each\n*                       row.\n*              inh    - The dimension of the system of normal equations\n*                       (inh=in-ilend-irend+1).\n*              nfirst - Integer array of dimension (im) containing \n*                       pointers to the first nonzero element of each row \n*                       of the B-spline refinement matrix from etau to et.\n*              nlast  - Integer array of dimension (im) containing \n*                       pointers to the last nonzero element of each row \n*                       of the B-spline refinement matrix from etau to et.\n*\n* \n* OUTPUT     : eb     - Real array of dimension (inh*ik) containing the \n*                       coefficient matrix of the normal equations. This\n*                       is really a in*in matrix but since each row of ea\n*                       only has at most ik nonzero elements and eb\n*                       essentially is of the form eb = ea(tr)*ea, it is\n*                       easy to see that eb is a band matrix of band with\n*                       at most ik. Since eb also is symmetric it is enough\n*                       to store the elements below and on the diagonal.\n*                       This is done by storing the diagonal element of row\n*                       i in eb(i*ik+ik-1), and then letting d2sta[i] indicate\n*                       the position of the first nonzero element in row i \n*                       of eb.\n*              ec     - Real array of lengh (in*idim) containing the right\n*                       hand side of the normal equations (or really the\n*                       idim right hand sides).\n*              n2sta  - Integer array of length (in*idim) containing pointers\n*                       to the first nonzero elements of the in rows of eb.\n*              jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*             \n* \n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        :\n*\n*-\n* CALLS      :   \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.92, on the basis of a routine\n*              written by Tom Lyche and Knut Moerken, 12.85.\n*\n*********************************************************************\n*/\n{ \n  int ki,kj,kr;\n  int ki1,ki2,kr1,kj1;\n  int kik,kih,krh,kihh,krhh;\n  double tw;\n  double thelp;\n  double *swa = SISL_NULL;\n  \n  /* Allocate space for a local array of length in to be used during\n     multiplication with dtau(-1/2).  */\n  \n  if ((swa = newarray(in,DOUBLE)) == SISL_NULL)goto err101;\n  \n  /* Initiate output arrays to zero.  */\n  \n  for (kj=0; kj<inh; kj++) n2sta[kj] = -1;\n  memzero(ec+ilend*idim,inh*idim,DOUBLE);\n  memzero(eb,inh*ik,DOUBLE);\n  \n  /* Determine the normal equations.\n     Compute ea(tr)*dt*ea and ea(tr)*dt*ed and store in eb and ec\n     respectively.  */\n  \n  for (kj=0; kj<im; kj++)\n    {\n       ki1 = MAX(nfirst[kj],ilend);\n       ki2 = MIN(nlast[kj],in-irend-1);\n       kr1 = ik - ki2 + ki1 - 1;\n       tw = (et[kj+ik] - et[kj])/(double)ik;\n       kik = ik - 1;\n       krhh = ik - nlast[kj] + ki1 - 1;\n       for (kr = kr1; kr<ik; ki1++, kik--, krhh++, kr++)\n\t {\n\t    kihh = ki1 - ilend;\n\t    if (n2sta[kihh] == -1) n2sta[kihh] = kik;\n\t    kih = ik - nlast[kj] + ki1 - 1;\n\t    krh = ik - 1;\n\t    thelp = tw*ea[kj*ik+krhh];\n\t    for (ki=ki1; ki<=ki2; kih++, kihh++, krh--, ki++)\n\t      eb[kihh*ik+krh] += ea[kj*ik+kih]*thelp;\n\t    kih = kr - ik + ki2 + 1;\n\t    for (ki=0; ki<idim; ki++)\n\t      ec[kih*idim+ki] += ed[kj*idim+ki]*thelp;\n\t }\n    }\n  \n  /* Multiply eb and ec by dtau(-1/2), but remember to skip the first ilen\n     and last irend elements of ec and dtau. */\n  \n  for (kihh=ilend, ki=0; ki<inh; kihh++, ki++)\n       swa[ki] = sqrt((double)ik/(etau[kihh+ik]-etau[kihh]));\n\n  for (kihh=ilend, ki=0; ki<inh; kihh++, kih++, ki++)\n    {\n       thelp = swa[ki];\n       for (kj=0; kj<idim; kj++)\n\t ec[kihh*idim+kj] *= thelp;\n       for (kj1=n2sta[ki], kih=kj1-ik+ki+1, kj=kj1;\n\tkj<ik; kih++, kj++)\n\t eb[ki*ik+kj] *= swa[kih]*thelp;\n    }\n   \n\n  /* Normal equations set.  */\n  \n   *jstat = 0;\n   goto out;\n   \n   /* Error in space allocation.  */\n   \n   err101: *jstat = -101;\n   goto out;\n   \n   out:\n      /* Free scratch used for local array.  */\n      \n      if (swa != SISL_NULL) freearray(swa);\n\t  \n      return;\n}\n   \n"
  },
  {
    "path": "src/sh1929.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1929.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n#define SH1929\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      sh1929(double etau[],int in,int ik,int imu,double et[],int im,\n\t     int ij,double eah[],int *jmuprm,int *jnu,int *jstat)\n#else\nvoid sh1929(etau,in,ik,imu,et,im,ij,eah,jmuprm,jnu,jstat)\n   double etau[];\n   int in;\n   int ik;\n   int imu;\n   double et[];\n   int im;\n   int ij;\n   double eah[];\n   int *jmuprm;\n   int *jnu;\n   int *jstat;\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : To compute the nonzero discrete B-splines at ij of order\n*              ik, given the knot vector etau and the refined knot vector\n*              et. Equivalently to compute the nonzero elements of row ij\n*              of the B-spline refinement matrix from the knot vector etau to\n*              the knot vector et.\n* \n* INPUT      : etau   - Real array of length (in+ik) containing the original \n*                       knot vector.\n*              in     - The dimension of the spline space corresponding\n*                       to etau.\n*\t       ik     - The order of the spline space.\n*              imu    - Integer with the property: \n*                          etau[imu] <= et[ij] < etau[imu+1]\n*              et     - Real array of length (im+ik) containing the refined\n*                       knot vector.\n*              im     - The dimension of the spline space corresponding to et.\n*              ij     - The point at which the value of the discrete B-splines\n*                       is to be evaluated, or equivalently, the row of \n*                       the B-spline refinement matrix that is to be computed.\n*                       The integer ij is the index of an element of the\n*                       knot vector with 1 <= ij <= im. In addition it is\n*                       assumed that there is at least one nonzero discrete\n*                       B-spline at ij.\n*\n* \n* OUTPUT     : eah    - Real array of length (ik) containing the value of the\n*                       (at most) ik nonzero discrete B-splines at ij, with \n*                       the last nonzero value in eah[ik-1].\n*              jmuprm - Integer giving the position of the last nonzero \n*                       discrete B-spline at ij in the etau knot vector.\n*              jnu    - Integer giving the number of nonzero discrete\n*                       B-splines at ij reduced by one, i.e.\n*                       #nonzero B-splines=inu+1. This may not be true near\n*                       the beginning and end of etau. In general the nonzero \n*                       discrete B-splines are the ones with index i\n*                       satisfying MAX(*jmuprm-*jnu,1) <= i <= MIN(*jmuprm,in).\n*              jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*             \n* \n* METHOD     : \n*\n*\n* REFERENCES : Lyche, T. and Moerken, K., Making the Oslo algorithm more\n*              efficient, SIAM Journal of numerical analyis, June 1986.\n*              \n*\n* USE        :\n*\n*-\n* CALLS      :   \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.92, on the basis of a routine\n*              written by Tom Lyche and Knut Moerken, 12.85.\n*\n*********************************************************************\n*/\n{ \n   int ki,kp;\n   int kih,kil,kiu,kkh;\n   int k1 = ik - 1;\n   double tbeta,tbeta1;\n   double tj;\n   double td1,td2;\n   double *ssi = SISL_NULL;\n   \n   /* Allocate scratch for a local array of length (ik-1) to hold the\n      new knots among et[ij+1],...,et[ij+ik-1].  */\n   \n   if ((ssi = newarray(ik-1,DOUBLE)) == SISL_NULL) goto err101;\n\n   /* Determine jmuprm.  */\n   \n   for (ki=ij+1, *jmuprm=imu; DEQUAL(et[ki],etau[*jmuprm]) && ki<ij+ik;\n        ki++, (*jmuprm)--);\n   kih = (*jmuprm) + 1;\n   *jnu = 0;\n   \n   /* Determine the new knots (together with jnu) and store them in ssi.  */\n\n   for (kp=1; kp<=k1; kp++)\n     {\n\tif (DEQUAL(et[ij+kp],etau[kih])) kih++;\n\telse\n\t{\n\t   ssi[*jnu] = et[ij+kp];\n\t   (*jnu)++;\n\t}\n     }\n   \n   /* Compute the eah-array.\n      The discrete B-splines are built up one order at a time starting with\n      splines of order one. With *jnu knots the number of nonzero discrete\n      B-splines of order ik at ij will be *jnu+1.   */\n   \n   eah[k1] = (double)1.0;\n   for (kp=0; kp<(*jnu); kp++)\n     {\n\ttbeta1 = (double)0.0;\n\ttj = ssi[kp];\n\tkih = kp + ik - (*jnu);\n\tif (kp >= (*jmuprm))\n\t   tbeta1 = (tj-etau[0])*eah[ik-(*jmuprm)-1]/(etau[kih]-etau[0]);\n\tkil = (*jmuprm) - kp;\n\tkiu = in + (*jnu) - kp;\n\tif (kil < 1 ) kil = 1;\n\tif (kiu > (*jmuprm)) kiu = (*jmuprm);\n\tfor (ki=kil; ki<=kiu; ki++)\n\t  {\n\t     td1 = tj - etau[ki];\n\t     td2 = etau[ki+kih] - tj;\n\t     tbeta = eah[ki+ik-(*jmuprm)-1]/(td1+td2);\n\t     eah[ki+ik-(*jmuprm)-2] = td2*tbeta + tbeta1;\n\t     tbeta1 = td1*tbeta;\n\t  }\n\tkkh = kiu + ik - (*jmuprm) - 1;\n\teah[kkh] = tbeta1;\n\tif (kiu < (*jmuprm)) \n\t   eah[kkh] = tbeta1 + \n\t   (etau[in+ik-1]-tj)*eah[kkh+1]/(etau[in+ik-1]-etau[kiu+1]);\n     }\n   \n   /* Discrete B-splines computed.  */\n\n   *jstat = 0;\n   goto out;\n   \n   /* Error in space allocation.  */\n   \n   err101: *jstat = -101;\n   goto out;\n   \n   out:\n      /* Free scratch used for local array.  */\n      \n      if (ssi != SISL_NULL) freearray(ssi);\n\t  \n      return;\n}\n   \n   \n"
  },
  {
    "path": "src/sh1930.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1930.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n#define SH1930\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      sh1930(double ea[],int nfirst[],int nlast[],double ed[],double ec[],\n\t     int ik,int in,int im,int idim,int ilend,int irend,int *jstat)\n#else\nvoid sh1930(ea,nfirst,nlast,ed,ec,ik,in,im,idim,ilend,irend,jstat)\n   double ea[];\n   int nfirst[];\n   int nlast[];\n   double ed[];\n   double ec[];\n   int ik;\n   int in;\n   int im;\n   int idim;\n   int ilend;\n   int irend;\n   int *jstat;\n#endif     \n/*\n*********************************************************************\n* \n* PURPOSE    : To modify a least squares problem to take into account \n*              equality constraints at the beginning and end of the vector\n*              of unknowns.\n* \n* INPUT      : ea     - Real array of dimension (im*ik) containing \n*                       the coefficient matrix of the problem. This matrix has\n*                       dimension im*in but since at most\n*                       ik entries are nonzero in each row, it can\n*                       be stored in a im*ik array together\n*                       with two integer arrays indicating the position\n*                       of the first and last nonzero elements in each\n*                       row. In addition it is known that the last nonzero\n*                       element of row ki is stored in ea[ki*ik+ik-1].\n*              nfirst - Integer array of dimension (im) containing \n*                       pointers to the first nonzero element of each row \n*                       of the original matrix.\n*              nlast  - Integer array of dimension (im) containing \n*                       pointers to the last nonzero element of each row \n*                       of the original matrix.\n*              ed     - Real array of dimension (in*idim) containing the \n*                       'right hand side' of the least squares problem.\n*              ec     - Real array of dimension (in*idim) which is to contain\n*                       the solution of the least squares problem. Upon entry\n*                       of this routine ec[0],...ec[ilend] and \n*                       ec[in-irend],...,ec[in-1] (assuming idim=1) contain\n*                       the values wich are forced by the constraints\n*                       (the first ilend derivatives are to be kept fixed\n*                       at the beginning of the curve, and the last irend at\n*                       the end of the curve).\n*\t       ik     - The order of the spline space in the underlying least\n*                       squares problem.\n*              in     - The number of unknowns in the original least squares\n*                       problem. This is reduced by (ilend+irend) due to the\n*                       constraints.\n*              im     - The number of constraints in the least squares problem\n*                       excluding the (ilend+irend) side constraints.\n*              idim   - The dimension of the geometry space.\n*              ilend  - The number of coefficients at the beginning of ec\n*                       which have a value.\n*              irend  - The number of coefficients at the end of ec\n*                       which have a value.\n*              \n*\n* \n* OUTPUT     : ed     - Real array of dimension (im*idim) containing the new\n*                       'right hand side' of the problem, which takes into\n*                       consideration the side constraints.\n*              jstat      - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*             \n* \n* METHOD     : \n*\n*\n* REFERENCES : \n*              \n*\n* USE        :\n*\n*-\n* CALLS      :   \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.92, on the basis of a routine\n*              written by Tom Lyche and Knut Moerken, 12.85.\n*\n*********************************************************************\n*/\n{ \n   int ki,kj,kr;\n   int kjst;\n   int knk1;\n   double th;\n   double *shelp = SISL_NULL;\n\n   /* Check input.  */\n   \n   if (ilend + irend >= in) goto err203;\n\n   /* Allocate scratch for help array and set to zero. */\n\t\t\t    \n   if ((shelp = new0array(idim,DOUBLE)) == SISL_NULL) goto err101;\n   \n   /* Make adjustments for the fact that ec[0],...,ec[ilend-1] are known\n      This is done by going through the rows of the coefficient matrix until\n      the first nonzero element is in column ilend or further to the right. */\n   \n   for (ki=0; ; ki++)\n     {\n\t/* The maximum column is im-1.  */\n\t\n\tif (ki >= im) break;\n\t\n\t/* Check if the first nonzero element is far to the right. */\n\t\n\tif (nfirst[ki] > ilend) break;\n\t\n\t/* kjst points to the last column among the first ilend that has \n\t   a nonzero element in row ki.     */\n\t\n\tkjst = MIN(ilend,nlast[ki]);\n\t\n\t/* Compute the necessary adjustment for row no. ki by multiplying\n\t   together the appropriate elements fo ec and ea and\n\t   accumulate.  */\n\t\n\tfor (kj=nfirst[ki]; kj<=kjst; kj++)\n\t  {\n\t     th = ea[ki*ik+ik-nlast[ki]+kj-1];\n\t     for (kr=0; kr<idim; kr++)\n\t       shelp[kr] += th*ec[kj*idim+kr];\n\t  }\n\t\n\t/* Adjust ed[ki].  */\n\t\n\tfor (kr=0; kr<idim; kr++)\n\t  {\n\t     ed[ki*idim+kr] -= shelp[kr];\n\t     shelp[kr] = (double)0.0;\n\t  }\n     }\n   \n   /* Make adjustments for the fact that ec[in-irend],...,ec[in-1] are known.\n      This is done by going through the rows of the coefficient matrix from\n      the right until the last nonzero element is in column in-irend-1 or\n      further to the left.  */\n   \n   for (knk1=in-irend, ki=im-1; ; ki--)\n     {\n\t/* In any case we can stop when we get passed column 0.  */\n\t\n\tif (ki < 0) break;\n\t\n\t/* Check if the last nonzero element is sufficiently far to the\n\t   right. */\n\t\n\tif (nlast[ki] < knk1) break;\n\t\n\t/* kjst points to the first element in this row that is of\n\t   interest. */\n\t\n\tkjst = MAX(knk1,nfirst[ki]);\n\t\n\t/* Multiply together the appropriate elements fo ea and ec and\n\t   accumulate.  */\n\t\n\tfor (kj=kjst; kj<=nlast[ki]; kj++)\n\t  {\n\t     th = ea[ki*ik+ik-nlast[ki]+kj-1];\n\t     for (kr=0; kr<idim; kr++)\n\t       shelp[kr] += th*ec[kj*idim+kr];\n\t  }\n\t\n\t/* Adjust ed[ki].  */\n\t\n\tfor (kr=0; kr<idim; kr++)\n\t  {\n\t     ed[ki*idim+kr] -= shelp[kr];\n\t     shelp[kr] = (double)0.0;\n\t  }\n     }\n   \n   /* Modification performed.  */\n\t      \n   *jstat = 0;\n   goto out;\n   \n   /* Error in space allocation.  */\n   \n   err101: *jstat = -101;\n   goto out;\n   \n   /* Error in input.  */\n   \n   err203: *jstat = -203;\n   goto out;\n   \n   out:\n      /* Free scratch used for local array.  */\n      \n      if (shelp != SISL_NULL) freearray(shelp);\n\t  \n      return;\n}\n   \n"
  },
  {
    "path": "src/sh1992.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1992.c,v 1.4 2007-08-06 13:09:13 vsk Exp $\n *\n */\n\n\n#define SH1992\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void sh1992_s9mbox3(double [],int,int,double,double,double [],double []);\nstatic void sh1992_s9mbox2(double [],int,int,double,double,double [],double []);\nstatic void sh1992_s9mbox(double [],int,int,int,double,double,double[],double [],int *);\n#else\nstatic void sh1992_s9mbox3();\nstatic void sh1992_s9mbox2();\nstatic void sh1992_s9mbox();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh1992(SISLObject *po,int itype,double aepsge,int *jstat)\n#else\nvoid sh1992(po,itype,aepsge,jstat)\n     SISLObject *po;\n     int    itype;\n     double aepsge;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make a SISLbox on the control-polygons given by\n*              ecoef to the object. If dimension is 2 then one\n*\t       SISLbox rotated 45 degree is also made. If dimension\n*\t       is 3 then one SISLbox roteted 45 degree around each\n*\t       main axes, in all 4 boxes is made.\n*\n*\n*\n* INPUT      : po     - Object to treat.\n*              itype  - Kind of box to make.\n*                       = 0 : Do not expand box.\n*                       = 1 : Make a totally expanded box.\n*                       = 2 : Make a box expanded in the inner of the\n*                             object, and reduced along the edges/endpoints.\n*                       If itype>=10, it is interpreted as itype-10, exept\n*                       for that no rotation of the box is performed.\n*              aepsge - Geometry resolution.\n*\n* OUTPUT     : jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                                                                     \n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :  s6existbox - Check if the wanted box exist already.\n*               s6newbox   - Make a box of a given type.\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-02.\n* MODIFIED BY : Vibeke Skytt, SI, 91-01. Tolerance dependant boxes.\n* MODIFIED BY : Vibeke Skytt, SI, 92-10. Points are connected\n*                                        non-expanded boxes. Exept for\n*                                        1D, boxes are expanded with\n*                                        eps/2 and eps.\n*\n*********************************************************************\n*/                                     \n{\n   int kstat = 0;                       /* Status variable.        */\n   int kdim;                       /* Dimension of geometry space. */\n   int ktype = itype % 10;              /* Kind of box.            */\n   int knum;                            /* Number of sides of box. */\n   int k2;                              /* Other box type.         */\n   int kbez = 0;                        /* Indicates if Bezier case. */\n   double teps_inner;     /* Tolerance with which to expand in the inner. */\n   double teps_edge;      /* Tolerance with which to expand at the edge.  */\n\n   /* Set correct tolerances.  */\n   \n   teps_inner = (ktype == 0) ? DZERO : (double)0.5*aepsge;\n   teps_edge = (ktype == 2) ? -teps_inner : teps_inner;\n   \n   if (po -> iobj == SISLPOINT)\n   {\n      if (po->p1->pbox == SISL_NULL)\n\t if ((po->p1->pbox = newbox(po->p1->idim)) == SISL_NULL) goto err101;\n      \n      if (s6existbox(po->p1->pbox,ktype,aepsge) < 1)\n      {\n     \t kdim = po->p1->idim;\n\t if (itype < 10 && kdim == 3) knum = 9;\n\t else if (itype < 10 && kdim == 2) knum = 4;\n\t else knum = kdim;\n\t   \n\t /* The box do not exist already. For a point we always \n\t    use non-expanded boxes.  */\n\n\t /* Create the box.  */\n\t \n\t s6newbox(po->p1->pbox,knum,ktype,aepsge,&kstat);\n\t if (kstat < 0) goto error;\n\t \n\t teps_inner = teps_edge = DZERO;\n\t \n\t k2 = (ktype == 0) ? 0 : ((ktype == 1) ? 2 : 1);\n\t if (ktype > 0 && s6existbox(po->p1->pbox,k2,aepsge))\n\t    {\n\t       memcopy(po->p1->pbox->e2min[ktype],po->p1->pbox->e2min[k2],\n\t\t       (1+(kdim!=1))*knum,double);\n\t       memcopy(po->p1->pbox->e2max[ktype],po->p1->pbox->e2max[k2],\n\t\t       (1+(kdim!=1))*knum,double);\n\t    }\n\t    else\n\t    {\n\t       /* Make the requested box. */\n\t       \n\t       if (knum == 9) \n\t\t  sh1992_s9mbox3(po->p1->ecoef,1,1,teps_inner,teps_edge,\n\t\t\t  po->p1->pbox->e2max[ktype],po->p1->pbox->e2min[ktype]);\n\t       else if (knum == 4)\n\t\t  sh1992_s9mbox2(po->p1->ecoef,1,1,teps_inner,teps_edge,\n\t\t\t  po->p1->pbox->e2max[ktype],po->p1->pbox->e2min[ktype]);\n\t       else\n\t       {\n\t\t  sh1992_s9mbox(po->p1->ecoef,1,1,kdim,teps_inner,teps_edge,\n\t\t\t po->p1->pbox->e2max[ktype],po->p1->pbox->e2min[ktype],\n\t\t\t &kstat);\n\t\t  if (kstat < 0) goto error;\n\t       }\n\t    }\n      }\n   }\n   else if (po -> iobj == SISLCURVE)\n   {\n      if (po->c1->pbox == SISL_NULL)\n\t if ((po->c1->pbox = newbox(po->c1->idim)) == SISL_NULL) goto err101;\n      \n      if (s6existbox(po->c1->pbox,ktype,aepsge) < 1)\n      {\n     \t kdim = po->c1->idim;\n\t if (itype < 10 && kdim == 3) knum = 9;\n\t else if (itype < 10 && kdim == 2) knum = 4;\n\t else knum = kdim;\n\t \n\t /* The box do not exist already. In the Bezier case,\n\t    it is not necessary to expand in the inner of the curve.  */\n\t \n\t /* Create the box.  */\n\t \n\t s6newbox(po->c1->pbox,knum,ktype,aepsge,&kstat);\n\t if (kstat < 0) goto error;\n\t \n\t if (kdim != 1 && po->c1->ik == po->c1->in) \n         {\n            teps_inner = DZERO;\n            kbez = 1;\n\t    }\n\t \n\t /* Make the requested box. First allocate scratch for\n\t    box arrays.  */\n\t \n\t if (knum == 9) \n\t    sh1992_s9mbox3(po->c1->ecoef,po->c1->in,1,teps_inner,teps_edge,\n\t\t    po->c1->pbox->e2max[ktype],po->c1->pbox->e2min[ktype]);\n\t else if (knum == 4)\n\t    sh1992_s9mbox2(po->c1->ecoef,po->c1->in,1,teps_inner,teps_edge,\n\t\t    po->c1->pbox->e2max[ktype],po->c1->pbox->e2min[ktype]);\n\t else\n\t {\n\t    sh1992_s9mbox(po->c1->ecoef,po->c1->in,1,kdim,teps_inner,\n\t\t   teps_edge,po->c1->pbox->e2max[ktype],\n\t\t   po->c1->pbox->e2min[ktype],&kstat);\n\t    if (kstat < 0) goto error;\n         }\n      }\n   } \n   else if (po -> iobj == SISLSURFACE)\n   {\n      if (po->s1->pbox == SISL_NULL)\n\t if ((po->s1->pbox = newbox(po->s1->idim)) == SISL_NULL) goto err101;\n      \n      if (s6existbox(po->s1->pbox,ktype,aepsge) < 1)\n      {\n     \t kdim = po->s1->idim;\n\t if (itype < 10 && kdim == 3) knum = 9;\n\t else if (itype < 10 && kdim == 2) knum = 4;\n\t else knum = kdim;\n\t \n\t /* The box do not exist already. In the Bezier case, it\n\t    is not necessary to expand in the inner of the surface.  */\n\t \n\t /* Create the box.  */\n\t \n\t s6newbox(po->s1->pbox,knum,ktype,aepsge,&kstat);\n\t if (kstat < 0) goto error;\n\t \n\t if (kdim != 1 &&\n\t     po->s1->ik1 == po->s1->in1 && po->s1->ik2 == po->s1->in2) \n         {\n\t    teps_inner = DZERO;\n            kbez = 1;\n\t }\n\t \n\t /* Make the requested box. First allocate scratch for\n\t    box arrays.  */\n\t \n\t if (knum == 9) \n\t    sh1992_s9mbox3(po->s1->ecoef,po->s1->in1,po->s1->in2,teps_inner,\n\t\t    teps_edge,po->s1->pbox->e2max[ktype],\n\t\t    po->s1->pbox->e2min[ktype]);\n\t else if (knum == 4)\n\t    sh1992_s9mbox2(po->s1->ecoef,po->s1->in1,po->s1->in2,teps_inner,\n\t\t    teps_edge,po->s1->pbox->e2max[ktype],\n\t\t    po->s1->pbox->e2min[ktype]);\n\t else\n\t {\n\t    sh1992_s9mbox(po->s1->ecoef,po->s1->in1,po->s1->in2,kdim,\n\t\t   teps_inner,teps_edge,po->s1->pbox->e2max[ktype],\n\t\t   po->s1->pbox->e2min[ktype],&kstat);\n\t    if (kstat < 0) goto error;\n\t }\n      }\n   }  \n  \n  *jstat = kbez;\n  goto out;\n\n  /* Error in space allocation.  */\n  \n  err101 : *jstat = -101;\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  goto out;\n     \n out:\n    return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh1992cu(SISLCurve *pc,int itype,double aepsge,int *jstat)\n#else\nvoid sh1992cu(pc,itype,aepsge,jstat)\n     SISLCurve *pc;\n     int   itype;\n     double aepsge;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make a SISLbox on the control-polygons given by\n*              ecoef to the object. If dimension is 2 then one\n*\t       SISLbox rotated 45 degree is also made. If dimension\n*\t       is 3 then one SISLbox roteted 45 degree around each\n*\t       main axes, in all 4 boxes is made.\n*\n*\n*\n* INPUT      : pc     - SISLObject to treat.\n*              itype  - Kind of box to make.\n*                       = 0 : Do not expand box.\n*                       = 1 : Make a totally expanded box.\n*                       = 2 : Make a box expanded in the inner of the\n*                             object, and reduced along the edges/endpoints.\n*                       If itype>=10, it is interpreted as itype-10, exept\n*                       for that no rotation of the box is performed.\n*              aepsge - Geometry resolution.\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                                                                     \n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :  s6existbox - Check if the wanted box exist already.\n*               s6newbox   - Make a box of a given type.\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-02.\n* MODIFIED BY : Vibeke Skytt, SI, 91-01. Tolerance dependant boxes.\n*\n*********************************************************************\n*/                                     \n{\n   int kstat = 0;                       /* Status variable.        */\n   int kdim = pc->idim;                 /* Dimension of geometry space. */\n   int ktype = itype % 10;              /* Kind of box.            */\n   int knum;                            /* Number of sides of box. */\n   int kbez = 0;                        /* Indicates if Bezier case. */\n   double teps_inner;     /* Tolerance with which to expand in the inner. */\n   double teps_edge;      /* Tolerance with which to expand at the edge.  */\n\n   /* Set number of box sides.  */\n   \n   if (itype < 10 && kdim == 3) knum = 9;\n   else if (itype < 10 && kdim == 2) knum = 4;\n   else knum = kdim;\n   \n   /* Set correct tolerances.  */\n   \n   teps_inner = (ktype == 0) ? DZERO : (double)0.5*aepsge;\n   teps_edge = (ktype == 2) ? -teps_inner : teps_inner;\n   \n   if (pc->pbox == SISL_NULL)\n      if ((pc->pbox = newbox(pc->idim)) == SISL_NULL) goto err101;\n   \n   if (s6existbox(pc->pbox,ktype,aepsge) < 1)\n   {\n      /* The box do not exist already. In the Bezier case,\n\t it is not necessary to expand in the inner of the curve.  */\n      \n      /* Create the box.  */\n      \n      s6newbox(pc->pbox,knum,ktype,aepsge,&kstat);\n      if (kstat < 0) goto error;\n\t\t     \n      if (pc->ik == pc->in) \n      {\n          teps_inner = DZERO;\n          kbez = 1;\n      }\n      \n      /* Make the requested box. First allocate scratch for\n\t box arrays.  */\n      \n      if (knum == 9) \n\t sh1992_s9mbox3(pc->ecoef,pc->in,1,teps_inner,teps_edge,\n\t\t pc->pbox->e2max[ktype],pc->pbox->e2min[ktype]);\n      else if (knum == 4)\n\t sh1992_s9mbox2(pc->ecoef,pc->in,1,teps_inner,teps_edge,\n\t\t pc->pbox->e2max[ktype],pc->pbox->e2min[ktype]);\n      else\n      {\n\t sh1992_s9mbox(pc->ecoef,pc->in,1,kdim,teps_inner,teps_edge,\n\t\tpc->pbox->e2max[ktype],pc->pbox->e2min[ktype],&kstat);\n\t if (kstat < 0) goto error;\n       }\n   }\n  \n  *jstat = kbez;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n  err101 : *jstat = -101;\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  goto out;\n  \n out:\n    return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh1992su(SISLSurf *ps,int itype,double aepsge,int *jstat)\n#else\nvoid sh1992su(ps,itype,aepsge,jstat)\n     SISLSurf *ps;\n     int  itype;\n     double aepsge;\n     int  *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make a SISLbox on the control-polygons given by\n*              ecoef to the object. If dimension is 2 then one\n*\t       SISLbox rotated 45 degree is also made. If dimension\n*\t       is 3 then one SISLbox roteted 45 degree around each\n*\t       main axes, in all 4 boxes is made.\n*\n*\n*\n* INPUT      : ps     - SISLObject to treat.\n*              itype  - Kind of box to make.\n*                       = 0 : Do not expand box.\n*                       = 1 : Make a totally expanded box.\n*                       = 2 : Make a box expanded in the inner of the\n*                             object, and reduced along the edges/endpoints.\n*                       If itype>=10, it is interpreted as itype-10, exept\n*                       for that no rotation of the box is performed.\n*              aepsge - Geometry resolution.\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*                                                                     \n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :  s6existbox - Check if the wanted box exist already.\n*               s6newbox   - Make a box of a given type.\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-02.\n* MODIFIED BY : Vibeke Skytt, SI, 91-01. Tolerance dependant boxes.\n*\n*********************************************************************\n*/                                     \n{\n   int kstat = 0;                       /* Status variable.        */\n   int kdim = ps->idim;                 /* Dimension of geometry space. */\n   int ktype = itype % 10;              /* Kind of box.            */\n   int knum;                            /* Number of sides of box. */\n   int kbez = 0;                        /* Indicates if Bezier.    */\n   double teps_inner;     /* Tolerance with which to expand in the inner. */\n   double teps_edge;      /* Tolerance with which to expand at the edge.  */\n\n   /* Set correct tolerances.  */\n   \n   teps_inner = (ktype == 0) ? DZERO : (double)0.5*aepsge;\n   teps_edge = (ktype == 2) ? -teps_inner : teps_inner;\n   \n   /* Set number of box sides.  */\n   \n   if (itype < 10 && kdim == 3) knum = 9;\n   else if (itype < 10 && kdim == 2) knum = 4;\n   else knum = kdim;\n   \n   if (ps->pbox == SISL_NULL)\n      if ((ps->pbox = newbox(ps->idim)) == SISL_NULL) goto err101;\n   \n   if (s6existbox(ps->pbox,ktype,aepsge) < 1)\n   {\n      /* The box do not exist already. In the Bezier case, it\n\t is not necessary to expand in the inner of the surface.  */\n      \n      /* Create the box.  */\n      \n      s6newbox(ps->pbox,knum,ktype,aepsge,&kstat);\n      if (kstat < 0) goto error;\n      \n      if (ps->ik1 == ps->in1 && ps->ik2 == ps->in2) \n      {\n\t teps_inner = DZERO;\n         kbez = 1;\n      }\n      \n      /* Make the requested box. First allocate scratch for\n\t box arrays.  */\n      \n      if (knum == 9) \n\t sh1992_s9mbox3(ps->ecoef,ps->in1,ps->in2,teps_inner,teps_edge,\n\t\t ps->pbox->e2max[ktype],ps->pbox->e2min[ktype]);\n      else if (knum == 4)\n\t sh1992_s9mbox2(ps->ecoef,ps->in1,ps->in2,teps_inner,teps_edge,\n\t\t ps->pbox->e2max[ktype],ps->pbox->e2min[ktype]);\n      else\n      {\n\t sh1992_s9mbox(ps->ecoef,ps->in1,ps->in2,kdim,\n\t\tteps_inner,teps_edge,ps->pbox->e2max[ktype],\n\t\tps->pbox->e2min[ktype],&kstat);\n\t if (kstat < 0) goto error;\n      }\n   }  \n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in space allocation.  */\n  \n  err101 : *jstat = -101;\n  goto out;\n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  goto out;\n  \n out:\n    return;\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  sh1992_s9mbox3(double ecoef[],int icoef1,int icoef2,double aeps1,\n\t\t double aeps2,double e2max[],double e2min[])\n#else\nstatic void sh1992_s9mbox3(ecoef,icoef1,icoef2,aeps1,aeps2,e2max,e2min)\n     double ecoef[];\n     int    icoef1;\n     int    icoef2;\n     double aeps1;\n     double aeps2;\n     double e2max[];\n     double e2min[];\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make 4 boxes on the control-polygons given by\n*              ecoef to the object.\n*\n*\n* INPUT      : ecoef   - Control-polygon.\n*              icoef1  - Number of vertices in control-polygon in\n*                        first parameter direction.\n*              icoef2  - Number of vertices in control-polygon in\n*                        second parameter direction.\n*              aeps1   - Size of expansion to use in the inner of\n*                        the object.\n*              aeps2   - Size of expansion to use at the edge of the object.\n*\n*                                                                     \n*\n* OUTPUT     : e2max   - Array to contain maximum values of the box.\n*\t       e2min   - Array to contain minimum values of the box.\n*\n*\n* METHOD     : Make 4 boxes. One ordinary and tree boxes rotated\n*\t       45 degree around the main axes.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-02.\n* MODIFIED BY : Vibeke Skytt, SI, 91-01. \n*\n*********************************************************************\n*/                                     \n{\n  int ki,kj;             /* Counters.                                 */\n  int kant = 9;          /* Number of box sides.                      */\n  int kinset = 0;        /* Indicates if inner box is set.            */\n  double teps1 = aeps1+aeps1; /* Double tolerance in the inner.       */\n  double teps2;               /* Tolerance at edge.                   */\n  double teps3;               /* Double tolerance at edge.            */\n  double t1,t2,t3,t4;    /* To store elements of the rotation matrix. */\n  double *tmin,*tmax;    /* Pointers used to traverse e2min and e2max.  */\n  double sminin[9],smaxin[9];   /* Box boundaries in the inner.       */\n  double sminedg[9],smaxedg[9]; /* Box boundaries at the edge.        */\n  double *sc1,*sc2,*sc3; /* Pointers to coefficients.                 */\n  \n  /* Set tolerances at edge. If the tolerance is positive or dimension\n     is 1D, the input tolerance is used, otherwise we must make sure \n     that the maximum distance from the total box at the edges to the\n     reduced box is aeps2.                                             */\n  \n  if (aeps2 >= DZERO)\n     teps2 = aeps2;\n  else\n     teps2 = (double)0.2767326953*aeps2; \n  teps3 = teps2 + teps2;\n\n  /* Initiate box boundaries of inner box.  */\n  \n  for (ki=0; ki<kant; ki++)\n  {\n     sminin[ki] = HUGE;\n     smaxin[ki] = -HUGE;\n  }\n  \n  /* Fetch value of first vertex.  */\n  \n  sc1 = ecoef; sc2 = sc1+1;  sc3 = sc2 + 1;\n  t1= ROTM * sc1[0];\n  t2= ROTM * sc2[0];\n  t3= ROTM * sc3[0];\n  \n  tmin = sminedg;\n  tmax = smaxedg;\n  *tmin = *tmax = *sc1;\n  tmin++; tmax++;\n  *tmin = *tmax = *sc2;\n  tmin++; tmax++;\n  *tmin = *tmax = *sc3;\n  tmin++; tmax++;\n  *tmin = *tmax = t2-t3;\n  tmin++; tmax++;\n  *tmin = *tmax = t2+t3;\n  tmin++; tmax++;\n  *tmin = *tmax = t1-t3;\n  tmin++; tmax++;\n  *tmin = *tmax = t1+t3;\n  tmin++; tmax++;\n  *tmin = *tmax = t1-t2;\n  tmin++; tmax++;\n  *tmin = *tmax = t1+t2;\n  \n  /* For each vertice at the edge check and corrigate the box.  */\n  \n  for (ki=0,sc1+=3,sc2+=3,sc3+=3; ki<icoef2; ki++)\n     for (kj=(ki==0); kj<icoef1; kj++,sc1+=3,sc2+=3,sc3+=3)\n     {\n\t\n\t/* Set correct pointers.  */ \n\t\n\tif (((ki==0 || ki==icoef2-1) && icoef2>1) ||\n\t\t  ((kj==0 || kj==icoef1-1) && icoef1>1))\n\t   tmin = sminedg, tmax = smaxedg;\n\telse \n\t   kinset = 1,  tmin = sminin,  tmax = smaxin;\n\t\n\tt1= ROTM * sc1[0];\n\tt2= ROTM * sc2[0];\n\tt3= ROTM * sc3[0];\n\n\tif(*sc1 < *tmin) *tmin = *sc1;\n\tif(*sc1 > *tmax) *tmax = *sc1;\n\ttmin++; tmax++;\n\tif(*sc2 < *tmin) *tmin = *sc2;\n\tif(*sc2 > *tmax) *tmax = *sc2;\n\ttmin++; tmax++;\n\tif(*sc3 < *tmin) *tmin = *sc3;\n\tif(*sc3 > *tmax) *tmax = *sc3;\n\ttmin++; tmax++;\n\tt4= t2 - t3;\n\tif(t4 < *tmin) *tmin = t4;\n\tif(t4 > *tmax) *tmax = t4;\n\ttmin++; tmax++;\n\tt4= t2 + t3;\n\tif(t4 < *tmin) *tmin = t4;\n\tif(t4 > *tmax) *tmax = t4;\n\ttmin++; tmax++;\n\tt4= t1 - t3;\n\tif(t4 < *tmin) *tmin = t4;\n\tif(t4 > *tmax) *tmax = t4;\n\ttmin++; tmax++;\n\tt4= t1 + t3;\n\tif(t4 < *tmin) *tmin = t4;\n\tif(t4 > *tmax) *tmax = t4;\n\ttmin++; tmax++;\n\tt4= t1 - t2;\n\tif(t4 < *tmin) *tmin = t4;\n\tif(t4 > *tmax) *tmax = t4;\n\ttmin++; tmax++;\n\tt4= t1 + t2;\n\tif(t4 < *tmin) *tmin = t4;\n\tif(t4 > *tmax) *tmax = t4;\n     }\n  \n  /* Merge the inner and the outer box, and adjust with the\n     tolerance.  */\n  \n  if (!kinset)\n  {\n     memcopy(sminin,sminedg,kant,DOUBLE);\n     memcopy(smaxin,smaxedg,kant,DOUBLE);\n  }\n  for (ki=0; ki<kant; ki++)\n  {\n     e2min[ki] = MIN(sminin[ki]-aeps1,sminedg[ki]-teps2);\n     e2max[ki] = MAX(smaxin[ki]+aeps1,smaxedg[ki]+teps2);\n     e2min[kant+ki] = MIN(sminin[ki]-teps1,sminedg[ki]-teps3);\n     e2max[kant+ki] = MAX(smaxin[ki]+teps1,smaxedg[ki]+teps3);\n  }\n}\n\f \n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  sh1992_s9mbox2(double ecoef[],int icoef1,int icoef2,double aeps1,\n\t\t double aeps2,double e2max[],double e2min[])\n#else\nstatic void sh1992_s9mbox2(ecoef,icoef1,icoef2,aeps1,aeps2,e2max,e2min)\n     double ecoef[];\n     int    icoef1;\n     int    icoef2;\n     double aeps1;\n     double aeps2;\n     double e2max[];\n     double e2min[];\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make 2 boxes on the control-polygons given by\n*              ecoef to the object.\n*\n*\n* INPUT      : ecoef  - Control-polygon.\n*              icoef1  - Number of vertices in control-polygon in\n*                        first parameter direction.\n*              icoef2  - Number of vertices in control-polygon in\n*                        second parameter direction.\n*              aeps1   - Size of expansion to use in the inner of\n*                        the object.\n*              aeps2   - Size of expansion to use at the edge of the object.\n*\n*                                                                     \n*\n* OUTPUT     : e2max   - Array to contain maximum values of the box.\n*\t       e2min   - Array to contain minimum values of the box.\n*\n*\n* METHOD     : Make two boxes. One ordinary and one rotated 45 degree.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-02.\n* MODIFIED BY : Vibeke Skytt, SI, 91-01.\n*\n*********************************************************************\n*/                                     \n{\n  int ki,kj;             /* Counters.                                 */\n  int kant = 4;          /* Number of box sides.                      */\n  int kinset = 0;        /* Indicates if an inner box is found.       */\n  double teps1 = aeps1+aeps1; /* Double tolerance in the inner.       */\n  double teps2;               /* Tolerance at edge.                   */\n  double teps3;               /* Double tolerance at edge.            */\n  double t1,t2,t3;       /* To store elements of the rotation matrix. */\n  double *tmin,*tmax;    /* Pointers used to traverse e2min and e2max.  */\n  double sminin[4],smaxin[4];   /* Box boundaries in the inner.       */\n  double sminedg[4],smaxedg[4]; /* Box boundaries at the edge.        */\n  double *sc1,*sc2;      /* Pointers into coefficient array.          */\n  \n  /* Set tolerances at edge. If the tolerance is positive or dimension\n     is 1D, the input tolerance is used, otherwise we must make sure \n     that the maximum distance from the total box at the edges to the\n     reduced box is aeps2.                                             */\n  \n  if (aeps2 >= DZERO)\n     teps2 = aeps2;\n  else\n     teps2 = (double)0.38268343*aeps2;   /* aeps2 * sin(PI/8).   */\n  teps3 = teps2 + teps2;\n \n  /* Initiate box boundaries of inner box.  */\n  \n  for (ki=0; ki<kant; ki++)\n  {\n     sminin[ki] = HUGE;\n     smaxin[ki] = -HUGE;\n  }\n  \n  /* Fetch value of first vertex.  */\n  \n  sc1 = ecoef;  sc2 = sc1 + 1;\n  t1= ROTM * sc1[0];\n  t2= ROTM * sc2[0];\n  \n  tmin = sminedg;\n  tmax = smaxedg;\n  *tmin = *tmax = *sc1;\n  tmin++; tmax++;\n  *tmin = *tmax = *sc2;\n  tmin++; tmax++;\n  *tmin = *tmax = t1-t2;\n  tmin++; tmax++;\n  *tmin = *tmax = t1+t2;\n  \n  /* For each vertex check and corrigate the box.  */\n  \n  for (ki=0,sc1+=2,sc2+=2; ki<icoef2; ki++)\n     /* UJK, writing error */\n     /*for (kj=(ki==1); kj<icoef1; kj++,sc1+=2,sc2+=2) */\n\n     for (kj=(ki==0); kj<icoef1; kj++,sc1+=2,sc2+=2)\n     {\n\t/* Set correct box boundaries.  */\n\t\n\tif (((ki==0 || ki==icoef2-1) && icoef2>1) ||\n\t\t  ((kj==0 || kj==icoef1-1) && icoef1>1))\n\t   tmin = sminedg,  tmax = smaxedg;\n\telse\n\t   kinset = 1,  tmin = sminin,  tmax = smaxin;\n\t\n\tt1= ROTM * sc1[0];\n\tt2= ROTM * sc2[0];\n\n\tif(*sc1 < *tmin) *tmin = *sc1;\n\tif(*sc1 > *tmax) *tmax = *sc1;\n\ttmin++; tmax++;\n\tif(*sc2 < *tmin) *tmin = *sc2;\n\tif(*sc2 > *tmax) *tmax = *sc2;\n\ttmin++; tmax++;\n\tt3= t1 - t2;\n\tif(t3 < *tmin) *tmin = t3;\n\tif(t3 > *tmax) *tmax = t3;\n\ttmin++; tmax++;\n\tt3= t1 + t2;\n\tif(t3 < *tmin) *tmin = t3;\n\tif(t3 > *tmax) *tmax = t3;\n     }\n  \n  /* Merge the inner and the outer box, and adjust with the\n     tolerance.  */\n  \n  if (!kinset)\n  {\n     memcopy(sminin,sminedg,kant,DOUBLE);\n     memcopy(smaxin,smaxedg,kant,DOUBLE);\n  }\n  for (ki=0; ki<kant; ki++)\n  {\n     e2min[ki] = MIN(sminin[ki]-aeps1,sminedg[ki]-teps2);\n     e2max[ki] = MAX(smaxin[ki]+aeps1,smaxedg[ki]+teps2);\n     e2min[kant+ki] = MIN(sminin[ki]-teps1,sminedg[ki]-teps3);\n     e2max[kant+ki] = MAX(smaxin[ki]+teps1,smaxedg[ki]+teps3);\n  }\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  sh1992_s9mbox(double ecoef[],int icoef1,int icoef2,int idim,\n\t\tdouble aeps1,double aeps2,double e2max[],\n\t\tdouble e2min[],int *jstat)\n#else   \nstatic void sh1992_s9mbox(ecoef,icoef1,icoef2,idim,aeps1,aeps2,\n\t\t\t  e2max,e2min,jstat)\n     double ecoef[];\n     int    icoef1;\n     int    icoef2;\n     int    idim;\n     double aeps1;\n     double aeps2;\n     double e2max[];\n     double e2min[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Make a SISLbox on the control-polygons given by\n*              ecoef to the object.\n*\n*\n* INPUT      : ecoef  - Control-polygon.\n*              icoef1  - Number of vertices in control-polygon in\n*                        first parameter direction.\n*              icoef2  - Number of vertices in control-polygon in\n*                       second parameter direction.\n*              aeps1   - Size of expansion to use in the inner of\n*                        the object.\n*              aeps2   - Size of expansion to use at the edge of the object.\n*\n*                                                                     \n*\n* OUTPUT     : e2max   - Array to contain maximum values of the box.\n*\t       e2min   - Array to contain minimum values of the box.\n*              jstat  - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-02.\n* MODIFIED BY : Vibeke Skytt, SI, 91-01.\n*\n*********************************************************************\n*/                                     \n{\n  int ki,ki1,kj;       /* Counters.  */\n  int kant = idim;     /* Number of box sides.                        */\n  int kinset = 0;      /* Indicates if the inner box is set.          */\n  double noice = (double)100.0*REL_COMP_RES;   /* Noice killer.       */\n  double teps1 = aeps1+aeps1; /* Double tolerance in the inner.       */\n  double teps2;               /* Tolerance at edge.                   */\n  double teps3;               /* Double tolerance at edge.            */\n  double *tmin,*tmax;  /* Pointers into box boundary arrays.          */\n  double *sc;          /* Pointer into coefficient array.             */\n  double *sminin=SISL_NULL,*smaxin=SISL_NULL;  /* Box boundaries of the inner.  */\n  double *sminedg=SISL_NULL,*smaxedg=SISL_NULL; /* Box boundaries of the edge.  */\n  \n  /* Set tolerances at edge. If the tolerance is positive or dimension\n     is 1D, the input tolerance is used, otherwise we must make sure \n     that the maximum distance from the total box at the edges to the\n     reduced box is aeps2.                                             */\n  \n  if (idim == 1 || aeps2 >= DZERO)\n     teps2 = aeps2;\n  else\n     teps2 = aeps2/sqrt((double)idim);\n  teps3 = teps2 + teps2;\n  \n  /* Allocate scratch for intermediate box arrays.  */\n  \n  if ((sminin = newarray(kant,double)) == SISL_NULL) goto err101;\n  if ((smaxin = newarray(kant,double)) == SISL_NULL) goto err101;\n  if ((sminedg = newarray(kant,double)) == SISL_NULL) goto err101;\n  if ((smaxedg = newarray(kant,double)) == SISL_NULL) goto err101;\n  \n  /* Initiate box boundaries of inner box.  */\n  \n  for (ki=0; ki<kant; ki++)\n  {\n     sminin[ki] = HUGE;\n     smaxin[ki] = -HUGE;\n  }\n  \n  /* Fetch value of first vertex.  */\n  \n  for (ki = 0; ki < idim; ki++) \n     sminedg[ki] = smaxedg[ki] = ecoef[ki];\n  \n  /* For each vertice check and corrigate the box.  */\n  \n  for (sc=ecoef+idim, ki=0; ki<icoef2; ki++)\n     for (kj=(ki==0); kj<icoef1; kj++)\n     {\n\t/* Set correct box.  */\n\t\n\tif (((ki==0 || ki==icoef2-1) && icoef2>1) ||\n\t\t  ((kj==0 || kj==icoef1-1) && icoef1>1))\n\t   tmin = sminedg,  tmax = smaxedg;\n\telse \n\t    kinset = 1,  tmin = sminin,  tmax = smaxin;\n\t\n\tfor (ki1=0; ki1<idim; ki1++,sc++,tmin++,tmax++)\n\t{\n\t   if(*sc < *tmin) *tmin = *sc;\n\t   if(*sc > *tmax) *tmax = *sc;\n\t}\n     }\n\n  /* Merge the inner and the outer box, and adjust with the\n     tolerance.  */\n  \n  if (!kinset)\n  {\n     memcopy(sminin,sminedg,kant,DOUBLE);\n     memcopy(smaxin,smaxedg,kant,DOUBLE);\n  }\n  for (ki=0; ki<kant; ki++)\n  {\n     e2min[ki] = MIN(sminin[ki]-aeps1,sminedg[ki]-teps2);\n     e2max[ki] = MAX(smaxin[ki]+aeps1,smaxedg[ki]+teps2);\n     if (idim > 1)\n     {\n\te2min[kant+ki] = MIN(sminin[ki]-teps1,sminedg[ki]-teps3);\n\te2max[kant+ki] = MAX(smaxin[ki]+teps1,smaxedg[ki]+teps3);\n     }\t\n  }\n  \n  /* ALA and UJK 30.10.90, remove noice near by zero.  */\n  \n  if (idim == 1)\n  {\n     if (fabs(e2max[0]) < noice) e2max[0] = DZERO;\n     if (fabs(e2min[0]) < noice) e2min[0] = DZERO;\n  }\n  \n  *jstat = 0;\n  goto out;\n  \n  /* Error in scratch allocation. */\n  \n  err101 : *jstat = -101;\n  goto out;\n  \n  out :\n  if (sminin != SISL_NULL) freearray(sminin);\n  if (smaxin != SISL_NULL) freearray(smaxin);\n  if (sminedg != SISL_NULL) freearray(sminedg);\n  if (smaxedg != SISL_NULL) freearray(smaxedg);\t\t       \n}\n \n\n"
  },
  {
    "path": "src/sh1993.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1993.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n#define SH1993\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh1993(SISLCurve *c1,double aepsge,int *jstat)\n#else\nvoid sh1993(c1,aepsge,jstat)\n     SISLCurve *c1;\n     double aepsge;\n     int   *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Check if a point-curve intersection in one dimention\n*              is a simple case,\n*              i.e. the intersection will result in one single point.\n*\n*\n*\n* INPUT      : c1    - SISLCurve in the intersection problem.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                                         = 1      : simpel case.\n*                                         = 0      : not simpel case.\n*                                         < 0      : error.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* CALLS      :\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-06.\n* Revised by : ALA and UJK 01.11.90, totale rewritten, same strategy\n*              as in s1994 (surface case).\n* REWISED BY : Vibeke Skytt, SI, 91-02.\n*\n*********************************************************************\n*/\n{\n  register int ki,kj;\n\n  int kk,kn;\n  int kbez;\n  double tmax;\n  double tmin;\n  double tdiff;\n  double *scoef=SISL_NULL;\n  /* ----------------------------------------------------------- */\n  \n  /* Init to  simple case. */\n  *jstat = 1;\n  \n  tmax = - HUGE;\n  tmin =   HUGE;\n  \n  /* Get curve attributes. */\n  kk  = c1->ik;\n  kn  = c1->in;\n  kbez = (kk == kn);\n  \n  /* Run through vertices to find\n     intervall of first derivative. */\n  \n  for (tdiff=DZERO, ki=1, scoef=c1->ecoef; ki<kn; ki+=kj, scoef+=kj)\n  {\n     for (kj=1; ki+kj<=kn; kj++)\n     {\n\tif (tdiff*(*(scoef+kj) - *(scoef+kj-1)) < DZERO)\n\t   {\n\t      scoef += (kj-1);\n\t      ki += (kj-1);\n\t      kj = 1;\n\t   }\n\t   tdiff = *(scoef + kj) - *scoef;\n\t   if (fabs(tdiff) >= aepsge) break;\n     }\n     if (ki+kj > kn) break;\n     \n     tmin = min(tmin,tdiff);\n     tmax = max(tmax,tdiff);\n  }\n  \n  \n  /* Simple case when no genuin zero's of first derivative. */\n  if (kbez && (tmin*tmax >=DZERO)) \n    *jstat = 1;\n  else if (tmin*tmax > DZERO) \n    *jstat = 1;\n  else if (tmin == tmax)\n    *jstat = 1;\n  else\n    /* Not a simple case. */\n    *jstat = 0;\n\n}\n\n\n\n"
  },
  {
    "path": "src/sh1994.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh1994.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n\n#define SH1994\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh1994(SISLSurf *s1,double aepsge,int *jstat)\n#else\nvoid sh1994(s1,aepsge,jstat)\n     SISLSurf *s1;\n     double aepsge;\n     int  *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : Check if a point-surface intersection in one dimention\n*              is a simple case,\n*              i.e. the intersection will result in one single point.\n*\n*\n*\n* INPUT      : s1     - Surface in the intersection problem.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                                         = 1      : simpel case.\n*                                         = 0      : not simpel case.\n*                                         < 0      : error.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* CALLS      : \n*\n* WRITTEN BY : TDO SI, 89-08.\n* REWISED BY : Vibeke Skytt, SI, 91-02.\n*              UJK, SI,91-10 Bug in first direction when a row\n*                            ends with 2 or more equal numbers.\n*                            Also added a test to include\n*                            tmax < tmin (both HUGE)\n*********************************************************************\n*/\n{\n  register int ki,kj,kh;\n  int kk1, kk2, kn1, kn2;\n  int kbez;\n  \n  double tmaxt, tmaxs;\n  double tmint, tmins;\n  double tdiff;\n  double *scoef=SISL_NULL;\n  \n  /* Init to  simple case. */\n  *jstat = 1;\n  \n  tmaxt = tmaxs = - HUGE;\n  tmint = tmins =   HUGE;\n  \n  /* Get surface attributes. */\n  kk1  = s1->ik1;\n  kk2  = s1->ik2;\n  kn1  = s1->in1;\n  kn2  = s1->in2;\n  kbez = (kk1 == kn1) && (kk2 == kn2); \n  \n  \n  /* If the surface is linear in some direction it is simpel case. */\n  if ((kk1 == 2 && kn1 == 2) || (kk2 == 2 && kn2 == 2)) goto out;\n  \n  \n  /* Run through vertices in first parameter direction to find\n     intervall of first derivative. */\n  \n  /* UJK, 91-10 */\n  /* for (kj=0, scoef=s1->ecoef; kj<kn2; kj++,scoef++) */\n  for (kj=0, scoef=s1->ecoef; kj<kn2; kj++,scoef=s1->ecoef+kn1*kj)\n     for (tdiff=DZERO, ki=1; ki<kn1; ki+=kh, scoef+=kh)\n     {\n\tfor (kh=1; ki+kh<=kn1; kh++)\n\t{\n\t   if (tdiff*(*(scoef+kh) - *(scoef+kh-1)) < DZERO)\n\t      {\n\t\t scoef += (kh-1);\n\t\t ki += (kh-1);\n\t\t kh = 1;\n\t      }\n\t      tdiff = *(scoef + kh) - *scoef;\n\t      if (fabs(tdiff) >= aepsge) break;\n\t}\n\tif (ki+kh > kn1) break;\n\t\n\ttmint = min(tmint,tdiff);\n\ttmaxt = max(tmaxt,tdiff);\n     }\n  \n  /* Run through vertices in second parameter direction to find\n     intervall of first derivative. */\n  \n  for (ki=0; ki<kn1; ki++)\n     for (tdiff=DZERO, kj=1, scoef=s1->ecoef+ki; kj<kn2; kj+=kh, scoef+=kh*kn1)\n     {\n\tfor (kh=1; kj+kh<=kn2; kh++)\n\t{\n\t   if (tdiff*(*(scoef+kh*kn1) - *(scoef+(kh-1)*kn1)) < DZERO)\n\t      {\n\t\t scoef += (kh-1)*kn1;\n\t\t kj += (kh-1);\n\t\t kh = 1;\n\t      }\n\t      tdiff = *(scoef + kh*kn1) - *scoef;\n\t      if (fabs(tdiff) >= aepsge) break;\n\t}\n\tif (kj+kh > kn2) break;\n\t\n\ttmins = min(tmins,tdiff);\n\ttmaxs = max(tmaxs,tdiff);\n     }\n\n  /* UJK, 91-10, maybe parameters not set */\n  if (tmint > tmaxt || tmins > tmaxs)\n  {\n     *jstat = 1;\n     goto out;\n  }\n  \n  /* The first derivatives decide directions of possible intersection curves. */\n  if (kbez && (tmint*tmaxt >=DZERO || tmins*tmaxs >=DZERO))\n    *jstat = 1;\n  else if (tmint*tmaxt > DZERO || tmins*tmaxs > DZERO) \n    *jstat = 1;\n  else if (tmint == tmaxt  || tmins == tmaxs) \n    *jstat = 1;\n  else\n    /* Not a simple case. */\n    *jstat = 0;\n  \n  goto out;\n out: ;\n}\n\n"
  },
  {
    "path": "src/sh6clvert.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6clvert.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n#define SH6CLOSEVERT\n\n#include \"sislP.h\"\n\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6closevert(SISLCurve *pcurve,SISLSurf *psurf,double *cpar1,\n\t     double epar2[])\n#else\nvoid sh6closevert(pcurve,psurf,cpar1,epar2)\n   SISLCurve *pcurve;\n   SISLSurf *psurf;\n   double *cpar1;\n   double epar2[];\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : Estimate the parameter values the closest vertices of\n*              a B-spline curve and a B-spline surface.\n*\n*\n*\n* INPUT      : pcurve   - Pointer to curve.\n*              psurf    - Pointer to surface.\n*\n*\n* OUTPUT     : cpar1    - Parameter value of closest vertex of the curve.\n*              epar2    - Parameter value of closest vertex of the surface.\n*\n*\n* METHOD     : Find the vertices of the curve and the surface that are\n*              closest to each other. Regard these vertices as Schoenberg\n*              points, and compute the parameter values.\n*\n*\n* REFERENCES :\n*\n*\n* USE        :\n*\n*-\n* CALLS      : s6dist - Distance between two points.\n*\n*\n* WRITTEN BY : Vibeke Skytt, SI, 06.92.\n*\n*********************************************************************\n*/\n{\n  int ki,kj,kl;           /* Counters.   */\n  int kdim = pcurve->idim; /* Dimension of geometry space.      */\n  int kminc;              /* Number of closest vertex of curve. */\n  int kmins1,kmins2;      /* Numbers of closest vertex of surface. */\n  int kn = pcurve->in;    /* Number of coefficients of curve. */\n  int kn1 = psurf->in1;   /* Number of coefficients of surface, 1. par. dir. */\n  int kn2 = psurf->in2;   /* Number of coefficients of surface, 2. par. dir. */\n  int kk = pcurve->ik;    /* Order of curve. */\n  int kk1 = psurf->ik1;   /* Order of surface, 1. par. dir. */\n  int kk2 = psurf->ik2;   /* Order of surface, 2. par. dir. */\n  double tdist;           /* Distance.   */\n  double tmin = HUGE;     /* Minimum distance.  */\n  double tpar;            /* Used to compute parameter values.   */\n  double *s1,*s2;         /* Pointers into arrays.   */\n\n  /* Find position of closest vertices. */\n\n  for (s1=pcurve->ecoef, ki=0; ki<kn; s1+=kdim, ki++)\n    for (s2=psurf->ecoef, kj=0; kj<kn1; kj++)\n      for (kl=0; kl<kn2; s2+=kdim, kl++)\n\t{\n\t   tdist = s6dist(s1,s2,kdim);\n\t   if (tdist < tmin)\n\t   {\n\t      tmin = tdist;\n\t      kminc = ki;\n\t      kmins1 = kj;\n\t      kmins2 = kl;\n\t   }\n\t}\n\n  /* Estimate parameter values of vertices.  */\n\n  for (ki=kminc+1, s1=pcurve->et+ki, tpar=DZERO;\n   ki<kminc+kk; tpar+=(*s1), s1++, ki++);\n  *cpar1 = tpar/(double)(kk-1);\n\n  for (ki=kmins1+1, s1=psurf->et1+ki, tpar=DZERO;\n   ki<kmins1+kk1; tpar+=(*s1), s1++, ki++);\n  epar2[0] = tpar/(double)(kk1-1);\n\n  for (ki=kmins2+1, s1=psurf->et2+ki, tpar=DZERO;\n   ki<kmins2+kk2; tpar+=(*s1), s1++, ki++);\n  epar2[1] = tpar/(double)(kk2-1);\n\n\n  goto out;\n\n out:\n  return;\n}\n"
  },
  {
    "path": "src/sh6comedg.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6comedg.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n\n#define SH6COMEDG\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6comedg (SISLObject * po1, SISLObject * po2, SISLIntpt *pt1, SISLIntpt *pt2,\n\t   \t\t\t\t\t\tint *jstat)\n#else\nvoid\nsh6comedg (po1, po2, pt1, pt2, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntpt *pt1;\n     SISLIntpt *pt2;\n     int *jstat;\n#endif\n\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Test if two intersection points is on a common edge and\n*\t\tconnected along this edge on one\n*\t\tof the objects.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              pt1      - Intersection point.\n*              pt2      - Intersection point.\n*\n*\n* OUTPUT     : jstat    - status messages\n*                        < 0  : Error.\n*\t\t\t   0  : Not on a common edge.\n*\t\t\t   1  : On a common edge in first object.\n*\t\t\t   2  : On a common edge in second object.\n*\t\t\t   3  : On a common edge in bouth objects.\n*\n*\n* METHOD     :\n*\n* CALLS      :\n*\n* REFERENCES :\n*\n* WRITTEN BY : Arne Laksaa, SI, Oslo, sep. -91.\n*********************************************************************\n*/\n{\n int kstat=0;\n double minpar[4];\n double maxpar[4];\n int nrpar, np1, np2;\n int common_edg, i, j;\n int is_inside = 1;\n int on_edge1 = 0;\n int on_edge2 = 0;\n int ind1, ind2;\n /* ---------------------------------------------------------------- */\n \n *jstat = 0;\n   \n if (pt1 != SISL_NULL && pt2 != SISL_NULL)\n {\n    /* Making the parametric boarders */\n \n    if (po1->iobj == SISLSURFACE)\n    {\n       nrpar = 2;\n       np1 = 4;\n\n       minpar[0] = po1->s1->et1[po1->s1->ik1-1];\n       minpar[1] = po1->s1->et2[po1->s1->ik2-1];\n       maxpar[0] = po1->s1->et1[po1->s1->in1];\n       maxpar[1] = po1->s1->et2[po1->s1->in2];\n    }\n    else if (po1->iobj == SISLCURVE)\n    {\n       nrpar = 1;\n       np1 = 2;\n\n       minpar[0] = po1->c1->et[po1->c1->ik-1];\n       maxpar[0] = po1->c1->et[po1->c1->in];\n    }\n    else    /* SISLPOINT */\n       np1 = nrpar = 0;\n\n    if (po2->iobj == SISLSURFACE)\n    {\n       minpar[nrpar]   = po2->s1->et1[po2->s1->ik1-1];\n       minpar[nrpar+1] = po2->s1->et2[po2->s1->ik2-1];\n       maxpar[nrpar]   = po2->s1->et1[po2->s1->in1];\n       maxpar[nrpar+1] = po2->s1->et2[po2->s1->in2];\n       nrpar += 2;\n       np2 = 4;\n    }\n    else if (po2->iobj == SISLCURVE)\n    {\n       minpar[nrpar] = po2->c1->et[po2->c1->ik-1];\n       maxpar[nrpar] = po2->c1->et[po2->c1->in];\n       nrpar++;\n       np2 = 2;\n    }\n    else   np2 = 0;     /* SISLPOINT */\n\n    /* Testing. */\n    \n    /* UJK, aug.92 */\n    /* for (i = 0; i < nrpar || !is_inside; i++) */\n    for (i = 0; i < nrpar && is_inside; i++)\n      {\n\t if (pt1->epar[i] <= maxpar[i] + REL_PAR_RES &&\n\t     pt1->epar[i] >= minpar[i] - REL_PAR_RES)\n\t   {\n\t      /* pt1 is inside. */\n\t      \n\t      if (pt1->epar[i] >= maxpar[i] - REL_PAR_RES)\n\t\ton_edge1 +=  (1 << (2*i));\t/* On edge/end */\n\t      if (pt1->epar[i] <= minpar[i] + REL_PAR_RES)\n\t\ton_edge1 +=  (1 << (2*i+1));\t/* On edge/end */\n\t      \n\t   }\n\t else  is_inside = 0;\n\t \n\t if (pt2->epar[i] <= maxpar[i] + REL_PAR_RES &&\n\t     pt2->epar[i] >= minpar[i] - REL_PAR_RES)\n\t   {\n\t      /* pt2 is inside. */\n\t      \n\t      if (pt2->epar[i] >= maxpar[i] - REL_PAR_RES)\n\t\ton_edge2 +=  (1 << (2*i));\t/* On edge/end */\n\t      if (pt2->epar[i] <= minpar[i] + REL_PAR_RES)\n\t\ton_edge2 +=  (1 << (2*i+1));\t/* On edge/end */\n\t      \n\t   }\n\t else  is_inside = 0;\n      }\n    \n    common_edg = on_edge1 & on_edge2;\n    (*jstat) = 0;\n    \n    if(is_inside && common_edg)\n    {\n       if (np1 > 0)\n       {\n\t  j = (15>>(4-np1));\n\t  if (common_edg & j)\n\t  {\n\t     sh6getlist(pt1,pt2,&ind1,&ind2,&kstat);\n             if (kstat < 0) goto err106;\n             if (kstat == 0)\n\t     {\n\t\tif (common_edg & 3) i = 2;\n\t\telse i = 0;\n\t\tif (common_edg & (3<<2)) i+= 4;\n\t\tif (pt1->curve_dir[ind1] & i)  (*jstat) = 1;\n\t     }\n\t  }\n       }\n       if (np2 > 0)\n       {\n\t  j = (15>>(4-np2));\n\t  j <<= np1;\n\t  if (common_edg & j)\n\t  {\n\t     sh6getlist(pt1,pt2,&ind1,&ind2,&kstat);\n             if (kstat < 0) goto err106;\n             if (kstat == 0)\n\t     {\n\t\tif (common_edg & (3<<np1)) i = 8;\n\t\telse i = 0;\n\t\tif (common_edg & (3<<(np1+2))) i+= 16;\n\t\tif (pt1->curve_dir[ind1] & i)  (*jstat) += 2;\n\t     }\n\t  }\n       }\n    }\n    else\n       (*jstat) = 0;\n }\n else goto err108;\n\n \n  /* Done. */\n\n  goto out;\n\n  /* Error in input. Conflicting dimensions.  */\n\nerr106:*jstat = -106;\n  s6err(\"sh6comedg\",*jstat,0);\n  goto out;\n\n  /* Error in input. No points */\n\nerr108:*jstat = -108;\n  s6err(\"sh6comedg\",*jstat,0);\n  goto out;\n\nout:\n  return;\n}\n\n"
  },
  {
    "path": "src/sh6condir.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n\n\n#define SH6CONDIR\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh6condir(SISLIntdat *rintdat, SISLIntpt *pt1, SISLIntpt *pt2, int *jstat)\n#else\n  void sh6condir(rintdat, pt1, pt2, jstat)\n     SISLIntdat *rintdat;\n     SISLIntpt *pt1;\n     SISLIntpt *pt2;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Connect the two points, make sure that they are main points\n*              and set direction.\n*\n*\n* INPUT      : rintdat  - Pool of intersection point\n*              pt1      - Pointer to first Intpt.\n*              pt2      - Pointer to second Intpt.\n*              jstat    - Error flag.\n*                        jstat < 0: Error\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 06-2023\n*********************************************************************\n*/\n{\n  int kstat = 0;\n  *jstat = 0;\n  sh6tomain (pt1, &kstat);\n  sh6tomain (pt2, &kstat);\n\t      \n  sh6idcon (&rintdat, &pt1, &pt2, &kstat);\n  if (kstat < 0)\n    *jstat = kstat;\n  else\n    sh6setdir (pt1, pt2, &kstat);\n  if (kstat < 0)\n    *jstat = kstat;\n}\n"
  },
  {
    "path": "src/sh6connect.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6connect.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define SH6CONNECT\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6connect (SISLIntpt * pt1, SISLIntpt * pt2, int *jstat)\n#else\nvoid\nsh6connect (pt1, pt2, jstat)\n     SISLIntpt *pt1;\n     SISLIntpt *pt2;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Connect the two points.\n*              If they are already connected give message.\n*\n*\n* INPUT      : pt1      - Pointer to first Intpt.\n*              pt2      - Pointer to second Intpt.\n*              jstat    - Error flag.\n*                        jstat =  0  => Successful\n*                        jstat =  1  => Points already connected.\n*                        jstat = -1  => Illegal to connect.\n*                        jstat = -2  => Error in data structure.\n*                        jstat = -3  => Error in subfunction.\n*                        jstat = -4  => Selfconnecting not legal.\n*\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. May 91.\n* CORRECTED BY : Ulf J. Krystad, SI, Oslo, Norway. July 91.\n*********************************************************************\n*/\n{\n  int kstat;\t\t\t/* error flag. */\n  int index1, index2;\t\t/* dummy indices.           */\n  int num;\t\t\t/* Number of main point pinters.  */\n\n  *jstat = 0;\n  \n  if (pt1 == pt2)\n    goto err4;\n\n  /* Check if pt1 and pt2 are already connected. */\n\n  sh6getlist (pt1, pt2, &index1, &index2, &kstat);\n  if (kstat < 0)\n    goto err3;\n  if (kstat < 1)\t\t/* Already connected. */\n    {\n      *jstat = 1;\n      goto out;\n    }\n\n  /* Check that we can connect pt1. There are restrictions if it\n     it a help point.  */\n\n  if (sh6ishelp (pt1))\t\t/* pt1 is a help point */\n    {\n      /* UJK, this is NO invariant */\n      /*if (pt1->no_of_curves > 2)\n         goto err2;\n         if (pt1->no_of_curves == 2)\n         goto err1; */\n\n      if (sh6ismain (pt2))\t/* pt2 is a main point. */\n\t{\n\t  num = sh6nmbmain (pt1, &kstat);\n\n\t  /* UJK, If invar does not hold, MAKE it hold */\n\t  /* if (num > 1)\n\t    goto err2;\n\t  if (num == 1)\n\t    goto err1; */\n\t  if (num >= 1)\n\t    sh6tomain (pt1, &kstat);\n\t  if (kstat < 0)\n\t    goto err2;\n\n\t  /* pt1 cannot be connected to two main points. */\n\t}\n    }\n\n  /* Check that we can connect pt2. There are restrictions if it\n     it a help point.  */\n\n  if (sh6ishelp (pt2))\t\t/* pt2 is a help point */\n    {\n      /* UJK, this is NO invariant */\n      /*if (pt2->no_of_curves > 2)\n         goto err2;\n         if (pt2->no_of_curves == 2)\n         goto err1; */\n\n      if (sh6ismain (pt1))\t/* pt1 is a main point. */\n\t{\n\t  num = sh6nmbmain (pt2, &kstat);\n\n\t  /* UJK, If invar does not hold, MAKE it hold */\n\t  /*if (num > 1)\n\t    goto err2;\n\t  if (num == 1)\n\t    goto err1; */\n\t  if (num >= 1)\n\t    sh6tomain (pt2, &kstat);\n\t  if (kstat < 0)\n\t    goto err2;\n\n\t  /* pt2 cannot be connected to two main points. */\n\t}\n    }\n\n  /* Now make the connection. */\n\n\n  /* Point pt1 to pt2. */\n\n  /* Check if we need to reallocate the pnext and curve_dir arrays. */\n\n  if (pt1->no_of_curves > pt1->no_of_curves_alloc)\n    goto err2;\n  if (pt1->no_of_curves == pt1->no_of_curves_alloc)\n    {\n      pt1->no_of_curves_alloc += 4;\n      pt1->pnext = increasearray (pt1->pnext,\n\t\t\t\t  pt1->no_of_curves_alloc, SISLIntpt *);\n      pt1->curve_dir = increasearray (pt1->curve_dir,\n\t\t\t\t      pt1->no_of_curves_alloc, int);\n      /* UJK, Must have size of pretop arrays increased */\n      pt1->left_obj_1 = increasearray (pt1->left_obj_1,\n\t\t\t\t       pt1->no_of_curves_alloc, int);\n      pt1->left_obj_2 = increasearray (pt1->left_obj_2,\n\t\t\t\t       pt1->no_of_curves_alloc, int);\n      pt1->right_obj_1 = increasearray (pt1->right_obj_1,\n\t\t\t\t\tpt1->no_of_curves_alloc, int);\n      pt1->right_obj_2 = increasearray (pt1->right_obj_2,\n\t\t\t\t\tpt1->no_of_curves_alloc, int);\n    }\n\n  /* Set new pointer to new position in array. */\n  /* Set new curve direction to 0 for now. */\n\n  pt1->pnext[pt1->no_of_curves] = pt2;\n  pt1->curve_dir[pt1->no_of_curves] = 0;\n\n  /* Increment no_of_curves. */\n\n  pt1->no_of_curves++;\n\n\n  /* Point pt2 to pt1. */\n\n  /* Check if we need to reallocate the pnext and curve_dir arrays. */\n\n  if (pt2->no_of_curves > pt2->no_of_curves_alloc)\n    goto err2;\n  if (pt2->no_of_curves == pt2->no_of_curves_alloc)\n    {\n      pt2->no_of_curves_alloc += 4;\n      /* UJK, pt1->pnext chaged to pt2->pnext */\n      pt2->pnext = increasearray (pt2->pnext,\n\t\t\t\t  pt2->no_of_curves_alloc, SISLIntpt *);\n      pt2->curve_dir = increasearray (pt2->curve_dir,\n\t\t\t\t      pt2->no_of_curves_alloc, int);\n      /* UJK, Must have size of pretop arrays increased */\n      pt2->left_obj_1 = increasearray (pt2->left_obj_1,\n\t\t\t\t       pt2->no_of_curves_alloc, int);\n      pt2->left_obj_2 = increasearray (pt2->left_obj_2,\n\t\t\t\t       pt2->no_of_curves_alloc, int);\n      pt2->right_obj_1 = increasearray (pt2->right_obj_1,\n\t\t\t\t\tpt2->no_of_curves_alloc, int);\n      pt2->right_obj_2 = increasearray (pt2->right_obj_2,\n\t\t\t\t\tpt2->no_of_curves_alloc, int);\n    }\n\n  /* Set new pointer to new position in array. */\n  /* Set new curve direction to 0 for now. */\n\n  pt2->pnext[pt2->no_of_curves] = pt1;\n  pt2->curve_dir[pt2->no_of_curves] = 0;\n\n  /* Increment no_of_curves. */\n\n  pt2->no_of_curves++;\n\n\n\n  goto out;\n\n  /* Illegal to connect. */\n  /*err1:\n\n  *jstat = -1;\n  s6err (\"sh6connect\", *jstat, 0);\n  goto out; */\n\n  /* Error in data structure. */\nerr2:\n\n  *jstat = -2;\n  s6err (\"sh6connect\", *jstat, 0);\n  goto out;\n\n  /* Error in subfunction. */\nerr3:\n\n  *jstat = -3;\n  s6err (\"sh6connect\", *jstat, 0);\n  goto out;\n\nerr4:\n  /* Selfconnecting not legal */\n  *jstat = -4;\n  s6err (\"sh6connect\", *jstat, 0);\n  goto out;\n\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/sh6count.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6count.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n\n#define SH6COUNT\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nint \n      sh6count(SISLIntpt *pt,int *jstat)\n#else\nint sh6count(pt,jstat)\n   SISLIntpt *pt;\n   int       *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given a main Intpt \n*              return the number of points in the list (of\n*              main points)\n*              and determine whether it is open or closed\n*              through *jstat. If the Intpt is not\n*              in a unique list, say so.\n*\n*\n* INPUT      : pt       - Pointer to the Intpt.\n*              index    - Index specifying a list containing pt.\n*              jstat    - Error flag.\n*                         jstat = 0   => Successful. List is open.\n*                         jstat = 1   => Successful. List is closed.\n*                         jstat = 2   => pt is a junction pt.\n*                         jstat = 3   => pt is isolated.\n*                         jstat = -1  => Error in pt.\n*                         jstat = -2  => List is inconsistent.\n*\n*\n*\n* METHOD     : 1. Traverse forwards from pt to one end of\n*                 the list.\n*              2. Then (unless list is closed) go to the\n*                 other end of the list.\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. Sept. 91.\n*\n*********************************************************************\n*/\n{\n   int       ki;      /* Counter.                        */\n   SISLIntpt *pt1, *pt2;  /* Neighbours of pt.           */\n   SISLIntpt *lastpt, *nowpt, *nextpt;\n\t\t\t /* 3 adjacents pts in the list. */\n   int       kstat;   /* Status variable.                */\n\n   *jstat = 0;\n   ki=1;\n\n   if(pt == SISL_NULL) goto err1;\n   if(!sh6ismain(pt)) goto err1;\n\n   sh6getnhbrs(pt,&pt1,&pt2,&kstat);\n   if(kstat < 0) goto err2; /* Bad list. */\n   if(kstat == 2)\n   {\n       *jstat = 2;\n       goto out;\n   }\n   if(kstat == 3)\n   {\n       *jstat = 3;\n       goto out;\n   }\n\n\n   /* Traverse in the first direction unless at the end. */\n\n   nextpt=pt1;\n   nowpt=pt;\n   while(nextpt != SISL_NULL && nextpt != pt)\n   {\n       ki++;\n       lastpt=nowpt;\n       nowpt=nextpt;\n       sh6getother(nowpt,lastpt,&nextpt,&kstat);\n       if(kstat < 0) goto err2; /* Bad list. */\n   }\n\n   /* Now if nextpt == pt the list is closed and we're finished. */\n\n   if(nextpt == pt)\n   {\n       *jstat=1;\n       goto out;\n   }\n\n   /* Otherwise traverse in the second direction. */\n\n   nextpt=pt2;\n   nowpt=pt;\n   while(nextpt != SISL_NULL)\n   {\n       ki++;\n       lastpt=nowpt;\n       nowpt=nextpt;\n       sh6getother(nowpt,lastpt,&nextpt,&kstat);\n       if(kstat < 0) goto err2; /* Bad list. */\n   }\n\n   goto out;\n\nerr1:\n   /* Error. Error in pt or index. */\n   *jstat = -1;\n   s6err(\"sh6count\",*jstat,0);\n   goto out;\n\nerr2:\n   /* Error. List is inconsistent. */\n   *jstat = -2;\n   s6err(\"sh6count\",*jstat,0);\n   goto out;\n\n   out :\n      return ki;\n}\n"
  },
  {
    "path": "src/sh6cvvert.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n#define SH6CVVERT\n\n#include \"sislP.h\"\n\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6cvvert(SISLCurve *pc1, SISLCurve *pc2, double *cpar1, double *cpar2)\n#else\nvoid sh6cvvert(pc1,pc2,cpar1,cpar2)\n   SISLCurve *pc1;\n   SISLCurve *pc2;\n   double *cpar1;\n   double *cpar2;\n#endif\n/*\n*********************************************************************\n* \n* PURPOSE    : Estimate the parameter values the closest vertices of\n*              two B-spline curves\n* \n* \n* \n* INPUT      : pc1      - Pointer to first curve.\n*              pc1      - Pointer to second curve.\n*\n*\n* OUTPUT     : cpar1    - Parameter value of closest vertex of the 1. curve.\n*              cpar2    - Parameter value of closest vertex of the 2. curve.\n* \n* \n* METHOD     : Find the vertices of the two curves that are closest \n*              to each other. Regard these vertices as Schoenberg\n*              points, and compute the parameter values.\n*\n*\n* REFERENCES : \n*              \n*\n* USE        :\n*\n*-\n* CALLS      : s6dist - Distance between two points.           \n*              \n*\n* WRITTEN BY : Vibeke Skytt, SI, 09.00.\n*\n*********************************************************************\n*/\n{\n  int ki,kj, kh;           /* Counters.   */\n  int kdim = pc1->idim; /* Dimension of geometry space.      */\n  int kminc1;           /* Number of closest vertex of 1. curve. */\n  int kminc2;           /* Number of closest vertex of 2. curve. */\n  int kn1 = pc1->in;    /* Number of coefficients of 1. curve. */\n  int kn2 = pc2->in;    /* Number of coefficients of 2. curve. */\n  int kk1 = pc1->ik;    /* Order of 1. curve. */\n  int kk2 = pc2->ik;   /* Order of 2. curve. */\n  double tdist;           /* Distance.   */\n  double tmin = HUGE;     /* Minimum distance.  */\n  double tpar;            /* Used to compute parameter values.   */\n  double *s1,*s2;         /* Pointers into arrays.   */\n  \n  /* Find position of closest vertices. */\n  \n  for (s1=pc1->ecoef, ki=0; ki<kn1; s1+=kdim, ki++)\n    for (s2=pc2->ecoef, kj=0; kj<kn2; s2+=kdim, kj++)\n      {\n\tfor (tdist=0.0, kh=kdim-1; kh>=0; kh--)\n\t  tdist += (s2[kh]-s1[kh])*(s2[kh]-s1[kh]);\n\t//\ttdist = s6dist(s1,s2,kdim);\n\tif (tdist < tmin)\n\t  {\n\t    tmin = tdist;\n\t    kminc1 = ki;\n\t    kminc2 = kj;\n\t   }\n\t}\n  \n  /* Estimate parameter values of vertices.  */\n  \n  for (ki=kminc1+1, s1=pc1->et+ki, tpar=0.0; \n   ki<kminc1+kk1; tpar+=(*s1), s1++, ki++);\n  *cpar1 = tpar/(double)(kk1-1);\n  \n  for (ki=kminc2+1, s1=pc2->et+ki, tpar=0.0; \n   ki<kminc2+kk2; tpar+=(*s1), s1++, ki++);\n  *cpar2 = tpar/(double)(kk2-1);\n\n  return;\n}\n"
  },
  {
    "path": "src/sh6degen.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6degen.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n\n#define SH6DEGEN\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void sh6degen_geom(SISLObject *,SISLObject *,double [],double [],\n\t\t\t  int *);\n#else\nstatic void sh6degen_geom();\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n  sh6degen(SISLObject * po1, SISLObject * po2, SISLIntdat ** pintdat,\n\t   double aepsge, int *jstat)\n#else\nvoid sh6degen(po1, po2, pintdat, aepsge, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntdat **pintdat;\n     double aepsge;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To replace any curves which are degenerate (to a\n*              point) by points and to remove any subsequent\n*              duplicate points.\n*\n*\n* INPUT      : pintdat  - Pointer to a pointer to intersection data.\n*\n*\n* OUTPUT     : jstat  - status messages\n*                               = 0      : OK\n*                               < 0      : error\n*\n*\n* METHOD     : Run through the Intlists. If an Intlist is degenerate,\n*              then it is a point. If this same point occurs elsewhere\n*              in pintdat (as an Intpt or an end point of another\n*              Intlist) then delete it. Otherwise add it to the\n*              array of Intpoints.\n*              At the end, the Intpoint array may have increased\n*              and the Intlist array may have decresed.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh6getnext       - Get next point in Intlist.\n*              sh6getother      - Get next point in Intlist.\n*              sh6idkpt         - Remove intersection point.\n*              s6length         - Lenght of vector.\n*              s6dist           - Distance between points.\n*              sh6degen_geom    - Fetch geometry.\n*              newIntpt    - Create new Intpt structure.\n*              freeIntlist - Free an intlist structure.\n*\n* WRITTEN BY :Mike Floater, 20/2/92.\n* REWISED BY: Vibeke Skytt, SI, 06.92.\n*\n*********************************************************************\n*/\n{\n  int kstat;\t\t/* Local status variable.          */\n  int kpos = 0;\t\t/* Position of error.              */\n  int ki,kj, kl;        /* Loop variables.        */\n  int kpoint;           /* Number of points in list.       */\n  int kstoremark;       /* Save marker of point.   */\n  int knumbpt;          /* Number of points in intersection list. */\n  int knpar;            /* Number of parameter directions.        */\n  int kexact;           /* Indicates which parameter direction is exact. */\n  SISLIntpt** vpoint;   /* Array of Int points.    */\n  int ipoint;           /* Number of Intpoints.            */\n  int ipmax;            /* Size of vpoint array.           */\n  SISLIntlist** vlist;  /* Array of Intlists.   */\n  int ilist;            /* Number of Intlists.             */\n  int ilmax;            /* Size of vlist array.           */\n  int isdegen;          /* Flag. Is curve degenerate? */\n  double spar[4];       /* Parameter value on intersection curve of\n\t\t\t   the  objects.                         */\n  SISLIntpt *pprev, *pcurr, *pnext;    /*    Pointers to Intpts. */    \n  SISLIntpt *pfirst, *plast;           /*    Pointers to Intpts. */    \n  SISLIntpt *qpt;  \n  SISLObject *qo2=SISL_NULL; /* Either po2 or dummy point. */\n  int newilist;         /* New number of Intlists. */\n  int idim;              /* Dimension of space. */\n  double geomfirst[3]; /* geometric info --- position etc. */\n  double geomcurr[3];  /* geometric info --- position etc. */\n  double geommid[3];   /* geometric info --- position etc. */\n  double len;    /* Distance between two vectors. */\n  \n  knpar = po1->iobj + po2->iobj;\n  *jstat = 0;\n\n  if(*pintdat == SISL_NULL) goto out;\n\n  /* Set up local variables. */\n\n  vpoint = (*pintdat) -> vpoint;\n  ipoint = (*pintdat) -> ipoint;\n  ipmax = (*pintdat) -> ipmax;\n  vlist = (*pintdat) -> vlist;\n  ilist = (*pintdat) -> ilist;\n  ilmax = (*pintdat) -> ilmax;\n\n  if(ipoint == 0 && ilist == 0) goto out;\n\n  /* Make dimension of geometry space. */\n\n  if (po1->iobj == SISLPOINT) idim = po1->p1->idim;\n  else if (po1->iobj == SISLCURVE) idim = po1->c1->idim;\n  else idim = po1->s1->idim;\n\n  /* UJK, feb 93, often po1 and po2 is the same geometry ie po2\n     is a dummy, so let create a dummy point in those cases. */\n  if ((*pintdat) -> vpoint[0]->ipar == po1->iobj)\n  {\n     if ((qo2 = newObject(SISLPOINT)) == SISL_NULL) goto err101;\n     knpar = po1->iobj;\n  }\n  else qo2 = po2;\n  \n     \n     for(ki=0; ki<ilist; ki++)\n  {\n      /* Find out whether the curve vlist[ki] is degenerate.\n      We assume that if all the guide points in vlist[ki]\n      are equal then it is degenerate. This should be\n      correct if SISL has done its job properly before\n      reaching this stage of the intersection algorithm.\n      Otherwise it clearly is not degenerate. */\n\n\n      isdegen = TRUE;\n\n      pfirst = vlist[ki]->pfirst;\n      plast  = vlist[ki]->plast;\n      knumbpt = vlist[ki]->inumb;\n\n      /* VSK, 02-93. Check if the list describes a trimming area.\n\t In that case no reduction is to be performed.            */\n      \n      if (pfirst->iinter == SI_TRIM) continue;\n      \n      kstat = 0;\n      sh6degen_geom(po1,qo2,pfirst->epar,geomfirst,&kstat);\n      if(kstat < 0) goto error;\n\n      pprev = pfirst;\n\n      pcurr = sh6getnext(pprev,vlist[ki]->ind_first);\n\n      /* Loop through the guide points and compare with pfirst. */\n\n      while(pcurr != plast)\n      {\n\t kstat = 0;\n\t  sh6degen_geom(po1,qo2,pcurr->epar,geomcurr,&kstat);\n\t  if(kstat < 0) goto error;\n\n\t  len = s6dist(geomcurr,geomfirst,idim);\n\t  if(len > aepsge)\n\t  {\n\t      isdegen = FALSE;\n\t      break;\n\t  }\n\n\t  sh6getother(pcurr,pprev,&pnext,&kstat);\n\t  if(kstat < 0) goto error;\n  \n\t  pprev = pcurr;\n\t  pcurr = pnext;\n      }\n      \n      /* Compare plast with pfirst. */\n\n      if(isdegen == TRUE)\n      {\n\t kstat = 0;\n\t  sh6degen_geom(po1,qo2,plast->epar,geomcurr,&kstat);\n\t  if(kstat < 0) goto error;\n\n\t  len = s6dist(geomcurr,geomfirst,idim);\n\t  if(len > aepsge)\n\t  {\n\t      isdegen = FALSE;\n\t  }\n      }\n      \n      /* Test if it is only 2 points in the intersection list. In that\n\t case it may be a cyclic constant parameter curve, and it is\n\t necessary to check in an internal point. */\n      \n      if (isdegen && knumbpt == 2)\n      {\n\t for (kexact=0, kj=0; kj<knpar; kj++) \n\t {\n\t    if (pfirst->curve_dir[vlist[ki]->ind_first] &\n\t\t(1 << (kj + 1))) \n\t       kexact = kj + 1;\n\t    spar[kj] = (double)0.5*(pfirst->epar[kj]+plast->epar[kj]);\n\t \n\t }\n\t \n\t /* UJK, 930811:\n\t    kstat = (kexact == 0 || kexact > po1->iobj) ? 1 : 0; */\n\t kstat = (kexact > po1->iobj) ? 1 : 0;\n\t sh6degen_geom(po1,qo2,spar,geommid,&kstat);\n\t \n\t len = s6dist(geommid,geomfirst,idim);\n\t if(len > aepsge)\n\t {\n\t    isdegen = FALSE;\n\t }\n\t else\n\t {\n\t    len = s6dist(geommid,geomcurr,idim);\n\t    if(len > aepsge)\n\t    {\n\t       isdegen = FALSE;\n\t    }\n\t }\n\t \n      }\n\n      if(isdegen == TRUE)\n      {\n\t  /* Curve vlist[ki] is degenerate, i.e. it's just a point.  \n\t     Free the list in pintdat, but make sure that there is one\n\t     point left. If there is a point that is an endpoint of an\n\t     other list, and that are equal to this degenerate list,\n\t     this endpoint should represent these point.\n\t     \n\t     First pass through the list and mark all points as removed.  */\n\n\t pcurr = pfirst;\n\t kstoremark = pfirst->marker;\n\t pnext = sh6getnext(pcurr,vlist[ki]->ind_first);\n\t kpoint = vlist[ki]->inumb;\n\t \n\t for (kl=0; kl<kpoint; kl++)\n\t   {\n\t      /* Mark the point as removed.  */\n\t      \n\t      pcurr->marker = -99;\n\t\t \n\t       pprev = pcurr;\n\t       pcurr = pnext;\n\t       \n\t       if (kl < kpoint-1)\n\t       {\n\t\t  sh6getother(pcurr,pprev,&pnext,&kstat);\n\t\t  if (kstat < 0) goto error;\n\t       }\n\t    }\n\t \n\t /* Free the list.  */\n\t \n\t freeIntlist(vlist[ki]);\n\t vlist[ki] = SISL_NULL;\n\t \n\t  /* Check the intersection points. If no point represent the\n\t     degenerated curve,restore the first point of the curve. */\n\n          for(kj=0; kj<ipoint; kj++)\n\t  {\n\t     qpt = vpoint[kj];\n\t     if (qpt->marker == -99) continue;\n\t     kstat = 0;\n\t    sh6degen_geom(po1,qo2,qpt->epar,geomcurr,&kstat);\n\t    if(kstat < 0) goto error;\n    \n\t    len = s6dist(geomfirst,geomcurr,idim);\n\t    if(len <= aepsge) break;\n\t  }\n\t  if (kj >= ipoint) pfirst->marker = kstoremark;\n\n      }\n  }\n\n  /*  Tidy up the vlist array afterwards since some of the\n      lists have been freed. */\n\n  newilist = 0;\n\n  for(ki=0; ki<ilist; ki++)\n  {\n      if(vlist[ki] != SISL_NULL)\n      {\n\t  newilist++;\n\t  if(newilist < ki+1)\n\t  {\n\t      vlist[newilist-1] = vlist[ki];\n\t      vlist[ki] = SISL_NULL;\n\t  }\n      }\n  }\n\n  ilist = newilist;\n\n  /* Pass through the points and remove all marked points. */\n  \n  for (kj=0; kj<(*pintdat) -> ipoint; )\n  {\n     qpt = (*pintdat)->vpoint[kj];\n     if (qpt->marker == -99)\n     {\n\t/* Remove point.  */\n\t\n\tsh6idkpt (pintdat, &qpt, 0, &kstat);\n\tif (kstat < 0) goto error;\n     }\n     else kj++;\n  }\n  \n  /* Reset the integer pintdat variables with the local\n  ones in case they have changed. */\n\n  (*pintdat)->ipmax =  ipmax;\n  (*pintdat)->ilist =  ilist;\n  (*pintdat)->ilmax =  ilmax;\n\n\n  /* Degeneracies removed. Finish. */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in alloc. */\nerr101:\n  *jstat = -101;\n  s6err (\"sh6degen\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level routine. */\nerror:\n  *jstat = kstat;\n  s6err (\"sh6degen\", *jstat, kpos);\n  goto out;\n\nout:\n   if (qo2 && qo2 != po2) freeObject(qo2);\n\n}\n\n   \n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  sh6degen_geom(SISLObject *po1,SISLObject *po2,double epar[],\n\t\tdouble geom[],int *jstat)\n#else\nstatic void sh6degen_geom(po1,po2,epar,geom,jstat)\n      SISLObject *po1;\n      SISLObject *po2;\n      double epar[];\n      double geom[];\n      int *jstat;\n#endif      \n/*\n*********************************************************************\n*\n* PURPOSE    : Evaluate object in an intersection point between the\n*              two objects, po1 and po2. \n*\n*\n* INPUT      : po1  - First object in intersection.\n*              po2  - Second object, in the case of a surface/curve - analytic\n*                     intersection, po2 = po1 = object pointing at\n*                     the surface or curve.\n*              epar - Parameter values of intersection point inherited\n*                     from the actual intersection point.\n*              jstat - = 0 : Evaluate first object.\n*                      = 1 : Evaluate second object.\n*              \n*\n* OUTPUT     : geom - Position of intersection point in geometry space.\n*              jstat   - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;             /* Local status variable.             */\n   int kdim;                  /* Dimension.                         */\n   int kder = 0;              /* Evaluate position.                 */\n   int kleft1 = 0;            /* Parameter to the evaluator.        */\n   int kleft2 = 0;            /* Parameter to the evaluator.        */\n   int keval = *jstat;        /* Indicates which object to evaluate. */\n   double sder[3];            /* Position and derivatives.          */\n   double snorm[3];           /* Dummy normal in surf. evalutation. */\n\n   *jstat = 0;\n   if (keval == 0)\n   {\n      if (po1->iobj == SISLSURFACE)\n      {\n\t /* Evaluate the surface.  */\n\t \n\t kdim = po1->s1->idim;\n\t s1421(po1->s1,kder,epar,&kleft1,&kleft2,sder,snorm,&kstat);\n\t if (kstat < 0) goto error;\n      }\n      \n      else if (po1->iobj == SISLCURVE)\n      {\n\t \n\t /* Evaluate the curve.  */\n\t \n\t kdim = po1->c1->idim;\n\t s1221(po1->c1,kder,epar[0],&kleft1,sder,&kstat);\n\t if (kstat < 0) goto error;\n      }\n      \n      else if (po1->iobj == SISLPOINT)\n      {\n\t \n\t /* Copy the value of the point. */\n\t \n\t kdim = po1->p1->idim;\n\t memcopy(sder,po1->p1->ecoef,kdim,DOUBLE);\n      }\n   }\n   else if (keval == 1)\n   {\n      if (po2->iobj == SISLSURFACE)\n      {\n\t /* Evaluate the surface.  */\n\t \n\t kdim = po2->s1->idim;\n\t s1421(po2->s1,kder,epar+po1->iobj,&kleft1,&kleft2,sder,snorm,&kstat);\n\t if (kstat < 0) goto error;\n      }\n      \n      else if (po2->iobj == SISLCURVE)\n      {\n\t \n\t /* Evaluate the curve.  */\n\t \n\t kdim = po2->c1->idim;\n\t s1221(po2->c1,kder,epar[po1->iobj],&kleft1,sder,&kstat);\n\t if (kstat < 0) goto error;\n      }\n      \n      else if (po2->iobj == SISLPOINT)\n      {\n\t \n\t /* Copy the value of the point. */\n\t \n\t kdim = po2->p1->idim;\n\t memcopy(sder,po1->p1->ecoef,kdim,DOUBLE);\n      }\n   }\n      \n\n   /* Copy result to output.  */\n   \n   memcopy(geom,sder,kdim,DOUBLE);\n   \n   *jstat = 0;\n   goto out;\n   \n   /* Error in lower level function. */\n   \n   error :\n      *jstat = kstat;\n   goto out;\n   \n   out :\n      return;\n}\n"
  },
  {
    "path": "src/sh6disconn.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6disconn.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define SH6DISCONNECT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n      sh6disconnect(SISLIntpt *pt1,SISLIntpt *pt2,int *jstat)\n#else\nvoid sh6disconnect(pt1,pt2,jstat)\n   SISLIntpt *pt1;\n   SISLIntpt *pt2;\n   int       *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Remove the connection between pt1 and pt2 (which\n*              must be unique) if any.\n*\n* INPUT      : pt1      - First point.\n*              pt2      - Second point.\n*              jstat    - Error flag.\n*                         jstat =  0  => Successful.\n*                         jstat =  1  => pt1 and pt2 are not connected\n*                         jstat = -1  => Error in data structure.\n*\n*\n* METHOD     : \n*\n* CALLS      : s6err      - Gives error message.\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n*\n*********************************************************************\n*/\n{\n  int kstat;                 /* Local status variable.            */\n  int index1,index2;         /* Indices for pt1 and pt2.          */\n  \n   *jstat = 0;\n  \n\n   /* Check if pt1 and pt2 are connected. */\n\n   sh6getlist(pt1,pt2,&index1,&index2,&kstat);\n   if(kstat < 0) goto err1;\n   if(kstat == 1)\n   {\n       *jstat = 1;\n       goto out;\n   }\n\n\n   /* Disconnect. */\n\n   pt1->no_of_curves--;\n   pt1->pnext[index1] = pt1->pnext[pt1->no_of_curves];\n   pt1->curve_dir[index1] = pt1->curve_dir[pt1->no_of_curves];\n\n   pt2->no_of_curves--;\n   pt2->pnext[index2] = pt2->pnext[pt2->no_of_curves];\n   pt2->curve_dir[index2] = pt2->curve_dir[pt2->no_of_curves];\n\n  \n  goto out;  \n  \n\n  \n  /* No connection exists. */\n\n  err1 : *jstat = -1;\n  s6err(\"sh6disconnect\",*jstat,0);\n  goto out;                       \n  \n  out: ;\n}\n"
  },
  {
    "path": "src/sh6edgpnt.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6edgpnt.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n\n#define SH6EDGPOINT\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6edgpoint (SISLEdge * vedge[], SISLIntpt *** wintpt, int *jnum,int *jstat)\n#else\nvoid\nsh6edgpoint (vedge, wintpt, jnum, jstat)\n     SISLEdge *vedge[];\n     SISLIntpt ***wintpt;\n     int *jnum;\n     int *jstat;\n#endif\n /*\n *********************************************************************\n *\n *********************************************************************\n *\n * PURPOSE    : Make an array of pointers pointing to different\n *              intersection points on edges.\n *\n *\n *\n * INPUT      : vedge[]  - SISLEdge intersection.\n *\n *\n * OUTPUT     : jnum     - Number of intersection points,\n *              wintpt   - Array of pointers to intersection points.\n *              jstat    - status messages\n *                           = 1     : Coinside found.\n *                           = 0     : no coinside.\n *                           < 0     : error\n *\n *\n * METHOD     :\n *\n *\n * REFERENCES :\n *\n * CALLS      : sh6getmain - Get main point in chain of help points.\n *\n *\n * WRITTEN BY : Arne Laksaa, SI, 89-06.\n *\n *********************************************************************\n */\n{\n  int lant[2];\n\n  if (vedge[0] == SISL_NULL)\n    lant[0] = 0;\n  else\n    lant[0] = vedge[0]->ipoint;\n\n  if (vedge[1] == SISL_NULL)\n    lant[1] = 0;\n  else\n    lant[1] = vedge[1]->ipoint;\n\n  if (lant[0] + lant[1] > 0)\n    {\n      int kn1;\t\t\t/* Number of int. pt. found.   */\n      int kn, ki, kj;\t\t/* Counters.                   */\n      SISLPtedge *qpt;\n      SISLIntpt *qintpt;\t/* Intersection point.         */\n      SISLIntpt *qmain;\t\t/* Main point in chain of help points.      */\n\n      /* Allocate array of pointers to the points. */\n\n      if (((*wintpt) = newarray (lant[0] + lant[1],\n\t\t\t\t SISLIntpt *)) == SISL_NULL)\n\tgoto err101;\n\n\n      /* Update the array. */\n\n      for (kn1 = 0, kn = 0; kn < 2; kn++)\n\tif (lant[kn] > 0)\n\t  for (kj = 0; kj < vedge[kn]->iedge; kj++)\n\t    for (qpt = vedge[kn]->prpt[kj]; qpt != SISL_NULL; qpt = qpt->pnext)\n\t      {\n\t\tfor (ki = 0; ki < kn1; ki++)\n\t\t  {\n\t\t    if (qpt->ppt == (*wintpt)[ki])\n\t\t      break;\n\t\t  }\n\t\tif (ki == kn1)\n\t\t  (*wintpt)[kn1++] = qpt->ppt;\n\t      }\n\n      /* Traverse the array and remove help points if the corresponding\n\t main point also lies in the array.     */\n\n      for (ki = 0; ki < kn1; ki++)\n\t{\n\t  qintpt = (*wintpt)[ki];\n\t  if (sh6ishelp (qintpt))\n\t    {\n\t      /* A help point is found. Fetch the corresponding main point. */\n\n\t      qmain = sh6getmain (qintpt);\n\n\t      /* Check if the main point lies in the array. */\n\n\t      if (qmain)\n\t\t{\n\t\t  for (kj = 0; kj < kn1; kj++)\n\t\t    if (qmain == (*wintpt)[kj])\n\t\t      break;\n\t\t  if (kj < kn1)\n\t\t    (*wintpt)[ki] = SISL_NULL;\n\t\t}\n\t    }\n\t}\n\n      /* Make sure that the array of int.pt. is dense.  */\n\n      for (ki = 0, kj = kn1; ki < kj; ki++)\n\tif ((*wintpt)[ki] == SISL_NULL)\n\t  (*wintpt)[ki] = (*wintpt)[--kj];\n\n      *jnum = kn1 = kj;\n    }\n  else\n    *jnum = 0;\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in memory allocation.      */\n\nerr101:*jstat = -101;\n  s6err (\"sh6edgpoint\", *jstat, 0);\n  goto out;\n\n\nout:;\n}\n"
  },
  {
    "path": "src/sh6edgred.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6edgred.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n\n#define SH6EDGRED\n\n/* commented out - guen Fri Oct 25 12:59:43 MEZ 1991\n include <stdio.h>\n   commented out - guen Fri Oct 25 12:59:43 MEZ 1991 */\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6edgred (SISLObject * po1, SISLObject * po2,\n\t   SISLIntdat * pintdat, int *jstat)\n#else\nvoid\nsh6edgred (po1, po2, pintdat, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntdat *pintdat;\n     int *jstat;\n#endif\n\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Reduse main int point to help point if they are not legal.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              pintdat  - Intersection data structure.\n*\n*\n* OUTPUT     : jstat    - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      :\n*\n* REFERENCES :\n*\n* WRITTEN BY : Arne Laksaa, SI, Oslo, sep. -91.\n* CORRECTED BY: UJK\n*********************************************************************\n*/\n{\n  int kstat, gstat, i, ki;\n  int change = FALSE;\n  int change_2 = FALSE;\n  int num = 0;\n  SISLIntpt *pt1 = SISL_NULL;\n  SISLIntpt *pt2 = SISL_NULL;\n  SISLIntpt *pcurr = SISL_NULL;\n\n  if (pintdat != SISL_NULL)\n    {\n      do\n\t{\n\t  change_2 = FALSE;\n\t  /* If trim point is internal and one neighbours, change to help\n\t     point, if two neighbours unite till one of them */\n\t  do\n\t    {\n\t      change = FALSE;\n\t      for (i = 0; i < pintdat->ipoint; i++)\n\t\t{\n\t\t  pcurr = pintdat->vpoint[i];\n\t\t  if (pcurr->iinter == SI_TRIM)\n\t\t    {\n\t\t      sh6isinside (po1, po2, pcurr, &kstat);\n\t\t      if (kstat < 0)\n\t\t\tgoto error;\n\t\t      if (kstat == 1)\n\t\t\t{\n\t\t\t  num = sh6nmbmain (pcurr, &kstat);\n\t\t\t  if (kstat < 0)\n\t\t\t    goto error;\n\t\t\t  if (num == 1)\n\t\t\t    {\n\t\t\t      sh6tohelp (pcurr, &kstat);\n\t\t\t      change = TRUE;\n\t\t\t    }\n\t\t\t  else if (num == 2)\n\t\t\t    {\n\t\t\t      sh6getnhbrs (pcurr, &pt1, &pt2, &gstat);\n\t\t\t      if (kstat < 0)\n\t\t\t\tgoto error;\n\t\t\t      if (pt1->iinter == SI_TRIM &&\n\t\t\t\t  pt2->iinter == SI_TRIM)\n\t\t\t\t{\n\t\t\t\t  sh6idunite (&pintdat, &pt1, &pcurr,\n\t\t\t\t\t      DZERO, &kstat);\n\t\t\t\t  if (kstat < 0)\n\t\t\t\t    goto error;\n\t\t\t\t  change = TRUE;\n\t\t\t\t}\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t}\n\t  } while (change);\n\n\n\t  /* For a trim point on the edge with only one trim\n             neighbour on an edge, unit till the other edge\n             neighbour and change status of neighbour*/\n\t  do\n\t    {\n\t      change = FALSE;\n\t      for (i = 0; i < pintdat->ipoint; i++)\n\t\t{\n\t\t  pt1 = pt2 = SISL_NULL;\n\t\t  pcurr = pintdat->vpoint[i];\n\t\t  if (pcurr->iinter == SI_TRIM)\n\t\t    {\n\t\t      sh6isinside (po1, po2, pcurr, &kstat);\n\t\t      if (kstat < 0)\n\t\t\tgoto error;\n\t\t      if (kstat == 2)\n\t\t\t{\n\t\t\t  for (ki = 0; ki < pcurr->no_of_curves; ki++)\n\t\t\t    {\n\t\t\t      pt1 = pcurr->pnext[ki];\n\t\t\t      if (pt1->iinter == SI_TRIM)\n\t\t\t\t{\n\t\t\t\t  sh6comedg (po1, po2, pcurr, pt1, &kstat);\n\t\t\t\t  if (kstat < 0)\n\t\t\t\t    goto error;\n\t\t\t\t    if (kstat)\n\t\t\t\t    {\n\t\t\t\t       if (pt2)\n\t\t\t\t\t  {\n\t\t\t\t\t     pt2 = SISL_NULL;\n\t\t\t\t\t     break;\n\t\t\t\t\t  }\n\t\t\t\t\t  else\n\t\t\t\t\t  pt2 = pt1;\n\t\t\t\t    }\n\t\t\t\t}\n\t\t\t    }\n\t\t\t  if (pt2)\n\t\t\t    {\n\t\t\t       /* sh6idunite (&pintdat, &pt2, &pcurr,\n\t\t\t\t              DZERO, &kstat);  */\n\t\t\t       /* UJK, 12.08.93  */\n\t\t\t      /* sh6idkpt (&pintdat, &pcurr, 1, &kstat);\n\t\t\t     sh6disconnect(pcurr,pt2,&kstat); */\n\t\t\t     pcurr->iinter = SI_SING;\n\n\t\t\t      /*------------------- */\n\t\t\t      /* If no trim neighbours on common\n\t\t\t         edge, remove trim status. */\n\t\t\t      pcurr = pt2;\n\t\t\t      kstat = 0;\n\n\t\t\t      for (ki = 0; ki < pcurr->no_of_curves; ki++)\n\t\t\t\t{\n\t\t\t\t  pt1 = pcurr->pnext[ki];\n\t\t\t\t  if (pt1->iinter == SI_TRIM)\n\t\t\t\t    {\n\t\t\t\t      sh6comedg (po1, po2, pcurr, pt1, &kstat);\n\t\t\t\t      if (kstat < 0)\n\t\t\t\t\tgoto error;\n\t\t\t\t      if (kstat)\n\t\t\t\t\tbreak;\n\n\t\t\t\t    }\n\n\t\t\t\t}\n\t\t\t      /* -------------------- */\n\t\t\t      if (!kstat)\n\t\t\t\tpcurr->iinter = SI_SING;\n\t\t\t      change = TRUE;\n\t\t\t      change_2 = TRUE;\n\t\t\t    }\n\n\t\t\t}\n\n\t\t    }\n\t\t}\n\t  } while (change);\n      } while (change_2);\n\n\n      /* Reduce internal stuff */\n      sh6red (po1, po2, pintdat, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n\n      /* General edge treatment */\n\n      /* UJK, aug 93, spesial branch for crv/crv */\n      if (po1->iobj == SISLCURVE &&\n\t  po2->iobj == SISLCURVE )\n      {\n\t do\n\t {\n\t    change = 0;\n\t    for (i = 0; i < pintdat->ipoint; i++)\n\t    {\n\t       if (sh6ismain (pintdat->vpoint[i]))\n\t       {\n\t\t  sh6getnhbrs (pintdat->vpoint[i], &pt1, &pt2, &gstat);\n\t\t  if (gstat == 1)\n\t\t  {\n\t\t     double parval;\n\t\t     SISLCurve *pcu=SISL_NULL;\n\t\t     if (pintdat->vpoint[i]->epar[0] == pt1->epar[0])\n\t\t     {\n\t\t\tparval = pintdat->vpoint[i]->epar[1];\n\t\t\tpcu    = po2->c1;\n\t\t     }\n\t\t     else if (pintdat->vpoint[i]->epar[1] == pt1->epar[1])\n\t\t     {\n\t\t\tparval = pintdat->vpoint[i]->epar[0];\n\t\t\tpcu    = po1->c1;\n\t\t     }\n\t\t     \n\t\t     if (pcu &&\n\t\t\t parval > pcu->et[pcu->ik-1] &&\n\t\t\t parval < pcu->et[pcu->in] )\n\t\t\t\n\t\t\t\n\t\t     {\n\t\t\tsh6tohelp (pintdat->vpoint[i], &kstat);\n\t\t\tif (kstat < 0)\n\t\t\t   goto error;\n\t\t\tchange = 1;\n\t\t     }\n\t\t  }\n\t       }\n\t    }\n\t } while (change);\n      }\n      else \n      { \n\t do\n\t {\n\t    change = 0;\n\t    for (i = 0; i < pintdat->ipoint; i++)\n\t    {\n\t       if (sh6ismain (pintdat->vpoint[i]))\n\t       {\n\t\t  sh6isinside (po1, po2, pintdat->vpoint[i], &kstat);\n\t\t  if (kstat < 0)\n\t\t     goto error;\n\t\t  \n\t\t  /* ALA and VSK. Test if the point lies on edge in \n\t\t     one or two objects.         */\n\t\t  if (kstat == 2 || kstat == 5)\n\t\t  {\n\t\t     sh6getnhbrs (pintdat->vpoint[i], &pt1, &pt2, &gstat);\n\t\t     if (gstat == 1)\n\t\t     {\n\t\t\tsh6comedg (po1, po2, pintdat->vpoint[i], pt1, &gstat);\n\t\t\t\n\t\t\t/* ALA and VSK. Test if the points lie on the same\n\t\t\t   edge in both objects if it lies on an edge in\n\t\t\t   both objects.                  */\n\t\t\tif ((kstat == 2 && gstat > 0) ||\n\t\t\t    (kstat == 5 && gstat == 3))\n\t\t\t{\n\t\t\t   sh6tohelp (pintdat->vpoint[i], &kstat);\n\t\t\t   if (kstat < 0)\n\t\t\t      goto error;\n\t\t\t   change = 1;\n\t\t\t}\n\t\t     }\n\t\t  }\n\t       }\n\t    }\n\t } while (change);\n      }\n    }\n\n\n\n  *jstat = 0;\n  goto out;\n\n  /* Error lower level routine.  */\n\nerror:(*jstat) = kstat;\n  s6err (\"sh6edgred\", *jstat, 0);\n  goto out;\n\nout:\n  return;\n}\n\n"
  },
  {
    "path": "src/sh6evalint.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6evalint.c,v 1.3 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n\n#define SH6EVALINT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6evalint (SISLObject * ob1, SISLObject * ob2, double eimpli[], int ideg,\n\t    SISLIntpt * pt, double aepsge,\n\t    double *curve_3d[], double *curve_2d_1[], double *curve_2d_2[],\n\t    int *jstat)\n#else\nvoid\nsh6evalint (ob1, ob2, eimpli, ideg,\n\t    pt, aepsge,\n\t    curve_3d, curve_2d_1, curve_2d_2,\n\t    jstat)\n     SISLObject *ob1;\n     SISLObject *ob2;\n     double eimpli[];\n     int ideg;\n     SISLIntpt *pt;\n     double aepsge;\n     double *curve_3d[];\n     double *curve_2d_1[];\n     double *curve_2d_2[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given an Intpt, get the tangent and curvature of intersection\n*\n*\n* INPUT      : ob1\t- Pointer to geometric object(first surf).\n*\t       ob2\t- Pointer to geometric object(second surf).\n*              eimpli   - Array containing descr. of implicit surf\n*\t       ideg     - Type of impl surf.\n*\t       pt       - Pointer to the Intpt.\n*              aepsge   - Absolute tolerance\n*\n*\n* OUTPUT     : curve_3d\t   - Interscetion data, object space (as in s1304, s1306)\n*              curve_2d_1  - Interscetion data, param space (as in s1304, s1306)\n*              curve_2d_2  - Interscetion data, param space (as in s1304)\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, Oslo, Norway. July 91.\n* REVICED BY : UJK, Changed to deal with SISL_Curves also.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Sept. 1994. Avoid array bound\n*              over-run in memcopy.\n*********************************************************************\n*/\n{\n  int dim;\t\t\t/* Geometric dimension. */\n  int kstat;\n  int kpos = 1;\t\t\t/* Position indicator ofr errors          */\n  int left1 = 0, left2 = 0;\t/* Knot navigators in s1421               */\n  int kder = 2;\t\t\t/* Numb of derivatives                    */\n  int silhouett;\t\t/* Flag silhouett case                    */\n  int ki;\t\t\t/* Variable used in loop                  */\n  int ksize;\t\t\t/* Size of output from s1421 or getgeom   */\n  double *geom1 = SISL_NULL;\t\t/* Output values from s1421 or getgeom    */\n  double con_tang[3];\t\t/* Constant tangent.                      */\n  double *norm1 = SISL_NULL;\t\t/* Output values from s1421 or getgeom    */\n  double *geom2 = SISL_NULL;\t\t/* Output values from s1421 or getgeom    */\n  double *norm2 = SISL_NULL;\t\t/* Output values from s1421 or getgeom    */\n  double normimpl[3];\t\t/* Normal of impl surf                    */\n  double right_dir[3];\t\t/* Right direction of 3D intersect. curve */\n  double dot;\t\t\t/* Scalar product */\n  double dummy[6];\n  double ang;\n  double min_hp_ang = 0.00000000001;\n  *jstat = 0;\n  con_tang[0] = (double) 1.0;\n  con_tang[1] = DZERO;\n  con_tang[2] = DZERO;\n\n\n  if (ob1->iobj != SISLSURFACE && ob1->iobj != SISLCURVE)\n    goto errinp;\n  if (!pt)\n    goto errinp;\n  if (ideg < 0)\n    goto errinp;\n\n  if (ob1->iobj == SISLSURFACE )\n    dim = ob1->s1->idim;\n  else\n    dim = ob1->c1->idim;\n\n  if (dim > 3 || dim < 1)\n    goto errinp;\n\n  *curve_3d = pt->geo_track_3d;\n  *curve_2d_1 = pt->geo_track_2d_1;\n  *curve_2d_2 = pt->geo_track_2d_2;\n\n  if (pt->evaluated)\n    goto out;\n\n  if (ideg == 0)\n    {\n       /* No implicit geometry involved */\n       kpos = 1;\n       if (ob2->iobj != SISLSURFACE && ob2->iobj != SISLCURVE)\n\t goto errinp;\n\n       if (ob2->iobj == SISLCURVE)\n\t {\n\t    /* At least the second object is a spline curve,\n\t       use this one */\n\t    kpos = 2;\n\t    if (ob2->c1->idim > 3) goto errinp;\n\n\t    /* Get geometry of first surface */\n\t    sh6getgeom (ob1, 1, pt, &geom1, &norm1, aepsge, &kstat);\n\t    if (kstat < 0)\n\t      goto error;\n\n\t    /* Get geometry of objects */\n\t    sh6getgeom (ob2, 2, pt, &geom2, &norm2, aepsge, &kstat);\n\t    if (kstat < 0)\n\t      goto error;\n\n\t    /* The number of elements to copy is given by pt->size_<obnr>\n\t       and we have obnr=2  (PFU 05/09-94) */\n\t    memcopy(*curve_3d,geom2,pt->size_2,double);\n\n\t }\n       else\n\t {\n\n\n\t    /* Two 3d surfaces */\n\t    kpos = 3;\n\t    if (ob2->iobj != SISLSURFACE)\n\t      goto errinp;\n\t    if ((dim = ob2->s1->idim) != 3)\n\t      goto errinp;\n\n\t    /* Get geometry of first surface */\n\t    sh6getgeom (ob1, 1, pt, &geom1, &norm1, aepsge, &kstat);\n\t    if (kstat < 0)\n\t      goto error;\n\n\t    /* Get geometry of second surface */\n\t    sh6getgeom (ob2, 2, pt, &geom2, &norm2, aepsge, &kstat);\n\t    if (kstat < 0)\n\t      goto error;\n\n\t    /* Get normal direction */\n\t    s6crss (norm1, norm2, right_dir);\n\t    if (kstat < 0)\n\t      goto error;\n\n\t    /* Compute angle. */\n\t    ang = s6ang(norm1, norm2,3);\n\t    if (ang < min_hp_ang)\n\t    {\n\t       /* The point is a singular meeting point.*/\n\t       if (pt->iinter == SI_ORD) pt->iinter = SI_SING;\n\t    }\n\n\t    /* Get tangent and curvature */\n\t    s1304 (geom1, geom2, pt->epar, pt->epar + 2,\n\t\t   *curve_3d, *curve_2d_1, *curve_2d_2, &kstat);\n\t    if (kstat < 0)\n\t      goto error;\n\n\t    if ((dot = s6scpr (right_dir, *curve_3d + 3, 3)) < DZERO)\n\t      {\n\t\t /* Change direction for tangent */\n\t\t for (ki = 0; ki < 3; ki++)\n\t\t   (*curve_3d)[ki + 3] *= -(double) 1;\n\t\t for (ki = 0; ki < 2; ki++)\n\t\t   {\n\t\t      (*curve_2d_1)[ki + 2] *= -(double) 1;\n\t\t      (*curve_2d_2)[ki + 2] *= -(double) 1;\n\t\t   }\n\t      }\n\t }\n\n       pt->evaluated = TRUE;\n    }\n  else\n    {\n       /* Implicit cases */\n       if (ideg == 2000)\n\t {\n\t    /* Here we treat the cases\n\t       spline surf vs implicit analytic curve\n\t       spline curve vs implicit analytic curve\n\t       spline curve vs implicit analytic surf\n\t       in all these cases only 3D posisition is necessary */\n\n\t    /* Clean up from 1D or 2D result */\n\t    if (pt->geo_data_1)\n\t      freearray (pt->geo_data_1);\n\t    if (pt->geo_data_2)\n\t      freearray (pt->geo_data_2);\n\t    pt->geo_data_1 = SISL_NULL;\n\t    pt->size_1 = 0;\n\t    pt->geo_data_2 = SISL_NULL;\n\t    pt->size_2 = 0;\n\n\t    /* Get the right values are computed */\n\t    sh6getgeom (ob1, 1, pt, &geom1, &norm1, aepsge, &kstat);\n\t    if (kstat < 0)\n\t      goto error;\n\n     \t    memcopy(*curve_3d,geom1,dim,double);\n     \t    memcopy((*curve_3d)+dim,con_tang,dim,double);\n\n\t }\n       else\n\t {\n\t    if (ideg == 1003 || ideg == 1004 || ideg == 1005)\n\t      {\n\t\t /* Silhouette cases, B-spline surface */\n\t\t kpos = 3;\n\t\t ksize = 33;\n\t\t silhouett = TRUE;\n\t\t kder = 3;\n\n\t      }\n\t    else\n\t      {\n\t\t /* Analytic surf vs B-spline surface */\n\n\t\t kpos = 4;\n\t\t ksize = 21;\n\t\t silhouett = FALSE;\n\t\t kder = 2;\n\t      }\n\n\t    if (pt->size_1 != ksize)\n\t      {\n\t\t /* Clean up from 1D result */\n\t\t if (pt->geo_data_1)\n\t\t   freearray (pt->geo_data_1);\n\t\t if (pt->geo_data_2)\n\t\t   freearray (pt->geo_data_2);\n\t\t pt->geo_data_1 = SISL_NULL;\n\t\t pt->size_1 = 0;\n\t\t pt->geo_data_2 = SISL_NULL;\n\t\t pt->size_2 = 0;\n\n\n\t\t if ((pt->geo_data_1 = newarray (ksize, DOUBLE))\n\t\t     == SISL_NULL)\n\t\t   goto err101;\n\t\t pt->size_1 = ksize;\n\t\t geom1 = pt->geo_data_1;\n\t\t norm1 = pt->geo_data_1 + ksize - 3;\n\n\t\t s1422 (ob1->s1, kder, pt->iside_1, pt->iside_2,\n\t\t\tpt->epar, &left1, &left2, geom1,\n\t\t\tnorm1, &kstat);\n\t\t if (kstat < 0)\n\t\t   goto error;\n\t      }\n\t    else\n\t      {\n\t\t /* The right values are computed */\n\t\t sh6getgeom (ob1, 1, pt, &geom1, &norm1, aepsge, &kstat);\n\t\t if (kstat < 0)\n\t\t   goto error;\n\n\t      }\n\n\n\t    /* Get normal of implicit surface */\n\t    s1331 (geom1, eimpli, ideg, kder = -1, dummy, normimpl, &kstat);\n\t    if (kstat < 0)\n\t      goto error;\n\n\t    /* Get the right direction of the intersection curve */\n\t    if (silhouett)\n\t      {\n\t\t ang = 1.5; /* Not used */\n\t\t memcopy (right_dir, normimpl, 3, DOUBLE);\n\t\t for (ki=0;ki<3;ki++) right_dir[ki] *= -(double)1.0;\n\t      }\n\t    else\n\t    {\n\t       /* Compute angle. */\n\t       ang = s6ang(norm1, normimpl,3);\n\t       s6crss (norm1, normimpl, right_dir);\n\t    }\n\n\t    /* Get tangent and curvature to the real intersection. */\n\t    s1306 (geom1, pt->epar,\n\t\t   eimpli, ideg, *curve_3d, *curve_2d_1, &kstat);\n\t    if (kstat < 0)\n\t      goto error;\n\t    if (kstat == 2)\n\t    {\n\t       /* The point is a singular meeting point.*/\n\t       if (pt->iinter == SI_ORD) pt->iinter = SI_SING;\n\t    }\n\t    else if (kstat == 10)\n\t    {\n\t       /* The point is a singular non-meeting point.\n\t\t  Tangent found, but sign might be wrong. */\n\t       if (pt->iinter == SI_ORD || pt->iinter == SI_SING )\n\t\t  pt->iinter = SI_TOUCH;\n\t    }\n\t    else if (ang < min_hp_ang)\n\t    {\n\t       /* The point is a singular meeting point.*/\n\t       if (pt->iinter == SI_ORD) pt->iinter = SI_SING;\n\t    }\n\t    else\n\t    if ((dot = s6scpr (right_dir, *curve_3d + 3, 3)) < DZERO)\n\t      {\n\t\t /* Change direction for tangent */\n\t\t for (ki = 0; ki < 3; ki++)\n\t\t   (*curve_3d)[ki + 3] *= -(double) 1;\n\t\t for (ki = 0; ki < 2; ki++)\n\t\t   (*curve_2d_1)[ki + 2] *= -(double) 1;\n\n\t      }\n\t }\n\n\n       pt->evaluated = TRUE;\n\n    }\n\n  *jstat = 0;\n  goto out;\n\n  /* ---------- ERROR EXITS --------------------------- */\n  /* Error in alloc  */\n  err101:\n     *jstat = -101;\n  s6err (\"shevalint\", *jstat, kpos);\n  goto out;\n\n  /* Error in lower level */\n  error:\n     *jstat = kstat;\n  s6err (\"shevalint\", *jstat, kpos);\n  goto out;\n\n  /* Error in input */\n  errinp:\n     *jstat = -200;\n  s6err (\"shevalint\", *jstat, kpos);\n  goto out;\n\n\n  out:;\n}\n"
  },
  {
    "path": "src/sh6floop.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6floop.c,v 1.3 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n\n#define SH6FLOOP\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      sh6floop(SISLIntpt *vedgept[],int inum,int *jpt,int *jstat)\n#else\nvoid sh6floop(vedgept,inum,jpt,jstat)\n   SISLIntpt *vedgept[];\n   int       inum;\n   int       *jpt;\n   int       *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given an array of edge intersection. Sort the array in\n*              such a way that the intersection points connected to the\n*              first point lie at the start of the array. Count the\n*              number of intersections belonging to the first list, and\n*              give a status dependant on the kind of list.\n*\n*\n* INPUT      : vedgept  - Intersection points at the edges of the\n*                         objects.\n*              inum     - Number of intersections in vedgept.\n*\n* OUTPUT     : jpt      - Number of intersections in the first list.\n*              jstat    - Status\n*                         jstat = 0   => Successful. List is open.\n*                         jstat = 1   => Successful. List is closed.\n*                         jstat = 2   => First point is isolated.\n*\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 11.92.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Sept. 1994.  Initialized\n*              gnext.\n* Revised by : Vibeke Skytt, SINTEF, 03.2018. Turn list than ends in \n*              help points\n*\n*********************************************************************\n*/\n{\n  int kstat = 0;\n   int kstat2 = -1;   /* Status of traversing the first list.           */\n   int kpt = 0;       /* Current number of intersections in first loop. */\n   int ki,kj;         /* Counters.                                      */\n   SISLIntpt *qstart; /* First intersection point around the edges.     */\n   SISLIntpt *qprev;  /* Previous intersection point found.             */\n   SISLIntpt *qt;     /* Current intersection point in list.            */\n   SISLIntpt *qnext = SISL_NULL;  /* The next point to enter the list.              */\n   SISLIntpt *qhelp;  /* Help point used in sorting vedgept.            */\n   int nmbmain;       /* Number of main points attahced to a point      */\n   int nmbturn = 0;\n\n   /* Check if there is a list.  */\n\n   *jpt = 0;\n   if (inum == 0) goto out;\n\n   /* Set start point. */\n\n   qstart = vedgept[0];\n\n   /* Traverse the edge intersections to fetch a list starting in qstart.\n      The elements in the list must lie on the edges of the objects.    */\n\n   for (qprev=SISL_NULL, qt=qstart; ; qt=vedgept[kpt])\n   {\n      if (kstat2 == 0 && nmbturn == 0)\n      {\n\t /* Open list. Travers in the opposite direction.  */\n\n\t qt = qstart;\n\t qprev = (kpt > 0) ? vedgept[1] : SISL_NULL;\n\n\t if (kpt > 0)\n\t   {\n\t     /* Turn direction of list */\n\t     for (ki=0; ki<(kpt+1)/2; ++ki)\n\t       {\n\t\t qhelp = vedgept[ki];\n\t\t vedgept[ki] = vedgept[kpt-ki];\n\t\t vedgept[kpt-ki] = qhelp;\n\t       }\n\t   }\n\t nmbturn++;\n      }\n      \n      /* Check if there is any possibility for a continued list */\n      nmbmain = sh6nmbmain(qt, &kstat);\n\n      for (ki=0; ki<qt->no_of_curves; ki++)\n      {\n\t /* Search all curves in this points to find the list.  */\n\n\t qnext = sh6getnext(qt,ki);\n\n\t if (qnext == SISL_NULL)\n\t {\n\t    kstat2 = 0; break;  /* No point.  */\n\t }\n\t if (qnext == qprev) \n\t   {\n\t     if (nmbmain == 1 && nmbturn == 0 && kpt < inum-1)\n\t       {\n\t\t qnext = SISL_NULL;\n\t\t kstat2 = -1;\n\t       }\n\t     continue;  /* Traversing of list have turned.\n\t\t\t   Try next curve.                 */\n\t   }\n\t if (qnext == qstart)\n\t {\n\t    kstat2 = 1; break;  /* A closed loop is found.  */\n\t }\n\n\t /* An intersection is found. Check if it lies on the current\n\t    edges.               */\n\n\t for (kj=kpt+1; kj<inum; kj++)\n\t    if (qnext == vedgept[kj]) break;\n\n\t if (kj == inum) continue;  /* The point lies not at an edge. */\n\n\t /* Change position in the array in such a way that the members\n\t    of the list are placed first.  */\n\n\t kpt++;\n\t qhelp = vedgept[kj];\n\t vedgept[kj] = vedgept[kpt];\n\t vedgept[kpt] = qhelp;\n\n\t /* Set previous pointer.  */\n\n\t qprev = qt;\n\n\t /* Check if we are finished or may continue with the next point. */\n\n\t if (qnext == SISL_NULL || (qnext == qstart && qnext != qprev) ||\n\t     qprev == qt) break;\n      }\n\n      /* Check if we have found the entire list.  */\n\n      if (qnext == qstart || kpt >= inum) break;\n      else if (ki == qt->no_of_curves)\n      {\n\t if (kstat2 < 0) kstat2 = 0;\n\t else break;\n      }\n   }\n\n   /* Set number of points in list and output status.  */\n\n   *jpt = kpt + 1;\n   if (kpt == 0) *jstat = 2;\n   else if (kstat2 == 1) *jstat = 1;\n   else *jstat = 0;\n\n   out :\n      return;\n}\n"
  },
  {
    "path": "src/sh6fndsplt.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6fndsplt.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n\n#define SH6FINDSPLIT\n\n#include \"sislP.h\"\n\n/* \n extern int nmbcall;\nextern int nmb0;\nextern int nmb1;\nextern int nmb2;\nextern int nmb3;\nextern int nmb4;\nextern int nmbsuccess; \n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6findsplit (SISLSurf *ps1, SISLSurf *ps2, double aepsge, int *jstat)\n#else\nvoid\nsh6findsplit (ps1, ps2, aepsge, jstat)\n   SISLSurf *ps1;\n   SISLSurf *ps2;\n   double aepsge;\n   int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Try to intercept intersection between two B-spline\n*              surfaces by finding a splitting geometry between the\n*              two surfaces. This geometry is a plane, a sphere, a\n*              cylinder or a torus.\n*\n*\n* INPUT      : ps1      - First surface.\n*              ps2      - Second surface.\n*              aepsge   - Geometry tolerance. \n*\n*\n* OUTPUT     : jstat    - status messages\n*                                = 1   : Intersection still possible.\n*                                = 0   : Ok. No intersection is possible.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      : \n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 93-05.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;   /* Local status variable.  */\n   int kdim = ps1->idim;  /* Dimension of space. */\n   int ratflag = 0; /* Indicates if surface is rational. */\n   double tepsge;   /* Local tolerance.        */\n   double tdist;    /* Large radius of torus.  */\n   double trad;     /* Radius of sphere, cylinder or torus. */\n   double scentre[3];  /* Centre of splitting geometry.     */\n   double saxis[3];    /* Axis of splitting geometry.       */\n   double simpli[16];   /* Array containing torus info.      */\n   double splitgeom[16];         /* Matrix description of a sphere\n\t\t\t\t    or cylinder.                   */\n   SISLSurf *qs1 = SISL_NULL; /* 1D surface.                     */\n   SISLSurf *qs2 = SISL_NULL; /* 1D surface.                     */\n      \n   /* Still overlap. Try to find splitting geometry object. */\n   \n   sh6splitgeom(ps1, ps2, aepsge, scentre, saxis, &tdist,\n\t\t&trad, &kstat);\n   if (kstat < 0) goto error;\n   \n   /* \n   if (kstat == 0) nmb0++;\n   else if (kstat == 1) nmb1++;\n   else if (kstat == 2) nmb2++; \n   else if (kstat == 3) nmb3++; \n   else if (kstat == 4) nmb4++; \n */\n   \n   /* If kstat = 0 is returned, no splitting geometry is found,\n      and no further interception is to be tried.  */\n   \n   if (kstat > 0)\n   {\n      if (kstat == 1)\n      {\n\t /* The splitting geometry is a plane. Set the two surfaces\n\t    into the plane equation.  */\n\t \n\t s1329 (ps1, scentre, saxis, kdim, &qs1, &kstat);\n\t if (kstat < 0)\n\t    goto error;\n\t s1329 (ps2, scentre, saxis, kdim, &qs2, &kstat);\n\t if (kstat < 0)\n\t    goto error;\n\t \n\t \n\t /* Set local tolerance.  */\n\t \n\t tepsge = aepsge;\n      }\n      else if (kstat == 2 || kstat == 3)\n      {\n\t if (kstat == 2)\n\t {\n\t    /* The splitting geometry object is a sphere.  \n\t       Make a matrix of dimension (idim+1)x(idim+1) describing a hyper\n\t       sphere as an implicit function.      \t      */\n\t    \n\t    s1321(scentre,trad,kdim,1,splitgeom,&kstat);\n\t    if (kstat < 0) goto error;\n\t    \n\t }\n\t else if (kstat == 3)\n\t {\n\t    /* The splitting geometry object is a cylinder.\n\t       Make a matrix of dimension (idim+1)x(idim+1) describing a \n\t       cylinder as an implicit function.           */\n\t    \n\t    s1322(scentre,saxis,trad,kdim,1,splitgeom,&kstat);\n\t    if (kstat < 0) goto error;\n\t }\n\t /* \n\t * Put the description of the surfaces into the implicit\n\t * equation for the sphere or cylinder.\n\t * ----------------------------------------------------------\n\t */\n\t \n\t ratflag = (ps1->ikind == 2 || ps1->ikind == 4) ? 1 : 0;\n\t s1320(ps1,splitgeom,1,ratflag,&qs1,&kstat);\n\t if (kstat < 0) goto error;\n\t \n\t ratflag = (ps2->ikind == 2 || ps2->ikind == 4) ? 1 : 0;\n\t s1320(ps2,splitgeom,1,ratflag,&qs2,&kstat);\n\t if (kstat < 0) goto error;\n\t \n\t /* Set up local tolerance. */\n\t \n\t tepsge = (double)2.0*trad*aepsge;\n      }\n      else if (kstat == 4)\n      {\n\t /* Set surfaces into torus equation. */\n\t \n\t /* \n\t * Put the information concerning the torus in the following sequence\n\t * into simpli: Center, normal, big radius, small radius \n\t * ------------------------------------------------------------------\n\t */\n\t \n\t memcopy(simpli,scentre,3,DOUBLE);\n\t memcopy(simpli+3,saxis,3,DOUBLE);\n\t simpli[6] = tdist;\n\t simpli[7] = trad;\n\t \n\t /* \n\t * Put surfaces into torus equation \n\t * -------------------------------\n\t */ \n\t \n\t s1378(ps1,simpli,1001,kdim,&qs1,&kstat);\n\t if (kstat<0) goto error;\n\t \n\t s1378(ps2,simpli,1001,kdim,&qs2,&kstat);\n\t if (kstat<0) goto error;\n\t \n\t /* Set up local tolerance. */\n\t \n\t tepsge = (double)8.0*aepsge*trad*tdist*tdist;\n      }\t \n\t \n      \n      /* Make box of first 1D surface. */\n      \n      sh1992su(qs1,2,tepsge,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Make box of second 1D surface. */\n      \n      sh1992su(qs2,2,tepsge,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Check if the boxes overlap.  */\n      \n      if (qs1->pbox->e2min[2][0] > qs2->pbox->e2max[2][0] ||\n\t  qs1->pbox->e2max[2][0] < qs2->pbox->e2min[2][0])\n      {\n\t /* \n\t nmbsuccess++; \n\t */\n\t \n\t /* No intersection is possible.  */\n\t \n\t *jstat = 0;\n      }\n      else *jstat = 1;  /* Mark possibility of intersection.  */\n   }\n   else *jstat = 1;  /* Mark possibility of intersection.  */\n\n   goto out;\n   \n   error : *jstat = kstat;\n   goto out;\n   \n   out:\n      if (qs1) freeSurf(qs1);\n      if (qs2) freeSurf(qs2);\n      \n      return;\n}\n"
  },
  {
    "path": "src/sh6getgeom.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6getgeom.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n\n#define SH6GETGEOM\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n      sh6getgeom(SISLObject *ob, int obnr, SISLIntpt *pt,\n\t\t double **geom, double **norm, double aepsge, int *jstat)\n#else\nvoid sh6getgeom(ob,obnr,pt,geom,norm,aepsge,jstat)\n   SISLObject *ob;\n   int        obnr;\n   SISLIntpt  *pt;\n   double     **geom;\n   double     **norm;\n   double     aepsge;\n   int        *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given an Intpt, get the geometric data.\n*\n*\n* INPUT      : ob\t- Pointer to geometric object.\n*\t       obnr\t- 1 or 2 number of object to evaluate.\n*\t       pt       - Pointer to the Intpt.\n*\n*\n* OUTPUT     : geom    \t- Geometric data for object.\n*              geom2    - Normal if existing, otherwise SISL_NULL(dummy).\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. May 91.\n* REVICED BY : Arne Laksaa, SI, Oslo, Norway. May 91.\n* CORRECTED BY: UJK (Lets have a OK status exit !)\n*********************************************************************\n*/\n{\n   int kgeom;\t/* Number of doubles pr object describing geometry. */\n   int dim;\t/* Geometric dimension. */\n   int kpar;\t/* Index of the parameter value of the object in pt. */\n   int kstat;\n   int left1=0,left2=0;\n   double *val;\n   \n   /* UJK */\n   *jstat = 0;\n\n   kgeom = (obnr == 1 ? pt->size_1 : pt->size_2);\n   \n   if (ob->iobj == SISLPOINT)      dim = ob->p1->idim;\n   else if (ob->iobj == SISLCURVE) dim = ob->c1->idim;\n   else if (ob->iobj == SISLSURFACE)  dim = ob->s1->idim;\n   \n   kpar = (obnr == 1 ? 0 : (pt->ipar - ob->iobj));\n\n   if (!kgeom)\n      switch(ob->iobj)\n      {\n\t case SISLPOINT:\n\t    (*geom) = ob->p1->ecoef; \n\t    (*norm) = SISL_NULL;\n            return;\t    \n\t case SISLCURVE:\n\t    val = newarray(2*dim,DOUBLE);\n\t    shevalc(ob->c1,1,pt->epar[kpar],aepsge,&left1,val,&kstat);\n\t    if (kstat < 0) goto err1;\n\t    if (obnr == 1)\n\t    {\n\t       pt->geo_data_1 = val;\n\t       pt->size_1 = 2*dim;\n\t       kgeom = pt->size_1;\n\t    }\n\t    else\n\t    {\n\t       pt->geo_data_2 = val;\n\t       pt->size_2 = 2*dim;\n\t       kgeom = pt->size_2;\n\t    }\n\t    \n\t    break;\n\t case SISLSURFACE:\n\t    val = newarray(7*dim,DOUBLE);\n\t    s1421(ob->s1,2,pt->epar+kpar,&left1,&left2,val,val+6*dim,&kstat);\n\t    if (kstat < 0) goto err1;\n\t    if (obnr == 1)\n\t    {\n\t       pt->geo_data_1 = val;\n\t       pt->size_1 = (dim == 3 ? 7 : 6)*dim;\n\t       kgeom = pt->size_1;\n\t    }\n\t    else\n\t    {\n\t       pt->geo_data_2 = val;\n\t       pt->size_2 = (dim == 3 ? 7 : 6)*dim;\n\t       kgeom = pt->size_2;\n\t    }\n\n\t    break;\n      }\n\t    \n   \n   (*geom) = (obnr == 1 ? pt->geo_data_1 : pt->geo_data_2);\n   \n   if (ob->iobj == SISLSURFACE) (*norm) = (*geom) + kgeom - dim;\n   else\t\t\t\t(*norm) = SISL_NULL;\n   goto out;\n   \n   err1: *jstat = kstat;\n   goto out;\n   \n   out :\n      return;\n}\n"
  },
  {
    "path": "src/sh6getlist.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6getlist.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define SH6GETLIST\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n      sh6getlist(SISLIntpt *pt1,SISLIntpt *pt2,int *index1,int *index2,int *jstat)\n#else\nvoid sh6getlist(pt1,pt2,index1,index2,jstat)\n   SISLIntpt *pt1;\n   SISLIntpt *pt2;\n   int       *index1;\n   int       *index2;\n   int       *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given two Intpts, find the two indices of the\n*              (unique) link which connects them.\n*              If no such link exists, index1 and index2 are set to -1.\n*              pt1 and pt2 can be the same point.\n*              Error if data structure\n*              is inconsistent.\n*\n*\n* INPUT      : pt1       - Pointer to first Intpt.\n*              pt2       - Pointer to second Intpt.\n*\n*\n* OUTPUT     : index1    - Index of list at pt1.\n*              index2    - Index of list at pt2.\n*              jstat     - Error flag.\n*                         jstat =  0  => OK.\n*                         jstat =  1  => No connection, indices = -1.\n*                         jstat = -1  => Data structure inconsistent.\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n*\n*********************************************************************\n*/\n{\n   *index1 = -1;\n   *index2 = -1;\n\n   *jstat=0;\n\n   /* Find \"next\" link from pt1 to pt2. */\n\n   *index1 = sh6getprev(pt1,pt2);\n   *index2 = sh6getprev(pt2,pt1);\n\n   if(*index1 >= 0 && *index2 < 0) goto err1;\n   if(*index2 >= 0 && *index1 < 0) goto err1;\n\n   if(*index1 < 0 && *index2 < 0) *jstat=1;\n\n\n   goto out;\n\nerr1:\n   /* Error --  bad data structure. */\n\n   *jstat = -1;\n   s6err(\"sh6getlist\",*jstat,0);\n   goto out;\n   \n   out :\n      return;\n}\n"
  },
  {
    "path": "src/sh6getmain.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6getmain.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n\n#define SH6GETMAIN\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLIntpt *\nsh6getmain (SISLIntpt * pt)\n#else\nSISLIntpt *\nsh6getmain (pt)\n     SISLIntpt *pt;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given a help point, find the unique main point it is\n*              linked to. If there is no such main point, return\n*              SISL_NULL.\n*\n*\n* INPUT      : pt       - Pointer to the Intpt.\n*\n*\n* OUTPUT     :\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n* CHANGED BY: Ulf J. Krystad, SI, Oslo, Norway. September 91.\n*********************************************************************\n*/\n{\n  int ki;\t\t\t/* Loop control */\n  int kstat;\t\t\t/* Local status */\n  int more = TRUE;\t\t/* Loop control */\n  SISLIntpt *mainpt = SISL_NULL;\n  SISLIntpt *pt1 = SISL_NULL;\n  SISLIntpt *pt2 = SISL_NULL;\n  SISLIntpt *prev = SISL_NULL;\n  SISLIntpt *pcurr = SISL_NULL;\n  SISLIntpt *pnext = SISL_NULL;\n  /* ------------------------------------------------------------- */\n\n\n  if (!sh6ishelp (pt))\n    goto out;\n\n  for (ki = 0; ki < pt->no_of_curves; ki++)\n    {\n      if (sh6ismain (pt1 = sh6getnext (pt, ki)))\n\t{\n\t  mainpt = pt1;\n\t  break;\n\t}\n    }\n\n  if (!mainpt)\n    {\n      /* No close neighbour is main, check along list\n         if not meeting point. */\n      sh6getnhbrs (pt, &pt1, &pt2, &kstat);\n      if (kstat == 1)\n\t{\n\t  /* Terminator, go towards other end */\n\t  prev = pt;\n\t  pcurr = pt1;\n\t  more = TRUE;\n\n\t  while ((!mainpt) && more)\n\t    {\n\t      sh6getother (pcurr, prev, &pnext, &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\n\t      if (pnext && (pnext != pt))\n\t\t{\n\t\t  if (sh6ismain (pnext))\n\t\t    mainpt = pnext;\n\t\t  else\n\t\t    {\n\t\t      prev = pcurr;\n\t\t      pcurr = pnext;\n\t\t      pnext = SISL_NULL;\n\t\t    }\n\t\t}\n\t      else\n\t\tmore = FALSE;\n\n\t    }\n\t}\n\n      else if (kstat == 0)\n\t{\n\t  /* Two neighbours, search both directions */\n\t  for (ki = 0, prev = pt, pcurr = pt1, more = TRUE; (!mainpt) && (ki < 2);\n\t       ki++, prev = pt, pcurr = pt2, more = TRUE)\n\n\t    while ((!mainpt) && more)\n\t      {\n\t\tsh6getother (pcurr, prev, &pnext, &kstat);\n\t\tif (kstat < 0)\n\t\t  goto error;\n\n\t\tif (pnext && (pnext != pt))\n\t\t  {\n\t\t    if (sh6ismain (pnext))\n\t\t      mainpt = pnext;\n\t\t    else\n\t\t      {\n\t\t\tprev = pcurr;\n\t\t\tpcurr = pnext;\n\t\t\tpnext = SISL_NULL;\n\t\t      }\n\t\t  }\n\t\telse\n\t\t  more = FALSE;\n\n\t      }\n\t}\n    }\n\n  goto out;\n\n  /* ------------------------------------------------------------- */\nerror:mainpt = SISL_NULL;\n  s6err (\"sh6getmain\", kstat, 0);\n  goto out;\n\n\n\nout:\n  return mainpt;\n}\n\n"
  },
  {
    "path": "src/sh6getnbrs.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6getnbrs.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n\n#define SH6GETNHBRS\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n      sh6getnhbrs(SISLIntpt *pt,SISLIntpt **pt1,SISLIntpt **pt2,int *jstat)\n#else\nvoid sh6getnhbrs(pt,pt1,pt2,jstat)\n   SISLIntpt *pt;\n   SISLIntpt **pt1;\n   SISLIntpt **pt2;\n   int       *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given the point pt, find both its neighbours if\n*              they are unique.\n*              If pt is help point, look for both type of neighbours.\n*              If main point, look only for main points.\n*\n* INPUT      : pt       - SISLIntpt point.\n*\n* OUTPUT     : pt1      - One neighbour.\n               pt2      - Second neighbour.\n*              jstat    - Error flag.\n*                         jstat =  0  => successful, 2 unique neighbours\n*                         jstat =  1  => pt is end point, pt2 SISL_NULL\n*                         jstat =  2  => pt is junction point, both SISL_NULL\n*                         jstat =  3  => pt is isolated, both SISL_NULL\n*                         jstat = -1  => error in data structure.\n*                         jstat <  0  => error in lower level routine\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n*\n*********************************************************************\n*/\n{\n  int num;              /* count number of pointers    */\n  int i;                /* Loop variable. */\n  \n   *pt1 = SISL_NULL;\n   *pt2 = SISL_NULL;\n   *jstat = 0;\n  \n  if(sh6ismain(pt))  /* pt is main point. */\n  {\n      num=0;\n\n      for(i=0; i < pt->no_of_curves; i++)\n      {\n\t  if(sh6ismain(pt->pnext[i]))\n\t  {\n\t      if(num == 0) *pt1 = pt->pnext[i];\n\t      else *pt2 = pt->pnext[i];\n\t      num++;\n\t  }\n      }\n\n      if(num == 0) *jstat = 3; /* pt is an isolated point. */\n      else if(num == 1) *jstat = 1; /* pt is an end point. */\n      else if(num > 2) /* pt is a junction point. */\n      {\n\t  *pt1 = SISL_NULL;\n\t  *pt2 = SISL_NULL;\n          *jstat = 2;\n      }\n  }\n  else  /* pt is help point. */\n  {\n      num=pt->no_of_curves;\n\n      if(num == 0) *jstat = 3; /* pt is an isolated point. */\n      else\n      {\n          *pt1=pt->pnext[0];\n          if(num == 1) *jstat = 1; /* pt is an end point. */\n\t  else\n          {\n              *pt2=pt->pnext[1];\n              /* UJK; Oh, yeah ?, don't discriminate help points. */\n\t      /* if(num > 2) goto err1; Error in data structure. */\n\t      if (num > 2)\n\t      {\n\t\t *pt1 = SISL_NULL;\n\t\t *pt2 = SISL_NULL;\n\t\t *jstat = 2;\n\t      }\n          }\n      }\n  }\n  \n  goto out;\n  \n\n/* Error in data structure. */\n  /*\nerr1: *jstat = -1;\n      s6err(\"sh6getnhbrs\",*jstat,0);\n      goto out; */\n\n   out:\n      return;\n}\n\n"
  },
  {
    "path": "src/sh6getnext.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6getnext.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n\n#define SH6GETNEXT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nSISLIntpt* \n      sh6getnext(SISLIntpt *pt,int index)\n#else\nSISLIntpt* sh6getnext(pt,index)\n   SISLIntpt *pt;\n   int       index;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given an Intpt and an index, fetch the next point\n*              given by index.\n*              If error, return SISL_NULL.\n*\n*\n* INPUT      : pt       - Pointer to the Intpt.\n*              index    - Index of link at pt.\n*\n*\n* OUTPUT     : \n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n*\n*********************************************************************\n*/\n{\n\n   SISLIntpt *nextpt = SISL_NULL;\n\n   /* check if index is within range */\n\n   if(pt != SISL_NULL &&\n      index >= 0 &&\n      index < pt->no_of_curves) nextpt = pt->pnext[index];\n\n   goto out;\n\n   \n   out :\n      return nextpt;\n}\n"
  },
  {
    "path": "src/sh6getothr.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6getothr.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n\n#define SH6GETOTHER\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n      sh6getother(SISLIntpt *pt,SISLIntpt *pt1,SISLIntpt **pt2,int *jstat)\n#else\nvoid sh6getother(pt,pt1,pt2,jstat)\n   SISLIntpt *pt;\n   SISLIntpt *pt1;\n   SISLIntpt **pt2;\n   int       *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given one neighbour pt1 of the point pt, find\n*              the other neighbour if it is unique.\n*              If pt is help point, look for both type of neighbours.\n*              If main point, look only for main points.\n*              pt and pt1 must be linked.\n*\n* INPUT      : pt       - SISLIntpt point.\n*              pt1      - One neighbour.\n*\n* OUTPUT     :  pt2     - Second neighbour if unique.\n*              jstat    - Error flag.\n*                         jstat =  0  => successful, unique neighbour\n*                         jstat =  1  => pt is end point, pt2 SISL_NULL\n*                         jstat =  2  => pt is junction point, pt2 SISL_NULL\n*                         jstat = -1  => pt1 and pt2 are not connected\n*                         jstat = -2  => error in data structure.\n*                         jstat <  0  => error in lower level routine\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n* CHANGED BY : Ulf J. Krystad, SI, Oslo, Norway. July 91.\n*********************************************************************\n*/\n{\n  int kstat;              /* Local status variable.    */\n  int index,index1;      /* Indices for pt and pt1.   */\n  int num;              /* count number of pointers    */\n  int i;              /* Loop variable. */\n  \n   *pt2 = SISL_NULL;\n   *jstat = 0;\n  \n  sh6getlist(pt,pt1,&index1,&index,&kstat);\n  if(kstat < 0) goto error;\n  if(kstat == 1) goto err1;\n\n  if(sh6ismain(pt))  /* pt is main point. */\n  {\n      if(!sh6ismain(pt1)) goto err1;\n      num=0;\n      /* UJK, don't pass singular point ! */\n      if (pt->iinter == SI_SING)\n      {\n\t  *pt2 = SISL_NULL;\n          *jstat = 2;\n          goto out;\n      }\n\t \n      for(i=0; i < pt->no_of_curves; i++)\n      {\n\t  if(i != index1 && sh6ismain(pt->pnext[i]))\n\t  {\n\t      *pt2 = pt->pnext[i];\n\t      num++;\n\t  }\n      }\n\n      if(num == 0) *jstat = 1; /* pt is an end point. */\n      else if(num > 1) /* pt is a junction point. */\n      {\n\t  *pt2 = SISL_NULL;\n          *jstat = 2;\n      }\n  }\n  else  /* pt is help point. */\n  {\n      num=0;\n\n      for(i=0; i < pt->no_of_curves; i++)\n      {\n\t  if(i != index1)\n\t  {\n\t      *pt2 = pt->pnext[i];\n\t      num++;\n\t  }\n      }\n\n      if(num > 1) goto err2; /* Error in data structure. */\n      if(num == 0) *jstat = 1; /* pt is an end point. */\n  }\n  \n  goto out;\n  \n\n/* Error. pt1 and pt2 are not linked.  */\n\nerr1: *jstat = -1;\n      s6err(\"sh6getother\",*jstat,0);\n      goto out;\n\n/* Error in sub function.  */\n\n/* Error in data structure. */\n\nerr2: *jstat = -2;\n      s6err(\"sh6getother\",*jstat,0);\n      goto out;\n\n/* Error in sub function.  */\n\nerror:  *jstat = kstat;\n        s6err(\"sh6getother\",*jstat,0);\n        goto out;\n\n   out:\n      return;\n}\n"
  },
  {
    "path": "src/sh6getprev.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6getprev.c,v 1.2 2001-03-19 15:59:07 afr Exp $\n *\n */\n\n\n#define SH6GETPREV\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nint \n      sh6getprev(SISLIntpt *pt1,SISLIntpt *pt2)\n#else\nint sh6getprev(pt1,pt2)\n   SISLIntpt *pt1;\n   SISLIntpt *pt2;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given an Intpt pt1 and a pointer to another Intpt pt2,\n*              fetch the index of the pt1 array corresponding\n*              to pt2. If no such index exists return -1.\n*\n*\n* INPUT      : pt1       - Pointer to the Intpt.\n*              pt2     - Pointer to another Intpt.\n*\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. May 91.\n*\n*********************************************************************\n*/\n{\n   int       ncurv;   /* number of curves pt1 is connected to       */\n   int       index;   /* index number for pnext array              */\n\n   index = -1;\n\n   if(pt1 == SISL_NULL || pt2 == SISL_NULL) goto out;\n\n   ncurv = pt1->no_of_curves;  /* note ncurv can be zero */\n\n   index=0;\n   while(index < ncurv && pt1->pnext[index] != pt2) index++;\n   if(index == ncurv) index = -1;  /* no index found */\n\n   goto out;\n\n   out :\n      return index;\n}\n"
  },
  {
    "path": "src/sh6getsegdiv.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define SH6GETSEGDIV\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nint sh6getsegdiv(SISLSurf *ps, int idiv, double epar[], int *seg_flag)\n#else\n  int sh6getsegdiv(ps, idiv, epar, seg_flag)\n     SISLSurf *ps;\n     int idiv;\n     double epar[];\n     int *seg_flag;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : \n*\n*\n*\n* INPUT      : ps     - Surface to fetch segmentation information\n*              idiv   - Parameter directions where a segmentation parameter\n*                       is wanted\n*                                                                     \n*\n* OUTPUT     : epar   - Segmentation parameters\n*              return value - Indicates found segmentation parameters\n*\t\t\t     = 0      : No parameters found\n*\t\t\t     = 1      : Segmentation in 1. par. dir. found\n*                            = 2      : Segmentation in 2. par. dir. found\n*                            = 3      : Segmentation in both par. dir. found\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 2018-02\n*\n*********************************************************************\n*/                                     \n{\n  int ki;\n  int found = 0;\n  double tmid;\n  double tmindist;\n  int prio;\n  double curr_par;\n  int curr_prio;\n  double par;\n  double tstart, tend;\n\n  *seg_flag = 0;\n  /* seg_flag =\n     0 : Segmentation to split along tangential belt\n     1 : Tangential belt to the left\n     2 : Tangential belt to the right\n     3 : Isolated singularity left-left\n     4 : Isolated singularity left-right\n     5 : Isolated singularity right-left\n     6 : Isolated singularity right-right */\n\n  if ((idiv == 1 || idiv == 3) && ps->seg1)\n    {\n      tstart = ps->et1[ps->ik1-1];\n      tend = ps->et1[ps->in1];\n      tmid = 0.5*(tstart + tend);\n      tmindist = HUGE;\n      prio = 0;\n      for (ki=0; ki<ps->seg1->num_seg; ++ki)\n\t{\n\t  curr_par = ps->seg1->seg_val[ki];\n\t  curr_prio = ps->seg1->seg_type[ki];\n\t  if (curr_prio > prio ||\n\t      (curr_prio == prio && fabs(curr_par-tmid) < tmindist))\n\t    {\n\t      par = curr_par;\n\t      prio = curr_prio;\n\t      tmindist = fabs(curr_par-tmid);\n\t    }\n\t}\n      if (DNEQUAL(par, tstart) && par > tstart && DNEQUAL(par, tend) &&\n\t  par < tend)\n\t{\n\t  epar[0] = par;\n\t  found += 1;\n\t  if (prio == TANGENTIAL_BELT_LEFT || prio == TANGENTIAL_BELT_RIGHT)\n\t    (*seg_flag) = prio;\n\t}\n    }\n\n  if ((idiv == 2 || idiv == 3) && ps->seg2)\n    {\n      tstart = ps->et2[ps->ik2-1];\n      tend = ps->et2[ps->in2];\n      tmid = 0.5*(tstart + tend);\n      tmindist = HUGE;\n      prio = 0;\n      for (ki=0; ki<ps->seg2->num_seg; ++ki)\n\t{\n\t  curr_par = ps->seg2->seg_val[ki];\n\t  curr_prio = ps->seg2->seg_type[ki];\n\t  if (curr_prio > prio ||\n\t      (curr_prio == prio && fabs(curr_par-tmid) < tmindist))\n\t    {\n\t      par = curr_par;\n\t      prio = curr_prio;\n\t      tmindist = fabs(curr_par-tmid);\n\t    }\n\t}\n      if (DNEQUAL(par, tstart) && par > tstart && DNEQUAL(par, tend) &&\n\t  par < tend)\n\t{\n\t  epar[1] = par;\n\t  found += 2;\n\t  if (prio == TANGENTIAL_BELT_LEFT || prio == TANGENTIAL_BELT_RIGHT)\n\t    {\n\t      if ((*seg_flag) == 0)\n\t\t(*seg_flag) = prio;\n\t      else if ((*seg_flag) == TANGENTIAL_BELT_LEFT)\n\t\t(*seg_flag) = (prio == TANGENTIAL_BELT_LEFT) ?\n\t\t  ISOLATED_SING_LEFT_LEFT : ISOLATED_SING_LEFT_RIGHT;\n\t      else if ((*seg_flag) == TANGENTIAL_BELT_RIGHT)\n\t\t(*seg_flag) = (prio == TANGENTIAL_BELT_LEFT) ?\n\t\t  ISOLATED_SING_RIGHT_LEFT : ISOLATED_SING_RIGHT_RIGHT;\n\t      else\n\t\t(*seg_flag) = 0;  /* Tangential belt segmentation is\n\t\t\t\t     expected in one parameter dir. only */\n\t    }\n\t}\n    }\n\n  return found;\n}\n"
  },
  {
    "path": "src/sh6gettop.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6gettop.c,v 1.2 2001-03-19 15:59:08 afr Exp $\n *\n */\n\n\n#define SH6GETTOP\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n      sh6gettop(SISLIntpt *pt,int ilist,int *left1,int *right1,int *left2,int *right2,int *jstat)\n#else\nvoid sh6gettop(pt,ilist,left1,right1,left2,right2,jstat)\n   SISLIntpt *pt;\n   int       ilist;\n   int       *left1;\n   int       *right1;\n   int       *left2;\n   int       *right2;\n   int       *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given an Intpt and a list which it lies in, get the\n*              pre-topology information. If list does not\n*              exist give an error message.\n*\n*\n* INPUT      : pt       - Pointer to the Intpt.\n*              ilist    - Index specifying a list.\n*\n*\n* OUTPUT     : pt       - Pointer to the updated Intpt.\n*              left1    - pre-topology data.\n*              right1   - pre-topology data.\n*              left2    - pre-topology data.\n*              right2   - pre-topology data.\n*              jstat    - Error flag.\n*                         jstat =  0  => OK.\n*                         jstat = -1  => ilist is out of range.\n*                         jstat = -2  => Error.\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n*\n*********************************************************************\n*/\n{\n   *jstat=0;\n\n   /* Check pt. */\n\n   if(pt == SISL_NULL) goto err2;\n\n   if(ilist >= 0 && ilist < pt->no_of_curves)\n   {\n       *left1=pt->left_obj_1[ilist];\n       *right1=pt->right_obj_1[ilist];\n       *left2=pt->left_obj_2[ilist];\n       *right2=pt->right_obj_2[ilist];\n   }\n   else if(pt->no_of_curves == 0 && ilist == 0)\n   {\n       *left1=pt->left_obj_1[0];\n       *right1=pt->right_obj_1[0];\n       *left2=pt->left_obj_2[0];\n       *right2=pt->right_obj_2[0];\n   }\n   /* UJK */\n   else if( ilist == -1)\n   {\n       *left1=pt->left_obj_1[0];\n       *right1=pt->right_obj_1[0];\n       *left2=pt->left_obj_2[0];\n       *right2=pt->right_obj_2[0];\n   }\n   else goto err1;\n\n\n   /* Data is set. */\n\n   goto out;\n   \n\nerr1:\n   /* Error. ilist is out of range. */\n   \n   *jstat = -1;\n   s6err(\"sh6gettop\",*jstat,0);\n   goto out;\n\nerr2:\n   /* Error in input. pt is SISL_NULL. */\n   \n   *jstat = -2;\n   s6err(\"sh6gettop\",*jstat,0);\n   goto out;\n   \n   \n   out :\n      return;\n}\n"
  },
  {
    "path": "src/sh6idaledg.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6idaledg.c,v 1.5 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n# define SH6ALLEDG\n#include \"sislP.h\"\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n    sh6idalledg (SISLObject * pob1, SISLObject * pob2, SISLIntdat * pintdat,\n\t       SISLEdge * wedge[], int *jstat)\n#else\n       void\n   sh6idalledg (pob1, pob2, pintdat, wedge, jstat)\n     SISLObject *pob1;\n     SISLObject *pob2;\n     SISLIntdat *pintdat;\n     SISLEdge *wedge[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE     : Update edge structure.\n*\n*\n*\n* INPUT      : pob1    - Pointer to first object.\n*              pob2    - Pointers to second object.\n*              pintdat - intersection data.\n*\n*\n*\n* OUTPUT     : wedge[] - SISLEdge structures to update.\n*              jstat   - status messages\n*                               = 0     : OK!\n*                               < 0     : error.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, 89-05.\n* REVISED BY: Ulf J. Krystad, SI, 91-07.\n* REVISED BY : Vibeke Skytt, SI, 92-09.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Nov.1994. Initialized\n*              'kleft1' and 'kleft2' to avoid memory problems.\n*********************************************************************\n*/\n{\n  int kpos = 0;\t\t\t/* Position of error.       */\n  int kstat = 0;\t\t/* Local error status.      */\n  int ki,kj, kn;\t\t/* Counters.                */\n  int kj1, kn1;\t\t\t/* Counters.                */\n  int kndir;                    /* Number of par. dir.      */\n  int kedg, kedg1;\t\t/* Number of edges.         */\n  int kpar;\t\t\t/* Parameter number.        */\n  int kleft1 = 0;               /* Index of knot.          */\n  int ln[4];                    /* Number of vertices in each par. dir. */\n  int lk[4];                    /* Order in each par. dir.  */\n  double tpar;\t\t\t/* Parameter value at edge. */\n  double tparmain;              /* Parameter of main point. */\n  double tparhelp;              /* Parameter of help point. */\n  double *st[4];                /* Pointer to knot vector in each par. dir. */\n  SISLObject *qob1, *qob2;\t/* Help pointer to object.  */\n  SISLObject *qob11, *qob21;\t/* Help pointer to object.  */\n  SISLPtedge *pte = SISL_NULL;\n  SISLPtedge *prev = SISL_NULL;\n  SISLPtedge *pte1 = SISL_NULL;\n  SISLIntpt *pmain;\n  int notfound;\n\n  /* Set up information about the knot vector in each parameter direction. */\n\n  if (pob1->iobj == SISLCURVE)\n  {\n     ln[0] = pob1->c1->in;\n     lk[0] = pob1->c1->ik;\n     st[0] = pob1->c1->et;\n  }\n  else if (pob1->iobj == SISLSURFACE)\n  {\n     ln[0] = pob1->s1->in1;\n     lk[0] = pob1->s1->ik1;\n     st[0] = pob1->s1->et1;\n     ln[1] = pob1->s1->in2;\n     lk[1] = pob1->s1->ik2;\n     st[1] = pob1->s1->et2;\n  }\n\n  if (pob2->iobj == SISLCURVE)\n  {\n     ln[pob1->iobj] = pob2->c1->in;\n     lk[pob1->iobj] = pob2->c1->ik;\n     st[pob1->iobj] = pob2->c1->et;\n  }\n  else if (pob2->iobj == SISLSURFACE)\n  {\n     ln[pob1->iobj] = pob2->s1->in1;\n     lk[pob1->iobj] = pob2->s1->ik1;\n     st[pob1->iobj] = pob2->s1->et1;\n     ln[pob1->iobj+1] = pob2->s1->in2;\n     lk[pob1->iobj+1] = pob2->s1->ik2;\n     st[pob1->iobj+1] = pob2->s1->et2;\n  }\n\n  for (kn = 0, qob1 = pob1, qob2 = pob2; kn < 2; kn++, qob1 = pob2, qob2 = pob1)\n    {\n      kedg = (qob1->iobj == SISLPOINT ? 0 : (qob1->iobj == SISLCURVE ? 2 : 4));\n\n      if (kedg)\n\twedge[kn]->ipoint = 0;\n\n      for (kj = 0; kj < kedg; kj++)\n\t{\n\t  if (qob1->iobj == SISLCURVE)\n\t    {\n\t      tpar = (kj == 0 ? qob1->c1->et[qob1->c1->ik - 1] :\n\t\t      qob1->c1->et[qob1->c1->in]);\n\t      kpar = 1;\n\t    }\n\t  else if (kj == 0)\n\t    {\n\t      tpar = qob1->s1->et2[qob1->s1->ik2 - 1];\n\t      kpar = 2;\n\t    }\n\t  else if (kj == 1)\n\t    {\n\t      tpar = qob1->s1->et1[qob1->s1->in1];\n\t      kpar = 1;\n\t    }\n\t  else if (kj == 2)\n\t    {\n\t      tpar = qob1->s1->et2[qob1->s1->in2];\n\t      kpar = 2;\n\t    }\n\t  else\n\t    {\n\t      tpar = qob1->s1->et1[qob1->s1->ik1 - 1];\n\t      kpar = 1;\n\t    }\n\n\t  s6idedg ((kn == 0 ? qob1 : qob2), (kn == 0 ? qob2 : qob1),\n\t\t   kn + 1, kpar, tpar, pintdat,\n\t\t   &(wedge[kn]->prpt[kj]), &(wedge[kn]->ipoint), &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n    }\n\n  /* UJK newi; remove helppoints if main point is present */\n  for (kn = 0, qob1 = pob1, qob2 = pob2; kn < 2; kn++, qob1 = pob2, qob2 = pob1)\n    {\n      kedg = (qob1->iobj == SISLPOINT ? 0 : (qob1->iobj == SISLCURVE ? 2 : 4));\n\n      for (kj = 0; kj < kedg; kj++)\n\t{\n\t  for (pte = wedge[kn]->prpt[kj], prev = pte;\n\t       pte != SISL_NULL;)\n\t    {\n\t      notfound = TRUE;\n\n\t      if ((pmain = sh6getmain (pte->ppt)))\n\t\t{\n\t\t  /* pte is a help point and pmain is the\n\t             main point connected to it */\n\n\t\t   /* Check if the help point and main point lie\n\t\t      in different knot intervals in any parameter\n\t\t      direction. In that case, keep the help point.  */\n\n\t\t   for (kndir=pob1->iobj+pob2->iobj, ki=0;\n\t\t    ki<kndir; ki++)\n\t\t   {\n\t\t      tparmain = pmain->epar[ki];\n\t\t      tparhelp = pte->ppt->epar[ki];\n\n\t\t      /* Find position of parameter value in\n\t\t\t to the knot vector.                  */\n\n\t\t      /* __________________________________ */\n\t\t      /* UJK, sept 93, this did not work\n\t\t\t for left hand help pts. */\n\t\t      /*s1219(st[ki],lk[ki],ln[ki],&kleft1,tparmain,&kstat);\n\t\t\t if (kstat < 0) goto error;\n\n\t\t\t s1219(st[ki],lk[ki],ln[ki],&kleft2,tparhelp,&kstat);\n\t\t\t if (kstat < 0) goto error;\n\n\t\t\t if (kleft1 != kleft2) break;*/\n\n\t\t      s6fndintvl(st[ki],lk[ki],ln[ki],&kleft1,\n\t\t\t\t tparmain,tparhelp,0,&kstat);\n\t\t      if (kstat < 0) goto error;\n\n\t\t      if (kstat) break;\n\n\t\t      /* UJK, sept 93, END */\n\t\t      /* __________________________________ */\n\t\t   }\n\n\t\t   if (ki == kndir)\n\t\t   {\n\t\t      /* Search for pmain */\n\t\t      for (kn1 = 0, qob11 = pob1, qob21 = pob2;\n\t\t       kn1 < 2 && notfound;\n\t\t       kn1++, qob11 = pob2, qob21 = pob1)\n\t\t      {\n\t\t\t kedg1 = (qob11->iobj == SISLPOINT ?\n\t\t\t\t  0 : (qob11->iobj == SISLCURVE ? 2 : 4));\n\n\t\t\t for (kj1 = 0; kj1 < kedg1 && notfound; kj1++)\n\t\t\t {\n\t\t\t    for (pte1 = wedge[kn1]->prpt[kj1];\n\t\t\t     pte1 != SISL_NULL && notfound;\n\t\t\t     pte1 = pte1->pnext)\n\t\t\t       if (pte1->ppt == pmain)\n\t\t\t\t  notfound = FALSE;\n\t\t\t }\n\t\t      }\n\t\t   }\n\t\t}\n\n\t      if (notfound == FALSE)\n\t\t{\n\t\t  /* Main point is present, remove help point. */\n\t\t  if (prev == pte)\n\t\t    {\n\t\t      wedge[kn]->prpt[kj] = pte->pnext;\n\t\t      freePtedge (pte);\n\t\t      pte = wedge[kn]->prpt[kj];\n\t\t      prev = pte;\n\t\t      wedge[kn]->ipoint--;\n\t\t    }\n\t\t  else\n\t\t    {\n\t\t      prev->pnext = pte->pnext;\n\t\t      freePtedge (pte);\n\t\t      pte = prev->pnext;\n\t\t      wedge[kn]->ipoint--;\n\t\t    }\n\t\t}\n\t      if (notfound == TRUE)\n\t      \t{\n\t      \t  sh6tomain(pte->ppt, &kstat);\n\t      \t  prev = pte;\n\t      \t  pte = pte->pnext;\n\t      \t}\n\n\t    }\n\t}\n    }\n\n\n  *jstat = 0;\n\n  goto out;\n\n/* Error in lower level routine.      */\n\nerror:*jstat = kstat;\n  s6err (\"sh6idalledg\", *jstat, kpos);\n  goto out;\n\nout:;\n}\n\f\n"
  },
  {
    "path": "src/sh6idcon.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6idcon.c,v 1.2 2001-03-19 15:59:08 afr Exp $\n *\n */\n\n\n#define SH6IDCON\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined (SISLNEEDPROTOTYPES)\nvoid\nsh6idcon (SISLIntdat ** pintdat, SISLIntpt ** pintpt1, SISLIntpt ** pintpt2, int *jstat)\n#else\nvoid \nsh6idcon (pintdat, pintpt1, pintpt2, jstat)\n     SISLIntdat **pintdat;\n     SISLIntpt **pintpt1;\n     SISLIntpt **pintpt2;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To connect two intersection points in pintdat into a list.\n*              If pintdat is SISL_NULL a new pintdat is also made.\n*              If  one of pintpt is close to an other intersection point\n*              the object pintpt is pointing to is removed, and\n*              pintpt is set to point to the already inserted point.\n*              The direction of the connection is set to go \n*              from pintpt1 to pintpt2.\n*\n*\n*\n* INPUT      : pintpt1  - Pointer to a pointer to new intersection point.\n*              pintpt2  - Pointer to a pointer to new intersection point.\n*              pintdat  - Pointer to a pointer to intersection date.\n*\n*\n* OUTPUT     : jstat  - status messages\n*                               = 0      : Connection done.\n*                               < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err      - Gives error message.\n*              sh6connect - Do the connection on low level.\n*              sh6idnpt   - Insert a new intpt structure.\n*\n* WRITTEN BY : Ulf J. Krystad 06.91\n* REVISED BY:  Micael Floater July 91. Set direction of connection.\n* REVISED BY:   Ulf J. Krystad 07.91  Removed direction of connection.\n*********************************************************************\n*/\n{\n  int kstat;\t\t\t/* Local status variable.                     */\n\n  /* First we have to be sure that pintdat contain the two points. */\n\n  sh6idnpt (pintdat, pintpt1, 1, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  sh6idnpt (pintdat, pintpt2, 1, &kstat);\n  if (kstat < 0)\n    goto error;\n\n    /* Connect */\n  sh6connect (*pintpt1, *pintpt2, &kstat);\n  if (kstat < 0)\n    goto error;\n\n    /* Set direction of connection. */\n    /*  sh6setdir(*pintpt1, *pintpt2, &kstat);\n    if (kstat < 0)\n    goto error; */\n\n\n  *jstat = 0;\n  goto out;\n\n  /* Error from lower function */\nerror:\n  *jstat = kstat;\n  s6err (\"sh6idcon\", *jstat, 0);\n  out:\n     ;\n}\n"
  },
  {
    "path": "src/sh6idfcros.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6idfcros.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define SH6IDFCROSS\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n      sh6idfcross(SISLIntdat *pintdat, SISLIntpt *vcross[], int *jncross,\n\t\t  int ipar1, int ipar2, int *jstat)\n#else\nvoid sh6idfcross(pintdat, vcross, jncross, ipar1, ipar2, jstat)\n   SISLIntdat *pintdat;\n   SISLIntpt  *vcross[];\n   int        *jncross;\n   int        ipar1;\n   int        ipar2;\n   int       *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given intersection data. Check if there exist 4\n*              intersection points where where the parameters\n*              corresponding to each object in the intersection\n*              are pairwise equal.\n*\n*\n* INPUT      : pintdat  - Intersection data.\n*              vcross   - Intersection points found so far.\n*              jncross  - Number of intersection points found so far.\n*              ipar1    - Number of parameter directions of first object.\n*              ipar2    - Number of parameter directions of second object.\n*\n* OUTPUT     : vcross   - Intersection points found.\n*              jncross  - Number of intersection points found.\n*              jstat    - Status\n*                         jstat = 0   => No set of points is found.\n*                         jstat = 1   => Successful. 4 points are found.\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*\n* CALLS      : s6dist    -  Distance between points.\n*\n*\n* WRITTEN BY : Vibeke Skytt, SI, 12.92.\n*\n*********************************************************************\n*/\n{ \n   int ki,kj;       /* Counters.                               */\n   int kpt;         /* Index of last intersection point found. */\n   int kpar1;       /* Start index of current parameter set.   */\n   int kpar2;       /* Number of parameter in current set.     */\n   double tdist;    /* Distance between parameter points.      */\n   SISLIntpt *pt;   /* Current intersection point.             */\n   SISLIntpt *qnext; /* Next point to find.                    */\n   \n \n   /* Test if there is 4 points in pintdat.  */\n   \n   if (pintdat->ipoint < 4)\n   {\n      /* No possibility of cross intersections. */\n      \n      *jstat = 0;\n      return;\n   }\n   \n   /* Test if a set of cross intersections is found. */\n   \n   if (*jncross == 4)\n   {\n      /* Test if the second parameter set of the last intersection point\n\t found is equal to that of the first point.         */\n      \n      tdist = s6dist(vcross[0]->epar+ipar1,vcross[3]->epar+ipar1,ipar2);\n      if (DEQUAL(tdist+(double)1.0,(double)1.0))\n\t /* The set of points is found.  */\n\t \n\t *jstat = 1;\n      else\n\t *jstat = 0;\n      \n      return;\n   }\n   \n   /* Prepare for a search for the next point in the set.  */\n   \n   kpt = (*jncross) - 1;\n   pt = vcross[kpt];\n   kpar1 = (kpt % 2 == 0) ? 0 : ipar1;\n   kpar2 = (kpt % 2 == 0) ? ipar1 : ipar2;\n   \n   /* Traverse the intersection points to find a point that has got\n      one parameter set equal to the current one.  */\n   \n   for (ki=0; ki<pintdat->ipoint; ki++)\n   {\n      qnext = pintdat->vpoint[ki];\n      \n      /* Check if the point is found already.  */\n      \n      for (kj=0; kj<=kpt; kj++)\n\t if (qnext == vcross[kj]) break;\n      if (kj <= kpt) continue;\n      \n      /* Check if the next point belongs to the wanted set. */\n      \n      tdist = s6dist(qnext->epar+kpar1,pt->epar+kpar1,kpar2);\n      if (DEQUAL(tdist+(double)1.0,(double)1.0))\n      {\n\t /* A point is found.  */\n\t \n\t kpt++;\n\t vcross[kpt] = qnext;\n\t (*jncross)++;\n\t \n\t /* Find next point.  */\n\t \n\t sh6idfcross(pintdat,vcross,jncross,ipar1,ipar2,jstat);\n\t if (*jstat == 1) return;  /* The entire set is found.  */\n\t \n\t (*jncross)--;\n\t kpt--;\n      }\n   }\n   \n   /* No set of cross intersections exist.  */\n   \n   *jstat = 0;\n   return;\n}\n"
  },
  {
    "path": "src/sh6idget.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6idget.c,v 1.2 2001-03-19 15:59:08 afr Exp $\n *\n */\n\n\n#define SH6IDGET\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6idget (SISLObject * po1, SISLObject * po2, int ipar, double apar, SISLIntdat * pintdat,\n\t  SISLIntdat ** rintdat, double aepsge, int *jstat)\n#else\nvoid\nsh6idget (po1, po2, ipar, apar, pintdat, rintdat, aepsge, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     int ipar;\n     double apar;\n     SISLIntdat *pintdat;\n     SISLIntdat **rintdat;\n     double aepsge;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To pick out points from one intdat(pintdat) and copy them over\n*              to another intdat(rintdat) which has one parameter\n*              dimension lower. The parameter index to be removed is\n*              ipar. Only those points in pintdat which has the value\n*              apar (ie epar[ipar]==apar) are copied.\n*              Help points are transformed to main points and\n*              the geometry data of the object not reduced is copied.\n*              Pretopology for the first connection is copied.\n*\n*\n*\n*\n* INPUT      : po1     - First object in the intersection.\n*              po2     - Second object in the intersection.\n*              ipar    - Number of the parameter that is missing in rintdat.\n*              apar    - Parameter value of the missing parameter.\n*              pintdat - Pointer to intersection data on the mother problem.\n*              aepsge  - Geometry tolerance\n*\n* OUTPUT     : rintdat  - Pointer to a pointer to intersection data.\n*              jstat    - status messages\n*                               = 0      : Inserting done.\n*                               < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err      - Gives error message.\n*              sh6idnpt   - Insert a new intpt structure.\n*\n* WRITTEN BY : UJK, 06.91.\n*\n*********************************************************************\n*/\n{\n  int kstat;\t\t\t/* Local status variable.                 */\n  int kpos = 0;\t\t\t/* Position of error.                     */\n  int ki, kj, kn, kl;\n  int keep_first;\t\t/* Flag, which object is not reduced      */\n  double tstart[4];\n  double tend[4];\n  double spar[4];\t\t/* Storing uppdated parametervalues.      */\n  double tlow, thigh;\n  double help_arr[4];\n  double thelp;\n  SISLIntpt *qpt = SISL_NULL, *pinter=SISL_NULL;\n  double *nullp = SISL_NULL;\n  int found = FALSE;\n  int ind_div, ind_other;\n  SISLObject *qo_div = SISL_NULL, *qo_other = SISL_NULL;\n  int kleftt = 0, klefts = 0;\n  double point[3];\n  int log_ind;\n  SISLIntpt *qtmain = NULL;\n\n  /* Find out which object the parameter belongs to */\n if (ipar < po1->iobj)\n {\n   if(ipar == 1)\tlog_ind = 0;\n   else \t\tlog_ind=1;\n   qo_div = po1;\n   qo_other = po2;\n   ind_div = 0;\n   ind_other = po1->iobj;\n      keep_first = 0;\n }\n else\n {\n   if(ipar == po1->iobj)\tlog_ind = ipar +1;\n   else \t\t\tlog_ind=ipar-1;\n   qo_div = po2;\n   qo_other = po1;\n   ind_div = po1->iobj;\n   ind_other = 0;\n   keep_first = 1;\n    }\n\n  if (pintdat == SISL_NULL)\n    goto out;\n\n  /* ----------------------------------------- */\n\n  for (ki = 0; ki < pintdat->ipoint; ki++)\n  {\n    sh6isinside (po1, po2, pintdat->vpoint[ki], &kstat);\n    if (kstat < 0)\n      goto error;\n\n    if (kstat)\n    {\n      for (kj = 0; kj < (pintdat->vpoint[ki])->no_of_curves;kj++)\n      {\n\tqpt = sh6getnext (pintdat->vpoint[ki], kj);\n\tsh6isinside (po1, po2, qpt, &kstat);\n\tif (kstat < 0)\n\t  goto error;\n\n\t/* For surface, check on curve_dir */\n\tif (kstat &&\n\t    (qo_div->iobj == SISLCURVE ||\n\t     (qo_div->iobj == SISLSURFACE &&\n\t      (pintdat->vpoint[ki]->curve_dir[kj] & (1 << (log_ind + 1))))))\n\t{\n\t  /* curve: */\n\t  tlow = pintdat->vpoint[ki]->epar[ipar];\n\t  thigh = qpt->epar[ipar];\n\t  if (thigh < tlow)\n\t  {\n\t    thelp = thigh;\n\t    thigh = tlow;\n\t    tlow = thelp;\n\t  }\n\n\t  if (apar > tlow && apar < thigh)\n\t  {\n\t    found = TRUE;\n\t    break;\n\t  }\n\t}\n      }\n    }\n    if (found)\n    {\n\n      for (kl=0; kl<qpt->ipar; kl++)\n\thelp_arr[kl] = (double)0.5*(pintdat->vpoint[ki]->epar[kl]\n\t\t\t\t    + qpt->epar[kl]);\n      help_arr[ipar] = apar;\n\n      /* Prepare for iteration. */\n      if (qo_div->iobj == SISLCURVE)\n      {\n\tkleftt=0;\n\ts1221 (qo_div->c1, 0, apar, &kleftt, point, &kstat);\n\tif (kstat < 0)\n\t  goto error;\n      }\n      else\n      {\n\tkleftt=0;\n\tklefts=0;\n\ts1421 (qo_div->s1, 0, help_arr + ind_div,\n\t       &kleftt, &klefts, point, nullp, &kstat);\n\tif (kstat < 0)\n\t  goto error;\n      }\n\n\n      sh6ptobj (point, qo_other, aepsge, help_arr + ind_other,\n\t\t    help_arr + ind_other, &kstat);\n      if (kstat == 1)\n      {\n\t/* Point found, insert */\n\n\tpinter = hp_newIntpt (qpt->ipar, help_arr, DZERO, qpt->iinter,\n\t\t\t      SI_UNDEF, SI_UNDEF, SI_UNDEF, SI_UNDEF,\n\t\t\t      0, 0, nullp, nullp);\n\tif (pinter == SISL_NULL)\n\t  goto err101;\n\n\tsh6insert (&pintdat, pintdat->vpoint[ki], qpt, &pinter, &kstat);\n\tif (kstat < 0)\n\t  goto error;\n      }\n    }\n    if (qo_div->iobj == SISLCURVE)\n      break;\n    else\n      found = FALSE;\n  }\n\n\n\n  /* ----------------------------------------- */\n\n\n\n  if (po1->iobj == SISLCURVE)\n  {\n    tstart[0] = po1->c1->et[po1->c1->ik - 1];\n    tend[0] = po1->c1->et[po1->c1->in];\n  }\n  else if (po1->iobj == SISLSURFACE)\n  {\n    tstart[0] = po1->s1->et1[po1->s1->ik1 - 1];\n    tend[0] = po1->s1->et1[po1->s1->in1];\n    tstart[1] = po1->s1->et2[po1->s1->ik2 - 1];\n    tend[1] = po1->s1->et2[po1->s1->in2];\n  }\n\n  if (po2->iobj == SISLCURVE)\n  {\n    tstart[po1->iobj] = po2->c1->et[po2->c1->ik - 1];\n    tend[po1->iobj] = po2->c1->et[po2->c1->in];\n  }\n  else if (po2->iobj == SISLSURFACE)\n  {\n    tstart[po1->iobj] = po2->s1->et1[po2->s1->ik1 - 1];\n    tend[po1->iobj] = po2->s1->et1[po2->s1->in1];\n    tstart[po1->iobj + 1] = po2->s1->et2[po2->s1->ik2 - 1];\n    tend[po1->iobj + 1] = po2->s1->et2[po2->s1->in2];\n  }\n\n  /* Fix pick values for reduced paramater. */\n  tstart[ipar] = tend[ipar] = apar;\n\n\n  /* Uppdate the array. */\n\n  for (ki = 0; ki < pintdat->ipoint; ki++)\n  {\n    for (kj = 0; kj < pintdat->vpoint[ki]->ipar; kj++)\n      if ((DNEQUAL (pintdat->vpoint[ki]->epar[kj], tstart[kj]) &&\n\t   pintdat->vpoint[ki]->epar[kj] < tstart[kj]) ||\n\t  (DNEQUAL (pintdat->vpoint[ki]->epar[kj], tend[kj]) &&\n\t   pintdat->vpoint[ki]->epar[kj] > tend[kj]))\n\tbreak;\n\n    if (kj == pintdat->vpoint[ki]->ipar)\n    {\n\t  if (sh6ishelp(pintdat->vpoint[ki]))\n\t    qtmain = sh6getmain(pintdat->vpoint[ki]);\n\t  else \n\t    qtmain = NULL;\n\n\t  if (qtmain)\n\t    {\n\t      /* A unique main point exist. Check if it belongs to the\n\t\t subproblem. */\n\n\t      for (kn=0; kn<qtmain->ipar; kn++)\n\t\tif ((qtmain->epar[kn] < tstart[kn] &&\n\t\t     DNEQUAL(qtmain->epar[kn], tstart[kn])) ||\n\t\t    (qtmain->epar[kn] > tend[kn] &&\n\t\t     DNEQUAL(qtmain->epar[kn], tend[kn])))\n\t\t  break;\n\n\t      if (kn == qtmain->ipar)\n\t\t/* The main point belongs to the subproblem. \n\t\t   Skip the help point. */\n\t\tcontinue;\n\t    }\n\n      for (kn = 0; kn < ipar; kn++)\n\tspar[kn] = pintdat->vpoint[ki]->epar[kn];\n      for (; kn < pintdat->vpoint[ki]->ipar - 1; kn++)\n\tspar[kn] = pintdat->vpoint[ki]->epar[kn + 1];\n\n      /* Point accepted, insert into rintdat. */\n      /* VSK. Let the point be a normal main point.  */\n\n      qpt = hp_newIntpt (pintdat->vpoint[ki]->ipar - 1, spar,\n\t\t\t pintdat->vpoint[ki]->adist,1,\n\t\t\t pintdat->vpoint[ki]->left_obj_1[0],\n\t\t\t pintdat->vpoint[ki]->right_obj_1[0],\n\t\t\t pintdat->vpoint[ki]->left_obj_2[0],\n\t\t\t pintdat->vpoint[ki]->right_obj_2[0],\n\t\t\t (keep_first ? pintdat->vpoint[ki]->size_1 : 0),\n\t\t\t (keep_first ? 0 : pintdat->vpoint[ki]->size_2),\n\t\t\t (keep_first ? pintdat->vpoint[ki]->geo_data_1 : nullp),\n\t\t\t (keep_first ? nullp : pintdat->vpoint[ki]->geo_data_2));\n\n      if (qpt == SISL_NULL)\n\tgoto err101;\n\n      sh6idnpt (rintdat, &qpt, 1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n  }\n\n  *jstat = 0;\n  goto out;\n\n\n/* Error in space allocation.  */\n\nerr101:*jstat = -101;\n  s6err (\"sh6idget\", *jstat, kpos);\n  goto out;\n\n/* Error in sub function.  */\n\nerror:*jstat = kstat;\n  s6err (\"sh6idget\", *jstat, kpos);\n  goto out;\n\nout:;\n}\n"
  },
  {
    "path": "src/sh6idkpt.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6idkpt.c,v 1.2 2001-03-19 15:59:08 afr Exp $\n *\n */\n\n\n#define S6IDKPT\n\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6idkpt (SISLIntdat ** pintdat, SISLIntpt ** pintpt, int join, int *jstat)\n#else\nvoid\nsh6idkpt (pintdat, pintpt, join, jstat)\n     SISLIntdat **pintdat;\n     SISLIntpt **pintpt;\n     int join;\n     int *jstat;\n#endif\n\n\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To remove an intersection point pintpt from pintdat.\n*              pintpt is removed from all lists which it lies in if any.\n*              If pintpt has exactly two neighbours, they are joined\n*              together if the option join is selected.\n*              After disconnection is done, pintpt is killed. If pintdat\n*              is empty pintdat is killed and set to SISL_NULL.\n*\n*\n*\n* INPUT/OUTPUT:pintpt   - Pointer to a pointer to new intersection point.\n*              pintdat  - Pointer to a pointer to intersection data.\n*              join     - Flag for whether the lists are repaired.\n*\t\t\t   --ALA-- and kill all help-points connected\n*\t\t\t  to this point if this point is a main point.\n*\n*\n* OUTPUT  :    jstat    - status messages\n*                               = 2      : Pintpt is not in pintdat.\n*                               = 1      : Pintpt is SISL_NULL\n*                               = 0      : OK!\n*                               < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : sh6err      - Gives error message.\n*              freeIntpt  - free instant of intpt structure.\n*\n* WRITTEN BY : Ulf J. Krystad, 06.91.\n*\n*********************************************************************\n*/\n{\n  int ki;\t\t\t/* Counters.    */\n  int knum;\n  int kstat = 0;\n  SISLIntpt *pnhbr_1 = SISL_NULL;\t/* First neighbour  */\n  SISLIntpt *pnhbr_2 = SISL_NULL;\t/* Second neighbour */\n  SISLIntpt *help_pt = SISL_NULL;\t/* help point */\n  int crv_dir_1 = 0;\n  int crv_dir_2 = 0;\n  int index1 = 0;\n  int index2 = 0;\n  int dummy;\n  /* ------------------------------------------------*/\n  \n  *jstat = 0;\n  \n  if ((*pintpt) == SISL_NULL)\n  {\n     *jstat = 1;\n     goto out;\n  }\n  \n  if (join)\n  {\n     /* ALA-- We first remove all help point if this point is a main point. */\n     if (sh6ismain(*pintpt))\n\tfor (ki = 0; ki < (*pintpt)->no_of_curves; ki++)\n\t{\n\t   if (sh6ishelp(help_pt = sh6getnext(*pintpt, ki)))\n\t   {\n\t      sh6idkpt (pintdat, &help_pt, 1, &kstat);\n\t      if (kstat < 0)\n\t\t goto error;\n\t   }\n\t}\n     \n     /* Remember the two neighbours */\n     sh6getnhbrs (*pintpt, &pnhbr_1, &pnhbr_2, &kstat);\n     if (kstat < 0)\n\tgoto error;\n     \n     \n     if (pnhbr_1 && pnhbr_2)\n     {\n\t/* Two neighbours, remember crv_dir */\n\tsh6getlist (*pintpt, pnhbr_1, &dummy, &index1, &kstat);\n\tif (kstat < 0)\n\t   goto error;\t\t/* Error. */\n\tif (kstat == 1)\n\t   goto err1;\t\t/* pt1 and pt2 are not linked. */\n\t\n\tsh6getlist (*pintpt, pnhbr_2, &dummy, &index2, &kstat);\n\tif (kstat < 0)\n\t   goto error;\t\t/* Error. */\n\tif (kstat == 1)\n\t   goto err1;\t\t/* pt1 and pt2 are not linked. */\n\t\n\tcrv_dir_1 = pnhbr_1->curve_dir[index1];\n\tcrv_dir_2 = pnhbr_2->curve_dir[index2];\n     }\n  }\n\n  \n  for (; (*pintpt)->no_of_curves;)\n  {\n     /* Disconnect all */\n     sh6disconnect (*pintpt, (*pintpt)->pnext[0], &kstat);\n     if (kstat < 0)\n\tgoto error;\n  }\n  \n  /* Connect the two neighbours */\n  if (pnhbr_1 && pnhbr_2)\n  {\n     sh6connect (pnhbr_1, pnhbr_2, &kstat);\n     if (kstat < 0)\n\tgoto error;\n     \n     /* UJK, MESZ 930617: Don't bother with curve_dir when \n\tthe points already were connected. */\n     if (kstat != 1)\n     {\n\tsh6getlist (pnhbr_1, pnhbr_2, &index1, &index2, &kstat);\n\tif (kstat < 0)\n\t   goto error;\t\t/* Error. */\n\tif (kstat == 1)\n\t   goto err1;\t\t/* pt1 and pt2 are not linked. */\n\t\n\tpnhbr_1->curve_dir[index1] = crv_dir_1;\n\tpnhbr_2->curve_dir[index2] = crv_dir_2;\n     }\n  }\n  \n  if ((*pintdat) == SISL_NULL)\n  {\n     freeIntpt (*pintpt);\n     (*pintpt) = SISL_NULL;\n     \n     *jstat = 1;\n     goto out;\n  }\n  \n  \n  /* Find pintpt in pintdat. */\n  \n  for (knum = -1, ki = 0; ki < (*pintdat)->ipoint; ki++)\n  {\n     if ((*pintdat)->vpoint[ki] == (*pintpt))\n     {\n\tknum = ki;\n\tbreak;\n     }\n  }\n  \n  \n  if (knum == -1)\n     *jstat = 1;\n  else\n  {\n     (*pintdat)->vpoint[knum] = (*pintdat)->vpoint[(*pintdat)->ipoint - 1];\n     ((*pintdat)->ipoint)--;\n     (*pintdat)->vpoint[(*pintdat)->ipoint] = SISL_NULL;\n     \n     \n     \n     if ((*pintdat)->ipoint == 0)\n     {\n\tfreeIntdat (*pintdat);\n\t(*pintdat) = SISL_NULL;\n     }\n  }\n  \n  freeIntpt (*pintpt);\n  (*pintpt) = SISL_NULL;\n  goto out;\n  \n  \nerr1:\n  *jstat = -1;\n  goto out;\n  \nerror:\n  *jstat = kstat;\n  goto out;\n\nout:;\n}\n"
  },
  {
    "path": "src/sh6idlis.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6idlis.c,v 1.3 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n#define SH6IDLIS\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6idlis (SISLObject * po1, SISLObject * po2, SISLIntdat ** pintdat,\n\t  double aepsge, int *jstat)\n#else\nvoid\nsh6idlis (po1, po2, pintdat, aepsge, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntdat **pintdat;\n     double aepsge;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To update vlist in pintdat.\n*\n*\n* INPUT      : pintdat  - Pointer to a pointer to intersection data.\n*\n*\n* OUTPUT     : jstat  - status messages\n*                               = 0      : OK !\n*                               < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err       - Gives error message.\n*              newIntlist  - Create new intlist structure.\n*              freeIntlist - Free an intlist structure.\n*\n* WRITTEN BY :Ulf J. Krystad, 06.90.\n*\n*********************************************************************\n*/\n{\n  int kstat;\t\t\t/* Local status variable.          */\n  int kpos = 0;\t\t\t/* Position of error.              */\n  int list_index = 0;\t\t/* Counter                         */\n  int knum = 0;\t\t\t/* Counter                         */\n  int indstart;\t\t\t/* Indexes used in lists           */\n  int indlast;\t\t\t/* Indexes used in lists           */\n  int ind1, ind2;\n  int inddum;\t\t\t/* Indexes used in lists           */\n  int no_main = 0;\t\t/* Counter                         */\n  int ki1, ki2, ki, kj;\t\t/* Counters                        */\n  int r1, r2, l1, l2;\t\t/* Pretopology info.\t\t   */\n  int ktype = 0;\t\t/* To indicate type of list.       */\n  int direction;\t\t/* Direction of curve              */\n  double *geom, *norm1, *norm2;\t/* help pointers.\t\t   */\n  SISLIntpt *prev, *pcurr;\t/* to traverse list of points.     */\n  SISLIntpt *pnext, *pstart;\t/* to traverse list of points.     */\n  SISLIntpt *plast, *pother;\t/* to traverse list of points.     */\n  int pretop[4];\n  int case_2d = 0;\t\t/* Case flag, 2d Sf vs Pnt.        */\n  int const_dir;\t\t/* Reduction of internal points\n\t\t\t\t   along a constant parameter.     */\n  int log_1, log_2;\n  /* ------------------------------------------------------------- */\n\n  /* If we do not have any intersection data we just return. */\n\n  if ((*pintdat) == SISL_NULL)\n    goto out;\n  if ((po1->iobj == SISLSURFACE && po1->s1->idim == 2) ||\n      (po2->iobj == SISLSURFACE && po2->s1->idim == 2))\n    case_2d = TRUE;\n  else\n    case_2d = FALSE;\n\n  /* We first destroy existing intersection lists. */\n\n  for (kj = 0; kj < (*pintdat)->ilist; kj++)\n    freeIntlist ((*pintdat)->vlist[kj]);\n\n  /* Set SI_AT info in topology part */\n  sh_set_at (po1, po2, *pintdat, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  \n  \n  /* Traverse all intersection points to get pretopology from help\n     points */\n  \n  for (ki1 = 0; *pintdat && ki1 < (*pintdat)->ipoint; ki1++)\n  {\n     pcurr = (*pintdat)->vpoint[ki1];\n     if (sh6ismain (pcurr))\n     {\n\tsh6gettop (pcurr, 0, pretop, pretop + 1, pretop + 2, pretop + 3, &kstat);\n\tif (kstat < 0)\n\t   goto error;\n\t\n\tfor (ki2 = 0; ki2 < pcurr->no_of_curves; ki2++)\n\t{\n\t   sh6gettophlp (pcurr->pnext[ki2], pretop, case_2d, &kstat);\n\t   if (kstat < 0)\n\t      goto error;\n\t}\n\t\n\tsh6settop (pcurr, 0, pretop[0], pretop[1], pretop[2], pretop[3], &kstat);\n\tif (kstat < 0)\n\t   goto error;\n\t\n     }\n  }\n  \n  \n  /* Remove all internal points in a list when along a\n     constant parameter direction */\n  /* Remove all singularpoints that has exactly two \n     singular neighbours. */\n  \n  if ((po1->iobj == SISLSURFACE && po2->iobj == SISLPOINT\n       && po1->s1->idim == 1) ||\n      (po2->iobj == SISLSURFACE && po1->iobj == SISLPOINT\n       && po2->s1->idim == 1) ||\n      (po1->iobj == SISLSURFACE && po2->iobj == SISLSURFACE\n       && po1->s1->idim == 3))\n     const_dir = 2;\n  else if ((po1->iobj == SISLSURFACE && po2->iobj == SISLCURVE) ||\n\t   (po1->iobj == SISLCURVE && po2->iobj == SISLSURFACE))\n     const_dir = 1;\n  else\n     const_dir = 0;\n  \n  for (kj = 0; kj < (*pintdat)->ipoint; kj++)\n  {\n     \n     pcurr = (*pintdat)->vpoint[kj];\n     \n     sh6getnhbrs (pcurr, &pstart, &plast, &kstat);\n     if (kstat < 0)\n\tgoto error;\n     \n     if (kstat == 0)\n     {\n\t/* Two neighbours, check */\n\tsh6getlist (pcurr, pstart, &indstart, &inddum, &kstat);\n\tif (kstat < 0)\n\t   goto error;\t\t/* Error. */\n\tif (kstat == 1)\n\t   goto errinconsist;\t/* pcurr and pstart are not linked. */\n\t\n\tsh6getlist (pcurr, plast, &indlast, &inddum, &kstat);\n\tif (kstat < 0)\n\t   goto error;\t\t/* Error. */\n\tif (kstat == 1)\n\t   goto errinconsist;\t/* pcurr and plast are not linked. */\n\t\n\tlog_1 = pcurr->curve_dir[indstart];\n\tlog_1 = log_1>>1;\n\tlog_1 &= 15;\n\tlog_2 = pcurr->curve_dir[indlast];\n\tlog_2 = log_2>>1;\n\tlog_2 &= 15;\n\t\n\t\n\tif (const_dir == 0 || \n\t    (log_1 & log_2 ) ||\n\t    (pcurr->iinter == SI_SING &&\n\t     pstart->iinter == SI_SING && plast->iinter == SI_SING))\n\t{\n\t   sh6idkpt (pintdat, &pcurr, 1, &kstat);\n\t   if (kstat < 0)\n\t      goto error;\n\t   /* Recursive nature : */\n\t   kj = -1;\n\t}\n\t\n\t\n     }\n  }\n  \n  /* -------------------------------------------- */\n  if (const_dir > 1)\n  {\n     /* Split curves at points when change in curve_dir */\n     for (kj = 0; kj < (*pintdat)->ipoint; kj++)\n     {\n\t\n\tpcurr = (*pintdat)->vpoint[kj];\n\t\n\tsh6getnhbrs (pcurr, &pstart, &plast, &kstat);\n\tif (kstat < 0)\n\t   goto error;\n\t\n\tif (pcurr->iinter == SI_ORD && kstat == 0)\n\t{\n\t   /* Two neighbours, check */\n\t   sh6getlist (pcurr, pstart, &indstart, &inddum, &kstat);\n\t   if (kstat < 0)\n\t      goto error;\t\t/* Error. */\n\t   if (kstat == 1)\n\t      goto errinconsist;\t/* pcurr and pstart are not linked. */\n\t   \n\t   sh6getlist (pcurr, plast, &indlast, &inddum, &kstat);\n\t   if (kstat < 0)\n\t      goto error;\t\t/* Error. */\n\t   if (kstat == 1)\n\t      goto errinconsist;\t/* pcurr and plast are not linked. */\n\t   \n\t   log_1 = pcurr->curve_dir[indstart];\n\t   log_1 = log_1>>1;\n\t   log_1 &= 15;\n\t   log_2 = pcurr->curve_dir[indlast];\n\t   log_2 = log_2>>1;\n\t   log_2 &= 15;\n\t   \n\t   /* If both curve_dir is set as constant, this must be a singular\n\t      point, (remember internal points on same edge has been\n\t      removed! )*/\n\t   if (log_1 && log_2 ) pcurr->iinter = SI_SING;\n\t}\n\t\n\t\n     }\n  }\n  \n  /* -------------------------------------------- */\n  \n  if (const_dir > 1)\n  {\n     \n     /* Split curves at corner points. This is put in to avoid\n\tproblems for the marching.   */\n     \n     for (kj = 0; kj < (*pintdat)->ipoint; kj++)\n     {\n\t\n\tpcurr = (*pintdat)->vpoint[kj];\n\t\n\tpcurr->marker = FALSE;\n\tif (pcurr->iinter == SI_ORD && sh6nmbmain(pcurr,&kstat) == 2)\n\t   \n\t{\n\t   sh6isinside(po1,po2,pcurr,&kstat);\n\t   \n\t   /* UJK, February 1993, Sometimes an intersection point on an edge is not\n\t      identified as singular. Therefore we split the curve at edges, \n\t      if this is no natural ending (ie parallel pnt), \n\t      int_join_per will join them. */\n\t   /* if (kstat == 3 || kstat == 4) */\n\t   \n\t   if (kstat < 0) goto error;\n\t   \n\t   if (kstat > 1) \n\t   {\n\t      /* The point lies on a boarder. Mark it\n\t\t achieve a split.  */\n\t      \n\t      /* UJK, aug 93, always mark singular in corners */\n\t      if (kstat == 3 || kstat == 4) pcurr->iinter = SI_SING;\n\t      pcurr->marker = TRUE;\n\t   }\n\t}\n     }\n  }\n  \n  \n  if (const_dir > 1)\n  {\n     /* All previous trim points in a corner, must split it's neighbour if\n\tthis lies on a corner */\n     for (kj = 0; kj < (*pintdat)->ipoint; kj++)\n     {\n\t\n\tpcurr = (*pintdat)->vpoint[kj];\n\t\n\tif (pcurr->iinter == SI_TRIM &&\n\t    sh6nmbmain (pcurr, &kstat) == 1)\n\t{\n\t   sh6isinside (po1, po2, pcurr, &kstat);\n\t   if (kstat == 3 || kstat == 4)\n\t   {\n\t      sh6getnhbrs (pcurr, &pstart, &plast, &kstat);\n\t      if (kstat < 0)\n\t\t goto error;\n\t      if (pstart->iinter == SI_TRIM)\n\t      {\n\t\t sh6isinside (po1, po2, pstart, &kstat);\n\t\t if (kstat == 3 || kstat == 4)\n\t\t {\n\t\t    \n\t\t    pstart->iinter = SI_SING;\n\t\t    \n\t\t    /* Recursive nature : */\n\t\t    kj = -1;\n\t\t }\n\t      }\n\t   }\n\t}\n     }\n  }\n  \n  /* April 92, we need one instanse of each end point. This\n     because of the storing of geometric data in the points\n     that is in some cases contex dependent (mirroring\n     in singular situation or translation of parameter space \n     values in periodicity treatment).\n     We identify junction points and make a copy\n     for each branch. */\n  for (ki1 = 0; *pintdat && ki1 < (*pintdat)->ipoint; ki1++)\n  {\n     pcurr = (*pintdat)->vpoint[ki1];\n     if (sh6ismain (pcurr))\n     {\n\t/* Get number of neighbours */\n\tno_main = sh6nmbmain (pcurr, &kstat);\n\tif (kstat < 0)\n\t   goto error;\n\t\n\tif (pcurr->marker ||\n\t    (no_main == 2 && pcurr->iinter == SI_SING) ||\n\t    no_main > 2)\n\t{\n\t   if (pcurr->iinter == SI_ORD && no_main > 2) \n\t      pcurr->iinter = SI_SING;\n\t   sh6idsplit(pintdat, pcurr, &kstat);\n\t   if (kstat < 0) goto error;\n\t}\n     }\n  }\n  /* End of split */\n  \n  /* Traverse all intersection points, mark all main points */\n  for (ki1 = 0; *pintdat && ki1 < (*pintdat)->ipoint; ki1++)\n     if (sh6ismain ((*pintdat)->vpoint[ki1]))\n     {\n\t/* Get number of neighbours */\n\t(*pintdat)->vpoint[ki1]->marker =\n\t   sh6nmbmain ((*pintdat)->vpoint[ki1], &kstat);\n\tif (kstat < 0)\n\t   goto error;\n     }\n     else\n\t(*pintdat)->vpoint[ki1]->marker = 0;\n     \n     \n     /* Traverse all intersection points to look for\n\tstart points to lists. If a point has only one neighbour,\n\tor is SI_SING or has more than two neighbours,\n\tit is a start or end point. */\n     \n     for (ki1 = 0; *pintdat && ki1 < (*pintdat)->ipoint; ki1++)\n\tif ((*pintdat)->vpoint[ki1]->marker > 0)\n\t{\n\t   /* Get number of neighbours */\n\t   no_main = sh6nmbmain ((*pintdat)->vpoint[ki1], &kstat);\n\t   if (kstat < 0)\n\t      goto error;\n\t   \n\t   if (no_main == 1 ||\n\t       (no_main == 2 && (*pintdat)->vpoint[ki1]->iinter == SI_SING) ||\n\t       no_main > 2)\n\t   {\n\t      pstart = (*pintdat)->vpoint[ki1];\n\t      \n\t      for (ki2 = 0; ki2 < pstart->no_of_curves; ki2++)\n\t\t if (sh6ismain (pstart->pnext[ki2]) &&\n\t\t     pstart->pnext[ki2]->marker)\n\t\t {\n\t\t    pcurr = pstart->pnext[ki2];\n\t\t    prev = pstart;\n\t\t    knum = 1;\n\t\t    \n\t\t    /* Get first index */\n\t\t    sh6getlist (pstart, pcurr, &indstart, &inddum, &kstat);\n\t\t    \n\t\t    while (pcurr)\n\t\t    {\n\t\t       /* Remember index */\n\t\t       sh6getlist (prev, pcurr, &inddum, &indlast, &kstat);\n\t\t       \n\t\t       prev->marker--;\n\t\t       pcurr->marker--;\n\t\t       sh6getother (pcurr, prev, &pnext, &kstat);\n\t\t       if (kstat < 0)\n\t\t\t  goto error;\n\t\t       \n\t\t       prev = pcurr;\n\t\t       pcurr = pnext;\n\t\t       knum++;\n\t\t    }\n\t\t    \n\t\t    /* Create list */\n\t\t    /* To be sure that list array is big enough. */\n\t\t    \n\t\t    if (list_index == (*pintdat)->ilmax)\n\t\t    {\n\t\t       (*pintdat)->ilmax += 20;\n\t\t       \n\t\t       if (((*pintdat)->vlist =\n\t\t\t    increasearray ((*pintdat)->vlist, (*pintdat)->ilmax,\n\t\t\t\t\t   SISLIntlist *)) == SISL_NULL)\n\t\t\t  goto err101;\n\t\t    }\n\t\t    \n\t\t    /* Type setting may be done in s1880? */\n\t\t    ktype = 0;\n\t\t    \n\t\t    /* Making a new list structure. */\n\t\t    if (((*pintdat)->vlist[list_index] =\n\t\t\t newIntlist (pstart, prev, ktype)) == SISL_NULL)\n\t\t       goto err101;\n\t\t    (*pintdat)->vlist[list_index]->inumb = knum;\n\t\t    (*pintdat)->vlist[list_index]->ind_first = indstart;\n\t\t    (*pintdat)->vlist[list_index]->ind_last = indlast;\n\t\t    list_index++;\n\t\t    \n\t\t    \n\t\t    \n\t\t }\n\t   }\n\t}\n     \n     /* Only closed list left */\n     for (ki1 = 0; *pintdat && ki1 < (*pintdat)->ipoint; ki1++)\n\tif ((*pintdat)->vpoint[ki1]->marker > 0)\n\t{\n\t   /* Get number of neighbours */\n\t   no_main = sh6nmbmain ((*pintdat)->vpoint[ki1], &kstat);\n\t   if (kstat < 0)\n\t      goto error;\n\t   \n\t   \n\t   if (no_main == 2)\n\t   {\n\t      pstart = prev = (*pintdat)->vpoint[ki1];\n\t      \n\t      sh6getnhbrs (prev, &pcurr, &pnext, &kstat);\n\t      if (kstat < 0 || pcurr == SISL_NULL)\n\t\t goto error;\n\t      knum = 1;\n\t      \n\t      /* Get first index */\n\t      sh6getlist (prev, pcurr, &indstart, &inddum, &kstat);\n\t      \n\t      /* Get last index */\n\t      sh6getlist (prev, pnext, &indlast, &inddum, &kstat);\n\t      \n\t      \n\t      \n\t      while (pcurr && pcurr != pstart)\n\t      {\n\t\t prev->marker = 0;\n\t\t \n\t\t sh6getother (pcurr, prev, &pnext, &kstat);\n\t\t if (kstat < 0)\n\t\t    goto error;\n\t\t \n\t\t prev = pcurr;\n\t\t pcurr = pnext;\n\t\t knum++;\n\t      }\n\t      prev->marker = 0;\n\t      if (pcurr == pstart)\n\t      {\n\t\t /* It really is a closed curve */\n\t\t knum++;\n\t\t prev = pstart;\n\t      }\n\t      else\n\t\t goto errinconsist;\n\t      \n\t      /* Create list */\n\t      /* To be sure that list array is big enough. */\n\t      \n\t      if (list_index == (*pintdat)->ilmax)\n\t      {\n\t\t (*pintdat)->ilmax += 20;\n\t\t \n\t\t if (((*pintdat)->vlist =\n\t\t      increasearray ((*pintdat)->vlist, (*pintdat)->ilmax,\n\t\t\t\t     SISLIntlist *)) == SISL_NULL)\n\t\t    goto err101;\n\t      }\n\t      \n\t      /* Type setting may be done in s1880? */\n\t      ktype = 0;\n\t      \n\t      /* Making a new list structure. */\n\t      if (((*pintdat)->vlist[list_index] =\n\t\t   newIntlist (pstart, prev, ktype)) == SISL_NULL)\n\t\t goto err101;\n\t      (*pintdat)->vlist[list_index]->inumb = knum;\n\t      (*pintdat)->vlist[list_index]->ind_first = indstart;\n\t      (*pintdat)->vlist[list_index]->ind_last = indlast;\n\t      list_index++;\n\t      \n\t      \n\t   }\n\t}\n     \n     \n     (*pintdat)->ilist = list_index;\n     \n     \n     /* If direction of a list is wrong, turn it. */\n     \n     for (kj = 0; kj < (*pintdat)->ilist; kj++)\n     {\n\tknum = (*pintdat)->vlist[kj]->inumb;\n\tindstart = (*pintdat)->vlist[kj]->ind_first;\n\t\n\tpcurr = (*pintdat)->vlist[kj]->pfirst;\n\tplast = (*pintdat)->vlist[kj]->plast;\n\tpnext = (*pintdat)->vlist[kj]->pfirst->pnext[indstart];\n\tdirection = (*pintdat)->vlist[kj]->pfirst->curve_dir[indstart];\n\t\n\t(*pintdat)->vlist[kj]->pretop[0] = SI_UNDEF;\n\t(*pintdat)->vlist[kj]->pretop[1] = SI_UNDEF;\n\t(*pintdat)->vlist[kj]->pretop[2] = SI_UNDEF;\n\t(*pintdat)->vlist[kj]->pretop[3] = SI_UNDEF;\n\t\n\t\n\twhile (pnext != plast)\n\t{\n\t   if (direction)\n\t      break;\n\t   \n\t   sh6getother (pnext, pcurr, &pother, &kstat);\n\t   if (kstat < 0)\n\t      goto error;\n\t   sh6getlist (pnext, pother, &ind1, &ind2, &kstat);\n\t   if (kstat < 0)\n\t      goto error;\n\t   direction = pnext->curve_dir[ind1];\n\t   pcurr = pnext;\n\t   pnext = pother;\n\t}\n\t\n\tif (direction < 0)\n\t{\n\t   pcurr = (*pintdat)->vlist[kj]->pfirst;\n\t   (*pintdat)->vlist[kj]->pfirst = (*pintdat)->vlist[kj]->plast;\n\t   (*pintdat)->vlist[kj]->plast = pcurr;\n\t   \n\t   inddum = (*pintdat)->vlist[kj]->ind_first;\n\t   (*pintdat)->vlist[kj]->ind_first = (*pintdat)->vlist[kj]->ind_last;\n\t   (*pintdat)->vlist[kj]->ind_last = inddum;\n\t   indstart = (*pintdat)->vlist[kj]->ind_first;\n\t}\n\t\n\t/* Set pretopology information. */\n\t/* Traverse the list */\n\t\n\tif ((po1->iobj == SISLSURFACE && po2->iobj == SISLPOINT\n\t     && po1->s1->idim == 1) ||\n\t    (po2->iobj == SISLSURFACE && po1->iobj == SISLPOINT\n\t     && po2->s1->idim == 1) ||\n\t    (po1->iobj == SISLSURFACE && po2->iobj == SISLSURFACE\n\t     && po1->s1->idim == 3))\n\t{\n\t   pstart = prev = (*pintdat)->vlist[kj]->pfirst;\n\t   plast = (*pintdat)->vlist[kj]->plast;\n\t   \n\t   if ((pstart->edge_1 && plast->edge_1) ||\n\t       (pstart->edge_2 && plast->edge_2))\n\t   {\n\t      l1 = SI_IN;\n\t      r1 = SI_OUT;\n\t      l2 = SI_OUT;\n\t      r2 = SI_IN;\n\t      \n\t      if (plast->edge_1 == SI_RIGHT)\n\t\t r1 = SI_AT;\n\t      else if (plast->edge_1 == SI_LEFT)\n\t\t l1 = SI_AT;\n\t      \n\t      if (plast->edge_2 == SI_RIGHT)\n\t\t r2 = SI_AT;\n\t      else if (plast->edge_2 == SI_LEFT)\n\t\t l2 = SI_AT;\n\t      \n\t      (*pintdat)->vlist[kj]->pretop[0] = l1;\n\t      (*pintdat)->vlist[kj]->pretop[1] = r1;\n\t      (*pintdat)->vlist[kj]->pretop[2] = l2;\n\t      (*pintdat)->vlist[kj]->pretop[3] = r2;\n\t      \n\t   }\n\t   \n\t   else\n\t   {\n\t      \n\t      r1 = r2 = l1 = l2 = 0;\n\t      pcurr = sh6getnext (prev, indstart);\n\t      \n\t      /* UJK,Does not work\n\t\t while (pcurr != plast) */\n\t      while (0)\n\t      {\n\t\t if (sh6nmbhelp (pcurr, &kstat))\n\t\t {\n\t\t    if (pcurr->left_obj_1[0] == pcurr->right_obj_1[0] &&\n\t\t\tpcurr->left_obj_1[0] != 0 && r1 == 0)\n\t\t    {\n\t\t       l1 = r1 = pcurr->left_obj_1[0];\n\t\t       if (po1->iobj == 2 && po2->iobj == 2 && po1->s1->idim == 3)\n\t\t       {\n\t\t\t  sh6getgeom (po1, 1, pcurr, &geom, &norm1, aepsge, &kstat);\n\t\t\t  if (kstat < 0)\n\t\t\t     goto error;\n\t\t\t  sh6getgeom (po2, 2, pcurr, &geom, &norm2, aepsge, &kstat);\n\t\t\t  if (kstat < 0)\n\t\t\t     goto error;\n\t\t\t  \n\t\t\t  if (s6scpr (norm1, norm2, 3) < 0.0)\n\t\t\t     l2 = r2 = l1;\n\t\t\t  else\n\t\t\t     l2 = r2 = (l1 == SI_IN ? SI_OUT : SI_IN);\n\t\t       }\n\t\t       else\n\t\t\t  l2 = r2 = (l1 == SI_IN ? SI_OUT : SI_IN);\n\t\t       \n\t\t       break;\n\t\t    }\n\t\t    \n\t\t    if (pcurr->left_obj_2[0] == pcurr->right_obj_2[0] &&\n\t\t\tpcurr->left_obj_2[0] != 0 && r2 == 0)\n\t\t    {\n\t\t       l2 = r2 = pcurr->left_obj_2[0];\n\t\t       if (po1->iobj == 2 && po2->iobj == 2 && po1->s1->idim == 3)\n\t\t       {\n\t\t\t  sh6getgeom (po1, 1, pcurr, &geom, &norm1, aepsge, &kstat);\n\t\t\t  if (kstat < 0)\n\t\t\t     goto error;\n\t\t\t  sh6getgeom (po2, 2, pcurr, &geom, &norm2, aepsge, &kstat);\n\t\t\t  if (kstat < 0)\n\t\t\t     goto error;\n\t\t\t  \n\t\t\t  if (s6scpr (norm1, norm2, 3) < 0.0)\n\t\t\t     l1 = r1 = l2;\n\t\t\t  else\n\t\t\t     l1 = r1 = (l2 == SI_IN ? SI_OUT : SI_IN);\n\t\t       }\n\t\t       else\n\t\t\t  l1 = r1 = (l2 == SI_IN ? SI_OUT : SI_IN);\n\t\t       \n\t\t       break;\n\t\t    }\n\t\t }\n\t\t else if (kstat < 0)\n\t\t    goto error;\n\t\t \n\t\t \n\t\t sh6getother (pcurr, prev, &pnext, &kstat);\n\t\t if (kstat < 0)\n\t\t    goto error;\n\t\t \n\t\t prev = pcurr;\n\t\t pcurr = pnext;\n\t      }\n\t      if (r1 == 0)\n\t      {\n\t\t l1 = SI_IN;\n\t\t r1 = SI_OUT;\n\t\t l2 = SI_OUT;\n\t\t r2 = SI_IN;\n\t      }\n\t      \n\t      \n\t      (*pintdat)->vlist[kj]->pretop[0] = l1;\n\t      (*pintdat)->vlist[kj]->pretop[1] = r1;\n\t      (*pintdat)->vlist[kj]->pretop[2] = l2;\n\t      (*pintdat)->vlist[kj]->pretop[3] = r2;\n\t      \n\t      prev = pstart;\n\t      pcurr = sh6getnext (prev, indstart);\n\t      sh6getlist (prev, pcurr, &ind1, &ind2, &kstat);\n\t      if (kstat < 0)\n\t\t goto error;\n\t      \n\t      for (ki = 0; ki < knum; ki++)\n\t      {\n\t\t sh6settop (prev, ind1, l1, r1, l2, r2, &kstat);\n\t\t if (!pcurr)\n\t\t    break;\n\t\t sh6settop (pcurr, ind2, l1, r1, l2, r2, &kstat);\n\t\t sh6getother (pcurr, prev, &pnext, &kstat);\n\t\t if (kstat < 0)\n\t\t    goto error;\n\t\t prev = pcurr;\n\t\t pcurr = pnext;\n\t\t sh6getlist (prev, pcurr, &ind1, &ind2, &kstat);\n\t\t if (kstat < 0)\n\t\t    goto error;\n\t      }\n\t   }\n\t}\n\t\n\telse if ((po1->iobj == SISLCURVE && po2->iobj == SISLPOINT) ||\n\t\t (po2->iobj == SISLCURVE && po1->iobj == SISLPOINT))\n\t   \n\t{\n\t   /* Curve point cases */\n\t   \n\t   (*pintdat)->vlist[kj]->pretop[0] =\n\t      (*pintdat)->vlist[kj]->pfirst->left_obj_1[0];\n\t   (*pintdat)->vlist[kj]->pretop[1] =\n\t      (*pintdat)->vlist[kj]->plast->right_obj_1[0];\n\t   (*pintdat)->vlist[kj]->pretop[2] =\n\t      (*pintdat)->vlist[kj]->pfirst->left_obj_2[0];\n\t   (*pintdat)->vlist[kj]->pretop[3] =\n\t      (*pintdat)->vlist[kj]->plast->right_obj_2[0];\n\t}\n\t\n\telse if (po1->iobj == SISLCURVE && po2->iobj == SISLCURVE)\n\t{\n\t   \n\t   /* Curve curve cases */\n\t   if ((*pintdat)->vlist[kj]->pfirst->epar[0] <=\n\t       (*pintdat)->vlist[kj]->plast->epar[0])\n\t   {\n\t      (*pintdat)->vlist[kj]->pretop[0] =\n\t\t (*pintdat)->vlist[kj]->pfirst->left_obj_1[0];\n\t      (*pintdat)->vlist[kj]->pretop[1] =\n\t\t (*pintdat)->vlist[kj]->plast->right_obj_1[0];\n\t   }\n\t   else\n\t   {\n\t      (*pintdat)->vlist[kj]->pretop[0] =\n\t\t (*pintdat)->vlist[kj]->plast->left_obj_1[0];\n\t      (*pintdat)->vlist[kj]->pretop[1] =\n\t\t (*pintdat)->vlist[kj]->pfirst->right_obj_1[0];\n\t   }\n\t   \n\t   if ((*pintdat)->vlist[kj]->pfirst->epar[1] <=\n\t       (*pintdat)->vlist[kj]->plast->epar[1])\n\t   {\n\t      (*pintdat)->vlist[kj]->pretop[2] =\n\t\t (*pintdat)->vlist[kj]->pfirst->left_obj_2[0];\n\t      (*pintdat)->vlist[kj]->pretop[3] =\n\t\t (*pintdat)->vlist[kj]->plast->right_obj_2[0];\n\t   }\n\t   else\n\t   {\n\t      (*pintdat)->vlist[kj]->pretop[2] =\n\t\t (*pintdat)->vlist[kj]->plast->left_obj_2[0];\n\t      (*pintdat)->vlist[kj]->pretop[3] =\n\t\t (*pintdat)->vlist[kj]->pfirst->right_obj_2[0];\n\t   }\n\t}\n\t\n\telse if ((po1->iobj == SISLSURFACE && po2->iobj == SISLCURVE\n\t\t  && po1->s1->idim == 3))\n\t{\n\t   \n\t   /* Suface curve case */\n\t   \n\t   (*pintdat)->vlist[kj]->pretop[0] =\n\t      (*pintdat)->vlist[kj]->pfirst->left_obj_1[0];\n\t   (*pintdat)->vlist[kj]->pretop[1] =\n\t      (*pintdat)->vlist[kj]->plast->right_obj_1[0];\n\t   \n\t   if ((*pintdat)->vlist[kj]->pfirst->epar[2] <=\n\t       (*pintdat)->vlist[kj]->plast->epar[2])\n\t   {\n\t      (*pintdat)->vlist[kj]->pretop[2] =\n\t\t (*pintdat)->vlist[kj]->pfirst->left_obj_2[0];\n\t      (*pintdat)->vlist[kj]->pretop[3] =\n\t\t (*pintdat)->vlist[kj]->plast->right_obj_2[0];\n\t   }\n\t   else\n\t   {\n\t      (*pintdat)->vlist[kj]->pretop[2] =\n\t\t (*pintdat)->vlist[kj]->plast->left_obj_2[0];\n\t      (*pintdat)->vlist[kj]->pretop[3] =\n\t\t (*pintdat)->vlist[kj]->pfirst->right_obj_2[0];\n\t   }\n\t   \n\t}\n\t\n\telse if ((po1->iobj == SISLCURVE && po2->iobj == SISLSURFACE\n\t\t  && po1->c1->idim == 3))\n\t{\n\t   \n\t   /* Curve suface case */\n\t   \n\t   if ((*pintdat)->vlist[kj]->pfirst->epar[0] <=\n\t       (*pintdat)->vlist[kj]->plast->epar[0])\n\t   {\n\t      (*pintdat)->vlist[kj]->pretop[0] =\n\t\t (*pintdat)->vlist[kj]->pfirst->left_obj_1[0];\n\t      (*pintdat)->vlist[kj]->pretop[1] =\n\t\t (*pintdat)->vlist[kj]->plast->right_obj_1[0];\n\t   }\n\t   else\n\t   {\n\t      (*pintdat)->vlist[kj]->pretop[0] =\n\t\t (*pintdat)->vlist[kj]->plast->left_obj_1[0];\n\t      (*pintdat)->vlist[kj]->pretop[1] =\n\t\t (*pintdat)->vlist[kj]->pfirst->right_obj_1[0];\n\t   }\n\t   \n\t   (*pintdat)->vlist[kj]->pretop[2] =\n\t      (*pintdat)->vlist[kj]->pfirst->left_obj_2[0];\n\t   (*pintdat)->vlist[kj]->pretop[3] =\n\t      (*pintdat)->vlist[kj]->plast->right_obj_2[0];\n\t   \n\t}\n     }\n     \n     \n     \n     \n     *jstat = 0;\n     goto out;\n     \n     /* ------------------------------------------------------ */\n     errinconsist:\n\t*jstat = -500;\n     s6err (\"sh6idlis\", *jstat, kpos);\n     goto out;\n     \n     err101:\n\t*jstat = -101;\n     s6err (\"sh6idlis\", *jstat, kpos);\n     goto out;\n     \n     error:\n\t*jstat = kstat;\n     s6err (\"sh6idlis\", *jstat, kpos);\n     goto out;\n     \n     out:\n\t;\n}\n   \n"
  },
  {
    "path": "src/sh6idnpt.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6idnpt.c,v 1.2 2001-03-19 15:59:08 afr Exp $\n *\n */\n\n\n#define SH6IDNPT\n\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n      sh6idnpt(SISLIntdat **pintdat,SISLIntpt **pintpt,int itest,int *jstat)\n#else\nvoid sh6idnpt(pintdat,pintpt,itest,jstat)\n     SISLIntdat **pintdat;\n     SISLIntpt  **pintpt;\n     int    itest;\n     int    *jstat;\n#endif   \n\n\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To insert a new intersection point into pintdat.\n*              If pintdat is SISL_NULL a new pintdat is also made.\n*              If pintpt is close to an other intersection point\n*              the object pintpt is pointing to is freed, and\n*              pintpt is set to point to the already inserted point.\n*\n*\n*\n* INPUT      : pintpt   - Pointer to a pointer to new intersection point.\n*              pintdat  - Pointer to a pointer to intersection data.\n*              itest    - Indikate testing equalety.\n*                               = 1      : Testing.\n*                               = 0      : No testing.\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                               = 2      : Already existing.\n*                               = 1      : Already inserted.\n*                               = 0      : Intersection point inserted.\n*                               < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err      - Gives error message.\n*              newIntdat  - Create new intdat structure.\n*              freeIntpt  - free instant of intpt structure.\n*\n* WRITTEN BY : Michael Floater, June 91.\n*\n*********************************************************************\n*/                                     \n{\n  register int ki,kj;              /* Counters.    */\n  \n  /* We have to be sure that we have an intdat structure. */\n  \n  if ((*pintdat) == SISL_NULL)\n    {\n      if (((*pintdat) = newIntdat()) == SISL_NULL) goto err101;\n    }\n  \n  \n  /* Then we have to be sure that we do not have the intersection point\n     before or an equal point. */\n  \n  for (ki=0; ki<(*pintdat)->ipoint; ki++)\n    if ((*pintdat)->vpoint[ki] == (*pintpt))\n      {\n\t*jstat = 1;\n\tgoto out;\n      }\n    else if (itest)\n      {\n\tfor (kj=0; kj<(*pintpt)->ipar; kj++)\n\t  if (DNEQUAL((*pintpt)->epar[kj],(*pintdat)->vpoint[ki]->epar[kj]))\n\t    break;\n\t\n\tif (kj == (*pintpt)->ipar)\n\t  {\n\t    freeIntpt(*pintpt);\n\t    (*pintpt) = (*pintdat)->vpoint[ki];\n\t    *jstat = 2;\n\t    goto out;\n\t  }\n      }\n  \n  \n  /* Then we have to be sure that the array vpoint is great enough. */\n  \n  if (ki == (*pintdat)->ipmax)\n    {\n      (*pintdat)->ipmax += 20;\n      \n      if (((*pintdat)->vpoint = increasearray((*pintdat)->vpoint,\n\t\t\t\t\t      (*pintdat)->ipmax,SISLIntpt *)) == SISL_NULL) \n\tgoto err101;\n    }\n  \n  \n  /* Now we can insert the new point. */\n  \n  (*pintdat)->vpoint[ki] = (*pintpt);\n  (*pintdat)->ipoint++;\n  *jstat = 0;\n  goto out;\n  \n\n/* Error in space allocation.  */\n\nerr101: *jstat = -101;\n        s6err(\"sh6idnpt\",*jstat,0);\n        goto out;\n\n out: ;\n}\n"
  },
  {
    "path": "src/sh6idnwun.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6idnwun.c,v 1.2 2001-03-19 15:59:08 afr Exp $\n *\n */\n\n\n#define SH6IDNEWUNITE\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6idnewunite (SISLObject *po1, SISLObject *po2, SISLIntdat ** intdat, \n\t       SISLIntpt ** pt1, SISLIntpt ** pt2, double weight, \n\t       double aepsge, int *jstat)\n#else\nvoid \nsh6idnewunite (po1, po2, intdat, pt1, pt2, weight, aepsge, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntdat **intdat;\n     SISLIntpt **pt1;\n     SISLIntpt **pt2;\n     double weight;\n     double aepsge;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given two Intpt, unite them to one by finding the\n*              weighted medium in the parameter values corresponding\n*              to one object, and iterate to the closest point in\n*              the other. If one of the objects is a point, no\n*              iteration is necessary.\n*\n*\n* INPUT      : po1      - First object in the intersection.\n*              po2      - Second object in the intersection.\n*              intdat\t- Pointer to intersection data.\n*\t       pt1\t- Pointer to the first Intpt.\n*\t       pt2\t- Pointer to the second Intpt.\n*\t       weight\t- Weight to middle parameter values. ((1-W)*p1+W*p2).\n*              aepsge   - Geometry tolerance. \n*\n*\n* OUTPUT     : pt1   \t- Pointer to joined Intpt.\n*\t       jstat   \t- Status value\n*\n*\n* METHOD     :\n*\n* CALLS      : sh6ptobj - Iterate to closest point in second object.\n*              s1221    - Curve evaluation.\n*              s1421    - Surface evaluation.\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Arne Laksaa, SI, Oslo, Norway. May 91.\n* CORRECTED BY: UJK, SI, Oslo, Norway. October 91.\n* RENAMED AND MODIFIED BY : Vibeke Skytt, SI, 92-11. Iterate in second\n*                                                    object.\n*********************************************************************\n*/\n{\n   int ki, kstat;\n   int kpar;           /* Number of parameter directions in 1. object. */\n   int kiterate;       /* Indicates if iteration is necessary.    */\n   int kleft1=0,kleft2=0; /* Parameters used in evaluation.       */\n   double spar[4];     /* Parameter values of intersection point. */\n   double start[2];    /* Start parameter value to iteration.     */\n   double spoint[3];   /* Position in curve or surface.           */\n   double snorm[3];    /* Dummy vector. Surface normal.           */\n   SISLIntpt *lpt;\n   SISLIntpt *lpt1;\n   SISLIntpt *lpt2;\n   \n   /* Test if one object is a point.  */\n   \n   if (po1->iobj == SISLPOINT || po2->iobj == SISLPOINT)\n   {\n      kpar = po1->iobj + po2->iobj;\n      kiterate = 0;\n   }\n   else\n   {\n      kpar = po1->iobj;\n      kiterate = 1;\n   }\n\n  sh6idnpt (intdat, pt1, 0, &kstat);\n  if (kstat < 0)\n    goto error;\n  sh6idnpt (intdat, pt2, 0, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  if (sh6ismain (*pt1))\n    {\n      lpt1 = (*pt1);\n      lpt2 = (*pt2);\n    }\n  else\n    {\n      lpt1 = (*pt2);\n      lpt2 = (*pt1);\n      weight = 1.0 - weight;\n    }\n\n  sh6disconnect (lpt1, lpt2, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* UJK, Oct. 91 */\n  /* for (ki=0;;ki++) */\n  for (ki = 0;;)\n    {\n      if ((lpt = sh6getnext (lpt2, ki)) == SISL_NULL)\n\tbreak;\n\n      sh6disconnect (lpt2, lpt, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n\n      sh6connect (lpt1, lpt, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  for (ki = 0; ki < kpar; ki++)\n    spar[ki] = lpt1->epar[ki] * (1.0 - weight) + lpt2->epar[ki] * weight;\n  \n  if (kiterate)\n  {\n     /* Compute start parameter to iteration.  */\n     \n     for (; ki < lpt1->ipar; ki++)\n\tstart[ki-kpar] = lpt1->epar[ki] * (1.0 - weight) + lpt2->epar[ki] * weight;\n\t\n     /* Iterate to closest point in second object. First evaluate\n\tvalue of intersection point in first object.  */\n     \n     if (po1->iobj == SISLCURVE)\n     {\n\ts1221(po1->c1,0,spar[0],&kleft1,spoint,&kstat);\n\tif (kstat < 0) goto error;\n     }\n     else\n     {\n\ts1421(po1->s1,0,spar,&kleft1,&kleft2,spoint,snorm,&kstat);\n\tif (kstat < 0) goto error;\n     }\n     \n     /* Iterate. */\n     \n     sh6ptobj(spoint,po2,aepsge,start,spar+kpar,&kstat);\n     if (kstat < 0) goto error;\n  }\n  \n  /* Copy new parameter values into intersection point. */\n  \n  memcopy(lpt1->epar,spar,lpt1->ipar,DOUBLE);\n     \n\n  sh6idkpt (intdat, &lpt2, 0, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  (*pt1) = lpt1;\n  (*pt2) = lpt2;\n\n  goto out;\n\nerror:\n  *jstat = kstat;\n  s6err (\"sh6idunite\", kstat, 0);\n  goto out;\nout:\n  ;\n}\n\n"
  },
  {
    "path": "src/sh6idput.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6idput.c,v 1.2 2001-03-19 16:06:03 afr Exp $\n *\n */\n\n\n#define SH6IDPUT\n\n#include \"sislP.h\"\n\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6idput (SISLObject * po1, SISLObject * po2,\n\t  SISLIntdat ** rintdat, SISLIntdat * pintdat,\n      int inr, double apar, SISLIntpt *** outintpt, int *npoint, int *jstat)\n#else\nvoid\nsh6idput (po1, po2, rintdat, pintdat, inr, apar, outintpt, npoint, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntdat **rintdat;\n     SISLIntdat *pintdat;\n     int inr;\n     double apar;\n     SISLIntpt ***outintpt;\n     int *npoint;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To insert all points in one intdat with one less number\n*              of parameters into rintdat. New copies is made with\n*              the missing parameter. Connections are kept.\n*              The geometry data of the object not enhanced, is kept.\n*\n*\n*\n* INPUT      : po1      - First object in the intersection.\n*              po2      - Second object in the intersection.\n*              pintdat  - Pointer to intersection data with one less\n*                         parameter than rintdat.\n*              inr      - Number of the parameter that is missing in pintdat.\n*              apar     - Parameter value of the missing parameter.\n*\n*\n* OUTPUT     : rintdat  - Pointer to a pointer to intersection data.\n*              outintpt - Help array containing pointers to the enhanced\n*                         points in rintdat.\n*              npoints -  Size of outinpt.\n*              jstat    - status messages\n*                               = 0      : Inserting done.\n*                               < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err        - Gives error message.\n*              sh6idnpt     - Insert a new intpt structure.\n*              sh6idfcross  - Fetch cross intersections.\n*              sh6idrmcross - Remove cross intersections.\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 06.91.\n* CHANGED BY : Vibeke Skytt, SI, 12.92.  Remove cross intersections in\n*                                        closed and degenerate coincidence.\n*********************************************************************\n*/\n{\n  int kstat=0;\t                /* Local status variable.               */\n  int kpos = 0;\t\t\t/* Position of error.                   */\n  int ki, kj, kr, kh, kh2, ka1, ka2, kb;  \t/* Counters             */\n  int keep_first;\t\t/* Flag, which object is not enhanced   */\n  int kant;\t\t\t/* Number of parameters in new points.  */\n  int ind1, ind2;\t        /* Indexes                              */\n  int no;\t\t\t/* No. of doubles to copy into geo_aux  */\n  double *scoef = SISL_NULL;\t\t/* Pointer to array copying into geo_aux*/\n  double *spar = SISL_NULL;\t\t/* Storing uppdated parametervalues.    */\n  SISLIntpt **uintpt = SISL_NULL;\t/* Help array while getting connections */\n  int iinter;\n  double *nullp = SISL_NULL;\n  int kx;\n  int log_1, log_2;                     /* Used to check curve_dir         */\n  double t1, t2, t3, t4;\n  SISLIntpt *prev, *curr;\n\n  /* VSK. Remove cross intersections. ----------------------------  */\n  int kcross = 1;     /* Indicates existence of cross intersections. */\n  int kncross = 0;    /* Number of cross intersections.              */\n  int kpt;            /* Index in uintpt.                            */\n  SISLIntpt *ucross[4];  /* Cross intersections.                     */\n\n  *npoint = 0;\n\n  /* Find out which object the parameter belongs to */\n  if (inr < po1->iobj)\n    keep_first = 0;\n  else\n    keep_first = 1;\n\n  /* Do we have an intdat structure? */\n  if (pintdat == SISL_NULL)\n    {\n      *jstat = 0;\n      goto out;\n    }\n\n  /* Computing number of new parameter direction. */\n  kant = pintdat->vpoint[0]->ipar + 1;\n\n\n  if (inr < 0 || inr >= kant)\n    goto err191;\n\n  *npoint = pintdat->ipoint;\n\n  /* Allocate an array for intersection points. */\n  if ((uintpt = newarray (pintdat->ipoint, SISLIntpt *)) == SISL_NULL)\n    goto err101;\n\n\n  /* Allocate an array for parametervalues. */\n  if ((spar = newarray (kant, double)) == SISL_NULL)\n    goto err101;\n\n\n  /* Enhance all intersection points. */\n  for (ki = 0; ki < pintdat->ipoint; ki++)\n    {\n      /* Insert the missing parameter value. */\n\n      for (kj = 0; kj < inr; kj++)\n\tspar[kj] = pintdat->vpoint[ki]->epar[kj];\n      spar[kj] = apar;\n      for (kj++; kj < kant; kj++)\n\tspar[kj] = pintdat->vpoint[ki]->epar[kj - 1];\n\n      iinter = pintdat->vpoint[ki]->iinter;\n\n      uintpt[ki] = hp_newIntpt (kant, spar, pintdat->vpoint[ki]->adist,\n\t\t\t\tiinter,\n\t\t\t\tpintdat->vpoint[ki]->left_obj_1[0],\n\t\t\t\tpintdat->vpoint[ki]->right_obj_1[0],\n\t\t\t\tpintdat->vpoint[ki]->left_obj_2[0],\n\t\t\t\tpintdat->vpoint[ki]->right_obj_2[0],\n\t\t\t     (keep_first ? pintdat->vpoint[ki]->size_1 : 0),\n\t\t\t     (keep_first ? 0 : pintdat->vpoint[ki]->size_2),\n\t\t     (keep_first ? pintdat->vpoint[ki]->geo_data_1 : nullp),\n\t\t    (keep_first ? nullp : pintdat->vpoint[ki]->geo_data_2));\n\n      if (uintpt[ki] == SISL_NULL)\n\tgoto err101;\n\n      /* Store info from lower level object */\n      if (keep_first)\n\t{\n\t  /* Store second object geometry in geo_aux */\n\t  no = pintdat->vpoint[ki]->size_2;\n\t  scoef = pintdat->vpoint[ki]->geo_data_2;\n\t}\n      else\n\t{\n\t  /* Store first object geometry in geo_aux */\n\t  no = pintdat->vpoint[ki]->size_1;\n\t  scoef = pintdat->vpoint[ki]->geo_data_1;\n\t}\n      /*      if (no > 0)\n        \tmemcopy (uintpt[ki]->geo_aux, scoef, (no < 6) ? no : 6, DOUBLE); */\n    }\n\n\n\n  /* Insert all new intersection points in rintdat. */\n  for (ki = 0; ki < (*npoint); ki++)\n    {\n      sh6idnpt (rintdat, &uintpt[ki], 1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  /* Transform the connections. */\n  for (ki = 0; ki < (*npoint); ki++)\n    {\n      for (kj = ki + 1; kj < (*npoint); kj++)\n\t{\n\t  sh6getlist (pintdat->vpoint[ki], pintdat->vpoint[kj],\n\t\t      &ind1, &ind2, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  kb = 2;\n\t  if (kstat == 0 && (uintpt[ki]->no_of_curves > 0 ||\n\t\t\t     uintpt[kj]->no_of_curves > 0))\n\t    {\n\t      /* Test curve direction */\n \t      log_1 = pintdat->vpoint[ki]->curve_dir[ind1];\n\t      log_1 = log_1>>1;\n\t      log_1 &= 15;\n\t      for (kb=0, ka1=ki, ka2=kj; kb<2; ++kb, ka1=kj, ka2=ki)\n\t\t{\n\t\t  for (kh=0; kh<uintpt[ka1]->no_of_curves; ++kh)\n\t\t    {\n\t\t      if (uintpt[ka1]->pnext[kh] == uintpt[ka2])\n\t\t\tcontinue;\n\t\t      log_2 = uintpt[ka1]->curve_dir[kh];\n\t\t      log_2 = log_2 >> 1;\n\t\t      log_2 &= 15;\n\t\t      if (log_1 & log_2)\n\t\t\t{\n\t\t\t  /* Test equality */\n\t\t\t  for (kr=0, kx=-1; kr<uintpt[ka1]->ipar; ++kr)\n\t\t\t    if (DNEQUAL(uintpt[ka1]->epar[kr], uintpt[ka2]->epar[kr]))\n\t\t\t      {\n\t\t\t\tkx = kr;\n\t\t\t\tbreak;\n\t\t\t      }\n\n\t\t\t  if (kx >= 0)\n\t\t\t    {\n\t\t\t      /* Check if the two points are connected in a chain,\n\t\t\t\t or the new point(s) lies between two previous ones */\n\t\t\t      t1 = pintdat->vpoint[ka1]->epar[kx];\n\t\t\t      t2 = pintdat->vpoint[ka2]->epar[kx];\n\t\t\t      t3 = uintpt[ka1]->pnext[kh]->epar[kx];\n\t\t\t      if (fabs(t3-t1) > fabs(t2-t1) &&\n\t\t\t\t  (t3 - t1)*(t2 - t1) > 0.0)\n\t\t\t\t{\n\t\t\t\t  /* place uintpt[ka2] in the link between\n\t\t\t\t     uintpt[ka1] and uintpt[ka1]->pnext[kh] */\n\t\t\t\t  sh6insertpt(uintpt[ka1], uintpt[ka1]->pnext[kh],\n\t\t\t\t\t      uintpt[ka2], &kstat);\n\t\t\t\t  if (kstat < 0)\n\t\t\t\t    goto error;\n\t\t\t\t  break;\n\t\t\t\t}\n\t\t\t      else if (fabs(t3-t1) < fabs(t2-t1) &&\n\t\t\t\t       (t3 - t1)*(t2 - t1) > 0.0)\n\t\t\t\t{\n\t\t\t\t  /* Follow the list of isocurve points until \n\t\t\t\t     uintpt[ka2] or the last point before it */\n\t\t\t\t  prev = uintpt[ka1];\n\t\t\t\t  curr = uintpt[ka1]->pnext[kh];\n\n\t\t\t\t  for (kh2=0; kh2<curr->no_of_curves; ++kh2)\n\t\t\t\t    {\n\t\t\t\t      if (curr->pnext[kh2] == prev)\n\t\t\t\t\tcontinue;\n\t\t\t\t      log_2 = curr->curve_dir[kh];\n\t\t\t\t      log_2 = log_2 >> 1;\n\t\t\t\t      log_2 &= 15;\n\t\t\t\t      if (!(log_1 & log_2))\n\t\t\t\t\tcontinue;\n\t\t\t\t      t4 = curr->pnext[kh2]->epar[kx];\n\t\t\t\t      prev = curr;\n\t\t\t\t      curr = curr->pnext[kh2];\n\t\t\t\t      if (fabs(t4-t1) >= fabs(t2-t1))\n\t\t\t\t\tbreak;\n\t\t\t\t    }\n\t\t\t\t  t3 = curr->epar[kx];\n\t\t\t\t  if (curr == uintpt[ka2])\n\t\t\t\t    {\n\t\t\t\t      /* Do nothing, connection already established */\n\t\t\t\t      ;\n\t\t\t\t    }\n\t\t\t\t  else if (fabs(t3-t1) > fabs(t2-t1))\n\t\t\t\t    {\n\t\t\t\t      sh6insertpt(uintpt[ka1], uintpt[ka1]->pnext[kh],\n\t\t\t\t\t\t  uintpt[ka2], &kstat);\n\t\t\t\t      if (kstat < 0)\n\t\t\t\t\tgoto error;\n\t\t\t\t    }\n\t\t\t\t  else\n\t\t\t\t    {\n\t\t\t\t      sh6idcon (rintdat, &curr, &uintpt[ka2], &kstat);\n\t\t\t\t      if (kstat < 0)\n\t\t\t\t\tgoto error;\n\t\t\t\t    }\n\t\t\t\t  break;\n\t\t\t\t}\n\t\t\t      /* printf(\"Here we are \\n\"); */\n\t\t\t    }\n\t\t\t}\n\t\t    }\n\t\t  if (kh < uintpt[ka1]->no_of_curves)\n\t\t    break;\n\t\t}\n\t    }\n\n\t  if (kstat == 0 && kb == 2)\n\t    {\n\t      sh6idcon (rintdat, &uintpt[ki], &uintpt[kj], &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t    }\n\t}\n\n      if (sh6ismain (pintdat->vpoint[ki]) &&\n\t  sh6nmbmain (pintdat->vpoint[ki], &kstat))\n\t{\n\t  sh6tomain (uintpt[ki], &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n    }\n  \n  if (po1->iobj > SISLPOINT && po2->iobj > SISLPOINT)\n  {\n     /* There is a possibility for cross intersections. Check the\n\tintersection data.  */\n     \n     kpt = 0;\n     while (kpt < (*npoint))\n     {\n\tkncross = 0;\n\tucross[kncross] = uintpt[kpt];\n\tkncross = 1;\n\t\n\t/* Fetch cross intersections.  */\n\t\n\tsh6idfcross(*rintdat,ucross,&kncross,po1->iobj,po2->iobj,&kstat);\n\tkcross = kstat;\n\t\n\tif (kcross)\n\t{\n\t   /* Remove cross intersections. */\n\t   \n\t   sh6idrmcross(po1, po2, rintdat, ucross, kncross, uintpt, \n\t\t\t*npoint, &kstat);\n\t   if (kstat < 0) goto error;\n\t   \n\t   if (kstat)\n\t   {\n\t      /* Points have been removed. Update uintpt.  */\n\t      \n\t      for (kj=0; kj<*npoint; kj++)\n\t\t if (uintpt[kj] == SISL_NULL)\n\t\t {\n\t\t    uintpt[kj] = uintpt[(*npoint)-1];\n\t\t    kj--;\n\t\t    (*npoint)--;\n\t\t }\n\t   }\n\t   else kpt++;\n\t}\n\telse kpt++;\n     }\n  }\n     \n  *jstat = 0;\n  goto out;\n\n\n/* Error in inserted parameter number.  */\n\nerr191:*jstat = -191;\n  s6err (\"sh6idput\", *jstat, kpos);\n  goto out;\n\n\n/* Error in space allocation.  */\n\nerr101:*jstat = -101;\n  s6err (\"sh6idput\", *jstat, kpos);\n  goto out;\n\n/* Error in sub function.  */\n\nerror:*jstat = kstat;\n  s6err (\"sh6idput\", *jstat, kpos);\n  goto out;\n\nout:*outintpt = uintpt;\n  if (spar != SISL_NULL)\n    freearray (spar);\n}\n\n"
  },
  {
    "path": "src/sh6idrcros.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6idrcros.c,v 1.4 2001-03-19 16:06:03 afr Exp $\n *\n */\n\n\n#define SH6IDRMCROSS\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      sh6idrmcross(SISLObject *po1, SISLObject *po2, SISLIntdat **pintdat,\n\t\t   SISLIntpt *vcross[], int incross, SISLIntpt *vpt[],\n\t\t   int inpt, int *jstat)\n#else\nvoid sh6idrmcross(po1, po2, pintdat, vcross, incross, vpt, inpt,jstat)\n   SISLObject *po1;\n   SISLObject *po2;\n   SISLIntdat **pintdat;\n   SISLIntpt  *vcross[];\n   int        incross;\n   SISLIntpt  *vpt[];\n   int        inpt;\n   int        *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given an array of 4 cross intersection. These are\n*              found by sh6idfcross. Check if the\n*              intersections may be divided into two pairs where\n*              the second pair consists of the cross intersections\n*              of the first pair. In that case remove the cross\n*              intersections.\n*\n*\n* INPUT      : po1      - First object in the intersection.\n*              po2      - Second object in the intersection.\n*              pintdat  - Intersection data.\n*              vcross   - Array of cross intersection point.\n*              incross  - Number of points in vcross. incross = 4.\n*              vpt      - Array of pointers into pintdat.\n*              inpt     - Number of points in vpt.\n*\n* OUTPUT     : pintdat  - Updated intersection data.\n*              vpt      - Updated array.\n*              jstat    - Status\n*                         jstat = 0   => No intersection points removed.\n*                         jstat = 1   => Cross intersections removed.\n*                         jstat < 0   => Error.\n*\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*\n* CALLS      : s1221, s1424, s6degnorm, s6scpr, s6length, sh6idkpt.\n*\n*\n* WRITTEN BY : Vibeke Skytt, SI, 12.92.\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, Sept. 1994. Init of\n*              kleft1 and kleft2.\n*\n*********************************************************************\n*/\n{\n   int kstat;          /* Status variable.                          */\n   int ki,kj,kl;       /* Counters.                                 */\n   int kdim;           /* Dimension of geometry space.              */\n   int kleft1 = 0;     /* Parameters used in evaluator.             */\n   int kleft2 = 0;\n   int kdir1,kdir2;    /* Parameter directions.                     */\n   int kpar;           /* Number of parameter directions.           */\n   int k1par = po1->iobj; /* Number of par. dir. in first object.   */\n   int kmin;           /* Number of minimum parameter point.        */\n   double tmin;        /* Length of minimum parameter point as vector. */\n   double thelp;       /* Help parameter. Length of vector.         */\n   double sder1[27];   /* Position, derivative etc. of object 1.    */\n   double sder2[27];   /* Position, derivative etc. of object 2.    */\n   double stang1[3];   /* Tangent in first parameter dir., deg. surf. */\n   double stang2[3];   /* Tangent in second parameter dir., deg. surf. */\n   double snorm[3];    /* Normal of degenerated surface.            */\n\n   *jstat = 0;\n\n   /* Test input.  */\n\n   if (incross != 4) goto err138;\n\n   if (po1->iobj == SISLPOINT || po2->iobj == SISLPOINT)\n   {\n      *jstat = 0;\n      goto out;\n   }\n\n   if (po1->iobj == SISLSURFACE)\n   {\n      /* Check if the intersection points have got one parameter in\n\t common.      */\n\n      for (kj=0; kj<2; kj++)\n      {\n\t for (ki=1; ki<incross; ki++)\n\t    if (DNEQUAL(vcross[ki]->epar[kj],vcross[0]->epar[kj])) break;\n\t if (ki == incross) break;  /* Common parameter direction.  */\n      }\n\n      if (kj == 2)\n      {\n\t /* No common parameter direction, i.e. no cross intersection\n\t    to remove.  */\n\n\t *jstat = 0;\n\t goto out;\n      }\n\n      /* Set the parameter direction that is not constant.  */\n\n      kdir1 = 1 - kj;\n   }\n\n   if (po2->iobj == SISLSURFACE)\n   {\n      /* Check if the intersection points have got one parameter in\n\t common.      */\n\n      for (kj=po1->iobj, kpar=vcross[0]->ipar; kj<kpar; kj++)\n      {\n\t for (ki=1; ki<incross; ki++)\n\t    if (DNEQUAL(vcross[ki]->epar[kj],vcross[0]->epar[kj])) break;\n\t if (ki == incross) break;  /* Common parameter direction.  */\n      }\n\n      if (kj == kpar)\n      {\n\t /* No common parameter direction, i.e. no cross intersection\n\t    to remove.  */\n\n\t *jstat = 0;\n\t goto out;\n      }\n\n      /* Set the parameter direction that is not constant.  */\n\n      kdir2 = kpar - 1 - kj;\n   }\n\n   /* Find the minimum parameter point in which to evaluate. */\n\n   kmin = 0;\n   tmin = s6length(vcross[0]->epar,vcross[0]->ipar,&kstat);\n\n   for (kj=1; kj<incross; kj++)\n   {\n      thelp = s6length(vcross[kj]->epar,vcross[kj]->ipar,&kstat);\n      if (thelp < tmin)\n      {\n\t tmin = thelp;\n\t kmin = kj;\n      }\n   }\n\n   /* Compute derivatives.  */\n\n   if (po1->iobj == SISLCURVE)\n   {\n      kdir1 = 0;\n      kdim = po1->c1->idim;\n      s1221(po1->c1,1,vcross[kmin]->epar[kdir1],&kleft1,sder1,&kstat);\n      if (kstat < 0) goto error;\n   }\n   else if (po1->iobj == SISLSURFACE)\n   {\n      kdim = po1->s1->idim;\n      s1424(po1->s1,2,2,vcross[kmin]->epar,&kleft1,&kleft2,sder1,\n\t    &kstat);\n      if (kstat < 0) goto error;\n      s6crss(sder1+kdim, sder1+2*kdim, snorm);\n\n      /* Check if the surface is degenerated in the wanted parameter\n\t direction.   */\n\n      if (s6length(sder1+(1+kdir1)*kdim,kdim,&kstat) <= REL_COMP_RES)\n      {\n\t /* Compute partial derivatives as a limit.  */\n\n\t s6degnorm(po1->s1,2,vcross[kmin]->epar,sder1,stang1,stang2,\n\t\t   snorm,&kstat);\n\t if (kstat < 0) goto error;\n\n\t memcopy(sder1+kdim,stang1,kdim,DOUBLE);\n\t memcopy(sder1+2*kdim,stang2,kdim,DOUBLE);\n      }\n   }\n\n   /* Compute derivatives.  */\n\n   if (po2->iobj == SISLCURVE)\n   {\n      kdir2 = 0;\n      s1221(po2->c1,1,vcross[kmin]->epar[k1par+kdir2],&kleft1,sder2,&kstat);\n      if (kstat < 0) goto error;\n   }\n   else if (po2->iobj == SISLSURFACE)\n   {\n      s1424(po2->s1,2,2,vcross[kmin]->epar+k1par,&kleft1,&kleft2,sder2,\n\t    &kstat);\n      if (kstat < 0) goto error;\n      s6crss(sder2+kdim, sder2+2*kdim, snorm);\n\n      /* Check if the surface is degenerated in the wanted parameter\n\t direction.   */\n\n      if (s6length(sder2+(1+kdir2)*kdim,kdim,&kstat) <= REL_COMP_RES)\n      {\n\t /* Compute partial derivatives as a limit.  */\n\n\t s6degnorm(po2->s1,2,vcross[kmin]->epar+k1par,sder2,stang1,stang2,\n\t\t   snorm,&kstat);\n\t if (kstat < 0) goto error;\n\n\t memcopy(sder2+kdim,stang1,kdim,DOUBLE);\n\t memcopy(sder2+2*kdim,stang2,kdim,DOUBLE);\n      }\n   }\n\n   if (s6ang(sder1+(kdir1+1)*kdim,sder2+(kdir2+1)*kdim,kdim) > ANGULAR_TOLERANCE\n       && !(s6length(sder1+(kdir1+1)*kdim,kdim,&kstat) < REL_COMP_RES &&\n\t    s6length(sder2+(kdir2+1)*kdim,kdim,&kstat) < REL_COMP_RES))\n   {\n      *jstat = 0;\n      goto out;\n   }\n\n   /* Check if the parameter directions of the objects are the same.  */\n\n   if (s6scpr(sder1+(kdir1+1)*kdim,sder2+(kdir2+1)*kdim,kdim) >= 0)\n   {\n      /* Remove the pair of intersection point that do not have the\n\t same \"parameter direction\" in both objects.  */\n\n      for (ki=0; ki<incross; ki++)\n\t{\n\t  for (kj=1; kj<incross; kj++)\n\t    {\n\t      if (DNEQUAL(vcross[ki]->epar[kdir1],vcross[kj]->epar[kdir1]) &&\n\t\t  DNEQUAL(vcross[ki]->epar[k1par+kdir2],\n\t\t\t  vcross[kj]->epar[k1par+kdir2]))\n\t\t{\n\t\t  /* A pair is found. Check if the pair should be removed. */\n\n\t\t  if ((vcross[ki]->epar[kdir1] - vcross[kj]->epar[kdir1]) *\n\t\t      (vcross[ki]->epar[k1par+kdir2] -\n\t\t       vcross[kj]->epar[k1par+kdir2]) < 0)\n\t\t    {\n\t\t      /* Remove the points. First make sure that vpt will\n\t\t\t not point to killed points.  */\n\n\t\t      for (kl=0; kl<inpt; kl++)\n\t\t\tif (vpt[kl] == vcross[ki] || vpt[kl] == vcross[kj])\n\t\t\t  vpt[kl] = SISL_NULL;\n\n\t\t      sh6idkpt(pintdat,&vcross[ki],1,&kstat);\n\t\t      if (kstat < 0) goto error;\n\n\t\t      sh6idkpt(pintdat,&vcross[kj],1,&kstat);\n\t\t      if (kstat < 0) goto error;\n\n\t\t      *jstat = 1;\n\t\t      break;\n\t\t    }\n\t\t}\n\t    }\n\t  if (kj < incross)\n\t    break;           /* The cross intersection is removed */\n\t}\n\n      if (*jstat == 1) goto out;  /* Points removed.  */\n   }\n   else\n   {\n      /* Remove the pair of intersection point that have the\n\t same \"parameter direction\" in both objects.  */\n\n      for (ki=0; ki<incross; ki++)\n\t{\n\t  for (kj=1; kj<incross; kj++)\n\t    {\n\t      if (DNEQUAL(vcross[ki]->epar[kdir1],vcross[kj]->epar[kdir1]) &&\n\t\t  DNEQUAL(vcross[ki]->epar[k1par+kdir2],\n\t\t\t  vcross[kj]->epar[k1par+kdir2]))\n\t\t{\n\t\t  /* A pair is found. Check if the pair should be removed. */\n\n\t\t  if ((vcross[ki]->epar[kdir1] - vcross[kj]->epar[kdir1]) *\n\t\t      (vcross[ki]->epar[k1par+kdir2] -\n\t\t       vcross[kj]->epar[k1par+kdir2]) > 0)\n\t\t    {\n\t\t      /* Remove the points. First make sure that vpt will\n\t\t\t not point to killed points. */\n\n\t\t      for (kl=0; kl<inpt; kl++)\n\t\t\tif (vpt[kl] == vcross[ki] || vpt[kl] == vcross[kj])\n\t\t\t  vpt[kl] = SISL_NULL;\n\n\t\t      sh6idkpt(pintdat,&vcross[ki],1,&kstat);\n\t\t      if (kstat < 0) goto error;\n\n\t\t      sh6idkpt(pintdat,&vcross[kj],1,&kstat);\n\t\t      if (kstat < 0) goto error;\n\n\t\t      *jstat = 1;\n\t\t      break;\n\t\t    }\n\t\t}\n\t    }\n\t  if (kj < incross)\n\t    break;           /* The cross intersection is removed */\n\t }\n\n      if (*jstat == 1) goto out;  /* Points removed.  */\n   }\n\n      /* No points are removed. Set status.  */\n\n      *jstat = 0;\n      goto out;\n\n\n   /* Wrong number of intersection points.  */\n\n   err138 : *jstat = -138;\n   goto out;\n\n   /* Error in lower level routine.  */\n\n   error : *jstat = kstat;\n   goto out;\n\n   out :\n      return;\n}\n"
  },
  {
    "path": "src/sh6idsplit.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6idsplit.c,v 1.2 2001-03-19 16:06:03 afr Exp $\n *\n */\n\n\n#define S6IDSPLIT\n\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n    sh6idsplit (SISLIntdat ** pintdat, SISLIntpt * psource, int *jstat)\n#else\nvoid\n   sh6idsplit (pintdat, psource, jstat)\n     SISLIntdat **pintdat;\n     SISLIntpt *psource;\n     int *jstat;\n#endif\n\n\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To split an intersection point into several instanses so\n*              that the each of the instances has exactly one (main) neighbour.\n*              \n*\n*\n* INPUT:       psource  - Pointer to an intersection point.\n* \n* \n* INPUT/OUTPUT:pintdat  - Pointer to a pointer to intersection data.\n*\n*\n* OUTPUT  :    jstat    - status messages\n*                               = 0      : OK\n*                               < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*   \n*\n* WRITTEN BY : Ulf J. Krystad, 04.92.\n*\n*********************************************************************\n*/\n{\n  int ki;\t\t\t/* Counters.                         */\n  int no_main;\t\t\t/* No of neighbours (main points)    */\n  int test= FALSE;              /* No equality testing when inserted\n\t\t\t\t   in pintdat                        */\n  int kstat = 0;                /* Local status.                     */\n  SISLIntpt *pneighb = SISL_NULL;\t/* Current neighbour                 */\n  SISLIntpt *pshadow = SISL_NULL;\t/* Current copy of source point      */\n  /* ------------------------------------------------*/\n  \n  *jstat = 0;\n  \n  if (psource == SISL_NULL)\n    {\n       *jstat = 1;\n       goto out;\n    }\n  \n  /* Get number of neighbours */\n  no_main = sh6nmbmain (psource, &kstat);\n  if (kstat < 0)\n    goto error;\n  \n  for (ki=psource->no_of_curves - 1; no_main > 1; ki--)\n    {\n       pneighb = sh6getnext(psource, ki);\n       if (!pneighb) goto error;\n       if (sh6ismain(pneighb))\n\t {\n\t    pshadow = hp_copyIntpt(psource);\n\t    sh6idnpt(pintdat, &pshadow, test=FALSE, &kstat);\n\t    if (kstat < 0) goto error;\n\t    \n\t    sh6insertpt(psource, pneighb, pshadow, &kstat);\n\t    if (kstat < 0) goto error;\n\t    \n\t    sh6disconnect(psource, pshadow, &kstat);\n\t    if (kstat < 0) goto error;\n\t    no_main--;\n\t }\n    }\n  goto out;\n  \n  \nerror:\n  *jstat = kstat;\n  goto out;\n\nout:;\n}\n"
  },
  {
    "path": "src/sh6idunite.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6idunite.c,v 1.2 2001-03-19 16:06:03 afr Exp $\n *\n */\n\n\n#define SH6IDUNITE\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6idunite (SISLIntdat ** intdat, SISLIntpt ** pt1, SISLIntpt ** pt2,\n\t    double weight, int *jstat)\n#else\nvoid \nsh6idunite (intdat, pt1, pt2, weight, jstat)\n     SISLIntdat **intdat;\n     SISLIntpt **pt1;\n     SISLIntpt **pt2;\n     double weight;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given two Intpt, unite them to one.\n*\n*\n* INPUT      : intdat\t- Pointer to intersection data.\n*\t       pt1\t- Pointer to the first Intpt.\n*\t       pt2\t- Pointer to the second Intpt.\n*\t       weight\t- Weight to middle parameter values. ((1-W)*p1+W*p2).\n*\n*\n* OUTPUT     : pt1   \t- Pointer to joined Intpt.\n*\t       jstat   \t- Status value\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Arne Laksaa, SI, Oslo, Norway. May 91.\n* CORRECTED BY: UJK, SI, Oslo, Norway. October 91.\n*********************************************************************\n*/\n{\n  int ki, kstat;\n  SISLIntpt *lpt;\n  SISLIntpt *lpt1;\n  SISLIntpt *lpt2;\n\n  sh6idnpt (intdat, pt1, 0, &kstat);\n  if (kstat < 0)\n    goto error;\n  sh6idnpt (intdat, pt2, 0, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  if (sh6ismain (*pt1))\n    {\n      lpt1 = (*pt1);\n      lpt2 = (*pt2);\n    }\n  else\n    {\n      lpt1 = (*pt2);\n      lpt2 = (*pt1);\n      weight = 1.0 - weight;\n    }\n\n  sh6disconnect (lpt1, lpt2, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  /* UJK, Oct. 91 */\n  /* for (ki=0;;ki++) */\n  for (ki = 0;;)\n    {\n      if ((lpt = sh6getnext (lpt2, ki)) == SISL_NULL)\n\tbreak;\n\n      sh6disconnect (lpt2, lpt, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n\n      sh6connect (lpt1, lpt, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  for (ki = 0; ki < lpt1->ipar; ki++)\n    lpt1->epar[ki] = lpt1->epar[ki] * (1.0 - weight) + lpt2->epar[ki] * weight;\n\n  sh6idkpt (intdat, &lpt2, 0, &kstat);\n  if (kstat < 0)\n    goto error;\n\n  (*pt1) = lpt1;\n  (*pt2) = lpt2;\n\n  goto out;\n\nerror:\n  *jstat = kstat;\n  s6err (\"sh6idunite\", kstat, 0);\n  goto out;\nout:\n  ;\n}\n\n"
  },
  {
    "path": "src/sh6insert.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6insert.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define SH6INSERT\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n      sh6insert(SISLIntdat **pintdat,SISLIntpt *pt1,SISLIntpt *pt2,SISLIntpt **ptnew,int *jstat)\n#else\nvoid sh6insert(pintdat,pt1,pt2,ptnew,jstat)\n   SISLIntdat **pintdat;\n   SISLIntpt *pt1;\n   SISLIntpt *pt2;\n   SISLIntpt **ptnew;\n   int       *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Place a new intersection point between two (connected)\n*              points. \n*              NOTE that if there exists a point in pintdat which is\n*              close to ptnew, then the input point is killed and\n*              no insertion is done.\n*              pt1 and pt2 must lie contiguously in a list.\n*\n* INPUT      : pintdat  - Pointer to pointer to the SISLIntdat data.\n*              pt1      - First point.\n*              pt2      - Second point.\n*              ptnew    - Point to be placed between pt1 and pt2.\n*              jstat    - Error flag.\n*                         jstat =  1  => Warning, point existing in\n*                                        pintdat, nothing done.\n*                         jstat =  0  => successful\n*                         jstat = -1  => pt1 and pt2 are not connected\n*                         jstat = -2  => error in space allocation\n*                         jstat <  0  => error in lower level routine\n*\n*\n* METHOD     : \n*\n* CALLS      : s6err      - Gives error message.\n*              sh6idnpt    - Insert a new intpt structure.\n*              copyIntpt  - Copy an intpt structure.\n*              newIntdat  - Create new intdat structure.\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n* MODYFIED BY: UJK, SI, Oslo, Norway. September 91.\n*********************************************************************\n*/\n{\n  int kstat;                /* Local status variable.                     */\n  \n   *jstat = 0;\n  \n  /* First we have to be sure that pintdat contains ptnew. */\n  \n  sh6idnpt(pintdat,ptnew,1,&kstat);\n  if (kstat < 0) goto error;\n  if (kstat > 0) \n    { \n       /* Point already existing in data structure, point killed, \n\t  no insertion */\n       *jstat = 1;\n       goto out;\n    }\n  \n  /* UJK, aug. 92 insert always mainpts if one of the neighbour is a main */\n  /* if (sh6ismain(pt1) && sh6ismain(pt2)) */\n   if (sh6ismain(pt1) || sh6ismain(pt2))\n     sh6tomain(*ptnew,&kstat);\n  else\n     sh6tohelp(*ptnew,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Then insert the point. */\n  sh6insertpt(pt1,pt2,*ptnew,&kstat);\n  if (kstat < 0) goto error;\n  \n  \n  goto out;\n  \n\n/* Error. pt1 and pt2 are not properly connected.  */\n\n\n/* Error in sub function.  */\n\nerror:  *jstat = kstat;\n        s6err(\"sh6insert\",*jstat,0);\n        goto out;\n\n   out:\n      return;\n}\n"
  },
  {
    "path": "src/sh6inspnt.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6inspnt.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define SH6INSERTPT\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6insertpt (SISLIntpt * pt1, SISLIntpt * pt2, SISLIntpt * ptnew, int *jstat)\n#else\nvoid \nsh6insertpt (pt1, pt2, ptnew, jstat)\n     SISLIntpt *pt1;\n     SISLIntpt *pt2;\n     SISLIntpt *ptnew;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Place a new intersection point between two (connected)\n*              points.\n*              pt1 and pt2 must be linked.\n*\n* INPUT      : pt1      - First point.\n*              pt2      - Second point.\n*              ptnew    - Point to be placed between pt1 and pt2.\n*              jstat    - Error flag.\n*                         jstat =  0  => successful\n*                         jstat = -1  => pt1 and pt2 are not connected\n*                         jstat <  0  => error in lower level routine\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n*              UJK, Connect before disconnect, to\n*              keep the index order\n*********************************************************************\n*/\n{\n  int kstat;\t\t\t/* Local status variable.                  */\n  int index1=0,index2=0;\n  int crv_dir1=0,crv_dir2=0;\n  \n  *jstat = 0;\n\n  sh6getlist (pt1, pt2, &index1, &index2, &kstat);\n  if (kstat < 0)\n    goto error;\t\t\t/* Error. */\n  if (kstat == 1)\n    goto err1;\t\t\t/* pt1 and pt2 are not linked. */\n\n  /* Save info in curve_dir */\n  crv_dir1 = pt1->curve_dir[index1];\n  crv_dir2 = pt2->curve_dir[index2];\n\n\n  /* Check pt1,pt2,ptnew. */\n\n  sh6connect (pt1, ptnew, &kstat);\n  if (kstat < 0)\n    goto error;\t\t\t/* Error. */\n\n  /* Set values in curve_dir */\n  sh6getlist (pt1, ptnew, &index1, &index2, &kstat);\n  pt1->curve_dir[index1]   = crv_dir1;\n  ptnew->curve_dir[index2] = crv_dir2;\n\n  sh6connect (pt2, ptnew, &kstat);\n  if (kstat < 0)\n    goto error;\t\t\t/* Error. */\n\n  /* Set values in curve_dir */\n  sh6getlist (pt2, ptnew, &index1, &index2, &kstat);\n  pt2->curve_dir[index1] = crv_dir2;\n  ptnew->curve_dir[index2] = crv_dir1;\n\n\n  sh6disconnect (pt1, pt2, &kstat);\n  if (kstat < 0)\n    goto error;\t\t\t/* Error. */\n  if (kstat == 1)\n    goto err1;\t\t\t/* pt1 and pt2 are not linked. */\n\n\n  goto out;\n\n\n/* Error. pt1 and pt2 are not linked.  */\n\nerr1:*jstat = -1;\n  s6err (\"sh6insertpt\", *jstat, 0);\n  goto out;\n\n/* Error in sub function.  */\n\nerror:*jstat = kstat;\n  s6err (\"sh6insertpt\", *jstat, 0);\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/sh6iscnect.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6iscnect.c,v 1.2 2001-03-19 16:06:03 afr Exp $\n *\n */\n\n\n#define SH6ISCONNECT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nint \n      sh6isconnect(SISLIntpt *pt0, SISLIntpt *pt1, SISLIntpt *pt2)\n#else\nint sh6isconnect(pt0, pt1, pt2)\n    SISLIntpt *pt0;\n    SISLIntpt *pt1;\n    SISLIntpt *pt2;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Boolean. Test if there exist a connection between\n*              the two intersection points pt1 and pt2.\n*\n*\n* INPUT      : pt0       - Pointer to previous Intpt, possibly SISL_NULL.\n*              pt1       - Pointer to first Intpt.\n*              pt2       - Pointer to second Intpt.\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 93-02.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;   /* Status on wether a connection is found.  */\n   int ki;          /* Counter.                                 */\n   SISLIntpt *qt;   /* Intersection point.                      */\n   int been_here = -199;\n\n   /* Test if the points are equal.  */\n\n   if (pt1 == pt2) return 1;\n   \n   /* UJK, aug 93, oo-loop in sh6isconn. */\n   if (pt1->marker == been_here) return 0;\n   pt1->marker = been_here;\n\n   /* Traverse the intersection points connected to pt1.  */\n   \n   for (ki=0; ki<pt1->no_of_curves; ki++)\n   {\n      qt = sh6getnext(pt1,ki);\n      if (qt == pt0) continue;\n      \n      kstat = sh6isconnect(pt1,qt,pt2);\n      \n      if (kstat) return 1;\n   }\n   \n   /* No connection is found.  */\n   \n   return 0;\n}\n"
  },
  {
    "path": "src/sh6ishelp.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6ishelp.c,v 1.2 2001-03-19 16:06:03 afr Exp $\n *\n */\n\n\n#define SH6ISHELP\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nint \n      sh6ishelp(SISLIntpt *pt)\n#else\nint sh6ishelp(pt)\n    SISLIntpt *pt;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Boolean. Is pt a help point?\n*\n*\n* INPUT      : pt       - Pointer to the Intpt.\n*\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n*\n*********************************************************************\n*/\n{\n   int flag = 0;\n\n   if(pt != SISL_NULL && pt->iinter < 0) flag = 1;\n\n\n   goto out;\n   \n\n   \n   out :\n      return flag;\n}\n\n\n\n\n\n\n"
  },
  {
    "path": "src/sh6isinsid.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6isinsid.c,v 1.2 2001-03-19 16:06:03 afr Exp $\n *\n */\n\n\n#define SH6ISINSIDE\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6isinside (SISLObject * po1, SISLObject * po2, SISLIntpt *intpt, int *jstat)\n#else\nvoid\nsh6isinside (po1, po2, intpt, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntpt *intpt;\n     int *jstat;\n#endif\n\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Test if an intersection point is inside the parametric space\n*\t\tof the objects.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              intpt    - Intersection point.\n*\n*\n* OUTPUT     : jstat    - status messages\n*                        < 0  : Error.\n*\t\t\t   0  : outside (UJK:at least one?) all objects\n*\t\t\t   1  : in the inner of all objects\n*\t\t\t   2  : on at least one edge/end of the objects\n*\t\t\t   3  : on one corner of one objects\n*\t\t\t   4  : on one corner of each objects\n*                          5  : on one edge/end of both objects\n*                               (not corner)\n*\n*\n* METHOD     :\n*\n* CALLS      :\n*\n* REFERENCES :\n*\n* WRITTEN BY : Arne Laksaa, SI, Oslo, sep. -91.\n* CORRECTED BY: UJK\n* REVISED BY : ALA and VSK, 09.92.  Introduced output status *jstat = 5.\n*********************************************************************\n*/\n{\n double minpar[4];\n double maxpar[4];\n int nrpar;\n int i;\n int is_inside = 1;\n int on_edge = 0;\n\n   \n if (intpt != SISL_NULL)\n {\n    /* Making the parametric boarders */\n \n    if (po1->iobj == SISLSURFACE)\n    {\n       nrpar = 2;\n\n       minpar[0] = po1->s1->et1[po1->s1->ik1-1];\n       minpar[1] = po1->s1->et2[po1->s1->ik2-1];\n       maxpar[0] = po1->s1->et1[po1->s1->in1];\n       maxpar[1] = po1->s1->et2[po1->s1->in2];\n    }\n    else if (po1->iobj == SISLCURVE)\n    {\n       nrpar = 1;\n\n       minpar[0] = po1->c1->et[po1->c1->ik-1];\n       maxpar[0] = po1->c1->et[po1->c1->in];\n    }\n    else    /* SISLPOINT */\n       nrpar = 0;\n\n    if (po2->iobj == SISLSURFACE)\n    {\n       minpar[nrpar]   = po2->s1->et1[po2->s1->ik1-1];\n       minpar[nrpar+1] = po2->s1->et2[po2->s1->ik2-1];\n       maxpar[nrpar]   = po2->s1->et1[po2->s1->in1];\n       maxpar[nrpar+1] = po2->s1->et2[po2->s1->in2];\n       nrpar += 2;\n    }\n    else if (po2->iobj == SISLCURVE)\n    {\n       minpar[nrpar] = po2->c1->et[po2->c1->ik-1];\n       maxpar[nrpar] = po2->c1->et[po2->c1->in];\n       nrpar++;\n    }\n    /*else    SISLPOINT */\n    \n    if (nrpar != intpt->ipar) goto err106;\n\n    /* Testing. */\n    \n    for (i = 0; (i < nrpar) && is_inside; i++)\n    {\n       if ((intpt->epar[i] <= maxpar[i] + REL_PAR_RES || \n\t    DEQUAL(intpt->epar[i], maxpar[i])) &&\n\t    (intpt->epar[i] >= minpar[i] - REL_PAR_RES ||\n\t     DEQUAL(intpt->epar[i], minpar[i])))\n\t{\n\t   /* Int point is inside. */\n\t   \n\t   if (intpt->epar[i] >= maxpar[i] - REL_PAR_RES)\n\t      on_edge +=  (1 << (2*i));\t/* On edge/end */\n\t   if (intpt->epar[i] <= minpar[i] + REL_PAR_RES)\n\t      on_edge +=  (1 << (2*i+1));\t/* On edge/end */\n\t   \n\t}\n\telse  is_inside = 0;\n    }\n    \n    if (is_inside)\n    {\n       (*jstat) = 1;\n       if(on_edge)\n       {\n\t  (*jstat) += 1;\n\t  if(on_edge > 1)\n\t  {\n    \t     if (po1->iobj == SISLSURFACE)\n     \t     {\n\t\tif ((on_edge & 1 || on_edge & 2) &&\n\t\t    (on_edge & 4 || on_edge & 8))\n\t\t   (*jstat) += 1;\n\t     }\n\n\t     if (po2->iobj == SISLSURFACE )\n     \t     {\n\t\tint ui = 2*(nrpar - 2);\n\t\tif ((on_edge & (1 << (ui)) || on_edge & (1 << (ui+1))) &&\n\t\t    (on_edge & (1 << (ui+2)) || on_edge & (1 << (ui+3))))\n\t\t   (*jstat) += 1;\n\t     }\n\t  }\n       }\n       \n       /* Test if the intersection point lies at an edge in both\n\t  objects and is not registered as a corner point.       */\n       \n       if (*jstat == 2 && (on_edge & 15) && (on_edge & 240))\n\t  *jstat = 5;\n    }\n    else\n       (*jstat) = 0;\n }\n else goto err108;\n\n \n  /* Done. */\n\n  goto out;\n\n  /* Error in input. Conflicting dimensions.  */\n\nerr106:*jstat = -106;\n  goto out;\n\n  /* Error in input. No points */\n\nerr108:*jstat = -108;\n  goto out;\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/sh6ismain.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6ismain.c,v 1.2 2001-03-19 16:06:03 afr Exp $\n *\n */\n\n\n#define SH6ISMAIN\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nint \n      sh6ismain(SISLIntpt *pt)\n#else\nint sh6ismain(pt)\n    SISLIntpt *pt;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Boolean. Is pt a main point?\n*\n*\n* INPUT      : pt       - Pointer to the Intpt.\n*\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n*\n*********************************************************************\n*/\n{\n   int flag = 0;\n\n   if(pt != SISL_NULL && pt->iinter > 0) flag = 1;\n\n\n   goto out;\n   \n\n   \n   out :\n      return flag;\n}\n\n\n\n\n\n\n"
  },
  {
    "path": "src/sh6nmbhelp.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6nmbhelp.c,v 1.2 2001-03-19 16:06:03 afr Exp $\n *\n */\n\n\n#define SH6NMBHELP\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nint \n      sh6nmbhelp(SISLIntpt *pt,int *jstat)\n#else\nint sh6nmbhelp(pt,jstat)\n   SISLIntpt *pt;\n   int       *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given an Intpt, return the number of help points\n*              it is linked to.\n*\n*\n* INPUT      : pt       - Pointer to the Intpt.\n*\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n*********************************************************************\n*/\n{\n   int num; /* Number of lists. */\n   int ki; /* Loop variable.  */\n\n   num=0;\n\n   /* Count number of main lists pt lies in. */\n\n   for(ki=0; ki<pt->no_of_curves; ki++)\n   {\n       if(pt->pnext[ki] == SISL_NULL) goto err1;\n       if(sh6ishelp(pt->pnext[ki])) num++;\n   }\n\n   goto out;\n   \n\nerr1:\n   /* Error in data structure. */\n   \n   *jstat = -1;\n   s6err(\"sh6nmbhelp\",*jstat,0);\n   goto out;\n   \n   \n   out :\n      return num;\n}\n\n\n\n\n\n\n"
  },
  {
    "path": "src/sh6nmbmain.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6nmbmain.c,v 1.2 2001-03-19 16:06:03 afr Exp $\n *\n */\n\n\n#define SH6NMBMAIN\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nint \n      sh6nmbmain(SISLIntpt *pt,int *jstat)\n#else\nint sh6nmbmain(pt,jstat)\n   SISLIntpt *pt;\n   int       *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given an Intpt, return the number of main points\n*              it is linked to.\n*\n*\n* INPUT      : pt       - Pointer to the Intpt.\n*\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n*********************************************************************\n*/\n{\n   int num; /* Number of lists. */\n   int ki; /* Loop variable.  */\n\n   num=0;\n\n   /* Count number of main lists pt lies in. */\n\n   for(ki=0; ki<pt->no_of_curves; ki++)\n   {\n       if(pt->pnext[ki] == SISL_NULL) goto err1;\n       if(sh6ismain(pt->pnext[ki])) num++;\n   }\n\n   goto out;\n   \n\nerr1:\n   /* Error in data structure. */\n   \n   *jstat = -1;\n   s6err(\"sh6nmbmain\",*jstat,0);\n   goto out;\n   \n   \n   out :\n      return num;\n}\n\n\n\n\n\n\n"
  },
  {
    "path": "src/sh6ptobj.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6ptobj.c,v 1.2 2001-03-19 16:06:03 afr Exp $\n *\n */\n\n\n#define SH6PTOBJ\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \nsh6ptobj(double *point, SISLObject *obj, double aepsge,\n\t   double start[], double result[], int *jstat)\n#else\nvoid sh6ptobj(point, obj, aepsge, start, result, jstat)\n     double *point;\n     SISLObject *obj;\n     double aepsge;\n     double start[];\n     double result[];\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Newton iteration on the distance function between\n*              a point and an object to find a closest point\n*              or an intersection point.\n*\n*\n* INPUT      : point     - Point in the intersection.\n*              obj       - Object in the intersection.\n*              aepsge    - Geometry resolution.\n*              start[]   - Start parameter value of the iteration on\n*                          the object.\n*\n*\n*\n* OUTPUT     : result[]  - Parameter value of the object in intersection\n*                          point.\n*              jstat   - status messages  \n*                                = 2   : A minimum distanse found.\n*                                = 1   : Intersection found.\n*                                < 0   : error.\n*\n*\n* METHOD     : Newton iteration.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Arne Laksaa, SI, Sep 1991\n*              UJK, SI, Sep 1991, include point object\n*********************************************************************\n*/                       \n{                        \n  int kstat = 0;            /* Local status variable.                      */\n  int kpos = 0;             /* Position of error.                          */\n  double pstart[2];\n  double pend[2];\n  SISLPoint *sislpt = SISL_NULL;\n  double loc_start[2];\n  \n  /* Test input.  */\n  \n  if (obj == SISL_NULL) goto err106;\n\t\t   \n  if ( obj->iobj == SISLSURFACE)\n  {\n     if ((sislpt = newPoint(point, obj->s1->idim, 0)) == SISL_NULL)\n        goto error;\n\n     memcopy(loc_start,start,2,double);\n     \n     pstart[0] = obj->s1->et1[obj->s1->ik1 - 1];\n     pstart[1] = obj->s1->et2[obj->s1->ik2 - 1];\n     pend[0]   = obj->s1->et1[obj->s1->in1];\n     pend[1]   = obj->s1->et2[obj->s1->in2];\n     \n     s1773(sislpt, obj->s1, aepsge,\n\t   pstart, pend, loc_start, result, &kstat);\n     if (kstat < 0) goto error;\n  }\n  else if ( obj->iobj == SISLCURVE)\n  {\n     if ((sislpt = newPoint(point, obj->c1->idim, 0)) == SISL_NULL)\n        goto error;\n     \n     pstart[0] = obj->c1->et[obj->c1->ik - 1];\n     pend[0]   = obj->c1->et[obj->c1->in];\n  \n     loc_start[0] = start[0];\n     s1771(sislpt, obj->c1, aepsge,\n\t   pstart[0], pend[0], loc_start[0], result, &kstat);\n     if (kstat < 0) goto error;\n  }\n  else if ( obj->iobj == SISLPOINT)\n  {\n     if(s6dist(point,obj->p1->ecoef,obj->p1->idim) < aepsge)\n\tkstat = 1;\n     else\n        kstat = 2;\n  }\n  else goto err106;\n  \n  *jstat = kstat;\n  goto out;\n  \n  /* Error in input. */\n  \n err106: *jstat = -106;\n  s6err(\"sh6ptobj\",*jstat,kpos);\n  goto out;                  \n  \n  /* Error in lower level routine.  */\n  \n  error : *jstat = kstat;\n  s6err(\"sh6ptobj\",*jstat,kpos);\n  goto out;                  \n\t \n out:    if (sislpt != SISL_NULL) freePoint(sislpt);\n}\n"
  },
  {
    "path": "src/sh6ptouchp.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6ptouchp.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define SH6PUTTOUCH\n#include \"sislP.h\"                            \n\n#if defined (SISLNEEDPROTOTYPES)\nvoid\n      sh6puttouch( SISLIntpt *psource, SISLIntpt *pdest, int seq)\n#else\n\t \n\t void sh6puttouch(psource,pdest, seq)\n\t    \n\t    SISLIntpt *psource,*pdest;\n\t    int seq;\n#endif\n\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To set right direction in a touch point (Singular, but no branch).\n*              The invariant to hold is that the direction on the curve \n*              in the parameter space is parallel to the delta vector between\n*              the to points.\n*\n*\n*\n* INPUT      : psource - The previous point on the curves.\n*              pdest   - The point that is to be fit in.\n*                        Posisiton must be ok.\n*              seq     - The sequncing of the points\n*                        +1 - psource comes before pdest.\n*                        -1 - psource comes after pdest.\n* OUTPUT     : pdest   - Geometric values, ie tangent is changed.\n\n*\n* METHOD     : \n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6scpr, s6diff, s6norm\n*\n* WRITTEN BY : UJK\n*\n*********************************************************************\n*/\n{\n  int kdim2=2;\n  int kdim3=3;\n  double diffv[3];\n  int ki;\n  double dot;\n  /* ______________________ */\n  \n  if (psource->iinter == SI_ORD)\n    sh6putsing(psource, pdest);\n  else\n    {\n       kdim2 = 2;\n       s6diff(pdest->geo_track_2d_1,psource->geo_track_2d_1,kdim2,diffv);\n       dot = s6scpr(pdest->geo_track_2d_1+kdim2, diffv, kdim2);\n       if (dot * seq < 0)\n\t {\n\t    /* Turn direction */\n\t    for (ki=0;ki<kdim2;ki++) \n\t      {\n\t\t pdest->geo_track_2d_1[kdim2+ki] = -pdest->geo_track_2d_1[kdim2+ki];\n\t\t pdest->geo_track_2d_2[kdim2+ki] = -pdest->geo_track_2d_2[kdim2+ki];\n\t      }  \n\t    \n\t    for (ki=0;ki<kdim3;ki++) \n\t      pdest->geo_track_3d[kdim3+ki] = -pdest->geo_track_3d[kdim3+ki];\n\t }\n       \n    }\n}\n"
  },
  {
    "path": "src/sh6putsing.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6putsing.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define SH6PUTSING\n#include \"sislP.h\"                            \n\n#if defined (SISLNEEDPROTOTYPES)\nvoid\n      sh6putsing( SISLIntpt *psource, SISLIntpt *pdest)\n#else\n\t \n\t void sh6putsing(psource,pdest)\n\t    \n\t    SISLIntpt *psource,*pdest;\n#endif\n\n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To set some approximative values in a singular point\n*              based on symmetry.\n*\n*\n*\n* INPUT      : psource - The previous point on the curves.\n*              pdest   - The point that is to be fit in.\n*                        Posisiton must be ok.\n* OUTPUT     : pdest   - Geometric values, ie tangent is changed.\n\n*\n* METHOD     : For each curve we mirror the tangent in psource\n*              around the difference vector pdest-psource.\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6scpr, s6diff, s6norm\n*\n* WRITTEN BY : UJK\n*\n*********************************************************************\n*/\n{\n  int kdim,kstat;                \n  double alfa;\n  double diffv[3];\n  double delta[3];\n  int ki;\n  \n  kdim = 3;\n  s6diff(pdest->geo_track_3d,psource->geo_track_3d,kdim,diffv);\n  s6norm(diffv,kdim,delta,&kstat);\n  alfa = (double)2.0*s6scpr(delta,psource->geo_track_3d+kdim,kdim);\n  for (ki=0;ki<kdim;ki++) \n    pdest->geo_track_3d[kdim+ki] = alfa*delta[ki] - psource->geo_track_3d[kdim+ki];\n\n  pdest->geo_track_3d[9] = -(double) 1.0;\n  \n  kdim = 2;\n  s6diff(pdest->geo_track_2d_1,psource->geo_track_2d_1,kdim,diffv);\n  s6norm(diffv,kdim,delta,&kstat);\n  alfa = (double)2.0*s6scpr(delta,psource->geo_track_2d_1+kdim,kdim);\n  for (ki=0;ki<kdim;ki++) \n    pdest->geo_track_2d_1[kdim+ki] = alfa*delta[ki] - psource->geo_track_2d_1[kdim+ki];\n  \n  pdest->geo_track_2d_1[6] = -(double) 1.0;\n\n  kdim = 2;\n  s6diff(pdest->geo_track_2d_2,psource->geo_track_2d_2,kdim,diffv);\n  s6norm(diffv,kdim,delta,&kstat);\n  alfa = (double)2.0*s6scpr(delta,psource->geo_track_2d_2+kdim,kdim);\n  for (ki=0;ki<kdim;ki++) \n    pdest->geo_track_2d_2[kdim+ki] = alfa*delta[ki] - psource->geo_track_2d_2[kdim+ki];\n\n  pdest->geo_track_2d_1[6] = -(double) 1.0;\n\n}\n"
  },
  {
    "path": "src/sh6red.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6red.c,v 1.3 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n#define SH6RED\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic int sh6red_help(SISLObject *po1, SISLObject *po2,\n\t\t\t SISLIntpt *pt, SISLIntpt *pmain, int *jstat);\n#else\nstatic int sh6red_help(po1, po2, pt, pmain, jstat);\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6red (SISLObject * po1, SISLObject * po2,\n\tSISLIntdat * pintdat, int *jstat)\n#else\nvoid\nsh6red (po1, po2, pintdat, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntdat *pintdat;\n     int *jstat;\n#endif\n\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Reduse main int point to help point if they are not legal.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              pintdat  - Intersection data structure.\n*\n*\n* OUTPUT     : jstat    - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      :\n*\n* REFERENCES :\n*\n* WRITTEN BY : Arne Laksaa, SI, Oslo, sep. -91.\n*********************************************************************\n*/\n{\n  int kstat, i, j;\n  double tepsge = (double)10000.0*REL_COMP_RES;\n  double weight = (double) 0.5;\n  int changed, doreduce;\n  SISLIntpt *pcurr,*pstart,*plast;\t/* to traverse list of points.     */\n  int indstart,indlast,inddum;\t\t/* Indexes used in lists           */\n  int log_1, log_2;\n  int dim;\n  SISLIntpt *qmain;\n  if (po1->iobj == SISLSURFACE)\n    dim = po1->s1->idim;\n  else if (po1->iobj == SISLCURVE)\n    dim = po1->c1->idim;\n  else if (po1->iobj == SISLPOINT)\n    dim = po1->p1->idim;\n\n  /* Remove all internal points in a list when along a\n     constant parameter direction */\n  \n  if (((po1->iobj == SISLSURFACE && po2->iobj == SISLPOINT\n        && dim == 1) ||\n       (po2->iobj == SISLSURFACE && po1->iobj == SISLPOINT\n        && dim == 1) ||\n       (po1->iobj == SISLSURFACE && po2->iobj == SISLSURFACE\n        && dim == 3) ||\n      (po1->iobj + po2->iobj == SISLSURFACE + SISLCURVE\n        && dim == 3) ||\n      (po2->iobj == SISLSURFACE && po1->iobj == SISLCURVE\n       && dim == 3)) &&\n       pintdat != SISL_NULL)\n     for (j = 0; j < pintdat->ipoint; j++)\n     {\n\t\n\tpcurr = pintdat->vpoint[j];\n\tsh6isinside (po1, po2, pcurr, &kstat);\n\tif (kstat < 0)\n\t   goto error;\n\t\n\t/* VSK && ALA. 01.93. Do not remove points at corners. */\n\tif (kstat != 1 && kstat != 2) continue;\n\t\n\tsh6getnhbrs (pcurr, &pstart, &plast, &kstat);\n\tif (kstat < 0)\n\t   goto error;\n\t\n\tif (kstat == 0)\n\t{\n\t   /* Two neighbours, check */\n\t   sh6getlist (pcurr, pstart, &indstart, &inddum, &kstat);\n\t   if (kstat < 0)\n\t      goto error;\t\t/* Error. */\n\t   if (kstat == 1)\n\t      goto errinconsist;\t/* pcurr and pstart are not linked. */\n\t   \n\t   sh6getlist (pcurr, plast, &indlast, &inddum, &kstat);\n\t   if (kstat < 0)\n\t      goto error;\t\t/* Error. */\n\t   if (kstat == 1)\n\t      goto errinconsist;\t/* pcurr and plast are not linked. */\n\t   \n\t   log_1 = pcurr->curve_dir[indstart];\n\t   log_1 = log_1>>1;\n\t   log_1 &= 15;\n\t   log_2 = pcurr->curve_dir[indlast];\n\t   log_2 = log_2>>1;\n\t   log_2 &= 15;\n\t   \t   \n\t   if (log_1 & log_2 )\n\t   {\n\t      sh6idkpt (&pintdat, &pcurr, 1, &kstat);\n\t      if (kstat < 0)\n\t\t goto error;\n\t      /* Recursive nature : */\n\t      j = -1;\n\t   }\n\t   \n\t   \n\t}\n     }\n   \n  \n  if (pintdat != SISL_NULL)\n    {\n      /* Weight value in 3D sf vs sf case is one */\n      if (pintdat->vpoint[0]->ipar == 4)\n\tweight = (double) 1.0;\n\n      /* Reduce an illegal trim_curve to one point. */\n\n      for (i = 0; i < pintdat->ipoint; i++)\n\t{\n\t  if (pintdat->vpoint[i]->iinter == SI_TRIM)\n\t    {\n\t      SISLIntpt **trim = SISL_NULL;\n\t      int no_trim = 0;\n\t      int no_alloc = 0;\n\t      sh6trimlist (pintdat->vpoint[i], &trim, &no_trim, &no_alloc);\n\t      for (j = 0; j < no_trim; j++)\n\t\t{\n\t\t  sh6isinside (po1, po2, trim[j], &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t\t  if (kstat != 1)\n\t\t    break;\n\t\t}\n\t      if (j == no_trim)\n\t\t{\n\t\t  /* Internal trim area. */\n\t\t  for (j = 1; j < no_trim; j++)\n\t\t    {\n\t\t       /* sh6idunite (&pintdat, &trim[0], &trim[j], weight, &kstat);\n\t\t\t  */\n\t\t       /* VSK. 01.93. */\n\t\t       sh6idnewunite(po1, po2, &pintdat, &trim[0], &trim[j], \n\t\t\t\t     weight, tepsge, &kstat);\n\t\t      if (kstat < 0)\n\t\t\tgoto error;\n\n\t\t      /* We now need to correct the intpoint. */\n\t\t    }\n\t\t  trim[0]->iinter = SI_SING;\n\t\t}\n\t      if (trim)\n\t\tfreearray (trim);\n\t    }\n\t}\n\n      /* Reduse ilegal main points to help points. */\n      do\n\t{\n\t  changed = 0;\n\t  //for (i = 0; i < pintdat->ipoint; i++)\n\t  for (i = pintdat->ipoint-1; i >= 0; i--)\n\t    {\n\t      sh6isinside (po1, po2, pintdat->vpoint[i], &kstat);\n\t      if (kstat < 0)\n\t\tgoto error;\n\t      if (kstat == 1 || (kstat == 2 && po1->iobj+po2->iobj == 2*SISLSURFACE))\n\t\t{\n\t\t  if (sh6ismain (pintdat->vpoint[i]) &&\n\t\t      sh6nmbmain (pintdat->vpoint[i], &kstat) == 1)\n\t\t    {\n\t\t      if (pintdat->vpoint[i]->fromhelp > 0)\n\t\t\tdoreduce = 1;\n\t\t      else\n\t\t\t{\n\t\t\t  /* Check if a reduction is recommended */\n\t\t\t  qmain = SISL_NULL;\n\t\t\t  for (j=0; j<pintdat->vpoint[i]->no_of_curves; ++j)\n\t\t\t    if (pintdat->vpoint[i]->pnext[j]->iinter > 0)\n\t\t\t      {\n\t\t\t\tqmain = pintdat->vpoint[i]->pnext[j];\n\t\t\t\tbreak;\n\t\t\t      }\n\n\t\t\t  if (qmain && po1->iobj+po2->iobj == 2*SISLSURFACE)\n\t\t\t    {\n\t\t\t      /* Check if the points are connected along an\n\t\t\t\t edge */\n\t\t\t      sh6comedg(po1, po2, pintdat->vpoint[i], qmain, &kstat);\n\t\t\t      if (kstat < 0)\n\t\t\t\tgoto error;\n\t\t\t      if (kstat == 0)\n\t\t\t\tqmain = SISL_NULL;   /* Not a common edge */\n\t\t\t    }\n\t\t\t  doreduce = (qmain == SISL_NULL) ? 0 :\n\t\t\t    sh6red_help(po1, po2, pintdat->vpoint[i], qmain, &kstat);\n\t\t\t  if (kstat < 0)\n\t\t\t    goto error;\n\t\t\t}\n\t\t      if (doreduce)\n\t\t\t{\n\t\t\t  sh6tohelp (pintdat->vpoint[i], &kstat);\n\t\t\t  if (kstat < 0)\n\t\t\t    goto error;\n\t\t\t  changed = 1;\n\t\t\t}\n\t\t    }\n\t\t}\n\t    }\n      } while (changed);\n \n      /*UJK, 12.08.93 */\n      /* Disconnect trim pts with 3 neighbours */\n      do\n\t{\n\t   int ind_1,ind_2;\n\t   SISLIntpt *p_neighb[3];\n\t   int log_check[3];\n\t   changed = 0;\n\t   for (i = 0; i < pintdat->ipoint; i++)\n\t   {\n\t      pcurr = pintdat->vpoint[i];\n\t      sh6isinside (po1, po2, pcurr, &kstat);\n\t      if (kstat < 0)\n\t\t goto error;\n\t      if (kstat &&\n\t\t  pcurr->iinter == SI_TRIM &&\n\t\t  sh6nmbmain (pcurr, &kstat) == 3)\n\t      {\n\t\t for (ind_1=ind_2=0;ind_1<pcurr->no_of_curves;ind_1++)\n\t\t    if (pcurr->pnext[ind_1]->iinter == SI_TRIM)\n\t\t    {\n\t\t       sh6isinside (po1, po2, pcurr->pnext[ind_1], &kstat);\n\t\t       if (kstat < 0)\n\t\t\t  goto error;\n\t\t       if (kstat)\n\t\t       {\n\t\t\t  p_neighb[ind_2]  = pcurr->pnext[ind_1];\n\t\t\t  log_check[ind_2] = pcurr->curve_dir[ind_1];\n\t\t\t  log_check[ind_2] = log_check[ind_2]>>1;\n\t\t\t  log_check[ind_2] &= 15;\n\t\t\t  ind_2++;\n\t\t       }\n\t\t    }\n\t\t \n\t\t if (ind_2 == 3)\n\t\t {\n\t\t    if (log_check[0] & log_check[1])\n\t\t       ind_2 = 2;\n\t\t    else if (log_check[0] & log_check[2])\n\t\t       ind_2 = 1;\n\t\t    else if (log_check[1] & log_check[2])\n\t\t       ind_2 = 0;\n\t\t    \n\t\t    if (ind_2 < 3)\n\t\t    {\n\t\t       changed = TRUE;\n\t\t       sh6disconnect(pcurr,p_neighb[ind_2],&kstat);\n\t\t       if (kstat < 0) goto error;\n\t\t       /* afr: Changed line below from an empty if-statement. */\n\t\t       sh6nmbmain (p_neighb[ind_2], &kstat);\n\t\t       if (kstat < 0) goto error;\n\t\t       sh6idkpt (&pintdat, &p_neighb[ind_2], 0, &kstat);\n\t\t       if (kstat < 0) goto error;\n\t\t    }\n\t\t }\n\t      }\n\t   }\n\t} while (changed);\n    }\n\n  /* VSK, 03-2018. Take another iteration to remove internal points in a\n     list after the help point reduction is performed.  */\n  if (pintdat != SISL_NULL)\n    {\n     for (j = 0; j < pintdat->ipoint; j++)\n     {\n\t\n\tpcurr = pintdat->vpoint[j];\n\tsh6isinside (po1, po2, pcurr, &kstat);\n\tif (kstat < 0)\n\t   goto error;\n\t\n\t/* Do not remove points at corners. */\n\tif (kstat != 1 && kstat != 2) continue;\n\t\n\tsh6getnhbrs (pcurr, &pstart, &plast, &kstat);\n\tif (kstat < 0)\n\t   goto error;\n\t\n\tif (kstat == 0)\n\t{\n\t   /* Two neighbours, check */\n\t   sh6getlist (pcurr, pstart, &indstart, &inddum, &kstat);\n\t   if (kstat < 0)\n\t      goto error;\t\t/* Error. */\n\t   if (kstat == 1)\n\t      goto errinconsist;\t/* pcurr and pstart are not linked. */\n\t   \n\t   sh6getlist (pcurr, plast, &indlast, &inddum, &kstat);\n\t   if (kstat < 0)\n\t      goto error;\t\t/* Error. */\n\t   if (kstat == 1)\n\t      goto errinconsist;\t/* pcurr and plast are not linked. */\n\t   \n\t   log_1 = pcurr->curve_dir[indstart];\n\t   log_1 = log_1>>1;\n\t   log_1 &= 15;\n\t   log_2 = pcurr->curve_dir[indlast];\n\t   log_2 = log_2>>1;\n\t   log_2 &= 15;\n\t   \t   \n\t   if ((log_1 & log_2) || \n\t       (dim == 3 && po1->iobj+po2->iobj < 4))\n\t   {\n\t      sh6idkpt (&pintdat, &pcurr, 1, &kstat);\n\t      if (kstat < 0)\n\t\t goto error;\n\t      /* Recursive nature : */\n\t      j = -1;\n\t   }\n\t}\n     }\n    }\n\n   /* Reduction done. */\n\n  (*jstat) = 0;\n  goto out;\n\nerrinconsist:\n  *jstat = -500;\n  s6err (\"sh6red\", *jstat, 0);\n  goto out;\n  \nerror:(*jstat) = kstat;\n  s6err (\"sh6red\", *jstat, 0);\n  goto out;\n\nout:\n  return;\n}\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic int sh6red_help(SISLObject *po1, SISLObject *po2,\n\t\t       SISLIntpt *pt, SISLIntpt *pmain, int *jstat)\n#else\n  static int sh6red_help(po1, po2, pt, pmain, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntpt *pt;\n     SISLIntpt *pmain;\n     int *jstat;\n#endif\n{\n  int kstat = 0;\n  int ki, k1;\n  int kleft1 = 0, kleft2 = 0, kleft3;\n  double tpar1, tpar2;\n  double *sst[4];   /* Knot vectors in the problem, maximum 4. */\n  int lkn[4];       /* Number of coefficients in each parameter direction. */\n  int lkk[4];       /* Order in each parameter direction. */\n  int  doreduce = 1;\n\n  *jstat = 0;\n  if (po1->iobj == SISLSURFACE)\n    {\n      sst[0] = po1->s1->et1;\n      sst[1] = po1->s1->et2;\n      lkn[0] = po1->s1->in1;\n      lkn[1] = po1->s1->in2;\n      lkk[0] = po1->s1->ik1;\n      lkk[1] = po1->s1->ik2;\n      k1 = 2;\n    }\n  else if (po1->iobj == SISLCURVE)\n    {\n      sst[0] = po1->c1->et;\n      lkn[0] = po1->c1->in;\n      lkk[0] = po1->c1->ik;\n      k1 = 1;\n    }\n  else\n    k1 = 0;\n\n  if (po2->iobj == SISLSURFACE)\n    {\n      sst[k1] = po2->s1->et1;\n      sst[k1+1] = po2->s1->et2;\n      lkn[k1] = po2->s1->in1;\n      lkn[k1+1] = po2->s1->in2;\n      lkk[k1] = po2->s1->ik1;\n      lkk[k1+1] = po2->s1->ik2;\n    }\n  else if (po2->iobj == SISLCURVE)\n    {\n      sst[k1] = po2->c1->et;\n      lkn[k1] = po2->c1->in;\n      lkk[k1] = po2->c1->ik;\n    }\n      \n  for (ki=0; ki<pt->ipar; ki++)\n    {\n      tpar1 = pt->epar[ki];\n      s1219(sst[ki], lkk[ki], lkn[ki], &kleft1, tpar1, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      if (tpar1 >= sst[ki][lkn[ki]])\n\tkleft1 = lkn[ki];\n\n      tpar2 = pmain->epar[ki];\n      s1219(sst[ki], lkk[ki], lkn[ki], &kleft2, tpar2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n      if (tpar2 >= sst[ki][lkn[ki]])\n\tkleft2 = lkn[ki];\n\n      kleft3 = (kleft2 > kleft1) ? kleft1 + 1 :\n\t((kleft1 == kleft2) ? kleft1 : kleft1 - 1);\n      if (DEQUAL(sst[ki][kleft1],tpar1) ||\n\t  (kleft1 != kleft2 && DNEQUAL(sst[ki][kleft3],sst[ki][kleft2])))\n\t{\n\t  doreduce = 0;\n\t  break;\n\t}\n    }\n  goto out;\n\n error:\n  *jstat = kstat;\n  goto out;\n\n out:\n  return doreduce;\n}\n"
  },
  {
    "path": "src/sh6remcon.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6remcon.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define SH6REMCON\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n      sh6remcon(SISLIntdat **pintdat,SISLIntpt *pt1,SISLIntpt *pt2,int *jstat)\n#else\nvoid sh6remcon(pintdat,pt1,pt2,jstat)\n   SISLIntdat **pintdat;\n   SISLIntpt *pt1;\n   SISLIntpt *pt2;\n   int       *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Remove connection between pt1 and pt2.\n*\n* INPUT      : pintdat  - Pointer to pointer to the SISLIntdat data.\n*              pt1      - First point.\n*              pt2      - Second point.\n*              jstat    - Error flag.\n*                         jstat =  0  => successful\n*                         jstat = -1  => pt1 and pt2 are not connected\n*                         jstat = -2  => error in space allocation\n*                         jstat <  0  => error in lower level routine\n*\n*\n* METHOD     : \n*\n* CALLS      : s6err      - Gives error message.\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n*\n*********************************************************************\n*/\n{\n  int kstat;                 /* Local status variable.                     */\n  \n   *jstat = 0;\n  \n\n  sh6disconnect(pt1,pt2,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Do we want to remove either point from pintdat? */\n\n  \n  goto out;  \n  \n\n  /* Error in lower level routine. */\n\n  error : *jstat = kstat;\n  s6err(\"sh6remcon\",*jstat,0);\n  goto out;                       \n  \n  \n  out: ;\n}\n"
  },
  {
    "path": "src/sh6rempnt.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6rempnt.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define SH6REMOVEPT\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n      sh6removept(SISLIntpt *pt1,SISLIntpt *pt2,SISLIntpt *ptold,int *jstat)\n#else\nvoid sh6removept(pt1,pt2,ptold,jstat)\n   SISLIntpt *pt1;\n   SISLIntpt *pt2;\n   SISLIntpt *ptold;\n   int       *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Remove the pt ptold from the list which contains\n*              pt1,ptold,pt2 consecutively.\n*              Error if there is no such list.\n*              The list is repaired afterwards.\n*\n* INPUT      : pt1      - First point.\n*              pt2      - Second point.\n*              ptold    - Point to be removed between pt1 and pt2.\n*              jstat    - Error flag.\n*                         jstat =  0  => successful\n*                         jstat = -1  => pt1,ptold,pt2 are not connected\n*                         jstat <  0  => error in lower level routine\n*\n*\n* METHOD     : \n*\n* CALLS      : s6err      - Gives error message.\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n*\n*********************************************************************\n*/\n{\n  int kstat;      /* Local status variables.          */\n  \n   *jstat = 0;\n  \n\n\n  sh6disconnect(pt1,ptold,&kstat);\n  if(kstat < 0) goto error;\n\n  sh6disconnect(pt2,ptold,&kstat);\n  if(kstat < 0) goto error;\n\n  sh6connect(pt1,pt2,&kstat);\n  if(kstat < 0) goto error;\n\n  \n  goto out;\n  \n\n\n/* Error in subfunction. */\n\nerror:  *jstat = kstat;\n        s6err(\"sh6removept\",*jstat,0);\n        goto out;\n\n\n   out:\n      return;\n}\n"
  },
  {
    "path": "src/sh6sepcrv.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6sepcrv.c,v 1.2 2001-03-19 16:06:03 afr Exp $\n *\n */\n\n\n#define SH6SEPCRV\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void sh6sepcrv_s9circle(double [], double[], double[], double, \n\t\t\t\t  double[], double[], double *, int *);\n#else\nstatic void sh6sepcrv_s9circle();\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n  sh6sepcrv (SISLCurve *pc1, SISLCurve *pc2, double aepsge, double ecentre[],\n\t     double *crad, int *jstat)\n#else\nvoid\n   sh6sepcrv (pc1, pc2, aepsge, ecentre, crad, jstat)\n   SISLCurve *pc1;\n   SISLCurve *pc2;\n   double aepsge;\n   double ecentre[];\n   double *crad;\n   int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find splitting geometry between two B-spline curves\n*              The geometry object is a sphere,\n*              and is used to put between two input objects to check if\n*              an intersection is possible.\n*\n*\n* INPUT      : pc1      - First curve.\n*              pc2      - Second curve.\n*              aepsge   - Geometry tolerance. \n*\n*\n* OUTPUT     : ecentre  - Centre of sphere.\n*              crad     - Radius of sphere.\n*              jstat    - status messages\n*                                = 1   : A sphere is found.\n*                                = 0   : Ok. No splitting geometry is found.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      : s1421   -  Surface evaluator.\n*              s1773   -  Closest point between point and surface.\n*              s6ang   -  Angle between vectors.\n*              s6scpr  -  Scalar product between vectors.\n*              s6norm  -  Normalize vector.\n*              s6diff  -  Difference vector.\n*              s6dist  -  Distance between points. \n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 93-02.\n* CHANGED BY : Vibeke Skytt, SI, 93-05. New splits introduced.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;         /* Status variable.       */\n   int ki,kj;             /* Counters.              */\n   int kleft1=0; /* Parameters to surface evaluator. */\n   int kdim=pc1->idim;    /* Dimension of geometry space.      */\n   double tpar;       /* Midpoint of surface.              */\n   double sparc1[3];      /* Corner parameters of first surface. */\n   double sparc2[3];      /* Parameters of closest points on second surface. */\n   double scorn1[9];     /* Corners of first surface.           */\n   double scorn2[9];     /* Closest points in the other surface. */\n   SISLPoint *qp = SISL_NULL;  /* Representing a surface corner as a point. */\n   double tstart;      /* Start parameters of second surface.       */\n   double tend;       /* End parameters of second surface.       */\n   double saxis[3];       /* Normal to circle between edges.         */\n   double tdot;\n   double tsign;\n   double tang;\n   double tpi4 = PI/(double)4.0;\n   \n   /* Test dimension.  */\n   \n   if (kdim != 3)\n   {\n      *jstat = 0;\n      goto out;\n   }\n   \n   /* Test if the cones of the surfaces is less than pi, otherwise\n      no attempt to find splitting geometry is made.  */\n   \n   if (pc1->pdir->igtpi != 0 || pc2->pdir->igtpi != 0)\n   {\n      *jstat = 0;\n      goto out;\n   }\n   \n   \n   /* Check that the objects are not too large, i.e. contain to many\n      vertices to be put into a sphere equation effectively. */\n   \n   if (pc1->in > 4*pc1->ik || pc2->in > 4*pc2->ik)\n   {\n      *jstat = 0;\n      goto out;\n   }\n   \n   /* Make sure that the cones lies in the same area, otherwise\n      return.   */\n\n   tdot = s6scpr(pc1->pdir->ecoef,pc2->pdir->ecoef,kdim);\n   tsign = (tdot >= DZERO) ? (double)1.0 : -(double)1.0;\n\n   tang = s6ang(pc1->pdir->ecoef,pc2->pdir->ecoef,kdim);\n   if (tang > tpi4)\n   {\n      *jstat = 0;\n      goto out;\n   }\n \n   /* Try to find a circle splitting the edge curves of the surface and the\n      cyrve, and extend this circle to a sphere.  */\n   \n   sparc1[0] = *(pc1->et+pc1->ik-1);\n   sparc1[2] = *(pc1->et+pc1->in);\n   sparc1[1] = (double)0.5*(sparc1[0] + sparc1[2]);\n   \n   tstart = *(pc2->et + pc2->ik - 1);\n   tend = *(pc2->et + pc2->in);\n   tpar= (double)0.5*(tstart + tend);\n   \n   for (ki=0; ki<3; ki++)\n   {\n      /* Evaluate curve.  */\n      \n      s1221(pc1, 0, sparc1[ki], &kleft1, scorn1+ki*kdim, &kstat);\n      if (kstat < 0) goto error;\n      \n      /* Find the closest point in the other surface. First express\n\t the corner as a SISLPoint. */\n      \n      if ((qp = newPoint(scorn1+ki*kdim, kdim, 1)) == SISL_NULL) goto err101;\n      s1771(qp, pc2, aepsge, tstart, tend, tpar, sparc2+ki, &kstat);\n      if (kstat < 0) goto error;\n      \n      /* Evaluate second curve. */\n      \n      s1221(pc2, 0, sparc2[ki], &kleft1, scorn2+ki*kdim, &kstat);\n      if (kstat < 0) goto error;\n      \n      if (qp != SISL_NULL) freePoint(qp); qp = SISL_NULL;\n   }\n   \n   \n   /* Find middle points between the sets of closest points. */\n   \n   for (kj=0; kj<3; kj++)\n      for (ki=0; ki<kdim; ki++)\n\t scorn1[kj*kdim+ki] = (double)0.5*(scorn1[kj*kdim+ki] + \n\t\t\t\t\t   scorn2[kj*kdim+ki]);\n   \n   /* Compute splitting cylinder. */\n   \n   sh6sepcrv_s9circle(scorn1, scorn1+kdim, scorn1+2*kdim,\n\t\t       aepsge, ecentre, saxis, crad, &kstat);\n   if (kstat < 0) goto error;\n   if (kstat > 0)\n   {\n      *jstat = 0;\n      goto out;\n   }\n   \n   /* Output sphere. */\n   \n   *jstat = 1;\n   goto out;\n\n   err101 : *jstat = -101;\n   goto out;\n   \n   error : *jstat = kstat;\n   goto out;\n   \n   out :\n      return;\n}\n\n   \n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  sh6sepcrv_s9circle(double apt1[], double apt2[], double apt3[],\n\t\t     double aepsge, double ecentre[], double eaxis[],\n\t\t     double *crad, int *jstat)\n#else\nstatic void sh6sepcrv_s9circle(apt1, apt2, apt3, aepsge, ecentre, eaxis,\n\t\t\t       crad, jstat)\n      double apt1[];\n      double apt2[];\n      double apt3[];\n      double aepsge;\n      double ecentre[];\n      double eaxis[];\n      double *crad;\n      int *jstat;\n#endif      \n/*\n*********************************************************************\n*\n* PURPOSE    : Compute the circle passing through 3 points in 3D, and\n*              the normal to the plane in which the cirle lies.\n*\n*\n* INPUT      : apt1   - First point on the circle.\n*              apt2   - Second point on the circle.\n*              apt3   - Third point on the circle.\n*              aepsge - Geometry tolerance.\n*              \n*\n* OUTPUT     : ecentre - Centre of the circle.\n*              eaxis   - Normal to the plane in which the circle lies.\n*              crad    - Radius of the circle.\n*              jstat   - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* CALLS      : s6diff, s6crss, s6length, s6scpr, s6dist, s6lufacp, s6lusolp \n*\n*********************************************************************\n*/\n{\n   int kstat = 0;\n   int ki;\n   int kdim = 3;\n   int lpiv[3];\n   double snorm[3];\n   double smid1[3];\n   double smid2[3];\n   double sdiff1[3];\n   double sdiff2[3];\n   double smat[9];\n   double sright[3];\n   \n   /* Compute difference vectors between the 1. and 2. and 2. and 3. point. */\n   \n   s6diff(apt1, apt2, kdim, sdiff1);\n   s6diff(apt3, apt2, kdim, sdiff2);\n   \n   /* Compute the normal of the plane in which the circle lies. */\n   \n   s6crss(sdiff1, sdiff2, snorm);\n   \n   /* Compute the normals to the planes normal to the first plane and\n      perpendicular to the difference vectors. */\n   \n   /* s6crss(sdiff1, snorm, snorm1);\n   s6crss(sdiff2, snorm, snorm3); */\n   \n   /* Check normals.  */\n   \n   if (s6norm(sdiff1, kdim, sdiff1, &kstat) < aepsge) goto warn1;\n   if (s6norm(snorm, kdim, snorm, &kstat) < aepsge) goto warn1;\n   if (s6norm(sdiff2, kdim, sdiff2, &kstat) < aepsge) goto warn1; \n   \n   /* Compute the midpoints of the difference vectors. */\n   \n   for (ki=0; ki<kdim; ki++)\n   {\n      smid1[ki] = (double)0.5*(apt1[ki] + apt2[ki]);\n      smid2[ki] = (double)0.5*(apt2[ki] + apt3[ki]);\n   }\n   \n   /* Set up equation system.  */\n\n   memcopy(smat, snorm, kdim, DOUBLE);\n   memcopy(smat+kdim, sdiff1, kdim, DOUBLE);\n   memcopy(smat+2*kdim, sdiff2, kdim, DOUBLE);\n   \n   sright[0] = s6scpr(apt2, snorm, kdim);\n   sright[1] = s6scpr(smid1, sdiff1, kdim);\n   sright[2] = s6scpr(smid2, sdiff2, kdim);\n   \n   /* Solve equation system.  */\n   \n   s6lufacp(smat, lpiv, 3, &kstat);\n   if (kstat < 0) goto error;\n   \n   s6lusolp(smat, sright, lpiv, 3, &kstat);\n   if (kstat < 0) goto error;\n   \n   /* Prepare output.  */\n   \n   memcopy(eaxis, snorm, kdim, DOUBLE);\n   memcopy(ecentre, sright, kdim, DOUBLE);\n   *crad = s6dist(ecentre, apt2, kdim);\n   \n   *jstat = 0; \n   goto out;\n   \n   /* Almost singular equation system.  */\n   \n   warn1 :\n      *jstat = 1;\n   goto out;\n   \n   /* Error in lower level routine.  */\n   \n   error :\n      *jstat = kstat;\n   goto out;\n   \n   out :\n      return;\n}\n      \n"
  },
  {
    "path": "src/sh6setcnsd.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6setcnsd.c,v 1.2 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n#define SH6SETCNSDIR\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n      sh6setcnsdir(SISLIntpt *pt1,SISLIntpt *pt2,int ipar,int *jstat)\n#else\nvoid sh6setcnsdir(pt1,pt2,ipar,jstat)\n   SISLIntpt *pt1;\n   SISLIntpt *pt2;\n   int       ipar;\n   int       *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Set the direction of the curve through pt1 and pt2 such\n*              that pt1 points to pt2 along a constant parameter line.\n*              If they are not connected, give error.\n*              NOTE: if the points are given singular status\n*                    when they are of type SI_ORD.\n*\n* INPUT      : pt1      - Pointer to first Intpt.\n*              pt2      - Pointer to second Intpt.\n*              ipar     - parameter index: 0,1,2,3\n*              jstat    - Error flag.\n*                        jstat =  0  => Successful\n*                        jstat = -1  => Points are not connected.\n*                        jstat = -2  => Error in subfunction.\n*                        jstat = -3  => Error in subfunction.\n*\n*\n*\n* REFERENCES : Same as sh6setdir, different values used in curve_dir\n*              \n* WRITTEN BY : Ulf J. Krystad, SI, Oslo, Norway. September 91.\n*********************************************************************\n*/\n{\n   int kstat;         /* error flag. */\n   int index1,index2; /* dummy indices.           */\n   \n   *jstat = 0;\n   /* Legal value on ipar ? */\n   if (ipar < 0 || ipar > 3) goto err0;\n\t\t\t     \n   /* Check if pt1 and pt2 are already connected. */\n\n   sh6getlist(pt1,pt2,&index1,&index2,&kstat);\n   if(kstat < 0) goto err2;\n   if(kstat > 1) goto err1; /* Not connected. */\n\t\t /*\n\t\t if(pt1->iinter == SI_ORD)       pt1->iinter =  SI_SING;\n\t\t else if(pt1->iinter == -SI_ORD) pt1->iinter = -SI_SING;\n\t\t \n\t\t if(pt2->iinter == SI_ORD)       pt2->iinter =  SI_SING;\n\t\t else if(pt2->iinter == -SI_ORD) pt2->iinter = -SI_SING;\n\t\t */\n /* Set constant direction between pt1 and pt2. */\n   pt1->curve_dir[index1] |= (1<<(ipar+1));\n   pt2->curve_dir[index2] |= (1<<(ipar+1));\n\n   goto out;\n\n   /* Wrong value on ipar. */\nerr0:\n\n   *jstat = -3;\n   s6err(\"sh6setcnsdir\",*jstat,0);\n   goto out;\n\n   /* Points are not connected. */\nerr1:\n\n   *jstat = -1;\n   s6err(\"sh6setcnsdir\",*jstat,0);\n   goto out;\n\n   /* Error in subfuction. */\nerr2:\n\n   *jstat = -2;\n   s6err(\"sh6setcnsdir\",*jstat,0);\n   goto out;\n\n   out :\n      return;\n}\n\n"
  },
  {
    "path": "src/sh6setdir.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6setdir.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define SH6SETDIR\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n      sh6setdir(SISLIntpt *pt1,SISLIntpt *pt2,int *jstat)\n#else\nvoid sh6setdir(pt1,pt2,jstat)\n   SISLIntpt *pt1;\n   SISLIntpt *pt2;\n   int       *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Set the direction of the curve through pt1 and pt2 such\n*              that pt1 points to pt2.\n*              If they are not connected, give error.\n*\n*\n* INPUT      : pt1      - Pointer to first Intpt.\n*              pt2      - Pointer to second Intpt.\n*              jstat    - Error flag.\n*                        jstat =  0  => Successful\n*                        jstat = -1  => Points are not connected.\n*                        jstat = -2  => Error in subfunction.\n*\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. July 91.\n*********************************************************************\n*/\n{\n   int kstat;         /* error flag. */\n   int index1,index2; /* dummy indices.           */\n\n   *jstat = 0;\n\n   /* Check if pt1 and pt2 are already connected. */\n\n   sh6getlist(pt1,pt2,&index1,&index2,&kstat);\n   if(kstat < 0) goto err2;\n   if(kstat > 1) goto err1; /* Not connected. */\n\n   /* Set direction from pt1 to pt2. */\n\n   pt1->curve_dir[index1] |= 1;\n/*   pt2->curve_dir[index2]  = (-1 ^ 33); */\n   pt2->curve_dir[index2] = -31;\n   pt2->curve_dir[index2] |= pt1->curve_dir[index1];\n\n\n   goto out;\n\n   /* Points are not connected. */\nerr1:\n\n   *jstat = -1;\n   s6err(\"sh6setdir\",*jstat,0);\n   goto out;\n\n   /* Error in subfuction. */\nerr2:\n\n   *jstat = -2;\n   s6err(\"sh6setdir\",*jstat,0);\n   goto out;\n\n   out :\n      return;\n}\n\n"
  },
  {
    "path": "src/sh6setseg.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n#define SH6SETSEG\n\n#include \"sislP.h\"\n\f\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid sh6setseg(SISLSurf *ps, int idir, double *segmentation, int nseg,\n\t       int type, int *jstat)\n#else\n  void sh6setseg(ps, idir, segmentation, nseg, type, jstat)\n     SISLSurf *ps;\n     int idir;\n     double *segmentation;\n     int nseg;\n     int type;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : \n*\n*\n*\n* INPUT      : ps     - Surface to aquire segmentation information\n*              idir   - Parameter direction corresponding to segmentation\n*              segmentation - Segmentation parameter values\n*              nseg   - Number of segmentation values\n*              type   - Segmentation type\n*                                                                     \n*\n* OUTPUT     : jstat  - status messages  \n*                            = 1      : Tangential curve found\n*\t\t\t     = 0      : The curve is not tangential or\n*\t\t\t                do not end in corners\n*                            < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Vibeke Skytt, SINTEF, 2018-02\n*\n*********************************************************************\n*/                                     \n{\n  int kstat = 0;\n  int ki;\n  SISLSegmentation *pseg = NULL;    /* Current segmentation direction */\n  int *seg_type = NULL;\n\n  seg_type = newarray(nseg, INT);\n  if (seg_type == NULL)\n    goto error;\n  \n  for (ki=0; ki<nseg; ++ki)\n    seg_type[ki] = type;\n  pseg = (idir == 0) ? ps->seg1 : ps->seg2;\n  if (idir == 0 && ps->seg1 == NULL)\n    {\n      /* Create segmentation array */\n      ps->seg1 = newSegmentation(segmentation, seg_type, nseg);\n    }\n  else if (idir == 0)\n    {\n      /* Merge arrays */\n    }\n  if (idir == 1 && ps->seg2 == NULL)\n    {\n      /* Create segmentation array */\n      ps->seg2 = newSegmentation(segmentation, seg_type, nseg);\n    }\n  else /* if (idir == 1) */\n    {\n      /* Merge arrays */\n    }\n\n  *jstat = 0;\n  goto out;\n  \n error:\n  *jstat = kstat;\n  goto out;\n\n out:\n  if (seg_type != NULL) freearray(seg_type);\n\n  return;\n}\n"
  },
  {
    "path": "src/sh6settop.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6settop.c,v 1.2 2001-03-19 16:06:03 afr Exp $\n *\n */\n\n\n#define SH6SETTOP\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n      sh6settop(SISLIntpt *pt,int ilist,int left1,int right1,int left2,int right2,int *jstat)\n#else\nvoid sh6settop(pt,ilist,left1,right1,left2,right2,jstat)\n   SISLIntpt *pt;\n   int       ilist;\n   int       left1;\n   int       right1;\n   int       left2;\n   int       right2;\n   int       *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Given an Intpt and a list which it lies in, set the\n*              pre-topology information. If list does not\n*              exist give an error message.\n*\n*\n* INPUT      : pt       - Pointer to the Intpt.\n*              ilist    - Index specifying a list.\n*              left1    - pre-topology data.\n*              right1   - pre-topology data.\n*              left2    - pre-topology data.\n*              right2   - pre-topology data.\n*\n*\n* OUTPUT     : pt       - Pointer to the updated Intpt.\n*              jstat    - Error flag.\n*                         jstat =  0  => OK.\n*                         jstat = -1  => ilist is out of range.\n*                         jstat = -2  => Error.\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n*\n*********************************************************************\n*/\n{\n   *jstat=0;\n\n   /* Check pt. */\n\n   if(pt == SISL_NULL) goto err2;\n\n   /* Check ilist. */\n\n   if(ilist >= 0 && ilist < pt->no_of_curves)\n   {\n       pt->left_obj_1[ilist]=left1;\n       pt->right_obj_1[ilist]=right1;\n       pt->left_obj_2[ilist]=left2;\n       pt->right_obj_2[ilist]=right2;\n   }\n   else if(pt->no_of_curves == 0 && ilist == 0)\n   {\n       pt->left_obj_1[0]=left1;\n       pt->right_obj_1[0]=right1;\n       pt->left_obj_2[0]=left2;\n       pt->right_obj_2[0]=right2;\n   }\n   else if(ilist == -1)\n   {\n       pt->left_obj_1[0]=left1;\n       pt->right_obj_1[0]=right1;\n       pt->left_obj_2[0]=left2;\n       pt->right_obj_2[0]=right2;\n   }\n   else goto err1;\n\n\n   /* Data is set. */\n\n   goto out;\n   \n\nerr1:\n   /* Error. ilist is out of range. */\n   \n   *jstat = -1;\n   s6err(\"sh6settop\",*jstat,0);\n   goto out;\n\nerr2:\n   /* Error in input. pt is SISL_NULL. */\n   \n   *jstat = -2;\n   s6err(\"sh6settop\",*jstat,0);\n   goto out;\n   \n   \n   out :\n      return;\n}\n"
  },
  {
    "path": "src/sh6spltgeo.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6spltgeo.c,v 1.3 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n#define SH6SPLITGEOM\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void sh6splitgeom_s9circle(double [], double[], double[], double, \n\t\t\t\t  double[], double[], double *, int *);\n#else\nstatic void sh6splitgeom_s9circle();\n#endif\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n  sh6splitgeom (SISLSurf *ps1, SISLSurf *ps2, double aepsge, double ecentre[],\n\t\tdouble eaxis[], double *cdist, double *crad, int *jstat)\n#else\nvoid\nsh6splitgeom (ps1, ps2, aepsge, ecentre, eaxis, cdist, crad, jstat)\n   SISLSurf *ps1;\n   SISLSurf *ps2;\n   double aepsge;\n   double ecentre[];\n   double eaxis[];\n   double *cdist;\n   double *crad;\n   int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Find splitting geometry between two B-spline surfaces.\n*              The geometry object is either a plane, a sphere, a cylinder\n*              or a torus and is used to put between two surfaces to check \n*              if an intersection is possible.\n*\n*\n* INPUT      : ps1      - First surface.\n*              ps2      - Second surface.\n*              aepsge   - Geometry tolerance. \n*\n*\n* OUTPUT     : ecentre  - Centre of sphere/cylinder/torus or point in plane.\n*              eaxis    - Axis of cylinder/torus or plane normal.\n*              cdist    - Large radius of torus.\n*              crad     - Radius of sphere/cylinder or small radius of torus.\n*              jstat    - status messages\n*                                = 4   : A torus is found.\n*                                = 3   : A cylinder is found.\n*                                = 2   : A sphere is found.\n*                                = 1   : A plane is found.\n*                                = 0   : Ok. No splitting geometry is found.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      : s1421   -  Surface evaluator.\n*              s1773   -  Closest point between point and surface.\n*              s6ang   -  Angle between vectors.\n*              s6scpr  -  Scalar product between vectors.\n*              s6norm  -  Normalize vector.\n*              s6diff  -  Difference vector.\n*              s6dist  -  Distance between points. \n*\n* REFERENCES :\n*\n* WRITTEN BY : Vibeke Skytt, SI, 93-02.\n* CHANGED BY : Vibeke Skytt, SI, 93-05. New splits introduced.\n* CHANGED BY : Vibeke Skytt, SI, 93-05. New geometry introduced.\n*\n*********************************************************************\n*/\n{\n   int kstat = 0;         /* Status variable.       */\n   int ki,kj,k1,k2;       /* Counters.              */\n   int kleft1=0, kleft2=0; /* Parameters to surface evaluator. */\n   int kder=0;            /* Evaluate only position.           */\n   int kdim=ps1->idim;    /* Dimension of geometry space.      */\n   double tpi6=PI/(double)6;\n   double tsign;          /* Sign of vector.        */\n   double tdot;           /* Scalar product.        */\n   double tang;           /* Angle between vectors. */\n   double trad1, trad2;   /* Curvature radius.          */\n   double tmaxrad;        /* Maximum radius of sphere/torus/cylinder. */\n   double tminfac = (double)0.9; /* Minimum factor between radiuses \n\t\t\t\t    for a sphere. */\n   double spar1[2],spar2[2]; /* Paramater value in which to evaluate\n\t\t\t\tsurfaces.                         */\n   double sder1[18];      /* Value of 1. surface. */\n   double snorm1[3];      /* Normal of 1. surface.  */\n   double sder2[18];      /* Value of 2. surface. */\n   double snorm2[3];      /* Normal of 2. surface.  */\n   double scentre1[3];    /* Centre of first circle. */\n   double scentre2[3];    /* Centre of second circle. */\n   double svec[3];        /* Vector used to find midpoint of \n\t\t\t     splitting geometry.    */\n   double sdiff[3];       /* Difference vector between midpoints. */\n   double sparc1[10];      /* Corner parameters of first surface. */\n   double sparc2[10];      /* Parameters of closest points on second surface. */\n   double scorn1[15];     /* Corners of first surface.           */\n   double scorn2[15];     /* Closest points in the other surface. */\n   SISLPoint *qp = SISL_NULL;  /* Representing a surface corner as a point. */\n   double start2[2];      /* Start parameters of second surface.       */\n   double send2[2];       /* End parameters of second surface.       */\n   double sdist[4];       /* Distance between closest points.        */\n   \n   /* Test if the cones of the surfaces is less than pi, otherwise\n      no attempt to find splitting geometry is made.  */\n   \n   if (ps1->pdir->igtpi != 0 || ps2->pdir->igtpi != 0)\n   {\n      *jstat = 0;\n      goto out; \n   }\n   \n   /*   if (ps1->pdir->aang > tpi4 || ps2->pdir->aang > tpi4)\n   {\n    *jstat = 0;\n      goto out; \n   } */\n   \n   /* Make sure that the cones lies in the same area, otherwise\n      return.   */\n   \n   tdot = s6scpr(ps1->pdir->ecoef,ps2->pdir->ecoef,kdim);\n   tsign = (tdot >= DZERO) ? (double)1.0 : -(double)1.0;\n   \n   tang = s6ang(ps1->pdir->ecoef,ps2->pdir->ecoef,kdim);\n   if (tang > tpi6)\n   {\n      *jstat = 0;\n      goto out; \n   } \n   \n   /* Check that the surfaces is not too large, i.e. contain to many\n      vertices to be put into a sphere- or cylinder equation effectively. */\n   \n   if (ps1->in1 > 2*ps1->ik1 || ps1->in2 > 2*ps1->ik2 ||\n       ps2->in1 > 2*ps2->ik1 || ps2->in2 > 2*ps2->ik2)\n   {\n      *jstat = 0;\n      goto out; \n   } \n   \n   /* Compute the midvector between the axises of the surface cones. */\n   \n   for (ki=0; ki<kdim; ki++)\n      svec[ki] = (double)0.5*(tsign*ps1->pdir->ecoef[ki] + ps2->pdir->ecoef[ki]);\n   (void)s6norm(svec,kdim,svec,&kstat);\n   if (!kstat)\n   {\n      *jstat = 0;\n      goto out; \n   }\n   \n   /* Set maximum radius. */\n   \n   tmaxrad = ps1->pbox->e2max[2][0] - ps1->pbox->e2min[2][0];\n   tmaxrad = MAX(tmaxrad, ps1->pbox->e2max[2][1]-ps1->pbox->e2min[2][1]);\n   tmaxrad = MAX(tmaxrad, ps1->pbox->e2max[2][2]-ps1->pbox->e2min[2][2]);\n   tmaxrad *= (double)10.0;\n   \n   /* Set parameter bourders of second surface. */\n   \n   start2[0] = *(ps2->et1 + ps2->ik1 - 1);\n   start2[1] = *(ps2->et2 + ps2->ik2 - 1);\n   send2[0] = *(ps2->et1 + ps2->in1);\n   send2[1] = *(ps2->et2 + ps2->in2);\n   \n   /* Evaluate the surfaces in their midpoints up to 2. order\n      derivatives.                                             */\n   \n   spar1[0] = (double)0.5*(ps1->et1[ps1->ik1-1] + ps1->et1[ps1->in1]);\n   spar1[1] = (double)0.5*(ps1->et2[ps1->ik2-1] + ps1->et2[ps1->in2]);\n      \n   s1421(ps1,kder,spar1,&kleft1,&kleft2,sder1,snorm1,&kstat);\n   if (kstat < 0) goto error;\n   \n   spar2[0] = (double)0.5*(ps2->et1[ps2->ik1-1] + ps2->et1[ps2->in1]);\n   spar2[1] = (double)0.5*(ps2->et2[ps2->ik2-1] + ps2->et2[ps2->in2]);\n      \n   s1421(ps2,kder,spar2,&kleft1,&kleft2,sder2,snorm2,&kstat);\n   if (kstat < 0) goto error;\n   \n   /* Check if the difference vector between the midpoints point in \n      about the same direction as the vector svec.  */\n   \n   s6diff(sder1, sder2, kdim, sdiff);\n   tang = s6ang(sdiff, svec, kdim);\n   if (tang < tpi6 || tang > (double)5.0*tpi6)\n   {\n      /* Set up parameter values for evaluation of first surface in\n\t the midpoint and in the midpoints of each edge curve.       */\n      \n      memcopy(sparc1, spar1, 2, DOUBLE);\n      sparc1[3] = *(ps1->et2+ps1->ik2-1);\n      sparc1[4] = *(ps1->et1+ps1->in1);\n      sparc1[7] = *(ps1->et2+ps1->in2);\n      sparc1[8] = *(ps1->et1+ps1->ik1-1);\n      sparc1[2] = sparc1[6] = spar1[0];\n      sparc1[5] = sparc1[9] = spar1[1];\n      \n      for (ki=0; ki<5; ki++)\n      {\n\t /* Evaluate point.  */\n\t \n\t if (ki == 0)\n\t    memcopy(scorn1, sder1, kdim, DOUBLE);\n\t else\n\t {\n\t    s1421(ps1, 0, sparc1+2*ki, &kleft1, &kleft2, scorn1+ki*kdim,\n\t\t  snorm1, &kstat);\n\t    if (kstat < 0) goto error;\n\t }\n\t \n\t /* Find the closest point in the other surface. First express\n\t    the corner as a SISLPoint. */\n\t \n\t if ((qp = newPoint(scorn1+ki*kdim, kdim, 1)) == SISL_NULL) goto err101;\n\t s1773(qp, ps2, aepsge, start2, send2, spar2, sparc2+2*ki, &kstat);\n\t if (kstat < 0) goto error;\n\t \n\t /* Evaluate surface. */\n\t \n\t s1421(ps2, 0, sparc2+2*ki, &kleft1, &kleft2, scorn2+ki*kdim,\n\t       snorm2, &kstat);\n\t if (kstat < 0) goto error;\n\t \n\t /* Compute midpoint. */\n\n\t for (kj=0; kj<kdim; kj++)\n\t    scorn1[ki*kdim+kj] = (double)0.5*(scorn1[ki*kdim+kj] + scorn2[ki*kdim+kj]);\n\t    \n\t if (qp != SISL_NULL) freePoint(qp); qp = SISL_NULL;\n      }\n      \n      /* Estimate circles.  */\n      \n      sh6splitgeom_s9circle(scorn1+kdim, scorn1, scorn1+3*kdim,\n\t\t\t    aepsge, scentre1, snorm1, &trad1, &kstat);\n      if (kstat < 0) goto error;\n      if (kstat > 0)\n\t *jstat = 1;  /* Find plane. */\n\n      sh6splitgeom_s9circle(scorn1+4*kdim, scorn1, scorn1+2*kdim,\n\t\t\t    aepsge, scentre2, snorm2, &trad2, &kstat);\n      if (kstat < 0) goto error;\n      if (kstat > 0)\n\t *jstat = 1;  /* Find plane. */\n      \n      /* Find kind of splitting geometry.  */\n      \n      if (*jstat == 1 || (trad1 > tmaxrad && trad2 > tmaxrad))\n      {\n\t /* Set plane geometry. */\n\t \n\t *jstat = 1;\n\t memcopy(ecentre, scorn1, kdim, DOUBLE);\n\t s6diff(scorn1+2*kdim, scorn1, kdim, scorn1+2*kdim);\n\t s6diff(scorn1+3*kdim, scorn1, kdim, scorn1+3*kdim);\n\t s6crss(scorn1+2*kdim, scorn1+3*kdim, eaxis);\n      }\n      else if (MAX(trad1,trad2) > tmaxrad)\n      {\n\t /* Set cylinder geometry.  */\n\t \n\t *jstat = 3;\n\t *crad = MIN(trad1, trad2);\n\t if (trad1 < trad2)\n\t {\n\t    memcopy(ecentre, scentre1, kdim, DOUBLE);\n\t    memcopy(eaxis, snorm1, kdim, DOUBLE);\n\t }\n\t else\n\t {\n\t    memcopy(ecentre, scentre2, kdim, DOUBLE);\n\t    memcopy(eaxis, snorm2, kdim, DOUBLE);\n\t }\n      }\n      else if (MIN(trad1,trad2)/MAX(trad1,trad2) > tminfac)\n      {\n\t /* Set sphere geometry. */\n\t \n\t *jstat = 2;\n\t *crad = (double)0.5*(trad1 + trad2);\n\t for (kj=0; kj<kdim; kj++) \n\t    ecentre[kj] = (double)0.5*(scentre1[kj] + scentre2[kj]);\n      }\n      else if (MAX(trad1,trad2)/MIN(trad1,trad2) > (double)25.0)\n      {\n\t /* Little chance of success in interception. */\n\t \n\t *jstat = 0;\n\t goto out;\n      }\n      else\n      {\n\t /* Set torus geometry.  */\n\t \n\t *jstat = 4;\n\t *crad = MIN(trad1, trad2);\n\t *cdist = MAX(trad1, trad2) - (*crad);\n\t *crad = MIN(trad1, trad2);\n\t if (trad1 < trad2)\n\t {\n\t    memcopy(ecentre, scentre2, kdim, DOUBLE);\n\t    memcopy(eaxis, snorm2, kdim, DOUBLE);\n\t }\n\t else\n\t {\n\t    memcopy(ecentre, scentre1, kdim, DOUBLE);\n\t    memcopy(eaxis, snorm1, kdim, DOUBLE);\n\t }\n\t     \n      }\n   }\n   else if (tang > (double)2.0*tpi6 && tang < (double)4.0*tpi6)\n   {\n      /* Try to find a circle splitting the edge curves of the surfaces,\n\t and extend this circle to a cylinder. First find closest edgecurves\n\t by feching the corners of the first surface and finding the closest\n\t points in the other surface. */\n      \n      sparc1[6] = sparc1[0] = *(ps1->et1+ps1->ik1-1);\n      sparc1[2] = sparc1[4] = *(ps1->et1+ps1->in1);\n      sparc1[1] = sparc1[3] = *(ps1->et2+ps1->ik2-1);\n      sparc1[5] = sparc1[7] = *(ps1->et2+ps1->in2);\n      \n      for (ki=0; ki<4; ki++)\n      {\n\t /* Evaluate corner.  */\n\t \n\t s1421(ps1, 0, sparc1+2*ki, &kleft1, &kleft2, scorn1+ki*kdim,\n\t       snorm1, &kstat);\n\t if (kstat < 0) goto error;\n\t \n\t /* Find the closest point in the other surface. First express\n\t    the corner as a SISLPoint. */\n\t \n\t if ((qp = newPoint(scorn1+ki*kdim, kdim, 1)) == SISL_NULL) goto err101;\n\t s1773(qp, ps2, aepsge, start2, send2, spar2, sparc2+2*ki, &kstat);\n\t if (kstat < 0) goto error;\n\t \n\t /* Evaluate surface. */\n\t \n\t s1421(ps2, 0, sparc2+2*ki, &kleft1, &kleft2, scorn2+ki*kdim,\n\t       snorm2, &kstat);\n\t if (kstat < 0) goto error;\n\t \n\t /* Compute distance. */\n\t \n\t sdist[ki] = s6dist(scorn1+ki*kdim, scorn2+ki*kdim, kdim);\n\t \n\t if (qp != SISL_NULL) freePoint(qp); qp = SISL_NULL;\n      }\n      \n      /* Check if the two closest points lies on a common edge. */\n      \n      if (sdist[0] < MIN(sdist[1],sdist[2]) && \n\t  sdist[3] < MIN(sdist[1],sdist[2]))\n      {\n\t k1 = 0; k2 = 3;\n      }\n      else if (sdist[1] < MIN(sdist[0],sdist[3]) && \n\t       sdist[2] < MIN(sdist[0],sdist[3]))\n      {\n\t k1 = 1; k2 = 2;\n      }\n      else if (sdist[0] < MIN(sdist[2],sdist[3]) && \n\t       sdist[1] < MIN(sdist[2],sdist[3]))\n      {\n\t k1 = 0; k2 = 1;\n      }\n      else if (sdist[2] < MIN(sdist[0],sdist[1]) && \n\t       sdist[3] < MIN(sdist[0],sdist[1]))\n      {\n\t k1 = 2; k2 = 3;\n      }\n      else\n      {\n\t *jstat = 0;\n\t goto out;\n      }\n      \n      /* Compute closest point to the midpoint between the two closest\n\t corners.                                                       */\n      \n      sparc1[8] = (double)0.5*(sparc1[2*k1] + sparc1[2*k2]);\n      sparc1[9] = (double)0.5*(sparc1[2*k1+1] + sparc1[2*k2+1]);\n      \n      /* Evaluate point.  */\n      \n      s1421(ps1, 0, sparc1+8, &kleft1, &kleft2, scorn1+4*kdim,\n\t    snorm1, &kstat);\n      if (kstat < 0) goto error;\n      \n      /* Find the closest point in the other surface. First express\n\t the corner as a SISLPoint. */\n      \n      if ((qp = newPoint(scorn1+4*kdim, kdim, 1)) == SISL_NULL) goto err101;\n      s1773(qp, ps2, aepsge, start2, send2, spar2, sparc2+8, &kstat);\n      if (kstat < 0) goto error;\n      \n      if (qp != SISL_NULL) freePoint(qp); qp = SISL_NULL;\n      \n      /* Evaluate surface. */\n      \n      s1421(ps2, 0, sparc2+8, &kleft1, &kleft2, scorn2+4*kdim,\n\t    snorm2, &kstat);\n      if (kstat < 0) goto error;\n\n      /* Find middle points between the sets of closest points. */\n      \n      for (ki=0; ki<kdim; ki++)\n      {\n\t scorn1[k1*kdim+ki] = (double)0.5*(scorn1[k1*kdim+ki] + scorn2[k1*kdim+ki]);\n\t scorn1[k2*kdim+ki] = (double)0.5*(scorn1[k2*kdim+ki] + scorn2[k2*kdim+ki]);\n\t scorn1[4*kdim+ki] = (double)0.5*(scorn1[4*kdim+ki] + scorn2[4*kdim+ki]);\n      }\n      \n      /* Compute splitting cylinder. */\n      \n      sh6splitgeom_s9circle(scorn1+k1*kdim, scorn1+4*kdim, scorn1+k2*kdim,\n\t\t\t    aepsge, ecentre, eaxis, crad, &kstat);\n      if (kstat < 0) goto error;\n      if (kstat > 0 || *crad > tmaxrad)\n      {\n\t /* Make plane. */\n\t    \n\t *jstat = 1;\n\t memcopy(ecentre, scorn1+4*kdim, kdim, DOUBLE);\n\t s6diff(scorn1+k1*kdim, scorn1+4*kdim, kdim, scorn1+k1*kdim);\n\t s6diff(scorn1+k2*kdim, scorn1+4*kdim, kdim, scorn1+k2*kdim);\n\t s6crss(scorn1+k1*kdim, scorn1+k2*kdim, eaxis);\n      }\n      else\n\t \n\t /* Output cylinder. */\n\t \n\t *jstat = 3;\n   }\n   else *jstat = 0;\n   \n   goto out;\n   \n   err101 : *jstat = -101;\n   goto out;\n   \n   error : *jstat = kstat;\n   goto out;\n   \n   out :\n      return;\n}\n\n\n   \n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  sh6splitgeom_s9circle(double apt1[], double apt2[], double apt3[],\n\t\t\tdouble aepsge, double ecentre[], double eaxis[],\n\t\t\tdouble *crad, int *jstat)\n#else\n   static void sh6splitgeom_s9circle(apt1, apt2, apt3, aepsge, ecentre, eaxis,\n\t\t\t\t     crad, jstat)\n      double apt1[];\n      double apt2[];\n      double apt3[];\n      double aepsge;\n      double ecentre[];\n      double eaxis[];\n      double *crad;\n      int *jstat;\n#endif      \n/*\n*********************************************************************\n*\n* PURPOSE    : Compute the circle passing through 3 points in 3D, and\n*              the normal to the plane in which the cirle lies.\n*\n*\n* INPUT      : apt1   - First point on the circle.\n*              apt2   - Second point on the circle.\n*              apt3   - Third point on the circle.\n*              aepsge - Geometry tolerance.\n*              \n*\n* OUTPUT     : ecentre - Centre of the circle.\n*              eaxis   - Normal to the plane in which the circle lies.\n*              crad    - Radius of the circle.\n*              jstat   - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n* CALLS      : s6diff, s6crss, s6length, s6scpr, s6dist, s6lufacp, s6lusolp \n*\n*********************************************************************\n*/\n{\n   int kstat = 0;\n   int ki;\n   int kdim = 3;\n   int lpiv[3];\n   double snorm2[3];\n   double smid1[3];\n   double smid2[3];\n   double sdiff1[3];\n   double sdiff2[3];\n   double smat[9];\n   double sright[3];\n   \n   /* Compute difference vectors between the 1. and 2. and 2. and 3. point. */\n   \n   s6diff(apt1, apt2, kdim, sdiff1);\n   s6diff(apt3, apt2, kdim, sdiff2);\n   \n   /* Compute the normal of the plane in which the circle lies. */\n   \n   s6crss(sdiff1, sdiff2, snorm2);\n   \n   /* Compute the normals to the planes normal to the first plane and\n      perpendicular to the difference vectors. */\n   \n   /* s6crss(sdiff1, snorm2, snorm1);\n   s6crss(sdiff2, snorm2, snorm3); */\n   \n   /* Check normals.  */\n   \n   if (s6norm(snorm2, kdim, snorm2, &kstat) < aepsge) goto warn1;\n   \n   /* Compute the midpoints of the difference vectors. */\n   \n   for (ki=0; ki<kdim; ki++)\n   {\n      smid1[ki] = (double)0.5*(apt1[ki] + apt2[ki]);\n      smid2[ki] = (double)0.5*(apt2[ki] + apt3[ki]);\n   }\n   \n   /* Set up equation system.  */\n\n   memcopy(smat, snorm2, kdim, DOUBLE);\n   memcopy(smat+kdim, sdiff1, kdim, DOUBLE);\n   memcopy(smat+2*kdim, sdiff2, kdim, DOUBLE);\n   \n   sright[0] = s6scpr(apt2, snorm2, kdim);\n   sright[1] = s6scpr(smid1, sdiff1, kdim);\n   sright[2] = s6scpr(smid2, sdiff2, kdim);\n   \n   /* Solve equation system.  */\n   \n   s6lufacp(smat, lpiv, 3, &kstat);\n   if (kstat < 0) goto error;\n   \n   s6lusolp(smat, sright, lpiv, 3, &kstat);\n   if (kstat < 0) goto error;\n   \n   /* Prepare output.  */\n   \n   memcopy(eaxis, snorm2, kdim, DOUBLE);\n   memcopy(ecentre, sright, kdim, DOUBLE);\n   *crad = s6dist(ecentre, apt2, kdim);\n   \n   *jstat = 0; \n   goto out;\n   \n   /* Almost singular equation system.  */\n   \n   warn1 :\n      *jstat = 1;\n   goto out;\n   \n   /* Error in lower level routine.  */\n   \n   error :\n      *jstat = kstat;\n   goto out;\n   \n   out :\n      return;\n}\n      \n"
  },
  {
    "path": "src/sh6tohelp.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6tohelp.c,v 1.2 2001-03-19 16:06:04 afr Exp $\n *\n */\n\n\n#define SH6TOHELP\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n      sh6tohelp(SISLIntpt *pt,int *jstat)\n#else\nvoid sh6tohelp(pt,jstat)\n   SISLIntpt *pt;\n   int       *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Check if pt is a mai point. If it is, transform to\n*              help point, if not give a message.\n*\n*\n* INPUT      : pt       - Pointer to the Intpt.\n*\n*\n* OUTPUT     : pt       - Pointer to the updated Intpt.\n*              jstat    - Error flag.\n*                         jstat =  0  => pt was a main point, now help.\n*                         jstat =  1  => pt is not a main point.\n*                         jstat = -1  => Error in pt.\n*                         jstat = -2  => Illegal to convert status\n*                         jstat = -3  => Error in data structure.\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n*\n*********************************************************************\n*/\n{\n   int kstat; /* Local status */\n   int num; \n\n   *jstat=0;\n\n   if(pt == SISL_NULL) goto err1;\n\n   if(sh6ismain(pt))  /* If pt is a help point. */\n   {\n      /* ??????????? */\n      /* if(pt->no_of_curves > 2) goto err2; */\n      \n      num=sh6nmbmain(pt,&kstat);\n      /* Problem in sh6edgred when starting reduction */\n      /* if(num > 1) goto err2; */\n\n       pt->iinter = -pt->iinter;  /* Convert status to main point. */\n   }\n   else\n   {\n       *jstat=1;\n   }\n\n   goto out;\n   \n\nerr1:\n   /* Error in input. pt is null. */\n   \n   *jstat = -1;\n   s6err(\"sh6tohelp\",*jstat,0);\n   goto out;\n   \n   /* Error, Illegal to change status. */\n   \n   /* err2:\n    *jstat = -2;\n   s6err(\"sh6tohelp\",*jstat,0);\n   goto out; */\n   \n   \n   out :\n      return;\n}\n"
  },
  {
    "path": "src/sh6tomain.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6tomain.c,v 1.2 2001-03-19 16:06:04 afr Exp $\n *\n */\n\n\n#define SH6TOMAIN\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n      sh6tomain(SISLIntpt *pt,int *jstat)\n#else\nvoid sh6tomain(pt,jstat)\n   SISLIntpt *pt;\n   int       *jstat;\n#endif   \n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Check if pt is a help point. If it is, transform to\n*              main point, if not give a message.\n*\n*\n* INPUT      : pt       - Pointer to the Intpt.\n*\n*\n* OUTPUT     : pt       - Pointer to the updated Intpt.\n*              jstat    - Error flag.\n*                         jstat =  0  => pt was a help point, now main.\n*                         jstat =  1  => pt is not a help point.\n*                         jstat = -1  => Error in pt.\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Michael Floater, SI, Oslo, Norway. June 91.\n* MODYFIED BY: UJK, SI, Oslo, Norway. September 91.\n*********************************************************************\n*/\n{\n   int ki; /* Loop variable. */\n   int num; \n   int kstat;\n   \n   *jstat=0;\n\n   if(pt == SISL_NULL) goto err1;\n\n   if(sh6ishelp(pt))  /* If pt is a help point. */\n   {\n       pt->iinter = -pt->iinter;  /* Convert status to main point. */\n\n       /* Go through all neighbours and keep invariant:\n\t  not more than one mainpoint connected to a help point. */\n       for(ki=0; ki<pt->no_of_curves; ki++) \n       {\n\t   if(sh6ishelp(pt->pnext[ki]))\n\t   {\n\t      /* UJK, change all NON-terminators to main */\n\t      /* num=sh6nmbmain(pt->pnext[ki],&kstat); */\n\t       num = pt->pnext[ki]->no_of_curves;\n\t       if(num > 1) sh6tomain(pt->pnext[ki],&kstat);\n\t   }\n       }\n       pt->fromhelp++;\n   }\n   else\n   {\n       *jstat=1;\n   }\n\n   goto out;\n   \n\nerr1:\n   /* Error in input. pt is null. */\n   \n   *jstat = -1;\n   s6err(\"sh6tomain\",*jstat,0);\n   goto out;\n   \n   \n   out :\n      return;\n}\n"
  },
  {
    "path": "src/sh6topohlp.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6topohlp.c,v 1.2 2001-03-19 16:06:04 afr Exp $\n *\n */\n\n\n#define SH6GETTOPHLP\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6gettophlp (SISLIntpt * pt, int pretop[4], int case_2d, int *jstat)\n#else\nvoid\nsh6gettophlp (pt, pretop, case_2d, jstat)\n     SISLIntpt *pt;\n     int pretop[4];\n     int case_2d;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Get pre-topology information, by traversing all help\n*              points connected in a network.\n*\n*\n* INPUT      : pt       - Pointer to the Intpt.\n*\n* INPUT/OUTPUT:\n*              pretop   - pre-topology data.\n*              case_2d  - flage 2d surf point.\n* OUTPUT     : pt       - Pointer to the Intpt.\n*              jstat    - Error flag.\n*                         jstat =  0  => OK.\n*                         jstat = -2  => Error.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : UJK, SI, Oslo, Norway. October 91.\n*\n*********************************************************************\n*/\n{\n  int loc_top[4];\n  int ki;\n\n  *jstat = 0;\n\n/* Check pt. */\n\n  if (pt == SISL_NULL)\n    goto err2;\n/* Only help points are treated */\n  if (sh6ishelp (pt) && pt->marker == 0)\n    {\n      /* To avoid infinite loops : */\n      pt->marker = -10;\n\n      sh6gettop (pt, 0, loc_top, loc_top + 1, loc_top + 2, loc_top + 3, jstat);\n      if (*jstat < 0)\n\tgoto out;\n\n      if (case_2d)\n      {\n\t /* Spesial treatment 2D surf point */\n\t for (ki=0; ki<4; ki++)\n\t    if (loc_top[ki] == SI_IN) pretop[ki] = SI_IN;\n\t    else if (loc_top[ki] == SI_OUT && pretop[ki] != SI_IN)\n\t       pretop[ki] = SI_OUT;\n      }\n      else\n      {\n\t /* Overrule ? */\n\t for (ki = 0; ki < 4; ki++)\n\t    if ((pretop[ki] == SI_UNDEF ||\n\t\t pretop[ki] == SI_ON) &&\n\t\tloc_top[ki] != SI_UNDEF &&\n\t\tloc_top[ki] != SI_ON)\n\t       pretop[ki] = loc_top[ki];\n      }\n      \n      for (ki = 0; ki < pt->no_of_curves; ki++)\n\tsh6gettophlp (pt->pnext[ki],  pretop, case_2d, jstat);\n\n      /* Data is set. */\n\n    }\n\n\n  goto out;\n\n\nerr2:\n  /* Error in input. pt is SISL_NULL. */\n\n  *jstat = -2;\n  s6err (\"sh6gettophlp\", *jstat, 0);\n  goto out;\n\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/sh6trmlist.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh6trmlist.c,v 1.2 2001-03-19 16:06:04 afr Exp $\n *\n */\n\n\n#define SH6TRIMLIST\n\n#include \"sislP.h\"\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh6trimlist (SISLIntpt * pt, SISLIntpt *** ptlist, int *no_of_points,\n\t     int *no_alloc)\n#else\nvoid\nsh6trimlist (pt, ptlist, no_of_points, no_alloc)\n     SISLIntpt *pt;\n     SISLIntpt ***ptlist;\n     int *no_of_points;\n     int *no_alloc;\n\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To find the maximal trim boundary (of coincidence)\n*              containg the given point pt.\n*\n*\n* INPUT      : pt            - Pointer to int point to be examined\n*\n*\n* INPUT/OUTP:  ptlist        - Pointer to an array containing\n*                              pointers to all intersection points\n*                              that are contigous trim neighbours.\n*               no_of_points - Number of points in ptlist array\n*               no_alloc     - Allocation size of ptlist array\n* OUTPUT     :\n*              jstat     - Error flag.\n*                         jstat =  0  => OK.\n*                         jstat = -1  => Data structure inconsistent.\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, Oslo, Norway. October 91.\n*\n*********************************************************************\n*/\n{\n  int clean_up = FALSE;\t\t/* Clean up on top level */\n  int incr = 20;\t\t/* Allocation size       */\n  int ki;\t\t\t/* Loop control          */\n  /* --------------------------------------------------- */\n\n\n  /* Check if point is a TRIM point */\n  if (pt->iinter != SI_TRIM)\n    goto out;\n\n  /* Check if point is treated */\n  if (pt->marker == -90)\n    goto out;\n\n  /* Mark point as treated */\n  pt->marker = -90;\n\n\n  if (*no_alloc <= *no_of_points)\n    {\n      if (*no_alloc == 0)\n\t{\n\t  clean_up = TRUE;\n\t  (*no_alloc) += incr;\n\t  *ptlist = newarray (*no_alloc, SISLIntpt *);\n\t  if (*ptlist == SISL_NULL)\n\t    goto out;\n\t}\n      else\n\t{\n\t  clean_up = FALSE;\n\t  (*no_alloc) += incr;\n\t  *ptlist = increasearray (*ptlist, *no_alloc, SISLIntpt *);\n\t  if (*ptlist == SISL_NULL)\n\t    goto out;\n\t}\n    }\n\n  /* Fill in */\n  (*ptlist)[*no_of_points] = pt;\n  (*no_of_points)++;\n\n  /* Treat all neighbours */\n  for (ki = 0; ki < pt->no_of_curves; ki++)\n    sh6trimlist (pt->pnext[ki], ptlist, no_of_points, no_alloc);\n\n\n/* Must unmark the points in array if no_alloc == 0 */\n  if (clean_up)\n    for (ki = 0; ki < (*no_of_points); ki++)\n      (*ptlist)[ki]->marker = 0;\n\n  goto out;\n\n\nout:\n  return;\n}\n"
  },
  {
    "path": "src/sh_1d_div.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh_1d_div.c,v 1.2 2001-03-19 16:06:04 afr Exp $\n *\n */\n\n\n#define SH_1D_DIV\n\n#include \"sislP.h\"\n\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n\n#if defined(SISLNEEDPROTOTYPES)\nstatic void sh_1d_div_sh9idnpt(SISLSurf*, SISLPoint*,SISLIntdat **,\n\t\t\t       SISLIntpt **,int, double,int *);\n#else\nstatic void sh_1d_div_sh9idnpt();\n#endif\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n  sh_1d_div (SISLObject *po1, SISLObject *po2, double aepsge,\n\t     SISLIntdat **pintdat,  SISLEdge * vedge[], int *jstat)\n#else\nvoid \n   sh_1d_div (po1, po2, aepsge, pintdat, vedge, jstat)\n   SISLObject *po1; \n   SISLObject *po2; \n   double aepsge;\n   SISLIntdat **pintdat;\n   SISLEdge * vedge[];\n   int *jstat;\n#endif\n/*\n********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE     :To check if we can subdivide a 1D surface problem\n*              by a factorization method.\n*\n*\n*\n*\n* INPUT      : po1          - Pointer to surface object.\n*              po2          - Pointer to point object.\n*              aepsge       - Geometry tolerance.\n*              vedge[2]  - Pointers to structure of edge-intersections.\n*\n*\n* INPUT/OUTPUT : pintdat - Pointer to intersection data.\n*\n* OUTPUT     : jstat     - status messages\n*                                           1      : Factorization done\n*                                                    together with intersection.\n*                                         = 0      : No factorization.\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*              \n*\n* WRITTEN BY : Ulf J. Krystad, SI, 92-12.\n* MODIFIED BY :\n*\n**********************************************************************/\n{\n\n   int kant;                    /* Number of parameter directions          */\n   int cv_dir_1, cv_dir_2;      /* Locals for curve_dir                    */\n   int ind1, ind2;              /* Locals indexes                          */\n   int kpos = 0;\t\t/* Position of error.                      */\n   int kstat = 0;\t\t/* Local error status.                     */\n   int knum;                    /* Number of intersection pts on edge      */              \n   int knum2;                   /* Number of intersection pts in corners   */              \n   int which_end_1=-1;          /* Branch paraeter fro zero edge.          */\n   int which_end_2=-1;          /* Branch paraeter fro zero edge.          */\n   int kn, kj, ki;              /* Loop control                            */\n   int edge_1=0, edge_2=0;      /* No of pts in pt_arr_1[2]                */\n   int alloc_1=0, alloc_2=0;    /* Size of pt_arr_1[2]                     */\n   SISLIntpt *pcurr = SISL_NULL;\t/* Array of poiners to int points.         */\n   SISLIntpt **uintpt = SISL_NULL;\t/* Array of poiners to int points.         */\n   SISLIntpt **up = SISL_NULL;\t/* Array of poiners to edge int points.    */\n   SISLIntpt **pt_arr_1 = SISL_NULL;\t/* Array of poiners to ZERO edge.          */\n   SISLIntpt **pt_arr_2 = SISL_NULL;\t/* Array of poiners to ZERO edge.          */\n   SISLIntpt **up2 = SISL_NULL;\t/* Array of poiners to corner int points.  */\n   SISLIntdat *qintdat = SISL_NULL;\t/* Data structure of sub inters problem    */\n   SISLObject *qo1 = SISL_NULL;      /* Pointer to surface in\n\t\t\t\t   object/point intersection. */\n   double *nullp = SISL_NULL;\n   /* ____________________________________________________________________ */\n\n   *jstat = 0;\n   \n   /* Check input */\n   if (po1->iobj != SISLSURFACE) goto err150;\n   if (po1->s1->idim != 1) goto err150;\n   \n   /* Bezier case ? */\n   if (po1->s1->ik1 != po1->s1->in1 ||\n       po1->s1->ik2 != po1->s1->in2) goto out;\n\n   if (po1->s1->ik1 < 3 ||\n       po1->s1->ik2 < 3 ) goto out;\n   \n   sh6edgpoint (vedge, &up, &knum, &kstat);\n   if (kstat < 0)\n      goto error;\n   if (knum < 2) goto out;\n   \n   /* Find corner points */\n   /* Allocate an array for intersection points. */\n   if ((up2= newarray (knum, SISLIntpt *)) == SISL_NULL)\n      goto err101;\n   \n   for (knum2=ki=0;ki<knum;ki++)\n   {\n      sh6isinside (po1, po2, up[ki], &kstat);\n      if (kstat < 0 ) goto error;\n      \n      if (kstat == 3)\n      {\n\t up2[knum2] = up[ki];\n\t knum2++;\n      }\n   }\n   \n   if (knum2 < 2) goto out;\n   \n   /* Find connections */\n   for (ki=0;ki<knum2-1;ki++)\n      for (kj=1;kj<knum2;kj++)\n      {\n\t sh6comedg (po1, po2, up2[ki], up2[kj], &kstat);\n\t if (kstat < 0) goto error;\n\t \n\t if (kstat == 1)\n\t {\n\t    /* One edge is zero, find which */\n\t    if (DEQUAL(up2[ki]->epar[0], up2[kj]->epar[0]))\n\t    {\n\t       \n\t       /* Store the two corner points (sorted). */\n\t       if (alloc_1 == 0)\n\t       {\n\t\t  alloc_1 = 10;\n\t\t  if((pt_arr_1 = newarray(alloc_1,SISLIntpt *))\n\t\t     == SISL_NULL) goto err101;\n\t       }\n\t       edge_1 = 2;\n\t       if (up2[ki]->epar[1] < up2[kj]->epar[1])\n\t       {\t\t   \n\t\t  pt_arr_1[0] = up2[ki];\n\t\t  pt_arr_1[1] = up2[kj];\n\t       }\n\t       else\n\t       {\t\t   \n\t\t  pt_arr_1[1] = up2[ki];\n\t\t  pt_arr_1[0] = up2[kj];\n\t       }\n\t       \n\t       if (DEQUAL(up2[ki]->epar[0],po1->s1->et1[0]))\n\t\t  which_end_1 = 0;\n\t       else\n\t\t  which_end_1 = 1;\n\t    }\n\t    else\n\t    {\n\t       \n\t       /* Store the two corner points (sorted). */\n\t       if (alloc_2 == 0)\n\t       {\n\t\t  alloc_2 = 10;\n\t\t  if((pt_arr_2 = newarray(alloc_2,SISLIntpt *))\n\t\t     == SISL_NULL) goto err101;\n\t       }\n\t       edge_2 = 2;\n\t       if (up2[ki]->epar[0] < up2[kj]->epar[0])\n\t       {\t\t   \n\t\t  pt_arr_2[0] = up2[ki];\n\t\t  pt_arr_2[1] = up2[kj];\n\t       }\n\t       else\n\t       {\t\t   \n\t\t  pt_arr_2[1] = up2[ki];\n\t\t  pt_arr_2[0] = up2[kj];\n\t       }\n\t       \n\t       if (DEQUAL(up2[ki]->epar[1],po1->s1->et2[0]))\n\t\t  which_end_2 = 0;\n\t       else\n\t\t  which_end_2 = 1;\n\t    }\n\t    \n\t }\n      }\n   \n   if (which_end_1 >=0 || which_end_2 >=0)\n   {\n      \n      /*\n      * Create new object and create surface to object.\n      * ------------------------------------------------\n      */\n      \n      if (!(qo1 = newObject (SISLSURFACE)))\n\t goto err101;\n      qo1->s1 = SISL_NULL;\n      qo1->o1 = qo1;\n      \n      /* Filter coefficients less than aepsge. */\n      for (ki=0; ki< po1->s1->in1*po1->s1->in2;ki++)\n\t if ( fabs(po1->s1->ecoef[ki]-po2->p1->ecoef[0]) < aepsge)\n\t    po1->s1->ecoef[ki] = po2->p1->ecoef[0];\n      \n      sh_div_surf(po1->s1,which_end_1, which_end_2, aepsge, &qo1->s1, &kstat);\n      if (kstat < 0) goto error;\n      \n      sh1761 (qo1, po2, aepsge, &qintdat, &kstat);\n      if (kstat < 0)\n\t goto error;\n      \n      /* UJK, JUNE 93: start____________ */\n      if (qintdat)\n      {\n\t \n\t /* Kill all help.pts. */\n\t for (ki = 0; ki < qintdat->ipoint; ki++)\n\t {\n\t    pcurr = qintdat->vpoint[ki];\n\t    if(sh6ishelp(pcurr))\n\t    {\n\t       sh6idkpt (&qintdat, &pcurr, 0, &kstat);\n\t       if (kstat < 0) goto error;\n\t       ki--;\n\t    }\n\t }\n      }\n      /* UJK, JUNE 93: end____________ */\n      \n      if (qintdat)\n      {\n\t /* Intersection found, transfere it to pintdat. */\n\t \n\t /* Number of parameter direction. */\n\t kant = qintdat->vpoint[0]->ipar;\n\t \n\t /* Allocate an array for intersection points. */\n\t if ((uintpt = newarray (qintdat->ipoint, SISLIntpt *)) == SISL_NULL)\n\t    goto err101;\n\t \n\t /* Copy all intersection points. */\n\t for (ki = 0; ki < qintdat->ipoint; ki++)\n\t {\n\t    \n\t    uintpt[ki] = hp_newIntpt (kant,  \n\t\t\t\t      qintdat->vpoint[ki]->epar, \n\t\t\t\t      qintdat->vpoint[ki]->adist,\n\t\t\t\t      qintdat->vpoint[ki]->iinter,\n\t\t\t\t      qintdat->vpoint[ki]->left_obj_1[0],\n\t\t\t\t      qintdat->vpoint[ki]->right_obj_1[0],\n\t\t\t\t      qintdat->vpoint[ki]->left_obj_2[0],\n\t\t\t\t      qintdat->vpoint[ki]->right_obj_2[0],\n\t\t\t\t      0, 0,\n\t\t\t\t      nullp, nullp);\n\t    \n\t    if (uintpt[ki] == SISL_NULL)\n\t       goto err101;\n\t }\n\t \n\t /* Insert all new intersection points in rintdat. */\n\n\t for (ki = 0; ki < qintdat->ipoint; ki++)\n\t {\n\t    sh_1d_div_sh9idnpt (po1->o1->s1,po2->p1,pintdat, &uintpt[ki], 1,aepsge,\n\t\t\t\t&kstat);\n\t    if (kstat < 0)\n\t       goto error;\n\t }\n\n\t \n\t /* Insert points on edges divided out/(splitting strategy. */\n\t for (ki = 0; ki < qintdat->ipoint; ki++)\n\t {\n\t    if (which_end_1 >=0 &&\n\t\tDEQUAL(uintpt[ki]->epar[0], pt_arr_1[0]->epar[0]) &&\n\t\tDEQUAL(uintpt[ki]->epar[0], pt_arr_1[1]->epar[0]))\n\t    {\n\t       for (kj=0; kj < edge_1 - 1; kj++)\n\t\t  if (uintpt[ki]->epar[1] > pt_arr_1[kj]->epar[1] &&\n\t\t      uintpt[ki]->epar[1] < pt_arr_1[kj+1]->epar[1])\n\t\t  {\n\t\t     sh6insertpt(pt_arr_1[kj],pt_arr_1[kj+1],uintpt[ki],&kstat);\n\t             if (kstat < 0) goto error;\n\t\t     if (edge_1 >= alloc_1)\n\t\t     {\n\t\t\talloc_1 += 10;\n\t\t\tif ((pt_arr_1 = \n\t\t\t     increasearray(pt_arr_1,alloc_1,SISLIntpt *))\n\t\t\t    == SISL_NULL) goto err101;\n\t\t     }\n\t\t     \n\t\t     for (kn = edge_1; kn > kj+1; kn--)\n\t\t\tpt_arr_1[kn] = pt_arr_1[kn-1];\n\t\t     pt_arr_1[kj+1] = uintpt[ki];\n\t\t     edge_1++;\n\t\t     \n\t\t     break;\n\t\t  }\n\t    }\n\t    else if (which_end_2 >=0 &&\n\t\tDEQUAL(uintpt[ki]->epar[1], pt_arr_2[0]->epar[1]) &&\n\t\tDEQUAL(uintpt[ki]->epar[1], pt_arr_2[1]->epar[1]))\n\t    {\n\t       for (kj=0; kj < edge_2 - 1; kj++)\n\t\t  if (uintpt[ki]->epar[0] > pt_arr_2[kj]->epar[0] &&\n\t\t      uintpt[ki]->epar[0] < pt_arr_2[kj+1]->epar[0])\n\t\t  {\n\t\t     sh6insertpt(pt_arr_2[kj],pt_arr_2[kj+1],uintpt[ki],&kstat);\n\t             if (kstat < 0) goto error;\n\t\t     if (edge_2 >= alloc_2)\n\t\t     {\n\t\t\talloc_2 += 10;\n\t\t\tif ((pt_arr_2 = \n\t\t\t     increasearray(pt_arr_2,alloc_2,SISLIntpt *))\n\t\t\t    == SISL_NULL) goto err101;\n\t\t     }\n\t\t     \n\t\t     for (kn = edge_2; kn > kj+1; kn--)\n\t\t\tpt_arr_2[kn] = pt_arr_2[kn-1];\n\t\t     pt_arr_2[kj+1] = uintpt[ki];\n\t\t     edge_2++;\n\t\t     \n\t\t     break;\n\t\t  }\n\t    }\n\t    \n\t }\t      \n\t    \n\t    \n\t /* Transform the connections. */\n\t for (ki = 0; ki < qintdat->ipoint; ki++)\n\t {\n\t    for (kj = ki + 1; kj < qintdat->ipoint; kj++)\n\t    {\n\t       sh6getlist (qintdat->vpoint[ki], qintdat->vpoint[kj],\n\t\t\t   &ind1, &ind2, &kstat);\n\t       if (kstat < 0)\n\t\t  goto error;\n\t       if (kstat == 0 && uintpt[kj] != uintpt[ki])\n\t       {\n                  cv_dir_1 = qintdat->vpoint[ki]->curve_dir[ind1];\n                  cv_dir_2 = qintdat->vpoint[kj]->curve_dir[ind2];\n\n\t\t  sh6idcon (pintdat, &uintpt[ki], &uintpt[kj], &kstat);\n\t\t  if (kstat < 0)\n\t\t    goto error;\n\t       \n\t\t  sh6getlist (uintpt[ki], uintpt[kj],\n\t\t\t   &ind1, &ind2, &kstat);\n\t\t  if (kstat != 0) goto error;\n\t\t  uintpt[ki]->curve_dir[ind1] |= cv_dir_1;\n\t\t  uintpt[kj]->curve_dir[ind2] |= cv_dir_2;\n\t\t  \n\t       }\n\t    }\n\t    \n\t    if (sh6ismain (qintdat->vpoint[ki]) &&\n\t\tsh6nmbmain (qintdat->vpoint[ki], &kstat))\n\t    {\n\t       sh6tomain (uintpt[ki], &kstat);\n\t       if (kstat < 0)\n\t\t  goto error;\n\t    }\n\t }\n\t \n\t /* Remains splitting of zero curves inside edges ! */\t \n\t \n      }\n\n      *jstat = 1;\n    }\n   \n   \n   \n   goto out;\n   /* ______________ ERROR EXITS ______________________________ */\n/* Lower level problem. */\nerror:\n   *jstat = kstat;\n   s6err(\"sh_1d_div\",*jstat,kpos);\n   goto out;\n   \n/* Space problem. */\nerr101:\n   *jstat = -101;\n   s6err(\"sh_1d_div\",*jstat,kpos);\n   goto out;\n   \n/* Input wrong. */\nerr150:\n   *jstat = -150;\n   s6err(\"sh_1d_div\",*jstat,kpos);\n   goto out;\n\n\nout:\n   if (uintpt) freearray(uintpt);\n   if (up) freearray(up);\n   if (up2) freearray(up2);\n   if (pt_arr_1) freearray(pt_arr_1);\n   if (pt_arr_2) freearray(pt_arr_2);\n   if (qo1)\n      freeObject (qo1);\n   if (qintdat)\n      freeIntdat (qintdat);\n }\n\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void \n  sh_1d_div_sh9idnpt(SISLSurf* surf, SISLPoint* point, SISLIntdat **pintdat,\n\t\t     SISLIntpt **pintpt, int itest, double aepsge, int *jstat)\n#else\nstatic void\n  sh_1d_div_sh9idnpt(surf,point,pintdat,pintpt,itest, aepsge, jstat)\n     SISLSurf* surf;\n     SISLPoint* point;\n     SISLIntdat **pintdat;\n     SISLIntpt  **pintpt;\n     int    itest;\n     double aepsge;\n     int    *jstat;\n#endif   \n\n\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To insert a new intersection point into pintdat.\n*              If pintdat is SISL_NULL a new pintdat is also made.\n*              If pintpt is close to an other intersection point\n*              the object pintpt is pointing to is freed, and\n*              pintpt is set to point to the already inserted point.\n*\n*\n*\n* INPUT      : pintpt   - Pointer to a pointer to new intersection point.\n*              pintdat  - Pointer to a pointer to intersection data.\n*              itest    - Indikate testing equalety.\n*                               = 1      : Testing.\n*                               = 0      : No testing.\n*              surf\t- pointer to the surface object in the intersection\n*              point    - pointer to the point object in the intersection\n*              aepsge  -  Resolution in space.\n*\n*\n* OUTPUT     : jstat  - status messages  \n*                               = 2      : Already existing.\n*                               = 1      : Already inserted.\n*                               = 0      : Intersection point inserted.\n*                               < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err      - Gives error message.\n*              newIntdat  - Create new intdat structure.\n*              freeIntpt  - free instant of intpt structure.\n*\n* WRITTEN BY : Michael Floater, June 91.\n* REVISED BY : Kyrre Stroem, Jan-93.\n*\n*********************************************************************\n*/                                     \n{\n  register int ki;              /* Counters.    */\n  double eps_ball_par;\n  int kstat;\n  \n  /* We have to be sure that we have an intdat structure. */\n  \n  if ((*pintdat) == SISL_NULL)\n    {\n      if (((*pintdat) = newIntdat()) == SISL_NULL) goto err101;\n    }\n  \n  \n  /* Then we have to be sure that we do not have the intersection point\n     before or an equal point. */\n  \n  for (ki=0; ki<(*pintdat)->ipoint; ki++)\n    if ((*pintdat)->vpoint[ki] == (*pintpt))\n      {\n\t*jstat = 1;\n\tgoto out;\n      }\n    else if (itest)\n      {\n\teps_ball_par = surf->et1[surf->in1]- surf->et1[surf->ik1];\n\teps_ball_par = max(eps_ball_par,\n\t\t\t   surf->et2[surf->in2]- surf->et2[surf->ik2])+1;\n\teps_ball_par *= 1e-6;\n\n\ts6identify(surf,(*pintpt)->epar,\n\t\t   (*pintdat)->vpoint[ki]->epar,\n\t\t   point->ecoef[0],eps_ball_par,aepsge,&kstat);\n\tif (kstat < 0 ) goto error;\n\tif (kstat == 1 ) \n\t  {\n\t    freeIntpt(*pintpt);\n\t    (*pintpt) = (*pintdat)->vpoint[ki];\n\t    *jstat = 2;\n\t    goto out;\n\t  }\n      }\n  \n  \n  /* Then we have to be sure that the array vpoint is great enough. */\n  \n  if (ki == (*pintdat)->ipmax)\n    {\n      (*pintdat)->ipmax += 20;\n      \n      if (((*pintdat)->vpoint = increasearray((*pintdat)->vpoint,\n\t\t\t\t\t      (*pintdat)->ipmax,SISLIntpt *)) == SISL_NULL) \n\tgoto err101;\n    }\n  \n  \n  /* Now we can insert the new point. */\n  \n  (*pintdat)->vpoint[ki] = (*pintpt);\n  (*pintdat)->ipoint++;\n  *jstat = 0;\n  goto out;\n  \n\n/* Error in space allocation.  */\n\nerr101: *jstat = -101;\n        s6err(\"sh_1d_div_sh9idnpt\",*jstat,0);\n        goto out;\nerror: *jstat = kstat;\n        s6err(\"sh_1d_div_sh9idnpt\",*jstat,0);\n        goto out;\n\n out: ;\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
  },
  {
    "path": "src/sh_div_crv.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh_div_crv.c,v 1.2 2001-03-19 16:06:04 afr Exp $\n *\n */\n\n\n#define SH_DIV_CRV\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n    sh_div_crv (SISLCurve * pc, int which_end, double aepsge, SISLCurve ** rcnew, int *jstat)\n#else\nvoid \n   sh_div_crv (pc, which_end, aepsge, rcnew, jstat)\n     SISLCurve *pc;\n     int which_end;\n     double aepsge;\n     SISLCurve **rcnew;\n     int *jstat;\n#endif\n/*\n********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE     :To factorize a bezier curve J(x) over the interval [a,b]\n*              into \n*              oldcurve = (x-a)/(b-a)*newcurve \n*              when which_end eq 0   (requires C0 = 0)\n*                 and\n*              oldcurve = (b-x)/(b-a)*newcurve \n*              when which_end eq 1   (requires Cn = 0).\n*\n*\n*\n*\n* INPUT      : pc           - Oldcurve to factorize.\n*              which_end     - Branch parameter for zero point.\n*              aepsge       - Geometry tolerance.\n*\n*\n*\n* OUTPUT     : rcnew      -The new curve.\n*              jstat     - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*              \n*\n* WRITTEN BY : Ulf J. Krystad, SI, 92-12.\n* MODIFIED BY :\n*\n**********************************************************************/\n{\n  int kpos = 0;\t\t\t/* Position of error.               */\n  int ki,kj;                    /* Loop control                     */\n  int kn,kk,kdim;               /* Attributes of inut curve         */\t\t\t/* Position of error.               */\n  double a,b;                   /* Bezier interval                  */\n  double *et_new = SISL_NULL;        /* New knot array                   */\n  double *ecoef_new = SISL_NULL;     /* New coefficient array            */\n  SISLCurve *qc = SISL_NULL;\t\t/* Pointer to new curve-object.     */\n\n\n  /* Check that we have a curve. */\n  if (!pc)\n    goto err150;\n\n  /* Minimum order allowed is 3. */\n  if (pc->ik < 3)\n     goto err151;\n  \n  /* The curve has to be of bezier type. */\n  if (pc->in != pc->ik)\n     goto err152;\n\n  kn = pc->in;\n  kk = pc->ik;\n  a  = pc->et[kk-1];\n  b  = pc->et[kn];\n  kdim = pc->idim;\n\n    /* Test if the corresponding coeficient is zero. */\n/*  if (which_end == 0)\n  {\n     for (ki=0; ki < kdim; ki++)\n\tif (fabs(pc->ecoef[ki]) > aepsge)\n\t   goto err153;\n  }\n  else\n  {\n     for (ki=(kn-1)*kdim; ki < kn*kdim; ki++)\n\tif (fabs(pc->ecoef[ki]) > aepsge)\n\t   goto err153;\n  }\n  */\n  \n  /* create knot array. __________________________________________*/\n  if ((et_new= newarray(kn+kk-2,DOUBLE)) == SISL_NULL) goto err101;\n\n  for (ki=0; ki < kk-1; ki++)\n  et_new[ki] = a;\n\n    for (; ki < kn+kk-2; ki++)\n  et_new[ki] = b;\n\n  /* create coeficient array. _________________________________ */\n  if ((ecoef_new= newarray(kdim*(kn-1),DOUBLE)) == SISL_NULL) goto err101;\n\n  if (which_end)\n     for (ki=0; ki < kn-1; ki++)\n\tfor (kj=0; kj < kdim; kj++)\n\t   ecoef_new[ki*kdim +kj] = pc->ecoef[ki*kdim +kj]*(kn-1)/(kn-1-ki);\n  else\n     for (ki=0; ki < kn-1; ki++)\n\tfor (kj=0; kj < kdim; kj++)\n\t   ecoef_new[ki*kdim +kj] = pc->ecoef[(ki+1)*kdim + kj]*(kn-1)/(ki+1);\n  \n  \n  /* Create factor curve */\n  if ((qc = newCurve (kn-1, kk-1, et_new, ecoef_new, pc->ikind, kdim, 2))\n      == SISL_NULL) goto err101;\n\n  *rcnew = qc;\n  *jstat = 0;\n  goto out;\n\n/* ERROR EXITS ___________________________________________ */\n\n/* Error. No input curve.  */\nerr150:\n  *jstat = -150;\n  s6err (\"sh_div_crv\", *jstat, kpos);\n  goto out;\n\n\n/* Error. order less than 3.  */\nerr151:\n  *jstat = -151;\n  s6err (\"sh_div_crv\", *jstat, kpos);\n  goto out;\n\n/* Error. Not a bezier curve.  */\nerr152:\n  *jstat = -152;\n  s6err (\"sh_div_crv\", *jstat, kpos);\n  goto out;\n\n\n/* Error in allocation.*/\n\nerr101:\n  if (et_new) freearray(et_new);\n  if (ecoef_new) freearray(ecoef_new);\n  *jstat = -101;\n  s6err (\"sh_div_crv\", *jstat, kpos);\n  goto out;\n\nout:\n;\n}\n"
  },
  {
    "path": "src/sh_set_at.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: sh_set_at.c,v 1.2 2001-03-19 16:06:04 afr Exp $\n *\n */\n\n\n#define SH_SET_AT\n\n#include \"sislP.h\"\n\n\f\n\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nsh_set_at (SISLObject * po1, SISLObject * po2, \n\tSISLIntdat * pintdat, int *jstat)\n#else\nvoid\nsh_set_at (po1, po2, pintdat,  jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     SISLIntdat *pintdat;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Set SI_AT topology part.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              pintdat  - Intersection data of object-object intersection.\n*\n* OUTPUT       : jstat    - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      : sh1781_AT          - Find pre-topology of 1D curve-point.\n*              sh1780_AT          - Find pre-topology of curve-curve.\n*              sh1779_AT          - Find pre-topology of 3D curve-surface.\n*\n* REFERENCES :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 09.91\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                        */\n  int ki;\t\t\t/* Counter.                                */\n  int kdim;\t\t\t/* Dimension of geometry space.            */\n  SISLIntpt *qpt = SISL_NULL;\t/* Pointer to intersection point.          */\n  /* --------------------------------------------------------------------- */\n\n  /* Init */\n  *jstat = 0;\n\n  /* Test if an intersection data structure exist.  */\n  if (pintdat == SISL_NULL)\n    goto out;\n\n\n  /* Fetch dimension of geometry space. */\n  if (po1->iobj == SISLPOINT)\n\n    kdim = po1->p1->idim;\n  else if (po1->iobj == SISLCURVE)\n    kdim = po1->c1->idim;\n  else\n    kdim = po1->s1->idim;\n\n  /* Treat only cases:\n     crv vs pt 1D\n     crv vs crv\n     crv vs sf\n     (?sf vs pt 2D)\n     */\n\n  if (!(((po1->iobj == SISLCURVE && po2->iobj >= SISLCURVE) ||\n\t (po2->iobj == SISLCURVE && po1->iobj >= SISLCURVE)) ||\n\t(kdim == 1 && (po1->iobj + po2->iobj) == (SISLPOINT + SISLCURVE)) ||\n\t(kdim == 2 && (po1->iobj + po2->iobj) == (SISLPOINT + SISLSURFACE))))\n    goto out;\n\n\n  for (ki = 0; ki < (pintdat)->ipoint; ki++)\n  {\n     qpt = (pintdat)->vpoint[ki];\n\n      /* Browse on the dimension of geometry space and the type of\n         the input objects.     */\n\n      if (kdim == 1 && ((po1->iobj == SISLCURVE && po2->iobj == SISLPOINT)\n\t\t     || (po2->iobj == SISLCURVE && po1->iobj == SISLPOINT)))\n\t{\n\t  /* Compute pre-topology in one-dimensional curve-level value\n             intersection.            */\n\n\t  sh1781_at (po1, po2,qpt, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n      else if (po1->iobj == SISLCURVE && po2->iobj == SISLCURVE)\n\t{\n\t  /* curve-curve intersection.  */\n\t  sh1780_at (po1, po2, qpt, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n      else if (kdim == 3 &&\n\t       ((po1->iobj == SISLCURVE && po2->iobj == SISLSURFACE) ||\n\t\t(po1->iobj == SISLSURFACE && po2->iobj == SISLCURVE)))\n\t{\n\t  /* Surface-curve intersection in 3-dimensional geometry space. */\n\n\t  sh1779_at (po1, po2, qpt, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t}\n    }\n\n  /* Task performed.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\nerror:*jstat = kstat;\n  goto out;\n\nout:\n   return;\n}\n"
  },
  {
    "path": "src/shape.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: shape.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define SHAPE\n\n#include \"sislP.h\"\n\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n      shape(double emid[],double etang[],int idim,int iedge,int *jstat)\n#else\t \nvoid shape(emid,etang,idim,iedge,jstat)\n     int idim,iedge,*jstat;\n     double emid[],etang[];\n#endif     \n/*\n*********************************************************************\n*                                                                   \n* PURPOSE    : This routine gives a possibility for the application\n*              to adjust the value and the derivatives in the midpoint\n*              of the vertex region, i.e. the point in which the region\n*              is divided.\n*\n*\n* INPUT      : idim    - Dimension of geometry space.\n*              iedge   - Number of edges of the vertex region.\n*\n*\n* INPUT/OUTPUT  : emid    - The value in the midpoint of the region.\n*                           Dimension is idim.\n*                 etang   - The tangents of the blending surfaces in\n*                           the midpoint of the region, along the \n*                           curves which divides the region into 4-sided\n*                           blending surfaces. Dimension is iedge*idim.\n*                       \n*\n* OUTPUT     : jstat   - status messages  \n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* USE        : The input of the arrays emid and etang may be changed.\n*              This will effect the geometry of the blend strongly. Make\n*              sure to return sensible midpoint and tangents. The midpoint\n*              should lie close to the real midpoint of the region, pulling\n*              it close to an edge, may result in blending surfaces with\n*              cusps. Also if the tangents is very long, cusps may occur.\n*              The numbering of the tangents must be the same as the numbering\n*              of the edges, otherwise the G1-continuity will be lost.\n*\n*-\n* CALLS      : \n*\n* WRITTEN BY : Vibeke Skytt, SI, 05.90.\n*\n*********************************************************************\n*/\n{\n  int ki;\n  double tfac = 1.0;\n  \n  /* printf(\"Give factor with which to multiply tangent : \");*/\n  /* scanf(\"%lf\",&tfac);*/\n  \n  for (ki=0; ki<iedge*idim; ki++) etang[ki] *= tfac;\n\n  *jstat = 0;\n\n  return;\n}\n"
  },
  {
    "path": "src/shcheckput.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: shcheckput.c,v 1.2 2001-03-19 16:06:04 afr Exp $\n *\n */\n\n\n#define SHCHECKPUT\n\n#include \"sislP.h\"                            \n\f\n\n#if defined (SISLNEEDPROTOTYPES)\nvoid\n     shcheckput(SISLObject *po1,SISLIntdat **rintdat,\n\t\tSISLIntdat *pintdat,int inr,double apar,int *jstat)\n#else\nvoid shcheckput(po1,rintdat,pintdat,inr,apar,jstat)\n     SISLObject *po1;\n     SISLIntdat **rintdat;\n     SISLIntdat *pintdat;\n     int    inr;\n     double apar;\n     int    *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To insert all points in one intdat with one less number\n*              of parameters into rintdat. New copies is made with\n*              the missing parameter. All listes is also to\n*              be uppdated. This is a special version in hp relaxation.\n*              The difference from s6idput is that this version\n*              is to be used only when upgrading from curve maxima\n*              to surface maxima. We use the function checktype to\n*              examin if the maxima from the curve is a maxima\n*              for the surface.\n*\n*\n*\n* INPUT      : po1      - Pointer to the surface object.\n*              pintdat  - Pointer to intersection data with one less\n*                         parameter than rintdat.\n*              inr      - Number of the parameter that is missing in pintdat.\n*              apar     - Parameter value of the missing parameter.\n*\n*\n* OUTPUT     : rintdat  - Pointer to a pointer to intersection data.\n*              jstat    - status messages  \n*                               > 0      : No of points transmitted.\n*                               = 0      : No points transmitted !\n*                               < 0      : error\n*\n*\n* METHOD     : \n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s6err      - Gives error message.\n*              s6idnpt    - Insert a new intpt structure.\n*              copyIntpt  - Copy an intpt structure.\n*              newIntdat  - Create new intdat structure.\n*\n* WRITTEN BY : Arne Laksaa, 05.89.\n*              UJK, 01.91 Changed a call to newIntpt, copying the\n*                         attribute adist.\n*********************************************************************\n*/                                     \n{\n\n  int ktype;                    /* Local extremum desciptor.            */\n  int kstat;                    /* Local status variable.               */\n/*guen  int kpos=0;  */                  /* Position of error.                   */\n/*guen changed into: */\n  int kpos=0;                   /* Position of error.                   */\n  int ki,kj;                    /* Counters                             */\n  int kant;                     /* Number of parameters in new points.  */\n  int knum;                     /* Number of points transmitted.        */\n  int *perm_arr = SISL_NULL;         /* Permutation array used in transmit.  */\n  double *spar   = SISL_NULL;        /* Storing uppdated parametervalues.    */\n  SISLIntpt **uintpt = SISL_NULL;    /* Pointers to new intersection points. */\n  /* ------------------------------------------------------------------ */\n  \n  /* Initiate to no points transmitted */\n  *jstat = 0;\n\n  /* Test if object is a surface                          */\n    if (po1->iobj != SISLSURFACE) goto err192;\n\t\t\t       \n  /* We have to be sure that we have an intdat structure. */\n  if (pintdat == SISL_NULL) goto out;\n   \n  /* Computing number of new parameter direction. */\n  \n  kant = pintdat->vpoint[0]->ipar + 1;\n  \n  \n  if (inr<0 || inr>=kant) goto err191;\n  \n  \n  /* Allocating an array for intersection points. */\n  \n  if ((uintpt = newarray(pintdat->ipoint,SISLIntpt *)) == SISL_NULL)\n    goto err101;\n  \n  /* Allocating an array for index relation between pintdat\n     and the selected points.      . */\n  \n  if ((perm_arr = newarray(pintdat->ipoint,int)) == SISL_NULL)\n    goto err101;\n  \n  /* Allocating an array for parametervalues. */\n  \n  if ((spar = newarray(kant,double)) == SISL_NULL)\n    goto err101;\n  \n  \n  /* Making copies of all intersection points. */\n  \n  for (ki=0,knum=0; ki<pintdat->ipoint; ki++)\n  {\n     /* First we have to insert the missing parameter value. */\n     \n     for(kj=0; kj<inr; kj++) spar[kj] = pintdat->vpoint[ki]->epar[kj];\n     spar[kj] = apar;\n     for(kj++; kj<kant; kj++) spar[kj] = pintdat->vpoint[ki]->epar[kj-1];\n     \n     /* Select the ones which are surface maximas */\n     ktype = shchecktype(po1,spar);\n     if (ktype < 0) goto error;\n     if (ktype == 1 || ktype == 3 || ktype == 4) \n     {\n\t/* UJK,01-91 bringing over the adist value ! */\n\tuintpt[knum] = newIntpt(kant,spar,pintdat->vpoint[ki]->adist);\n \tperm_arr[ki] = knum;\n \tknum++;\n     }\n     else perm_arr[ki] = -1;\n  }\n  \n  if (knum == 0) goto out;\n\t\t \n  /* Than we can insert all new intersection points in rintdat. */\n  \n  for (ki=0; ki<knum; ki++)\n    {\n      s6idnpt(rintdat,&uintpt[ki],1,&kstat);\n      if (kstat < 0) goto error;\n    }\n  \n  /* Than we can uppdate all pcurve pointers (lists). */\n  \n  for (ki=0; ki<pintdat->ipoint; ki++)\n    if (pintdat->vpoint[ki]->pcurve != SISL_NULL)\n      {\n\tfor (kj=0;kj<pintdat->ipoint;kj++)\n\t  if (pintdat->vpoint[ki]->pcurve == pintdat->vpoint[kj])\n\t    break;\n\t\n\tif (kj == pintdat->ipoint) goto err190;\n\t\n\tif (perm_arr[ki] >=0 && perm_arr[kj] >= 0)\n\t   {\n\t   s6idcon(rintdat,&uintpt[perm_arr[ki]],&uintpt[perm_arr[kj]],&kstat);\n\t   if (kstat < 0) goto error;\n           }\n      }\n  \n  \n  *jstat = knum;\n  goto out;\n  \n\n/* Error, wrong object type.  */\n\nerr192: *jstat = -192;\n        s6err(\"shcheckput\",*jstat,kpos);\n        goto out;\n\n/* Error in inserted parameter number.  */\n\nerr191: *jstat = -191;\n        s6err(\"shcheckput\",*jstat,kpos);\n        goto out;\n/* Error in intersection list.  */\n\nerr190: *jstat = -190;\n        s6err(\"shcheckput\",*jstat,kpos);\n        goto out;\n\n/* Error in space allocation.  */\n\nerr101: *jstat = -101;\n        s6err(\"shcheckput\",*jstat,kpos);\n        goto out;\n\n/* Error in sub function.  */\n\nerror: *jstat = kstat;\n        s6err(\"shcheckput\",*jstat,kpos);\n        goto out;\n\n out: if (uintpt     != SISL_NULL) freearray(uintpt);\n      if (spar       != SISL_NULL) freearray(spar);\n      if (perm_arr   != SISL_NULL) freearray(perm_arr);\n}\n"
  },
  {
    "path": "src/shchecktyp.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: shchecktyp.c,v 1.2 2001-03-19 16:06:04 afr Exp $\n *\n */\n\n\n#define SHCHECKTYPE\n\n#include \"sislP.h\"                            \n\f\n\n#if defined (SISLNEEDPROTOTYPES)\nint\n    shchecktype(SISLObject *pobj,double *parval)\n#else\nint shchecktype(pobj,parval)\n\n     SISLObject *pobj;\n     double *parval;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To classify (in the extremal sense) a onedimensional \n*              object's behaviour at a given parameter value.\n*\n*\n*\n* INPUT      : pobj     - Pointer to a surface or curve object.\n*              parval   - Parameter value(s).\n*\n*\n* OUTPUT     : shchecktype :\n*                            0 - No extremal point\n*                            1 - Maximum point\n*                            2 - Minimum point\n*                            3 - Saddle point (used in surface only)\n*                            4 - Extremum, test inconclusive.\n*                          < 0 - error\n*\n*\n* METHOD     : Test are performed on the first and second derivatives.\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1221      - Evaluate curve.\n*              s1421      - Evaluate surface.\n*\n* WRITTEN BY :Ulf J. Krystad, January 1991.\n*\n*********************************************************************\n*/                                     \n{\n   \n   int kstat;              /* Local status variable.            */\n   int kleft1 = 0;         /* Knot navigator                    */\n   int kleft2 = 0;         /* Knot navigator                    */\n   int kder   = 2;         /* Flag, compute 2. derivative.      */\n   int kdim   = 1;         /* Dimension is one !                */\n   double sval[9];         /* Storing uppdated parametervalues. */\n   double sval1[9];        /* Storing uppdated parametervalues. */\n   double *snorm = sval+6; /* Dummy normal pointer              */\n   double tmax;        \t   /* Size of derivatives               */\n   double tdet;            /* Size of Hessian determinant       */\n   int mult = 0;           /* Knot multiplicity                 */\n   double ttol = 1000000.0*REL_COMP_RES;\n   /* --------------------------------------------------------- */\n   \n   if (pobj == SISL_NULL ||\n       (pobj->iobj != SISLCURVE && pobj->iobj != SISLSURFACE))\n      return -1;\n   \n   if (pobj->iobj == SISLCURVE )\n   {\n      /* Curve case */\n      if (pobj->c1->idim != kdim) return -1;\n      \n      /* Get function values */\n      s1221(pobj->o1->c1,kder,parval[0],&kleft1,sval,&kstat);\n      if (kstat < 0) return -2;\n      \n      mult = s6knotmult(pobj->o1->c1->et,pobj->o1->c1->ik,\n\t\t     pobj->o1->c1->in,&kleft1,parval[0],&kstat);\n      if (kstat < 0) return -2;\n      \n      if (mult >= pobj->o1->c1->ik - 1)\n      {\t \n\t /* Get left side function values */\n\t s1227(pobj->o1->c1,kder,parval[0],&kleft1,sval1,&kstat);\n\t if (kstat < 0) return -2;\n\t /* Test function values */\n\t if (sval[1] < -ttol && sval1[1] >ttol)       return 1;\n\t else if (sval[1] > ttol && sval1[1] < -ttol) return 2;\n\t else                                       return 4;\n      }\n      else\n      {\n\t /* Test if first derivative is zero */\n\t if (fabs(sval[1]) > ttol) return 0;\n\t \n\t /* Test if max, min or inconclusive point */\n\t if      (sval[2] < -ttol) return 1;\n\t else if (sval[2] >  ttol) return 2;\n\t else                      return 4;\n      }\n   }\n   else\n   {\n      /* Surface case */\n      if (pobj->s1->idim != kdim) return -1;\n      \n      /* Get function values */\n      \n      s1421(pobj->o1->s1,kder,parval,&kleft1,&kleft2,\n\t    sval,snorm,&kstat);\n      if (kstat < 0) return -2;\n      \n      /* Test function values */\n      \n      /* Test if first derivative is zero */\n      tmax = sqrt(sval[1]*sval[1] + sval[2]*sval[2]);\n      if (tmax > ttol) return 0;\n      \n      /* Test if max, min ,saddle or inconclusive point */\n      tdet = (sval[3]*sval[5] - sval[4]*sval[4]);\n      if      (tdet < -ttol) return 3;\n      else if (tdet <  ttol) return 4;\n      else if (sval[3] < DZERO) return 1;\n      else return 2;\n      \n   }\n   \n}\t \n   \n"
  },
  {
    "path": "src/shcsfsing.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: shcsfsing.c,v 1.2 2001-03-19 16:06:04 afr Exp $\n *\n */\n\n#define SHCSFSING\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n#if defined(SISLNEEDPROTOTYPES)\nstatic void shcsfsing_s9corr(double [], double [], double[]);\nstatic void shcsfsing_s9dir(double [], double [], double[]);\n#else\nstatic void shcsfsing_s9corr();\nstatic void shcsfsing_s9dir();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n  shcsfsing(SISLCurve *pcurve,SISLSurf *psurf,double limit[],\n\t    double enext[], double gpos[],int *jstat)\n#else\nvoid shcsfsing(pcurve,psurf,limit,enext,gpos,jstat)\n     SISLCurve        *pcurve;\n     SISLSurf         *psurf;\n     double       limit[];\n     double       enext[];\n     double       gpos[];\n     int          *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To find one magical points.\n*\n* INPUT      : pcurve - Pointer to curve\n*              psurf  - Pointer to surface\n*              limit  - Parameter boarders of both geometries\n*                       limit[0] - limit[1] Parameter interval curve.\n*                       limit[2] - limit[3] Parameter interval surface 1.dir\n*                       limit[4] - limit[5] Parameter interval surface 2.dir\n*              enext    - Parameter start value for iteration(3 values).\n*\n*\n* OUTPUT     : gpos    - Parameter values of the found singularity.(3 values)\n*              jstat   - status messages  \n*                                = 1   : Extremum found.\n*                                = 0   : Extremum NOT found.\n*                                < 0   : error.\n*\n*\n* METHOD     :  - Start with a guess value (u,v) in domain of curve (S(w))\n*           (a) - Find domain value (r,t) of closest point (to S(w) \n*                 in surface(Q(r,t))\n*               - If vf(u,v) = <Sw,Normal(Q)> is small enough  stop \n*                      (<,> means scalar prod.)\n*               - Find dwa by taylorizing vf.\n*                 This include finding the derivatives of the closest \n*                 point function (r(w),t(w))\n*                 with respect to w. (called h(w) in article, see coments \n*                 in shcsfsing_s9dir)\n*               - w:= w+dw, goto (a)\n*\n*\n* REFERENCES : Solutions of tangential surface and curve intersections.\n*              R P Markot and R L Magedson\n*              Computer-Aided Design; vol. 21, no 7 sept. 1989, page 421-429\n*\n*\n* WRITTEN BY : Ulf J. Krystad, SI, SEPTEMBER 1992\n*\n*********************************************************************\n*/                       \n{                        \n  int kstat = 0;            /* Local status variable.                       */\n  int kpos = 0;             /* Position of error.                           */\n  int ki;                   /* Loop control                                 */\n  int kleft=0;             /* Variables used in the evaluator.              */\n  int kleftu=0;             /* Variables used in the evaluator.             */\n  int kleftv=0;             /* Variables used in the evaluator.             */\n  int kder=2;               /* Order of derivatives to be calulated         */\n  int kdim=3;               /* Dimension of space the surface lies in       */\n  int knbit;                /* Number of iterations                         */\n  double tdelta[3];         /* Length of parameter intervals.               */\n  double tdist;             /* The current scalar product.                  */\n  double tprev;             /* The previous scalar product.                 */\n  double td[3],t1[3],tdn[3];/* Distances between old and new parameter      */\n\t\t\t    /* value in the three parameter directions.     */\n  double crv_val[21];         /* Value ,first and second derivatiev of surf.*/ \n  double *crv_tang=crv_val+3;  /* Curve tangent                             */\n  double surf_val[21];         /* Value ,first and second deriv. of surf.   */ \n  double *surf_norm=surf_val+18;  /* Normal vector of the surface           */\n  double snext[3];          /* Parameter values                             */\n  double start[2];          /* Parameters limit of surface, used in         */\n                            /* call to closest point                        */\n  double end[2];            /* Parameters limit of surface, used in         */\n                            /* call to closest point                        */\n  double guess[2];          /* Start point for closest point iteration      */\n  double tol = (double)10000.0*REL_COMP_RES; /* equality tol. in par.space  */\n  SISLPoint *ppoint=SISL_NULL;   /* Contains the current position of the curve   */ \n                            /* used in closest point iteration              */\n  int max_iter=20;          /* Maximal number of iteration allowed          */\n\n  /* ---------------------------------------------------------------------- */\n  \n  /* Test input.  */\n  if (pcurve->idim != kdim) goto err106;\n  if (psurf->idim != kdim) goto err106;\n  \n  /* Fetch referance numbers from the serach intervals for the surfaces.  */\n  tdelta[0] = limit[1] - limit[0];\n  tdelta[1] = limit[3] - limit[2];\n  tdelta[2] = limit[5] - limit[4];\n\n  /* Set limit values, used in closest point iteration */\n  start[0] = limit[2];\n  start[1] = limit[4];\n  end[0]   = limit[3];\n  end[1]   = limit[5];\n  \n  /* Create point, used in closest point iteration */\n  ppoint = newPoint(crv_val,3,0);\n  \n  /* Collapsed ? */\n  for (ki=0;ki<3;ki++) if (tdelta[ki] < tol) goto errsmall;  \n  \n  /* Initiate output variables.  */\n  for (ki=0;ki<3;ki++)     gpos[ki] = enext[ki];\n\n  /* Evaluate 0.-2. derivatives ofthe curve */\n  s1221(pcurve,kder,gpos[0],&kleft,crv_val,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Get closest point in second surface. */\n  guess[0] = gpos[1];\n  guess[1] = gpos[2];\n  s1773(ppoint,psurf,REL_COMP_RES,start,end,guess,gpos+1,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Evaluate 0.-2. derivatives of surface */\n  s1421(psurf,kder,gpos+1,&kleftu,&kleftv,surf_val,surf_norm,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Get length of dot product */\n  tprev = fabs(s6scpr(crv_tang,surf_norm,kdim));\n  \n  /* Compute the Newton stepdistance vector in first surface. */\n  shcsfsing_s9dir(td,crv_val,surf_val);\n  \n  /* Adjust if we are not inside the parameter intervall. */\n  for (ki=0;ki<3;ki++)    t1[ki] = td[ki];\n\n  shcsfsing_s9corr(t1,gpos,limit);\n  \n  /* Iteratation loop.  */\n  \n  for (knbit = 0; knbit < max_iter; knbit++)\n    {\n      \n      snext[0] = gpos[0] + t1[0];\n   \n      /* Evaluate 0.-2. derivatives of curve */\n      s1221(pcurve,kder,snext[0],&kleft,crv_val,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Get closest point in surface. */\n      guess[0] = gpos[1];\n      guess[1] = gpos[2];\n      s1773(ppoint,psurf,REL_COMP_RES,start,end,guess,snext+1,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Evaluate 0.-2. derivatives of surface */\n      s1421(psurf,kder,snext+1,&kleftu,&kleftv,surf_val,surf_norm,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Get length of dot product */\n      tdist = fabs(s6scpr(crv_tang,surf_norm,kdim));\n \n      /* Compute the Newton stepdistance vector. */\n      shcsfsing_s9dir(tdn,crv_val,surf_val);\n      \n      if (tdist <= tprev)\n\t{\n\t  /* Ordinary converging. */\n\t  \n\t  for (ki=0;ki<3;ki++) gpos[ki] = snext[ki];\n\t  td[0] = t1[0] = tdn[0];\n\n\t  /* Adjust if we are not inside the parameter intervall. */\n\t  shcsfsing_s9corr(t1,gpos,limit);\n\t\t  \n          if ((fabs(t1[0]/tdelta[0]) <= REL_COMP_RES))\n\t      {\n\t\tgpos[0] += t1[0];\n\t\t/* Evaluate 0.-2. derivatives of curve */\n\t\ts1221(pcurve,kder,gpos[0],&kleft,crv_val,&kstat);\n\t\tif (kstat < 0) goto error;\n\t\t\n\t\t/* Get closest point in surface. */\n\t\tguess[0] = gpos[1];\n\t\tguess[1] = gpos[2];\n\t\ts1773(ppoint,psurf,REL_COMP_RES,start,end,guess,gpos+1,&kstat);\n\t\tif (kstat < 0) goto error;\n\t\tbreak;\n\t      }\n\t  tprev = tdist;\n\t}\n      \n      else\n\t{\n\t  /* Not converging, half step length try again. */\n\t   \n\t   t1[0] /= (double)2;\n\t}\n    }\n  \n  /* Iteration stopped, test if point is extremum */\n  /* Unsure about what is right here */\n  if (tdist <= tol)\n    *jstat = 1;\n  else\n    *jstat = 0;\n\n \n  /* Test if the iteration is close to a knot */\n  if (fabs(gpos[0] - pcurve->et[kleft])/tdelta[0] < tol)\n    gpos[0] = pcurve->et[kleft];\n  else if (fabs(gpos[0] - pcurve->et[kleft+1])/tdelta[0] < tol)\n    gpos[0] = pcurve->et[kleft+1];\n\n  if (fabs(gpos[1] - psurf->et1[kleftu])/tdelta[1] < tol)\n    gpos[1] = psurf->et1[kleftu];\n  else if (fabs(gpos[1] - psurf->et1[kleftu+1])/tdelta[1] < tol)\n    gpos[1] = psurf->et1[kleftu+1];\n  \n  if (fabs(gpos[2] - psurf->et2[kleftv])/tdelta[2] < tol)\n    gpos[2] = psurf->et2[kleftv];\n  else if (fabs(gpos[3] - psurf->et2[kleftv+1])/tdelta[2] < tol)\n    gpos[2] = psurf->et2[kleftv+1];\n  \n  /* Iteration completed.  */\n  goto out;\n  \n  /* --------------------------------------------------------------------- */ \n  /* Error in input. Dimension not equal to 3 */\n  err106: *jstat = -106;\n  s6err(\"shcsfsing\",*jstat,kpos);\n  goto out;                  \n\n  /* Error in input. One parameter interval colapsed. */\n  errsmall: *jstat = -200;\n  s6err(\"shcsfsing\",*jstat,kpos);\n  goto out;                  \n  \n  /* Error in lower level routine.  */\n  error : *jstat = kstat;\n  s6err(\"shcsfsing\",*jstat,kpos);\n  goto out;                  \n  \n out:if(ppoint) freePoint(ppoint);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  shcsfsing_s9corr(double gd[], double coef[],double limit[])\n#else\nstatic void shcsfsing_s9corr(gd,coef,limit)\n     double gd[];\n     double coef[];\n     double limit[];\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To be sure that we are inside the boarder of the\n*              parameter plan. If we are outside clipping is used\n*\t       to adjust the step value.\n*\n*\n* INPUT      : coef    - Current position.\n*              limit   - Parameter boarders of both surfaces.\n*\n*\n*\n* INPUT/OUTPUT : gd    - Proposed delta values.\n*\n*\n* METHOD     : Cutting the line towards the parameter box.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Ulf J. Krystad, SI, SEPTEMBER 1992\n*\n*********************************************************************\n*/                       \n{\n  int ki;\n\n  for (ki=0;ki<3;ki++)\n    if (coef[ki] + gd[ki] < limit[2*ki])        gd[ki] = limit[2*ki]    - coef[ki];\n    else if (coef[ki] + gd[ki] > limit[2*ki+1]) gd[ki] = limit[2*ki +1] - coef[ki];\n  \n\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  shcsfsing_s9dir(double cdiff[],double evals[],double evalq[])\n#else\nstatic void shcsfsing_s9dir(cdiff,evals,evalq)\n     double cdiff[];\n     double evals[];\n     double evalq[];\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate the increments in the first surface domain.\n*              \n*\n*\n* INPUT      : evals - Value and derivatives  on curve\n*              evalq - Value and derivatives  on surface.\n*              \n*\n* OUTPUT     : cdiff1  - Parameter increments in one direction.\n*            \n*\n*\n* METHOD     : See comments in main header.\n*              The only thing missing in the article is the derivation of the\n*              function h(w). Calling this function (r(w), t(w))\n*              we know that\n*              For all w (<,> meaning scalar product)\n*              <S(w)-Q(r(w),t(w)),Qt(r(w),t(w))> = 0\n*              <S(w)-Q(r(w),t(w)),Qr(r(w),t(w))> = 0\n*              This means that (derivation by w)\n*              <Sw-[Qt*tw+Qr*rw],Qt> + <S-Q,Qtt*tw + Qtr*rw> = 0\n*              <Sw-[Qt*tw+Qr*rw],Qr> + <S-Q,Qrt*tw + Qrr*rw> = 0\n*              Solving these two equations gives us rw,tw. \n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Ulf J. Krystad, SI, SEPTEMBER 1992\n*\n*********************************************************************\n*/                       \n{                        \n\n\n  int ki;                          /* Loop control.                               */\n  int kdim = 3;                       /* Dim of object space.                        */\n  double *sval;                       /* Pointer to first surface value              */\n  double *s_w,*s_ww;                  /* Pointers to curve derivatives       */\n  double *qval;                       /* Pointer to surface value             */\n  double *q_t,*q_r,*q_tt,*q_tr,*q_rr; /* Pointer to surface derivatives       */\n  double *nq;                         /* Pointer to surface normal            */\n  double nq_w[3];            \t      /* Derivatives of surface normal (with w!) */\n  double help1[3], help2[3];          /* Help arrays                                 */\n  double help3[3], help4[3];          /* Help arrays                                 */\n  double matr[4];                     /* Matrix in linear equation to be solved      */\n  int    piv[2];                      /* Pivotation array                            */\n  double sq[3];                       /* The difference cevtor S-Q                   */\n  double h_w[2];                      /* The derivative of h() by w          */\n  double f_val, f_deriv;              /* Value and derivative of the 1 D function. */\n   int kstat;                          /* Local status                                */\n  \n  /* ------------------------------------------------------------------------------- */\n  \n  cdiff[0] = DZERO;\n  cdiff[1] = DZERO;\n  cdiff[2] = DZERO;\n\n  /* Init, Set pointers to input values */\n  sval = evals;\n  qval = evalq;\n  \n  s_w   = sval + kdim;\n  s_ww  = s_w   + kdim;\n\n  q_t   = qval + kdim;\n  q_r   = q_t   + kdim;\n  q_tt  = q_r   + kdim;\n  q_tr  = q_tt  + kdim;\n  q_rr  = q_tr  + kdim;\n  nq    = q_rr  + kdim;\n\n  /* Get the difference vector S-Q */\n  s6diff(sval,qval,kdim,sq);\n  \n  /* Find the derivatives of the h() function by solving 2 2x2 systems (same matrix) */\n  matr[0] = s6scpr(q_tt,sq,kdim) - s6scpr(q_t,q_t,kdim);\n  matr[1] = s6scpr(q_tr,sq,kdim) - s6scpr(q_t,q_r,kdim);\n  matr[2] = matr[1];\n  matr[3] = s6scpr(q_rr,sq,kdim) - s6scpr(q_r,q_r,kdim);\n\n  h_w[0] = -s6scpr(s_w,q_t,kdim);\n  h_w[1] = -s6scpr(s_w,q_r,kdim);\n  \n\n  /* Factorize matrix */\n  s6lufacp(matr,piv,2,&kstat);\n  if (kstat != 0) goto out;\n  \n  /* Solve */\n  s6lusolp(matr,h_w,piv,2,&kstat);\n  if (kstat != 0) goto out;\n\n\n  /* Construct matrix for finding dw */\n  s6crss(q_tt,q_r,help3);\n  s6crss(q_t,q_tr,help4);\n  \n  for (ki=0;ki<3;ki++) help1[ki] = (help3[ki] + help4[ki])*h_w[0];\n\n  s6crss(q_tr,q_r,help3);\n  s6crss(q_t,q_rr,help4);\n  \n  for (ki=0;ki<3;ki++) help2[ki] = (help3[ki] + help4[ki])*h_w[1];\n\n  for (ki=0;ki<3;ki++) nq_w[ki] = (help1[ki] + help2[ki]);\n  \n  f_val = s6scpr(s_w, nq, kdim);\n  f_deriv = s6scpr(s_ww, nq, kdim) + s6scpr(s_w, nq_w, kdim);\n  \n  if (DNEQUAL(f_val + fabs(f_deriv), f_val))\n      cdiff[0] = - f_val/f_deriv;\n     \n  out:;\n  \n}\n"
  },
  {
    "path": "src/shdivsurf.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: shdivsurf.c,v 1.3 2005-02-28 09:04:50 afr Exp $\n *\n */\n\n\n#define SH_DIV_SURF\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n    sh_div_surf (SISLSurf * ps, int which_end_1, int which_end_2,\n\t\t double aepsge, SISLSurf ** rsnew, int *jstat)\n#else\nvoid \n   sh_div_surf (ps, which_end_1, which_end_2, aepsge, rsnew, jstat)\n   SISLSurf *ps;\n   int which_end_1;\n   int which_end_2;\n   double aepsge;\n   SISLSurf **rsnew;\n   int *jstat;\n#endif\n/*\n********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE     :To factorize a bezier surface S(u,v)  over the interval \n*              [a,b]x[c,d] into\n*              \n*              oldsurf = (u-a)/(b-a) *newsurf \n*              when which_end_1 eq 0 \n*                 and\n*              oldcurve = (b-u)/(b-a)*newsurf \n*              when which_end_1 eq 1\n*                 and\n*              oldsurf = (v-c)/(d-c) *newsurf \n*              when which_end_2 eq 0 \n*                 and\n*              oldcurve = (d-v)/(d-c)*newsurf \n*              when which_end_2 eq 1\n*                  NB ! Both which_end_1 and which_end_2 can be\n*                       used at the same time. To achieve no factorisation\n*                       in one dir, set the proper which_end to -1.\n*\n*                ------------------------\n*                |          1            |\n*                |                       |\n*             ^  |                       |\n*             |  | 0                   1 |\n*             |  |                       |\n*             v  |          0            |\n*                ------------------------\n*                    u --->\n*              The edge in question must be zero.\n*\n*\n* INPUT      : ps           - Oldsurf to factorize.\n*              which_end_1   - (-1,0,1) Branch parameter for zero edge 1. dir.\n*              which_end_2   - (-1,0,1) Branch parameter for zero edge 2. dir.\n*              aepsge       - Geometry tolerance.\n*\n*\n*\n* OUTPUT     : rsnew      -The new surf.\n*              jstat     - status messages\n*                                         > 0      : warning\n*                                         = 0      : ok\n*                                         < 0      : error\n*\n*\n* METHOD     :\n*\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*              \n*\n* WRITTEN BY : Ulf J. Krystad, SI, 92-12.\n* MODIFIED BY :\n*\n**********************************************************************/\n{\n  int kstat;\t\t\t/* Local status variable.\t\t*/\n  int kdim = ps->idim;\t\t/* Dimension of geometry space.        */\n  int kkind = ps->ikind;\t/* Kind of surface.                    */\n  int kk1;\t\t\t/* Order in 1. par. dir.               */\n  int kk2;\t\t\t/* Order in 2. par. dir.               */\n  int kn1;\t\t\t/* Number of vertices in 1. par. dir.  */\n  int kn2;\t\t\t/* Number of vertices in 2. par. dir.  */\n  double *st1;\t\t\t/* Knot vector in 1. par. dir.         */\n  double *st2;\t\t\t/* Knot vector in 2. par. dir.         */\n  double *scoef1 = SISL_NULL;\t/* Coefficients of input curve to\n\t\t\t           factorize in 1. par. dir.           */\n  double *scoef2 = SISL_NULL;\t/* Coefficients of factorized surface. */\n  double *scoef;\t\t/* Coefficients of factorized surface. */\n  SISLCurve *qc1 = SISL_NULL;\t/* Input curve to sh_div_crv in 1. par. dir.    */\n  SISLCurve *qc2 = SISL_NULL;\t/* Output curve from sh_div_crv in 1. par. dir. */\n  SISLCurve *qc3 = SISL_NULL;\t/* Output curve from sh_div_crv in 2. par. dir. */\n  /* __________________________________________________________________ */\n\n  if (which_end_1 > -1)\n    {\n      /* Factorize 1. dir,\n\t first express the surface as a curve.  */\n\n      if ((scoef1 = newarray (kdim * ps->in1 * ps->in2, double)) == SISL_NULL)\n\tgoto err101;\n\n      /* Change parameter directions of surface.  */\n\n      s6chpar (ps->ecoef, ps->in1, ps->in2, kdim, scoef1);\n\n      /* Create curve.  */\n\n      qc1 = newCurve (ps->in1, ps->ik1, ps->et1, scoef1, kkind, kdim * ps->in2, 0);\n      if (qc1 == SISL_NULL)\n\tgoto err101;\n\n      /* Factorize the curve.  */\n      sh_div_crv (qc1, which_end_1, aepsge, &qc2, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /* Change parameter directions of the coefficient array of\n         the resulting curve.  */\n\n      if ((scoef2 = newarray (qc2->in *ps->in2 * kdim, DOUBLE)) == SISL_NULL)\n\tgoto err101;\n      s6chpar (qc2->ecoef, ps->in2, qc2->in, kdim, scoef2);\n\n      /* Set local parameters of factorized surface. */\n\n      kk1 = qc2->ik;\n      kn1 = qc2->in;\n      kk2 = ps->ik2;\n      kn2 = ps->in2;\n      st1 = qc2->et;\n      st2 = ps->et2;\n\n      /* Free curve used as input to the sh_div_crv. */\n\n      if (qc1 != SISL_NULL)\n\tfreeCurve (qc1);\n      qc1 = SISL_NULL;\n    }\n  else\n    {\n      /* Set local parameters of input surface. */\n\n      kk1 = ps->ik1;\n      kk2 = ps->ik2;\n      kn1 = ps->in1;\n      kn2 = ps->in2;\n      st1 = ps->et1;\n      st2 = ps->et2;\n      scoef2 = ps->ecoef;\n    }\n\n  if (which_end_2 > -1)\n    {\n      /* Factorize in second parameter direction of the\n\t surface. First express the surface as a curve.           */\n\n      if ((qc1 = newCurve (kn2, ps->ik2, st2, scoef2, kkind, kn1 * kdim, 0))\n\t  == SISL_NULL)\n\tgoto err101;\n\n\n\n      \n      /* Factorize the curve.  */\n      sh_div_crv(qc1, which_end_2, aepsge, &qc3, &kstat);\n      if (kstat < 0)\n\tgoto error;\n\n      /*\tSet local parameters of the surface. */\n\n      kk2 = qc3->ik;\n      kn2 = qc3->in;\n      st2 = qc3->et;\n      scoef = qc3->ecoef;\n    }\n  else\n    scoef = scoef2;\n\n  /* Express result as a surface.  */\n\n  if ((*rsnew = newSurf (kn1, kn2, kk1, kk2, st1, st2,\n\t\t\t scoef, kkind, kdim, 1)) == SISL_NULL)\n    goto err101;\n\n  /* Exit.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in scratch allocation.  */\n\nerr101:*jstat = -101;\n  goto out;\n\n  /* Error in lower level routine.  */\n\nerror:*jstat = kstat;\n  goto out;\n\nout:\n  /* Free scratch occupied by local arrays and objects.  */\n\n  if (which_end_1 > -1 && scoef1 != SISL_NULL)\n    freearray (scoef1);\n  if (which_end_1 > -1&& scoef2 != SISL_NULL)\n    freearray (scoef2);\n  if (qc1 != SISL_NULL)\n    freeCurve (qc1);\n  if (qc2 != SISL_NULL)\n    freeCurve (qc2);\n  if (qc3 != SISL_NULL)\n    freeCurve (qc3);\n\n  return;\n}\n"
  },
  {
    "path": "src/shevalc.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: shevalc.c,v 1.3 2001-03-19 16:06:04 afr Exp $\n *\n */\n\n\n#define SHEVALC\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nshevalc(SISLCurve *pc1,int ider,double ax,double aepsge,int *ileft,\n\t     double eder[],int *jstat)\n#else\nvoid shevalc(pc1,ider,ax,aepsge,ileft,eder,jstat)\n     SISLCurve *pc1;\n     int ider;\n     double ax;\n     double aepsge;\n     int *ileft;\n     double eder[];\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To compute the value and ider first derivatives of the\n*              B-spline curve pointed to by pc1, at the point with\n*              parameter value ax. Use the filtered coefficients of the\n*              curve.\n*\n*\n*\n* INPUT      : pc1    - Pointer to the curve for which position\n*                       and derivatives are to be computed.\n*              ider   - The number of derivatives to compute.\n*                       < 0 : Error.\n*                       = 0 : Compute position.\n*                       = 1 : Compute position and first derivative.\n*                       etc.\n*              ax     - The parameter value at which to compute\n*                       position and derivatives.\n*              aepsge - Geometry resolution.\n*\n*\n*\n* INPUT/OUTPUT : ileft - Pointer to the interval in the knot vector\n*                        where ax is located. If et is the knot vector,\n*                        the relation\n*\n*                          et[ileft] <= ax < et[ileft+1]\n*\n*                        should hold. (If ax == et[in] then ileft should\n*                        be in-1. Here in is the number of B-spline\n*                        coefficients.)\n*                        If ileft does not have the right value upon\n*                        entry to the routine, its value will be changed\n*                        to the value satisfying the above condition.\n*\n*\n*\n* OUTPUT     : eder   - Double array of dimension [(ider+1)*idim]\n*                       containing the position and derivative vectors.\n*                       (idim is the number of components of each B-spline\n*                       coefficient, i.e. the dimension of the Euclidean\n*                       space in which the curve lies.)\n*                       These vectors are stored in the following order:\n*                       First the idim components of the position vector,\n*                       then the idim components of the tangent vector,\n*                       then the idim components of the second derivative\n*                       vector, and so on.\n*                       (The C declaration of eder as a two dimensional array\n*                       would therefore be eder[ider+1,idim].)\n*              jstat  - Status messages\n*                                         > 0      : Warning.\n*                                         = 0      : Ok.\n*                                         < 0      : Error.\n*\n*\n* METHOD     :\n*\n* REFERENCES :\n*\n*-\n* CALLS      : s1221    - Evaluate curve.\n*              s1991    - Make the direction cone of a curve.\n*              newCurve - Create new curve object.\n*              freeCurve - Free scratch occupied by curve object.\n*\n* WRITTEN BY :  Vibeke Skytt, SI, 04.91.\n* CORRECTED BY: UJK, SI, 06.91\n* Modified by : Paal Fugelli, SINTEF, Oslo, Norway, 09.94. Replaced\n*               code using 'pdir->esmooth' and s1991() with 'qc = pc1;'\n*               and modified the free'ing of 'qc'.\n*               Added check for 1D rationals.\n*********************************************************************\n*/\n{\n  int kstat=0;        /* Local status variable.                          */\n  int kdim = pc1->idim;  /* Dimension of geometry space.                 */\n  double *scoef=SISL_NULL;    /* Array storing filtered coefficients.         */\n  double *s1,*s2,*s3,*s4; /* Pointers into coefficient arrays.           */\n  SISLCurve *qc = SISL_NULL;   /* Curve to evaluate.                          */\n\n  /* Make sure that the filtered coefficients of the curve exist.  */\n\n  if (kdim == 1)\n  {\n\n    /*\n     * PFU 09-94.\n     * There should never be a rational 1D curve here according to UJK, but\n     * I (PFU) added a test just in case...\n     * A rational curve would have caused a memory usage error in newCurve\n     * when trying to divide out the weights from the coefs.\n     * This could result in a core dump (division by zero) since the data\n     * would be \"garbage\".\n     *\n     * If future changes requires this to handle rational 1D curves, this\n     * must be updated to use rcoef when input is rational.\n     *\n     */\n\n    if ( pc1->ikind == 2 || pc1->ikind == 4 )\n      goto err151;\n\n     /* Create filtered coefficients. */\n\n     if ((scoef = newarray(pc1->in,DOUBLE)) == SISL_NULL) goto err101;\n\n     for (s1=pc1->ecoef, s2=scoef, s3=s1+pc1->in; s1<s3; s1=s4)\n     {\n\t*s2 = *s1;\n\tfor (s2++, s4=s1+1; s4<s3; s4++, s2++)\n\t{\n\t   if (fabs((*s4)-(*s1)) < aepsge) *s2 = *s1;\n\t   else break;\n\t}\n     }\n\n     /* Create curve object.  */\n\n     if ((qc = newCurve(pc1->in,pc1->ik,pc1->et,scoef,pc1->ikind,\n\t\t\tkdim,0)) == SISL_NULL) goto err101;\n  }\n  else\n    qc = pc1;\n\n  /*\n   * This previously used AN ANACRONISM ('pdir->esmooth') - taken out\n   * (Confirmed by VSK).\n   */\n\n\n\n  /* Evaluate curve.  */\n\n  s1221(qc,ider,ax,ileft,eder,&kstat);\n  if (kstat < 0) goto error;\n\n  /* UJK Let's have a normal exit possibility !*/\n  *jstat = 0;\n  goto out;\n\n\n  /* Error in input (1D rationals is not handled) */\n err151:\n  *jstat = -151;\n  goto out;\n\n  /* Error in scratch allocation.  */\n err101:\n  *jstat = -101;\n  goto out;\n\n  /* Error in lower level routine.  */\n\n error:\n  *jstat = kstat;\n  goto out;\n\nout:\n   /* Free scratch occupied by local objects. */\n\n   if (scoef != SISL_NULL) freearray(scoef);\n   if (qc != SISL_NULL && qc != pc1 ) freeCurve(qc);\n\n   return;\n}\n"
  },
  {
    "path": "src/shmkhlppts.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: shmkhlppts.c,v 1.4 2001-03-19 16:06:04 afr Exp $\n *\n */\n\n\n#define SHMKHLPPTS\n\n#include \"sislP.h\"\n#if defined(SISLNEEDPROTOTYPES)\nvoid\nshmkhlppts (SISLObject * po1, SISLObject * po2, double aepsge,\n\tSISLIntdat ** rintdat, SISLEdge * vedge[], int *jnewpt, int *jstat)\n#else\nvoid\nshmkhlppts (po1, po2, aepsge, rintdat, vedge, jnewpt, jstat)\n     SISLObject *po1;\n     SISLObject *po2;\n     double aepsge;\n     SISLIntdat **rintdat;\n     SISLEdge *vedge[];\n     int *jnewpt;\n     int *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : Make help points (and pretopology) for main points.\n*\n*\n* INPUT      : po1      - Pointer to the first object in the intersection.\n*              po2      - Pointer to the second object in the intersection.\n*              aepsge   - Geometry resolution.\n*              vedge    - SISLEdge intersection objects to the two\n*                         objects in intersection problem.\n*\n*\n* INPUT/OUTPUT : rintdat  - Intersection data of object-object intersection.\n*\n* OUTPUT       : jnewpt   - Number of new intersection points.\n*                jstat    - status messages\n*                                > 0   : Warning.\n*                                = 0   : Ok.\n*                                < 0   : Error.\n*\n*\n* METHOD     :\n*\n* CALLS      : sh1781          - Find pre-topology of 1D curve-point.\n*              sh1780          - Find pre-topology of curve-curve.\n*              sh1779          - Find pre-topology of 3D curve-surface.\n*              sh1786          - Find pre-topology of 2D point-curve.\n*              sh1787          - Find pre-topology of 2D point-surface.\n*\n* REFERENCES :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, 09.91\n* Revised by : Paal Fugelli, SINTEF, Oslo, Norway, 09-94. Fixed over-running\n*              of 'up' array.\n*********************************************************************\n*/\n{\n  int kstat = 0;\t\t/* Status variable.                        */\n  int knum = 0;\t\t\t/* Number of intpt on edges.               */\n  int ki;\t\t\t/* Counter.                                */\n  int kdim;\t\t\t/* Dimension of geometry space.            */\n  int knewpt = 0;\t\t/* Number of new intersection points.      */\n  int kobj;\t\t\t/* Number of obj, used in s6idint          */\n  int index1, index2;\t\t/* Dummy in this context                   */\n  SISLIntpt **up = SISL_NULL;\t/* Array of poiners to intersection point. */\n  /*  SISLIntpt *lup[3];*/\t\t/* Array of poiners to intersection point. */\n  SISLIntpt *qptint = SISL_NULL;\t/* Pointer to internal intersection point. */\n  SISLIntpt *qpt = SISL_NULL;\t/* Pointer to intersection point.          */\n  /* --------------------------------------------------------------------- */\n\n  /* Init */\n  *jstat = 0;\n  *jnewpt = 0;\n\n  /* Test if an intersection data structure exist.  */\n  if (*rintdat == SISL_NULL)\n    goto out;\n\n\n  /* Fetch dimension of geometry space. */\n  if (po1->iobj == SISLPOINT)\n\n    kdim = po1->p1->idim;\n  else if (po1->iobj == SISLCURVE)\n    kdim = po1->c1->idim;\n  else\n    kdim = po1->s1->idim;\n\n  /* Treat only cases:\n     crv vs pt 1D\n     crv vs crv\n     crv vs sf\n     crv vs pt 2D\n     sf vs pt 2D\n     */\n\n  if (!(((po1->iobj == SISLCURVE && po2->iobj >= SISLCURVE) ||\n\t (po2->iobj == SISLCURVE && po1->iobj >= SISLCURVE)) ||\n\t(kdim == 1 && (po1->iobj + po2->iobj) == (SISLPOINT + SISLCURVE)) ||\n\t(kdim == 2 && (po1->iobj + po2->iobj) >= (SISLPOINT + SISLCURVE))))\n    goto out;\n\n  /* Compute number of intersection points on edges, 0 1 or 2. */\n  if (vedge[0] == SISL_NULL)\n    knum = 0;\n  else\n    knum = vedge[0]->ipoint;\n\n  if (vedge[1] != SISL_NULL)\n    knum += vedge[1]->ipoint;\n\n\n  if (knum > 0)\n    {\n      sh6edgpoint (vedge, &up, &knum, &kstat);\n      if (kstat < 0)\n\tgoto error;\n    }\n\n  if (knum == 2)\n    {\n      /* when two edge points, check if they are connected */\n      sh6getlist (up[0], up[1], &index1, &index2, &kstat);\n      if (kstat == 0)\n\tknum = 0;\n    }\n\n  if (knum == 0) /* BOH & ALA Added: 200993 */\n  {\n    /* Task performed.  */\n\n    *jstat = 0;\n    goto out;\n  }\n\n  /* Copy pointer of edge points into local pointer array */\n  /*for (ki = 0; ki < knum; ki++)\n\n    lup[ki] = up[ki]; */\n\n  /* Get the internal point if any */\n  if (po1->iobj == SISLPOINT)\n    kobj = 2;\n  else\n    kobj = 1;\n\n    s6idint (po1, po2, *rintdat, &qptint, kobj);\n    if (qptint)\n    {\n       qpt = qptint;\n       ki=-1;\n    }\n    else\n    {\n       ki = 0;\n       qpt = up[0];\n    }\n\n  for (; ki < knum; ki++ )\n    {\n\n      if (ki >= 0) qpt = up[ki];\n\n      /* Browse on the dimension of geometry space and the type of\n         the input objects.     */\n\n      if (kdim == 1 && ((po1->iobj == SISLCURVE && po2->iobj == SISLPOINT)\n\t\t     || (po2->iobj == SISLCURVE && po1->iobj == SISLPOINT)))\n\t{\n\t  /* Compute pre-topology in one-dimensional curve-level value\n             intersection.            */\n\n\t  sh1781 (po1, po2, aepsge, rintdat, qpt, &knewpt, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  *jnewpt += knewpt;\n\t}\n      else if (po1->iobj == SISLCURVE && po2->iobj == SISLCURVE)\n\t{\n\t  /* curve-curve intersection.  */\n\t  sh1780 (po1, po2, aepsge, rintdat, qpt, &knewpt, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  *jnewpt += knewpt;\n\t}\n      else if (kdim == 2 &&\n\t       ((po1->iobj == SISLCURVE && po2->iobj == SISLPOINT)\n\t\t|| (po2->iobj == SISLCURVE && po1->iobj == SISLPOINT)))\n\t{\n\t  /* 2 dimensional point-curve intersection.  */\n\n\t  sh1786 (po1, po2, aepsge, rintdat, qpt, &knewpt, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  *jnewpt += knewpt;\n\t}\n      else if (kdim == 2 &&\n\t       ((po1->iobj == SISLSURFACE && po2->iobj == SISLPOINT)\n\t\t|| (po2->iobj == SISLSURFACE && po1->iobj == SISLPOINT)))\n\t{\n\t  /* 2 dimensional point-surface intersection.  */\n\n\t  sh1787 (po1, po2, aepsge, rintdat, qpt, &knewpt, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  *jnewpt += knewpt;\n\t}\n      else if (kdim == 3 &&\n\t       ((po1->iobj == SISLCURVE && po2->iobj == SISLSURFACE) ||\n\t\t(po1->iobj == SISLSURFACE && po2->iobj == SISLCURVE)))\n\t{\n\t  /* Surface-curve intersection in 3-dimensional geometry space. */\n\n\t  sh1779 (po1, po2, aepsge, rintdat, qpt, &knewpt, &kstat);\n\t  if (kstat < 0)\n\t    goto error;\n\t  *jnewpt += knewpt;\n\n\t}\n    }\n\n  /* Task performed.  */\n\n  *jstat = 0;\n  goto out;\n\n  /* Error in lower level routine.  */\n\nerror:*jstat = kstat;\n  goto out;\n\nout:\n  if (up != SISL_NULL)\n    freearray (up);\n\n  return;\n}\n"
  },
  {
    "path": "src/shsing.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: shsing.c,v 1.2 2001-03-19 16:06:04 afr Exp $\n *\n */\n\n#define SHSING\n\n#include \"sislP.h\"\n\n/*\n* Forward declarations.\n* ---------------------\n*/\n#if defined(SISLNEEDPROTOTYPES)\nstatic void shsing_s9corr(double [], double [], double[]);\nstatic void shsing_s9dir(double [], double [], double[]);\n#else\nstatic void shsing_s9corr();\nstatic void shsing_s9dir();\n#endif\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n  shsing(SISLSurf *psurf1,SISLSurf *psurf2,double limit[],\n\t double enext[], double gpos[],int *jstat)\n#else\nvoid shsing(psurf1,psurf2,limit,enext,gpos,jstat)\n     SISLSurf         *psurf1;\n     SISLSurf         *psurf2;\n     double       limit[];\n     double       enext[];\n     double       gpos[];\n     int          *jstat;\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*\n* PURPOSE    : To find one point in each surface where the two normals\n*              are parallel to each other and to the difference vector \n*              between the two points.\n*\n* INPUT      : psurf1 - Pointer to first surface\n*              psurf2 - Pointer to second surface\n*              limit  - Parameter boarders of both surfaces.\n*                       limit[0] - limit[1] Parameter interval first\n*                                  surface first direction.\n*                       limit[2] - limit[3] Parameter interval first \n*                                  surface second direction.\n*                       limit[4] - limit[5] Parameter interval second \n*                                  surface first direction.\n*                       limit[6] - limit[7] Parameter interval second \n*                                  surface second direction.\n*              enext    - Parameter start value for iteration(4 values).\n*\n*\n* OUTPUT     : gpos    - Parameter values of the found singularity.(4 values)\n*              jstat   - status messages  \n*                                = 1   : Extremum found.\n*                                = 0   : Extremum NOT found.\n*                                < 0   : error.\n*\n*\n* METHOD     :  - Start with a guess value (u,v) in domain of \n*                 surface 1 (S(u,v))\n*           (a) - Find domain value (r,t) of closest point (to S(u,v) \n*                 in surface 2 (Q(r,t))\n*               - If vf1(u,v) = <Su,Normal(Q> and vf2(u,v)= <Sv,Normal(Q> \n*                 is small enough  stop.  (<,> means scalar prod.)\n*               - Find du and dv by taylorizing vf1 and vf2.\n*                 This include finding the derivatives of the closest point \n*                 function (r(u,v),t(u,v)) with respect to u and v. \n*                 (called h(u,v) in article, see coments in shsing_s9dir)\n*               - u:= u+du v:= v+dv, goto (a)\n*\n*\n* REFERENCES : Solutions of tangential surface and curve intersections.\n*              R P Markot and R L Magedson\n*              Computer-Aided Design; vol. 21, no 7 sept. 1989, page 421-429\n*\n*\n* WRITTEN BY : Ulf J. Krystad, SI, JANUARY 1991\n*\n*********************************************************************\n*/                       \n{                        \n  int kstat = 0;            /* Local status variable.                      */\n  int kpos = 0;             /* Position of error.                          */\n  int ki;                   /* Loop control                                */\n  int kleftt=0;             /* Variables used in the evaluator.            */\n  int klefts=0;             /* Variables used in the evaluator.            */\n  int kleftu=0;             /* Variables used in the evaluator.            */\n  int kleftv=0;             /* Variables used in the evaluator.            */\n  int kder=2;               /* Order of derivatives to be calulated        */\n  int kdim=3;               /* Dimension of space the surface lies in      */\n  int knbit;                /* Number of iterations                        */\n  double tdelta[4];         /* Length of parameter intervals.              */\n  double tdist;             /* The current norm of the cross product       */\n                            /* between the two normals                     */\n  double tprev;             /* The current norm of the cross product       */\n                            /* between the two normals                     */\n  double td[4],t1[4],tdn[4];/* Distances between old and new parameter     */\n\t\t\t    /* value in the four parameter directions.     */\n  double sval1[21];         /* Value ,first and second derivatiev of surf. */ \n  double *snorm1=sval1+18;  /* Normal vector of the surface                */\n  double sval2[21];         /* Value ,first and second derivatiev of surf. */ \n  double *snorm2=sval2+18;  /* Normal vector of the surface                */\n  double snext[4];          /* Parameter values                            */\n  double temp[3];           /* Temp vector storing cross products.         */\n  double start[2];          /* Parameters limit of second surface, used in */\n                            /* call to closest point                       */\n  double end[2];            /* Parameters limit of second surface, used in */\n                            /* call to closest point                       */\n  double guess[2];          /* Start point for closest point iteration     */\n  double tol = (double)10000.0*REL_COMP_RES; /* equality tol. in par.space */\n  SISLPoint *ppoint=SISL_NULL;   /* Contains the current position in first      */ \n                            /* surface used in closest point iteration     */\n  int max_iter=20;          /* Maximal number of iteration allowed         */\n\n  /* --------------------------------------------------------------------- */\n  \n  /* Test input.  */\n  if (psurf1->idim != kdim) goto err106;\n  if (psurf2->idim != kdim) goto err106;\n  \n  /* Fetch referance numbers from the serach intervals for the surfaces.  */\n  tdelta[0] = limit[1] - limit[0];\n  tdelta[1] = limit[3] - limit[2];\n  tdelta[2] = limit[5] - limit[4];\n  tdelta[3] = limit[7] - limit[6];\n\n  /* Set limit values, used in closest point iteration */\n  start[0] = limit[4];\n  start[1] = limit[6];\n  end[0]   = limit[5];\n  end[1]   = limit[7];\n  \n  /* Create point, used in closest point iteration */\n  ppoint = newPoint(sval1,3,0);\n  \n  /* Collapsed ? */\n  for (ki=0;ki<4;ki++) if (tdelta[ki] < tol) goto errsmall;  \n  \n  /* Initiate output variables.  */\n  for (ki=0;ki<4;ki++)     gpos[ki] = enext[ki];\n\n  /* Evaluate 0.-2. derivatives of first surface */\n  s1421(psurf1,kder,gpos,&kleftt,&klefts,sval1,snorm1,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Get closest point in second surface. */\n  guess[0] = gpos[2];\n  guess[1] = gpos[3];\n  s1773(ppoint,psurf2,REL_COMP_RES,start,end,guess,gpos+2,&kstat);\n  if (kstat < 0) goto error;\n  \n  /* Evaluate 0.-2. derivatives of second surface */\n  s1421(psurf2,kder,gpos+2,&kleftu,&kleftv,sval2,snorm2,&kstat);\n  if (kstat < 0) goto error;\n\n  /* Get length of normal cross product */\n  s6crss(snorm1,snorm2,temp);\n  tprev = s6length(temp,kdim,&kstat);\n  \n  /* Compute the Newton stepdistance vector in first surface. */\n  shsing_s9dir(td,sval1,sval2);\n  \n  /* Adjust if we are not inside the parameter intervall. */\n  for (ki=0;ki<4;ki++)    t1[ki] = td[ki];\n\n  shsing_s9corr(t1,gpos,limit);\n  \n  /* Iteratation loop.  */\n  \n  for (knbit = 0; knbit < max_iter; knbit++)\n    {\n      \n      for (ki=0;ki<2;ki++)    snext[ki] = gpos[ki] + t1[ki];\n   \n      /* Evaluate 0.-2. derivatives of first surface */\n      s1421(psurf1,kder,snext,&kleftt,&klefts,sval1,snorm1,&kstat);\n      if (kstat < 0) goto error;\n      \n      /* Get closest point in second surface. */\n      guess[0] = gpos[2];\n      guess[1] = gpos[3];\n      s1773(ppoint,psurf2,REL_COMP_RES,start,end,guess,snext+2,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Evaluate 0.-2. derivatives of second surface */\n      s1421(psurf2,kder,snext+2,&kleftu,&kleftv,sval2,snorm2,&kstat);\n      if (kstat < 0) goto error;\n\n      /* Get length of normal cross product */\n      s6crss(snorm1,snorm2,temp);\n      tdist = s6length(temp,kdim,&kstat);\n  \n      /* Compute the Newton stepdistance vector. */\n      shsing_s9dir(tdn,sval1,sval2);\n      \n      if (tdist <= tprev)\n\t{\n\t  /* Ordinary converging. */\n\t  \n\t  for (ki=0;ki<4;ki++)\n\t    {\n\t      gpos[ki] = snext[ki];\n\t      td[ki] = t1[ki] = tdn[ki];\n\t    }\n\t  \n\t  /* Adjust if we are not inside the parameter intervall. */\n\t  shsing_s9corr(t1,gpos,limit);\n\t\t  \n          if ((fabs(t1[0]/tdelta[0]) <= REL_COMP_RES) &&\n\t      (fabs(t1[1]/tdelta[1]) <= REL_COMP_RES) &&\n\t      (fabs(t1[2]/tdelta[2]) <= REL_COMP_RES) &&\t   \n\t      (fabs(t1[3]/tdelta[3]) <= REL_COMP_RES))\n\t      {\n\t\tfor (ki=0;ki<2;ki++) gpos[ki] += t1[ki];\n\t\t/* Evaluate 0.-2. derivatives of first surface */\n\t\ts1421(psurf1,kder,gpos,&kleftt,&klefts,sval1,snorm1,&kstat);\n\t\tif (kstat < 0) goto error;\n\t\t\n\t\t/* Get closest point in second surface. */\n\t\tguess[0] = gpos[2];\n\t\tguess[1] = gpos[3];\n\t\ts1773(ppoint,psurf2,REL_COMP_RES,start,end,guess,gpos+2,&kstat);\n\t\tif (kstat < 0) goto error;\n\t\tbreak;\n\t      }\n\t  tprev = tdist;\n\t}\n      \n      else\n\t{\n\t  /* Not converging, half step length try again. */\n\t  \n\t  for (ki=0;ki<4;ki++) t1[ki] /= (double)2;\n\t}\n    }\n  \n  /* Iteration stopped, test if point is extremum */\n  /* Unsure about what i right here , angle between normals and difference vector ?? */\n  if (tdist <= tol)\n    *jstat = 1;\n  else\n    *jstat = 0;\n\n \n  /* Test if the iteration is close to a knot */\n  if (fabs(gpos[0] - psurf1->et1[kleftt])/tdelta[0] < tol)\n    gpos[0] = psurf1->et1[kleftt];\n  else if (fabs(gpos[0] - psurf1->et1[kleftt+1])/tdelta[0] < tol)\n    gpos[0] = psurf1->et1[kleftt+1];\n  \n  if (fabs(gpos[1] - psurf1->et2[klefts])/tdelta[1] < tol)\n    gpos[1] = psurf1->et2[klefts];\n  else if (fabs(gpos[1] - psurf1->et2[klefts+1])/tdelta[1] < tol)\n    gpos[1] = psurf1->et2[klefts+1];\n\n  if (fabs(gpos[2] - psurf2->et1[kleftu])/tdelta[2] < tol)\n    gpos[2] = psurf2->et1[kleftu];\n  else if (fabs(gpos[2] - psurf2->et1[kleftu+1])/tdelta[2] < tol)\n    gpos[2] = psurf2->et1[kleftu+1];\n  \n  if (fabs(gpos[3] - psurf2->et2[kleftv])/tdelta[3] < tol)\n    gpos[3] = psurf2->et2[kleftv];\n  else if (fabs(gpos[3] - psurf2->et2[kleftv+1])/tdelta[3] < tol)\n    gpos[3] = psurf2->et2[kleftv+1];\n  \n  /* Iteration completed.  */\n  goto out;\n  \n  /* --------------------------------------------------------------------- */ \n  /* Error in input. Dimension not equal to 3 */\n  err106: *jstat = -106;\n  s6err(\"shsing\",*jstat,kpos);\n  goto out;                  \n\n  /* Error in input. One parameter interval colapsed. */\n  errsmall: *jstat = -200;\n  s6err(\"shsing\",*jstat,kpos);\n  goto out;                  \n  \n  /* Error in lower level routine.  */\n  error : *jstat = kstat;\n  s6err(\"shsing\",*jstat,kpos);\n  goto out;                  \n  \n out:if(ppoint) freePoint(ppoint);\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  shsing_s9corr(double gd[], double coef[],double limit[])\n#else\nstatic void shsing_s9corr(gd,coef,limit)\n     double gd[];\n     double coef[];\n     double limit[];\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To be sure that we are inside the boarder of the\n*              parameter plan. If we are outside clipping is used\n*\t       to adjust the step value.\n*\n*\n* INPUT      : coef    - Current position.\n*              limit   - Parameter boarders of both surfaces.\n*\n*\n*\n* INPUT/OUTPUT : gd    - Proposed delta values.\n*\n*\n* METHOD     : Cutting the line towards the parameter box.\n*\n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Ulf J. Krystad, SI, NOVEMBER 1990\n*\n*********************************************************************\n*/                       \n{\n  int ki;\n\n  for (ki=0;ki<4;ki++)\n    {\n      if (coef[ki] + gd[ki] < limit[2*ki])\n\tgd[ki] = limit[2*ki]    - coef[ki];\n      else if (coef[ki] + gd[ki] > limit[2*ki+1])\n\tgd[ki] = limit[2*ki +1] - coef[ki];\n    }\n\n}\n\f\n#if defined(SISLNEEDPROTOTYPES)\nstatic void\n  shsing_s9dir(double cdiff[],double evals[],double evalq[])\n#else\nstatic void shsing_s9dir(cdiff,evals,evalq)\n     double cdiff[];\n     double evals[];\n     double evalq[];\n#endif\n/*\n*********************************************************************\n*\n*********************************************************************\n*                                                                   \n* PURPOSE    : To calculate the increments in the first surface domain.\n*              \n*\n*\n* INPUT      : evals - Value and derivatives  on first surface.\n*              evalq - Value and derivatives  on second surface.\n*              \n*\n* OUTPUT     : cdiff1  - Parameter increments in two directions.\n*            \n*\n*\n* METHOD     : See comments in main header.\n*              The only thing missing in the article is the derivation of the\n*              function h(u,v). Calling this function (r(u,v), t(u,v))\n*              we know that\n*              For all (u,v) (<,> meaning scalar product)\n*              <S(u,v)-Q(r(u,v),t(u,v)),Qt(r(u,v),t(u,v))> = 0\n*              <S(u,v)-Q(r(u,v),t(u,v)),Qr(r(u,v),t(u,v))> = 0\n*              This means that (derivation by u and v)\n*              <Su-[Qt*tu+Qr*ru],Qt> + <S-Q,Qtt*tu + Qtr*ru> = 0\n*              <Su-[Qt*tu+Qr*ru],Qr> + <S-Q,Qrt*tu + Qrr*ru> = 0\n*              <Sv-[Qt*tv+Qr*rv],Qt> + <S-Q,Qtt*tv + Qtr*rv> = 0\n*              <Sv-[Qt*tv+Qr*rv],Qr> + <S-Q,Qrt*tv + Qrr*rv> = 0\n*              Solving these four equations gives us ru,rv,tu,tv. \n*\n* REFERENCES :\n*\n*\n* WRITTEN BY : Ulf J. Krystad, SI, JANUARY 1991\n*\n*********************************************************************\n*/                       \n{                        \n\n\n  int ki;                             /* Loop control.                               */\n  int kdim = 3;                       /* Dim of object space.                        */\n  double *sval;                       /* Pointer to first surface value              */\n  double *s_u,*s_v,*s_uu,*s_uv,*s_vv; /* Pointers to first surface derivatives       */\n  double *ns;                         /* Pointer to first surface normal             */\n  double *qval;                       /* Pointer to second surface value             */\n  double *q_t,*q_r,*q_tt,*q_tr,*q_rr; /* Pointer to second surface derivatives       */\n  double *nq;                         /* Pointer to second surface normal            */\n  double nq_u[3], nq_v[3];            /* Derivatives of second surface normal (with u and v !) */\n  double help1[3], help2[3];          /* Help arrays                                 */\n  double help3[3], help4[3];          /* Help arrays                                 */\n  double matr[4];                     /* Matrix in linear equation to be solved      */\n  int    piv[2];                      /* Pivotation array                            */\n  double sq[3];                       /* The difference cevtor S-Q                   */\n  double h_u[2];                      /* The partial derivative of h() by u          */\n  double h_v[2];                      /* The partial derivative of h() by v          */\n  int kstat;                          /* Local status                                */\n  \n  /* ------------------------------------------------------------------------------- */\n  \n  cdiff[0] = DZERO;\n  cdiff[1] = DZERO;\n  cdiff[2] = DZERO;\n  cdiff[3] = DZERO;\n\n  /* Init, Set pointers to input values */\n  sval = evals;\n  qval = evalq;\n  \n  s_u   = sval + kdim;\n  s_v   = s_u   + kdim;\n  s_uu  = s_v   + kdim;\n  s_uv  = s_uu  + kdim;\n  s_vv  = s_uv  + kdim;\n  ns    = s_vv  + kdim;\n\n  q_t   = qval + kdim;\n  q_r   = q_t   + kdim;\n  q_tt  = q_r   + kdim;\n  q_tr  = q_tt  + kdim;\n  q_rr  = q_tr  + kdim;\n  nq    = q_rr  + kdim;\n\n  /* Get the difference vector S-Q */\n  s6diff(sval,qval,kdim,sq);\n  \n  /* Find the derivatives of the h() function by solving 2 2x2 systems (same matrix) */\n  matr[0] = s6scpr(q_tt,sq,kdim) - s6scpr(q_t,q_t,kdim);\n  matr[1] = s6scpr(q_tr,sq,kdim) - s6scpr(q_t,q_r,kdim);\n  matr[2] = matr[1];\n  matr[3] = s6scpr(q_rr,sq,kdim) - s6scpr(q_r,q_r,kdim);  \n\n  h_u[0] = -s6scpr(s_u,q_t,kdim);\n  h_u[1] = -s6scpr(s_u,q_r,kdim);\n\n  h_v[0] = -s6scpr(s_v,q_t,kdim);\n  h_v[1] = -s6scpr(s_v,q_r,kdim);\n  \n\n  /* Factorize matrix */\n  s6lufacp(matr,piv,2,&kstat);\n  if (kstat != 0) goto out;\n  \n  /* Solve */\n  s6lusolp(matr,h_u,piv,2,&kstat);\n  if (kstat != 0) goto out;\n\n  /* Solve */\n  s6lusolp(matr,h_v,piv,2,&kstat);\n  if (kstat != 0) goto out;\n\n  /* Construct matrix for finding du and dv */\n  for (ki=0;ki<kdim;ki++) \n    {\n      help1[ki] = q_tt[ki]*h_u[0] + q_tr[ki]*h_u[1];\n      help2[ki] = q_tr[ki]*h_u[0] + q_rr[ki]*h_u[1];\n    }\n  s6crss(help1,q_r,help3);\n  s6crss(q_t,help2,help4);\n  \n  for (ki=0;ki<3;ki++) nq_u[ki] = help3[ki] + help4[ki];\n\n  for (ki=0;ki<kdim;ki++) \n    {\n      help1[ki] = q_tt[ki]*h_v[0] + q_tr[ki]*h_v[1];\n      help2[ki] = q_tr[ki]*h_v[0] + q_rr[ki]*h_v[1];\n    }\n  s6crss(help1,q_r,help3);\n  s6crss(q_t,help2,help4);\n  \n  for (ki=0;ki<3;ki++) nq_v[ki] = help3[ki] + help4[ki];\n\n  for (ki=0;ki<4;ki++) matr[ki] = DZERO;\n  \n  for (ki=0;ki<3;ki++) \n    {\n      matr[0] += s_uu[ki]*nq[ki] + s_u[ki]*nq_u[ki];\n      matr[1] += s_uv[ki]*nq[ki] + s_u[ki]*nq_v[ki];\n      matr[2] += s_uv[ki]*nq[ki] + s_v[ki]*nq_u[ki];\n      matr[3] += s_vv[ki]*nq[ki] + s_v[ki]*nq_v[ki];\n    }\n  \n  /* solve the linear 2x2 system */\n\n  s6lufacp(matr,piv,2,&kstat);\n  if (kstat != 0) \n    {\n      if( DNEQUAL(matr[0],DZERO)) cdiff[0] = - s6scpr(s_u,nq,kdim)/matr[0];\n      else if( DNEQUAL(matr[1],DZERO)) cdiff[1] = - s6scpr(s_u,nq,kdim)/matr[1];\n      else if( DNEQUAL(matr[2],DZERO)) cdiff[0] = - s6scpr(s_v,nq,kdim)/matr[2];\n      else if( DNEQUAL(matr[3],DZERO)) cdiff[1] = - s6scpr(s_v,nq,kdim)/matr[3];\n\n    }\n  else \n    {\n      cdiff[0] = - s6scpr(s_u,nq,kdim);\n      cdiff[1] = - s6scpr(s_v,nq,kdim);\n      s6lusolp(matr,cdiff,piv,2,&kstat);\n    }\n  out:;\n  \n}\n"
  },
  {
    "path": "src/spli_silh.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: spli_silh.c,v 1.2 2001-03-19 16:06:04 afr Exp $\n *\n */\n\n\n#define SPLI_SILH\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid\n    spli_silh (SISLIntdat ** pintdat,\n\t    SISLObject * po1,\n\t    int *jstat)\n\n#else\nvoid\n   spli_silh (pintdat,\n\t    po1,\n\t    jstat)\n\n     SISLIntdat **pintdat;\n     SISLObject *po1;\n     int *jstat;\n\n#endif\n/*\n*********************************************************************\n*\n* PURPOSE    : To split intersection curves at knot values where\n*              they are only C0, only silhuett case.\n*              (easy to change to ordinary intersections when\n*              only C0 geometry is allowed.)\n*\n*\n* INPUT      : pintdat     - Pointer to pointer to the SISLIntdat data.\n*              po1         - Pointer surface object.\n*\n*\n* OUTPUT     :  jstat  - status messages\n*                       = 0      : ok\n*                       < 0      : error\n*\n*\n* METHOD     :\n*\n* USE        : The function is only working i 3-D\n*\n* REFERENCES :\n*\n*-\n* CALLS      :\n*\n* WRITTEN BY : Ulf J. Krystad, SI, Oslo, Norway, January-1993\n*\n*********************************************************************\n*/\n{\n  int kstat;\t\t\t/* Local status variable.          \t  */\n  int kpos = 0;\t\t\t/* Position of error.              \t  */\n  int ktype = 0;\t\t/* Type of intersection curve.    \t  */\n  int klist = 0;\t\t/* No of lists in pintdat.         \t  */\n  int indstart = 0;\t\t/* Index.                      \t          */\n  int indlast = 0;\t\t/* Index.                      \t          */\n  int index1 = 0;\t\t/* Index.                      \t          */\n  int indum = 0;\t\t/* Not used index.            \t          */\n  int ki=0, kp=0;\t\t/* Loop controls.                         */\n  int mu_1=0, mu_2=0;\t\t/* Knot multiplicity.                     */\n  int left1=0,left2=0;\t\t/* Knot navigators.                       */\n  int ac_no=0;\t\t        /* No of points in first half of split crv*/\n  int knum=0;\t\t        /* No of points in crv to split.          */\n  int test=0;\t\t        /* Flag input to s6idnpt.                 */\n  SISLIntpt *pfirst=SISL_NULL;\t/* First point in a list.                 */\n  SISLIntpt *plast=SISL_NULL;\t/* Last point in a list.                  */\n  SISLIntpt *plast_prev=SISL_NULL;\t/* Next to last point in a list.          */\n  SISLIntpt *pshadow=SISL_NULL;\t/* Copy of pnext.                         */\n  SISLIntpt *pnext=SISL_NULL;\t/* Navigator in  a list.             \t  */\n  SISLIntpt *prev=SISL_NULL;\t \t/* Navigator in  a list.             \t  */\n  SISLIntpt *pother=SISL_NULL;\t/* Navigator in  a list.             \t  */\n  SISLSurf  *psurf=SISL_NULL;\t/* The surface in question.            \t  */\n  double arr[2];            \t/* Delta vector in par space              */\n  /* -------------------------------------------------------------------- */ \n       \n  *jstat = 0;\n  \n  /* If we do not have any intersection data we just return. */     \n  if ((*pintdat) == SISL_NULL)\n    goto out;\n  \n  if (po1->iobj != SISLSURFACE) goto errinp;\n  psurf = po1->s1;\n   \n\n  /* First pass, examine for split pts. */\n  for (ki = 0; ki < (*pintdat)->ilist; ki++)\n  {\n     knum     = (*pintdat)->vlist[ki]->inumb;\n     pfirst   = (*pintdat)->vlist[ki]->pfirst;\n     plast    = (*pintdat)->vlist[ki]->plast;\n     indstart = (*pintdat)->vlist[ki]->ind_first;\n     indlast  = (*pintdat)->vlist[ki]->ind_last;\n     ktype    = (*pintdat)->vlist[ki]->itype;\n     prev     = pfirst;\n     pnext    = pfirst->pnext[indstart];\n     ac_no    = 1;\n\n     /* VSK, 23/2-93. First check if the list describes an area of\n\tcoincidence.  */\n     \n     if (pfirst->iinter == SI_TRIM) continue;\n     \n     if (pfirst == plast &&\n\t knum > 3)\n     {\n\tmu_1 = s6knotmult(psurf->et1,psurf->ik1,\n\t\t\t   psurf->in1,&left1,pfirst->epar[0], &kstat);\n\tmu_2 = s6knotmult(psurf->et2,psurf->ik2,\n\t\t\t  psurf->in2,&left2,pfirst->epar[1], &kstat);\n\t\n\t/* Always seperate */\n\t/* if(mu_1 > psurf->ik1 - 3 ||\n\t   mu_2 > psurf->ik2 - 3) \n\t   { */\n\t\n\t/* Don't allow closed ring. */\n\tkpos = 10;\n\tplast_prev = plast->pnext[indlast];\n\tpshadow    = hp_copyIntpt(plast);\n\tif (!pshadow) goto err101;\n\tsh6idnpt(pintdat, &pshadow, test=FALSE, &kstat);\n\tif (kstat < 0) goto error;\n\t\n\t\n\tsh6insertpt(plast_prev, plast, pshadow, &kstat);\n\tif (kstat < 0) goto error;\n\t\n\tsh6disconnect(plast, pshadow, &kstat);\n\tif (kstat < 0) goto error;\n\tsh6getlist(pshadow, plast_prev, &index1, &indum, &kstat);\n\tkpos = 11;\n\tif (kstat < 0 || index1 < 0) goto errinconsis;\n\t\n\tplast    = (*pintdat)->vlist[ki]->plast = pshadow;\n\tindlast  = (*pintdat)->vlist[ki]->ind_last = index1;\n\n\t/*UJK, July 93 */\n\tsh6getlist(pfirst, pnext, &index1, &indum, &kstat);\n\tkpos = 12;\n\tif (kstat < 0 || index1 < 0) goto errinconsis;\n\tindstart = (*pintdat)->vlist[ki]->ind_first = index1;\n\t\n\t/*\t} */\n     }\n     \n     if (knum > 2)\n     {\n\twhile (pnext != plast)\n\t{\n\t   ac_no++;\n\t   kpos = 1;\n\t   if (ac_no >= knum) goto errinconsis;\n\t   sh6getother(pnext,prev,&pother,&kstat);\n\t   if (kstat < 0) goto error;\n\t   \n\t   mu_1 = s6knotmult(psurf->et1,psurf->ik1,\n\t\t\t      psurf->in1,&left1,pnext->epar[0], &kstat);\n\t   mu_2 = s6knotmult(psurf->et2,psurf->ik2,\n\t\t\t      psurf->in2,&left2,pnext->epar[1], &kstat);\n\t   \n\t   if(mu_1 > psurf->ik1 - 3 ||\n\t      mu_2 > psurf->ik2 - 3)\n\t   {\n\n\t      /* Split list */\n\t      pshadow = hp_copyIntpt(pnext);\n\t      if (!pshadow) goto err101;\n\t      sh6idnpt(pintdat, &pshadow, test=FALSE, &kstat);\n\t      if (kstat < 0) goto error;\n\t      \n\t      sh6insertpt(prev, pnext, pshadow, &kstat);\n\t      if (kstat < 0) goto error;\n\t      \n\t      sh6disconnect(pnext, pshadow, &kstat);\n\t      if (kstat < 0) goto error;\n\t      \n\t      /* Update first part of list. */\n\t      sh6getlist(pshadow, prev, &index1, &indum, &kstat);\n\t      kpos = 3;\n\t      if (kstat < 0 || index1 < 0) goto errinconsis;\n\t      \n\t      (*pintdat)->vlist[ki]->inumb    = ac_no;\n\t      (*pintdat)->vlist[ki]->ind_last = index1;\n\t      (*pintdat)->vlist[ki]->plast    = pshadow;\n\t      \n\t      /* Make and update second part of list. */\n\t      sh6getlist(pnext, pother, &index1, &indum, &kstat);\n\t      kpos = 4;\n\t      if (kstat < 0 || index1 < 0) goto errinconsis;\n\t      \n\t      klist = (*pintdat)->ilist;\n\t      kpos = 5;\n\t      if (klist > (*pintdat)->ilmax) goto errinconsis;\n\t      if (klist == (*pintdat)->ilmax)\n\t      {\n\t\t /* Increase size of vlist-array */\n\t\t (*pintdat)->ilmax += 20;\n\t\t \n\t\t if (((*pintdat)->vlist =\n\t\t      increasearray ((*pintdat)->vlist, (*pintdat)->ilmax,\n\t\t\t\t     SISLIntlist *)) == SISL_NULL)\n\t\t    goto err101;\n\t      }\n\t      \n\t      \n\t      if(((*pintdat)->vlist[klist] = newIntlist (pnext, plast, ktype))\n\t\t == SISL_NULL) goto err101;\n\t      (*pintdat)->vlist[klist]->inumb = knum + 1 - ac_no;\n\t      (*pintdat)->vlist[klist]->ind_first = index1;\n\t      (*pintdat)->vlist[klist]->ind_last  = indlast;\n\t      for (kp = 0; kp < 4; kp++)\n\t\t (*pintdat)->vlist[klist]->pretop[kp] =\n\t\t    (*pintdat)->vlist[ki]->pretop[kp];\n\t      \n\t      (*pintdat)->ilist++;\n\t      break;\n\t   }\n\t   else\n\t   {\n\t      prev = pnext;\n\t      pnext = pother;\n\t   }\n\t   \n\t} \n\t\n     }\n  }\n  \n  /* Second pass, select left/right evaluator at start and stop pts. */\n  for (ki = 0; ki < (*pintdat)->ilist; ki++)\n  {\n     pfirst   = (*pintdat)->vlist[ki]->pfirst;\n     plast    = (*pintdat)->vlist[ki]->plast;\n     indstart = (*pintdat)->vlist[ki]->ind_first;\n     indlast  = (*pintdat)->vlist[ki]->ind_last;\n\n     /* Startpoint. */\n     pnext    = pfirst->pnext[indstart];\n     s6diff(pnext->epar,pfirst->epar,2,arr);\n     pfirst->iside_1 = (arr[0]>=0 ? 1 : -1);\n     pfirst->iside_2 = (arr[1]>=0 ? 1 : -1);\n     \n     /* Endpoint. */\n     pnext    = plast->pnext[indlast];\n     s6diff(pnext->epar,plast->epar,2,arr);\n     plast->iside_1 = (arr[0]>=0 ? 1 : -1);\n     plast->iside_2 = (arr[1]>=0 ? 1 : -1);\n     \n     \n     /* UJK, July 93: Clean up computed results */\n     if (pfirst->geo_data_1)\n\tfreearray (pfirst->geo_data_1);\n     if (pfirst->geo_data_2)\n\tfreearray (pfirst->geo_data_2);\n     pfirst->geo_data_1 = SISL_NULL;\n     pfirst->size_1 = 0;\n     pfirst->geo_data_2 = SISL_NULL;\n     pfirst->size_2 = 0;\n     pfirst->evaluated = FALSE;\n     \n     if (plast->geo_data_1)\n\tfreearray (plast->geo_data_1);\n     if (plast->geo_data_2)\n\tfreearray (plast->geo_data_2);\n     plast->geo_data_1 = SISL_NULL;\n     plast->size_1 = 0;\n     plast->geo_data_2 = SISL_NULL;\n     plast->size_2 = 0;\n     plast->evaluated = FALSE;\n  }  \n    \n     \n  \n  *jstat = 0;\n  goto out;\n  /* ERROR EXITS. ____________________________________ */\n  \n  /* Error in alloc */\n  err101:\n  *jstat = -101;\n  s6err (\"spli_silh\", *jstat, kpos);\n  goto out;\n\n  /* Error in input */\n  errinp:\n  *jstat = -200;\n  s6err (\"spli_silh\", *jstat, kpos);\n  goto out;\n\n  /* Error data structure */\n  errinconsis:\n  *jstat = -200;\n  s6err (\"spli_silh\", *jstat, kpos);\n  goto out;\n\n  error:\n  *jstat = kstat;\n  s6err (\"spli_silh\", *jstat, kpos);\n  goto out;\n\nout:\n  ;\n}\n"
  },
  {
    "path": "src/tstcyclknt.c",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"sisl-copyright.h\"\n\n/*\n *\n * $Id: tstcyclknt.c,v 1.1 1994-04-21 12:10:42 boh Exp $\n *\n */\n\n\n#define TEST_CYCLIC_KNOTS\n\n#include \"sislP.h\"\n\f\n#if defined(SISLNEEDPROTOTYPES)\nvoid \n  test_cyclic_knots(double et[],int in,int ik,int *jstat)\n#else\nvoid test_cyclic_knots(et,in,ik,jstat)\n     double et[];\n     int    in;\n     int    ik;\n     int    *jstat;\n#endif\n     /*\n      *********************************************************************\n      *                                                                   \n      * PURPOSE    : To test if a knot vector is cyclic.\n      *\n      *             \n      *\n      * INPUT      : et     - Knot vector\n      *              in     - Number of knots\n      *              ik     - Polynomial order\n      *\n      * OUTPUT     : \n      *              jstat  - status messages  \n      *                                        = 2 : Cyclic full freedom.\n      *                                        = 1 : Cyclic NOT full freedom.\n      *                                        = 0 : NOT cyclic.\n      *                                        < 0 : Error.\n      *\n      * METHOD     : 1. Check multiplicity of start and end parameter value\n      *              2. Check if knots before start parameter value and after\n      *                 end parameter value are repeated in a cyclic way.\n      *              3. Check that number of basis function not repeated\n      *                 are at least ik.\n      *\n      *\n      * REFERENCES :\n      *\n      *-                                      \n      * CALLS      : \n      *\n      * WRITTEN BY : Tor Dokken, SI, Oslo, Norway, April 1992\n      *\n      *********************************************************************\n      */\n{\n  int    kleft;          /* Pointer into knot interval             */\n  int    kmult1;         /* Multiplicity of start parameter value  */\n  int    kmult2;         /* Multiplicity of end  parameter value   */\n  int    ki;             /* Control variable in loop               */\n  int    kpos = 1;       /* Position of error                      */\n  int    kant;           /* Number of knots before start parameter value */\n  int    kcyclic;        /* Flag telling if cyclic basis           */\n  int    kstat;          /* Local status variable                  */\n  \n  double tperiode;       /* Periode of basis                       */\n  \n  /* Find multiplicity of et[ik-1] and et[in] */\n  \n  kleft = ik-1;\n  \n  kmult1 = s6knotmult(et,ik,in,&kleft,et[ik-1],&kstat);\n  if(kstat<0) goto error;\n  \n  kleft = in;\n  \n  kmult2 = s6knotmult(et,ik,in,&kleft,et[in],&kstat);\n  if(kstat<0) goto error;\n  \n  if (kmult1 != kmult2 || kmult1 == ik) goto noncyclic;\n  \n  kant = ik - kmult1;\n  tperiode = et[in] -et[ik-1];  \n  \n  /* Test that the first kant knots are repetitions of the knots in-kant,...,in-1 */\n  \n  for (ki=0, kcyclic=1; ki<kant ; ki++)\n    if (DNEQUAL((et[ki]+tperiode),et[in-kant+ki])) kcyclic = 0;\n  \n  /* Test that the last kant knots are repetions of knots ik,..,ik+kant-1 */\n  \n  for (ki=0; ki<kant ; ki++)\n    if (DNEQUAL((et[ik+ki]+tperiode),et[in+kmult1+ki])) kcyclic = 0;\n  \n  if (kcyclic == 0) goto noncyclic;\n  \n  /* The basis should have at least kant+ik degrees of freedom to allow for\n     a proper cyclic curve with ik degrees of real freadom since kant vertices\n     are repeated */\n  \n  if (in<ik+kant) goto missing_freedom; \n  \n  /* Cyclic with enough degrees of freedom */\n  \n  *jstat = 2;\n  goto out;\n  \n  /* Cyclic with less than ik+kant degrees of freedom */\n missing_freedom:\n  \n  *jstat = 1;\n  goto out;\n  \n  /* Noncyclic basis */\n noncyclic:\n  \n  *jstat = 0;\n  goto out;\n  \n error:\n  *jstat = kstat;\n  s6err(\"test_cyclic_knots\",*jstat,kpos);\n  goto out;\n  \n out:\n  \n  return;\n  \n}\n\n\n"
  },
  {
    "path": "streaming/include/GoReadWrite.h",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#ifndef _GOREADWRITE_H\n#define _GOREADWRITE_H\n\n#include <iostream>\n#include <vector>\n\n// forward declarations\nstruct SISLCurve;\nstruct SISLSurf;\n\n//===========================================================================\n// For the two following read-functions, the memory for the SISL objects will be\n// dynamically allocated inside the function, and a pointer is passed to the user.\n// It is the user's responsibility to free the memory afterwards.  \n// IMPORTANT:  Since the objects are allocated within SISL (which is written in \n// pure C), the C memory allocation functions are used.  To 'free' a SISLCurve \n// pointed to by 'c', you should call 'freeCurve(c)'.  The command to free\n// SISLSurf objects is 'freeSurf()'.\n//===========================================================================\n\n// Read a curve in Go-format from stream and generate a SISLCurve object from it.\nSISLCurve* readGoCurve(std::istream& go_stream);\n\n// Read a surface in Go-format from stream and generate a SISLSurf object from it.\nSISLSurf* readGoSurface(std::istream& go_stream);\n\n\n//===========================================================================\n// The following four functions are used to write SISL objects to a stream in\n// Go-format.\n//===========================================================================\n\n// Write a SISLCurve object to stream using the Go-format\nvoid writeGoCurve(SISLCurve* curve, std::ostream& go_stream);\n\n// Write the SISLSurf object to stream using the Go-format.\nvoid writeGoSurface(SISLSurf* surf, std::ostream& go_stream);\n\n//===========================================================================\n// The following is just an access function to read/write a set of 3D points\n// on the Go format.  It is unrelated to SISL, but useful when you want to\n// visualise 3D-points with the Go-compatible viewer.\n//===========================================================================\n\n// The 3D points whose coords are pointed to by 'coords' will be written in \n// Go-format to the stream.  The number of points is indicated by 'num_points'.\nvoid writeGoPoints(int num_points, double* coords, std::ostream& go_stream);\n\n// Read 3D coordinates grom a point cloud in Go-format.  The points' coordinates \n// will be filled into the vector 'coords' (whose length, divided by 3, is the \n// total number of points).  The points are read from the 'go_stream' stream.\nvoid readGoPoints(std::vector<double>& coords, std::istream& go_stream);\n\n#endif // _GOREADWRITE_H\n\n"
  },
  {
    "path": "streaming/src/GoReadWrite.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include \"GoReadWrite.h\"\n#include <vector>\n#include <iostream>\n#include <stdexcept>\n#include \"sisl.h\"\n\n\nusing namespace std;\n\nnamespace {\n    // Go-header-related info.\n    const int HEADER_SIZE = 3;\n    const int CURVE_INSTANCE_TYPE = 100;\n    const int SURFACE_INSTANCE_TYPE = 200;\n    const int POINTCLOUD_INSTANCE_TYPE = 400;\n    const int MAJOR_VERSION = 1;\n    const int MINOR_VERSION = 0;\n\n    inline int determine_go_instance_type(istream& is) \n    {\n\tint result;\n\tis >> result;\n\tfor (int dummy, i = 1; i < HEADER_SIZE; ++i)\n\t    is >> dummy;\n\tint num;\n\tis >> num;\n\tfor (int dummy, i = 0; i < num; ++i)\n\t    is >> dummy;\n\treturn result;\n    }\n\n    inline void read_basis(istream& is, int& n, int& k, vector<double>& knots) \n    {\n\tis >> n >> k;\n\tknots.resize(n + k);\n\tfor (int i = 0; i < n + k; ++i) {\n\t     is >> knots[i];\n\t}\n    }\n\n    inline void write_basis(ostream& os, const int&n, const int& k, const double* knots)\n    {\n\tos << n << ' ' << k << '\\n';\n\tfor (int i = 0; i < n + k; ++i) {\n\t    os << knots[i] << ' ';\n\t}\n\tos << '\\n';\n    }\n\n\n}; // end anonymous namespace \n\n//===========================================================================\nSISLSurf* readGoSurface(istream& go_stream)\n//===========================================================================\n{\n    if (determine_go_instance_type(go_stream) != SURFACE_INSTANCE_TYPE) {\n\tthrow runtime_error(\"stream given to readGoSurface() does not \"\n\t\t\t    \"contain surface type.\");\n    }\n    \n    // reading basic surface properties\n    int kind, dim, rational;\n    go_stream >> dim >> rational;\n    kind = rational ? 2 : 1;\n    \n    // reading basis information (one basis for each parameter)\n    int num_coefs_1, num_coefs_2;\n    int order_1, order_2;\n    vector<double> knots_1, knots_2;\n    read_basis(go_stream, num_coefs_1, order_1, knots_1);\n    read_basis(go_stream, num_coefs_2, order_2, knots_2);\n    \n    // reading control points\n    int coef_size = num_coefs_1 * num_coefs_2 * (rational ? dim + 1 : dim);\n    vector<double> coef(coef_size);\n    for (int i = 0; i < coef_size; ++i) {\n\tgo_stream >> coef[i];\n    }\n    \n    int copy = 1; // flag that the input arrays should be _copied_\n    return newSurf(num_coefs_1, \n\t\t   num_coefs_2,\n\t\t   order_1,     \n\t\t   order_2, \n\t\t   &knots_1[0], \n\t\t   &knots_2[0],\n\t\t   &coef[0],\n\t\t   kind,\n\t\t   dim,\n\t\t   copy);\n}\n\n//===========================================================================\nvoid writeGoSurface(SISLSurf* surf, ostream& go_stream)\n//===========================================================================\n{\n    if (!surf) {\n\tthrow runtime_error(\"zero pointer given to writeGoSurface()\");\n    }\n\n    // write standard header\n    go_stream << SURFACE_INSTANCE_TYPE << ' ' << MAJOR_VERSION << ' ' \n\t      << MINOR_VERSION << \" 0\\n\";\n\n    // write basic surface properties\n    const int& dim = surf->idim;\n    const int rational = (surf->ikind % 2 == 0) ? 1 : 0;\n    go_stream << dim << ' ' << rational << '\\n';\n\n    // writing basis information\n    write_basis(go_stream, surf->in1, surf->ik1, surf->et1);\n    write_basis(go_stream, surf->in2, surf->ik2, surf->et2);\n    \n    // writing control points\n    int coef_size = surf->in1 * surf->in2 * (rational ? dim + 1 : dim);\n    const double* coef_pointer = rational ? surf->rcoef : surf->ecoef;\n    for (int i = 0; i < coef_size; ++i) {\n\tgo_stream << coef_pointer[i] << ' ';\n    }\n    go_stream << endl;\n}\n\n\n//===========================================================================\nvoid writeGoCurve(SISLCurve* curve, std::ostream& go_stream)\n//===========================================================================\n{\n    if (!curve) {\n\tthrow runtime_error(\"zero pointer given to writeGoCurve()\");\n    }\n\n    // write standard header\n    go_stream << CURVE_INSTANCE_TYPE << ' ' << MAJOR_VERSION << ' ' \n\t      << MINOR_VERSION << \" 0\\n\";\n\n    // write basic curve properties\n    const int& dim = curve->idim;\n    const int rational = (curve->ikind % 2 == 0) ? 1 : 0;\n    go_stream << dim << ' ' << rational << '\\n';\n\n    // write bspline basis information\n    write_basis(go_stream, curve->in, curve->ik, curve->et);\n   \n    // write control points\n    int coef_size = curve->in * (rational ? (dim + 1) : dim);\n    const double* coef_pointer = rational ? curve->rcoef : curve->ecoef;\n    for (int i = 0; i < coef_size; ++i) {\n\tgo_stream << coef_pointer[i] << ' ';\n    }\n    go_stream << endl;\n}\n\n\n//===========================================================================\nSISLCurve* readGoCurve(istream& go_stream)\n//===========================================================================\n{\n    if (determine_go_instance_type(go_stream) != CURVE_INSTANCE_TYPE) {\n\tthrow runtime_error(\"stream given to readGoCurve() does not contain curve.\");\n    }\n    \n    // reading basic curve properties\n    int kind, dim, rational;\n    go_stream >> dim >> rational;\n    kind = rational ? 2 : 1;\n\n    // reading bspline basis information\n    int num_coefs, order;\n    vector<double> knots;\n    read_basis(go_stream, num_coefs, order, knots);\n    \n    // reading control points\n    int coef_size = num_coefs * (rational ? (dim + 1) : dim);\n    vector<double> coef(coef_size);\n    for (int i = 0; i < coef_size; ++i) {\n\tgo_stream >> coef[i];\n    }\n\n    int copy = 1; // flag that the input arrays (knots, coef) should be _copied_\n    return newCurve(num_coefs, order, &knots[0], &coef[0], kind, dim, copy);\n\n}\n\n\n//===========================================================================\nvoid writeGoPoints(int num_points, double* coords, std::ostream& go_stream)\n//===========================================================================\n{\n    if (!coords) {\n\tthrow runtime_error(\"zero coordinate pointer given to writeGoPoints.\");\n    }\n    // write standard header\n    go_stream << POINTCLOUD_INSTANCE_TYPE << ' ' << MAJOR_VERSION << ' '\n\t      << MINOR_VERSION << \" 4 255 255 0 255\\n\";\n\n    // write the number of points\n    go_stream << num_points << '\\n';\n    \n    // write point coordinates\n    for (int i = 0; i < num_points * 3; ++i) {\n\tgo_stream << coords[i];\n\tif ((i+1) % 3) {\n\t    go_stream << ' ';\n\t} else {\n\t    go_stream << '\\n';\n\t}\n    }\n    go_stream << endl;\n}\n\n//===========================================================================\nvoid readGoPoints(std::vector<double>& coords, std::istream& go_stream)\n//===========================================================================\n{\n    if (determine_go_instance_type(go_stream) != POINTCLOUD_INSTANCE_TYPE) {\n\tthrow runtime_error(\"stream given to readGoPoints() does not contain pointcloud.\");\n    }\n    // read away extra header information\n    for (int dummy, i = 0; i < 4; ++i) {\n\tgo_stream >> dummy;\n    }\n\n    int num_points;\n    go_stream >> num_points;\n    coords.resize(num_points * 3);\n\n    // read point coordinates\n    for (int i = 0; i < (int)coords.size(); ++i) {\n\tgo_stream >> coords[i];\n    }\n}\n"
  },
  {
    "path": "viewer/include/aux2.h",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#ifndef AUX2_H_INCLUDED\n\n#include <vector>\nusing std::vector;\nusing std::pair;\n\n#include <iostream>\nusing std::cout;\nusing std::endl;\n\n#include <stdio.h>\n\n#include \"jonvec.h\"\n\n\n#ifdef MICROSOFT\n#  define CRIT_ERR(stmnt) \\\n    printf(\"\\nIn file %s, line %d:\\n  \", __FILE__, __LINE__), \\\n    (stmnt), printf(\"\\n%d\\n\", getchar()), exit(0)\n#else\n#  define CRIT_ERR(stmnt) \\\n    printf(\"\\nIn file %s, line %d:\\n  \", __FILE__, __LINE__), \\\n    (stmnt), exit(0)\n#endif\n\n#define ASSERT2(a, b) if (!(a)) CRIT_ERR(b)\n\n#ifndef _ERRORMACROS_H\n#define _ERRORMACROS_H\n\n#include <exception>\n#include <iostream>\n\n/// Usage: REPORT;\n/// Usage: MESSAGE(\"Message string.\");\n#ifdef NVERBOSE // Not verbose mode\n#  define REPORT 0\n#  define MESSAGE(x) 0\n#else // Verbose mode\n#  define REPORT cout << \"\\nIn file \" << __FILE__ << \", line \" << __LINE__ << endl\n#  define MESSAGE(x) cout << \"\\nIn file \" << __FILE__ << \", line \" << __LINE__ << \": \" << x << endl\n#endif\n\n/// Usage: THROW(\"Error message string.\");\n#define THROW(x) MESSAGE(x), throw std::exception()\n\n/// Usage: ASSERT(condition)\n/// Usage: ASSERT2(condition, \"Error message string.\")\n/// Usage: ERROR_IF(condition, \"Error message string.\");\n#ifdef NDEBUG // Not in debug mode\n#  ifndef QTMODE\n//   030916: There is a conflict. Hope I don't use ASSERT for anything...\n#    define ASSERT(x)\n#  endif\n#  define ASSERT3(cond, x)\n#  define ERROR_IF(cond, x)\n#else // Debug mode\n#  ifndef QTMODE\n//   030916: There is a conflict. Hope I don't use ASSERT for anything...\n#    define ASSERT(cond) if (!(cond)) THROW(\"Assertation \\'\" #cond \"\\' failed.\")\n#  endif\n#  define ASSERT3(cond, x) if (!(cond)) THROW(x)\n#  define ERROR_IF(cond, x) if (cond) THROW(x)\n#endif\n\n\n#endif // _ERRORMACROS_H\n\n\n\n\n\n\n//\n// 030102: There are some routines for this in 'aux1.C', but these macros\n//         are more in line with what is used in the CoCreate project,\n//         and in sisl. (Just hope there won't be any conflicts...)\n// 030116: Ajajaj... Horrible mistake, forgot the max(..., 1)...\n// 040411: Legger inn en egen ikke-sisl-relatert variant med spesifisert\n//         toleranse.\n//\n\n#define DEQUALX(a, b, tol) (fabs((a)-(b))<=(tol) * std::max(std::max(fabs(a), fabs(b)), 1.0))\n\n#define DEQUAL(a, b) (fabs((a)-(b))<=1e-12 * std::max(std::max(fabs(a), fabs(b)), 1.0))\n#define NDEQUAL(a, b) (!DEQUAL(a, b))\n#define DNEQUAL(a, b) (NDEQUAL(a, b))\n#define DLESS(a, b) (((a)<(b)) && (NDEQUAL((a), (b))))\n#define DGREATER(a, b) (((a)>(b)) && (NDEQUAL((a), (b))))\n#define DLESSEQ(a, b) (((a)<(b)) || (DEQUAL((a), (b))))\n#define DGREATEREQ(a, b) (((a)>(b)) || (DEQUAL((a), (b))))\n\n//\n// 030105: For some reason that I'm not completely sure of, some relatively\n//         simple computations (angles in triangles, 2nd degree equations,\n//         not very fancy) seem to be riddled with extreme loss of precision.\n//         (Geos. project, see 'building2.C', 'split_triangle_corner_edge'.\n//\n#define DEQUAL2(a, b) (fabs((a)-(b))<=1e-8 * std::max(std::max(fabs(a), fabs(b)), 1.0))\n// 030711: The 3-version for floats...\n#define DEQUAL3(a, b) (fabs((a)-(b))<=1e-6 * std::max(std::max(fabs(a), fabs(b)), 1.0))\n#define NDEQUAL2(a, b) (!DEQUAL2(a, b))\n#define DNEQUAL2(a, b) (NDEQUAL2(a, b))\n#define DLESSEQ2(a, b) (((a)<(b)) || (DEQUAL2((a), (b))))\n#define DGREATEREQ2(a, b) (((a)>(b)) || (DEQUAL2((a), (b))))\n\n\n#define DEQUAL4(a, b) (fabs((a)-(b))<=1e-14 * std::max(std::max(fabs(a), fabs(b)), 1.0))\n\n\n\n\n\n#define SQR(a) ((a)*(a))\n\n#ifndef PI\n#  define PI 3.1415926535\n#endif\n\n#ifndef MIN\n#  define MIN(a,b) ((a)<(b)? (a):(b))\n#endif\n#ifndef MAX\n#  define MAX(a,b) ((a)>(b)? (a):(b))\n#endif\n\n\n\n  \n\n\nint eps_equal(const double &a, const double &b);\nint eps_less(const double &a, const double &b);\nint eps_greater(const double &a, const double &b);\nint eps_less_eq(const double &a, const double &b);\nint eps_greater_eq(const double &a, const double &b);\n\nvoid tic(void);\nvoid toc(void);\n\n\n\n\n\n\n#define AUX2_H_INCLUDED\n#endif\n"
  },
  {
    "path": "viewer/include/gl_aux.h",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#ifndef GL_AUX_INCLUDED\n#define GL_AUX_INCLUDED\n\n#include <stdio.h>\n#include <GL/glut.h>\n#include <algorithm>\n\n#include \"transfutils.h\"\n#include \"jonvec.h\"\n\nextern const int predefined_colours;\nextern const double predef_col_table[];\nextern const double col_setting_back_old[];\nextern const double col_setting_back[];\n\n\n//\n// 020723: I don't remember when the stuff above is used... May be that the\n//         class below could/should replace them...\n//\n// This class is used in this way: The glut application should make a\n// (global) instance of this class, and call it's 'Key' member from\n// the 'Key' callback function. The \"multi purpose standard\n// Key-callback\" defined in xxxxx does just this.\n//\n// 020822: This crap should be fixed, updated, cleaned up.\n//\n\nclass material_appearance\n{\nprivate:\n#ifndef MICROSOFT\n  static const int schemes=7;\n#else\n  //\n  // @@@ 021027: Remember to ask afr about this...\n  //\n#  define schemes 7\n#endif\n\n  int cubemap_mode, col_scheme;\n  float front_mat_shininess[schemes];\n  float front_mat_specular[4*schemes];\n  float front_mat_diffuse[4*schemes];\n  float front_mat_ambient[4*schemes];\n  float front_mat_emission[4*schemes];\n  float back_mat_shininess[schemes];\n  float back_mat_specular[4*schemes];\n  float back_mat_diffuse[4*schemes];\n  float back_mat_ambient[4*schemes];\n  float back_mat_emission[4*schemes];\n  int spec_mode;\n  int col_face;\t\t// State variable for chosen face to modify.\n  int col_param;\t// State variable for chosen param to modify.\n  float *property;\t// Property data to modify.\npublic:\n  double ztrans_delta;\nprivate:\n  int rescale, bg_invert;\n  \npublic:\n  material_appearance(void):\n    cubemap_mode(0), col_scheme(0), spec_mode(0), col_face(0), col_param(0),\n    property(front_mat_specular), ztrans_delta(0.0), rescale(0), bg_invert(0)\n    {\n      static const float front_mat_shininess0[schemes] ={200.0,\n\t\t\t\t\t\t\t 200.0,\n\t\t\t\t\t\t\t 200.0,\n\t\t\t\t\t\t\t 200.0,\n\t\t\t\t\t\t\t 200.0,\n\t\t\t\t\t\t\t 200.0,\n\t\t\t\t\t\t\t 200.0};\n      static const float front_mat_specular0[4*schemes]={0.8, 0.8, 0.8, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.8, 0.8, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.8, 0.8, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.8, 0.8, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.8, 0.8, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.8, 0.8, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.8, 0.8, 1.0};\n      static const float front_mat_diffuse0[4*schemes] ={0.7, 0.7, 0.7, 1.0,\n\t\t\t\t\t\t\t 0.7, 0.4, 0.4, 1.0,\n\t\t\t\t\t\t\t 0.4, 0.7, 0.7, 1.0,\n\t\t\t\t\t\t\t 0.0, 0.8, 0.2, 1.0,\n\t\t\t\t\t\t\t 0.7, 0.7, 0.4, 1.0,\n\t\t\t\t\t\t\t 0.4, 0.4, 0.7, 1.0,\n\t\t\t\t\t\t\t 0.5, 0.4, 0.4, 1.0};\n      static const float front_mat_ambient0[4*schemes] ={0.3, 0.3, 0.3, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.8, 0.3, 1.0,\n\t\t\t\t\t\t\t 0.3, 0.3, 0.8, 1.0,\n\t\t\t\t\t\t\t 0.5, 0.0, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.3, 0.8, 1.0,\n\t\t\t\t\t\t\t 0.3, 0.8, 0.3, 1.0,\n\t\t\t\t\t\t\t 0.0, 0.0, 0.0, 1.0};\n      static const float front_mat_emission0[4*schemes]={0.3, 0.0, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.3, 0.2, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.0, 0.2, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.3, 0.2, 0.3, 1.0,\n\t\t\t\t\t\t\t 0.1, 0.2, 0.1, 1.0,\n\t\t\t\t\t\t\t 0.0, 0.2, 0.4, 1.0,\n\t\t\t\t\t\t\t 0.0, 0.0, 0.0, 1.0};\n      static const float back_mat_shininess0[schemes]  ={200.0, \n\t\t\t\t\t\t\t 200.0,\n\t\t\t\t\t\t\t 228.0,\n\t\t\t\t\t\t\t 228.0,\n\t\t\t\t\t\t\t 228.0,\n\t\t\t\t\t\t\t 228.0,\n\t\t\t\t\t\t\t 228.0};\n      static const float back_mat_specular0[4*schemes] ={0.8, 0.0, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.0, 0.0, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.9, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.9, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.9, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.9, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.9, 0.0, 1.0};\n      static const float back_mat_diffuse0[4*schemes]  ={0.7, 0.7, 0.7, 1.0,\n\t\t\t\t\t\t\t 0.6, 0.9, 0.6, 1.0,\n\t\t\t\t\t\t\t 0.0, 0.7, 0.9, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.9, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.9, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.9, 0.7, 0.9, 1.0,\n\t\t\t\t\t\t\t 0.4, 0.4, 0.4, 1.0};\n      static const float back_mat_ambient0[4*schemes]  ={0.3, 0.3, 0.3, 1.0,\n\t\t\t\t\t\t\t 0.9, 0.3, 0.3, 1.0,\n\t\t\t\t\t\t\t 0.3, 0.9, 0.3, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.9, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.9, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.9, 0.9, 0.3, 1.0,\n\t\t\t\t\t\t\t 0.0, 0.0, 0.0, 1.0};\n      static const float back_mat_emission0[4*schemes] ={0.0, 0.3, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.9, 0.3, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.0, 0.9, 0.9, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.9, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.8, 0.9, 0.0, 1.0,\n\t\t\t\t\t\t\t 0.9, 0.0, 0.9, 1.0,\n\t\t\t\t\t\t\t 0.0, 0.0, 0.0, 1.0};\n      \n      memcpy(front_mat_shininess, front_mat_shininess0, schemes*sizeof(float));\n      memcpy(front_mat_specular, front_mat_specular0, 4*schemes*sizeof(float));\n      memcpy(front_mat_diffuse, front_mat_diffuse0, 4*schemes*sizeof(float));\n      memcpy(front_mat_ambient, front_mat_ambient0, 4*schemes*sizeof(float));\n      memcpy(front_mat_emission, front_mat_emission0, 4*schemes*sizeof(float));\n      memcpy(back_mat_shininess, back_mat_shininess0, 4*schemes*sizeof(float));\n      memcpy(back_mat_specular, back_mat_specular0, 4*schemes*sizeof(float));\n      memcpy(back_mat_diffuse, back_mat_diffuse0, 4*schemes*sizeof(float));\n      memcpy(back_mat_ambient, back_mat_ambient0, 4*schemes*sizeof(float));\n      memcpy(back_mat_emission, back_mat_emission0, 4*schemes*sizeof(float));\n    }\n\n  int col_scheme_selected(void) const { return col_scheme; }\n  void col_scheme_select(const int i)\n    {\n      col_scheme=i%schemes;\n    }\n\n  void set_material(void)\n    {\n      glMaterialfv(GL_FRONT, GL_SHININESS, front_mat_shininess+col_scheme);\n      glMaterialfv(GL_FRONT, GL_SPECULAR, front_mat_specular+col_scheme*4);\n      glMaterialfv(GL_FRONT, GL_DIFFUSE, front_mat_diffuse+col_scheme*4);\n      glMaterialfv(GL_FRONT, GL_AMBIENT, front_mat_ambient+col_scheme*4);\n      glMaterialfv(GL_FRONT, GL_EMISSION, front_mat_emission+col_scheme*4);\n      \n      glMaterialfv(GL_BACK, GL_SHININESS, back_mat_shininess+col_scheme);\n      glMaterialfv(GL_BACK, GL_SPECULAR, back_mat_specular+col_scheme*4);\n      glMaterialfv(GL_BACK, GL_DIFFUSE, back_mat_diffuse+col_scheme*4);\n      glMaterialfv(GL_BACK, GL_AMBIENT, back_mat_ambient+col_scheme*4);\n      glMaterialfv(GL_BACK, GL_EMISSION, back_mat_emission+col_scheme*4);\n    }\n\n  void redefine_material_f(const vector3t<double> &diff,\n\t\t\t   const vector3t<double> &amb,\n\t\t\t   const vector3t<double> &em,\n\t\t\t   const vector3t<double> &spec,\n\t\t\t   const double shin)\n    {\n      front_mat_diffuse[col_scheme*4+0]=diff.x();\n      front_mat_diffuse[col_scheme*4+1]=diff.y();\n      front_mat_diffuse[col_scheme*4+2]=diff.z();\n      front_mat_diffuse[col_scheme*4+3]=1.0;\n\n      front_mat_ambient[col_scheme*4+0]=amb.x();\n      front_mat_ambient[col_scheme*4+1]=amb.y();\n      front_mat_ambient[col_scheme*4+2]=amb.z();\n      front_mat_ambient[col_scheme*4+3]=1.0;\n\n      front_mat_emission[col_scheme*4+0]=em.x();\n      front_mat_emission[col_scheme*4+1]=em.y();\n      front_mat_emission[col_scheme*4+2]=em.z();\n      front_mat_emission[col_scheme*4+3]=1.0;\n\n      front_mat_specular[col_scheme*4+0]=spec.x();\n      front_mat_specular[col_scheme*4+1]=spec.y();\n      front_mat_specular[col_scheme*4+2]=spec.z();\n      front_mat_specular[col_scheme*4+3]=1.0;\n\n      front_mat_shininess[col_scheme]=shin;\n    }\n\n  void Key(unsigned char key)\n    {\n      bool adjust_material=false;\n      int comp=0; // Colour component to modify.\n      double delta=0.0; // Amount of modification.\n      \n      switch (key)\n\t{\n\t  // case 'm': // @H@ ------ Material and lighting properties prefix:\n\t  \n\tcase 's': // @H@ Toggle on/off specular property of material.\n\t  spec_mode=1-spec_mode;\n\t  printf(\"spec_mode=%d\\n\", spec_mode);\n\t  {\n\t    int i;\n\t    \n\t    for (i=0; i<3; i++)\n\t      if (spec_mode)\n\t\tfront_mat_specular[4*schemes+i]=\n\t\t  back_mat_specular[4*schemes+i]=1.0;\n\t      else\n\t\tfront_mat_specular[4*schemes+i]=\n\t\t  back_mat_specular[4*schemes+i]=0.0;\n\t  }\n\t  glMaterialfv(GL_FRONT, GL_SPECULAR,\n\t\t       front_mat_specular+4*col_scheme);\n\t  glMaterialfv(GL_BACK, GL_SPECULAR,\n\t\t       back_mat_specular+4*col_scheme);\n\t  //material_prefix_pressed=false;\n\t  break;\n\t  \n\tcase 'c': // @H@ Cycle through color schemes.\n\t  col_scheme=(col_scheme+1)%schemes;\n\t  printf(\"col_scheme=%d\\n\", col_scheme);\n\t  adjust_material=true;\n\t  //material_prefix_pressed=false;\n\t  break;\n\n\tcase 'b': // @H@ Toggle which face to adjust colour for.\n\t  col_face=1-col_face;\n\t  printf(\"col_face=%s\\n\", col_face ? \"back\" : \"front\");\n\t  break;\n\t  \n\tcase 'p': // @H@ Cycle through colour parameter to tune.\n\t  col_param=(col_param+1)%5;\n\t  printf(\"Colour parameter to be tuned: '\");\n\t  switch (col_param)\n\t    {\n\t    case 0:\n\t      printf(\"shininess\");\n\t      property=col_face ? back_mat_shininess : front_mat_shininess;\n\t      break;\n\t    case 1:\n\t      printf(\"specular\");\n\t      property=col_face ? back_mat_specular : front_mat_specular;\n\t      break;\n\t    case 2:\n\t      printf(\"diffuse\");\n\t      property=col_face ? back_mat_diffuse : front_mat_diffuse;\n\t      break;\n\t    case 3:\n\t      printf(\"ambient\");\n\t      property=col_face ? back_mat_ambient : front_mat_ambient;\n\t      break;\n\t    case 4:\n\t      printf(\"emission\");\n\t      property=col_face ? back_mat_emission : front_mat_emission;\n\t      break;\n\t    }\n\t  printf(\"'.\\n\");\n\t  break;\n\n\tcase 'r': // @H@ Increase red-comp. of current colour.\n\t  comp=0; adjust_material=true; delta=1.0/16.0; break;\n\tcase 'f': // @H@ Decrease red-comp. of current colour.\n\t  comp=0; adjust_material=true; delta=-1.0/16.0; break;\n\tcase 't': // @H@ Increase green-comp. of current colour.\n\t  comp=1; adjust_material=true; delta=1.0/16.0; break;\n\tcase 'g': // @H@ Decrease green-comp. of current colour.\n\t  comp=1; adjust_material=true; delta=-1.0/16.0; break;\n\tcase 'y': // @H@ Increase blue-comp. of current colour.\n\t  comp=2; adjust_material=true; delta=1.0/16.0; break;\n\tcase 'h': // @H@ Decrease blue-comp. of current colour.\n\t  comp=2; adjust_material=true; delta=-1.0/16.0; break;\n\n\tcase 'H': // @H@ Help for the 'material property' mode.\n\n\n\t  puts(\"\\nUse the following keys:\\n\");\n// \t  system(\"cat \"PWD\"/\"__FILE__\" | \"\n// \t\t \"gawk '/[c]ase.*@H@/ { match($0, \"\n// \t\t \"'\\\"/[c]ase.*'.*'/\\\"'); printf(\\\"%c) \\\", substr($0, \"\n// \t\t \"RSTART+RLENGTH-2, 1)); match($0, /@H@/); print(substr($0, \"\n// \t\t \"RSTART+RLENGTH+1)) } /@[H]H@/ { match($0, /@[H]H@/); \"\n// \t\t \"print(substr($0, RSTART+RLENGTH+1)) }'\");\n\n\n\t  puts(\"\\nSpecific help for material property selection:\\n\"\n\t       \"  Note that the following keys do not exit 'material' mode\\n\"\n\t       \"  after their application. (The key 'm' does that.) Use:\\n\"\n\t       \"  b - for toggling of face, 'back'/'front',\\n\"\n\t       \"  p - for cycling through allowed properties,\\n\"\n\t       \"      'shininess', 'specular', 'diffuse', 'ambient' and\\n\"\n\t       \"      'emission',\\n\"\n\t       \"  r - for increasing the red-component,\\n\"\n\t       \"  f - for decreasing the red-component,\\n\"\n\t       \"  t - for increasing the green-component,\\n\"\n\t       \"  g - for decreasing the green-component,\\n\"\n\t       \"  y - for increasing the blue-component and\\n\"\n\t       \"  h - for decreasing the blue-component.\\n\"\n\t       \"  Also, these are available:\\n\"\n\t       \"  i - invert background,\"\n\t       \"  d - dump numbers.\\n\");\n\t  break;\n\n\tcase 'i': // @H@ Invert background colour.\n\t  bg_invert=1-bg_invert;\n\t  printf(\"bg_invert=%d\\n\", bg_invert);\n\t  if (bg_invert)\n\t    glClearColor(1.0, 1.0, 1.0, 0.0);\n\t  else\n\t    glClearColor(0.0, 0.0, 0.0, 0.0);\n\t  break;\n\t  \n\tcase 'd':\n\t{\n\t  int i;\n\t  \n\t  puts(\"\\nThe numbers for front properties, listed in the order of\\n\"\n\t       \"shininess, specular, diffuse, ambient and emmisive light,\\n\"\n\t       \"is:\\n\");\n\t  printf(\"%.5f\\n\", *(front_mat_shininess+col_scheme));\n\t  for (i=0; i<4; i++)\n\t    printf(\"%.5f   \", (front_mat_specular+col_scheme*4)[i]);\n\t  printf(\"\\n\");\n\t  for (i=0; i<4; i++)\n\t    printf(\"%.5f   \", (front_mat_diffuse+col_scheme*4)[i]);\n\t  printf(\"\\n\");\n\t  for (i=0; i<4; i++)\n\t    printf(\"%.5f   \", (front_mat_ambient+col_scheme*4)[i]);\n\t  printf(\"\\n\");\n\t  for (i=0; i<4; i++)\n\t    printf(\"%.5f   \", (front_mat_emission+col_scheme*4)[i]);\n\t  puts(\"\\n\\nThe numbers for back properties, listed in the order of\\n\"\n\t       \"shininess, specular, diffuse, ambient and emmisive light,\\n\"\n\t       \"is:\\n\");\n\t  printf(\"%.5f\\n\", *(back_mat_shininess+col_scheme));\n\t  for (i=0; i<4; i++)\n\t    printf(\"%.5f   \", (back_mat_specular+col_scheme*4)[i]);\n\t  printf(\"\\n\");\n\t  for (i=0; i<4; i++)\n\t    printf(\"%.5f   \", (back_mat_diffuse+col_scheme*4)[i]);\n\t  printf(\"\\n\");\n\t  for (i=0; i<4; i++)\n\t    printf(\"%.5f   \", (back_mat_ambient+col_scheme*4)[i]);\n\t  printf(\"\\n\");\n\t  for (i=0; i<4; i++)\n\t    printf(\"%.5f   \", (back_mat_emission+col_scheme*4)[i]);\n\t  printf(\"\\n\\n\");\n\t}\n\tbreak;\n\n\tcase 'z': // @H@ Reduce the amount of 'perspective'.\n\t  if (ztrans_delta==0.0)\n\t    ztrans_delta=0.01;\n\t  ztrans_delta=std::min(ztrans_delta*1.1, 1000.0);\n\t  ztrans=-6-ztrans_delta;\n\t  printf(\"ztrans_delta=%f\\n\", ztrans_delta);\n\t  printf(\"ztrans=%f\\n\", ztrans);\n\t  glMatrixMode(GL_PROJECTION);\n\t  glLoadIdentity();\n\t  glFrustum(-1.0, 1.0, -1.0, 1.0, 5+ztrans_delta, 20+ztrans_delta);\n\t  glMatrixMode(GL_MODELVIEW);\n\t  glLoadIdentity();\n\t  printf(\"trans=%f %f %f\\n\", xtrans, ytrans, ztrans);\n\t  glTranslated(xtrans, ytrans, ztrans);\n\t  printf(\"scale=%f %f %f\\n\", xscale, yscale, zscale);\n\t  glScaled(xscale, yscale, zscale);\n\t  break;\n\tcase 'x': // @H@ Increase the amount of 'perspective'.\n\t  ztrans_delta*=0.9;\n\t  ztrans=-6-ztrans_delta;\n\t  printf(\"ztrans_delta=%f\\n\", ztrans_delta);\n\t  printf(\"ztrans=%f\\n\", ztrans);\n\t  glMatrixMode(GL_PROJECTION);\n\t  glLoadIdentity();\n\t  glFrustum(-1.0, 1.0, -1.0, 1.0, 5+ztrans_delta, 20+ztrans_delta);\n\t  glMatrixMode(GL_MODELVIEW);\n\t  glLoadIdentity();\n\t  glTranslated(xtrans, ytrans, ztrans);\n\t  glScaled(xscale, yscale, zscale);\n\t  break;\n\t\n\tcase 'm': // @H@ ------ Material prefix section ends here.\n\t  //material_prefix_pressed=false;\n\t  break;\n\t  \n\tcase 'q': // @H@ Exit the program.\n\t  exit(0);\n\t  break;\n\n\t}\n      \n      if (adjust_material)\n\t{\n\t  float * const &tmp=(property+\n\t\t\t      col_scheme*(col_param==0 ? 1 : 4)+\n\t\t\t      (col_param==0 ? 0 : comp));\n\t  printf(\"Old value %.4f replaced by new value \", *tmp);\n\t  if (col_param==0)\n\t    *tmp=std::min(std::max((*tmp)*(1+delta), 0.0), 1000.0);\n\t  else\n\t    *tmp=std::min(std::max(*tmp+delta, 0.0), 1.0);\n\t  printf(\"%.4f\\n\", *tmp);\n\n\t  set_material();\n\t}\n\n    } // end of 'Key'\n\n};\n\n\n\n\n\n\nvoid draw_cylinder(double x0, double y0, double z0,\n\t\t   double x1, double y1, double z1,\n\t\t   double radius, double radius2, int n);\n\nvoid draw_gl_axes_old(int n=10, double r=0.7, double radius=0.01,\n\t\t      double rim=0.04, double l=0.1);\n\nvoid draw_grid(const int n1, const int n2, const int n3);\n\nvoid draw_grid_planes(const int n1, const int n2, const int n3);\n\nvoid gl_init(int argc, char *argv[],\n\t     const int xs, const int ys,\n\t     const int x0, const int y0,\n\t     const int doubleBuffer,\n\t     const int two_sided,\n\t     const int lighting,\n\t     const int normalize,\n\t     const int smooth,\n\t     const double xtrans, const double ytrans, const double ztrans,\n\t     const double xscale, const double yscale, const double zscale,\n\t     int &tx,\n\t     int &ty,\n\t     const int texture_mode,\n\t     const char * const texfile=NULL);\n\nvoid print_gl_matrix(const int m);\n\nvoid reshape_window(int width, int height);\n\n//\n// Writing and reading the GL transformation matrices to and from\n// files.\n// 020505: Copied from the sisl_view version of gl_aux... Here is some\n//         more merging to do...\n//\nvoid write_gl_matrices(FILE *f);\nvoid read_gl_matrices(FILE *f);\n\n\n\n\n\n\n#endif\n"
  },
  {
    "path": "viewer/include/glutils.h",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#ifndef GLUTILS_H_INCLUDED\n\n\n#ifndef _MSC_VER // 041103\n#  include <GL/glx.h>\n#endif\n#include \"GL/glut.h\"\n\n#include <vector>\nusing std::vector;\n\n#include \"jonvec.h\"\n\n\n//\n// 991117: Note!!! glGetError shouldn't be called between glBegin/End!!!\n//\n\n//\n// If gl-error, write out a message and abort execution.\n// If no error, this should be fast.\n// If you want to fool yourself, use the macro with function syntax!\n//\nvoid assert_gl_m(int line, char *file, const bool do_exit=true);\nvoid assert_gl_dummy_and_empty(void);\n\n\n//\n// No semicolon; we won't allow anybody to destroy the source formatting...\n//\n#define ASSERT_GL assert_gl_m(__LINE__, __FILE__)\n#define ASSERT_GL_DONT_EXIT assert_gl_m(__LINE__, __FILE__, false)\n\n//\n// This must be called with parantheses, function-like...\n//\n#define assert_gl assert_gl_m(__LINE__, __FILE__); assert_gl_dummy_and_empty\n\n#ifndef _MSC_VER // 041103\nvoid list_FBConfigs(GLXFBConfig *config, int nelements);\n#endif\n\nvoid draw_sphere(const vector3t<float> &pos, const float r,\n\t\t const int n, const int slot,\n\t\t const vector3t<float> &col,\n\t\t const bool wiremode);\n\n\n\n\n\n\n#define GLUTILS_H_INCLUDED\n#endif\n"
  },
  {
    "path": "viewer/include/jonvec.h",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#ifndef JONVEC_H_INCLUDED\n#define JONVEC_H_INCLUDED\n\n#include <stdio.h>\n#include <math.h>\n#include <vector>\n\n#include \"aux2.h\"\n\n\n/*!\n\n  \\page filters_mainpage The filter routines main page\n  \\anchor filters_mainpage\n  \n  \\section filters_intro Introduction\n\n  This is a collection of routines for handling various (3x3x3) 3d\n  filters.<p>\n\n  020114: This REALLY REALLY must be cleaned up...\n  021231: Not yet, but soon, it will only be a question of removing commented\n          out stuff... Hopefully...\n  050120: Changed return types for boolean functions from int to bool.\n          Hope this doesn't break anything.\n\n*/\n\n\n\n\n\n\ntemplate<typename T>\nclass vector3t\n{\npublic:\n  T coo[3];\n\n  vector3t()\n    {\n      coo[0]=0.0;\n      coo[1]=0.0;\n      coo[2]=0.0;\n    };\n  vector3t(const T a, const T b, const T c)\n    {\n      coo[0]=a;\n      coo[1]=b;\n      coo[2]=c;\n    }\n  vector3t(const float *a)\n    {\n      coo[0]=a[0];\n      coo[1]=a[1];\n      coo[2]=a[2];\n    }\n  vector3t(const double *a)\n    {\n      coo[0]=a[0];\n      coo[1]=a[1];\n      coo[2]=a[2];\n    }\n  // 030819: Disse to delegger et eller annet. Fordi de erstatter en default (og bitwise) copy constructor, uten at de samtidig er gode nok til  gjre det??? Skjnner ikke helt hva som skjer... M sjekkes opp... @@@\n//    vector3t(vector3t<float> &v0) // 030819\n//      {\n//        coo[0]=v0.x();\n//        coo[1]=v0.y();\n//        coo[2]=v0.z();\n//      }\n//    vector3t(vector3t<double> &v0) // 030819\n//      {\n//        coo[0]=v0.x();\n//        coo[1]=v0.y();\n//        coo[2]=v0.z();\n//      }\n  ~vector3t(void) {}\n\n//  vector rotate2d(T,int);\n//  vector transform(coo_system &);\n\n  //\n  // 010122: For fast access used in OpenGL:\n  //\n  inline const T *raw(void) const\n    {\n      return coo;\n    }\n\n  //\n  // 010125\n  // 021024: Added the reference-versions.\n  //\n  inline T x(void) const { return coo[0]; }\n  inline T y(void) const { return coo[1]; }\n  inline T z(void) const { return coo[2]; }\n  inline T &x(void) { return coo[0]; }\n  inline T &y(void) { return coo[1]; }\n  inline T &z(void) { return coo[2]; }\n\n  //\n  // 010207\n  //\n  inline void setx(const T a) { coo[0]=a; }\n  inline void sety(const T a) { coo[1]=a; }\n  inline void setz(const T a) { coo[2]=a; }\n\n  //\n  // Check out this on gcc... Why does only SGI CC complain?\n  //\n  inline bool operator==(const vector3t &v) const\n    {\n      return ((coo[0]==v.coo[0]) && (coo[1]==v.coo[1]) && (coo[2]==v.coo[2]));\n    }\n\n  //\n  // 050120: Adding this... Would also be nice with one \"and\"'ing the\n  //         results on each component... No, not necessary...\n  //         Remember that deMorgan gives that a<&b <=> !(a>|b).\n  //\n  inline bool operator<(const vector3t &v) const\n    {\n      return ((coo[0]<v.coo[0]) || (coo[1]<v.coo[1]) || (coo[2]<v.coo[2]));\n    }\n  inline bool operator>(const vector3t &v) const\n    {\n      return ((coo[0]>v.coo[0]) || (coo[1]>v.coo[1]) || (coo[2]>v.coo[2]));\n    }\n\n  //\n  // Note: Prefer a!=b to !(a==b) since the former is probably faster!\n  //\n  inline bool operator!=(const vector3t &v) const\n    {\n      return ((coo[0]!=v.coo[0]) || (coo[1]!=v.coo[1]) || (coo[2]!=v.coo[2]));\n    }\n\n  //\n  // Ok, the strange warning produced when actually using this operator,\n  // stemmed from a missing 'const' at the end of the declaration of\n  // this operator. (Then the function could have altered *this, and\n  // that would have discarded any const'ness...)\n  //\n  inline const vector3t operator+(const vector3t &v) const\n    {\n      return vector3t(coo[0]+v.coo[0], coo[1]+v.coo[1], coo[2]+v.coo[2]);\n    }\n\n  inline vector3t &operator+=(const vector3t &v)\n    {\n      coo[0]+=v.coo[0]; coo[1]+=v.coo[1]; coo[2]+=v.coo[2];\n      return *this;\n    }\n\n  // 030819\n//    inline vector3t<float> &operator+=(const vector3t<double> &v)\n//      {\n//        coo[0]+=v.coo[0]; coo[1]+=v.coo[1]; coo[2]+=v.coo[2];\n//        return *this;\n//      }\n\n  inline vector3t &operator-=(const vector3t &v)\n    {\n      coo[0]-=v.coo[0]; coo[1]-=v.coo[1]; coo[2]-=v.coo[2];\n      return *this;\n    }\n\n  // 030513\n  inline vector3t &operator-=(const T &d)\n    {\n      coo[0]-=d; coo[1]-=d; coo[2]-=d;\n      return *this;\n    }\n\n  // 030626\n  inline vector3t &operator+=(const T &d)\n    {\n      coo[0]+=d; coo[1]+=d; coo[2]+=d;\n      return *this;\n    }\n\n  // 030709\n  inline vector3t &operator*=(const double x)\n    {\n      coo[0]*=x; coo[1]*=x; coo[2]*=x;\n      return *this;\n    }\n\n  // 030709\n  inline vector3t &operator/=(const double x)\n    {\n      coo[0]/=x; coo[1]/=x; coo[2]/=x;\n      return *this;\n    }\n\n  inline const vector3t operator-(const vector3t &v) const\n    {\n      return vector3t(coo[0]-v.coo[0], coo[1]-v.coo[1], coo[2]-v.coo[2]);\n    }\n\n  // 000310\n  inline const vector3t operator-(const T &d) const\n    {\n      return vector3t(coo[0]-d, coo[1]-d, coo[2]-d);\n    }\n\n  inline const vector3t operator-(void) const\n    {\n      return vector3t(-coo[0], -coo[1], -coo[2]);\n    }\n\n  //\n  // Why can't a non-member operator like this be 'const'?\n  //\n  inline const friend vector3t operator*(const T &a, const vector3t &v)\n    {\n      return vector3t(a*v.coo[0], a*v.coo[1], a*v.coo[2]);\n    }\n\n  // 030120:\n  inline const friend vector3t operator+(const double &a, const vector3t &v)\n    {\n      return vector3t(a+v.coo[0], a+v.coo[1], a+v.coo[2]);\n    }\n  inline const friend vector3t operator+(const float &a, const vector3t &v)\n    {\n      return vector3t(a+v.coo[0], a+v.coo[1], a+v.coo[2]);\n    }\n\n  inline T operator*(const vector3t &v) const\n    {\n      return (coo[0]*v.coo[0] + coo[1]*v.coo[1] + coo[2]*v.coo[2]);\n    }\n\n  inline vector3t operator/(const vector3t &v) const\n    {\n      return (vector3t(coo[1]*v.coo[2]-coo[2]*v.coo[1],\n\t\t      coo[2]*v.coo[0]-coo[0]*v.coo[2],\n\t\t      coo[0]*v.coo[1]-coo[1]*v.coo[0]));\n    }\n\n  //\n  // Why can't I make this a const function?\n  //\n  inline friend T cosangle(const vector3t &v0, const vector3t &v1)\n    {\n      return ((v0*v1)/sqrt((v0*v0)*(v1*v1)));\n    }\n\n  inline const vector3t &clamp(const vector3t &v0, const vector3t &v1)\n    {\n      coo[0]=std::max(v0.coo[0], std::min(v1.coo[0], coo[0]));\n      coo[1]=std::max(v0.coo[1], std::min(v1.coo[1], coo[1]));\n      coo[2]=std::max(v0.coo[2], std::min(v1.coo[2], coo[2]));\n      return *this;\n    }\n\n  //\n  // Added 021010:\n  // (Hmm... What is the sensible thing to do in such a case,\n  // return a new object, like for 'clamp' above, or to just modify\n  // *this, like in this definition??)\n  //\n#ifdef _WIN32\n  //\n  // 030208: I simply don't know where these get defined as macros...\n  //         (But I suspect some Microsoft .h-file does it...)\n  //\n#  undef min\n#  undef max\n#endif\n  inline void min(const vector3t &v)\n    {\n      coo[0]=std::min(v.x(), x());\n      coo[1]=std::min(v.y(), y());\n      coo[2]=std::min(v.z(), z());\n    }\n  inline void max(const vector3t &v)\n    {\n      coo[0]=std::max(v.x(), x());\n      coo[1]=std::max(v.y(), y());\n      coo[2]=std::max(v.z(), z());\n    }\n\n\n  //\n  // When I do this, how come that I'm allowed to do something like this:\n  //\n  // vector3t x, y, z, w;\n  // z=x.conv(y);\n  // z+=w;\n  //\n  // Aha. Because it's the z I modify, not the return value of conv.\n  // This shouldn't work:\n  //\n  // (x.conv(y)).conv(w)\n  //\n  // And it does not. Therefore, 'inline vec...' instead of\n  // 'inline const vec...'.\n  // \n  inline vector3t &conv(const vector3t &v)\n    {\n      coo[0]*=v.coo[0];\n      coo[1]*=v.coo[1];\n      coo[2]*=v.coo[2];\n      return *this;\n    }\n  // 050122: Added this variation.\n  inline friend vector3t conv2(const vector3t &v1, const vector3t &v2)\n    {\n      return vector3t(v1.x()*v2.x(), v1.y()*v2.y(), v1.z()*v2.z());\n    }\n\n  // 050122: Added this... Note, no checking on components being zero!\n  //         So, to scale V to the box with corners A and B:\n  //         conv2((B-A).reciprocal(), V-A);\n  inline vector3t reciprocal(void) const\n    {\n      return vector3t(1.0/coo[0], 1.0/coo[1], 1.0/coo[2]);\n    }\n\n  // 050122: Might as well add this, then, for better clarity in calling code.\n  //         Hmm... 'transform' or something would have been a better name.\n  inline vector3t &rescale(const vector3t &mi, const vector3t &ma,\n\t\t\t   const vector3t &new_mi, const vector3t &new_ma)\n    {\n      *this=conv2(conv2((ma-mi).reciprocal(), *this-mi), new_ma-new_mi)+new_mi;\n      return *this;\n    }\n\n  inline T length_squared(void) const\n    {\n      return (coo[0]*coo[0]+coo[1]*coo[1]+coo[2]*coo[2]);\n    }\n\n  inline T length(void) const\n    {\n      return (sqrt(length_squared()));\n      //return (sqrt(coo[0]*coo[0]+coo[1]*coo[1]+coo[2]*coo[2]));\n    }\n\n  inline void normalize(void)\n    {\n      const T tmp=1.0/length();\n      coo[0]*=tmp;\n      coo[1]*=tmp;\n      coo[2]*=tmp;\n    }\n\n  inline vector3t normalized(void) const\n    {\n      return (1.0/length())*(*this);\n    }\n\n  void print(void) const\n    {\n      printf(\"vector3t(%f %f %f)\\n\",\n\t     (double)coo[0], (double)coo[1], (double)coo[2]);\n    }\n\n  // 041212: Added version which does not print a newline.\n  void print2(void) const\n    {\n      printf(\"vector3t(%f %f %f)\",\n\t     (double)coo[0], (double)coo[1], (double)coo[2]);\n    }\n\n  // 050214: Added version which does not print a newline, fixed size.\n  void print3(void) const\n    {\n      printf(\"(%7.3f %7.3f %7.3f)\",\n\t     (double)coo[0], (double)coo[1], (double)coo[2]);\n    }\n\n  inline T min_coo(void) const\n    {\n      return std::min(coo[0], std::min(coo[1], coo[2]));\n    }\n\n  inline T max_coo(void) const\n    {\n      return std::max(coo[0], std::max(coo[1], coo[2]));\n    }\n  \n  inline bool dequal(const vector3t<T> &v) const\n    {\n      return (DEQUAL(x(), v.x()) && DEQUAL(y(), v.y()) && DEQUAL(z(), v.z()));\n    }\n\n  inline bool dequal2(const vector3t<T> &v) const\n    {\n      return (DEQUAL2(x(), v.x()) &&\n\t      DEQUAL2(y(), v.y()) &&\n\t      DEQUAL2(z(), v.z()));\n    }\n\n  // 030711: For floats\n  inline bool dequal3(const vector3t<T> &v) const\n    {\n      return (DEQUAL3(x(), v.x()) &&\n\t      DEQUAL3(y(), v.y()) &&\n\t      DEQUAL3(z(), v.z()));\n    }\n\n  // 030209: Useful because we avoid casting to a vector2t.\n  inline bool dequal_2d(const vector3t<T> &v) const\n    {\n      return (DEQUAL(x(), v.x()) && DEQUAL(y(), v.y()));\n    }\n\n  // 030709: Rotation in the xy-plane, i.e., around the z-axis.\n  inline void rotate_xy(const double cosa, const double sina)\n    {\n      double oldx=coo[0], oldy=coo[1];\n      coo[0] =  cosa*oldx + sina*oldy;\n      coo[1] = -sina*oldx + cosa*oldy;\n    }\n\n  // 030709: Rotation in the xz-plane, i.e., around the y-axis, but note the\n  //         \"opposite\" orientation...\n  inline void rotate_xz(const double cosa, const double sina)\n    {\n      double oldx=coo[0], oldz=coo[2];\n      coo[0] =  cosa*oldx + sina*oldz;\n      coo[2] = -sina*oldx + cosa*oldz;\n    }\n\n  // 030819: Rotation in the yz-plane, i.e., around the x-axis.\n  inline void rotate_yz(const double cosa, const double sina)\n    {\n      double oldy=coo[1], oldz=coo[2];\n      coo[1] =  cosa*oldy + sina*oldz;\n      coo[2] = -sina*oldy + cosa*oldz;\n    }\n};\n\n\n\n\n\n\n#endif\n"
  },
  {
    "path": "viewer/include/mouse.h",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#ifndef MOUSE_H_INCLUDED\n\n\n//\n// 990831: See the C-file for comments.\n//\nextern GLboolean allow_zrot;\nextern int last_x, last_y, last_x0, last_y0;\nextern bool mouse_movement; // 021203: Adopted from old (?) version.\n\n\nint transversal_rotation(int x, int y, int last_xx, int last_yy);\nvoid MouseRotate(int x, int y);\nvoid MouseZoom(int x, int y);\nvoid MouseTranslate(int x, int y);\nvoid Mouse(int butt, int state, int x, int y);\n\n\n\n\n\n\n#define MOUSE_H_INCLUDED\n#endif\n"
  },
  {
    "path": "viewer/include/sisl_aux.h",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#ifndef SISL_AUX_H_INCLUDED\n\n\n#include \"sisl.h\"\n#include \"sislP.h\"\n//#include \"jonvec.h\"\n\nvoid lower_degree_to_linear(SISLSurf **srf, double e);\n\nvoid lower_degree_and_subdivide(SISLSurf **srf, int new_knots_per_interval,\n \t\t\t\tint max_number_of_knots);\n\nvoid compute_surface_normals(SISLSurf *srf, double **ngrid);\n\n\n\n\n\n\n#define SISL_AUX_H_INCLUDED\n#endif\n"
  },
  {
    "path": "viewer/include/transfutils.h",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#ifndef TRANSFUTILS_H_INCLUDED\n\n//\n// 990831: See the C-file for comments.\n//\nextern double xtrans, ytrans, ztrans, xrot_eps, yrot_eps, zrot_eps;\nextern double xscale, yscale, zscale;\nextern double xrot, yrot, zrot;\n\n\n\n\n\n\nvoid rotate(double y_ang, double x_ang, double z_ang);\nvoid translate(double x, double y, double z);\nvoid scale(double x, double y, double z);\n\n\n\n\n\n\n#define TRANSFUTILS_H_INCLUDED\n#endif\n"
  },
  {
    "path": "viewer/sisl_view_demo.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <stdio.h>\n#include <math.h>\n#include <stdlib.h>\t// atoi\n#include <ctype.h>\t// tolower\n#include <string>\n#include <iostream>\n#include <fstream>\n#include <stdexcept>\n#include <vector>\n#include <cstring>\n\n#ifdef WIN32\n#include <windows.h>\n#endif\n\n#include <GL/gl.h>\n#include <GL/glut.h>\n\n#include \"gl_aux.h\"\n#include \"transfutils.h\"\n#include \"mouse.h\"\n#include \"sisl_aux.h\"\n//#include \"read_nurbs_sf.h\"\n//#include \"read_curves.h\"\n#include \"GoReadWrite.h\" // from 'streaming'\n#include \"aux2.h\"\n#include \"jonvec.h\"\n\n#ifndef WIN32\n#  include <unistd.h>\t// usleep\n#else\n#  define MIDDLE_EMU\n#endif\n\n#ifdef _MSC_VER\n#  include <time.h>\n#endif\n\nstatic const int DEFAULT_REF = 30000000;\nstatic const int DEFAULT_MAX_REF = 100;\n\nchar init_key_string[1000];\ndouble axis_thickness=0.3, axis_length=0.7, marker_size=1.0;\nint draw_edges=0;\nfloat wire_col=0.0, background_col=0.0;\nint draw_axes=1;\nint frames_without_movement=0;\n\n#define MAX_SURFACES 100\n#define MAX_CURVES 2000\n#define MAX_LINES 100\n\nSISLSurf *surface[MAX_SURFACES];\nint surfaces=0, selected_surface=-1, surface_highlights=0, curve_highlights=0;\nint selected_curve=-1;\ndouble *normal[MAX_SURFACES];\nint surf_enabled[MAX_SURFACES];\nint curve_enabled[MAX_CURVES];\nchar *surface_name[MAX_SURFACES];\nchar *curve_name[MAX_CURVES];\nSISLCurve *curve[MAX_CURVES];\nint curves=0;\ndouble *discr_curve[MAX_CURVES]; // This must be filled with NULLs.\nvector< vector3t<float> > pcloud;\n\n// 001101: Moving these out of set_material, so they can be used by the\n//         curve-drawing functions too...\n// 021203: There is a problem with duplicated code here... Should be\n//         resolved some time...\n//\nconst int predef_colours=6;\nconst double col_setting[3*predef_colours]\n={1.0, 0.0, 0.0,\n  0.0, 1.0, 0.0,\n  0.0, 0.0, 1.0,\n  1.0, 1.0, 0.0,\n  0.0, 1.0, 1.0,\n  1.0, 0.0, 1.0};\nconst double col_x_setting_back[3*predef_colours]\n={0.6, 0.2, 0.0,\n  0.0, 0.6, 0.2,\n  0.2, 0.0, 0.6,\n  0.6, 0.6, 0.2,\n  0.2, 0.6, 0.6,\n  0.6, 0.2, 0.6};\n\n\nstatic std::string general_help_string = \n//-------|---------|---------|---------|---------|---------|---------|---------|\n\"USAGE:\\n\"\n\"sisl_view_demo <option list> \\n\"\n\"The options are: \\n\"\n\"'s' - next string is the filename of one or more surfaces to read \\n\"\n\"'c' - next string is the filename of one or more curves to read \\n\"\n\"'p' - next string is the filename of a pointcloud to read \\n\"\n//\"'r' - set refinement factor (Note! Must appear before 's' option.)\\n\"\n//\"'R' - set max refinement factor (Note! Must appear before 's' option.)\\n\"\n\"'r' - set max refinement factor (Note! Must appear before 's' option.)\\n\"\n\"'e' - a string with keypresses to execute follows \\n\"\n\"'hotkeys' - display a list of hotkeys that can be used \\n\"\n\"            when viewing an object\\n\\n\";\n\n\nstatic std::string hotkey_help_string = \n//-------|---------|---------|---------|---------|---------|---------|---------|\n\"\\nCommand keys in viewer are: \\n\"\n\"\\n\"\n\"---General---\\n\"\n\"'q' - Quit\\n\"\n\"\\n\"\n\"---Selection---\\n\"\n\"<space> - select curve by cycling through each of them\\n\"\n\"<tab>   - select surface by cycling through each of them\\n\"\n\"\\n\"\n\"---Toggles---\\n\"\n\"'B' - toggle between black and white color for backgrounds\\n\"\n\"'A' - toggle axes on/off\\n\"\n\"'w' - toggle wireframe on/off\\n\"\n\"\\n\"\n\"---Enabling/disabling---\\n\"\n\"'e'      - enable/disable currently selected surface\\n\"\n\"<ctrl-e> - enable/disable currently selected curve\\n\"\n\"'a'      - enable all surfaces\\n\"\n\"<ctrl-a> - enable all curves\\n\"\n\"'d'      - disable all other surfaces than this\\n\"\n\"<ctrl-d> - disable all other curves than this\\n\"\n\"\\n\"\n\"---Centering of elements---\\n\"\n\"'O' - center and rescale (i.e. ditch aspect ratio) all objects around origo\\n\"\n\"      such that they fit snuggly into a (-1, -1, -1) to (1, 1, 1) cube.\\n\"\n\"'o' - center all objects around origo, no rescaling done, aspect ratios\\n\"\n\"      preserved.\\n\"\n\"\\n\"\n\"---Size of elements---\\n\"\n\"'+' - increase thickness of axes\\n\"\n\"'-' - decrease thickness of axes\\n\"\n\"'>' - increase size of points\\n\"\n\"'<' - decrease size of points\\n\"\n\"'*' / increase length of axes\\n\"\n\"'/' - decrease length of axes\\n\"\n\"\\n\"\n\"---Load/save viewpoint---\\n\"\n\"[n] is here an integer from 0 to 9.\\n\"\n\"<esc>-'w'-[n] - store viewpoint in slot [n]\\n\"\n\"<esc>-'r'-[n] - load viewpoint from slot[n]\\n\"\n\"\\n\\n\";\n\nstatic std::istream& eatwhite(std::istream& is) \n{\n  char c;\n  while (is.get(c)) {\n    if (!isspace(c)) {\n      is.putback(c);\n      break;\n    }\n  }\n  return is;\n}\n\nstatic void set_material(int i)\n{\n  const double a=0.8;\n  int j;\n  i=i+4;\n  i=i % predef_colours;\n  \n  float front_mat_shininess[] = {150.0};\n  float front_mat_specular[] = {0.9, 0.9, 0.9, a};\n\n  float front_mat_ambient[] = {0.2, 0.1, 0.1, a};\n  float front_mat_diffuse[] = {0.6, 0.2, 0.2, a};\n  float front_mat_emission[] = {0.2, 0.05, 0.05, a};\n  float back_mat_ambient[] = {0.2, 0.2, 0.1, a};\n  float back_mat_diffuse[] = {0.6, 0.6, 0.2, a};\n  float back_mat_emission[] = {0.2, 0.2, 0.05, a};\n\n  for (j=0; j<3; j++)\n    {\n      front_mat_ambient[j] =0.1 *col_setting[     3*i+j]+0.1 ;\n      front_mat_diffuse[j] =0.5 *col_setting[     3*i+j]+0.2 ;\n      front_mat_emission[j]=0.15*col_setting[     3*i+j]+0.05;\n      back_mat_ambient[j]  =0.1 *col_x_setting_back[3*i+j]+0.1 ;\n      back_mat_diffuse[j]  =0.5 *col_x_setting_back[3*i+j]+0.2 ;\n      back_mat_emission[j] =0.15*col_x_setting_back[3*i+j]+0.05;\n    }\n  \n  glMaterialfv(GL_FRONT, GL_SHININESS, front_mat_shininess);\n  glMaterialfv(GL_FRONT, GL_SPECULAR,  front_mat_specular);\n  glMaterialfv(GL_FRONT, GL_DIFFUSE,   front_mat_diffuse);\n  glMaterialfv(GL_FRONT, GL_AMBIENT,   front_mat_ambient);\n  glMaterialfv(GL_FRONT, GL_EMISSION,  front_mat_emission);\n  \n  glMaterialfv(GL_BACK, GL_SHININESS, front_mat_shininess);\n  glMaterialfv(GL_BACK, GL_SPECULAR,  front_mat_specular);\n  glMaterialfv(GL_BACK, GL_DIFFUSE,   back_mat_diffuse);\n  glMaterialfv(GL_BACK, GL_AMBIENT,   back_mat_ambient);\n  glMaterialfv(GL_BACK, GL_EMISSION,  back_mat_emission);\n}\n\n\n\n\n\n\nstatic void show_general_help()\n{\n  puts(general_help_string.c_str());\n}\n\n\n\n\n\n\nstatic void show_hotkey_help()\n{\n  puts(hotkey_help_string.c_str());\n}\n\n\n\n\n\n\nstatic void draw_all_surfaces(void)\n{\n\n  int i, j, k;\n\n  for (i=0; i<surfaces; i++)\n    {\n      if ((surface_highlights) && (selected_surface==i))\n\tglDisable(GL_LIGHTING);\n      set_material(i);\n\n      //\n      // As a first brute force solution, we draw single triangles,\n      // and we draw the control polygon. Normals should already be\n      // computed and stored in the array 'normal'.\n      //\n      // A surface is drawn if it is enabled, or if it is selected.\n      //\n      if ((surf_enabled[i]) ||\n\t  ((surface_highlights) && (selected_surface==i)))\n\t//\n\t// ... or else, we fall back on the control polygon solution.\n\t//\n\tfor (j=0; j<surface[i]->in1-1; j++)\n\t  {\n\t    //\n\t    // Now, we do a strip in the second (v)\n\t    // parameter direction.\n\t    //\n\t    glBegin(GL_TRIANGLE_STRIP);\n\t    glColor3f(1.0, 1.0, 1.0);\n\t    for (k=0; k<surface[i]->in2; k++)\n\t      {\n\t\tint p=3*(j+k*surface[i]->in1);\n\t\tglNormal3f(normal[i][p+0], normal[i][p+1], normal[i][p+2]);\n\t\tglColor3f(0.0, 1.0, 0.0);\n\t\tglTexCoord2d((double)k, 0.0);\n\t\tglVertex3f(surface[i]->ecoef[p+0],\n\t\t\t   surface[i]->ecoef[p+1],\n\t\t\t   surface[i]->ecoef[p+2]);\n\t\tp+=3;\n\t\tglNormal3f(normal[i][p+0], normal[i][p+1], normal[i][p+2]);\n\t\tglColor3f(1.0, 0.0, 0.0);\n\t\tglTexCoord2d((double)k, 1.0);\n\t\tglVertex3f(surface[i]->ecoef[p+0],\n\t\t\t   surface[i]->ecoef[p+1],\n\t\t\t   surface[i]->ecoef[p+2]);\n\t      }\n\t    glEnd();\n\t      \n\t    if (draw_edges)\n\t      {\n\t\tglBegin(GL_LINE_STRIP);\n\t\tglColor3f(1.0, 1.0, 1.0);\n\t\tfor (k=0; k<surface[i]->in2; k++)\n\t\t  {\n\t\t    int p=3*(j+k*surface[i]->in1);\n\t\t    glNormal3f(normal[i][p+0], normal[i][p+1],\n\t\t\t       normal[i][p+2]);\n\t\t    glColor3f(0.0, 1.0, 0.0);\n\t\t    glTexCoord2d((double)k, 0.0);\n\t\t    glVertex3f(surface[i]->ecoef[p+0],\n\t\t\t       surface[i]->ecoef[p+1],\n\t\t\t       surface[i]->ecoef[p+2]);\n\t\t    p+=3;\n\t\t    glNormal3f(normal[i][p+0], normal[i][p+1],\n\t\t\t       normal[i][p+2]);\n\t\t    glColor3f(1.0, 0.0, 0.0);\n\t\t    glTexCoord2d((double)k, 1.0);\n\t\t    glVertex3f(surface[i]->ecoef[p+0],\n\t\t\t       surface[i]->ecoef[p+1],\n\t\t\t       surface[i]->ecoef[p+2]);\n\t\t  }\n\t\t  \n\t\tglEnd();\n\t      }\n\n\t  }\n      \n      if ((surface_highlights) && (selected_surface==i))\n\t{\n\t  surface_highlights--;\n\t  glEnable(GL_LIGHTING);\n\t}\n      glDisable(GL_BLEND);\n    }\n}\n\n\n\n\n\n\nstatic void draw_all_points(void)\n{\n  int i;\n\n  glDisable(GL_LIGHTING);\n  glPointSize(marker_size);\n  glBegin(GL_POINTS);\n  glColor3f(1.0, 1.0, 1.0);\n  for (i=0; i<int(pcloud.size()); i++)\n    glVertex3fv(pcloud[i].raw());\n  glEnd();\n  glEnable(GL_LIGHTING);\n}\n\n\n\n\n\n\nvoid draw_all_curves(void)\n{\n  int i, j;\n  \n  for (i=0; i<curves; i++)\n    {\n      if (curve_enabled[i])\n\t{\n\t  //\n\t  // As a first brute force solution, we simply evaluate the curves\n\t  // in 100 points and draw straight line segments.\n\t  // All evaluations are done once, since the curves are not evolving\n\t  // in any way.\n\t  //\n#define CURVE_EVALUATIONS 500\n\t  if (discr_curve[i]==NULL)\n\t    {\n\t      discr_curve[i]=new double[3*CURVE_EVALUATIONS];\n\t      int left=0;\n\t      \n\t      for (j=0; j<CURVE_EVALUATIONS; j++)\n\t\t{\n\t\t  double t=\n\t\t    curve[i]->et[curve[i]->ik-1]+\n\t\t    (curve[i]->et[curve[i]->in]-curve[i]->et[curve[i]->ik-1])*\n\t\t    j/(CURVE_EVALUATIONS-1.0);\n\t\t  {\n\t\t    int stat;\n\t\t    \n\t\t    s1227(curve[i], 0, t, &left, discr_curve[i]+3*j, &stat);\n\t\t    if (stat!=0)\n\t\t      CRIT_ERR(printf(\"s1227 returned status %d.\\n\", stat));\n\t\t  }\n\t\t}\n\t    }\n\t  \n\t  //\n\t  // Now we draw all the line segments.\n\t  //\n\t  glLineWidth(1.0);\n\t  glDisable(GL_LIGHTING);\n\t  glBegin(GL_LINE_STRIP);\n\t  {\n\t    // int c=i % predef_colours;\n\t    \n\t    for (j=0; j<CURVE_EVALUATIONS; j++)\n\t      {\n\t\t//glColor3dv(col_setting+3*c);\n\t\t//glColor3f(0.0, 0.0, 0.0);\n\t\tglColor3f(1.0-background_col,\n\t\t\t  1.0-background_col,\n\t\t\t  1.0-background_col);\n\t\tglVertex3dv(discr_curve[i]+3*j);\n// \t\tprintf(\"%4d: %f %f %f\\n\", j,   discr_curve[i][3*j],\n// \t\t       discr_curve[i][3*j+1], discr_curve[i][3*j+2]);\n\t      }\n\t  }\n\t  glEnd();\n\t  glEnable(GL_LIGHTING);\n\t  \n\t} // end of if(curve_enabled[i]) ...\n    }\n}\n\n\n\n\n\n\nstatic void draw(void)\n{\n  /* We don't push the matrix stack, we just keep adding rotations. */\n  rotate(yrot*0.01, xrot*0.01, zrot*0.01);\n  \n  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);\n  glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);\n  \n  draw_all_surfaces();\n  draw_all_curves();\n  draw_all_points();\n  \n  if (draw_axes)\n    draw_gl_axes_old(10, axis_length,\n\t\t     axis_thickness*0.01, axis_thickness*0.04, 0.1);\n  glFlush();\n  glutSwapBuffers();\n  glutPostRedisplay();\n  \n  mouse_movement=0;\n}\n\n\n\n\n\n\nstatic void Reshape(int width, int height)\n{\n  glViewport(0, 0, (GLint)width, (GLint)height);\n  /*\n    glutPostRedisplay();\n  */\n}\n\n\n\n\n\n\nstatic void center_and_scale(const int rescale)\n{\n  int i, j;\n  double minx=1e30, miny=1e30, minz=1e30;\n  double maxx=-1e30, maxy=-1e30, maxz=-1e30;\n  \n  for (i=0; i<surfaces; i++)\n    if ((surf_enabled[i]) && (surface[i]->idim==3))\n      for (j=0; j<surface[i]->in1*surface[i]->in2; j++)\n\t{\n\t  minx=MIN(minx, surface[i]->ecoef[3*j+0]);\n\t  miny=MIN(miny, surface[i]->ecoef[3*j+1]);\n\t  minz=MIN(minz, surface[i]->ecoef[3*j+2]);\n\t  maxx=MAX(maxx, surface[i]->ecoef[3*j+0]);\n\t  maxy=MAX(maxy, surface[i]->ecoef[3*j+1]);\n\t  maxz=MAX(maxz, surface[i]->ecoef[3*j+2]);\n\t}\n  \n  for (i=0; i<curves; i++)\n    if (curve_enabled[i])\n      for (j=0; j<curve[i]->in; j++)\n\t{\n\t  minx=MIN(minx, curve[i]->ecoef[3*j+0]);\n\t  miny=MIN(miny, curve[i]->ecoef[3*j+1]);\n\t  minz=MIN(minz, curve[i]->ecoef[3*j+2]);\n\t  maxx=MAX(maxx, curve[i]->ecoef[3*j+0]);\n\t  maxy=MAX(maxy, curve[i]->ecoef[3*j+1]);\n\t  maxz=MAX(maxz, curve[i]->ecoef[3*j+2]);\n\t}\n\n  for (i=0; i<int(pcloud.size()); i++)\n    {\n      minx=MIN(minx, pcloud[i].x());\n      miny=MIN(miny, pcloud[i].y());\n      minz=MIN(minz, pcloud[i].z());\n      maxx=MAX(maxx, pcloud[i].x());\n      maxy=MAX(maxy, pcloud[i].y());\n      maxz=MAX(maxz, pcloud[i].z());\n    }\n  \n  // printf(\"%f %f\\n%f %f\\n%f %f\\n\", minx, maxx, miny, maxy, minz, maxz);\n\n  if (minx==1e30)\n    {\n      puts(\"\\n\\n!Oops! No surfaces/curves \"\n\t   \"enabled for 'center_and_rescale'?!\\n\\n\");\n      return;\n    }\n  \n  double x=-0.5*(maxx+minx);\n  double y=-0.5*(maxy+miny);\n  double z=-0.5*(maxz+minz);\n  double xs=1.0, ys=1.0, zs=1.0;\n//  printf(\"transl: %f %f %f\\n\", x, y, z);\n  \n  if (rescale)\n    {\n      xs=1.0/(maxx+x);\n      ys=1.0/(maxy+y);\n      zs=1.0/(maxz+z);\n      if (fabs(maxx-minx)<1e-10) // We're probably in a plane...\n\txs=1.0;\n      if (fabs(maxy-miny)<1e-10) // We're probably in a plane...\n\tys=1.0;\n      if (fabs(maxz-minz)<1e-10) // We're probably in a plane...\n\tzs=1.0;\n    }\n\n  for (i=0; i<curves; i++)\n    {\n      delete discr_curve[i];\n      discr_curve[i]=NULL;\n      for (j=0; j<curve[i]->in; j++)\n\t{\n\t  curve[i]->ecoef[3*j+0]=(curve[i]->ecoef[3*j+0]+x)*xs;\n\t  curve[i]->ecoef[3*j+1]=(curve[i]->ecoef[3*j+1]+y)*ys;\n\t  curve[i]->ecoef[3*j+2]=(curve[i]->ecoef[3*j+2]+z)*zs;\n\t}\n    }\n  \n  for (i=0; i<surfaces; i++)\n    {\n      if (surface[i]->ikind!=1)\n\tprintf(\"\\nRational (?) surface probably going to be ****** up...\\n\");\n      for (j=0; j<surface[i]->in1*surface[i]->in2; j++)\n\tif (surface[i]->idim==3)\n\t  {\n\t    surface[i]->ecoef[3*j+0]=(surface[i]->ecoef[3*j+0]+x)*xs;\n\t    surface[i]->ecoef[3*j+1]=(surface[i]->ecoef[3*j+1]+y)*ys;\n\t    surface[i]->ecoef[3*j+2]=(surface[i]->ecoef[3*j+2]+z)*zs;\n\t  }\n      // if dim!=3, nothing happens... not very graceful, this, but, ...\n    }\n\n  for (i=0; i<int(pcloud.size()); i++)\n    {\n      pcloud[i].coo[0]=(pcloud[i].coo[0]+x)*xs;\n      pcloud[i].coo[1]=(pcloud[i].coo[1]+y)*ys;\n      pcloud[i].coo[2]=(pcloud[i].coo[2]+z)*zs;\n    }\n\n//  printf(\"xxx scale: %f %f %f\\n\", xscale, yscale, zscale);\n  scale(1.0/xscale, 1.0/yscale, 1.0/zscale);\n\n  if (!rescale)\n    // we don't rescale the data but try to fit it into the frustum.\n    {\n      xs=1.0/(maxx+x);\n      ys=1.0/(maxy+y);\n      zs=1.0/(maxz+z);\n      if (fabs(maxx-minx)<1e-10) // We're probably in a plane...\n\txs=1.0;\n      if (fabs(maxy-miny)<1e-10) // We're probably in a plane...\n\tys=1.0;\n      if (fabs(maxz-minz)<1e-10) // We're probably in a plane...\n\tzs=1.0;\n//       printf(\"frustum fit: %f %f %f      %f\\n\",\n// \t     xs, ys, zs, std::max(zs, std::max(xs, ys)));\n      scale(std::max(zs, std::max(xs, ys)),\n\t    std::max(zs, std::max(xs, ys)),\n\t    std::max(zs, std::max(xs, ys)));\n    }\n  \n}\n\n\n\n\n\n\n//\n// A forward decl. here, since the 'h' function only works properly\n// if the 'read_curves_and_surfaces' follows after 'Key'...\n//\nstatic void read_curves_and_surfaces(int argc, char *argv[]);\n\n\n\n\n\n\nstatic void parse_keys(const int key_in,\n\t\t       const unsigned char * const key_ptr=NULL,\n\t\t       const int keys=1)\n{\n  int i;\n  \n  for (i=0; i<keys; i++)\n    {\n      int rescale=0; // Used by 'o' and 'O'.\n      // Default is the 'no rescale' of 'o'.\n      int key;\n      if (key_ptr==NULL)\n\t// Now 'keys' should be 1!\n\tkey=key_in;\n      else\n\t//\n\t// First, we try to detect the \"pseudocharacter\" '<ESC>'. Or '<TAB>'.\n\t// 010508: Trying to add <CTRL>\n\t//\n\t{\n#define ESC_STRING \"<ESC>\"\n#define TAB_STRING \"<TAB>\"\n#define CTRL_STRING \"<CTRL>\"\n\t  const int esc_len=strlen(ESC_STRING);\n\t  const int tab_len=strlen(TAB_STRING);\n\t  const int ctrl_len=strlen(CTRL_STRING);\n\n\t  if ((keys-i>=esc_len+2) &&\n\t      (strncmp((const char *)key_ptr+i, ESC_STRING, esc_len)==0))\n\t    {\n\t      key = (27<<16) + (key_ptr[i+esc_len]<<8) + key_ptr[i+esc_len+1];\n\t      // 011211: Format seems to be: 27*65536+code1*256+code2.\n\t      i+=esc_len+1;\n\t    }\n\t  else\n\t    if ((keys-i>=tab_len) &&\n\t\t(strncmp((const char *)key_ptr+i, TAB_STRING, tab_len)==0))\n\t      {\n\t\tkey=9;\n\t\ti+=tab_len-1;\n\t      }\n\t    else\n\t      if ((keys-i>=ctrl_len+1) &&\n\t\t  (strncmp((const char *)key_ptr+i, CTRL_STRING, ctrl_len)==0))\n\t\t{\n\t\t  key = tolower(key_ptr[i+ctrl_len])-'a'+1;\n\t\t  i+=ctrl_len;\n\t\t}\n\t      else\n\t\tkey=key_ptr[i];\n\t}\n      \n      // printf(\"key=%d (%c)\\n\", key, key);\n\n      switch (key)\n\t{\n\t  //\n\t  // 021203: What was this? Only place obj_trans (from old mouse.h or something\n\t  //         was used...?!)\n\t  //\n\t  //  \tcase 0: // @H@ Toggle mouse-translation mode.\n\t  //  \t  obj_trans=1-obj_trans;\n\t  //  \t  printf(\"obj_trans=%d\\n\", obj_trans);\n\t  //  \t  break;\n\t  \n\t  //--------------------------------------------------\n\t  //\n\t  // Selection, enabling etc. of surfaces.\n\t  //\n\t  //--------------------------------------------------\n\t  \n\tcase 9:\n\t  // (tab) Select surface by cycling through all surfaces.\n\t  printf(\"Surfaces=%d\\n\", surfaces);\n\t  if ((surfaces>0) /* && (surface_highlights==0) */ )\n\t    {\n\t      selected_surface++;\n\t      if (selected_surface==surfaces)\n\t\tselected_surface=0;\n\t      printf(\"Surface selected is '%s', which has dim=%d.\\n\",\n\t\t     surface_name[selected_surface],\n\t\t     surface[selected_surface]->idim);\n\t      //\n\t      // Now, we signal highlighting of the\n\t      // surface for a few frames.\n\t      //\n\t      surface_highlights=50;\n\t    }\n\t  break;\n\n\tcase 'e':\n\t  // Enable/Disable the selected surface.\n\t  if (selected_surface>-1)\n\t    surf_enabled[selected_surface]=\n\t      1-surf_enabled[selected_surface];\n\t  if (surf_enabled[selected_surface])\n\t    printf(\"Enabled surface '%s'.\\n\", \n\t\t   surface_name[selected_surface]);\n\t  else\n\t    printf(\"Disabled surface '%s'.\\n\",\n\t\t   surface_name[selected_surface]);\n\t  break;\n\n\tcase 'd':\n\t  // Disable all other surfaces than this.\n\t  if (selected_surface>-1)\n\t    {\n\t      int i;\n\t\t      \n\t      for (i=0; i<surfaces; i++)\n\t\tsurf_enabled[i]=(i==selected_surface);\n\t    }\n\t  printf(\"Enabled surface '%s'.\\n\",\n\t\t surface_name[selected_surface]);\n\t  break;\n\n\tcase 'a':\n\t  // Enable all surfaces.\n\t{\n\t  int i;\n\t\t  \n\t  for (i=0; i<surfaces; i++)\n\t    surf_enabled[i]=1;\n\t}\n\tputs(\"All surfaces enabled.\");\n\tbreak;\n\t\t\n\t//--------------------------------------------------\n\t//\n\t// Selection, enabling etc. of curves.\n\t//\n\t//--------------------------------------------------\n\t\t\n\tcase ' ':\n\t  // (space) Select curve by cycling through all of them.\n\t  if ((curves>0) && (curve_highlights==0))\n\t    {\n\t      selected_curve++;\n\t      if (selected_curve==curves)\n\t\tselected_curve=0;\n\t      printf(\"Curve selected is '%s'.\\n\",\n\t\t     curve_name[selected_curve]);\n\t      surface_highlights=5;\n\t    }\n\t  break;\n\t\t  \n\tcase 5:\n\t  // (ctrl-e) Enable/Disable the selected curve.\n\t  if (selected_curve>-1)\n\t    curve_enabled[selected_curve]=1-curve_enabled[selected_curve];\n\t  if (curve_enabled[selected_curve])\n\t    printf(\"Enabled curve '%s'.\\n\", curve_name[selected_curve]);\n\t  else\n\t    printf(\"Disabled curve '%s'.\\n\", curve_name[selected_curve]);\n\t  break;\n\tcase 4: // (ctrl-d) Disable all other curves than this.\n\t  if (selected_curve>-1)\n\t    {\n\t      int i;\n\t      \n\t      for (i=0; i<curves; i++)\n\t\tcurve_enabled[i]=(i==selected_curve);\n\t    }\n\t  printf(\"Enabled curve '%s'.\\n\", curve_name[selected_curve]);\n\t  break;\n\n\tcase 1: // (ctrl-a) Enable all curves.\n\t{\n\t  int i;\n\t\t  \n\t  for (i=0; i<curves; i++)\n\t    curve_enabled[i]=1;\n\t}\n\tputs(\"All curves enabled.\");\n\tbreak;\n\t  \n\t//\n\t// 001206: Hmm... How should we handle the centering and rescaling \n\t//         for inifinte straight lines? Could use the point closest\n\t//         to origo, perhaps???\n\t//\n\tcase 'O': // Center and rescale all objects around origo.\n\t  rescale=1;\n\t  //\n\t  // Note how we simply continue into the code for 'o'...\n\t  //\n\tcase 'o': // Center all objects around origo. Possibly rescale.\n\t  center_and_scale(rescale);\n\t  break;\n\t  \n\tcase 'q': // Quit.\n\t  exit(0);\n\t  \n\t  //--------------------------------------------------\n\t  //\n\t  // Colour stuff.\n\t  //\n\t  //--------------------------------------------------\n\t  \n\tcase 'b': // Toggle between black and white for wireframes.\n\t  wire_col=1.0-wire_col;\n\t  break;\n\tcase 'B': // Toggle between black and white for the background.\n\t  background_col=1.0-background_col;\n\t  glClearColor(background_col, background_col, background_col, 0.0);\n\t  break;\n\t  \n\t  //--------------------------------------------------\n\t  \n\tcase '+': // Increase thickness of axes.\n\t  axis_thickness*=1.1;\n\t  //printf(\"axis_thickness=%f\\n\", axis_thickness);\n\t  break;\n\tcase '-': // Decrease thickness of axes.\n\t  if (axis_thickness>0.1)\n\t    axis_thickness*=0.9;\n\t  //printf(\"axis_thickness=%f\\n\", axis_thickness);\n\t  break;\n\n\tcase '>': // Increase size of point markers.\n\t  marker_size*=1.1;\n\t  //printf(\"marker_size=%.5f\\n\", marker_size);\n\t  break;\n\tcase '<': // Decrease size of point markers.\n\t  if (marker_size>0.00001)\n\t    marker_size*=0.9;\n\t  //printf(\"marker_size=%.5f\\n\", marker_size);\n\t  break;\n\n\tcase '*': // Increase length of axes.\n\t  axis_length*=1.1;\n\t  //printf(\"axis_length=%f\\n\", axis_length);\n\t  break;\n\tcase '/': // Decrease length of axes.\n\t  if (axis_length>0.1)\n\t    axis_length*=0.9;\n\t  //printf(\"axis_length=%f\\n\", axis_length);\n\t  break;\n\t  \n\tcase 'A': // Toggle axes on/off.\n\t  draw_axes=1-draw_axes;\n\t  //printf(\"draw_axes=%d\\n\", draw_axes);\n\t  break;\n\n\tcase 'w': // Toggle wireframe mode on/off, no hidden line removal.\n\t  draw_edges=1-draw_edges;\n\t  //printf(\"draw_edges=%d\\n\", draw_edges);\n\t  break;\n\t  \n\t  //--------------------------------------------------\n\t  //\n\t  // Reading and writing of viewing parameters.\n\t  //\n\t  //--------------------------------------------------\n\t  \n\tcase (27<<16)+('w'<<8)+'1': // (Esc-w-<n>) Storing viewing parameters in slot <n>.\n\tcase (27<<16)+('w'<<8)+'2':\n\tcase (27<<16)+('w'<<8)+'3':\n\tcase (27<<16)+('w'<<8)+'4':\n\tcase (27<<16)+('w'<<8)+'5':\n\tcase (27<<16)+('w'<<8)+'6':\n\tcase (27<<16)+('w'<<8)+'7':\n\tcase (27<<16)+('w'<<8)+'8':\n\tcase (27<<16)+('w'<<8)+'9':\n\t{\n\t  int slot=(key&255)-'1'+1;\n\n\t  printf(\"Storing viewing parameters in slot %d.\\n\", slot);\n\t  char tmp[1000];\n#ifdef _MSC_VER\n\t  // don't know which headerfile to use for VC++...\n\t  // Also: Using root instead of home directory...\n\t  sprintf(tmp, \"view%d\", slot);\n#else\n\t  snprintf(tmp, 1000, \"view%d\", slot);\n#endif\n\t  FILE *f=fopen(tmp, \"w\");\n\t  if (f==NULL)\n\t    CRIT_ERR(printf(\"Error opening file '%s' for writing.\\n\", tmp));\n\t  write_gl_matrices(f);\n\t  fprintf(f, \"%.15e %.15e %.15e\\n\", xtrans, ytrans, ztrans);\n\t  fprintf(f, \"%.15e %.15e %.15e\\n\", xscale, yscale, zscale);\n\t  fclose(f);\n\t}\n\tbreak;\n\tcase (27<<16)+('r'<<8)+'1': // (Esc-r-<n>) Retrieving viewing parameters in slot <n>.\n\tcase (27<<16)+('r'<<8)+'2':\n\tcase (27<<16)+('r'<<8)+'3':\n\tcase (27<<16)+('r'<<8)+'4':\n\tcase (27<<16)+('r'<<8)+'5':\n\tcase (27<<16)+('r'<<8)+'6':\n\tcase (27<<16)+('r'<<8)+'7':\n\tcase (27<<16)+('r'<<8)+'8':\n\tcase (27<<16)+('r'<<8)+'9':\n\t{\n\t  int slot=(key&255)-'1'+1;\n\n\t  printf(\"Retrieving viewing parameters from slot %d.\\n\", slot);\n\t  char tmp[1000];\n#ifdef _MSC_VER\n\t  // don't know which headerfile to use for VC++...\n\t  // Also: Using root instead of home directory...\n\t  sprintf(tmp, \"/view%d\", slot);\n#else\n\t  snprintf(tmp, 1000, \"view%d\", slot);\n#endif\n\t  FILE *f=fopen(tmp, \"r\");\n\t  if (f==NULL)\n\t    printf(\"Error opening file '%s' for reading, skipping.\\n\", tmp);\n\t  else\n\t    {\n\t      read_gl_matrices(f);\n\t      fscanf(f, \"%lf %lf %lf\\n\", &xtrans, &ytrans, &ztrans);\n\t      fscanf(f, \"%lf %lf %lf\\n\", &xscale, &yscale, &zscale);\n\t      fclose(f);\n\t    }\n\t}\n\tbreak;\n\t  \n\tdefault:\n\t  ;\n\t}\n    }\n}\n\n\n\n\n\n\nstatic void Key(unsigned char key_in, int x, int y)\n{\n  static unsigned char multi_key[3];\n  static int multi_key_length=0;\n  int key=key_in;\n\n  if ((key==27) && (multi_key_length==0))\n    //\n    // Esc as first key in sequence was pressed.\n    //\n    {\n      multi_key[0]=key;\n      multi_key_length=1;\n      return;\n    }\n\n  if ((multi_key_length==1) && (multi_key[0]==27))\n    //\n    // Second key in esc sequence was pressed.\n    //\n    {\n      if ((key=='r') || (key=='w'))\n\t{\n\t  multi_key_length=2;\n\t  multi_key[1]=key;\n\t  return;\n\t}\n      //\n      // This causes a two-key esc sequence to be parsed.\n      //\n      key+=256*multi_key[0];\n      multi_key_length=0;\n    }\n\n  if (multi_key_length==2)\n    //\n    // Third key in a known three-key esc sequence was pressed.\n    //\n    {\n      if ((multi_key[1]=='r') || (multi_key[1]=='w'))\n\tif ((key>='1') && (key<='9'))\n\t  printf(\"Storing/retrieving viewing parameters in slot '%c'.\\n\", key);\n      //\n      // This causes the three-key esc sequence to be parsed.\n      //\n      key=(multi_key[0]<<16) + (multi_key[1]<<8) + key;\n      printf(\"mk=%d %d %d key=%d\\n\",\n\t     multi_key[0], multi_key[1], multi_key[2], key);\n      multi_key_length=0;\n    }\n  \n  //\n  // Now key can be extended into max. 3 bytes...\n  //\n  parse_keys(key);\n\n  glutPostRedisplay();\n}\n\n\n\n\n\n\nstatic void idle_func(void)\n{\n}\n\n\n\n\n\n\nstatic void read_curves_and_surfaces(int argc, char *argv[])\n{\n  xscale=yscale=zscale=1.0;\n  int ref=DEFAULT_REF; // Number of new knots between old ones.\n  int maxref=DEFAULT_MAX_REF; // Maximal number of coeffs in any given direction.\n  // (n, n) makes sure new knots are inserted close to max limit = n...\n  int i;\n\n  //\n  // This must be reset every time we change control vertices, since\n  // the discretization is done in the drawing routine.\n  //\n  for (i=0; i<curves; i++) {\n    if (discr_curve[i]!=NULL) {\n      delete discr_curve[i];\n      discr_curve[i]=NULL;\n    }\n  }\n\n  // @HH@\n  // @HH@ Use the following optional command line options:\n  // @HH@\n  \n  surfaces=0;\n  curves=0;\n\n\n\n  for (i=1; i<argc; i++) {\n    switch (argv[i][0]) {\n    case 's': {\n      // Next string is filename for surface. (One surface.)\n\t    \n      puts(\"Reading surfaces\");\n      // surface[surfaces-1]=read_nurbs_sf(argv[i+1]); // old format    \n\n      std::vector<SISLSurf*> tmp;\n      std::ifstream is(argv[i+1]);\n      if (!is) {\n\tCRIT_ERR(printf(\"Could not open file: '%s'.\\n\", argv[i+1]));\n      }\n      try {\n\teatwhite(is);\n\twhile (!is.eof()) {\n\t  //surface[surfaces-1] = readGoSurface(is);\n\t  tmp.push_back(readGoSurface(is));\n\t  eatwhite(is);\n\t}\n      } catch (std::exception& e) {\n\tCRIT_ERR(printf(\"Error occured while reading surface: %s\\n\", e.what()));\n      }\n      is.close();\n      int num_surfaces = tmp.size();\n      if (surfaces + num_surfaces > MAX_SURFACES) {\n\tCRIT_ERR(puts(\"Increase MAX_SURFACES.\"));\n      }\n\t    \n      for (int k = 0; k < num_surfaces; ++k) {\n\t//\n\t// 010116: This should be a quick fix for periodic\n\t//         surfaces...\n\t//\n\tif (tmp[k] == NULL) {\n\t  CRIT_ERR(printf(\"Couldn't read SISLSurf '%s'.\\n\", argv[i+1]));\t    \n\t}\n\n\tif ((tmp[k]->cuopen_1 == SISL_CRV_PERIODIC ||\n\t     tmp[k]->cuopen_2 == SISL_CRV_PERIODIC)) {\n\t  int kstat;\n\t  SISLSurf *tmp_surf;\n\t  make_sf_kreg(tmp[k], &tmp_surf, &kstat);\n\t  if (kstat < 0) {\n\t    CRIT_ERR(printf(\"make_sf_kreg failed!\\n\"));\n\t  }\n\t  freeSurf(tmp[k]);\n\t  tmp[k] = tmp_surf;\n\t}\n\tif (tmp[k]->idim != 3) {\n\t  CRIT_ERR(printf(\"Dimension of surface is %d and not 3!\\n\",\n\t\t\t  tmp[k]->idim));\n\t}\n\t\t\n\tif (surface[surfaces]) {\n\t  // deleting old surface\n\t  freeSurf(surface[surfaces]);\n\t}\n\tsurface[surfaces] = tmp[k];\n\tsurface_name[surfaces] = argv[i+1];\n\tsurf_enabled[surfaces] = 1;\n\n\t// Generating an approximating polygon.\n\tlower_degree_and_subdivide(surface + surfaces, ref, maxref);\n\n\t// evaluating normals (normalized)\n\tdelete normal[surfaces];\n\tcompute_surface_normals(surface[surfaces], normal + surfaces);\n\t\t\n\t++surfaces;\n      }\n    }\n      i++;\n      break;\n      \n    case 'c': {\n      // Next string is filename for file containing 1 curve.\n\t    \n      printf(\"Reading a single curve into slot %d.\\n\", curves);\n\n      std::vector<SISLCurve*> tmp;\n\t    \n      //n=get_curve_set(argv[i+1], &tmp, &stat);\n      //get_single_curve(argv[i+1], &tmp, &stat); // old format\n      std::ifstream is(argv[i+1]);\n      if (!is) {\n\tCRIT_ERR(printf(\"Could not open file: '%s'.\\n\", argv[i+1]));\n      }\n      try {\n\teatwhite(is);\n\twhile (!is.eof()) {\n\t  tmp.push_back(readGoCurve(is));\n\t  eatwhite(is);\n\t}\n      } catch (std::exception& e) {\n\tCRIT_ERR(printf(\"Error occured while reading curve: %s\\n\", e.what()));\n      }\n      is.close();\n      int num_curves = tmp.size();\n\n      if (curves + num_curves > MAX_CURVES) {\n\tCRIT_ERR(puts(\"Increase MAX_CURVES.\"));\n      }\n\t    \n      for(int k = 0; k < num_curves; ++k) {\n\tif (curve[curves + k] != NULL) {\n\t  freeCurve(curve[curves + k]);\n\t}\n\tcurve[curves + k] = tmp[k];\n\t\t\n\t//\n\t// 001206: If the dimension is 2, we set up a\n\t//         new curve, filling in zeros.\n\t//\n\tif (curve[curves + k]->idim==2) {\n\t\t    \n\t  double *new_coeffs=\n\t    new double[3*curve[curves + k]->in];\n\t  if (new_coeffs==NULL)\n\t    CRIT_ERR(puts(\"Couldn't allocate memory.\"));\n\t  int j;\n\t\t    \n\t  for (j=0; j<curve[curves + k]->in; j++) {\n\t    new_coeffs[3*j+0]= curve[curves + k]->ecoef[2*j+0];\n\t    new_coeffs[3*j+1]= curve[curves + k]->ecoef[2*j+1];\n\t    new_coeffs[3*j+2]=0.0;\n\t  }\n\t  SISLCurve *tmp2=curve[curves + k];\n\t  curve[curves + k]= newCurve(tmp2->in, tmp2->ik, tmp2->et,\n\t\t\t\t      new_coeffs, tmp2->ikind, 3, 1);\n\t  freeCurve(tmp2);\n\t}\n\t\t\n\tif (curve[curves + k]->idim!=3) {\n\t  CRIT_ERR(printf(\"Dimension of curve is %d and not 3?!\\n\",\n\t\t\t  curve[curves + k]->idim));\n\t}\n\n\tcurve_name[curves + k]=argv[i+1];\n\tcurve_enabled[curves + k]=1;\n      }\n      curves+=num_curves;\n    }\n      i++;\n      break;\n\t    \n    case 'p': {\n      // Next string is filename for file containing a point cloud.\n\t    \n      printf(\"Reading a point cloud.\\n\");\n\n      std::ifstream is(argv[i+1]);\n      if (!is) {\n\tCRIT_ERR(printf(\"Could not open file: '%s'.\\n\", argv[i+1]));\n      }\n      try {\n\t  vector<double> coords;\n\t  readGoPoints(coords, is);\n\t  int num_points = int(coords.size()) / 3;\n\t  printf(\"Number of vertices: %d\\n\", num_points);\n\t  for (int i = 0; i < num_points; ++i) {\n\t      pcloud.push_back(vector3t<float>(coords[3 * i], \n\t\t\t\t\t       coords[3 * i + 1], \n\t\t\t\t\t       coords[3 * i + 2]));\n\t  }\n// \teatwhite(is);\n// \tint tmp;\n// \tis >> tmp;\n// \tis >> tmp;\n// \tis >> tmp;\n// \tis >> tmp;\n// \tis >> tmp;\n// \tis >> tmp;\n// \tis >> tmp;\n// \tis >> tmp;\n// \teatwhite(is);\n// \tis >> tmp;\n// \tprintf(\"Number of vertices: %d\\n\", tmp);\n// \twhile (!is.eof()) {\n// \t  double x, y, z;\n// \t  is >> x;\n// \t  is >> y;\n// \t  is >> z;\n// \t  //printf(\"point: %f %f %f\\n\", x, y, z);\n// \t  pcloud.push_back(vector3t<float>(x, y, z));\n// \t  eatwhite(is);\n//      }\n      } catch (std::exception& e) {\n\t  CRIT_ERR(printf(\"Error occured while reading curve: %s\\n\", e.what()));\n      }\n      is.close();\n      printf(\"pcloud size is now %d\\n\", pcloud.size());\n    }\n\ti++;\n      break;\n\t    \n// \tcase 'r':\n// \t    // Set refinement factor. Default value is ???.\n\t    \n// \t    puts(\"Reading surface refinement factor\");\n// \t    ref=atoi(argv[i+1]);\n// \t    i++;\n// \t    break;\n\t    \n//\tcase 'R': \n    case 'r':\n      // Set max refinement factor. Default value is ???.\n\t    \n      puts(\"Reading upper bound for surface refinement.\");\n      maxref=atoi(argv[i+1]);\n      i++;\n      break;\n\t    \n    case 'e': \n      // String with keypresses to execute follows. Not\n      // everything will work!\n\t    \n      printf(\"Executing '%s'.\\n\", argv[i+1]);\n      strncpy(init_key_string, argv[i+1], 1000);\n      i++;\n      break;\n\t    \n    default:\n      puts(\"Huh?! Unknown option.\");\n      exit(0);\n\t    \n    }\n  }\n}\n\n\n\n\n\nint main(int argc, char *argv[])\n{\n  if (argc == 1) {\n    // program called with no arguments.  Show info\n    show_general_help();\n    return 0;\n  } else if (argc == 2 && \n\t     (std::string(argv[1]) == \"hotkeys\" || std::string(argv[1]) == \"HOTKEYS\")) {\n    show_hotkey_help();\n    return 0;\n  }\n  xscale=yscale=zscale=1.0;\n  int i;\n\n  \n  for (i=0; i<MAX_SURFACES; i++)\n    {\n      surface[i]=NULL;\n      normal[i]=NULL;\n    }\n  for (i=0; i<MAX_CURVES; i++)\n    curve[i]=NULL;\n\n  for (i=0; i<MAX_CURVES; i++)\n    discr_curve[i]=NULL;\n\n  read_curves_and_surfaces(argc, argv);\n  \n  {\n    int tx=32, ty=32;\t// gl_init needs variables, but doesn't do\n    // anything when texfile==NULL.\n#ifdef _MSC_VER\n    gl_init(argc, argv, 500, 500, 180, 100, true,\n#else\n\t    gl_init(argc, argv, 1100, 1100, 460, 20, true,\n#endif\n\t\t    1, GL_TRUE, 1, GL_TRUE,\n\t\t    xtrans, ytrans, ztrans,\n\t\t    // xscale, yscale, zscale, tx, ty, NULL);\n\t\t    xscale, yscale, zscale, tx, ty,\n\t\t    // GL_MODULATE,\n\t\t    // GL_BLEND,\n\t\t    GL_DECAL,\n\t\t    NULL\t\t\t// NULL produces a frame.\n\t\t    // \"greyclouds3.pgm\"\t// A texture.\n\t      );\n\t    }\n  \n    //\n    // This will have the same effect as pressing 'tab'+'d'.\n    //\n    if (surfaces>0)\n      {\n\tint i;\n      \n\tselected_surface=0;\n\tfor (i=0; i<surfaces; i++)\n\t  surf_enabled[i]= 1 ; //(i==selected_surface);\n      }\n\n    //\n    // This will have the same effect as pressing 'space'+'ctrl-d'.\n    //\n    if (curves>0)\n      {\n\tint i;\n      \n\tselected_curve=0;\n\tfor (i=0; i<curves; i++)\n\t  curve_enabled[i]=1; // (i==selected_curve);\n      }\n\n    glPolygonOffset(1.0, 1.0);\n    glEnable(GL_POLYGON_OFFSET_POINT);\n    glEnable(GL_POLYGON_OFFSET_LINE);\n    glEnable(GL_POLYGON_OFFSET_FILL);\n  \n    glutReshapeFunc(Reshape);\n    glutKeyboardFunc(Key);\n    glutMotionFunc(MouseRotate);\n    glutMouseFunc(Mouse);\n    glutDisplayFunc(draw);\n    glutIdleFunc(idle_func);\n\n    scale(0.5, 0.5, 0.5);\n    glEnable(GL_NORMALIZE);\n\n\n    parse_keys(0,\n\t       (const unsigned char *)init_key_string,\n\t       strlen(init_key_string));\n\n    // making sure loaded object is centered\n    //parse_keys('o'); // doesn't work as expected\n\n\n    glutMainLoop();\n  \n    return 0;\n  }\n"
  },
  {
    "path": "viewer/src/aux2.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <stdio.h>\n#include <math.h>\n\n// #ifdef _MSC_VER\n// #  include <vector>\n// #else\n// #  include <vector.h>\n// #endif\n#include <vector>\n\n#ifdef _MSC_VER\n#  define max(a, b) ((a)>(b)? (a) : (b))\n#endif\n\n#if defined(_MSC_VER) || defined(LINUX)\n#  include <sys/timeb.h>\n#endif\n\n#ifndef _MSC_VER\n#  include <strings.h>\n#  include <unistd.h>\n#else\n#  include <stdlib.h>\n#endif\n\n#include <time.h>\n\n\n\n\ndouble jon_timer;\n\n\nstatic double jon_sec(void)\n{\n#ifndef _MSC_VER\n#ifdef LINUX\n  struct timeb jon_ts;\n#else\n  struct timespec jon_ts;\n#endif\n#else\n  struct _timeb jon_ts;\n#endif\n  \n#ifndef _MSC_VER\n#ifdef LINUX\n  ftime(&jon_ts);\n  return (jon_ts.time + 0.001*jon_ts.millitm);\n#else\n  clock_gettime(CLOCK_REALTIME, &jon_ts);\n  return (int)(jon_ts.tv_sec) + ((double)(jon_ts.tv_nsec)/1e9);\n#endif\n#else\n  _ftime(&jon_ts);\n  return (jon_ts.time + 0.001*jon_ts.millitm);\n#endif\n}\n\n\nvoid tic(void)\n{\n  jon_timer=jon_sec();\n}\n\n\nvoid toc(void)\n{\n  printf(\"Time elapsed: %f\\n\", jon_sec()-jon_timer);\n}\n"
  },
  {
    "path": "viewer/src/gl_aux.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <math.h>\n#include <stdlib.h>\n#include <cstring>\n\n#include \"aux2.h\"\n#include \"gl_aux.h\"\n\n\n\n#ifndef PI\n#  define PI 3.1415926536\t// Where should it *really* be defined?\n#endif\n\n\nconst int predefined_colours=24;\nconst double predef_col_table[3*predefined_colours]\n={1.0, 0.0, 0.0,\n  0.0, 1.0, 0.0,\n  0.0, 0.0, 1.0,\n  1.0, 1.0, 0.0,\n  0.0, 1.0, 1.0,\n  1.0, 0.0, 1.0,\n  0.7, 0.0, 0.0,\n  0.0, 0.7, 0.0,\n  0.0, 0.0, 0.7,\n  0.7, 0.7, 0.0,\n  0.0, 0.7, 0.7,\n  0.7, 0.0, 0.7,\n  0.3, 0.8, 0.8,\n  0.8, 0.3, 0.8,\n  0.8, 0.8, 0.3,\n  0.3, 0.3, 0.8,\n  0.8, 0.3, 0.3,\n  0.3, 0.8, 0.3,\n  0.5, 0.8, 0.8,\n  0.8, 0.5, 0.8,\n  0.8, 0.8, 0.5,\n  0.5, 0.5, 0.8,\n  0.8, 0.5, 0.5,\n  0.5, 0.8, 0.5};\n\n\n\n\n\n//----------------------------------------------------------------------\n//\n// Drawing a cylinder, or possibly a cone.\n//\n//----------------------------------------------------------------------\n\nvoid draw_cylinder(double x0, double y0, double z0,\n\t\t   double x1, double y1, double z1,\n\t\t   double radius, double radius2, int n)\n{\n  int i;\n  double y, z, r;\n  \n  glPushMatrix();\n  glTranslatef(x0, y0, z0);\n  /*\n    Now, we have to move P=(x1-x0, y1-y0, z1-z0) to (r, 0, 0) where\n    r=length(x1-x0, y1-y0, z1-z0). First, rotate P to Q in the xy-plane:\n  */\n  /* Hvorfor blir det ikke riktig med neg. rotasjon her? */\n  glRotatef(atan2(x1-x0, z1-z0)/PI*180.0-90.0,\n\t    0.0, 1.0, 0.0);\n/*  printf(\"%f %f %f\\t\",\n\t x1-x0,\n\t z1-z0, \n\t atan2(x1-x0, z1-z0)/PI*180.0);*/\n  /*\n    Now, we have to move Q=(sqrt((x1-x0)^2+(z1-z0)^2), y1-y0, 0) to\n    (r, 0, 0).\n  */\n  r=sqrt((x1-x0)*(x1-x0)+(y1-y0)*(y1-y0)+(z1-z0)*(z1-z0));\n  /* Hvorfor blir det ikke riktig med neg. rotasjon her? */\n  glRotatef(atan2(y1-y0, sqrt((x1-x0)*(x1-x0)+(z1-z0)*(z1-z0)))/PI*180.0,\n\t    0.0, 0.0, 1.0);\n/*  printf(\"%f %f %f\\n\",\n\t y1-y0,\n\t sqrt((x1-x0)*(x1-x0)+(z1-z0)*(z1-z0)),\n\t atan2(y1-y0, sqrt((x1-x0)*(x1-x0)+(z1-z0)*(z1-z0)))/PI*180.0);*/\n  /*\n    The next step is to draw the cylinder. Or cone. Normals not perfect for\n    the cone. Impossible at pointy end with tri-fan?\n  */\n  if (radius==radius2)\n    {\n      glBegin(GL_QUAD_STRIP);\n      for (i=0; i<=n; i++)\n\t{\n\t  y=radius*cos((2.0*PI*i)/n);\n\t  z=radius*sin((2.0*PI*i)/n);\n\t  glNormal3f(0.0, y, z);\n\t  glVertex3f(0.0, y, z);\n\t  glNormal3f(0.0, y, z);\n\t  glVertex3f(  r, y, z);\n\t}\n      glEnd();\n    }\n  else\n    {\n      glBegin(GL_TRIANGLE_FAN);\n      glNormal3f(1.0, 0.0, 0.0);\n      glVertex3f(r, 0.0, 0.0);\n      for (i=0; i<=n; i++)\n\t{\n\t  y=radius*cos((2.0*PI*i)/n);\n\t  z=radius*sin((2.0*PI*i)/n);\n\t  glNormal3f(0.0, y, z);\n\t  glVertex3f(0.0, y, z);\n\t}\n      glEnd();\n    }\n  /*\n    Finally, we restore the transformation stack.\n  */\n  glPopMatrix();\n}\n\n\n\n\n\n\n//----------------------------------------------------------------------\n//\n// Drawing a set of axes.\n//\n// 021203: Actually, this is newer. Fix!!!!\n//\n//----------------------------------------------------------------------\n\nvoid draw_gl_axes_old(int n, double r, double radius, double rim, double l)\n{\n  // int n=10;\n  // double r=0.7;\n  // double radius=0.01, rim=0.04, l=0.1;\n  \n  const double vertex_red=1.0, vertex_green=1.0, vertex_blue=1.0;\n  \n  glColor3f(vertex_red, vertex_green, vertex_blue);\n  \n  draw_cylinder(0.0, 0.0, -r, 0.0, 0.0, r, radius, radius, n);\n  draw_cylinder(0.0, 0.0, r-0.1, 0.0, 0.0, r+0.3, rim, 0.0, n);\n  draw_cylinder(-0.5*l, l, r+0.3, 0.5*l, l, r+0.3,\n\t\tradius, radius, n);\n  draw_cylinder(-0.5*l, l*2.0, r+0.3, 0.5*l, l*2.0, r+0.3,\n\t\tradius, radius, n);\n  draw_cylinder(-0.5*l, l, r+0.3, 0.5*l, l*2.0, r+0.3,\n\t\tradius, radius, n);\n  \n  draw_cylinder(-r, 0.0, 0.0, r, 0.0, 0.0, radius, radius, n);\n  draw_cylinder(r-0.1, 0.0, 0.0, r+0.3, 0.0, 0.0, rim, 0.0, n);\n  draw_cylinder(r+0.3, l, 0.5*l, r+0.3, 2*l, -0.5*l,\n\t\tradius, radius, n);\n  draw_cylinder(r+0.3, l, -0.5*l, r+0.3, 2*l, 0.5*l,\n\t\tradius, radius, n);\n  \n  draw_cylinder(0.0, -r, 0.0, 0.0, r, 0.0, radius, radius, n);\n  draw_cylinder(0.0, r-0.1, 0.0, 0.0, r+0.3, 0.0, rim, 0.0, n);\n  draw_cylinder(0.0, r+0.3, 2.0*l, 0.0, r+0.3, 1.5*l,\n\t\tradius, radius, n);\n  draw_cylinder(0.0, r+0.3, 1.5*l, -0.5*l, r+0.3, l,\n\t\tradius, radius, n);\n  draw_cylinder(0.0, r+0.3, 1.5*l, 0.5*l, r+0.3, l,\n\t\tradius, radius, n);\n  \n  glColor3f(1.0, 1.0, 1.0);\n}\n\n\n\n\n\n\n//----------------------------------------------------------------------\n//\n// Draw gridlines to visualize cells.\n//\n//----------------------------------------------------------------------\n\nvoid draw_grid(const int n1, const int n2, const int n3)\n{\n  int i, j, k;\n  \n  glBegin(GL_LINES);\n  for (i=0; i<n1; i++)\n    for (j=0; j<n2; j++)\n      {\n\tconst double x=2.0*(i/(n1-1.0)-0.5);\n\tconst double y=2.0*(j/(n2-1.0)-0.5);\n\n\tglColor3f(  1.0, 0.0,  0.0);\n\tglVertex3f(   x,   y, -1.0);\n\tglColor3f(  1.0, 0.0,  0.0);\n\tglVertex3f(   x,   y,  1.0);\n      }\n  for (j=0; j<n2; j++)\n    for (k=0; k<n3; k++)\n      {\n\tconst double y=2.0*(j/(n2-1.0)-0.5);\n\tconst double z=2.0*(k/(n3-1.0)-0.5);\n\n\tglColor3f(  0.0, 1.0, 0.0);\n\tglVertex3f(-1.0,   y,   z);\n\tglColor3f(  0.0, 1.0, 0.0);\n\tglVertex3f( 1.0,   y,   z);\n      }\n  for (k=0; k<n3; k++)\n    for (i=0; i<n1; i++)\n      {\n\tconst double z=2.0*(k/(n3-1.0)-0.5);\n\tconst double x=2.0*(i/(n1-1.0)-0.5);\n\n\tglColor3f(  0.0,  0.0, 1.0);\n\tglVertex3f(   x, -1.0,   z);\n\tglColor3f(  0.0,  0.0, 1.0);\n\tglVertex3f(   x,  1.0,   z);\n      }\n  glEnd();\n}\n\n\n\n\n\n\n//\n// 020505: Adding transparent planes.\n//\n\nvoid draw_grid_planes(const int n1, const int n2, const int n3)\n{\n  int i, j, k;\n  \n  glDisable(GL_LIGHTING); // must be turned on by the caller...\n\n  glBlendFunc(GL_ONE, GL_ONE);\n  glEnable(GL_BLEND);\n  glDisable(GL_DEPTH_TEST);\n  glBegin(GL_QUADS);\n  for (k=0; k<n3; k++)\n    {\n      const double z=2.0*(k/(n3-1.0)-0.5);\n      \n      glColor3f(  0.0,  0.0, 0.2);\n      glVertex3f(-1.0, -1.0,   z);\n      glVertex3f( 1.0, -1.0,   z);\n      glVertex3f( 1.0,  1.0,   z);\n      glVertex3f(-1.0,  1.0,   z);\n    }\n  for (j=0; j<n2; j++)\n    {\n      const double y=2.0*(j/(n2-1.0)-0.5);\n      \n      glColor3f(  0.0,  0.2,  0.0);\n      glVertex3f(-1.0,    y, -1.0);\n      glVertex3f( 1.0,    y, -1.0);\n      glVertex3f( 1.0,    y,  1.0);\n      glVertex3f(-1.0,    y,  1.0);\n    }\n  for (i=0; i<n1; i++)\n    {\n      const double x=2.0*(i/(n1-1.0)-0.5);\n      \n      glColor3f(  0.2,  0.0,  0.0);\n      glVertex3f(   x, -1.0, -1.0);\n      glVertex3f(   x,  1.0, -1.0);\n      glVertex3f(   x,  1.0,  1.0);\n      glVertex3f(   x, -1.0,  1.0);\n    }\n  glEnd();\n  glEnable(GL_DEPTH_TEST);\n  glDisable(GL_BLEND);\n}\n\n\n\n\n\n\n//----------------------------------------------------------------------\n//\n// Initializing glut and gl.\n//\n//----------------------------------------------------------------------\n\nvoid gl_init(int argc, char *argv[],\n\t     const int xs, const int ys,\n\t     const int x0, const int y0,\n\t     const int doubleBuffer,\n\t     const int two_sided,\n\t     const int lighting,\n\t     const int normalize,\n\t     const int smooth,\n\t     const double xtrans,\n\t     const double ytrans,\n\t     const double ztrans,\n\t     const double xscale,\n\t     const double yscale,\n\t     const double zscale,\n\t     int &tx,\n\t     int &ty,\n\t     const int texture_mode,\n\t     const char * const texfile /* =NULL */)\n{\n  int i;\n  const int use_accum=0;\n  \n  //\n  // 020430: NB! Note that the really confusing name 'GLUT_RGBA' hides the\n  //         fact that this setting does not induce an alpha buffer being set\n  //         up! One must in fact specify GLUT_ALPHA explicitly!\n  //         (But I'm not sure how important this is... Perhaps this alpha is\n  //         not actually needed for the *window* for OpenGL for instance to\n  //         be able to do alpha blending?!)\n  // 020501: Seems that we get accum buffer even without specifying it?!\n  // 020502: GLUT_ALPHA seems not to be available on smaug.\n  //         But we don't actually need it for alpha-blending, anyway. For\n  //         that we only need alpha for the textures.\n  //         Ok, it's there when we go to 24 bpp mode in X.\n  //\n#ifndef QTMODE\n  glutInitDisplayMode(GLUT_RGBA | // GLUT_ALPHA | \n\t\t      (use_accum ? GLUT_ACCUM : 0) |\n\t\t      ((doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE) |\n\t\t      GLUT_DEPTH);\n  glutInitWindowSize(xs, ys);\n  glutInitWindowPosition(x0, y0);\n  glutInit(&argc, argv);\n  glutCreateWindow(argv[0]);\n#endif\n\n  glClearColor(0.0, 0.0, 0.0, 0.0);\n  if (use_accum)\n    glClearAccum(0.0, 0.0, 0.0, 0.0);\n  if (smooth)\n    glShadeModel(GL_SMOOTH);\n  else\n    glShadeModel(GL_FLAT);\n  glEnable(GL_DEPTH_TEST);\n  glDepthFunc(GL_LESS);\t\t\t/* GL_LESS is default. */\n/*  glDepthRange(100.0, -100.0);*/\t/* What is default value? */\n/*  glClearDepth(0.0); */\t\t/* What is default value? */\n\n  /* Initialize materials */\n\n  {\n    static float ambient[] = {0.1, 0.1, 0.1, 1.0};\n    static float diffuse[] = {0.4, 0.4, 0.4, 1.0};\n\n    static float position0[] = { 5.0, 5.0, 200.0, 0.0};\n    static float position1[] = {-5.0, -5.0, 200.0, 0.0};\n\n    static float front_mat_shininess[] = {50.0};\n    // static float front_mat_specular[] = {0.9, 0.9, 0.9, 1.0};\n    static float front_mat_specular[] = {0.0, 0.0, 0.0, 1.0};\n    static float front_mat_diffuse[] = {0.7, 0.7, 0.7, 1.0};\n    // static float front_mat_diffuse[] = {0, 0, 0, 1.0};\n    static float front_mat_ambient[] = {0.3, 0.3, 0.3, 1.0};\n    static float front_mat_emission[] = {0.3, 0.0, 0.0, 1.0};\n\n    static float back_mat_shininess[] = {128.0};\n    // static float back_mat_specular[] = {0.4, 0.4, 0.4, 1.0};\n    static float back_mat_specular[] = {0.0, 0.0, 0.0, 1.0};\n    static float back_mat_diffuse[] = {0.7, 0.7, 0.7, 1.0};\n    static float back_mat_ambient[] = {0.3, 0.3, 0.3, 1.0};\n    static float back_mat_emission[] = {0.0, 0.3, 0.0, 1.0};\n  \n    static float lmodel_ambient[] = {1.0, 1.0, 1.0, 1.0};\n    static float lmodel_twoside[] = {GL_TRUE};\n\n    if (two_sided)\n      lmodel_twoside[0]=GL_TRUE;\n    else\n      lmodel_twoside[0]=GL_FALSE;\n    \n    glLightfv(GL_LIGHT0, GL_AMBIENT, ambient);\n    glLightfv(GL_LIGHT0, GL_DIFFUSE, diffuse);\n    glLightfv(GL_LIGHT0, GL_POSITION, position0);\n    \n    glLightfv(GL_LIGHT1, GL_AMBIENT, ambient);\n    glLightfv(GL_LIGHT1, GL_DIFFUSE, diffuse);\n    glLightfv(GL_LIGHT1, GL_POSITION, position1);\n\n    glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lmodel_ambient);\n    glLightModelfv(GL_LIGHT_MODEL_TWO_SIDE, lmodel_twoside);\n\n    // glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);\n\n    glMaterialfv(GL_FRONT, GL_SHININESS, front_mat_shininess);\n    glMaterialfv(GL_FRONT, GL_SPECULAR,  front_mat_specular);\n    glMaterialfv(GL_FRONT, GL_DIFFUSE,   front_mat_diffuse);\n    glMaterialfv(GL_FRONT, GL_AMBIENT,   front_mat_ambient);\n    glMaterialfv(GL_FRONT, GL_EMISSION,  front_mat_emission);\n\n    glMaterialfv(GL_BACK, GL_SHININESS, back_mat_shininess);\n    glMaterialfv(GL_BACK, GL_SPECULAR,  back_mat_specular);\n    glMaterialfv(GL_BACK, GL_DIFFUSE,   back_mat_diffuse);\n    glMaterialfv(GL_BACK, GL_AMBIENT,   back_mat_ambient);\n    glMaterialfv(GL_BACK, GL_EMISSION,  back_mat_emission);\n\n    glEnable(GL_LIGHT0);\n    glEnable(GL_LIGHT1); \n    if (lighting)\n      glEnable(GL_LIGHTING);\n    else\n      glDisable(GL_LIGHTING);\n    if (normalize)\n      glEnable(GL_NORMALIZE);\n    else\n      glDisable(GL_NORMALIZE);\n  }\n  \n  glMatrixMode(GL_PROJECTION);\n  glLoadIdentity();\n/*  glFrustum( -1.0, 1.0, -1.0, 1.0, 5, 25 ); */\n/*  glFrustum( -1.0, 1.0, -1.0, 1.0, 2, 4 ); */\n/*  glFrustum( -1.0, 1.0, -1.0, 1.0, 100, 102 ); */\n/*  glFrustum( -1.0, 1.0, -1.0, 1.0, 5, 7 );*/\n  /*\n    Note that the far clipping plane distance doesn't influence on\n    the projection, but that the distance between near and far should be\n    as close to one as possible to best utilise the z-buffer. Or something\n    like this...\n  */\n  //\n  // 000304: Was near=5, near clipping plane to far from viewer.\n  //         6-0.5*sqrt(3) should make a 1x1x1 cube never intersect the near\n  //         plane regardless of rotation... Making it even closer will\n  //         make it possible to expand things more before being clipped...\n  //\n  //glFrustum(-1.0, 1.0, -1.0, 1.0, 6-0.5*sqrt(3), 20);\n  \n  //\n  // 020214: This one seems to be rather good, we can zoom in quite a lot\n  //         without stuff hitting the near clipping plane.\n  //\n  glFrustum(-1.0, 1.0, -1.0, 1.0, 3, 20); // cmt out 020201\n\n  // 020410 experimenting\n  glLoadIdentity();\n  glFrustum(-1.0, 1.0, -1.0, 1.0, 3, 20);\n\n  //\n  // 020214: The next one let's us see inside more easily, because the near\n  //         clipping plane is further away from us.\n  //\n  //glFrustum(-1.0, 1.0, -1.0, 1.0, 5, 20);\n\n  //\n  // 021206: Trying to get the near clipping plane closer to us.\n  //         I've lost track of the actual numbers here...\n  //         Should be dealt with...\n  //\n  glLoadIdentity();\n  glFrustum(-1.0, 1.0, -1.0, 1.0, 2.0, 20);\n\n  //\n  // 020627: Trying to reduce the \"perspective\" effect.\n  //\n  //glFrustum(-1.0, 1.0, -1.0, 1.0, 5+100, 20+100);\n  \n  glMatrixMode(GL_MODELVIEW);\n  glLoadIdentity();\n/*  glTranslated( 0.0, 0.0, -6.0 ); */\n/*  glTranslated( 0.0, 0.0, -3.0 ); */\n/*  glTranslated( 0.0, 0.0, -101.0 ); */\n  glTranslated(xtrans, ytrans, ztrans);\n  glScaled(xscale, yscale, zscale);\n\n  /*\n    Why did I do this? To clear both buffers? Is this necessary here?\n  */\n  for (i=0; i<2; i++)\n    {\n      glDrawBuffer(GL_BACK);\n      glReadBuffer(GL_BACK);\n      glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);\n      glClear(GL_COLOR_BUFFER_BIT | (use_accum ? GL_ACCUM_BUFFER_BIT : 0));\n#ifndef QTMODE\n      glutSwapBuffers();\n#endif\n    }\n\n  //\n  // Note that after the texture has been inserted into the GL engine, it\n  // is lost/deallocated from the application.\n  // (But (for some reason) the size is returned...)\n  //\n  unsigned char *texture=NULL;\n  if (texfile==NULL)\n    {\n      if (tx!=ty)\n\tCRIT_ERR(printf(\"tx=%d, ty=%d, not implemented.\\n\", tx, ty));\n      \n      if ((texture=new unsigned char[3*SQR(tx)])==NULL)\n\tCRIT_ERR(puts(\"Couldn't allocate space for texture.\"));\n      \n      int i;\n      const unsigned char a=255, b=0;\n      \n      for (i=0; i<3*SQR(tx); i++)\n\ttexture[i]=a;\n      for (i=0; i<tx; i++)\n\t{\n\t  texture[3*(i*tx+0)+0]=b;\n\t  texture[3*(i*tx+0)+1]=b;\n\t  texture[3*(i*tx+0)+2]=b;\n\t  texture[3*(i*tx+(tx-1))+0]=b;\n\t  texture[3*(i*tx+(tx-1))+1]=b;\n\t  texture[3*(i*tx+(tx-1))+2]=b;\n\t  texture[3*(0*tx+i)+0]=b;\n\t  texture[3*(0*tx+i)+1]=b;\n\t  texture[3*(0*tx+i)+2]=b;\n\t  texture[3*((tx-1)*tx+i)+0]=b;\n\t  texture[3*((tx-1)*tx+i)+1]=b;\n\t  texture[3*((tx-1)*tx+i)+2]=b;\n\t}\n    }\n  else\n    //\n    // Read texture from file...\n    //\n    {\n      puts(\"texture code not compiled in!\");\n      exit(0);\n#if 0\n      unsigned char *texture_tmp=read_ppm_file(texfile, &tx, &ty);\n      puts(\"Leste pgm-fil.\");\n      if (tx!=ty)\n\tCRIT_ERR(puts(\"Not implemented.\"));\n      if ((tx!=1) && (tx!=2) && (tx!=4) && (tx!=8) && (tx!=16) && (tx!=32) && \n\t  (tx!=64) && (tx!=128) && (tx!=256) && (tx!=512) && (tx!=1024) &&\n\t  (tx!=2048) && (tx!=4096))\n\tCRIT_ERR(puts(\"Texture size not ok.\"));\n\n      printf(\"Texture size is %dx%d.\\n\", tx, ty);\n      \n      if ((texture=new unsigned char[3*SQR(tx)])==NULL)\n\tCRIT_ERR(puts(\"Couldn't allocate space for texture.\"));\n\n      int i;\n     \n      for (i=0; i<SQR(tx); i++)\n\t{\n\t  texture[3*i+0]=texture_tmp[i];\n\t  texture[3*i+1]=texture_tmp[i];\n\t  texture[3*i+2]=texture_tmp[i];\n\t  // printf(\"%5d - %3d %3d %3d\\n\", i,\n\t  // texture[i+0], texture[i+1], texture[i+2]);\n\t}\n\n      delete texture_tmp;\n#endif\n    }\n  \n  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, tx, ty,\n\t       0, GL_RGB, GL_UNSIGNED_BYTE, texture);\n  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, texture_mode);\n  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);\n  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);\n  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);\n  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);\n  \n  delete texture;\n\n  //glPolygonOffset(0.0, 20.0);\n  //\n  // 020430: PolygonOffset(factor, units) produces an offset o, where\n  //         o = max depth slope * factor + impl. dep. const. r * units.\n  //         0.0, 20.0 worked just perfect for GeForce 2 and  Matrox Mystique,\n  //         but not for GeForce 3.\n  //         Perhaps it was strange that it worked? Or maybe it enough now\n  //         just use a factor slightly greater than 0.0?\n  //         A good idea would perhaps be to make a tool to adjust these\n  //         empirically during runtime?!\n  //         Seems that it is not enough to just increase factor slightly,\n  //         perhaps the GF3 has another definition for 'units'? Increasing\n  //         it somewhat seems to make the problem go away...\n  //         Don't want to increase it too much though.\n  //         Perhaps a way to do this: Increase the 'factor' until very\n  //         slanted surfaces turns out ok, and increase 'units' until\n  //         flat (parallel to near plane) surfaces are ok?! Will do it\n  //         like this but opposite order.\n  //         Hmm!!! (1.0, 1.0) seems to be just fine!\n  // \n  glPolygonOffset(1.0, 1.0);\n  glEnable(GL_POLYGON_OFFSET_POINT);\n  glEnable(GL_POLYGON_OFFSET_LINE);\n  glEnable(GL_POLYGON_OFFSET_FILL);\n\n}\n\n\n\n\n\n\nvoid transpose_matrix(double * const d)\n{\n  int i, j;\n  \n  for (i=0; i<4; i++)\n    for (j=0; j<i; j++)\n      {\n\tdouble tmp=d[i*4+j];\n\td[i*4+j]=d[j*4+i];\n\td[j*4+i]=tmp;\n      }\n}\n\n\n\n\n\n\nvoid print_gl_matrix(const int m)\n{\n  int i;\n  double p[16], p2[16];\n  \n  switch (m)\n    {\n    case GL_PROJECTION_MATRIX:\n\n    case GL_MODELVIEW_MATRIX:\n      glGetDoublev((GLenum)m, p);\n      break;\n\n#if 0\n    case GL_MODELVIEW_MATRIX + GL_PROJECTION_MATRIX:\n      glMatrixMode(GL_MODELVIEW);\n      glPushMatrix();\n      glGetDoublev(GL_PROJECTION_MATRIX, p);\n      glMultMatrixd(p);\n      glGetDoublev(GL_MODELVIEW_MATRIX, p);\n      glPopMatrix();\n      break;\n#endif\n\n    case GL_MODELVIEW_MATRIX + GL_PROJECTION_MATRIX:\n      glMatrixMode(GL_MODELVIEW);\n      glGetDoublev(GL_MODELVIEW_MATRIX, p2);\n      glPushMatrix();\n      glLoadIdentity();\n      glGetDoublev(GL_PROJECTION_MATRIX, p);\n      glMultMatrixd(p);\n      glMultMatrixd(p2);\n      glGetDoublev(GL_MODELVIEW_MATRIX, p);\n      glPopMatrix();\n      break;\n    }\n\n  //\n  // 000320: BUG was here! GL uses column-order...\n  //\n  transpose_matrix(p);\n  \n  printf(\"{\");\n  for (i=0; i<15; )\n    {\n      printf(\"%g, \", p[i]);\n      i++;\n      if (i%4==0)\n\tprintf(\"\\n\");\n    }\n  printf(\"%g}\\n\\n\", p[15]);\n\n  printf(\"For Mathematica:\\n\\n\");\n  printf(\"{\");\n  for (i=0; i<15; )\n    {\n      if (i%4==0)\n\tprintf(\"{\");\n      printf(\"%f\", p[i]);\n      i++;\n      if (i%4==0)\n\tprintf(\"}, \");\n      else\n\tprintf(\", \");\n    }\n  printf(\"%f}}\\n\\n\", p[15]);\n \n\n}\n\n\n\n\n\n\n\n//----------------------------------------------------------------------\n//\n// This callback is called when the window is reshaped.\n//\n//----------------------------------------------------------------------\n\nvoid reshape_window(int width, int height)\n{\n  glViewport(0, 0, (GLint)width, (GLint)height);\n/*\n  glutPostRedisplay();\n*/\n}\n\n\n\n\n\n\n//----------------------------------------------------------------------\n//\n// Writing and reading the GL transformation matrices to and from\n// files.\n//\n//----------------------------------------------------------------------\n\nvoid write_gl_matrices(FILE *f)\n{\n  int i, current_mode;\n  double p[16];\n  \n  glGetIntegerv(GL_MATRIX_MODE, &current_mode);\n\n  fprintf(f, \"GL_PROJECTION_MATRIX\\n\");\n  glGetDoublev(GL_PROJECTION_MATRIX, p);\n  for (i=0; i<16; i++)\n    fprintf(f, \"%.15e\\n\", p[i]);\n\n  fprintf(f, \"GL_MODELVIEW_MATRIX\\n\");\n  glGetDoublev(GL_MODELVIEW_MATRIX, p);\n  for (i=0; i<16; i++)\n    fprintf(f, \"%.15e\\n\", p[i]);\n\n  glMatrixMode(current_mode);\n}\n\nvoid read_gl_matrices(FILE *f)\n{\n  int i, current_mode;\n  double p[16];\n  char s[1000];\n  \n  glGetIntegerv(GL_MATRIX_MODE, &current_mode);\n\n  fgets(s, 1000, f);\n  if (strcmp(s, \"GL_PROJECTION_MATRIX\\n\")!=0)\n    CRIT_ERR(printf(\"Corrupt file contents? Read '%s'.\\n\", s));\n  for (i=0; i<16; i++)\n    fscanf(f, \"%lf\\n\", p+i);\n  glMatrixMode(GL_PROJECTION_MATRIX);\n  glLoadMatrixd(p);\n\n  fgets(s, 1000, f);\n  if (strcmp(s, \"GL_MODELVIEW_MATRIX\\n\")!=0)\n    CRIT_ERR(printf(\"Corrupt file contents? Read '%s'.\\n\", s));\n  for (i=0; i<16; i++)\n    fscanf(f, \"%lf\\n\", p+i);\n  glMatrixMode(GL_MODELVIEW_MATRIX);\n  glLoadMatrixd(p);\n\n  glMatrixMode(current_mode);\n}\n"
  },
  {
    "path": "viewer/src/glutils.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#ifdef _MSC_VER\n#  include <io.h>\n#else\n#  include <unistd.h>\n#endif\n\n#include <fcntl.h>\n#include <stdlib.h>\n#include <stdio.h>\n\n#include \"glutils.h\"\n\n#ifndef M_PI\n#define M_PI 3.1415926535897932384\n#endif\n\n\n\n\n\nvoid assert_gl_m(int line, char *file, const bool do_exit /* =true */ )\n{\n  int tmp=glGetError(), known_error=1;\n\n  if (tmp==GL_NO_ERROR)\n    return;\n  \n  while (tmp!=GL_NO_ERROR)\n    {\n      printf(\"'glGetError' returned %d \", tmp);\n      switch (tmp)\n\t{\n\tcase GL_NO_ERROR:\n\t  printf(\"(GL_NO_ERROR) \");\n\t  break;\n\tcase GL_INVALID_ENUM:\n\t  printf(\"(GL_INVALID_ENUM) \");\n\t  break;\n\tcase GL_INVALID_VALUE:\n\t  printf(\"(GL_INVALID_VALUE) \");\n\t  break;\n\tcase GL_INVALID_OPERATION:\n\t  printf(\"(GL_INVALID_OPERATION) \");\n\t  break;\n\tcase GL_STACK_OVERFLOW:\n\t  printf(\"(GL_STACK_OVERFLOW) \");\n\t  break;\n\tcase GL_STACK_UNDERFLOW:\n\t  printf(\"(GL_STACK_UNDERFLOW) \");\n\t  break;\n\tcase GL_OUT_OF_MEMORY:\n\t  printf(\"(GL_OUT_OF_MEMORY) \");\n\t  break;\n\tdefault:\n\t  known_error=0;\n\t  printf(\"(UNKNOWN ERROR(?!)) \");\n\t}\n      if (file!=NULL)\n\tprintf(\" at line %d in file '%s'.\\n\", line, file);\n      \n      if (known_error)\n\t{\n\t  printf(\"The man page has this to say about this error:\\n\\n\");\n\t  switch (tmp)\n\t    {\n\t    case GL_INVALID_ENUM:\n\t      printf(\"An unacceptable value is\\n\");\n\t      printf(\"specified for an enumerated\\n\");\n\t      printf(\"argument.  The offending\\n\");\n\t      printf(\"command is ignored, and has no\\n\");\n\t      printf(\"other side effect than to set\\n\");\n\t      printf(\"the error flag.\\n\");\n\t      break;\n\t    case GL_INVALID_VALUE:\n\t      printf(\"A numeric argument is out of\\n\");\n\t      printf(\"range.  The offending command\\n\");\n\t      printf(\"is ignored, and has no other\\n\");\n\t      printf(\"side effect than to set the\\n\");\n\t      printf(\"error flag.\\n\");\n\t      break;\n\t    case GL_INVALID_OPERATION:\n\t      printf(\"The specified operation is not\\n\");\n\t      printf(\"allowed in the current state.\\n\");\n\t      printf(\"The offending command is\\n\");\n\t      printf(\"ignored, and has no other side\\n\");\n\t      printf(\"effect than to set the error\\n\");\n\t      printf(\"flag.\\n\");\n\t      break;\n\t    case GL_STACK_OVERFLOW:\n\t      printf(\"This command would cause a\\n\");\n\t      printf(\"stack overflow.  The offending\\n\");\n\t      printf(\"command is ignored, and has no\\n\");\n\t      printf(\"other side effect than to set\\n\");\n\t      printf(\"the error flag.\\n\");\n\t      break;\n\t    case GL_STACK_UNDERFLOW:\n\t      printf(\"This command would cause a\\n\");\n\t      printf(\"stack underflow.  The\\n\");\n\t      printf(\"offending command is ignored,\\n\");\n\t      printf(\"and has no other side effect\\n\");\n\t      printf(\"than to set the error flag.\\n\");\n\t      break;\n\t    case GL_OUT_OF_MEMORY:\n\t      printf(\"There is not enough memory\\n\");\n\t      printf(\"left to execute the command.\\n\");\n\t      printf(\"The state of the GL is\\n\");\n\t      printf(\"undefined, except for the\\n\");\n\t      printf(\"state of the error flags,\\n\");\n\t      printf(\"after this error is recorded.\\n\");\n\t      break;\n\t    }\n\t}\n      tmp=glGetError();\n    }\n  \n  if (do_exit)\n    exit(-1);\n  else\n    puts(\"\\n\\n\\nOpenGL error!!!! \\n\\n\\n\");\n}\n\n\n\n\n\n\nvoid assert_gl_dummy_and_empty(void)\n{\n  return;\n}\n\n\n\n\n\n\n#ifndef _MSC_VER\n\n//----------------------------------------------------------------------\n//\n// 040229: A small routine to list out the properties of a list of\n//         GLXFBConfigs. (There *may* be properties not listed, I don't\n//         remember exactly how complete this list is...)\n//\n//----------------------------------------------------------------------\n\nvoid list_FBConfigs(GLXFBConfig *config, int nelements)\n{\n  int attr_list[]=\n    {\n      GLX_FBCONFIG_ID,\n      GLX_VISUAL_ID ,\n      GLX_BUFFER_SIZE,\n      GLX_LEVEL \t,\n      GLX_DOUBLEBUFFER \t,\n      GLX_STEREO \t,\n      GLX_AUX_BUFFERS \t,\n      GLX_RENDER_TYPE \t,\n      GLX_RED_SIZE \t,\n      GLX_GREEN_SIZE \t,\n      GLX_BLUE_SIZE \t,\n      GLX_ALPHA_SIZE \t,\n      GLX_DEPTH_SIZE \t,\n      GLX_STENCIL_SIZE \t,\n      GLX_ACCUM_RED_SIZE \t,\n      GLX_ACCUM_GREEN_SIZE \t,\n      GLX_ACCUM_BLUE_SIZE \t,\n      GLX_ACCUM_ALPHA_SIZE \t,\n      GLX_DRAWABLE_TYPE \t,\n      GLX_X_RENDERABLE \t,\n      GLX_X_VISUAL_TYPE ,\n      GLX_CONFIG_CAVEAT ,\n      GLX_TRANSPARENT_TYPE,\n      GLX_TRANSPARENT_INDEX_VALUE \t,\n      GLX_TRANSPARENT_RED_VALUE \t,\n      GLX_TRANSPARENT_GREEN_VALUE \t,\n      GLX_TRANSPARENT_BLUE_VALUE \t,\n      GLX_TRANSPARENT_ALPHA_VALUE \t,\n      GLX_MAX_PBUFFER_WIDTH \t,\n      GLX_MAX_PBUFFER_HEIGHT \t,\n      GLX_MAX_PBUFFER_PIXELS\n    };\n  char *attr_name[]=\n    {\n     \"GLX_FBCONFIG_ID\",\n     \"GLX_VISUAL_ID\",\n     \"GLX_BUFFER_SIZE\",\n     \"GLX_LEVEL\",\n     \"GLX_DOUBLEBUFFER\",\n     \"GLX_STEREO\",\n     \"GLX_AUX_BUFFERS\",\n     \"GLX_RENDER_TYPE\",\n     \"GLX_RED_SIZE\",\n     \"GLX_GREEN_SIZE\",\n     \"GLX_BLUE_SIZE\",\n     \"GLX_ALPHA_SIZE\",\n     \"GLX_DEPTH_SIZE\",\n     \"GLX_STENCIL_SIZE\",\n     \"GLX_ACCUM_RED_SIZE\",\n     \"GLX_ACCUM_GREEN_SIZE\",\n     \"GLX_ACCUM_BLUE_SIZE\",\n     \"GLX_ACCUM_ALPHA_SIZE\",\n     \"GLX_DRAWABLE_TYPE\",\n     \"GLX_X_RENDERABLE\",\n     \"GLX_X_VISUAL_TYPE\",\n     \"GLX_CONFIG_CAVEAT\",\n     \"GLX_TRANSPARENT_TYPE\",\n     \"GLX_TRANSPARENT_INDEX_VALUE\",\n     \"GLX_TRANSPARENT_RED_VALUE\",\n     \"GLX_TRANSPARENT_GREEN_VALUE\",\n     \"GLX_TRANSPARENT_BLUE_VALUE\",\n     \"GLX_TRANSPARENT_ALPHA_VALUE\",\n     \"GLX_MAX_PBUFFER_WIDTH\",\n     \"GLX_MAX_PBUFFER_HEIGHT\",\n     \"GLX_MAX_PBUFFER_PIXELS\"\n    };\n#if 0\n  char *attr_str[]=\n    {\n      \"This attribute is the XID of the GLX FBConfig.\",\n      \"This attribute is the XID of the X Visual associated with the GLX FBConfig.\",\n      \"This attribute defines the number of bits per color buffer. For GLX FBConfigs that correspond to a PseudoColor or StaticColor visual, this is equal to the depth value reported in the X11 visual. For GLX FBConfigs that correspond to TrueColor or DirectColor visual, this is the sum of GLX_RED_SIZE, GLX_GREEN_SIZE, GLX_BLUE_SIZE, and GLX_ALPHA_SIZE.\",\n      \"This attribute defines the frame buffer level of the visual. Level 0 is the default frame buffer. Positive levels correspond to frame buffers that overlay the default buffer; negative levels correspond to frame buffers that underlay the default buffer.\",\n      \"This attribute is True if color buffers exist in front/back pairs that can be swapped. Otherwise, it is False.\",\n      \"This attribute is True if color buffers exist in left/right pairs. Otherwise, it is False.\",\n      \"This attribute defines the number of auxiliary color buffers available. Zero indicates that no auxiliary color buffers exist.\",\n      \"This attribute indicates what type of GLX Context a drawable created with the corresponding GLX FBConfig can be bound to. The following bit settings can exist:\",\n      \"This attribute defines the number of red bits stored in each color buffer. If the GLX_RGBA_BIT is not set in the GLX_RENDER_TYPE attribute, the GLX_RED_SIZE attribute is undefined.\",\n      \"This attribute defines the number of green bits stored in each color buffer. If the GLX_RGBA_BIT is not set in the GLX_RENDER_TYPE attribute, the GLX_GREEN_SIZE attribute is undefined.\",\n      \"This attribute defines the number of blue bits stored in each color buffer. If the GLX_RGBA_BIT is not set in the GLX_RENDER_TYPE attribute, the GLX_BLUE_SIZE attribute is undefined.\",\n      \"This attribute defines the number of alpha bits stored in each color buffer. If the GLX_RGBA_BIT is not set in the GLX_RENDER_TYPE attribute, the GLX_ALPHA_SIZE attribute is undefined.\",\n      \"This attribute defines the number of bits in the depth buffer.\",\n      \"This attribute defines the number of bits in the stencil buffer.\",\n      \"This attribute defines the number of red bits stored in the accumulation buffer.\",\n      \"This attribute defines the number of green bits stored in the accumulation buffer.\",\n      \"This attribute defines the number of blue bits stored in the accumulation buffer.\",\n      \"This attribute defines the number of alpha bits stored in the accumulation buffer.\",\n      \"This attribute defines which GLX drawables are supported by the GLX FBConfig. The following bit settings can exist:\",\n      \"This attribute indicates whether X can be used to render into a drawable created with the GLX FBConfig. This attribute is True is the GLX FBConfig supports GLX windows and/or pixmaps, otherwise it is False.\",\n      \"This attribute defines the X visual type of the X visual associated with the GLX FBConfig. It can have one of the following values:\",\n      \"This attribute defines any problems that the GLX FBConfig may have:\",\n      \"This attribute defines the type of transparency (if any) supported by the FBConfig. It can have the following values:\",\n      \"This attribute defines the index value of the transparent pixel when the transparency type is GLX_TRANSPARENT_INDEX.\",\n      \"This attribute defines the red value of the transparent pixel when the transparency type is GLX_TRANSPARENT_RGB.\",\n      \"This attribute defines the green value of the transparent pixel when the transparency type is GLX_TRANSPARENT_RGB\",\n      \"This attribute defines the blue value of the transparent pixel when the transparency type is GLX_TRANSPARENT_RGB.\",\n      \"This attribute defines the alpha value of the transparent pixel when the transparency type is GLX_TRANSPARENT_RGB.\",\n      \"This attribute defines the maximum width value that can be passed into glXCreatePbuffer.\",\n      \"This attribute defines the maximum height value that can be passed into glXCreatePbuffer.\",\n      \"This attribute defines the maximum number of pixels (width times height) for a GLX Pbuffer. It can have a value that is less than the maximum width times the maximum height. Also, the value is static and assumes that no other pbuffers or X resources are contending for the framebuffer memory. Therefore, it may not be possible to allocate a pbuffer of the size given by this attribute.\"\n    };\n#endif\n  int i, j;\n  Display *dpy=glXGetCurrentDisplay();\n  \n  for (i=0; i<nelements; i++)\n    {\n      printf(\"FBConfig %d:\\n\", i);\n      for (j=0; j<31; j++)\n\t{\n\t  int val;\n\t  int tmp=glXGetFBConfigAttrib(dpy, config[i], attr_list[j], &val);\n\t  printf(\"  %2d, %5d = %s: %d, tmp=%d\\n\",\n\t\t j, attr_list[j], attr_name[j], val, tmp);\n\t}\n    }\n\n}\n\n#endif // of if not microsoft\n\n\n\n\n\n\n//======================================================================\n//\n// 050123: Moving this out of sfviewer1b, for re-use.\n//\n//         There are a set of spheres stored here, indexed by 'slot',\n//         starting from 1 and onwards.\n//         If 'slot' > existing number of spheres, a new one is \n//         tesselated and stored, then drawn.\n//\n//======================================================================\n\nvoid draw_sphere(const vector3t<float> &pos, const float r,\n\t\t const int n, const int slot,\n\t\t const vector3t<float> &col,\n\t\t const bool wiremode)\n{\n//  const int n=20; // gir 1520 triangler\n//  const int n=15; // gir 840 triangler\n//  const int n=29; // 3248 triangler, max som passer i grafikkortet?!\n//  const int n=10; // gir 360 triangler\n  //const int n=25;\n//  const int n=4;\n  \n  static vector< vector< vector3t<float> > > all_vert1, all_norm1;\n  static vector< vector<int> > all_tri;\n\n  if (slot>(int)all_vert1.size())\n    {\n      vector< vector3t<float> > vert1, norm1;\n      vector<int> tri;\n\n      vert1.push_back(pos+vector3t<float>(0, 0, r));\n      vert1.push_back(pos+vector3t<float>(0, 0, -r));\n      norm1.push_back(vector3t<float>(0.0, 0.0, 1.0));\n      norm1.push_back(vector3t<float>(0.0, 0.0, -1.0));\n      \n      int i, j;\n      for (i=1; i<=n; i++)\n\t{\n\t  double ph=(double)i/n*M_PI-M_PI*0.5;\n\t  \n\t  for (j=0; j<2*n; j++)\n\t    {\n\t      double th=(double)j/(2*n)*M_PI*2.0;\n\t      \n\t      // sphere\n\t      double x=cos(th)*cos(ph);\n\t      double y=sin(th)*cos(ph);\n\t      double z=sin(ph);\n\t      if (i<n)\n\t\t{\n\t\t  vert1.push_back(pos+r*vector3t<float>(x, y, z));\n\t\t  norm1.push_back(vector3t<float>(x, y, z));\n\t\t}\n\t      \n\t      \n\t      // shall not make vertices for the top pole, but we need\n\t      // i=n to make the last ring of triangles!\n\t      \n\t      int k=vert1.size()-1;\n\t      if (j>0)\n\t\tif (i==1) {\n\t\t  tri.push_back(1); tri.push_back(k); tri.push_back(k-1);\n\t\t} else {\n\t\t  if (i==n) {\n\t\t    tri.push_back(0); tri.push_back(k-(2*n-1)+j-1);\n\t\t    tri.push_back(k-(2*n-1)+j);\n\t\t  } else {\n\t\t    tri.push_back(k-2*n-1); tri.push_back(k);\n\t\t    tri.push_back(k-1); tri.push_back(k-2*n-1);\n\t\t    tri.push_back(k-2*n); tri.push_back(k);\n\t\t  }\n\t\t}\n\t      else\n\t\tif (i==1) {\n\t\t  tri.push_back(1); tri.push_back(k); tri.push_back(k-1+2*n);\n\t\t} else\n\t\t  if (i==n) {\n\t\t    tri.push_back(0); tri.push_back(k);\n\t\t    tri.push_back(k-(2*n-1));\n\t\t  } else {\n\t\t    tri.push_back(k+2*n-1);\ttri.push_back(k-1);\n\t\t    tri.push_back(k); tri.push_back(k);\n\t\t    tri.push_back(k-1); tri.push_back(k-2*n);\n\t\t  }\n\t    }\n\t}\n      \n      all_vert1.push_back(vert1);\n      all_norm1.push_back(norm1);\n      all_tri.push_back(tri);\n    }\n\n  if (!wiremode)\n    {\n      glBegin(GL_TRIANGLES);\n      glColor3fv(col.raw());\n      int i;\n      for (i=0; i<(int)all_tri[slot-1].size(); i++)\n\t{\n\t  glNormal3fv(all_norm1[slot-1][all_tri[slot-1][i]].raw());\n\t  glVertex3fv(all_vert1[slot-1][all_tri[slot-1][i]].raw());\n\t}\n      glEnd();\n    }\n  else\n    {\n      GLboolean light_temp;\n      glGetBooleanv(GL_LIGHTING, &light_temp);\n      glDisable(GL_LIGHTING);\n      glColor3fv(col.raw());\n      int i;\n      for (i=0; i<(int)all_tri[slot-1].size(); i+=3)\n\t{\n\t  glBegin(GL_LINE_STRIP);\n\t  glVertex3fv(all_vert1[slot-1][all_tri[slot-1][i  ]].raw());\n\t  glVertex3fv(all_vert1[slot-1][all_tri[slot-1][i+1]].raw());\n\t  glVertex3fv(all_vert1[slot-1][all_tri[slot-1][i+2]].raw());\n\t  glVertex3fv(all_vert1[slot-1][all_tri[slot-1][i  ]].raw());\n\t  glEnd();\n\t}\n      if (light_temp)\n\tglEnable(GL_LIGHTING);\n    }\n}\n"
  },
  {
    "path": "viewer/src/mouse.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <stdio.h>\n#define GLUT_DISABLE_ATEXIT_HACK\n#include <GL/glut.h>\n#include <math.h>\n#ifndef _MSC_VER\n#  include <unistd.h>\n#endif\n\n#ifndef PI\n#  define PI 3.1415926536\n#endif\n#include \"mouse.h\"\n#include \"transfutils.h\"\n#include \"aux2.h\"\n\n//\n// All casting to double in calls to sqrt are just because of aCC on tor.\n// Doing this by using temporary variables instead...\n//\n\n\n\n\n\n\n//\n// 990831: These are used for storage of flags, states, old mouse-\n//         positions etc.\n//\nGLboolean allow_zrot=GL_TRUE;\nint last_x=0, last_y=0, last_x0=0, last_y0=0;\nbool mouse_movement=false; // Mouse-movement routines set this.\n\n\n\n\n\n\n//\n// 040326: An attempt to make a \"draw cursor into framebuffer\" subroutine,\n//         in order to get the cursor into movie sequences produced with\n//         'sfviewer1'.\n//\n\nfloat curx=0.0, cury=0.0, curz=0.0;\n\nvoid draw_cursor(int x, int y)\n{\n  GLint viewport[4];\n  GLdouble modelview[16];\n  GLdouble projection[16];\n  GLfloat winX, winY, winZ;\n  GLdouble posX, posY, posZ;\n  \n  glGetDoublev( GL_MODELVIEW_MATRIX, modelview );\n  glGetDoublev( GL_PROJECTION_MATRIX, projection );\n  glGetIntegerv( GL_VIEWPORT, viewport );\n  \n  winX = (float)x;\n  winY = (float)viewport[3] - (float)y;\n  glReadPixels( x, int(winY), 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &winZ );\n  \n  gluUnProject(winX, winY, winZ,\n\t       modelview, projection, viewport, &posX, &posY, &posZ);\n\n  curx=posX;\n  cury=posY;\n  curz=posZ;\n}\n\n\n\n\n\n\nint transversal_rotation(int x, int y, int last_xx, int last_yy)\n{\n  int viewp[4];\n\n  glGetIntegerv(GL_VIEWPORT, viewp);\n  if ((fabs(((x-last_xx)*(x-(viewp[0]+viewp[2])*0.5)+\n\t     (y-last_yy)*(y-(viewp[1]+viewp[3])*0.5))/\n\t    sqrt((double)(SQR(x-last_xx)+SQR(y-last_yy)))/\n\t    sqrt((double)(SQR(x-(viewp[0]+viewp[2])*0.5)+\n\t\t\t  SQR(y-(viewp[1]+viewp[3])*0.5)))) >\n       cos(50.0/180.0*PI)) ||\n      (sqrt((x-(viewp[0]+viewp[2])*0.5)*(x-(viewp[0]+viewp[2])*0.5)+\n\t    (y-(viewp[1]+viewp[3])*0.5)*(y-(viewp[1]+viewp[3])*0.5)) <\n       0.2*sqrt((double)SQR(viewp[2]-viewp[0])+SQR(viewp[3]-viewp[1]))) ||\n      (!allow_zrot))\n    {\n      /* puts(\"radielt\");*/\n      return 0;\n    }\n  else\n    {\n      /* puts(\"transversalt\");*/\n      return 1;\n    }\n  // draw_cursor(x, y);\n}\n\n\n\n\n\n\n//\n// 990831: Would have liked to send other parameters too, but \n//         glut won't allow that...\n//\nvoid MouseRotate(int x, int y)\n{\n  int viewp[4];\n  //const double sensitiveness=0.1;\n  // 030129: Reducing sensitivity slightly.\n  //const double sensitiveness=0.05;\n  // 030302: Reducing sensitivity slightly more, for demo.\n  const double sensitiveness=0.02;\n\n  mouse_movement = mouse_movement || ((x!=last_x) || (y!=last_y));\n\n  //puts(\"MouseRotate\");\n  glGetIntegerv(GL_VIEWPORT, viewp);\n\ndraw_cursor(x, y);\n\n  if (!transversal_rotation(x, y, last_x, last_y))\n    rotate((x-last_x)*sensitiveness, (y-last_y)*sensitiveness, 0.0);\n  else\n    {\n      int s;\n\n      if (atan2(y-(viewp[1]+viewp[3])*0.5,\n\t\tx-(viewp[0]+viewp[2])*0.5)>\n\t  atan2(last_y-(viewp[1]+viewp[3])*0.5,\n\t\tlast_x-(viewp[0]+viewp[2])*0.5))\n\ts=-1;\n      else\n\ts=1;\n      \n      rotate(0.0, 0.0,\n\t     s*sqrt((double)(SQR(x-last_x)+SQR(y-last_y)))*sensitiveness);\n    }\n  \n  last_x0=last_x;\n  last_y0=last_y;\n  last_x=x;\n  last_y=y;\n}\n\n\n\n\n\n\nvoid MouseZoom(int x, int y)\n{\n  scale(1.0+(y-last_y)*0.01, 1.0+(y-last_y)*0.01, 1.0+(y-last_y)*0.01);\n  last_x=x;\n  last_y=y;\ndraw_cursor(x, y);\n}\n\n\n\n\n\n\nvoid MouseTranslate(int x, int y)\n{\n  translate(xtrans+(x-last_x)*0.01, ytrans-(y-last_y)*0.01, ztrans);\n  last_x=x;\n  last_y=y;\ndraw_cursor(x, y);\n}\n\n\n\n\n\n\nvoid Mouse(int butt, int state, int x, int y)\n{\n  //\n  // 990824: Forsoek paa aa emulere midterste tast vha. begge de to\n  //         paa PC...\n  //\n#ifdef MIDDLE_EMU\n  static int left_down=0, right_down=0;\n#endif\n  \n/*\n  printf(\"butt=%d state=%d x=%d y=%d \"\n\t \"last_x=%d last_y=%d last_x=%d last_y=%d\\n\",\n\t butt, state, x, y, last_x, last_y, last_x0, last_y0);\n#ifdef MIDDLE_EMU\n  printf(\"Left down=%d, right down=%d\\n\", left_down, right_down);\n#endif\n*/\n\n  if (state==GLUT_DOWN)\n    {\n      /* A fresh start, all \"last\" info to be discarded... */\n      last_x=x;\n      last_y=y;\n      last_x0=x;\n      last_y0=y;\n\n#ifdef MIDDLE_EMU\n      //\n      // 990824: Forsoek paa aa emulere midterste tast vha. begge de to\n      //         paa PC...\n      //\n      if (butt==GLUT_RIGHT_BUTTON)\n\t{\n\t  if (left_down)\n\t    butt=GLUT_MIDDLE_BUTTON;\n\t  right_down=1;\n\t}\n      else\n\tif (butt==GLUT_LEFT_BUTTON)\n\t  {\n\t    if (right_down)\n\t      butt=GLUT_MIDDLE_BUTTON;\n\t    left_down=1;\n\t  }\n\n      /*      if (((left_down) && (butt==GLUT_RIGHT_BUTTON)) ||\n\t  ((right_down) && (butt==GLUT_LEFT_BUTTON)))\n\t{\n\t  butt=GLUT_MIDDLE_BUTTON;\n\t  left_down=right_down=1;\n\t}*/\n#endif\n\n      switch (butt)\n\t{\n\tcase GLUT_LEFT_BUTTON:\n\t  xrot=0;\n\t  yrot=0;\n\t  zrot=0;\n#ifndef QTMODE\n\t  glutMotionFunc(MouseRotate);\n#else\n\t  // 030917: setting global variable so that new qt event handler\n\t  //         knows what to do.\n\t  extern bool enableMouseRotation;\n\t  enableMouseRotation=true;\n#endif\n\t  break;\n\tcase GLUT_MIDDLE_BUTTON:\n#ifndef QTMODE\n\t  glutMotionFunc(MouseZoom);\n#else\n\t  // 030918: setting global variable so that new qt event handler\n\t  //         knows what to do.\n\t  extern bool enableMouseZoom;\n\t  enableMouseZoom=true;\n#endif\n\t  break;\n\tcase GLUT_RIGHT_BUTTON:\n#ifndef QTMODE\n\t  glutMotionFunc(MouseTranslate);\n#else\n\t  // 030918: setting global variable so that new qt event handler\n\t  //         knows what to do.\n\t  extern bool enableMouseTranslate;\n\t  enableMouseTranslate=true;\n#endif\n\t  break;\n\t}\n    }\n  \n  if (state==GLUT_UP)\n    {\n\n#ifdef MIDDLE_EMU\n      if (butt==GLUT_LEFT_BUTTON)\n\tleft_down=0;\n      if (butt==GLUT_RIGHT_BUTTON)\n\tright_down=0;\n#endif\n#ifdef QTMODE\n      extern bool enableMouseRotation, enableMouseZoom, enableMouseTranslate;\n      enableMouseRotation=false;\n      enableMouseZoom=false;\n      enableMouseTranslate=false;\n#endif\n\n      //\n      // 020410: Introduced 'spin_speed', was 1 before, setting to 2.\n      //         There seems to be some confusion here as to whether\n      //         the ?rot-variables are ints or floats?!\n      // 040220: Reducing to 1, seems to be very unwieldy with the new\n      //         GF4 card...(?!)\n      // 040505: N med fx5900, 1.0 ser ut til  vre alt for mye for\n      //         endel bview2-greier. \n      //\n      //const double spin_speed=2.0;\n      //const double spin_speed=1.0;\n      const double spin_speed=0.1;\n      \n      //\n      // 991123: This was a stupid thing to do! We don't need to\n      //         disable this one! It's only active while the button\n      //         is pressed down, anyway!\n      //\n      // glutMotionFunc(MouseDummy);\n      if ((butt==GLUT_LEFT_BUTTON) &&\n\t  ((x-last_x0)*(x-last_x0)+(y-last_y0)*(y-last_y0)>4))\n\t{\n\t  if (!transversal_rotation(x, y, last_x0, last_y0))\n\t    {\n\t      xrot=(y-last_y0)*spin_speed;\n\t      yrot=(x-last_x0)*spin_speed;\n\t      /*\t      zrot=0;*/\n\t    }\n\t  else\n\t    {\n\t      int s;\n\t      int viewp[4];\n\n\t      glGetIntegerv(GL_VIEWPORT, viewp);\n\t      if (atan2(y-(viewp[1]+viewp[3])*0.5,\n\t\t\tx-(viewp[0]+viewp[2])*0.5)>\n\t\t  atan2(last_y0-(viewp[1]+viewp[3])*0.5,\n\t\t\tlast_x0-(viewp[0]+viewp[2])*0.5))\n\t\ts=-1;\n\t      else\n\t\ts=1;\n\t      \n\t      /*\t      xrot=0;\n\t      yrot=0;*/\n\t      zrot=(s*(int)(sqrt((double)(SQR(y-last_y0)+SQR(x-last_x0))))*\n\t\t    spin_speed);\n\t    }\n\t}\n    }\t  \n\n/*\n  printf(\"butt=%d state=%d x=%d y=%d \"\n\t \"last_x=%d last_y=%d last_x=%d last_y=%d\\n\",\n\t butt, state, x, y, last_x, last_y, last_x0, last_y0);\n#ifdef MIDDLE_EMU\n//  printf(\"Left down=%d, right down=%d\\n\", left_down, right_down);\n#endif\n  puts(\" \");\n*/\ndraw_cursor(x, y);\n}\n"
  },
  {
    "path": "viewer/src/sisl_aux.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#define DBGqqq\n#include <stdio.h>\n#include <ctype.h>\n#include <stdlib.h>\n\n#include \"sisl_aux.h\"\n#include \"aux2.h\"\n\n\n\n\n\n\n//----------------------------------------------------------------------\n//\n// 000817: Discretizing a surface for plotting by lowering the degree\n//         to 1 in both direction, so that we can plot the control\n//         polygon.\n// 000829: Oopps! s1968 doesn't do general degree lowering!\n//\n//----------------------------------------------------------------------\n\nvoid lower_degree_to_linear(SISLSurf **srf, double e)\n{\n  CRIT_ERR(puts(\"Not implemented.\"));\n}\n\n\n\n\n\n\n//----------------------------------------------------------------------\n//\n// 000817: Discretizing a surface for plotting by lowering the degree\n//         to 3 in both directions and inserting new knots, so that we\n//         can plot the control polygon with increased probability of\n//         plotting something that actually looks like the surface.\n//\n//----------------------------------------------------------------------\n\nvoid lower_degree_and_subdivide(SISLSurf **srf,\n\t\t\t\tint new_knots_per_interval,\n\t\t\t\tint max_number_of_knots)\n{\n\n\n//   printf(\"\\n\\n\\n ############# %d %d \\n\\n\\n\\n\\n\", new_knots_per_interval,\n// \t max_number_of_knots);\n\n  SISLSurf *tmp=*srf;\n  const double tol=1e-7;\n\n  if (tmp->idim!=3)\n    CRIT_ERR(puts(\"Dimension is supposed to be three.\"));\n  \n  double eeps[3];\n  eeps[0]=eeps[1]=eeps[2]=tol;\n\n  int nend[4];\n  nend[0]=nend[1]=nend[2]=nend[3]=2;\n\n  double edgeps[4*3];\n  {\n    int i;\n    \n    for (i=0; i<12; i++)\n      edgeps[i]=tol;\n  }\n\n  if ((tmp->ik1>4) || (tmp->ik2>4))\n    {\n      int stat;\n      \n      s1968(tmp, eeps, nend, tmp->cuopen_1, tmp->cuopen_2, edgeps, 3, 2,\n\t    srf, &stat);\n      if (stat!=0)\n\tCRIT_ERR(printf(\"s1968 returned %d.\\n\", stat));\n      freeSurf(tmp);\n    }\n\n  if (new_knots_per_interval==0)\n    return;\n\n  //\n  // Now, we insert new knots.\n  // 1. pick out distinct knots. 2. generate new knots. 3. insert.\n  //\n  tmp=*srf;\n\n  //\n  // 001101: From now on we use a different refinement value for each\n  //         parameter direction, and we also limit the number of knots.\n  //         NB! This could be done much more precise, but we'll go for the\n  //         quick and dirty solution.\n  int new_knots_per_interval1 = new_knots_per_interval;\n\n  if ((tmp->in1 - tmp->ik1 + 1) * new_knots_per_interval1 > max_number_of_knots) {\n      new_knots_per_interval1 = (int)(max_number_of_knots / (tmp->in1 - tmp->ik1 + 1));\n  }\n\n  int new_knots_per_interval2 = new_knots_per_interval;\n  \n  if ((tmp->in2 - tmp->ik2 + 1) * new_knots_per_interval2 > max_number_of_knots) {\n      new_knots_per_interval2 = (int)(max_number_of_knots / (tmp->in2 - tmp->ik2 + 1));\n  }\n\n  //\n  // Allocating space for *max* number of new knots. Note that all of\n  // it will be used only if we have no knots of multiplicity greater\n  // than one.\n  // @@@ Note! Looks like this code assumes k-multiple knots at the ends,\n  //     at least it looks like no new knots are inserted between the\n  //     k end-knots at either end...?!?! Should be fixed...\n  //\n  double *new_u=new double[(tmp->in1-tmp->ik1+1)*new_knots_per_interval1];\n  if (new_u==NULL)\n    CRIT_ERR(puts(\"Couldn't allocate memory for new knots.\"));\n  double *new_v=new double[(tmp->in2-tmp->ik2+1)*new_knots_per_interval2];\n  if (new_v==NULL)\n    CRIT_ERR(puts(\"Couldn't allocate memory for new knots.\"));\n\n  int new_u_knots, new_v_knots;\n  \n  // printf(\"New knots in direction 1:\");\n  {\n    int i, j, p;\n\n    for (i=0, p=0; i<tmp->in1-tmp->ik1+1; i++)\n      if (fabs(tmp->et1[tmp->ik1+i]-tmp->et1[tmp->ik1-1+i]) > 1e-12)\n\tfor (j=0; j<new_knots_per_interval1; j++, p++)\n\t  {\n\t    new_u[p]=(tmp->et1[tmp->ik1-1+i]+\n\t\t      (tmp->et1[tmp->ik1+i]-tmp->et1[tmp->ik1-1+i])/\n\t\t      (new_knots_per_interval1+1.0)*(j+1.0));\n\t    // printf(\" %f\", new_u[p]);\n\t  }\n    // printf(\"\\n\");\n    new_u_knots=p;\n  }\n\n  // printf(\"New knots in direction 2:\");\n  {\n    int i, j, p;\n\n    for (i=0, p=0; i<tmp->in2-tmp->ik2+1; i++)\n      if (fabs(tmp->et2[tmp->ik2+i]-tmp->et2[tmp->ik2-1+i]) > 1e-12)\n\tfor (j=0; j<new_knots_per_interval2; j++, p++)\n\t  {\n\t    new_v[p]=(tmp->et2[tmp->ik2-1+i]+\n\t\t      (tmp->et2[tmp->ik2+i]-tmp->et2[tmp->ik2-1+i])/\n\t\t      (new_knots_per_interval2+1.0)*(j+1.0));\n\t    // printf(\" %f\", new_v[p]);\n\t  }\n    // printf(\"\\n\");\n    new_v_knots=p;\n  }\n\n  {\n    int stat;\n\n    s1025(tmp, new_u, new_u_knots, new_v, new_v_knots, srf, &stat);\n    if (stat!=0)\n      CRIT_ERR(printf(\"s1025 returned %d.\\n\", stat));\n  }\n\n  freeSurf(tmp);\n  delete new_u;\n  delete new_v;\n}\n\n\n\n\n\n\n//----------------------------------------------------------------------\n//\n// 000828: Evaluating normals in all knot-pairs. If degree is linear in\n//         both directions, what will it produce?\n//\n// ngrid: (Pointer to) array of 3*n1*n2 doubles containing normals. Layout:\n//        n1 normals for smallest second parameter value, then n1 for\n//        next second parameter value and so on. n1 and n2 are the numbers\n//        of control vertices in first and second parameter direction,\n//        respectively. The normals are evaluated in the parameters\n//\n//          ts_i = (t_{i+1} + ... + t_{i+d})/d. \n//\n//----------------------------------------------------------------------\n\nvoid compute_surface_normals(SISLSurf *srf, double **ngrid)\n{\n  if (srf->idim!=3)\n    CRIT_ERR(puts(\"This should be a 3d surface.\"));\n\n  *ngrid=new double[3*(srf->in1)*(srf->in2)];\n\n  int i, j, left1=0, left2=0;\n  \n  for (i=0; i<srf->in2; i++)\n    for (j=0; j<srf->in1; j++)\n      {\n\tdouble par[2];\n\t{\n\t  int k;\n\t  \n\t  par[0]=0.0;\n\t  for (k=1; k<srf->ik1; k++)\n\t    par[0]+=srf->et1[j+k];\n\t  par[0]/=(srf->ik1-1.0);\n\n\t  par[1]=0.0;\n\t  for (k=1; k<srf->ik2; k++)\n\t    par[1]+=srf->et2[i+k];\n\t  par[1]/=(srf->ik2-1.0);\n\t}\n\n\tdouble der[9];\n\tdouble norm[3];\n\t\n\tint stat;\n\ts1421(srf, 1, par, &left1, &left2, der, norm, &stat);\n\tif (stat!=0)\n\t  {\n\t    printf(\"s1421 returned %d.\\n\"\n\t\t   \" (\"\"Surface is degenerate at the point, normal has \"\n\t\t   \"zero length\"\")\\n\", stat);\n\t    printf(\"Trying to continue anyway.\\n\");\n\t    printf(\"Location: %s:%d\\n\", __FILE__, __LINE__);\n\t    norm[0]=norm[1]=norm[2]=1.0;\n\t  }\n\n\tdouble l=s6length(norm, 3, &stat);\n\tif (stat==0)\n\t  CRIT_ERR(printf(\"s6length-vector had length 0.\\n\"));\n\n\tint k;\n\tfor (k=0; k<3; k++)\n\t  (*ngrid)[3*(i*(srf->in1)+j) + k]=norm[k]/l;\n      }\n}\n\n"
  },
  {
    "path": "viewer/src/transfutils.cpp",
    "content": "/*\n * Copyright (C) 1998, 2000-2007, 2010, 2011, 2012, 2013 SINTEF Digital,\n * Applied Mathematics, Norway.\n *\n * Contact information: E-mail: tor.dokken@sintef.no                      \n * SINTEF Digital, Department of Mathematics and Cybernetics,                         \n * P.O. Box 124 Blindern,                                                 \n * 0314 Oslo, Norway.                                                     \n *\n * This file is part of SISL.\n *\n * SISL is free software: you can redistribute it and/or modify\n * it under the terms of the GNU Affero General Public License as\n * published by the Free Software Foundation, either version 3 of the\n * License, or (at your option) any later version. \n *\n * SISL 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 Affero General Public License for more details.\n *\n * You should have received a copy of the GNU Affero General Public\n * License along with SISL. If not, see\n * <http://www.gnu.org/licenses/>.\n *\n * In accordance with Section 7(b) of the GNU Affero General Public\n * License, a covered work must retain the producer line in every data\n * file that is created or manipulated using SISL.\n *\n * Other Usage\n * You can be released from the requirements of the license by purchasing\n * a commercial license. Buying such a license is mandatory as soon as you\n * develop commercial activities involving the SISL library without\n * disclosing the source code of your own applications.\n *\n * This file may be used in accordance with the terms contained in a\n * written agreement between you and SINTEF Digital. \n */\n\n#include <GL/glut.h>\n#include <stdio.h>\n\n#include \"transfutils.h\"\n\n\n\n\n\n\n//\n// 990831: These are used for storing \"global\" rotations etc. It's convenient\n//         to do this with global variables, since the mouse callbacks can only\n//         take parameters fixed by glut...\n//\n// 980913: ztrans -6 makes the near clipping plane \"visible\", because it's\n//         at -5. ztrans -5 would fix this.\n//\ndouble xtrans=0.0, ytrans=0.0, ztrans=-6;\ndouble xrot_eps=5.0, yrot_eps=5.0, zrot_eps=5.0;\ndouble xscale=1.0, yscale=1.0, zscale=1.0;\ndouble xrot, yrot, zrot; // These are initialized in 'Mouse'.\n\n\n\n\n\n\nvoid rotate(double y_ang, double x_ang, double z_ang)\n{\n  float oldModelView[16];\n\n  if (y_ang)\n    {\n      glGetFloatv(GL_MODELVIEW_MATRIX, oldModelView);\n      glLoadIdentity();\n      glTranslated(xtrans, ytrans, ztrans);\n      glRotated(y_ang*yrot_eps, 0.0, 1.0, 0.0);\n      glTranslated(-xtrans, -ytrans, -ztrans);\n      glMultMatrixf(oldModelView);\n    }\n  \n  if (x_ang)\n    {\n      glGetFloatv(GL_MODELVIEW_MATRIX, oldModelView);\n      glLoadIdentity();\n      glTranslated(xtrans, ytrans, ztrans);\n      glRotated(x_ang*xrot_eps, 1.0, 0.0, 0.0);\n      glTranslated(-xtrans, -ytrans, -ztrans);\n      glMultMatrixf(oldModelView);\n    }\n\n  if (z_ang)\n    {\n      glGetFloatv(GL_MODELVIEW_MATRIX, oldModelView);\n      glLoadIdentity();\n      glTranslated(xtrans, ytrans, ztrans);\n      glRotated(z_ang*zrot_eps, 0.0, 0.0, 1.0);\n      glTranslated(-xtrans, -ytrans, -ztrans);\n      glMultMatrixf(oldModelView);\n    }\n}\n\n\n\n\n\n\nvoid translate(double x, double y, double z)\n{\n  float oldModelView[16];\n\n  glGetFloatv(GL_MODELVIEW_MATRIX, oldModelView);\n  glLoadIdentity();\n  glTranslated(x, y, z);\n  glTranslated(-xtrans, -ytrans, -ztrans);\n  xtrans=x;\n  ytrans=y;\n  ztrans=z;\n  glMultMatrixf(oldModelView);\n}\n\n\n\n\n\n\nvoid scale(double x, double y, double z)\n{\n  glScaled(x, y, z);\n  xscale*=x;\n  yscale*=y;\n  zscale*=z;\n}\n"
  }
]